From f142f01c920c22cc01f31d5e08c298a6fa4e3fe0 Mon Sep 17 00:00:00 2001 From: Oleksandr Tyshkovets Date: Fri, 1 Aug 2014 18:15:43 +0300 Subject: [PATCH 01/68] Added passcode settings --- app/res/values/strings.xml | 6 ++ app/res/xml/fragment_passcode_preferences.xml | 29 +++++++ app/res/xml/preference_headers.xml | 2 + .../org/gnucash/android/ui/UxArgument.java | 10 +++ .../settings/PasscodePreferenceFragment.java | 78 +++++++++++++++++++ 5 files changed, 125 insertions(+) create mode 100755 app/res/xml/fragment_passcode_preferences.xml create mode 100644 app/src/org/gnucash/android/ui/settings/PasscodePreferenceFragment.java diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index 786e173b1..41217efb1 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -453,6 +453,12 @@ app_license Select Account There are no transactions available to export + Passcode + Passcode Preferences + enable_passcode + Turn On/Off Passcode + Change Passcode + change_passcode about_gnucash About GnuCash Gnucash is a mobile finance expense tracker application for Android.\n diff --git a/app/res/xml/fragment_passcode_preferences.xml b/app/res/xml/fragment_passcode_preferences.xml new file mode 100755 index 000000000..09484fe9f --- /dev/null +++ b/app/res/xml/fragment_passcode_preferences.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/res/xml/preference_headers.xml b/app/res/xml/preference_headers.xml index 88cc6c0f6..b85596715 100644 --- a/app/res/xml/preference_headers.xml +++ b/app/res/xml/preference_headers.xml @@ -21,6 +21,8 @@ android:title="@string/header_account_settings" />
+
diff --git a/app/src/org/gnucash/android/ui/UxArgument.java b/app/src/org/gnucash/android/ui/UxArgument.java index 8d97baf3a..abff1fa77 100644 --- a/app/src/org/gnucash/android/ui/UxArgument.java +++ b/app/src/org/gnucash/android/ui/UxArgument.java @@ -48,6 +48,16 @@ public final class UxArgument { */ public static final String PARENT_ACCOUNT_ID = "parent_account_id"; + /** + * Key for checking whether the passcode is enabled or not. + */ + public static final String ENABLED_PASSCODE = "enabled_passcode"; + + /** + * Key for storing the passcode. + */ + public static final String PASSCODE = "passcode"; + /** * Amount passed as a string */ diff --git a/app/src/org/gnucash/android/ui/settings/PasscodePreferenceFragment.java b/app/src/org/gnucash/android/ui/settings/PasscodePreferenceFragment.java new file mode 100644 index 000000000..ac6364f1d --- /dev/null +++ b/app/src/org/gnucash/android/ui/settings/PasscodePreferenceFragment.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014 Oleksandr Tyshkovets + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gnucash.android.ui.settings; + +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.PreferenceFragment; +import android.preference.PreferenceManager; + +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockPreferenceActivity; + +import org.gnucash.android.R; +import org.gnucash.android.ui.UxArgument; + +/** + * Fragment for configuring passcode to the application + * @author Oleksandr Tyshkovets + */ +public class PasscodePreferenceFragment extends PreferenceFragment { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.fragment_passcode_preferences); + + ActionBar actionBar = ((SherlockPreferenceActivity) getActivity()).getSupportActionBar(); + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setTitle(R.string.title_passcode_preferences); + } + + @Override + public void onResume() { + super.onResume(); + + final SharedPreferences.Editor editor = PreferenceManager + .getDefaultSharedPreferences(getActivity().getApplicationContext()).edit(); + + final String keyEnablePasscode = getString(R.string.key_enable_passcode); + findPreference(keyEnablePasscode) + .setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + editor.putBoolean(UxArgument.ENABLED_PASSCODE, (Boolean) newValue); + editor.commit(); + return true; + } + }); + findPreference(getString(R.string.key_change_passcode)) + .setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + editor.putString(UxArgument.PASSCODE, newValue.toString()); + editor.commit(); + return true; + } + }); + + } + +} From d95acf960cbd4e4d46193c11e27f8be945c1d7a3 Mon Sep 17 00:00:00 2001 From: Oleksandr Tyshkovets Date: Sat, 2 Aug 2014 21:25:24 +0300 Subject: [PATCH 02/68] Added passcode lock screen --- CONTRIBUTORS | 1 + app/AndroidManifest.xml | 9 +- app/res/layout/passcode_lockscreen.xml | 37 ++++++++ app/res/values/strings.xml | 3 + .../passcode/PasscodeLockScreenActivity.java | 93 +++++++++++++++++++ 5 files changed, 141 insertions(+), 2 deletions(-) create mode 100755 app/res/layout/passcode_lockscreen.xml create mode 100644 app/src/org/gnucash/android/ui/passcode/PasscodeLockScreenActivity.java diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a33fd3cc2..b99b83849 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -16,4 +16,5 @@ Nicolas Barranger Sigurd Gartmann Pedro Abel windwarrior +Oleksandr Tyshkovets Lei Xiao Bao \ No newline at end of file diff --git a/app/AndroidManifest.xml b/app/AndroidManifest.xml index 84a8fc427..78d468aa6 100644 --- a/app/AndroidManifest.xml +++ b/app/AndroidManifest.xml @@ -48,13 +48,18 @@ android:label="@string/app_name" android:theme="@style/Theme.Sherlock.Light.DarkActionBar"> + android:name=".ui.passcode.PasscodeLockScreenActivity" + android:noHistory="true" + android:windowSoftInputMode="stateAlwaysVisible"> + + diff --git a/app/res/layout/passcode_lockscreen.xml b/app/res/layout/passcode_lockscreen.xml new file mode 100755 index 000000000..cf92b3328 --- /dev/null +++ b/app/res/layout/passcode_lockscreen.xml @@ -0,0 +1,37 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index 41217efb1..c475d5176 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -27,6 +27,9 @@ Account name Cancel Save + Enter Passcode + Wrong passcode, please try again + You didn’t enter the full passcode Description Amount New transaction diff --git a/app/src/org/gnucash/android/ui/passcode/PasscodeLockScreenActivity.java b/app/src/org/gnucash/android/ui/passcode/PasscodeLockScreenActivity.java new file mode 100644 index 000000000..17fafdb6b --- /dev/null +++ b/app/src/org/gnucash/android/ui/passcode/PasscodeLockScreenActivity.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2014 Oleksandr Tyshkovets + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gnucash.android.ui.passcode; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.widget.EditText; +import android.widget.Toast; + +import org.gnucash.android.R; +import org.gnucash.android.ui.UxArgument; +import org.gnucash.android.ui.account.AccountsActivity; + +/** + * Activity for displaying and managing the passcode lock screen. + * @author Oleksandr Tyshkovets + */ +public class PasscodeLockScreenActivity extends Activity { + + private static final String TAG = "PasscodeLockScreenActivity"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.passcode_lockscreen); + + final SharedPreferences sharedPreferences = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()); + + if (!sharedPreferences.getBoolean(UxArgument.ENABLED_PASSCODE, false)) { + startActivity(new Intent(this, AccountsActivity.class)); + } + + final EditText passcodeEditText = (EditText) findViewById(R.id.passcode); + passcodeEditText.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable editable) { + String pass = editable.toString(); + String passcode = sharedPreferences.getString(UxArgument.PASSCODE, ""); + Log.d(TAG, passcode); + if (pass.length() == 4) { + if (pass.equals(passcode)) { + startActivity(new Intent(getApplicationContext(), AccountsActivity.class)); + } else { + Toast.makeText(getApplicationContext(), + R.string.toast_wrong_passcode, Toast.LENGTH_SHORT).show(); + passcodeEditText.getText().clear(); + } + } + } + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {} + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) {} + }); + + passcodeEditText.setOnKeyListener(new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + if ((event.getAction() == KeyEvent.ACTION_DOWN) + && (keyCode == KeyEvent.KEYCODE_ENTER)) { + Toast.makeText(getApplicationContext(), + R.string.toast_enter_full_passcode, Toast.LENGTH_LONG).show(); + } + return false; + } + }); + + } + +} From 177e8cb3f0567b61908a91d3bf1b918c9837ab60 Mon Sep 17 00:00:00 2001 From: Oleksandr Tyshkovets Date: Tue, 5 Aug 2014 21:13:30 +0300 Subject: [PATCH 03/68] Added soft numeric keyboard --- app/res/drawable-mdpi/clear_btn.png | Bin 0 -> 1650 bytes app/res/layout/fragment_numeric_keyboard.xml | 227 ++++++++++++++++++ .../android/ui/passcode/KeyboardFragment.java | 188 +++++++++++++++ 3 files changed, 415 insertions(+) create mode 100644 app/res/drawable-mdpi/clear_btn.png create mode 100644 app/res/layout/fragment_numeric_keyboard.xml create mode 100644 app/src/org/gnucash/android/ui/passcode/KeyboardFragment.java diff --git a/app/res/drawable-mdpi/clear_btn.png b/app/res/drawable-mdpi/clear_btn.png new file mode 100644 index 0000000000000000000000000000000000000000..bc3b9850767f7639000c4b33320a0ba96af90a9d GIT binary patch literal 1650 zcmV-&295cNP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raEqj|Hn*v_0vLD6*JUm7SztHtPShSG9O$p? w4#Zi@eh(-4n)N7f$aj_9xuNW#9_k_Z2Nj`H7y<$RE&u=k07*qoM6N<$f}s-MzW@LL literal 0 HcmV?d00001 diff --git a/app/res/layout/fragment_numeric_keyboard.xml b/app/res/layout/fragment_numeric_keyboard.xml new file mode 100644 index 000000000..869a455b2 --- /dev/null +++ b/app/res/layout/fragment_numeric_keyboard.xml @@ -0,0 +1,227 @@ + + + + + + + + +