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
This commit is contained in:
qwazix 2018-07-30 16:31:35 +03:00 committed by Konrad Pozniak
commit 562beacfc1
29 changed files with 94 additions and 10 deletions

View file

@ -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);

View file

@ -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()));

View file

@ -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)

View file

@ -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;

View file

@ -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;