fixed issues in GeneratePassword and CreateDatabaseActivity

This commit is contained in:
Philipp Crocoll 2015-08-11 08:34:16 +02:00
parent 6095f32b08
commit 6bb4e69f38
3 changed files with 80 additions and 50 deletions

View File

@ -5,6 +5,7 @@ using Android.Content.PM;
using Android.Graphics.Drawables;
using Android.OS;
using Android.Preferences;
using Android.Support.V7.App;
using Android.Text;
using Android.Views;
using Android.Widget;
@ -20,7 +21,7 @@ namespace keepass2android
[Activity(Label = "@string/app_name",
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden,
Theme = "@style/MyTheme_ActionBar")]
public class CreateDatabaseActivity : Activity
public class CreateDatabaseActivity : AppCompatActivity
{
private IOConnectionInfo _ioc;
private string _keyfileFilename;
@ -57,6 +58,9 @@ namespace keepass2android
base.OnCreate(bundle);
_design.ApplyTheme();
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeButtonEnabled(true);
SetContentView(Resource.Layout.create_database);
_appTask = AppTask.GetTaskInOnCreate(bundle, Intent);
@ -578,6 +582,15 @@ namespace keepass2android
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Android.Resource.Id.Home:
OnBackPressed();
return true;
}
return false;
}
}
}

View File

@ -26,8 +26,8 @@ using Android.Widget;
namespace keepass2android
{
[Activity(Label = "@string/app_name", Theme = "@style/MyTheme_ActionBar")]
public class GeneratePasswordActivity : LockCloseActivity {
[Activity(Label = "@string/app_name", Theme = "@style/MyTheme_ActionBar", WindowSoftInputMode = SoftInput.StateHidden)]
public class GeneratePasswordActivity : LockCloseActivity {
private readonly int[] _buttonIds = new[] {Resource.Id.btn_length6, Resource.Id.btn_length8, Resource.Id.btn_length12, Resource.Id.btn_length16};
public static void Launch(Activity act) {
@ -109,6 +109,9 @@ namespace keepass2android
EditText txtPasswordToSet = (EditText) FindViewById(Resource.Id.password);
txtPasswordToSet.Text = GeneratePassword();
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeButtonEnabled(true);
}
public String GeneratePassword() {
@ -157,6 +160,18 @@ namespace keepass2android
return password;
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Android.Resource.Id.Home:
OnBackPressed();
return true;
}
return false;
}
}
}

View File

@ -2,51 +2,53 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="?android:attr/dividerVertical"
android:showDividers="middle"
android:layout_alignParentBottom="true"
android:dividerPadding="12dp"
android:baselineAligned="false">
<FrameLayout
android:id="@+id/accept_button"
style="?android:attr/actionButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
<RelativeLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:drawableLeft="?attr/NavigationAcceptDrawable"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:text="@string/accept" />
</FrameLayout>
<FrameLayout
android:id="@+id/cancel_button"
style="?android:attr/actionButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:drawableLeft="?attr/CancelDrawable"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:text="@android:string/cancel" />
</FrameLayout>
</LinearLayout>
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:baselineAligned="false">
<Button
android:id="@+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@android:string/cancel"
android:drawableLeft="@android:drawable/ic_menu_close_clear_cancel"
style="@style/BottomBarButton" />
<Button
android:id="@+id/accept_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/accept"
android:drawableLeft="@drawable/navigation_accept"
style="@style/BottomBarButton" />
</RelativeLayout>
<!--
<Button
android:id="@+id/accept_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/accept"
style="@style/BottomBarButton" />
<Button
android:id="@+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="?attr/CancelDrawable"
android:layout_alignParentLeft="true"
android:text="@android:string/cancel"
style="@style/BottomBarButton" />
-->
<ScrollView
android:id="@+id/ScrollView"
android:layout_width="wrap_content"
@ -55,7 +57,8 @@
android:layout_marginBottom="12dip"
android:layout_marginLeft="12dip"
android:layout_marginRight="12dip"
android:layout_marginTop="12dip">
android:layout_marginTop="12dip"
android:layout_alignParentTop="false">
<RelativeLayout
android:id="@+id/RelativeLayout"
android:layout_height="wrap_content"
@ -77,7 +80,6 @@
<TextView
android:id="@+id/length_label"
android:text="@string/length"
style="@style/TextAppearance_SmallHeading"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_below="@id/generate_password_button" />