re-introduce (simplified) dark theme

ask confirmation message before permanently deleting entries (when no recycle bin is present)
This commit is contained in:
Philipp Crocoll
2015-12-22 05:42:02 +01:00
parent 169994eb06
commit c048399c63
31 changed files with 343 additions and 109 deletions

View File

@@ -9,8 +9,10 @@ namespace keepass2android
public enum UiStringKey public enum UiStringKey
{ {
AskDeletePermanentlyGroup, AskDeletePermanentlyGroup,
AskDeletePermanentlyGroupNoRecycle,
progress_title, progress_title,
AskDeletePermanentlyEntry, AskDeletePermanentlyEntry,
AskDeletePermanentlyEntryNoRecycle,
search_results, search_results,
AskDeletePermanently_title, AskDeletePermanently_title,
saving_database, saving_database,
@@ -58,6 +60,7 @@ namespace keepass2android
DuplicateUuidsError, DuplicateUuidsError,
DuplicateUuidsErrorAdditional, DuplicateUuidsErrorAdditional,
DeletingItems, DeletingItems,
AskDeletePermanentlyItems AskDeletePermanentlyItems,
AskDeletePermanentlyItemsNoRecycle
} }
} }

View File

@@ -43,7 +43,7 @@ namespace keepass2android
} }
} }
protected override UiStringKey QuestionsResourceId protected override UiStringKey QuestionRecycleResourceId
{ {
get get
{ {
@@ -51,6 +51,14 @@ namespace keepass2android
} }
} }
protected override UiStringKey QuestionNoRecycleResourceId
{
get
{
return UiStringKey.AskDeletePermanentlyEntryNoRecycle;
}
}
protected override void PerformDelete(List<PwGroup> touchedGroups, List<PwGroup> permanentlyDeletedGroups) protected override void PerformDelete(List<PwGroup> touchedGroups, List<PwGroup> permanentlyDeletedGroups)
{ {
DoDeleteEntry(_entry, touchedGroups); DoDeleteEntry(_entry, touchedGroups);

View File

@@ -61,14 +61,19 @@ namespace keepass2android
} }
} }
protected override UiStringKey QuestionsResourceId protected override UiStringKey QuestionRecycleResourceId
{ {
get get
{ {
return UiStringKey.AskDeletePermanentlyGroup; return UiStringKey.AskDeletePermanentlyGroup;
} }
} }
protected override UiStringKey QuestionNoRecycleResourceId
{
get { return UiStringKey.AskDeletePermanentlyGroupNoRecycle; }
}
protected override void PerformDelete(List<PwGroup> touchedGroups, List<PwGroup> permanentlyDeletedGroups) protected override void PerformDelete(List<PwGroup> touchedGroups, List<PwGroup> permanentlyDeletedGroups)
{ {
DoDeleteGroup(_group, touchedGroups, permanentlyDeletedGroups); DoDeleteGroup(_group, touchedGroups, permanentlyDeletedGroups);

View File

@@ -50,11 +50,16 @@ namespace keepass2android
get { return _canRecycle; } get { return _canRecycle; }
} }
protected override UiStringKey QuestionsResourceId protected override UiStringKey QuestionRecycleResourceId
{ {
get { return UiStringKey.AskDeletePermanentlyItems; } get { return UiStringKey.AskDeletePermanentlyItems; }
} }
protected override UiStringKey QuestionNoRecycleResourceId
{
get { return UiStringKey.AskDeletePermanentlyItemsNoRecycle; }
}
protected override void PerformDelete(List<PwGroup> touchedGroups, List<PwGroup> permanentlyDeletedGroups) protected override void PerformDelete(List<PwGroup> touchedGroups, List<PwGroup> permanentlyDeletedGroups)
{ {
foreach (var g in _elementsToDelete.OfType<PwGroup>()) foreach (var g in _elementsToDelete.OfType<PwGroup>())

View File

@@ -107,17 +107,23 @@ namespace keepass2android
else { System.Diagnostics.Debug.Assert(pgRecycleBin.Uuid.Equals(Db.KpDatabase.RecycleBinUuid)); } else { System.Diagnostics.Debug.Assert(pgRecycleBin.Uuid.Equals(Db.KpDatabase.RecycleBinUuid)); }
} }
protected abstract UiStringKey QuestionsResourceId protected abstract UiStringKey QuestionRecycleResourceId
{ {
get; get;
} }
protected abstract UiStringKey QuestionNoRecycleResourceId
{
get;
}
public void Start() public void Start()
{ {
if (CanRecycle) if (CanRecycle)
{ {
App.AskYesNoCancel(UiStringKey.AskDeletePermanently_title, App.AskYesNoCancel(UiStringKey.AskDeletePermanently_title,
QuestionsResourceId, QuestionRecycleResourceId,
(dlgSender, dlgEvt) => (dlgSender, dlgEvt) =>
{ {
DeletePermanently = true; DeletePermanently = true;
@@ -138,11 +144,22 @@ namespace keepass2android
} }
else else
{ {
ProgressTask pt = new ProgressTask(App, Ctx, this); App.AskYesNoCancel(UiStringKey.AskDeletePermanently_title,
pt.Run(); QuestionNoRecycleResourceId,
(dlgSender, dlgEvt) =>
{
ProgressTask pt = new ProgressTask(App, Ctx, this);
pt.Run();
},
null,
(dlgSender, dlgEvt) => { },
Ctx);
} }
} }
protected void DoDeleteEntry(PwEntry pe, List<PwGroup> touchedGroups) protected void DoDeleteEntry(PwEntry pe, List<PwGroup> touchedGroups)
{ {
PwDatabase pd = Db.KpDatabase; PwDatabase pd = Db.KpDatabase;

View File

@@ -29,7 +29,13 @@ namespace keepass2android
[Activity(Label = "@string/app_name", Theme = "@style/MyTheme_ActionBar", WindowSoftInputMode = SoftInput.StateHidden)] [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};
private ActivityDesign _design;
public GeneratePasswordActivity()
{
_design = new ActivityDesign(this);
}
public static void Launch(Activity act) { public static void Launch(Activity act) {
Intent i = new Intent(act, typeof(GeneratePasswordActivity)); Intent i = new Intent(act, typeof(GeneratePasswordActivity));
@@ -48,6 +54,7 @@ namespace keepass2android
protected override void OnCreate(Bundle savedInstanceState) { protected override void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState); base.OnCreate(savedInstanceState);
_design.ApplyTheme();
SetContentView(Resource.Layout.generate_password); SetContentView(Resource.Layout.generate_password);
SetResult(KeePass.ExitNormal); SetResult(KeePass.ExitNormal);

View File

@@ -20,6 +20,7 @@ using System.IO;
using Android.App; using Android.App;
using Android.Content; using Android.Content;
using Android.Graphics; using Android.Graphics;
using Android.Graphics.Drawables;
using Android.OS; using Android.OS;
using Android.Preferences; using Android.Preferences;
using Android.Views; using Android.Views;
@@ -178,6 +179,32 @@ namespace keepass2android
{ {
return 0; return 0;
} }
public static Bitmap DrawableToBitmap (Drawable drawable) {
Bitmap bitmap = null;
if (drawable is BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
if(bitmapDrawable.Bitmap != null) {
return bitmapDrawable.Bitmap;
}
}
if(drawable.IntrinsicWidth <= 0 || drawable.IntrinsicHeight <= 0) {
bitmap = Bitmap.CreateBitmap(1, 1, Bitmap.Config.Argb8888); // Single color bitmap will be created of 1x1 pixel
} else {
bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
}
Canvas canvas = new Canvas(bitmap);
drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
drawable.Draw(canvas);
return bitmap;
}
public override View GetView(int position, View convertView, ViewGroup parent) public override View GetView(int position, View convertView, ViewGroup parent)
{ {
@@ -197,8 +224,11 @@ namespace keepass2android
if (position < (int)PwIcon.Count) if (position < (int)PwIcon.Count)
{ {
tv.Text = "" + position; tv.Text = "" + position;
App.Kp2a.GetDb() var drawable = App.Kp2a.GetDb()
.DrawableFactory.AssignDrawableTo(iv, _act, App.Kp2a.GetDb().KpDatabase, (KeePassLib.PwIcon) position, null, false); .DrawableFactory.GetIconDrawable(_act, App.Kp2a.GetDb().KpDatabase, (KeePassLib.PwIcon) position, null, false);
drawable = new BitmapDrawable(DrawableToBitmap(drawable));
iv.SetImageDrawable(drawable);
//App.Kp2a.GetDb().DrawableFactory.AssignDrawableTo(iv, _act, App.Kp2a.GetDb().KpDatabase, (KeePassLib.PwIcon) position, null, false);
if ( if (
PreferenceManager.GetDefaultSharedPreferences(currView.Context) PreferenceManager.GetDefaultSharedPreferences(currView.Context)
@@ -206,7 +236,6 @@ namespace keepass2android
{ {
Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.SrcAtop; Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.SrcAtop;
Color color = new Color(189, 189, 189); Color color = new Color(189, 189, 189);
iv.SetImageDrawable(iv.Drawable.Mutate());
iv.SetColorFilter(color, mMode); iv.SetColorFilter(color, mMode);
} }

View File

@@ -159,13 +159,13 @@ namespace keepass2android
public PasswordActivity (IntPtr javaReference, JniHandleOwnership transfer) public PasswordActivity (IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer) : base(javaReference, transfer)
{ {
_activityDesign = new ActivityDesign(this);
} }
public PasswordActivity() public PasswordActivity()
{ {
_activityDesign = new ActivityDesign(this);
} }
@@ -686,6 +686,8 @@ namespace keepass2android
private string mDrawerTitle; private string mDrawerTitle;
private MeasuringRelativeLayout.MeasureArgs _measureArgs; private MeasuringRelativeLayout.MeasureArgs _measureArgs;
private ActivityDesign _activityDesign;
internal class MyActionBarDrawerToggle : ActionBarDrawerToggle internal class MyActionBarDrawerToggle : ActionBarDrawerToggle
{ {
PasswordActivity owner; PasswordActivity owner;
@@ -739,7 +741,7 @@ namespace keepass2android
protected override void OnCreate(Bundle savedInstanceState) protected override void OnCreate(Bundle savedInstanceState)
{ {
base.OnCreate(savedInstanceState); base.OnCreate(savedInstanceState);
_activityDesign.ApplyTheme();
//use FlagSecure to make sure the last (revealed) character of the master password is not visible in recent apps //use FlagSecure to make sure the last (revealed) character of the master password is not visible in recent apps
if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean( if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(
@@ -1572,6 +1574,7 @@ namespace keepass2android
protected override void OnResume() protected override void OnResume()
{ {
base.OnResume(); base.OnResume();
_activityDesign.ReapplyTheme();
EditText pwd = FindViewById<EditText>(Resource.Id.password_edit); EditText pwd = FindViewById<EditText>(Resource.Id.password_edit);
pwd.PostDelayed(() => pwd.PostDelayed(() =>

View File

@@ -9,13 +9,13 @@
<item android:state_focused="true"> <item android:state_focused="true">
<shape android:shape="rectangle" > <shape android:shape="rectangle" >
<corners android:radius="2dip" /> <corners android:radius="2dip" />
<solid android:color="#fff"/> <solid android:color="?activityBackgroundColor"/>
</shape> </shape>
</item> </item>
<item > <item >
<shape android:shape="rectangle" > <shape android:shape="rectangle" >
<corners android:radius="2dip" /> <corners android:radius="2dip" />
<solid android:color="#fff" /> <solid android:color="?activityBackgroundColor" />
</shape> </shape>
</item> </item>
</selector> </selector>

View File

@@ -3,7 +3,7 @@
<item > <item >
<shape android:shape="rectangle" > <shape android:shape="rectangle" >
<corners android:radius="6dip" /> <corners android:radius="6dip" />
<solid android:color="#fff" /> <solid android:color="?activityBackgroundColor" />
</shape> </shape>
</item> </item>
</selector> </selector>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/entry_scroll" android:id="@+id/entry_scroll"
android:background="#ffffffff" android:background="?activityBackgroundColor"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
<LinearLayout <LinearLayout
@@ -23,7 +23,8 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:src="@drawable/ic00" /> android:src="@drawable/ic00" />
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
style="@style/EntryEditSingleLine_TextInputLayout"> style="@style/EntryEditSingleLine_TextInputLayout"
android:layout_toLeftOf="@id/icon_button">
<EditText <EditText
android:id="@+id/entry_title" android:id="@+id/entry_title"
style="@style/EntryEditSingleLine_EditText" style="@style/EntryEditSingleLine_EditText"

View File

@@ -9,7 +9,7 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:fillViewport="true" android:fillViewport="true"
android:background="#ffffffff" android:background="?activityBackgroundColor"
android:scrollbarStyle="insideOverlay"> android:scrollbarStyle="insideOverlay">
<keepass2android.view.EntryContentsView <keepass2android.view.EntryContentsView
android:id="@+id/entry_contents" android:id="@+id/entry_contents"

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<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:background="?activityBackgroundColor"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
<RelativeLayout <RelativeLayout

View File

@@ -4,7 +4,7 @@
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="#fff"> android:background="?activityBackgroundColor">
<LinearLayout <LinearLayout
android:id="@+id/top" android:id="@+id/top"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -42,7 +42,6 @@
<TextView android:id="@+id/group_text" <TextView android:id="@+id/group_text"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:textColor="#000"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="2dp" android:paddingTop="2dp"
android:paddingBottom="2dp"/> android:paddingBottom="2dp"/>

View File

@@ -21,8 +21,8 @@
android:id="@+id/IconGridView" android:id="@+id/IconGridView"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@android:color/background_light"
android:verticalSpacing="5dp" android:verticalSpacing="5dp"
android:background="?activityBackgroundColor"
android:horizontalSpacing="5dp" android:horizontalSpacing="5dp"
android:columnWidth="60dp" android:columnWidth="60dp"
android:numColumns="auto_fit" android:numColumns="auto_fit"

View File

@@ -10,7 +10,7 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:id="@+id/relative_layout" android:id="@+id/relative_layout"
android:background="#ffffffff"> android:background="?activityBackgroundColor">
<LinearLayout <LinearLayout
android:id="@+id/top" android:id="@+id/top"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -2,6 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?activityBackgroundColor"
android:orientation="vertical"> android:orientation="vertical">
<include <include
android:id="@+id/mytoolbar" android:id="@+id/mytoolbar"

View File

@@ -4,7 +4,7 @@
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="#fff"> android:background="?activityBackgroundColor">
<LinearLayout <LinearLayout
android:id="@+id/top" android:id="@+id/top"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -3,7 +3,7 @@
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="#fff"> android:background="?activityBackgroundColor">
<LinearLayout <LinearLayout
android:id="@+id/top" android:id="@+id/top"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -17,6 +17,19 @@
<item name="actionModeBackground">@color/appAccentColor</item> <item name="actionModeBackground">@color/appAccentColor</item>
</style> </style>
<style name="MyTheme_Dark" parent="MyTheme_Dark.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
<item name="android:actionModeBackground">@color/appAccentColor</item>
</style>
<style name="MyTheme_ActionBar_Dark" parent="MyTheme_ActionBar_Dark.Base">
<item name="android:actionModeBackground">@color/appAccentColor</item>
<item name="actionModeBackground">@color/appAccentColor</item>
</style>
<style name="EntryFieldHeader"> <style name="EntryFieldHeader">
<item name="android:drawablePadding">2dp</item> <item name="android:drawablePadding">2dp</item>
<item name="android:layout_marginLeft">0dip</item> <item name="android:layout_marginLeft">0dip</item>

View File

@@ -17,6 +17,8 @@
<attr name="ic_launcher_folder_small" format="reference"></attr> <attr name="ic_launcher_folder_small" format="reference"></attr>
<attr name="ic_action_search_drawable" format="reference"></attr> <attr name="ic_action_search_drawable" format="reference"></attr>
<attr name="NavigationAcceptDrawable" format="reference"></attr> <attr name="NavigationAcceptDrawable" format="reference"></attr>
<attr name="activityBackgroundColor" format="reference|color" />
</resources> </resources>

View File

@@ -19,6 +19,10 @@
--> -->
<resources> <resources>
<color name="bgColorLight">#fff</color>
<color name="bgColorDark">#000</color>
<color name="bgColor">#000</color>
<color name="appPrimaryColor">#8bc34a</color> <color name="appPrimaryColor">#8bc34a</color>
<color name="appPrimaryDarkColor">#548a2e</color> <color name="appPrimaryDarkColor">#548a2e</color>
<color name="appAccentColor">#0277bd</color> <color name="appAccentColor">#0277bd</color>

View File

@@ -357,6 +357,11 @@
<string name="AskDeletePermanentlyEntry">Do you want to delete this entry permanently? Press No to recycle.</string> <string name="AskDeletePermanentlyEntry">Do you want to delete this entry permanently? Press No to recycle.</string>
<string name="AskDeletePermanentlyGroup">Do you want to delete this group permanently? Press No to recycle.</string> <string name="AskDeletePermanentlyGroup">Do you want to delete this group permanently? Press No to recycle.</string>
<string name="AskDeletePermanentlyItems">Do you want to delete the selected elements permanently? Press No to recycle.</string> <string name="AskDeletePermanentlyItems">Do you want to delete the selected elements permanently? Press No to recycle.</string>
<string name="AskDeletePermanentlyEntryNoRecycle">Do you want to delete this entry permanently?</string>
<string name="AskDeletePermanentlyGroupNoRecycle">Do you want to delete this group permanently?</string>
<string name="AskDeletePermanentlyItemsNoRecycle">Do you want to delete the selected elements permanently?</string>
<string name="AskDeletePermanently_title">Delete permanently?</string> <string name="AskDeletePermanently_title">Delete permanently?</string>
<string name="AskReloadFile_title">Reload file?</string> <string name="AskReloadFile_title">Reload file?</string>
<string name="AskReloadFile">The file which is currently open was changed by another program. Do you want to reload it?</string> <string name="AskReloadFile">The file which is currently open was changed by another program. Do you want to reload it?</string>
@@ -780,8 +785,8 @@ Initial public release
</string-array> </string-array>
<string-array name="design_options"> <string-array name="design_options">
<item>Holo Light</item> <item>Light</item>
<item>Holo Dark</item> <item>Dark</item>
</string-array> </string-array>
<string name="design_title">Design</string> <string name="design_title">Design</string>

View File

@@ -17,6 +17,136 @@
--> -->
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme_ActionBar.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">true</item>
<item name="colorPrimary">@color/appPrimaryColor</item>
<item name="colorPrimaryDark">@color/appPrimaryDarkColor</item>
<item name="colorAccent">@color/appAccentColor</item>
<item name="activityBackgroundColor">@color/bgColorLight</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="actionModeBackground">@color/appPrimaryDarkColor</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyTheme_ActionBar" parent="MyTheme_ActionBar.Base">
<item name="actionModeBackground">@color/appAccentColor</item>
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="activityBackgroundColor">@color/bgColorLight</item>
<item name="CancelDrawable">@drawable/ic_menu_close</item>
<item name="ic_launcher_folder_small">@drawable/ic_launcher_folder_small</item>
<item name="ic_action_search_drawable">@drawable/ic_action_search</item>
<item name="NavigationAcceptDrawable">@drawable/navigation_accept</item>
<item name="android:windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/appPrimaryColor</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/appPrimaryDarkColor</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/appAccentColor</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyTheme" parent="MyTheme.Base">
<item name="actionModeBackground">@color/appAccentColor</item>
</style>
<style name="MyTheme_Blue" parent="MyTheme">
<item name="colorPrimary">@color/appAccentColor</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/appAccentColorDark</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/appAccentColor</item>
</style>
<style name="Base_Dialog" parent="Theme.AppCompat.Light.Dialog" />
<!-- dark themes -->
<style name="MyTheme_ActionBar_Dark.Base" parent="Theme.AppCompat">
<item name="activityBackgroundColor">@color/bgColorDark</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">true</item>
<item name="colorPrimary">@color/appPrimaryColor</item>
<item name="colorPrimaryDark">@color/appPrimaryDarkColor</item>
<item name="colorAccent">@color/appAccentColor</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="actionModeBackground">@color/appPrimaryDarkColor</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyTheme_ActionBar_Dark" parent="MyTheme_ActionBar_Dark.Base">
<item name="actionModeBackground">@color/appAccentColor</item>
</style>
<!-- Base theme applied no matter what API -->
<style name="MyTheme_Dark.Base" parent="Theme.AppCompat.NoActionBar">
<item name="activityBackgroundColor">@color/bgColorDark</item>
<item name="CancelDrawable">@drawable/ic_menu_close</item>
<item name="ic_launcher_folder_small">@drawable/ic_launcher_folder_small</item>
<item name="ic_action_search_drawable">@drawable/ic_action_search</item>
<item name="NavigationAcceptDrawable">@drawable/navigation_accept</item>
<item name="android:windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/appPrimaryColor</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/appPrimaryDarkColor</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/appAccentColor</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyTheme_Dark" parent="MyTheme_Dark.Base">
<item name="actionModeBackground">@color/appAccentColor</item>
</style>
<style name="MyTheme_Blue_Dark" parent="MyTheme_Dark">
<item name="colorPrimary">@color/appAccentColor</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/appAccentColorDark</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/appAccentColor</item>
</style>
<style name="Base_Dialog_Dark" parent="Theme.AppCompat.Dialog" />
<!-- end dark themen -->
<style name="BottomBarButton" parent="@style/Widget.AppCompat.Button.Borderless"> <style name="BottomBarButton" parent="@style/Widget.AppCompat.Button.Borderless">
<item name="android:textSize">16sp</item> <item name="android:textSize">16sp</item>
<item name="android:layout_margin">6dp</item> <item name="android:layout_margin">6dp</item>
@@ -89,56 +219,7 @@
<item name="android:gravity">center_vertical</item> <item name="android:gravity">center_vertical</item>
</style> </style>
<style name="MyTheme" parent="MyTheme.Base">
<item name="actionModeBackground">@color/appAccentColor</item>
</style>
<style name="MyTheme_Blue" parent="MyTheme">
<item name="colorPrimary">@color/appAccentColor</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/appAccentColorDark</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/appAccentColor</item>
</style>
<!--style name="MyTheme.ActionMode" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionModeBackground">#FFFFFF</item>
</style-->
<style name="MyTheme_ActionBar" parent="MyTheme_ActionBar.Base">
<item name="actionModeBackground">@color/appAccentColor</item>
</style>
<!-- Base theme applied no matter what API -->
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="CancelDrawable">@drawable/ic_menu_close</item>
<item name="ic_launcher_folder_small">@drawable/ic_launcher_folder_small</item>
<item name="ic_action_search_drawable">@drawable/ic_action_search</item>
<item name="NavigationAcceptDrawable">@drawable/navigation_accept</item>
<item name="android:windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/appPrimaryColor</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/appPrimaryDarkColor</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/appAccentColor</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid"> <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">@style/MyTitleTextStyle</item> <item name="titleTextStyle">@style/MyTitleTextStyle</item>
@@ -150,19 +231,7 @@
</style> </style>
<style name="MyTheme_ActionBar.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">true</item>
<item name="colorPrimary">@color/appPrimaryColor</item>
<item name="colorPrimaryDark">@color/appPrimaryDarkColor</item>
<item name="colorAccent">@color/appAccentColor</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="actionModeBackground">@color/appPrimaryDarkColor</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle"> <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item> <item name="spinBars">true</item>
<item name="color">@android:color/white</item> <item name="color">@android:color/white</item>
@@ -172,7 +241,7 @@
<item name="@android:textStyle">italic</item> <item name="@android:textStyle">italic</item>
</style> </style>
<style name="Base_Dialog" parent="Theme.AppCompat.Light.Dialog" />
<style name="Dialog" parent="Base_Dialog"></style> <style name="Dialog" parent="Base_Dialog"></style>
</resources> </resources>

View File

@@ -196,7 +196,16 @@
android:persistent="false" android:persistent="false"
android:key="IconSetKey"/> android:key="IconSetKey"/>
<CheckBoxPreference <ListPreference
android:key="@string/design_key"
android:title="@string/design_title"
android:entries="@array/design_options"
android:entryValues="@array/design_values"
android:dialogTitle="@string/design_title"
android:defaultValue="@string/design_default"/>
<CheckBoxPreference
android:enabled="true" android:enabled="true"
android:persistent="true" android:persistent="true"
android:summary="@string/ViewDatabaseSecure_summary" android:summary="@string/ViewDatabaseSecure_summary"

View File

@@ -1,3 +1,5 @@
using System;
using System.Linq;
using Android.App; using Android.App;
using Android.Preferences; using Android.Preferences;
@@ -11,31 +13,73 @@ namespace keepass2android
private string _currentIconSet; private string _currentIconSet;
private readonly string _attributeTheme;
public ActivityDesign(Activity activity) public ActivityDesign(Activity activity)
{ {
_activity = activity; _activity = activity;
try
{
var activityAttr = activity.GetType().GetCustomAttributes(false).Where(
x => x is Android.App.ActivityAttribute
).Cast<ActivityAttribute>().First();
_attributeTheme = activityAttr.Theme;
}
catch (Exception e)
{
Kp2aLog.Log(e.ToString());
}
} }
public void ApplyTheme() public void ApplyTheme()
{ {
/*if (HasThemes()) if (HasThemes())
{ {
var dark = UseDarkTheme; var dark = UseDarkTheme;
//int newTheme = dark ? Resource.Style.ThemeDark : Resource.Style.ThemeLight; int newTheme = dark ? DarkTheme : LightTheme;
int newTheme = Resource.Style.ThemeMaterial;
_activity.SetTheme(newTheme); _activity.SetTheme(newTheme);
_currentThemeId = newTheme; _currentThemeId = newTheme;
}*/ }
_currentIconSet = PreferenceManager.GetDefaultSharedPreferences(_activity) _currentIconSet = PreferenceManager.GetDefaultSharedPreferences(_activity)
.GetString("IconSetKey", _activity.PackageName); .GetString("IconSetKey", _activity.PackageName);
} }
public int DarkTheme
{
get
{
if (string.IsNullOrEmpty(_attributeTheme))
return Resource.Style.MyTheme_Dark;
if (_attributeTheme.Contains("MyTheme_Blue"))
return Resource.Style.MyTheme_Blue_Dark;
if (_attributeTheme.Contains("MyTheme_ActionBar"))
return Resource.Style.MyTheme_ActionBar_Dark;
return Resource.Style.MyTheme_Dark;
}
}
public int LightTheme
{
get
{
if (string.IsNullOrEmpty(_attributeTheme))
return Resource.Style.MyTheme;
if (_attributeTheme.Contains("MyTheme_Blue"))
return Resource.Style.MyTheme_Blue;
if (_attributeTheme.Contains("MyTheme_ActionBar"))
return Resource.Style.MyTheme_ActionBar;
return Resource.Style.MyTheme;
}
}
public void ReapplyTheme() public void ReapplyTheme()
{ {
/*if (HasThemes()) if (HasThemes())
{ {
//int newTheme = UseDarkTheme ? Resource.Style.ThemeDark : Resource.Style.ThemeLight; int newTheme = UseDarkTheme ? DarkTheme : LightTheme;
int newTheme = Resource.Style.ThemeMaterial;
if (newTheme != _currentThemeId) if (newTheme != _currentThemeId)
{ {
Kp2aLog.Log("recreating due to theme change."); Kp2aLog.Log("recreating due to theme change.");
@@ -43,7 +87,7 @@ namespace keepass2android
return; return;
} }
} }
*/
if (PreferenceManager.GetDefaultSharedPreferences(_activity) if (PreferenceManager.GetDefaultSharedPreferences(_activity)
.GetString("IconSetKey", _activity.PackageName) != _currentIconSet) .GetString("IconSetKey", _activity.PackageName) != _currentIconSet)
{ {
@@ -69,7 +113,7 @@ namespace keepass2android
if (HasThemes()) if (HasThemes())
{ {
bool dark = UseDarkTheme; bool dark = UseDarkTheme;
//_activity.SetTheme(dark ? Resource.Style.DialogDark : Resource.Style.DialogLight); _activity.SetTheme(dark ? Resource.Style.Base_Dialog : Resource.Style.Base_Dialog_Dark);
} }
} }

View File

@@ -337,8 +337,8 @@ namespace keepass2android
builder.SetMessage(GetResourceString(messageKey)); builder.SetMessage(GetResourceString(messageKey));
builder.SetPositiveButton(GetResourceString(yesString), yesHandler); builder.SetPositiveButton(GetResourceString(yesString), yesHandler);
if (noHandler != null)
builder.SetNegativeButton(GetResourceString(noString), noHandler); builder.SetNegativeButton(GetResourceString(noString), noHandler);
if (cancelHandler != null) if (cancelHandler != null)
{ {

View File

@@ -48,12 +48,16 @@ private static Drawable _blank;
* Keys: Integer, Values: Drawables * Keys: Integer, Values: Drawables
*/ */
private readonly Dictionary<int/*icon key*/, Drawable> _standardIconMap = new Dictionary<int, Drawable>(); private readonly Dictionary<int/*icon key*/, Drawable> _standardIconMap = new Dictionary<int, Drawable>();
public void AssignDrawableTo (ImageView iv, Context context, PwDatabase db, PwIcon icon, PwUuid customIconId, bool forGroup) public void AssignDrawableTo(ImageView iv, Context context, PwDatabase db, PwIcon icon, PwUuid customIconId, bool forGroup)
{ {
Drawable draw = GetIconDrawable (context, db, icon, customIconId, forGroup); Drawable draw = GetIconDrawable (context, db, icon, customIconId, forGroup);
if (draw != null) if (draw != null)
{
draw = draw.Mutate();
iv.SetImageDrawable(draw); iv.SetImageDrawable(draw);
}
else else
Kp2aLog.Log("icon not found : " + icon); Kp2aLog.Log("icon not found : " + icon);
} }
@@ -172,6 +176,7 @@ private static Drawable _blank;
_customIconMap.Clear (); _customIconMap.Clear ();
} }
} }
} }

View File

@@ -104,8 +104,10 @@ namespace keepass2android
protected override void OnCreate(Bundle savedInstanceState) protected override void OnCreate(Bundle savedInstanceState)
{ {
_design.ApplyTheme();
base.OnCreate(savedInstanceState); base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.preference); SetContentView(Resource.Layout.preference);
SetSupportActionBar(FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar)); SetSupportActionBar(FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar));

View File

@@ -337,6 +337,8 @@ namespace keepass2android
FindPreference(GetString(Resource.String.keyfile_key)).PreferenceChange += OnRememberKeyFileHistoryChanged; FindPreference(GetString(Resource.String.keyfile_key)).PreferenceChange += OnRememberKeyFileHistoryChanged;
FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += OnShowUnlockedNotificationChanged; FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += OnShowUnlockedNotificationChanged;
PrepareNoDonatePreference(Activity, FindPreference(GetString(Resource.String.NoDonateOption_key))); PrepareNoDonatePreference(Activity, FindPreference(GetString(Resource.String.NoDonateOption_key)));
FindPreference(GetString(Resource.String.design_key)).PreferenceChange += (sender, args) => Activity.Recreate();
Database db = App.Kp2a.GetDb(); Database db = App.Kp2a.GetDb();
if (db.Loaded) if (db.Loaded)