improve keyboard activation

This commit is contained in:
Philipp Crocoll
2020-06-29 19:45:40 +02:00
parent 862083c0be
commit d14d287c3a
5 changed files with 45 additions and 4 deletions

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/switch_ime_text" />
<Button
android:id="@+id/btn_reopen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/switch_ime_reopen" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cancel" />
</LinearLayout>

View File

@@ -1226,6 +1226,8 @@ Initial public release
<string name="emergency_infotext_main">Did you ever consider what happens if you are no longer able to access your password database? What if you have an accident? It is good practice to pass your master key to some trusted person for emergency cases. Nobody will have access to your passwords otherwise.</string>
<string name="no_secure_display">The currently valid display is not marked as secure. This means that screenshots might be taken by other apps. Keepass2Android is configured to display sensitive information on secure displays only. Please change to a secure display (e.g. by detaching an HDMI monitor) or change the app settings.</string>
<string name="switch_ime_text">Please activate the Keepass2Android keyboard.</string>
<string name="switch_ime_reopen">Retry</string>
</resources>

View File

@@ -20,6 +20,9 @@ namespace keepass2android
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.switch_ime_activity_layout);
FindViewById<Button>(Resource.Id.btn_reopen).Click += (sender, args) => TrySwitchKeyboard();
FindViewById<Button>(Resource.Id.btn_cancel).Click += (sender, args) => Finish();
}
private string Kp2aInputMethodName
{
@@ -32,6 +35,11 @@ namespace keepass2android
{
base.OnResume();
TrySwitchKeyboard();
}
private void TrySwitchKeyboard()
{
var needsKeyboardSwitch = NeedsKeyboardSwitch();
if (needsKeyboardSwitch)
@@ -50,8 +58,6 @@ namespace keepass2android
if (!NeedsKeyboardSwitch()) Finish();
});
}, null, timeToWait, timeToWait);
}
else
Finish();

View File

@@ -2053,6 +2053,11 @@
<Version>1.3.50.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\switch_ime_activity_layout.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>

View File

@@ -849,7 +849,7 @@ namespace keepass2android
ActivityManager.RunningAppProcessInfo appProcessInfo = new ActivityManager.RunningAppProcessInfo();
ActivityManager.GetMyMemoryState(appProcessInfo);
//at least on Samsung devices, we always need the helper activity
mustUseHelperActivity = true;// TODO enable again (appProcessInfo.Importance != Importance.Foreground) || (Build.Manufacturer != "Google");
mustUseHelperActivity = (appProcessInfo.Importance != Importance.Foreground) || (Build.Manufacturer != "Google");
}
if (mustUseHelperActivity)
{