diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index 5d1c91964..cc9e29c25 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -15,8 +15,6 @@ package com.keylesspalace.tusky; -import android.annotation.SuppressLint; -import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -46,9 +44,7 @@ import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; -@SuppressLint("Registered") -public class BaseActivity extends AppCompatActivity { - protected static final int SERVICE_REQUEST_CODE = 8574603; // This number is arbitrary. +public abstract class BaseActivity extends AppCompatActivity { public MastodonApi mastodonApi; protected Dispatcher mastodonApiDispatcher; @@ -60,12 +56,30 @@ public class BaseActivity extends AppCompatActivity { redirectIfNotLoggedIn(); createMastodonApi(); + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); + /* There isn't presently a way to globally change the theme of a whole application at * runtime, just individual activities. So, each activity has to set its theme before any * views are created. */ - if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false)) { + if (preferences.getBoolean("lightTheme", false)) { setTheme(R.style.AppTheme_Light); } + + int style; + switch(preferences.getString("statusTextSize", "small")) { + case "large": + style = R.style.TextSizeLarge; + break; + case "medium": + style = R.style.TextSizeMedium; + break; + case "small": + default: + style = R.style.TextSizeSmall; + break; + } + getTheme().applyStyle(style, false); + } @Override diff --git a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java index 80704422d..4ff4590d0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java @@ -31,7 +31,7 @@ import com.keylesspalace.tusky.fragment.PreferencesFragment; public class PreferencesActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener { - private boolean themeSwitched; + private boolean restartActivitiesOnExit; private @XmlRes int currentPreferences; private @StringRes int currentTitle; @@ -39,10 +39,10 @@ public class PreferencesActivity extends BaseActivity protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { - themeSwitched = savedInstanceState.getBoolean("themeSwitched"); + restartActivitiesOnExit = savedInstanceState.getBoolean("restart"); } else { Bundle extras = getIntent().getExtras(); - themeSwitched = extras != null && extras.getBoolean("themeSwitched"); + restartActivitiesOnExit = extras != null && extras.getBoolean("restart"); } SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); @@ -91,7 +91,7 @@ public class PreferencesActivity extends BaseActivity } private void saveInstanceState(Bundle outState) { - outState.putBoolean("themeSwitched", themeSwitched); + outState.putBoolean("restart", restartActivitiesOnExit); outState.putInt("preferences", currentPreferences); outState.putInt("title", currentTitle); } @@ -105,7 +105,7 @@ public class PreferencesActivity extends BaseActivity public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { switch (key) { case "lightTheme": { - themeSwitched = true; + restartActivitiesOnExit = true; // recreate() could be used instead, but it doesn't have an animation B). Intent intent = getIntent(); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); @@ -117,6 +117,10 @@ public class PreferencesActivity extends BaseActivity overridePendingTransition(R.anim.fade_in, R.anim.fade_out); break; } + case "statusTextSize": { + restartActivitiesOnExit = true; + break; + } case "notificationsEnabled": { boolean enabled = sharedPreferences.getBoolean("notificationsEnabled", true); if (enabled) { @@ -146,7 +150,7 @@ public class PreferencesActivity extends BaseActivity * Either the back stack activities need to all be recreated, or do the easier thing, which * is hijack the back button press and use it to launch a new MainActivity and clear the * back stack. */ - if (themeSwitched) { + if (restartActivitiesOnExit) { Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); diff --git a/app/src/main/res/drawable/compose_button_colors.xml b/app/src/main/res/drawable/compose_button_colors.xml index 195d08942..2487c7a34 100644 --- a/app/src/main/res/drawable/compose_button_colors.xml +++ b/app/src/main/res/drawable/compose_button_colors.xml @@ -2,21 +2,31 @@ + - - + + + + + - - + + + + diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index 1e111e4fb..3b4d7c24a 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -66,6 +66,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" + android:textSize="?attr/status_text_large" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -75,6 +76,7 @@ android:layout_height="wrap_content" android:layout_marginEnd="10dp" android:layout_marginRight="10dp" + android:textSize="?attr/status_text_medium" android:text="@string/follows_you" android:textColor="?android:textColorPrimary" app:layout_constraintEnd_toEndOf="@id/follow_btn" @@ -87,7 +89,7 @@ android:ellipsize="end" android:maxLines="1" android:textColor="?android:textColorPrimary" - android:textSize="18sp" + android:textSize="?attr/status_text_large" android:textStyle="normal|bold" app:layout_constraintTop_toBottomOf="@id/account_avatar" tools:text="Tusky Mastodon Client" /> @@ -98,6 +100,7 @@ android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" + android:textSize="?attr/status_text_medium" android:textColor="?android:textColorSecondary" app:layout_constraintTop_toBottomOf="@id/account_display_name" tools:text="\@Tusky" /> @@ -123,6 +126,7 @@ android:layout_below="@id/account_username" android:paddingBottom="16dp" android:paddingTop="10dp" + android:textSize="?attr/status_text_medium" android:textColor="?android:textColorTertiary" app:layout_constraintTop_toBottomOf="@id/account_username" tools:text="This is a test description" /> @@ -137,6 +141,7 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_bias="0" app:layout_constraintStart_toStartOf="parent" + android:textSize="?attr/status_text_medium" app:layout_constraintTop_toBottomOf="@id/account_note" tools:text="3000 Followers" /> @@ -149,6 +154,7 @@ app:layout_constraintEnd_toStartOf="@id/statuses_btn" app:layout_constraintHorizontal_bias="0" app:layout_constraintStart_toEndOf="@id/followers_tv" + android:textSize="?attr/status_text_medium" app:layout_constraintTop_toTopOf="@id/followers_tv" tools:text="500 Following" /> @@ -158,6 +164,7 @@ android:layout_height="wrap_content" android:textColor="@color/account_tab_font_color" app:layout_constraintEnd_toEndOf="parent" + android:textSize="?attr/status_text_medium" app:layout_constraintHorizontal_bias="0" app:layout_constraintStart_toEndOf="@id/following_tv" app:layout_constraintTop_toTopOf="@id/followers_tv" @@ -194,6 +201,7 @@ android:background="?android:colorBackground" app:tabGravity="fill" app:tabMaxWidth="0dp" + app:tabTextAppearance="@style/TuskyTabAppearance" app:tabSelectedTextColor="?attr/colorAccent"> + android:textSize="?attr/status_text_large" />