AMOLED dark theme is now available.

This commit is contained in:
Alex Ning 2019-10-03 20:31:55 +08:00
parent 66b0eeef99
commit 11f6b5dc91
73 changed files with 474 additions and 1085 deletions

View File

@ -13,8 +13,6 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -30,10 +28,8 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.FragmentCommunicator;
@ -41,15 +37,8 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class AccountPostsActivity extends BaseActivity implements UserThingSortTypeBottomSheetFragment.UserThingSortTypeSelectionCallback {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class AccountPostsActivity extends AppCompatActivity implements UserThingSortTypeBottomSheetFragment.UserThingSortTypeSelectionCallback {
static final String EXTRA_USER_WHERE = "EUW"; static final String EXTRA_USER_WHERE = "EUW";
@ -80,18 +69,9 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_account_posts); setContentView(R.layout.activity_account_posts);
@ -140,24 +120,6 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
mUserWhere = getIntent().getExtras().getString(EXTRA_USER_WHERE); mUserWhere = getIntent().getExtras().getString(EXTRA_USER_WHERE);
if (mUserWhere.equals(PostDataSource.USER_WHERE_UPVOTED)) { if (mUserWhere.equals(PostDataSource.USER_WHERE_UPVOTED)) {
toolbar.setTitle(R.string.upvoted); toolbar.setTitle(R.string.upvoted);
@ -190,6 +152,11 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndInitializeFragment() { private void getCurrentAccountAndInitializeFragment() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -13,8 +13,6 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -35,10 +33,8 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.FragmentCommunicator;
@ -46,16 +42,9 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class AccountSavedThingActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class AccountSavedThingActivity extends AppCompatActivity {
private static final String NULL_ACCESS_TOKEN_STATE = "NATS"; private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
private static final String ACCESS_TOKEN_STATE = "ATS"; private static final String ACCESS_TOKEN_STATE = "ATS";
@ -89,18 +78,9 @@ public class AccountSavedThingActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_account_saved_thing); setContentView(R.layout.activity_account_saved_thing);
@ -149,24 +129,6 @@ public class AccountSavedThingActivity extends AppCompatActivity {
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -187,6 +149,11 @@ public class AccountSavedThingActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndInitializeViewPager() { private void getCurrentAccountAndInitializeViewPager() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -0,0 +1,86 @@
package ml.docilealligator.infinityforreddit.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences mSharedPreferences = getSharedPreferences();
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
getTheme().applyStyle(R.style.Theme_Default, true);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
getTheme().applyStyle(R.style.Theme_Default_AmoledDark, true);
} else {
getTheme().applyStyle(R.style.Theme_Default_NormalDark, true);
}
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
getTheme().applyStyle(R.style.Theme_Default, true);
} else {
if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
getTheme().applyStyle(R.style.Theme_Default_AmoledDark, true);
} else {
getTheme().applyStyle(R.style.Theme_Default_NormalDark, true);
}
}
}
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.navBarColor, typedValue, true);
int navBarColor = typedValue.data;
window.setNavigationBarColor(navBarColor);
}
}
public abstract SharedPreferences getSharedPreferences();
}

View File

@ -3,15 +3,11 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
@ -19,11 +15,8 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
@ -41,23 +34,14 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.linkify.LinkifyPlugin; import io.noties.markwon.linkify.LinkifyPlugin;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CommentData; import ml.docilealligator.infinityforreddit.CommentData;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SendComment; import ml.docilealligator.infinityforreddit.SendComment;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class CommentActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class CommentActivity extends AppCompatActivity {
public static final String EXTRA_COMMENT_PARENT_TEXT_KEY = "ECPTK"; public static final String EXTRA_COMMENT_PARENT_TEXT_KEY = "ECPTK";
public static final String EXTRA_PARENT_FULLNAME_KEY = "EPFK"; public static final String EXTRA_PARENT_FULLNAME_KEY = "EPFK";
@ -94,18 +78,9 @@ public class CommentActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_comment); setContentView(R.layout.activity_comment);
@ -113,32 +88,6 @@ public class CommentActivity extends AppCompatActivity {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor));
}
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
if (savedInstanceState == null) { if (savedInstanceState == null) {
getCurrentAccount(); getCurrentAccount();
} else { } else {
@ -186,6 +135,11 @@ public class CommentActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccount() { private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -3,23 +3,16 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
@ -34,26 +27,17 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditAPI; import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.RedditUtils; import ml.docilealligator.infinityforreddit.RedditUtils;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class EditCommentActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class EditCommentActivity extends AppCompatActivity {
public static final String EXTRA_CONTENT = "EC"; public static final String EXTRA_CONTENT = "EC";
public static final String EXTRA_FULLNAME = "EF"; public static final String EXTRA_FULLNAME = "EF";
@ -80,18 +64,9 @@ public class EditCommentActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_edit_comment); setContentView(R.layout.activity_edit_comment);
@ -99,38 +74,12 @@ public class EditCommentActivity extends AppCompatActivity {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor));
}
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mFullName = getIntent().getExtras().getString(EXTRA_FULLNAME); mFullName = getIntent().getStringExtra(EXTRA_FULLNAME);
mAccessToken = getIntent().getExtras().getString(EXTRA_ACCESS_TOKEN); mAccessToken = getIntent().getStringExtra(EXTRA_ACCESS_TOKEN);
contentEditText.setText(getIntent().getExtras().getString(EXTRA_CONTENT)); contentEditText.setText(getIntent().getStringExtra(EXTRA_CONTENT));
contentEditText.requestFocus(); contentEditText.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@ -139,6 +88,11 @@ public class EditCommentActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();

View File

@ -3,24 +3,17 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
@ -35,26 +28,17 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditAPI; import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.RedditUtils; import ml.docilealligator.infinityforreddit.RedditUtils;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class EditPostActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class EditPostActivity extends AppCompatActivity {
static final String EXTRA_TITLE = "ET"; static final String EXTRA_TITLE = "ET";
static final String EXTRA_CONTENT = "EC"; static final String EXTRA_CONTENT = "EC";
@ -80,18 +64,9 @@ public class EditPostActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_edit_post); setContentView(R.layout.activity_edit_post);
@ -99,39 +74,13 @@ public class EditPostActivity extends AppCompatActivity {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor));
}
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mFullName = getIntent().getExtras().getString(EXTRA_FULLNAME); mFullName = getIntent().getStringExtra(EXTRA_FULLNAME);
mAccessToken = getIntent().getExtras().getString(EXTRA_ACCESS_TOKEN); mAccessToken = getIntent().getStringExtra(EXTRA_ACCESS_TOKEN);
titleTextView.setText(getIntent().getExtras().getString(EXTRA_TITLE)); titleTextView.setText(getIntent().getStringExtra(EXTRA_TITLE));
contentEditText.setText(getIntent().getExtras().getString(EXTRA_CONTENT)); contentEditText.setText(getIntent().getStringExtra(EXTRA_CONTENT));
contentEditText.requestFocus(); contentEditText.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@ -140,6 +89,11 @@ public class EditPostActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();

View File

@ -13,8 +13,6 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -30,9 +28,7 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.SearchPostSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.SearchPostSortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment;
@ -43,15 +39,8 @@ import ml.docilealligator.infinityforreddit.Post;
import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class FilteredThingActivity extends BaseActivity implements SortTypeBottomSheetFragment.SortTypeSelectionCallback,
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class FilteredThingActivity extends AppCompatActivity implements SortTypeBottomSheetFragment.SortTypeSelectionCallback,
SearchPostSortTypeBottomSheetFragment.SearchSortTypeSelectionCallback, UserThingSortTypeBottomSheetFragment.UserThingSortTypeSelectionCallback { SearchPostSortTypeBottomSheetFragment.SearchSortTypeSelectionCallback, UserThingSortTypeBottomSheetFragment.UserThingSortTypeSelectionCallback {
public static final String EXTRA_NAME = "ESN"; public static final String EXTRA_NAME = "ESN";
@ -92,18 +81,9 @@ public class FilteredThingActivity extends AppCompatActivity implements SortType
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_filtered_thing); setContentView(R.layout.activity_filtered_thing);
@ -152,24 +132,6 @@ public class FilteredThingActivity extends AppCompatActivity implements SortType
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -196,6 +158,11 @@ public class FilteredThingActivity extends AppCompatActivity implements SortType
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndBindView(int filter, String sortType) { private void getCurrentAccountAndBindView(int filter, String sortType) {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -5,7 +5,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem; import android.view.MenuItem;
import android.webkit.CookieManager; import android.webkit.CookieManager;
@ -14,8 +13,6 @@ import android.webkit.WebViewClient;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import org.json.JSONException; import org.json.JSONException;
@ -37,18 +34,12 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditAPI; import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.RedditUtils; import ml.docilealligator.infinityforreddit.RedditUtils;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class LoginActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class LoginActivity extends AppCompatActivity {
@BindView(R.id.toolbar_login_activity) @BindView(R.id.toolbar_login_activity)
Toolbar toolbar; Toolbar toolbar;
@ -66,33 +57,15 @@ public class LoginActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
ButterKnife.bind(this); ButterKnife.bind(this);
((Infinity) getApplication()).getAppComponent().inject(this);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
WebView webView = findViewById(R.id.webview_login_activity); WebView webView = findViewById(R.id.webview_login_activity);
@ -218,6 +191,11 @@ public class LoginActivity extends AppCompatActivity {
}); });
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) { if (item.getItemId() == android.R.id.home) {

View File

@ -20,8 +20,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.GravityCompat; import androidx.core.view.GravityCompat;
@ -68,13 +66,11 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeFontSizeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchMyInfo; import ml.docilealligator.infinityforreddit.FetchMyInfo;
import ml.docilealligator.infinityforreddit.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.PostTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment;
@ -90,16 +86,10 @@ import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class MainActivity extends BaseActivity implements SortTypeBottomSheetFragment.SortTypeSelectionCallback,
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class MainActivity extends AppCompatActivity implements SortTypeBottomSheetFragment.SortTypeSelectionCallback,
PostTypeBottomSheetFragment.PostTypeSelectionCallback { PostTypeBottomSheetFragment.PostTypeSelectionCallback {
static final String EXTRA_POST_TYPE = "EPT"; static final String EXTRA_POST_TYPE = "EPT";
@ -202,21 +192,12 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar); setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
ButterKnife.bind(this); ButterKnife.bind(this);
@ -273,24 +254,6 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
postTypeBottomSheetFragment = new PostTypeBottomSheetFragment(); postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
bestSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment(); bestSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
@ -348,6 +311,11 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
}); });
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndBindView() { private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
boolean enableNotification = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_NOTIFICATION_KEY, true); boolean enableNotification = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_NOTIFICATION_KEY, true);
@ -944,7 +912,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
} }
@Subscribe @Subscribe
public void onChangeFontSizeEvent(ChangeFontSizeEvent changeFontSizeEvent) { public void onRecreateActivityEvent(RecreateActivityEvent recreateActivityEvent) {
recreate(); recreate();
} }

View File

@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -11,7 +10,6 @@ import android.provider.MediaStore;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
@ -19,12 +17,9 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
@ -49,27 +44,18 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SubmitImagePostEvent; import ml.docilealligator.infinityforreddit.Event.SubmitImagePostEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubmitPostService; import ml.docilealligator.infinityforreddit.SubmitPostService;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class PostImageActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class PostImageActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -152,18 +138,9 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_post_image); setContentView(R.layout.activity_post_image);
@ -171,32 +148,6 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor));
}
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -367,6 +318,11 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
}); });
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccount() { private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -2,24 +2,18 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
@ -39,28 +33,19 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent; import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.RedditUtils; import ml.docilealligator.infinityforreddit.RedditUtils;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubmitPostService; import ml.docilealligator.infinityforreddit.SubmitPostService;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class PostLinkActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
static final String EXTRA_LINK = "EL"; static final String EXTRA_LINK = "EL";
@ -127,18 +112,9 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_post_link); setContentView(R.layout.activity_post_link);
@ -146,32 +122,6 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor));
}
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -306,6 +256,11 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
}); });
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccount() { private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -2,24 +2,18 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
@ -39,28 +33,19 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent; import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.RedditUtils; import ml.docilealligator.infinityforreddit.RedditUtils;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubmitPostService; import ml.docilealligator.infinityforreddit.SubmitPostService;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class PostTextActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class PostTextActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
static final String EXTRA_CONTENT = "EC"; static final String EXTRA_CONTENT = "EC";
@ -127,18 +112,9 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_post_text); setContentView(R.layout.activity_post_text);
@ -146,32 +122,6 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor));
}
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -310,6 +260,11 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
}); });
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccount() { private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -10,19 +9,15 @@ import android.provider.MediaStore;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
@ -51,27 +46,18 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent; import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubmitPostService; import ml.docilealligator.infinityforreddit.SubmitPostService;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class PostVideoActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class PostVideoActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -160,18 +146,9 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_post_video); setContentView(R.layout.activity_post_video);
@ -179,32 +156,6 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor));
}
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -372,6 +323,11 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
}); });
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccount() { private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -15,8 +15,6 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -38,28 +36,19 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.RulesRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.Adapter.RulesRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.JSONUtils; import ml.docilealligator.infinityforreddit.JSONUtils;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditAPI; import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.Rule; import ml.docilealligator.infinityforreddit.Rule;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import ml.docilealligator.infinityforreddit.Utils; import ml.docilealligator.infinityforreddit.Utils;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class RulesActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class RulesActivity extends AppCompatActivity {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -83,18 +72,9 @@ public class RulesActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_rules); setContentView(R.layout.activity_rules);
@ -150,24 +130,6 @@ public class RulesActivity extends AppCompatActivity {
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -180,6 +142,11 @@ public class RulesActivity extends AppCompatActivity {
fetchRules(); fetchRules();
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void fetchRules() { private void fetchRules() {
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
errorTextView.setVisibility(View.GONE); errorTextView.setVisibility(View.GONE);

View File

@ -4,23 +4,17 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import com.ferfalk.simplesearchview.SimpleSearchView; import com.ferfalk.simplesearchview.SimpleSearchView;
@ -31,20 +25,11 @@ import javax.inject.Inject;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class SearchActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class SearchActivity extends AppCompatActivity {
static final String EXTRA_QUERY = "EQ"; static final String EXTRA_QUERY = "EQ";
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -75,18 +60,9 @@ public class SearchActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_search); setContentView(R.layout.activity_search);
@ -94,35 +70,9 @@ public class SearchActivity extends AppCompatActivity {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Window window = getWindow();
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor));
}
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
boolean searchOnlySubreddits = getIntent().getExtras().getBoolean(EXTRA_SEARCH_ONLY_SUBREDDITS); boolean searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false);
simpleSearchView.setOnSearchViewListener(new SimpleSearchView.SearchViewListener() { simpleSearchView.setOnSearchViewListener(new SimpleSearchView.SearchViewListener() {
@Override @Override
@ -211,6 +161,11 @@ public class SearchActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();

View File

@ -14,8 +14,6 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -34,10 +32,8 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.SearchPostSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.SearchPostSortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.SearchUserAndSubredditSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.SearchUserAndSubredditSortTypeBottomSheetFragment;
@ -48,15 +44,8 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class SearchResultActivity extends BaseActivity implements SearchPostSortTypeBottomSheetFragment.SearchSortTypeSelectionCallback,
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class SearchResultActivity extends AppCompatActivity implements SearchPostSortTypeBottomSheetFragment.SearchSortTypeSelectionCallback,
SearchUserAndSubredditSortTypeBottomSheetFragment.SearchUserAndSubredditSortTypeSelectionCallback { SearchUserAndSubredditSortTypeBottomSheetFragment.SearchUserAndSubredditSortTypeSelectionCallback {
static final String EXTRA_QUERY = "QK"; static final String EXTRA_QUERY = "QK";
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -87,18 +76,9 @@ public class SearchResultActivity extends AppCompatActivity implements SearchPos
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_search_result); setContentView(R.layout.activity_search_result);
@ -144,24 +124,6 @@ public class SearchResultActivity extends AppCompatActivity implements SearchPos
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -196,6 +158,11 @@ public class SearchResultActivity extends AppCompatActivity implements SearchPos
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndInitializeViewPager() { private void getCurrentAccountAndInitializeViewPager() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -14,8 +14,6 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -30,22 +28,13 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment; import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class SearchSubredditsResultActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class SearchSubredditsResultActivity extends AppCompatActivity {
static final String EXTRA_QUERY = "EQ"; static final String EXTRA_QUERY = "EQ";
static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN"; static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
@ -71,18 +60,9 @@ public class SearchSubredditsResultActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_search_subreddits_result); setContentView(R.layout.activity_search_subreddits_result);
@ -128,24 +108,6 @@ public class SearchSubredditsResultActivity extends AppCompatActivity {
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -166,6 +128,11 @@ public class SearchSubredditsResultActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndInitializeFragment(String query) { private void getCurrentAccountAndInitializeFragment(String query) {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -4,15 +4,13 @@ import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.TypedValue;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@ -21,21 +19,12 @@ import javax.inject.Inject;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class SettingsActivity extends BaseActivity implements
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class SettingsActivity extends AppCompatActivity implements
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback { PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
private static final String TITLE_STATE = "TS"; private static final String TITLE_STATE = "TS";
@ -48,20 +37,11 @@ public class SettingsActivity extends AppCompatActivity implements
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences setContentView(R.layout.activity_settings);
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.settings_activity);
ButterKnife.bind(this); ButterKnife.bind(this);
@ -70,25 +50,10 @@ public class SettingsActivity extends AppCompatActivity implements
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
} }
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor)); TypedValue typedValue = new TypedValue();
} getTheme().resolveAttribute(R.attr.navBarColor, typedValue, true);
int navBarColor = typedValue.data;
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; window.setNavigationBarColor(navBarColor);
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
} }
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -108,8 +73,11 @@ public class SettingsActivity extends AppCompatActivity implements
setTitle(R.string.settings_about_master_title); setTitle(R.string.settings_about_master_title);
} }
}); });
}
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
} }
@Override @Override

View File

@ -16,8 +16,6 @@ import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -36,27 +34,18 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class SubredditSelectionActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class SubredditSelectionActivity extends AppCompatActivity {
static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS"; static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS";
static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN"; static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
@ -91,18 +80,9 @@ public class SubredditSelectionActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_subreddit_selection); setContentView(R.layout.activity_subreddit_selection);
@ -151,24 +131,6 @@ public class SubredditSelectionActivity extends AppCompatActivity {
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -190,6 +152,11 @@ public class SubredditSelectionActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndBindView() { private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -12,8 +12,6 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -36,28 +34,19 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.FollowedUsersListingFragment; import ml.docilealligator.infinityforreddit.Fragment.FollowedUsersListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class SubscribedThingListingActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class SubscribedThingListingActivity extends AppCompatActivity {
private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS"; private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
private static final String NULL_ACCESS_TOKEN_STATE = "NATS"; private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
@ -87,18 +76,9 @@ public class SubscribedThingListingActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_subscribed_thing_listing); setContentView(R.layout.activity_subscribed_thing_listing);
@ -147,24 +127,6 @@ public class SubscribedThingListingActivity extends AppCompatActivity {
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -183,6 +145,11 @@ public class SubscribedThingListingActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndInitializeViewPager() { private void getCurrentAccountAndInitializeViewPager() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) { if (account == null) {

View File

@ -17,8 +17,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
@ -43,25 +41,16 @@ import ml.docilealligator.infinityforreddit.Adapter.MessageRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchMessages; import ml.docilealligator.infinityforreddit.FetchMessages;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MessageViewModel; import ml.docilealligator.infinityforreddit.MessageViewModel;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class ViewMessageActivity extends BaseActivity {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class ViewMessageActivity extends AppCompatActivity {
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN"; public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
@ -101,18 +90,9 @@ public class ViewMessageActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_view_message); setContentView(R.layout.activity_view_message);
@ -168,24 +148,6 @@ public class ViewMessageActivity extends AppCompatActivity {
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
toolbar.setTitle(R.string.inbox); toolbar.setTitle(R.string.inbox);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -205,6 +167,11 @@ public class ViewMessageActivity extends AppCompatActivity {
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndFetchMessage() { private void getCurrentAccountAndFetchMessage() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (mNewAccountName != null) { if (mNewAccountName != null) {

View File

@ -20,8 +20,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -53,7 +51,6 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CommentData; import ml.docilealligator.infinityforreddit.CommentData;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.DeleteThing; import ml.docilealligator.infinityforreddit.DeleteThing;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent; import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
@ -63,7 +60,6 @@ import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchComment; import ml.docilealligator.infinityforreddit.FetchComment;
import ml.docilealligator.infinityforreddit.FetchPost; import ml.docilealligator.infinityforreddit.FetchPost;
import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.HidePost; import ml.docilealligator.infinityforreddit.HidePost;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
@ -77,20 +73,15 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.RedditUtils; import ml.docilealligator.infinityforreddit.RedditUtils;
import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.EXTRA_COMMENT_DATA_KEY; import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.EXTRA_COMMENT_DATA_KEY;
import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.WRITE_COMMENT_REQUEST_CODE; import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.WRITE_COMMENT_REQUEST_CODE;
public class ViewPostDetailActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback { public class ViewPostDetailActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
public static final String EXTRA_POST_DATA = "EPD"; public static final String EXTRA_POST_DATA = "EPD";
public static final String EXTRA_POST_LIST_POSITION = "EPLI"; public static final String EXTRA_POST_LIST_POSITION = "EPLI";
@ -168,18 +159,9 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_view_post_detail); setContentView(R.layout.activity_view_post_detail);
@ -236,24 +218,6 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
toolbar.setTitle(""); toolbar.setTitle("");
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -288,6 +252,11 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
} }
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndBindView() { private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (mNewAccountName != null) { if (mNewAccountName != null) {

View File

@ -17,8 +17,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -46,11 +44,9 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsSubscribedToSubredditAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsSubscribedToSubredditAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchSubredditData; import ml.docilealligator.infinityforreddit.FetchSubredditData;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.PostTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment;
@ -60,21 +56,14 @@ import ml.docilealligator.infinityforreddit.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.ReadMessage;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditDao; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditDao;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
import ml.docilealligator.infinityforreddit.SubredditSubscription; import ml.docilealligator.infinityforreddit.SubredditSubscription;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class ViewSubredditDetailActivity extends BaseActivity implements SortTypeBottomSheetFragment.SortTypeSelectionCallback,
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class ViewSubredditDetailActivity extends AppCompatActivity implements SortTypeBottomSheetFragment.SortTypeSelectionCallback,
PostTypeBottomSheetFragment.PostTypeSelectionCallback { PostTypeBottomSheetFragment.PostTypeSelectionCallback {
public static final String EXTRA_SUBREDDIT_NAME_KEY = "ESN"; public static final String EXTRA_SUBREDDIT_NAME_KEY = "ESN";
@ -146,18 +135,9 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_view_subreddit_detail); setContentView(R.layout.activity_view_subreddit_detail);
@ -205,24 +185,6 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
} }
} }
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME_KEY); subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME_KEY);
if (savedInstanceState == null) { if (savedInstanceState == null) {
@ -349,6 +311,11 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
}); });
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndBindView() { private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (mNewAccountName != null) { if (mNewAccountName != null) {

View File

@ -7,6 +7,7 @@ import android.content.res.Resources;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.TypedValue;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -17,8 +18,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -50,12 +49,10 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsFollowingUserAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsFollowingUserAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
import ml.docilealligator.infinityforreddit.DeleteThing; import ml.docilealligator.infinityforreddit.DeleteThing;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchUserData; import ml.docilealligator.infinityforreddit.FetchUserData;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment;
@ -65,9 +62,7 @@ import ml.docilealligator.infinityforreddit.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.ReadMessage;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import ml.docilealligator.infinityforreddit.User.UserDao; import ml.docilealligator.infinityforreddit.User.UserDao;
import ml.docilealligator.infinityforreddit.User.UserData; import ml.docilealligator.infinityforreddit.User.UserData;
import ml.docilealligator.infinityforreddit.User.UserViewModel; import ml.docilealligator.infinityforreddit.User.UserViewModel;
@ -75,12 +70,7 @@ import ml.docilealligator.infinityforreddit.UserFollowing;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; public class ViewUserDetailActivity extends BaseActivity implements UserThingSortTypeBottomSheetFragment.UserThingSortTypeSelectionCallback {
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public class ViewUserDetailActivity extends AppCompatActivity implements UserThingSortTypeBottomSheetFragment.UserThingSortTypeSelectionCallback {
public static final String EXTRA_USER_NAME_KEY = "EUNK"; public static final String EXTRA_USER_NAME_KEY = "EUNK";
public static final String EXTRA_MESSAGE_FULLNAME = "ENF"; public static final String EXTRA_MESSAGE_FULLNAME = "ENF";
@ -150,18 +140,9 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences super.onCreate(savedInstanceState);
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
setContentView(R.layout.activity_view_user_detail); setContentView(R.layout.activity_view_user_detail);
@ -169,24 +150,6 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
switch (themeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
break;
case 2:
if (systemDefault) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
}
username = getIntent().getStringExtra(EXTRA_USER_NAME_KEY); username = getIntent().getStringExtra(EXTRA_USER_NAME_KEY);
if (savedInstanceState == null) { if (savedInstanceState == null) {
@ -234,13 +197,19 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
expandedTabTextColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor); expandedTabTextColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor);
expandedTabBackgroundColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabBackground);
expandedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabIndicator); expandedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabIndicator);
TypedValue expandedTabBackgroundColorTypedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.tabLayoutWithExpandedCollapsingToolbarTabBackground, expandedTabBackgroundColorTypedValue, true);
expandedTabBackgroundColor = expandedTabBackgroundColorTypedValue.data;
collapsedTabTextColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTextColor); collapsedTabTextColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTextColor);
collapsedTabBackgroundColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabBackground);
collapsedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabIndicator); collapsedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabIndicator);
TypedValue collapsedTabBackgroundColorTypedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.tabLayoutWithCollapsedCollapsingToolbarTabBackground, collapsedTabBackgroundColorTypedValue, true);
collapsedTabBackgroundColor = collapsedTabBackgroundColorTypedValue.data;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
&& (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT && (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
|| resources.getBoolean(R.bool.isTablet))) { || resources.getBoolean(R.bool.isTablet))) {
@ -418,6 +387,11 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment(); userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();
} }
@Override
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
private void getCurrentAccountAndInitializeViewPager() { private void getCurrentAccountAndInitializeViewPager() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (mNewAccountName != null) { if (mNewAccountName != null) {

View File

@ -9,6 +9,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -106,6 +107,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean isInitiallyLoadingFailed; private boolean isInitiallyLoadingFailed;
private boolean mHasMoreComments; private boolean mHasMoreComments;
private boolean loadMoreCommentsFailed; private boolean loadMoreCommentsFailed;
private int mCommentBackgroundColor;
public CommentAndPostRecyclerViewAdapter(Activity activity, Retrofit retrofit, Retrofit oauthRetrofit, public CommentAndPostRecyclerViewAdapter(Activity activity, Retrofit retrofit, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide, RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
@ -152,6 +154,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
isInitiallyLoadingFailed = false; isInitiallyLoadingFailed = false;
mHasMoreComments = false; mHasMoreComments = false;
loadMoreCommentsFailed = false; loadMoreCommentsFailed = false;
TypedValue typedValue = new TypedValue();
mActivity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
mCommentBackgroundColor = typedValue.data;
} }
@Override @Override
@ -1204,8 +1210,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
params.width = 0; params.width = 0;
((CommentViewHolder) holder).verticalBlock.setLayoutParams(params); ((CommentViewHolder) holder).verticalBlock.setLayoutParams(params);
((CommentViewHolder) holder).itemView.setPadding(0, 0, 0, 0); ((CommentViewHolder) holder).itemView.setPadding(0, 0, 0, 0);
((CommentViewHolder) holder).itemView.setBackgroundColor( ((CommentViewHolder) holder).itemView.setBackgroundColor(mCommentBackgroundColor);
mActivity.getResources().getColor(R.color.cardViewBackgroundColor));
} else if (holder instanceof PostDetailViewHolder) { } else if (holder instanceof PostDetailViewHolder) {
((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter(); ((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter();
((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -53,6 +54,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
private Resources mResources; private Resources mResources;
private NetworkState networkState; private NetworkState networkState;
private RetryLoadingMoreCallback mRetryLoadingMoreCallback; private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
private int mMessageBackgroundColor;
public MessageRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, String accessToken, public MessageRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, String accessToken,
RetryLoadingMoreCallback retryLoadingMoreCallback) { RetryLoadingMoreCallback retryLoadingMoreCallback) {
@ -81,6 +83,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
.build(); .build();
mAccessToken = accessToken; mAccessToken = accessToken;
mResources = context.getResources(); mResources = context.getResources();
TypedValue typedValue = new TypedValue();
mContext.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
mMessageBackgroundColor = typedValue.data;
} }
@NonNull @NonNull
@ -126,7 +132,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
} }
if (message.isNew()) { if (message.isNew()) {
((DataViewHolder) holder).itemView.setBackgroundColor(mResources.getColor(R.color.backgroundColor)); ((DataViewHolder) holder).itemView.setBackgroundColor(mMessageBackgroundColor);
message.setNew(false); message.setNew(false);
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, message.getFullname(), ReadMessage.readMessage(mOauthRetrofit, mAccessToken, message.getFullname(),
@ -183,7 +189,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder); super.onViewRecycled(holder);
if (holder instanceof DataViewHolder) { if (holder instanceof DataViewHolder) {
((DataViewHolder) holder).itemView.setBackgroundColor(mResources.getColor(R.color.backgroundColor)); ((DataViewHolder) holder).itemView.setBackgroundColor(mMessageBackgroundColor);
((DataViewHolder) holder).titleTextView.setVisibility(View.VISIBLE); ((DataViewHolder) holder).titleTextView.setVisibility(View.VISIBLE);
((DataViewHolder) holder).authorTextView.setTextColor(mResources.getColor(R.color.primaryTextColor)); ((DataViewHolder) holder).authorTextView.setTextColor(mResources.getColor(R.color.primaryTextColor));
} }

View File

@ -1,4 +1,4 @@
package ml.docilealligator.infinityforreddit.Event; package ml.docilealligator.infinityforreddit.Event;
public class ChangeFontSizeEvent { public class RecreateActivityEvent {
} }

View File

@ -48,6 +48,7 @@ public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
@ -72,6 +73,7 @@ public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO); ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO);
dismiss(); dismiss();
}); });
}
return rootView; return rootView;
} }

View File

@ -8,7 +8,7 @@ import androidx.preference.PreferenceFragmentCompat;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.Event.ChangeFontSizeEvent; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
@ -25,7 +25,7 @@ public class FontSizePreferenceFragment extends PreferenceFragmentCompat {
if (fontSizePreference != null) { if (fontSizePreference != null) {
fontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> { fontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeFontSizeEvent()); EventBus.getDefault().post(new RecreateActivityEvent());
activity.recreate(); activity.recreate();
return true; return true;
}); });
@ -33,14 +33,14 @@ public class FontSizePreferenceFragment extends PreferenceFragmentCompat {
if (titleFontSizePreference != null) { if (titleFontSizePreference != null) {
titleFontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> { titleFontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeFontSizeEvent()); EventBus.getDefault().post(new RecreateActivityEvent());
return true; return true;
}); });
} }
if (contentFontSizePreference != null) { if (contentFontSizePreference != null) {
contentFontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> { contentFontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeFontSizeEvent()); EventBus.getDefault().post(new RecreateActivityEvent());
return true; return true;
}); });
} }

View File

@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity; import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -18,6 +19,7 @@ import javax.inject.Inject;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent; import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
@ -43,11 +45,22 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
if (activity != null) { if (activity != null) {
((Infinity) activity.getApplication()).getAppComponent().inject(this); ((Infinity) activity.getApplication()).getAppComponent().inject(this);
SwitchPreference amoledDarkSwitch = findPreference(SharedPreferencesUtils.AMOLED_DARK_KEY);
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY); SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY); SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY); SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
ListPreference themePreference = findPreference(SharedPreferencesUtils.THEME_KEY); ListPreference themePreference = findPreference(SharedPreferencesUtils.THEME_KEY);
if(amoledDarkSwitch != null) {
amoledDarkSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_NO) {
EventBus.getDefault().post(new RecreateActivityEvent());
activity.recreate();
}
return true;
});
}
if (nsfwSwitch != null) { if (nsfwSwitch != null) {
nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> { nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue)); EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));

View File

@ -27,4 +27,5 @@ public class SharedPreferencesUtils {
public static final String FONT_SIZE_KEY = "font_size"; public static final String FONT_SIZE_KEY = "font_size";
public static final String TITLE_FONT_SIZE_KEY = "title_font_size"; public static final String TITLE_FONT_SIZE_KEY = "title_font_size";
public static final String CONTENT_FONT_SIZE_KEY = "content_font_size"; public static final String CONTENT_FONT_SIZE_KEY = "content_font_size";
public static final String AMOLED_DARK_KEY = "amoled_dark";
} }

View File

@ -4,12 +4,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:context=".Activity.AccountPostsActivity"> tools:context=".Activity.AccountPostsActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_account_posts_activity" android:id="@+id/appbar_layout_account_posts_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout

View File

@ -4,12 +4,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:context=".Activity.AccountPostsActivity"> tools:context=".Activity.AccountPostsActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_account_saved_thing_activity" android:id="@+id/appbar_layout_account_saved_thing_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
@ -35,7 +37,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="@color/greyTabBackgroundColor" android:background="?attr/toolbarAndTabBackgroundColor"
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
app:tabGravity="fill" app:tabGravity="fill"
app:tabIndicatorColor="@android:color/white" app:tabIndicatorColor="@android:color/white"

View File

@ -5,11 +5,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_comment_activity" android:id="@+id/coordinator_layout_comment_activity"
android:background="?attr/backgroundColor"
tools:application=".CommentActivity"> tools:application=".CommentActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -5,11 +5,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_edit_comment_activity" android:id="@+id/coordinator_layout_edit_comment_activity"
android:background="?attr/backgroundColor"
tools:context=".Activity.EditCommentActivity"> tools:context=".Activity.EditCommentActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -5,11 +5,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_edit_post_activity" android:id="@+id/coordinator_layout_edit_post_activity"
android:background="?attr/backgroundColor"
tools:context=".Activity.EditPostActivity"> tools:context=".Activity.EditPostActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -4,12 +4,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:application=".FilteredPostsActivity"> tools:application=".FilteredPostsActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_filtered_posts_activity" android:id="@+id/appbar_layout_filtered_posts_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout

View File

@ -4,11 +4,13 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:application="ml.docilealligator.infinityforreddit.Activity.LoginActivity"> tools:application="ml.docilealligator.infinityforreddit.Activity.LoginActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -5,6 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:background="?attr/backgroundColor"
tools:openDrawer="start"> tools:openDrawer="start">
<include <include
@ -16,7 +17,8 @@
android:id="@+id/nav_view" android:id="@+id/nav_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="start"> android:layout_gravity="start"
android:background="?attr/backgroundColor">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll_view_main_activity" android:id="@+id/nested_scroll_view_main_activity"

View File

@ -5,11 +5,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_post_image_activity" android:id="@+id/coordinator_layout_post_image_activity"
android:background="?attr/backgroundColor"
tools:application=".PostImageActivity"> tools:application=".PostImageActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -5,11 +5,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_post_link_activity" android:id="@+id/coordinator_layout_post_link_activity"
android:background="?attr/backgroundColor"
tools:application=".PostTextActivity"> tools:application=".PostTextActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -5,11 +5,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_post_text_activity" android:id="@+id/coordinator_layout_post_text_activity"
android:background="?attr/backgroundColor"
tools:application=".PostTextActivity"> tools:application=".PostTextActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -5,11 +5,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_post_video_activity" android:id="@+id/coordinator_layout_post_video_activity"
android:background="?attr/backgroundColor"
tools:application=".PostImageActivity"> tools:application=".PostImageActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -4,12 +4,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:application=".RulesActivity"> tools:application=".RulesActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_rules_activity" android:id="@+id/appbar_layout_rules_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout

View File

@ -4,11 +4,13 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:application=".SearchActivity"> tools:application=".SearchActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<FrameLayout <FrameLayout
@ -34,7 +36,7 @@
app:hintColor="#E0E0E0" app:hintColor="#E0E0E0"
app:iconsAlpha="1" app:iconsAlpha="1"
app:iconsTint="@android:color/white" app:iconsTint="@android:color/white"
app:searchBackground="@color/colorPrimary" app:searchBackground="?attr/colorPrimary"
app:voiceSearch="true" /> app:voiceSearch="true" />
</FrameLayout> </FrameLayout>

View File

@ -3,12 +3,14 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_search_result_activity" android:id="@+id/appbar_layout_search_result_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
@ -30,7 +32,7 @@
android:id="@+id/tab_layout_search_result_activity" android:id="@+id/tab_layout_search_result_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/greyTabBackgroundColor" android:background="?attr/toolbarAndTabBackgroundColor"
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
app:tabGravity="fill" app:tabGravity="fill"
app:tabMode="fixed" app:tabMode="fixed"

View File

@ -4,12 +4,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:application=".SearchSubredditsResultActivity"> tools:application=".SearchSubredditsResultActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_search_subreddits_result_activity" android:id="@+id/appbar_layout_search_subreddits_result_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -1,11 +1,13 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> android:background="?attr/backgroundColor">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -4,12 +4,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:application=".SubredditSelectionActivity"> tools:application=".SubredditSelectionActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_subreddit_selection_activity" android:id="@+id/appbar_layout_subreddit_selection_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout

View File

@ -4,12 +4,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:application=".SubscribedThingListingActivity"> tools:application=".SubscribedThingListingActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_subscribed_thing_listing_activity" android:id="@+id/appbar_layout_subscribed_thing_listing_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
@ -33,7 +35,7 @@
android:id="@+id/tab_layout_subscribed_thing_listing_activity" android:id="@+id/tab_layout_subscribed_thing_listing_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/greyTabBackgroundColor" android:background="?attr/toolbarAndTabBackgroundColor"
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
app:tabGravity="fill" app:tabGravity="fill"
app:tabMode="fixed" app:tabMode="fixed"

View File

@ -4,12 +4,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
tools:context=".Activity.ViewMessageActivity"> tools:context=".Activity.ViewMessageActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_view_message_activity" android:id="@+id/appbar_layout_view_message_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
@ -45,7 +47,7 @@
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
app:mlpb_progress_stoke_width="3dp" app:mlpb_progress_stoke_width="3dp"
app:mlpb_progress_color="@color/colorAccent" app:mlpb_progress_color="@color/colorAccent"
app:mlpb_background_color="@color/circularProgressBarBackground" /> app:mlpb_background_color="?attr/circularProgressBarBackground" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_view_message_activity" android:id="@+id/recycler_view_view_message_activity"

View File

@ -5,13 +5,14 @@
android:id="@+id/coordinator_layout_view_post_detail" android:id="@+id/coordinator_layout_view_post_detail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/cardViewBackgroundColor" android:background="?attr/backgroundColor"
tools:application=".ViewPostDetailActivity"> tools:application=".ViewPostDetailActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_view_post_detail_activity" android:id="@+id/appbar_layout_view_post_detail_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout

View File

@ -5,12 +5,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_view_subreddit_detail_activity" android:id="@+id/coordinator_layout_view_subreddit_detail_activity"
android:background="?attr/backgroundColor"
tools:application=".ViewSubredditDetailActivity"> tools:application=".ViewSubredditDetailActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_view_subreddit_detail" android:id="@+id/appbar_layout_view_subreddit_detail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
@ -50,7 +52,7 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:layout_below="@id/banner_image_view_view_subreddit_detail_activity" android:layout_below="@id/banner_image_view_view_subreddit_detail_activity"
android:background="@color/backgroundColor"> android:background="?attr/backgroundColor">
<TextView <TextView
android:id="@+id/subreddit_name_text_view_view_subreddit_detail_activity" android:id="@+id/subreddit_name_text_view_view_subreddit_detail_activity"

View File

@ -5,6 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/coordinator_layout_view_user_detail_activity" android:id="@+id/coordinator_layout_view_user_detail_activity"
android:background="?attr/backgroundColor"
tools:application=".ViewUserDetailActivity"> tools:application=".ViewUserDetailActivity">
<androidx.viewpager.widget.ViewPager <androidx.viewpager.widget.ViewPager
@ -17,6 +18,7 @@
android:id="@+id/appbar_layout_view_user_detail" android:id="@+id/appbar_layout_view_user_detail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
@ -56,7 +58,7 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:layout_below="@id/banner_image_view_view_user_detail_activity" android:layout_below="@id/banner_image_view_view_user_detail_activity"
android:background="@color/backgroundColor"> android:background="?attr/backgroundColor">
<TextView <TextView
android:id="@+id/user_name_text_view_view_user_detail_activity" android:id="@+id/user_name_text_view_view_user_detail_activity"
@ -106,6 +108,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="?attr/toolbarAndTabBackgroundColor"
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
app:tabGravity="fill" app:tabGravity="fill"
app:tabMode="fixed" app:tabMode="fixed"

View File

@ -11,6 +11,7 @@
android:id="@+id/appbar_layout_main_activity" android:id="@+id/appbar_layout_main_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
@ -36,7 +37,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="@color/greyTabBackgroundColor" android:background="?attr/toolbarAndTabBackgroundColor"
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
app:tabGravity="fill" app:tabGravity="fill"
app:tabIndicatorColor="@android:color/white" app:tabIndicatorColor="@android:color/white"

View File

@ -15,7 +15,7 @@
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
app:mlpb_progress_stoke_width="3dp" app:mlpb_progress_stoke_width="3dp"
app:mlpb_progress_color="@color/colorAccent" app:mlpb_progress_color="@color/colorAccent"
app:mlpb_background_color="@color/circularProgressBarBackground" app:mlpb_background_color="?attr/circularProgressBarBackground"
android:layout_gravity="center_horizontal"/> android:layout_gravity="center_horizontal"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

View File

@ -4,6 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:background="?attr/backgroundColor"
tools:application=".FlairBottomSheetFragment"> tools:application=".FlairBottomSheetFragment">
<TextView <TextView

View File

@ -13,7 +13,7 @@
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
app:mlpb_progress_stoke_width="3dp" app:mlpb_progress_stoke_width="3dp"
app:mlpb_progress_color="@color/colorAccent" app:mlpb_progress_color="@color/colorAccent"
app:mlpb_background_color="@color/circularProgressBarBackground" app:mlpb_background_color="?attr/circularProgressBarBackground"
android:layout_gravity="center_horizontal"/> android:layout_gravity="center_horizontal"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

View File

@ -15,7 +15,7 @@
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
app:mlpb_progress_stoke_width="3dp" app:mlpb_progress_stoke_width="3dp"
app:mlpb_progress_color="@color/colorAccent" app:mlpb_progress_color="@color/colorAccent"
app:mlpb_background_color="@color/circularProgressBarBackground" app:mlpb_background_color="?attr/circularProgressBarBackground"
android:layout_gravity="center_horizontal"/> android:layout_gravity="center_horizontal"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

View File

@ -15,7 +15,7 @@
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
app:mlpb_progress_stoke_width="3dp" app:mlpb_progress_stoke_width="3dp"
app:mlpb_progress_color="@color/colorAccent" app:mlpb_progress_color="@color/colorAccent"
app:mlpb_background_color="@color/circularProgressBarBackground" app:mlpb_background_color="?attr/circularProgressBarBackground"
android:layout_gravity="center_horizontal"/> android:layout_gravity="center_horizontal"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

View File

@ -5,7 +5,7 @@
android:id="@+id/linear_layout_item_comment" android:id="@+id/linear_layout_item_comment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/cardViewBackgroundColor"> android:background="?attr/cardViewBackgroundColor">
<View <View
android:id="@+id/vertical_block_item_post_comment" android:id="@+id/vertical_block_item_post_comment"

View File

@ -12,7 +12,7 @@
android:layout_margin="16dp" android:layout_margin="16dp"
app:mlpb_progress_stoke_width="3dp" app:mlpb_progress_stoke_width="3dp"
app:mlpb_progress_color="@color/colorAccent" app:mlpb_progress_color="@color/colorAccent"
app:mlpb_background_color="@color/circularProgressBarBackground" app:mlpb_background_color="?attr/circularProgressBarBackground"
android:layout_gravity="center_horizontal"/> android:layout_gravity="center_horizontal"/>
</LinearLayout> </LinearLayout>

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/cardViewBackgroundColor"> android:background="?attr/cardViewBackgroundColor">
<View <View
android:id="@+id/vertical_block_item_load_more_comments" android:id="@+id/vertical_block_item_load_more_comments"

View File

@ -2,7 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"> android:padding="16dp"
android:background="?attr/cardViewBackgroundColor">
<TextView <TextView
android:id="@+id/author_text_view_item_message" android:id="@+id/author_text_view_item_message"

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:id="@+id/card_view_item_post" android:id="@+id/card_view_item_post"
app:cardBackgroundColor="?attr/cardViewBackgroundColor"
app:cardElevation="2dp" app:cardElevation="2dp"
app:cardCornerRadius="16dp"> app:cardCornerRadius="16dp">

View File

@ -4,7 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/cardViewBackgroundColor"> android:background="?attr/cardViewBackgroundColor">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/relative_layout_item_post_detail" android:id="@+id/relative_layout_item_post_detail"

View File

@ -1,6 +1,5 @@
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height" android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar" android:background="@drawable/side_nav_bar"

View File

@ -12,8 +12,6 @@
<color name="colorPrimaryDarkDayNightTheme">#1E88E5</color> <color name="colorPrimaryDarkDayNightTheme">#1E88E5</color>
<color name="circularProgressBarBackground">#242424</color>
<color name="dividerColor">#69666C</color> <color name="dividerColor">#69666C</color>
<color name="grey">#424242</color> <color name="grey">#424242</color>
@ -62,5 +60,5 @@
<color name="commentVerticalBar6">#00B925</color> <color name="commentVerticalBar6">#00B925</color>
<color name="commentVerticalBar7">#EE4602</color> <color name="commentVerticalBar7">#EE4602</color>
<color name="greyTabBackgroundColor">#282828</color> <color name="toolbarAndTabBackgroundColor">#282828</color>
</resources> </resources>

View File

@ -25,4 +25,17 @@
<attr name="content_font_18" format="dimension"/> <attr name="content_font_18" format="dimension"/>
<attr name="content_font_20" format="dimension"/> <attr name="content_font_20" format="dimension"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="Theme">
<attr name="colorPrimary" format="color"/>
<attr name="colorPrimaryDark" format="color"/>
<attr name="backgroundColor" format="color"/>
<attr name="roundedBottomSheetPrimaryBackground" format="color"/>
<attr name="cardViewBackgroundColor" format="color"/>
<attr name="toolbarAndTabBackgroundColor" format="color"/>
<attr name="circularProgressBarBackground" format="color"/>
<attr name="tabLayoutWithExpandedCollapsingToolbarTabBackground" format="color"/>
<attr name="tabLayoutWithCollapsedCollapsingToolbarTabBackground" format="color"/>
<attr name="navBarColor" format="color" />
</declare-styleable>
</resources> </resources>

View File

@ -12,8 +12,6 @@
<color name="colorPrimaryDarkDayNightTheme">@color/colorPrimaryDark</color> <color name="colorPrimaryDarkDayNightTheme">@color/colorPrimaryDark</color>
<color name="circularProgressBarBackground">#FFFFFF</color>
<color name="dividerColor">#E0E0E0</color> <color name="dividerColor">#E0E0E0</color>
<color name="grey">#E0E0E0</color> <color name="grey">#E0E0E0</color>
@ -70,7 +68,7 @@
<color name="commentVerticalBar6">#02EE6E</color> <color name="commentVerticalBar6">#02EE6E</color>
<color name="commentVerticalBar7">#EE4602</color> <color name="commentVerticalBar7">#EE4602</color>
<color name="greyTabBackgroundColor">@color/colorPrimary</color> <color name="toolbarAndTabBackgroundColor">@color/colorPrimary</color>
<color name="submitter">#EE8A02</color> <color name="submitter">#EE8A02</color>

View File

@ -273,6 +273,7 @@
<string name="settings_theme_light__theme_summary">Light Theme</string> <string name="settings_theme_light__theme_summary">Light Theme</string>
<string name="settings_theme_dark_theme_summary">Dark Theme</string> <string name="settings_theme_dark_theme_summary">Dark Theme</string>
<string name="settings_theme_system_default_summary">Device default</string> <string name="settings_theme_system_default_summary">Device default</string>
<string name="settings_amoled_dark_title">Amoled Dark</string>
<string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string> <string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
<string name="settings_font_size_title">Font Size</string> <string name="settings_font_size_title">Font Size</string>
<string name="settings_title_font_size_title">Title Font Size</string> <string name="settings_title_font_size_title">Title Font Size</string>

View File

@ -3,8 +3,8 @@
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">?attr/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">?attr/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="android:navigationBarColor">@android:color/black</item> <item name="android:navigationBarColor">@android:color/black</item>
<item name="android:textColorPrimary">@android:color/white</item> <item name="android:textColorPrimary">@android:color/white</item>
@ -46,6 +46,7 @@
<style name="MaterialAlertDialogTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog"> <style name="MaterialAlertDialogTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="android:textSize">?attr/font_default</item> <item name="android:textSize">?attr/font_default</item>
<item name="android:background">?attr/cardViewBackgroundColor</item>
<item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle</item> <item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle</item>
<item name="materialAlertDialogBodyTextStyle">@style/MaterialAlertDialogBodyTextStyle</item> <item name="materialAlertDialogBodyTextStyle">@style/MaterialAlertDialogBodyTextStyle</item>
<item name="buttonBarPositiveButtonStyle">@style/MaterialAlertDialogPositiveButtonStyle</item> <item name="buttonBarPositiveButtonStyle">@style/MaterialAlertDialogPositiveButtonStyle</item>
@ -74,6 +75,7 @@
<item name="android:textColorPrimary">@color/primaryTextColor</item> <item name="android:textColorPrimary">@color/primaryTextColor</item>
<item name="buttonBarPositiveButtonStyle">@style/MaterialAlertDialogPositiveButtonStyle</item> <item name="buttonBarPositiveButtonStyle">@style/MaterialAlertDialogPositiveButtonStyle</item>
<item name="buttonBarNegativeButtonStyle">@style/MaterialAlertDialogNegativeButtonStyle</item> <item name="buttonBarNegativeButtonStyle">@style/MaterialAlertDialogNegativeButtonStyle</item>
<item name="alertDialogTheme">@style/ListPreferenceStyle</item>
</style> </style>
<style name="PreferenceTitleTextStyle"> <style name="PreferenceTitleTextStyle">
@ -85,6 +87,10 @@
<item name="android:textSize">?attr/font_default</item> <item name="android:textSize">?attr/font_default</item>
</style> </style>
<style name="ListPreferenceStyle" parent="ThemeOverlay.AppCompat.Dialog.Alert">
<item name="android:background">?attr/cardViewBackgroundColor</item>
</style>
<style name="FontStyle" /> <style name="FontStyle" />
<style name="FontStyle.Small"> <style name="FontStyle.Small">
@ -195,4 +201,45 @@
<item name="content_font_20">26sp</item> <item name="content_font_20">26sp</item>
</style> </style>
<style name="Theme" />
<style name="Theme.Default">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="backgroundColor">@color/backgroundColor</item>
<item name="roundedBottomSheetPrimaryBackground">@color/roundedBottomSheetPrimaryBackground</item>
<item name="cardViewBackgroundColor">@color/cardViewBackgroundColor</item>
<item name="toolbarAndTabBackgroundColor">@color/toolbarAndTabBackgroundColor</item>
<item name="circularProgressBarBackground">#FFFFFF</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#FFFFFF</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</item>
<item name="navBarColor">@color/backgroundColor</item>
</style>
<style name="Theme.Default.NormalDark">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="backgroundColor">@color/backgroundColor</item>
<item name="roundedBottomSheetPrimaryBackground">@color/roundedBottomSheetPrimaryBackground</item>
<item name="cardViewBackgroundColor">@color/cardViewBackgroundColor</item>
<item name="toolbarAndTabBackgroundColor">@color/toolbarAndTabBackgroundColor</item>
<item name="circularProgressBarBackground">@color/colorPrimary</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">@color/backgroundColor</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</item>
<item name="navBarColor">@color/backgroundColor</item>
</style>
<style name="Theme.Default.AmoledDark">
<item name="colorPrimary">#000000</item>
<item name="colorPrimaryDark">#000000</item>
<item name="backgroundColor">#000000</item>
<item name="roundedBottomSheetPrimaryBackground">#000000</item>
<item name="cardViewBackgroundColor">#000000</item>
<item name="toolbarAndTabBackgroundColor">#000000</item>
<item name="circularProgressBarBackground">#000000</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#000000</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">#000000</item>
<item name="navBarColor">#000000</item>
</style>
</resources> </resources>

View File

@ -15,6 +15,11 @@
app:title="@string/settings_theme_title" app:title="@string/settings_theme_title"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
<SwitchPreference
app:defaultValue="false"
app:key="amoled_dark"
app:title="@string/settings_amoled_dark_title" />
<ListPreference <ListPreference
app:defaultValue="2.5" app:defaultValue="2.5"
android:entries="@array/settings_lazy_mode_interval" android:entries="@array/settings_lazy_mode_interval"