Improved darkmode

Closes #10
This commit is contained in:
Michael Schättgen 2018-04-10 00:45:48 +02:00
parent f6bbae3d96
commit ae686c8ae2
14 changed files with 38 additions and 36 deletions

2
.idea/misc.xml generated
View file

@ -24,7 +24,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View file

@ -36,7 +36,6 @@ dependencies {
compile 'me.dm7.barcodescanner:zxing:1.9'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:support-v4:27.1.0'
compile 'com.yarolegovich:lovely-dialog:1.0.4'
compile 'com.mattprecious.swirl:swirl:1.0.0'
compile 'com.madgag.spongycastle:core:1.56.0.0'
compile 'com.github.apl-devs:appintro:v4.2.2'

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.impy.aegis">
xmlns:tools="http://schemas.android.com/tools"
package="me.impy.aegis">
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
@ -13,11 +14,11 @@
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
tools:replace="android:theme"
android:theme="@style/AppTheme.Default.NoActionBar">
<activity
android:name=".ui.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.Default.NoActionBar"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask">
<intent-filter>
@ -44,15 +45,13 @@
</activity>
<activity
android:name=".ui.AuthActivity"
android:launchMode="singleTop"
android:theme="@style/AppTheme.Default.NoActionBar">
android:launchMode="singleTop">
</activity>
<activity android:name=".ui.PreferencesActivity">
</activity>
<activity
android:name=".ui.SlotManagerActivity"
android:label="Manage key slots"
android:theme="@style/AppTheme.Default.NoActionBar">
android:label="Manage key slots">
</activity>
</application>
</manifest>

View file

@ -13,7 +13,7 @@ public abstract class AegisActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
_app = (AegisApplication) getApplication();
boolean nightMode = _app.getPreferences().getBoolean("pref_night_mode", false);
boolean nightMode = _app.getPreferences().getBoolean("pref_dark_mode", false);
setPreferredTheme(nightMode);
}

View file

@ -49,6 +49,8 @@ public class EditProfileActivity extends AegisActivity {
private Spinner _spinnerDigits;
private SpinnerItemSelectedListener _selectedListener = new SpinnerItemSelectedListener();
int _dialogStyle = android.R.style.Theme_Material_Light_Dialog_NoActionBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -189,8 +191,10 @@ public class EditProfileActivity extends AegisActivity {
@Override
protected void setPreferredTheme(boolean nightMode) {
if (nightMode) {
_dialogStyle = android.R.style.Theme_Material_Dialog_NoActionBar;
setTheme(R.style.AppTheme_Dark_TransparentActionBar);
} else {
_dialogStyle = android.R.style.Theme_Material_Light_Dialog_NoActionBar;
setTheme(R.style.AppTheme_Default_TransparentActionBar);
}
}
@ -202,7 +206,8 @@ public class EditProfileActivity extends AegisActivity {
return;
}
new AlertDialog.Builder(this)
new AlertDialog.Builder(this, _dialogStyle)
.setTitle("Discard changes?")
.setMessage("Your changes have not been saved")
.setPositiveButton(R.string.save, (dialog, which) -> onSave())
.setNegativeButton(R.string.discard, (dialog, which) -> super.onBackPressed())

View file

@ -500,7 +500,7 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
protected void onResume() {
super.onResume();
boolean nightMode = _app.getPreferences().getBoolean("pref_night_mode", false);
boolean nightMode = _app.getPreferences().getBoolean("pref_dark_mode", false);
if (nightMode != _nightMode) {
setPreferredTheme(nightMode);
recreate();

View file

@ -52,7 +52,7 @@ public class PreferencesActivity extends AegisActivity {
// set the result intent in advance
setResult();
Preference nightModePreference = findPreference("pref_night_mode");
Preference nightModePreference = findPreference("pref_dark_mode");
nightModePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {

View file

@ -56,7 +56,7 @@
android:hint="Name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:backgroundTint="#949494"
android:backgroundTint="#ff0000"
android:layout_weight="1"/>
</TableRow>
@ -234,6 +234,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:passwordToggleTint="#949494"
android:backgroundTint="#949494"
app:hintEnabled="false"
app:passwordToggleEnabled="true">
@ -242,6 +243,7 @@
android:id="@+id/text_secret"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#949494"
android:hint="Secret (base32)"
android:inputType="textPassword"/>

View file

@ -85,7 +85,7 @@
android:id="@+id/profile_code"
android:includeFontPadding="false"
android:textSize="34sp"
android:textColor="?attr/colorPrimary"
android:textColor="?attr/primaryText"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:layout_alignParentTop="true"

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#03A9F4</color>
<color name="colorPrimaryDark">#0288D1</color>
<color name="colorHeaderSuccess">#12b600</color>
<color name="colorPrimaryLight">#B3E5FC</color>
<color name="colorAccent">#49ca8a</color>
<color name="primary_text">#ffffff</color>
<color name="secondary_text">#49ca8a</color>
<color name="icons">#FFFFFF</color>
<color name="divider">#BDBDBD</color>
<color name="background">#191919</color>
</resources>

View file

@ -6,7 +6,7 @@
<color name="colorPrimaryLight">#5472d3</color>
<color name="colorAccent">#FF5252</color>
<color name="colorAccentPressed">#FF5252</color>
<color name="primary_text">#212121</color>
<color name="primary_text">#0d47a1</color>
<color name="secondary_text">#434343</color>
<color name="extra_info_text">#8e8e8e</color>
<color name="primary_text_inverted">#ffffff</color>
@ -21,6 +21,7 @@
<color name="card_background_dark">#212121</color>
<color name="primary_text_dark">#ffffff</color>
<color name="hint_text_dark">#a7a7a7</color>
<color name="secondary_text_dark">#FF5252</color>
<color name="background_dark">#191919</color>

View file

@ -8,8 +8,8 @@
<string name="title_activity_intro">IntroActivity</string>
<string name="settings">Preferences</string>
<string name="pref_night_mode_title">Night mode</string>
<string name="pref_night_mode_summary">Enable this to use darker colors</string>
<string name="pref_dark_mode_title">Dark mode</string>
<string name="pref_dark_mode_summary">Enable this to use darker colors</string>
<string name="pref_issuer_title">Show the issuer</string>
<string name="pref_issuer_summary">Enable this to show the issuer next to the profile name</string>
<string name="pref_timeout_title">Timeout</string>

View file

@ -5,9 +5,9 @@
<!-- Customize your theme here. -->
<item name="swirl_ridgeColor">?android:attr/textColorSecondary</item>
<item name="swirl_errorColor">?android:attr/colorAccent</item>
<item name="colorPrimary">@color/colorPrimary</item>
<!-- <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorAccent">@color/colorAccent</item>-->
</style>
<style name="AppTheme.TransparentActionBar">
@ -59,6 +59,10 @@
<item name="secondaryText">@color/secondary_text</item>
<item name="background">@color/background</item>
<item name="cardBackground">@color/card_background</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Default.NoActionBar" parent="AppTheme.Default">
<item name="windowActionBar">false</item>
@ -81,6 +85,11 @@
<item name="secondaryText">@color/secondary_text_dark</item>
<item name="background">@color/background_dark</item>
<item name="cardBackground">@color/card_background_dark</item>
<item name="android:textColorHint">@color/secondary_text</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Dark.NoActionBar" parent="AppTheme.Dark">
<item name="windowActionBar">false</item>

View file

@ -6,9 +6,9 @@
android:title="Appearance">
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_night_mode"
android:title="@string/pref_night_mode_title"
android:summary="@string/pref_night_mode_summary"/>
android:key="pref_dark_mode"
android:title="@string/pref_dark_mode_title"
android:summary="@string/pref_dark_mode_summary"/>
<CheckBoxPreference
android:defaultValue="false"