automatically bring up keyboard selection

This commit is contained in:
Philipp Crocoll 2013-05-22 06:37:59 +02:00
parent 26064a0327
commit 7c292ebd57
4 changed files with 146 additions and 48 deletions

View File

@ -2,26 +2,36 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.296
// Laufzeitversion:4.0.30319.18033
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: Android.Runtime.ResourceDesignerAttribute("KeePassLib2Android.Resource", IsApplication=false)]
[assembly: global::Android.Runtime.ResourceDesignerAttribute("KeePassLib2Android.Resource", IsApplication=false)]
namespace KeePassLib2Android
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Novell.MonoDroid.Build.Tasks", "1.0.0.0")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{
static Resource()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
public partial class Attribute
{
static Attribute()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Attribute()
{
}
@ -33,6 +43,11 @@ namespace KeePassLib2Android
// aapt resource value: 0x7f020000
public static int library_name = 2130837504;
static String()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private String()
{
}

View File

@ -147,6 +147,7 @@ namespace keepass2android
Intent showNotIntent = new Intent(this, typeof(CopyToClipboardService));
Intent.SetAction(Intents.SHOW_NOTIFICATION);
showNotIntent.PutExtra(KEY_ENTRY, mEntry.Uuid.ToHexString());
showNotIntent.PutExtra(KEY_CLOSE_AFTER_CREATE, closeAfterCreate);
StartService(showNotIntent);

View File

@ -2,23 +2,28 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.296
// Laufzeitversion:4.0.30319.18033
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: Android.Runtime.ResourceDesignerAttribute("keepass2android.Resource", IsApplication=true)]
[assembly: global::Android.Runtime.ResourceDesignerAttribute("keepass2android.Resource", IsApplication=true)]
namespace keepass2android
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Novell.MonoDroid.Build.Tasks", "1.0.0.0")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{
static Resource()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
public static void UpdateIdValues()
{
KeePassLib2Android.Resource.String.library_name = keepass2android.Resource.String.library_name;
@ -39,6 +44,11 @@ namespace keepass2android
// aapt resource value: 0x7f040003
public const int anim_leave_back = 2130968579;
static Animation()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Animation()
{
}
@ -62,6 +72,11 @@ namespace keepass2android
// aapt resource value: 0x7f0a0001
public const int list_size_values = 2131361793;
static Array()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Array()
{
}
@ -70,6 +85,11 @@ namespace keepass2android
public partial class Attribute
{
static Attribute()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Attribute()
{
}
@ -102,6 +122,11 @@ namespace keepass2android
// aapt resource value: 0x7f090002
public const int sort_default = 2131296258;
static Boolean()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Boolean()
{
}
@ -152,6 +177,11 @@ namespace keepass2android
// aapt resource value: 0x7f06000c
public const int light_gray = 2131099660;
static Color()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Color()
{
}
@ -169,6 +199,11 @@ namespace keepass2android
// aapt resource value: 0x7f070000
public const int key_height = 2131165184;
static Dimension()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Dimension()
{
}
@ -504,6 +539,11 @@ namespace keepass2android
// aapt resource value: 0x7f02006c
public const int YellowButton = 2130837612;
static Drawable()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Drawable()
{
}
@ -1010,6 +1050,11 @@ namespace keepass2android
// aapt resource value: 0x7f0d0002
public const int version_title = 2131558402;
static Id()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Id()
{
}
@ -1123,6 +1168,11 @@ namespace keepass2android
// aapt resource value: 0x7f030022
public const int url_credentials = 2130903074;
static Layout()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Layout()
{
}
@ -1146,6 +1196,11 @@ namespace keepass2android
// aapt resource value: 0x7f0c0004
public const int password = 2131492868;
static Menu()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Menu()
{
}
@ -2012,6 +2067,11 @@ namespace keepass2android
// aapt resource value: 0x7f0800b1
public const int yes = 2131230897;
static String()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private String()
{
}
@ -2101,6 +2161,11 @@ namespace keepass2android
// aapt resource value: 0x7f0b000c
public const int WhiteOnDarkSmall = 2131427340;
static Style()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Style()
{
}
@ -2127,6 +2192,11 @@ namespace keepass2android
// aapt resource value: 0x7f050005
public const int symbols_shift = 2131034117;
static Xml()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Xml()
{
}

View File

@ -74,18 +74,12 @@ namespace keepass2android
Android.Util.Log.Debug("DEBUG","Received intent to provide access to entry");
String uuidBytes = intent.GetStringExtra(EntryActivity.KEY_ENTRY);
bool closeAfterCreate = intent.GetBooleanExtra(EntryActivity.KEY_CLOSE_AFTER_CREATE, false);
PwUuid entryId = PwUuid.Zero;
if (uuidBytes != null)
entryId = new KeePassLib.PwUuid(MemUtil.HexStringToByteArray(uuidBytes));
/*Android.Util.Log.Debug("DEBUG","Uuid="+uuidBytes);
foreach (PwUuid key in App.getDB().entries.Keys)
{
Android.Util.Log.Debug("DEBUG",key.ToHexString() + " -> " + App.getDB().entries[key].Uuid.ToHexString());
}*/
PwEntry entry;
try
{
@ -98,7 +92,7 @@ namespace keepass2android
return StartCommandResult.NotSticky;
}
displayAccessNotifications(entry);
displayAccessNotifications(entry, closeAfterCreate);
return StartCommandResult.RedeliverIntent;
@ -143,7 +137,7 @@ namespace keepass2android
return PendingIntent.GetBroadcast(this, requestCode, intent, PendingIntentFlags.CancelCurrent);
}
public void displayAccessNotifications(PwEntry entry)
public void displayAccessNotifications(PwEntry entry, bool closeAfterCreate)
{
// Notification Manager
mNM = (NotificationManager)GetSystemService(NotificationService);
@ -190,6 +184,13 @@ namespace keepass2android
keyboard.DeleteIntent = createDeleteIntent(NOTIFY_KEYBOARD);
mNumElementsToWaitFor++;
mNM.Notify(NOTIFY_KEYBOARD, keyboard);
//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)
{
ActivateKp2aKeyboard(this);
}
}
}
@ -347,7 +348,6 @@ namespace keepass2android
class CopyToClipboardBroadcastReceiver: BroadcastReceiver
{
CopyToClipboardService mService;
@ -379,39 +379,10 @@ namespace keepass2android
}
} else if (action.Equals(Intents.CHECK_KEYBOARD))
{
string currentIme = Android.Provider.Settings.Secure.GetString(
mService.ContentResolver,
Android.Provider.Settings.Secure.DefaultInputMethod);
string kp2aIme = mService.PackageName+"/keepass2android.softkeyboard.KP2AKeyboard";
InputMethodManager imeManager = (InputMethodManager)mService.ApplicationContext.GetSystemService(Context.InputMethodService);
if (currentIme == kp2aIme)
{
imeManager.ToggleSoftInput(ShowSoftInputFlags.Explicit, HideSoftInputFlags.None);
return;
CopyToClipboardService.ActivateKp2aKeyboard(mService);
}
}
IList<InputMethodInfo> inputMethodProperties = imeManager.EnabledInputMethodList;
if (!inputMethodProperties.Any(imi => imi.Id.Equals(kp2aIme)))
{
Toast.MakeText(mService, Resource.String.please_activate_keyboard, ToastLength.Long).Show();
Intent settingsIntent = new Intent(Android.Provider.Settings.ActionInputMethodSettings);
settingsIntent.SetFlags(ActivityFlags.NewTask);
mService.StartActivity(settingsIntent);
}
else
{
if (imeManager != null) {
imeManager.ShowInputMethodPicker();
} else {
Toast.MakeText(mService, Resource.String.not_possible_im_picker, ToastLength.Long).Show();
}
}
}
}
};
class NotificationDeletedBroadcastReceiver: BroadcastReceiver
@ -432,6 +403,47 @@ namespace keepass2android
}
#endregion
}
internal static void ActivateKp2aKeyboard(CopyToClipboardService service)
{
string currentIme = Android.Provider.Settings.Secure.GetString(
service.ContentResolver,
Android.Provider.Settings.Secure.DefaultInputMethod);
string kp2aIme = service.PackageName + "/keepass2android.softkeyboard.KP2AKeyboard";
InputMethodManager imeManager = (InputMethodManager)service.ApplicationContext.GetSystemService(Context.InputMethodService);
if (currentIme == kp2aIme)
{
imeManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.None);
}
else
{
IList<InputMethodInfo> inputMethodProperties = imeManager.EnabledInputMethodList;
if (!inputMethodProperties.Any(imi => imi.Id.Equals(kp2aIme)))
{
Toast.MakeText(service, Resource.String.please_activate_keyboard, ToastLength.Long).Show();
Intent settingsIntent = new Intent(Android.Provider.Settings.ActionInputMethodSettings);
settingsIntent.SetFlags(ActivityFlags.NewTask);
service.StartActivity(settingsIntent);
}
else
{
if (imeManager != null)
{
imeManager.ShowInputMethodPicker();
}
else
{
Toast.MakeText(service, Resource.String.not_possible_im_picker, ToastLength.Long).Show();
}
}
}
}
}
}