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.Graphics.Drawables;
using Android.OS; using Android.OS;
using Android.Preferences; using Android.Preferences;
using Android.Support.V7.App;
using Android.Text; using Android.Text;
using Android.Views; using Android.Views;
using Android.Widget; using Android.Widget;
@ -20,7 +21,7 @@ namespace keepass2android
[Activity(Label = "@string/app_name", [Activity(Label = "@string/app_name",
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden,
Theme = "@style/MyTheme_ActionBar")] Theme = "@style/MyTheme_ActionBar")]
public class CreateDatabaseActivity : Activity public class CreateDatabaseActivity : AppCompatActivity
{ {
private IOConnectionInfo _ioc; private IOConnectionInfo _ioc;
private string _keyfileFilename; private string _keyfileFilename;
@ -57,6 +58,9 @@ namespace keepass2android
base.OnCreate(bundle); base.OnCreate(bundle);
_design.ApplyTheme(); _design.ApplyTheme();
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeButtonEnabled(true);
SetContentView(Resource.Layout.create_database); SetContentView(Resource.Layout.create_database);
_appTask = AppTask.GetTaskInOnCreate(bundle, Intent); _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 namespace keepass2android
{ {
[Activity(Label = "@string/app_name", Theme = "@style/MyTheme_ActionBar")] [Activity(Label = "@string/app_name", Theme = "@style/MyTheme_ActionBar", WindowSoftInputMode = SoftInput.StateHidden)]
public class GeneratePasswordActivity : LockCloseActivity { 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}; 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) { public static void Launch(Activity act) {
@ -109,6 +109,9 @@ namespace keepass2android
EditText txtPasswordToSet = (EditText) FindViewById(Resource.Id.password); EditText txtPasswordToSet = (EditText) FindViewById(Resource.Id.password);
txtPasswordToSet.Text = GeneratePassword(); txtPasswordToSet.Text = GeneratePassword();
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeButtonEnabled(true);
} }
public String GeneratePassword() { public String GeneratePassword() {
@ -157,6 +160,18 @@ namespace keepass2android
return password; 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" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/bottom_bar" <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/bottom_bar"
android:orientation="horizontal" android:layout_width="match_parent"
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"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:orientation="horizontal"
android:paddingRight="20dp" android:layout_alignParentBottom="true"
android:drawableLeft="?attr/NavigationAcceptDrawable" android:baselineAligned="false">
android:drawablePadding="8dp" <Button
android:gravity="center_vertical" android:id="@+id/cancel_button"
android:text="@string/accept" /> android:layout_width="wrap_content"
</FrameLayout> android:layout_height="wrap_content"
<FrameLayout android:layout_alignParentLeft="true"
android:id="@+id/cancel_button" android:text="@android:string/cancel"
style="?android:attr/actionButtonStyle" android:drawableLeft="@android:drawable/ic_menu_close_clear_cancel"
android:layout_width="0dp" style="@style/BottomBarButton" />
android:layout_height="wrap_content" <Button
android:layout_weight="1"> android:id="@+id/accept_button"
<TextView android:layout_width="wrap_content"
style="?android:actionBarTabTextStyle" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:text="@string/accept"
android:layout_gravity="center" android:drawableLeft="@drawable/navigation_accept"
android:paddingRight="20dp" style="@style/BottomBarButton" />
android:drawableLeft="?attr/CancelDrawable" </RelativeLayout>
android:drawablePadding="8dp"
android:gravity="center_vertical" <!--
android:text="@android:string/cancel" /> <Button
</FrameLayout> android:id="@+id/accept_button"
</LinearLayout> 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 <ScrollView
android:id="@+id/ScrollView" android:id="@+id/ScrollView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -55,7 +57,8 @@
android:layout_marginBottom="12dip" android:layout_marginBottom="12dip"
android:layout_marginLeft="12dip" android:layout_marginLeft="12dip"
android:layout_marginRight="12dip" android:layout_marginRight="12dip"
android:layout_marginTop="12dip"> android:layout_marginTop="12dip"
android:layout_alignParentTop="false">
<RelativeLayout <RelativeLayout
android:id="@+id/RelativeLayout" android:id="@+id/RelativeLayout"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -77,7 +80,6 @@
<TextView <TextView
android:id="@+id/length_label" android:id="@+id/length_label"
android:text="@string/length" android:text="@string/length"
style="@style/TextAppearance_SmallHeading"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_below="@id/generate_password_button" /> android:layout_below="@id/generate_password_button" />