From 3b09db6cb46c47183146f3ac417b01bf343ee194 Mon Sep 17 00:00:00 2001 From: qwazix Date: Mon, 30 Jul 2018 16:31:35 +0300 Subject: [PATCH] Add black theme (#726) * Add black theme On amoled screens a completely black theme helps save battery, besides looking awesome! * Fix first set of merge request issues except the dialog. * Black theme inherits from dark and only the different values are declared * Make nav bar translucent (for some reason content does not go behind it in main activity. Need to investigate) * Remove nav bar line * Fix toolbar color * Fix dialog issue with black theme. Revert translucent navigation. * Translations updated, as well as possible from online sources. * Make login screen respect black theme --- app/build.gradle | 12 +++------ .../com/keylesspalace/tusky/BaseActivity.java | 5 ++++ .../keylesspalace/tusky/ComposeActivity.java | 6 ++++- .../com/keylesspalace/tusky/LoginActivity.kt | 3 +++ .../tusky/PreferencesActivity.java | 2 ++ .../keylesspalace/tusky/util/ThemeUtils.java | 4 +++ .../background_dialog_activity_black.xml | 5 ++++ app/src/main/res/values-ar/strings.xml | 1 + app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-large/styles.xml | 10 +++++++ app/src/main/res/values-night-v27/styles.xml | 4 +++ app/src/main/res/values-nl/strings.xml | 1 + app/src/main/res/values-oc/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-ta/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rMO/strings.xml | 1 + app/src/main/res/values-zh-rSG/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/colors.xml | 9 +++++++ app/src/main/res/values/donottranslate.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 26 +++++++++++++++++++ 29 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 app/src/main/res/drawable/background_dialog_activity_black.xml diff --git a/app/build.gradle b/app/build.gradle index 10b8fd47..63353d80 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -93,31 +93,25 @@ dependencies { // EmojiCompat implementation "com.android.support:support-emoji:$supportLibraryVersion" implementation "com.android.support:support-emoji-appcompat:$supportLibraryVersion" - implementation "de.c1710:filemojicompat:1.0.14" + implementation 'de.c1710:filemojicompat:1.0.14' // architecture components implementation 'android.arch.lifecycle:extensions:1.1.1' //room implementation 'android.arch.persistence.room:runtime:1.1.1' kapt 'android.arch.persistence.room:compiler:1.1.1' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - implementation "com.google.dagger:dagger:$daggerVersion" kapt "com.google.dagger:dagger-compiler:$daggerVersion" implementation "com.google.dagger:dagger-android:$daggerVersion" implementation "com.google.dagger:dagger-android-support:$daggerVersion" kapt "com.google.dagger:dagger-android-processor:$daggerVersion" - - testImplementation "org.robolectric:robolectric:3.8" - testImplementation "org.mockito:mockito-inline:2.19.1" + testImplementation 'org.robolectric:robolectric:3.8' + testImplementation 'org.mockito:mockito-inline:2.19.1' androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', { exclude group: 'com.android.support', module: 'support-annotations' }) - debugImplementation 'im.dino:dbinspector:3.4.1@aar' - implementation 'io.reactivex.rxjava2:rxjava:2.1.16' implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' implementation 'com.uber.autodispose:autodispose-android-archcomponents:0.8.0' diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index af55d6d7..858974c6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -25,6 +25,7 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; +import android.util.Log; import android.util.TypedValue; import android.view.Menu; @@ -59,6 +60,10 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab * runtime, just individual activities. So, each activity has to set its theme before any * views are created. */ String theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT); + Log.d("activeTheme", theme); + if (theme.equals("black")) { + setTheme(R.style.TuskyBlackTheme); + } ThemeUtils.setAppNightMode(theme, this); long accountId = getIntent().getLongExtra("account", -1); diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 73676b49..70c24130 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -216,6 +216,11 @@ public final class ComposeActivity @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); + String theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT); + if (theme.equals("black")) { + setTheme(R.style.TuskyDialogActivityBlackTheme); + } setContentView(R.layout.activity_compose); replyTextView = findViewById(R.id.composeReplyView); @@ -381,7 +386,6 @@ public final class ComposeActivity if (intent != null) { if (startingVisibility == Status.Visibility.UNKNOWN) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); Status.Visibility preferredVisibility = Status.Visibility.byString( preferences.getString("defaultPostPrivacy", Status.Visibility.PUBLIC.serverString())); diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt index 856ab434..cfb0d286 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt @@ -70,6 +70,9 @@ class LoginActivity : AppCompatActivity(), Injectable { preferences = PreferenceManager.getDefaultSharedPreferences(this) val theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT) + if (theme == "black") { + setTheme(R.style.TuskyBlackTheme) + } ThemeUtils.setAppNightMode(theme, this) setContentView(R.layout.activity_login) diff --git a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java index 2db70373..1f1e965d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java @@ -24,6 +24,7 @@ import android.support.annotation.StringRes; import android.support.annotation.XmlRes; import android.support.v7.app.ActionBar; import android.support.v7.widget.Toolbar; +import android.util.Log; import android.view.MenuItem; import com.keylesspalace.tusky.fragment.PreferencesFragment; @@ -105,6 +106,7 @@ public class PreferencesActivity extends BaseActivity switch (key) { case "appTheme": { String theme = sharedPreferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT); + Log.d("activeTheme", theme); ThemeUtils.setAppNightMode(theme, this); restartActivitiesOnExit = true; diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java index de643c95..bf00af23 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java @@ -39,6 +39,7 @@ public class ThemeUtils { public static final String THEME_NIGHT = "night"; public static final String THEME_DAY = "day"; + public static final String THEME_BLACK = "black"; public static final String THEME_AUTO = "auto"; public static Drawable getDrawable(Context context, @AttrRes int attribute, @@ -101,6 +102,9 @@ public class ThemeUtils { case THEME_DAY: mode = UiModeManager.MODE_NIGHT_NO; break; + case THEME_BLACK: + mode = UiModeManager.MODE_NIGHT_YES; + break; case THEME_AUTO: mode = UiModeManager.MODE_NIGHT_AUTO; break; diff --git a/app/src/main/res/drawable/background_dialog_activity_black.xml b/app/src/main/res/drawable/background_dialog_activity_black.xml new file mode 100644 index 00000000..4a02e6c8 --- /dev/null +++ b/app/src/main/res/drawable/background_dialog_activity_black.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 73a66c2e..9087b827 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -163,6 +163,7 @@ داكنة فاتحة + أسود تلقائي عند الغروب diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4eca5dd2..a48238ca 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -165,6 +165,7 @@ Dunkel Hell + Schwarz Automatisch bei Sonnenuntergang diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 30f591fe..294f1d0b 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -164,6 +164,7 @@ Oscuro Claro + Negro Automático diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 83ec3b3c..514d26f5 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -182,6 +182,7 @@ Sombre Clair + Noir Basé sur le coucher du soleil diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 28ab5684..5032f052 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -160,6 +160,7 @@ Dark Light + Black 日没による自動設定 diff --git a/app/src/main/res/values-large/styles.xml b/app/src/main/res/values-large/styles.xml index 71044ab1..ae2b1d64 100644 --- a/app/src/main/res/values-large/styles.xml +++ b/app/src/main/res/values-large/styles.xml @@ -9,4 +9,14 @@ true + + diff --git a/app/src/main/res/values-night-v27/styles.xml b/app/src/main/res/values-night-v27/styles.xml index 51d8e816..0131db62 100644 --- a/app/src/main/res/values-night-v27/styles.xml +++ b/app/src/main/res/values-night-v27/styles.xml @@ -7,4 +7,8 @@ @color/status_divider_dark + diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 01ab6495..ae021272 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -174,6 +174,7 @@ Donker Licht + Zwart Automatisch tijdens zonsondergang diff --git a/app/src/main/res/values-oc/strings.xml b/app/src/main/res/values-oc/strings.xml index 2dcd1446..163a1a56 100644 --- a/app/src/main/res/values-oc/strings.xml +++ b/app/src/main/res/values-oc/strings.xml @@ -168,6 +168,7 @@ Escur Luminós + Negre Alba automatica diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 8efaa8da..c53c9cb2 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -176,6 +176,7 @@ Ciemny Jasny + Czarny Zmieniaj automatycznie po zachodzie słońca diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 8943fcc7..735d7656 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -174,6 +174,7 @@ Noturno Diurno + Negro Automático diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 7b4c8dfb..3dd35c61 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -172,6 +172,7 @@ Тёмная Светлая + Черный Автоматическая (по времени) diff --git a/app/src/main/res/values-ta/strings.xml b/app/src/main/res/values-ta/strings.xml index d74a0fbf..ae2d4444 100644 --- a/app/src/main/res/values-ta/strings.xml +++ b/app/src/main/res/values-ta/strings.xml @@ -153,6 +153,7 @@ கருமை வெளிச்சம் + பிளாக் தானியங்கி diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index c1f5498f..51476d4a 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -160,6 +160,7 @@ 黑夜 白天 + 黑色 自动切换 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 31a90c59..c29f2836 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -160,6 +160,7 @@ 黑夜 白天 + 黑色 自動切換 diff --git a/app/src/main/res/values-zh-rMO/strings.xml b/app/src/main/res/values-zh-rMO/strings.xml index 31a90c59..c29f2836 100644 --- a/app/src/main/res/values-zh-rMO/strings.xml +++ b/app/src/main/res/values-zh-rMO/strings.xml @@ -160,6 +160,7 @@ 黑夜 白天 + 黑色 自動切換 diff --git a/app/src/main/res/values-zh-rSG/strings.xml b/app/src/main/res/values-zh-rSG/strings.xml index c1f5498f..51476d4a 100644 --- a/app/src/main/res/values-zh-rSG/strings.xml +++ b/app/src/main/res/values-zh-rSG/strings.xml @@ -160,6 +160,7 @@ 黑夜 白天 + 黑色 自动切换 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 6fbba641..20191fe7 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -160,6 +160,7 @@ 黑夜 白天 + 黑色 自動切換 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 1dcd2b00..f71ca19a 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -40,6 +40,15 @@ #2F2F2F #313543 #373c4b + + #000000 + #111111 + #000000 + #000000 + #FFFFFF + #FFFFFF + #111111 + #111111 #dfdfdf #8f8f8f diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 9cda52a8..7e7c2a4d 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -35,6 +35,7 @@ night day + black auto diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e0694fc4..8e6519a1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -176,6 +176,7 @@ Dark Light + Black Automatic at sunset diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index e6b8756b..ebcd668e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -148,4 +148,30 @@ ?attr/status_text_medium + + +