mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-11 20:15:04 -05:00
fixed issues with switching back to previous keyboard
improved preferences for switch keyboard on rooted. now allowing to switch to KP2A when entry opened (in any case)
This commit is contained in:
parent
f9a7d66e8e
commit
b61904c01c
@ -97,14 +97,6 @@
|
||||
android:dependency="kp2a_simple_keyboard"
|
||||
/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="kp2a_switch_on_sendgodone"
|
||||
android:title="@string/kp2a_switch_on_sendgodone"
|
||||
android:summary="@string/kp2a_switch_on_sendgodone_summary"
|
||||
android:persistent="true"
|
||||
android:defaultValue="false"
|
||||
android:dependency="kp2a_simple_keyboard"
|
||||
/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
@ -76,7 +76,10 @@ import java.util.Map;
|
||||
public class KP2AKeyboard extends InputMethodService
|
||||
implements LatinKeyboardBaseView.OnKeyboardActionListener,
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String KEEPASS2ANDROID_KEYBOARD_CLEARED = "keepass2android.keyboard_cleared";
|
||||
private static String get_KEEPASS2ANDROID_KEYBOARD_CLEARED(Context ctx)
|
||||
{
|
||||
return ctx.getPackageName()+".keyboard_cleared";
|
||||
}
|
||||
private static final String KP2A_SAVED_FIELD_HINTS = "savedFieldHints";
|
||||
private static final String PREF_KP2A_REMEMBER_AUTO_FILL = "kp2a_remember_auto_fill";
|
||||
private static final String TAG = "LatinIME";
|
||||
@ -289,13 +292,17 @@ public class KP2AKeyboard extends InputMethodService
|
||||
public class ClearKeyboardBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
android.util.Log.d("KP2AK", "received clear keyboard broadcast");
|
||||
mShowKp2aKeyboard = false;
|
||||
updateKeyboardMode(getCurrentInputEditorInfo());
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean switchback = sp.getBoolean("AutoSwitchBackKeyboard_key", true);
|
||||
if (switchback)
|
||||
{
|
||||
//switch back, but only "silently" (i.e. if automatic switching is enabled and available)
|
||||
keepass2android.kbbridge.ImeSwitcher.switchToPreviousKeyboard(KP2AKeyboard.this, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -359,7 +366,8 @@ public class KP2AKeyboard extends InputMethodService
|
||||
mHadKp2aData = mShowKp2aKeyboard = keepass2android.kbbridge.KeyboardData.hasData();
|
||||
|
||||
mClearKeyboardReceiver = new ClearKeyboardBroadcastReceiver();
|
||||
registerReceiver(mClearKeyboardReceiver, new IntentFilter(KEEPASS2ANDROID_KEYBOARD_CLEARED));
|
||||
registerReceiver(mClearKeyboardReceiver, new IntentFilter(get_KEEPASS2ANDROID_KEYBOARD_CLEARED(this)));
|
||||
android.util.Log.d("KP2AK", "registered receiver for clear keyboard broadcast: "+get_KEEPASS2ANDROID_KEYBOARD_CLEARED(this));
|
||||
|
||||
}
|
||||
|
||||
|
2288
src/keepass2android/Resources/Resource.designer.cs
generated
2288
src/keepass2android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -84,6 +84,7 @@
|
||||
<string name="display_prefs_key">display_prefs_key</string>
|
||||
<string name="QuickUnlock_prefs_key">QuickUnlock_prefs_key</string>
|
||||
<string name="FileHandling_prefs_key">FileHandling_prefs_key</string>
|
||||
<string name="keyboardswitch_prefs_key">keyboardswitch_prefs_key</string>
|
||||
|
||||
<string name="QuickUnlockDefaultEnabled_key">Enable_QuickUnlock_by_default</string>
|
||||
<string name="QuickUnlockLength_key">QuickUnlockLength</string>
|
||||
@ -96,7 +97,7 @@
|
||||
|
||||
<string name="UseFileTransactions_key">UseFileTransactions</string>
|
||||
<string name="LockWhenScreenOff_key">LockWhenScreenOff</string>
|
||||
<string name="LockWhenNavigateBack_key">LockWhenNavigateBack</string>
|
||||
<string name="LockWhenNavigateBack_key">kp2a_switch_rootedLockWhenNavigateBack</string>
|
||||
|
||||
<string name="NoDonateOption_key">NoDonateOption</string>
|
||||
|
||||
@ -119,6 +120,12 @@
|
||||
<string name="OpenKp2aKeyboardAutomatically_key">OpenKp2aKeyboardAutomatically</string>
|
||||
<bool name="OpenKp2aKeyboardAutomatically_default">true</bool>
|
||||
|
||||
<string name="OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key">OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key</string>
|
||||
<bool name="OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_default">false</bool>
|
||||
|
||||
<string name="AutoSwitchBackKeyboard_key">AutoSwitchBackKeyboard_key</string>
|
||||
<bool name="AutoSwitchBackKeyboard_default">true</bool>
|
||||
|
||||
<string name="clipboard_timeout_default">300000</string>
|
||||
<string-array name="clipboard_timeout_values">
|
||||
<item>30000</item>
|
||||
|
@ -43,6 +43,7 @@
|
||||
<string name="export_prefs">Export database...</string>
|
||||
<string name="import_db_prefs">Import database to internal folder</string>
|
||||
<string name="import_keyfile_prefs">Import key file to internal folder</string>
|
||||
<string name="keyboardswitch_prefs">Keyboard switching</string>
|
||||
<string name="OnlyAvailableForLocalFiles">Only available for local files.</string>
|
||||
<string name="FileIsInInternalDirectory">File is stored in internal directory.</string>
|
||||
<string name="DatabaseFileMoved">Database file was copied to internal folder. Press Ok to open from the new location. Note: Do not forget to regularly export the database to a safe storage!</string>
|
||||
@ -303,7 +304,13 @@
|
||||
<string name="OpenKp2aKeyboardAutomatically_summary">Open keyboard selection dialog when entry is available through KP2A keyboard after search from the browser.</string>
|
||||
|
||||
<string name="kp2a_switch_rooted">Auto-switch on rooted devices</string>
|
||||
<string name="kp2a_switch_rooted_summary">On rooted devices, it is possible to automatically switch to the Keepass2Android keyboard (after search for an entry or by clicking the KP2A keyboard notification) and to switch back to the previous keyboard without showing the Input method picker. This also requires to install the Secure Settings app. See the KP2A documentation for more information!</string>
|
||||
<string name="kp2a_switch_rooted_summary">Automatically switch to KP2A keyboard when entry is opened. Requires root and the Secure Settings app with System+. </string>
|
||||
|
||||
<string name="OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_title">Auto-switch only after search</string>
|
||||
<string name="OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_summary">Only automatically switch to KP2A keyboard after using the Share URL function (but not when opening an entry in another way)</string>
|
||||
|
||||
<string name="AutoSwitchBackKeyboard_title">Keyboard switch back</string>
|
||||
<string name="AutoSwitchBackKeyboard_summary">Switch back to previous keyboard when no entry is opened.</string>
|
||||
|
||||
<string name="ShowUnlockedNotification_title">Notification icon while unlocked</string>
|
||||
<string name="ShowUnlockedNotification_summary">Show a notification icon while the database is unlocked.</string>
|
||||
|
@ -214,22 +214,58 @@
|
||||
android:defaultValue="@bool/UseKp2aKeyboard_default"
|
||||
android:title="@string/ShowKp2aKeyboardNotification_title"
|
||||
android:key="@string/UseKp2aKeyboard_key" />
|
||||
<CheckBoxPreference
|
||||
android:enabled="true"
|
||||
android:persistent="true"
|
||||
android:summary="@string/OpenKp2aKeyboardAutomatically_summary"
|
||||
android:defaultValue="@bool/OpenKp2aKeyboardAutomatically_default"
|
||||
android:title="@string/OpenKp2aKeyboardAutomatically_title"
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="@string/keyboardswitch_prefs_key"
|
||||
android:title="@string/keyboardswitch_prefs"
|
||||
android:dependency="@string/UseKp2aKeyboard_key"
|
||||
android:key="@string/OpenKp2aKeyboardAutomatically_key" />
|
||||
|
||||
>
|
||||
<CheckBoxPreference
|
||||
android:key="kp2a_switch_rooted"
|
||||
android:title="@string/kp2a_switch_rooted"
|
||||
android:summary="@string/kp2a_switch_rooted_summary"
|
||||
android:persistent="true"
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/UseKp2aKeyboard_key"
|
||||
/>
|
||||
|
||||
|
||||
<!-- no autoswitch on root only-->
|
||||
<CheckBoxPreference
|
||||
android:enabled="true"
|
||||
android:persistent="true"
|
||||
android:summary="@string/OpenKp2aKeyboardAutomatically_summary"
|
||||
android:defaultValue="@bool/OpenKp2aKeyboardAutomatically_default"
|
||||
android:title="@string/OpenKp2aKeyboardAutomatically_title"
|
||||
android:key="@string/OpenKp2aKeyboardAutomatically_key" />
|
||||
|
||||
<!-- autoswitch on root only-->
|
||||
<CheckBoxPreference
|
||||
android:enabled="true"
|
||||
android:persistent="true"
|
||||
android:summary="@string/OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_summary"
|
||||
android:defaultValue="@bool/OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_default"
|
||||
android:title="@string/OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_title"
|
||||
android:key="@string/OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:enabled="true"
|
||||
android:persistent="true"
|
||||
android:summary="@string/AutoSwitchBackKeyboard_summary"
|
||||
android:defaultValue="@bool/AutoSwitchBackKeyboard_default"
|
||||
android:title="@string/AutoSwitchBackKeyboard_title"
|
||||
android:key="@string/AutoSwitchBackKeyboard_key" />
|
||||
|
||||
<!-- with and without autoswitch on root-->
|
||||
<CheckBoxPreference
|
||||
android:key="kp2a_switch_on_sendgodone"
|
||||
android:title="@string/kp2a_switch_on_sendgodone"
|
||||
android:summary="@string/kp2a_switch_on_sendgodone_summary"
|
||||
android:persistent="true"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
|
||||
</PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
android:key="@string/QuickUnlock_prefs_key"
|
||||
|
@ -266,6 +266,17 @@ namespace keepass2android
|
||||
_numElementsToWaitFor++;
|
||||
_notificationManager.Notify(NotifyKeyboard, keyboard);
|
||||
|
||||
if (prefs.GetBoolean("kp2a_switch_rooted", false))
|
||||
{
|
||||
//switch rooted
|
||||
bool onlySwitchOnSearch = prefs.GetBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key), false);
|
||||
if (closeAfterCreate || (!onlySwitchOnSearch))
|
||||
{
|
||||
ActivateKp2aKeyboard();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//if the app is about to be closed again (e.g. after searching for a URL and returning to the browser:
|
||||
// automatically bring up the Keyboard selection dialog
|
||||
if ((closeAfterCreate) && prefs.GetBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomatically_key), Resources.GetBoolean(Resource.Boolean.OpenKp2aKeyboardAutomatically_default)))
|
||||
@ -276,6 +287,8 @@ namespace keepass2android
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((!hasKeyboardDataNow) && (hadKeyboardData))
|
||||
{
|
||||
ClearKeyboard(true); //this clears again and then (this is the point) broadcasts that we no longer have keyboard data
|
||||
|
@ -32,6 +32,7 @@ namespace keepass2android
|
||||
public class AppSettingsActivity : LockingPreferenceActivity
|
||||
{
|
||||
private ActivityDesign _design;
|
||||
private KeyboardSwitchPrefManager _switchPrefManager;
|
||||
|
||||
public AppSettingsActivity()
|
||||
{
|
||||
@ -113,6 +114,81 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
FindPreference(GetString(Resource.String.db_key)).Enabled = false;
|
||||
//PrepareKeyboardSwitchingPreferences(this);
|
||||
_switchPrefManager = new KeyboardSwitchPrefManager(this);
|
||||
|
||||
}
|
||||
|
||||
public class KeyboardSwitchPrefManager
|
||||
{
|
||||
private readonly PreferenceActivity _act;
|
||||
private CheckBoxPreference _switchPref;
|
||||
private CheckBoxPreference _openKp2aAutoPref;
|
||||
private CheckBoxPreference _openOnlyOnSearchPref;
|
||||
private CheckBoxPreference _switchBackPref;
|
||||
private PreferenceScreen _screen;
|
||||
|
||||
public KeyboardSwitchPrefManager(PreferenceActivity act)
|
||||
{
|
||||
this._act = act;
|
||||
|
||||
_switchPref = (CheckBoxPreference)_act.FindPreference("kp2a_switch_rooted");
|
||||
_openKp2aAutoPref =
|
||||
(CheckBoxPreference)act.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomatically_key));
|
||||
_openOnlyOnSearchPref =
|
||||
(CheckBoxPreference)
|
||||
act.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key));
|
||||
_switchBackPref =
|
||||
(CheckBoxPreference)act.FindPreference(act.GetString(Resource.String.AutoSwitchBackKeyboard_key));
|
||||
_screen = (PreferenceScreen)act.FindPreference(act.GetString(Resource.String.keyboardswitch_prefs_key));
|
||||
EnableSwitchPreferences(_switchPref.Checked);
|
||||
|
||||
_switchPref.PreferenceChange += (sender, args) =>
|
||||
{
|
||||
bool switchOnRooted = (bool)args.NewValue;
|
||||
EnableSwitchPreferences(switchOnRooted);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private void EnableSwitchPreferences(bool switchOnRooted)
|
||||
{
|
||||
if (!switchOnRooted)
|
||||
{
|
||||
if (_act.FindPreference(_act.GetString(Resource.String.OpenKp2aKeyboardAutomatically_key)) == null)
|
||||
{
|
||||
_screen.AddPreference(_openKp2aAutoPref);
|
||||
}
|
||||
if (_act.FindPreference(_act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key)) != null)
|
||||
{
|
||||
_screen.RemovePreference(_openOnlyOnSearchPref);
|
||||
}
|
||||
if (_act.FindPreference(_act.GetString(Resource.String.AutoSwitchBackKeyboard_key)) != null)
|
||||
{
|
||||
_screen.RemovePreference(_switchBackPref);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_act.FindPreference(_act.GetString(Resource.String.OpenKp2aKeyboardAutomatically_key)) != null)
|
||||
{
|
||||
_screen.RemovePreference(_openKp2aAutoPref);
|
||||
}
|
||||
if (_act.FindPreference(_act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key)) == null)
|
||||
{
|
||||
_screen.AddPreference(_openOnlyOnSearchPref);
|
||||
}
|
||||
if (_act.FindPreference(_act.GetString(Resource.String.AutoSwitchBackKeyboard_key)) == null)
|
||||
{
|
||||
_screen.AddPreference(_switchBackPref);
|
||||
}
|
||||
}
|
||||
/*_openKp2aAutoPref.Enabled = !switchOnRooted;
|
||||
|
||||
_openOnlyOnSearchPref.Enabled = switchOnRooted;
|
||||
|
||||
_switchBackPref.Enabled = switchOnRooted;*/
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDesignChange(object sender, Preference.PreferenceChangeEventArgs preferenceChangeEventArgs)
|
||||
|
@ -39,6 +39,7 @@ namespace keepass2android
|
||||
public class DatabaseSettingsActivity : LockingClosePreferenceActivity
|
||||
{
|
||||
private ActivityDesign _design;
|
||||
private AppSettingsActivity.KeyboardSwitchPrefManager _switchPrefManager;
|
||||
|
||||
public DatabaseSettingsActivity()
|
||||
{
|
||||
@ -182,6 +183,8 @@ namespace keepass2android
|
||||
|
||||
UpdateImportDbPref();
|
||||
UpdateImportKeyfilePref();
|
||||
//AppSettingsActivity.PrepareKeyboardSwitchingPreferences(this);
|
||||
_switchPrefManager = new AppSettingsActivity.KeyboardSwitchPrefManager(this);
|
||||
}
|
||||
|
||||
private void UpdateImportKeyfilePref()
|
||||
|
Loading…
Reference in New Issue
Block a user