Continue adding support for custom font.

This commit is contained in:
Alex Ning 2022-01-13 23:30:55 +08:00
parent e0c849e135
commit 6f1cd194cb
196 changed files with 2101 additions and 1033 deletions

View File

@ -65,11 +65,6 @@
<activity <activity
android:name=".activities.LockScreenActivity" android:name=".activities.LockScreenActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.AnonymousSubscriptionsActivity"
android:label="@string/subscriptions"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity <activity
android:name=".activities.WebViewActivity" android:name=".activities.WebViewActivity"
android:label="" android:label=""

View File

@ -5,7 +5,6 @@ import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
import ml.docilealligator.infinityforreddit.activities.AccountPostsActivity; import ml.docilealligator.infinityforreddit.activities.AccountPostsActivity;
import ml.docilealligator.infinityforreddit.activities.AccountSavedThingActivity; import ml.docilealligator.infinityforreddit.activities.AccountSavedThingActivity;
import ml.docilealligator.infinityforreddit.activities.AnonymousSubscriptionsActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity; import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.CreateMultiRedditActivity; import ml.docilealligator.infinityforreddit.activities.CreateMultiRedditActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity; import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity;
@ -271,8 +270,6 @@ public interface AppComponent {
void inject(CrashReportsFragment crashReportsFragment); void inject(CrashReportsFragment crashReportsFragment);
void inject(AnonymousSubscriptionsActivity anonymousSubscriptionsActivity);
void inject(LockScreenActivity lockScreenActivity); void inject(LockScreenActivity lockScreenActivity);
void inject(MaterialYouService materialYouService); void inject(MaterialYouService materialYouService);

View File

@ -0,0 +1,7 @@
package ml.docilealligator.infinityforreddit;
import android.graphics.Typeface;
public interface CustomFontReceiver {
void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface);
}

View File

@ -81,8 +81,8 @@ public class Infinity extends Application implements LifecycleObserver {
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override @Override
public void onActivityPreCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) { public void onActivityPreCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
if (activity instanceof BaseActivity) { if (activity instanceof CustomFontReceiver) {
((BaseActivity) activity).setCustomFont(typeface, titleTypeface, contentTypeface); ((CustomFontReceiver) activity).setCustomFont(typeface, titleTypeface, contentTypeface);
} }
} }

View File

@ -52,6 +52,7 @@ import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.post.PostPagingSource; import ml.docilealligator.infinityforreddit.post.PostPagingSource;
import ml.docilealligator.infinityforreddit.readpost.InsertReadPost; import ml.docilealligator.infinityforreddit.readpost.InsertReadPost;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface, public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface,
@ -179,10 +180,10 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> { new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) { switch (position) {
case 0: case 0:
tab.setText(R.string.posts); Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.posts));
break; break;
case 1: case 1:
tab.setText(R.string.comments); Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.comments));
break; break;
} }
}).attach(); }).attach();

View File

@ -1,116 +0,0 @@
package ml.docilealligator.infinityforreddit.activities;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.fragments.SubscribedSubredditsListingFragment;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class AnonymousSubscriptionsActivity extends BaseActivity {
@BindView(R.id.coordinator_layout_anonymous_subscriptions_activity)
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_anonymous_subscriptions_activity)
AppBarLayout appBarLayout;
@BindView(R.id.collapsing_toolbar_layout_anonymous_subscriptions_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_anonymous_subscriptions_activity)
Toolbar toolbar;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
setImmersiveModeNotApplicable();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_anonymous_subscriptions);
ButterKnife.bind(this);
applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
if (isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
if (isImmersiveInterface()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
coordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
} else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
adjustToolbar(toolbar);
}
}
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
SubscribedSubredditsListingFragment mFragment = new SubscribedSubredditsListingFragment();
Bundle bundle = new Bundle();
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, "-");
mFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_anonymous_subscriptions_activity, mFragment).commit();
}
@Override
protected SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}
@Override
protected CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return false;
}
}

View File

@ -20,6 +20,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.widget.TextView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -40,6 +41,7 @@ import java.util.Locale;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.font.ContentFontFamily; import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
@ -50,8 +52,9 @@ import ml.docilealligator.infinityforreddit.font.TitleFontFamily;
import ml.docilealligator.infinityforreddit.font.TitleFontStyle; import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
public abstract class BaseActivity extends AppCompatActivity { public abstract class BaseActivity extends AppCompatActivity implements CustomFontReceiver {
private boolean immersiveInterface; private boolean immersiveInterface;
private boolean changeStatusBarIconColor; private boolean changeStatusBarIconColor;
private boolean transparentStatusBarAfterToolbarCollapsed; private boolean transparentStatusBarAfterToolbarCollapsed;
@ -321,13 +324,21 @@ public abstract class BaseActivity extends AppCompatActivity {
if (toolbar.getOverflowIcon() != null) { if (toolbar.getOverflowIcon() != null) {
toolbar.getOverflowIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); toolbar.getOverflowIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
} }
if (typeface != null) {
toolbar.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) -> {
for (int j = 0; j < toolbar.getChildCount(); j++) {
if (toolbar.getChildAt(j) instanceof TextView) {
((TextView) toolbar.getChildAt(j)).setTypeface(typeface);
}
}
});
}
} }
@SuppressLint("RestrictedApi") @SuppressLint("RestrictedApi")
protected boolean applyMenuItemTheme(Menu menu) { protected boolean applyMenuItemTheme(Menu menu) {
if (customThemeWrapper != null) { if (customThemeWrapper != null) {
int size = Math.min(menu.size(), 2); for (int i = 0; i < menu.size(); i++) {
for (int i = 0; i < size; i++) {
MenuItem item = menu.getItem(i); MenuItem item = menu.getItem(i);
if (((MenuItemImpl) item).requestsActionButton()) { if (((MenuItemImpl) item).requestsActionButton()) {
Drawable drawable = item.getIcon(); Drawable drawable = item.getIcon();
@ -336,6 +347,7 @@ public abstract class BaseActivity extends AppCompatActivity {
item.setIcon(drawable); item.setIcon(drawable);
} }
} }
Utils.setTitleWithCustomFontToMenuItem(typeface, item, null);
} }
} }
return true; return true;
@ -372,6 +384,7 @@ public abstract class BaseActivity extends AppCompatActivity {
} catch (NoSuchFieldException | IllegalAccessException ignore) {} } catch (NoSuchFieldException | IllegalAccessException ignore) {}
} }
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) { public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface; this.typeface = typeface;
this.titleTypeface = titleTypeface; this.titleTypeface = titleTypeface;

View File

@ -243,6 +243,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
@Override @Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) { public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
if (contentTypeface != null) {
textView.setTypeface(contentTypeface);
}
textView.setTextColor(markdownColor); textView.setTextColor(markdownColor);
textView.setOnLongClickListener(view -> { textView.setOnLongClickListener(view -> {
Utils.hideKeyboard(CommentActivity.this); Utils.hideKeyboard(CommentActivity.this);
@ -357,6 +360,11 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor(); int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
commentEditText.setHintTextColor(secondaryTextColor); commentEditText.setHintTextColor(secondaryTextColor);
markdownColor = secondaryTextColor; markdownColor = secondaryTextColor;
if (typeface != null) {
commentParentMarkwonView.setTypeface(typeface);
commentEditText.setTypeface(typeface);
}
} }
@Override @Override

View File

@ -38,6 +38,7 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.multireddit.CreateMultiReddit; import ml.docilealligator.infinityforreddit.multireddit.CreateMultiReddit;
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel; import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class CreateMultiRedditActivity extends BaseActivity { public class CreateMultiRedditActivity extends BaseActivity {
@ -235,5 +236,9 @@ public class CreateMultiRedditActivity extends BaseActivity {
descriptionEditText.setHintTextColor(secondaryTextColor); descriptionEditText.setHintTextColor(secondaryTextColor);
visibilityTextView.setTextColor(primaryTextColor); visibilityTextView.setTextColor(primaryTextColor);
selectSubredditTextView.setTextColor(primaryTextColor); selectSubredditTextView.setTextColor(primaryTextColor);
if (typeface != null) {
Utils.setFontToAllTextViews(coordinatorLayout, typeface);
}
} }
} }

View File

@ -9,6 +9,7 @@ import android.content.SharedPreferences;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.TypedValue; import android.util.TypedValue;
@ -48,6 +49,7 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme; import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
@ -59,10 +61,14 @@ import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.fragments.ThemePreviewCommentsFragment; import ml.docilealligator.infinityforreddit.fragments.ThemePreviewCommentsFragment;
import ml.docilealligator.infinityforreddit.fragments.ThemePreviewPostsFragment; import ml.docilealligator.infinityforreddit.fragments.ThemePreviewPostsFragment;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class CustomThemePreviewActivity extends AppCompatActivity { public class CustomThemePreviewActivity extends AppCompatActivity implements CustomFontReceiver {
public static final String EXTRA_CUSTOM_THEME_SETTINGS_ITEMS = "ECTSI"; public static final String EXTRA_CUSTOM_THEME_SETTINGS_ITEMS = "ECTSI";
public Typeface typeface;
public Typeface titleTypeface;
public Typeface contentTypeface;
@BindView(R.id.coordinator_layout_theme_preview_activity) @BindView(R.id.coordinator_layout_theme_preview_activity)
CoordinatorLayout coordinatorLayout; CoordinatorLayout coordinatorLayout;
@ -357,6 +363,13 @@ public class CustomThemePreviewActivity extends AppCompatActivity {
applyFABTheme(fab); applyFABTheme(fab);
unsubscribedColor = customTheme.unsubscribed; unsubscribedColor = customTheme.unsubscribed;
subscribedColor = customTheme.subscribed; subscribedColor = customTheme.subscribed;
if (typeface != null) {
subredditNameTextView.setTypeface(typeface);
usernameTextView.setTypeface(typeface);
primaryTextView.setTypeface(typeface);
secondaryTextView.setTypeface(typeface);
subscribeSubredditChip.setTypeface(typeface);
}
} }
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) { protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) {
@ -369,6 +382,15 @@ public class CustomThemePreviewActivity extends AppCompatActivity {
if (toolbar.getOverflowIcon() != null) { if (toolbar.getOverflowIcon() != null) {
toolbar.getOverflowIcon().setColorFilter(customTheme.toolbarPrimaryTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN); toolbar.getOverflowIcon().setColorFilter(customTheme.toolbarPrimaryTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
} }
if (typeface != null) {
toolbar.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) -> {
for (int j = 0; j < toolbar.getChildCount(); j++) {
if (toolbar.getChildAt(j) instanceof TextView) {
((TextView) toolbar.getChildAt(j)).setTypeface(typeface);
}
}
});
}
} }
private void adjustToolbar(Toolbar toolbar) { private void adjustToolbar(Toolbar toolbar) {
@ -424,6 +446,13 @@ public class CustomThemePreviewActivity extends AppCompatActivity {
} }
} }
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
this.titleTypeface = titleTypeface;
this.contentTypeface = contentTypeface;
}
private class SectionsPagerAdapter extends FragmentPagerAdapter { private class SectionsPagerAdapter extends FragmentPagerAdapter {
private ThemePreviewPostsFragment themePreviewPostsFragment; private ThemePreviewPostsFragment themePreviewPostsFragment;
private ThemePreviewCommentsFragment themePreviewCommentsFragment; private ThemePreviewCommentsFragment themePreviewCommentsFragment;
@ -450,9 +479,9 @@ public class CustomThemePreviewActivity extends AppCompatActivity {
public CharSequence getPageTitle(int position) { public CharSequence getPageTitle(int position) {
switch (position) { switch (position) {
case 0: case 0:
return "Posts"; return Utils.getTabTextWithCustomFont(typeface, "Posts");
case 1: case 1:
return "Comments"; return Utils.getTabTextWithCustomFont(typeface, "Comments");
} }
return null; return null;
} }

View File

@ -498,6 +498,10 @@ public class CustomizePostFilterActivity extends BaseActivity {
setCursorDrawableColor(minAwardsTextInputEditText, primaryTextColor); setCursorDrawableColor(minAwardsTextInputEditText, primaryTextColor);
setCursorDrawableColor(maxAwardsTextInputEditText, primaryTextColor); setCursorDrawableColor(maxAwardsTextInputEditText, primaryTextColor);
} }
if (typeface != null) {
Utils.setFontToAllTextViews(coordinatorLayout, typeface);
}
} }
public static void setCursorDrawableColor(EditText editText, int color) { public static void setCursorDrawableColor(EditText editText, int color) {

View File

@ -185,6 +185,10 @@ public class EditCommentActivity extends BaseActivity implements UploadImageEnab
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
contentEditText.setTextColor(mCustomThemeWrapper.getCommentColor()); contentEditText.setTextColor(mCustomThemeWrapper.getCommentColor());
if (contentTypeface != null) {
contentEditText.setTypeface(contentTypeface);
}
} }
@Override @Override

View File

@ -41,6 +41,7 @@ import ml.docilealligator.infinityforreddit.multireddit.FetchMultiRedditInfo;
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit; import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel; import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class EditMultiRedditActivity extends BaseActivity { public class EditMultiRedditActivity extends BaseActivity {
@ -288,5 +289,9 @@ public class EditMultiRedditActivity extends BaseActivity {
descriptionEditText.setHintTextColor(secondaryTextColor); descriptionEditText.setHintTextColor(secondaryTextColor);
visibilityTextView.setTextColor(primaryTextColor); visibilityTextView.setTextColor(primaryTextColor);
selectSubredditTextView.setTextColor(primaryTextColor); selectSubredditTextView.setTextColor(primaryTextColor);
if (typeface != null) {
Utils.setFontToAllTextViews(coordinatorLayout, typeface);
}
} }
} }

View File

@ -196,6 +196,13 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor()); titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor());
divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor()); divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor());
contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor()); contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
if (titleTypeface != null) {
titleTextView.setTypeface(titleTypeface);
}
if (contentTypeface != null) {
contentEditText.setTypeface(contentTypeface);
}
} }
@Override @Override

View File

@ -52,6 +52,7 @@ import ml.docilealligator.infinityforreddit.services.EditProfileService;
import ml.docilealligator.infinityforreddit.user.UserViewModel; import ml.docilealligator.infinityforreddit.user.UserViewModel;
import ml.docilealligator.infinityforreddit.utils.EditProfileUtils; import ml.docilealligator.infinityforreddit.utils.EditProfileUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -61,7 +62,7 @@ public class EditProfileActivity extends BaseActivity {
private static final int PICK_IMAGE_AVATAR_REQUEST_CODE = 0x402; private static final int PICK_IMAGE_AVATAR_REQUEST_CODE = 0x402;
@BindView(R.id.root_layout_view_edit_profile_activity) @BindView(R.id.root_layout_view_edit_profile_activity)
CoordinatorLayout root; CoordinatorLayout coordinatorLayout;
@BindView(R.id.content_view_edit_profile_activity) @BindView(R.id.content_view_edit_profile_activity)
LinearLayout content; LinearLayout content;
@BindView(R.id.collapsing_toolbar_layout_edit_profile_activity) @BindView(R.id.collapsing_toolbar_layout_edit_profile_activity)
@ -344,9 +345,11 @@ public class EditProfileActivity extends BaseActivity {
@Override @Override
protected void applyCustomTheme() { protected void applyCustomTheme() {
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
root.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
changeColorTextView(content, mCustomThemeWrapper.getPrimaryTextColor()); changeColorTextView(content, mCustomThemeWrapper.getPrimaryTextColor());
if (typeface != null) {
Utils.setFontToAllTextViews(coordinatorLayout, typeface);
}
} }
private void changeColorTextView(ViewGroup viewGroup, int color) { private void changeColorTextView(ViewGroup viewGroup, int color) {

View File

@ -3,14 +3,10 @@ package ml.docilealligator.infinityforreddit.activities;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
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;
@ -33,9 +29,6 @@ import org.commonmark.ext.gfm.tables.TableBlock;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -63,9 +56,8 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager; import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin; import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor; import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
public class FullMarkdownActivity extends BaseActivity { public class FullMarkdownActivity extends BaseActivity {
@ -157,6 +149,9 @@ public class FullMarkdownActivity extends BaseActivity {
@Override @Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) { public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
if (typeface != null) {
textView.setTypeface(typeface);
}
textView.setTextColor(markdownColor); textView.setTextColor(markdownColor);
} }

View File

@ -19,7 +19,6 @@ import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.switchmaterial.SwitchMaterial; import com.google.android.material.switchmaterial.SwitchMaterial;
@ -113,7 +112,7 @@ public class GiveAwardActivity extends BaseActivity {
} }
private void bindView() { private void bindView() {
adapter = new AwardRecyclerViewAdapter(Glide.with(this), mCustomThemeWrapper, award -> { adapter = new AwardRecyclerViewAdapter(this, mCustomThemeWrapper, award -> {
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.dialog_give_award, null); View layout = inflater.inflate(R.layout.dialog_give_award, null);
SwitchMaterial switchMaterial = layout.findViewById(R.id.switch_material_give_award_dialog); SwitchMaterial switchMaterial = layout.findViewById(R.id.switch_material_give_award_dialog);

View File

@ -58,6 +58,7 @@ import ml.docilealligator.infinityforreddit.fragments.InboxFragment;
import ml.docilealligator.infinityforreddit.message.FetchMessage; import ml.docilealligator.infinityforreddit.message.FetchMessage;
import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -283,10 +284,10 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> { new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) { switch (position) {
case 0: case 0:
tab.setText(R.string.notifications); Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.notifications));
break; break;
case 1: case 1:
tab.setText(R.string.messages); Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.messages));
break; break;
} }
}).attach(); }).attach();

View File

@ -98,6 +98,10 @@ public class LockScreenActivity extends BaseActivity {
textView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); textView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
unlockButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); unlockButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
unlockButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme()); unlockButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
if (typeface != null) {
textView.setTypeface(typeface);
unlockButton.setTypeface(typeface);
}
} }
@Override @Override

View File

@ -286,6 +286,9 @@ public class LoginActivity extends BaseActivity {
Drawable infoDrawable = Utils.getTintedDrawable(this, R.drawable.ic_info_preference_24dp, mCustomThemeWrapper.getPrimaryIconColor()); Drawable infoDrawable = Utils.getTintedDrawable(this, R.drawable.ic_info_preference_24dp, mCustomThemeWrapper.getPrimaryIconColor());
twoFAInfoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); twoFAInfoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null);
applyFABTheme(fab); applyFABTheme(fab);
if (typeface != null) {
twoFAInfoTextView.setTypeface(typeface);
}
} }
@Override @Override

View File

@ -25,7 +25,6 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -355,12 +354,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
applyTabLayoutTheme(tabLayout); applyTabLayoutTheme(tabLayout);
bottomAppBar.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor())); bottomAppBar.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
applyFABTheme(fab); applyFABTheme(fab);
for (int i = 0; i < toolbar.getChildCount(); i++) {
View view = toolbar.getChildAt(i);
if (view instanceof TextView) {
((TextView) view).setTypeface(typeface);
}
}
} }
private void initializeNotificationAndBindView(boolean doNotInitializeNotificationIfNoNewAccount) { private void initializeNotificationAndBindView(boolean doNotInitializeNotificationIfNoNewAccount) {
@ -858,32 +851,32 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> { new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) { switch (position) {
case 0: case 0:
tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home))); Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
break; break;
case 1: case 1:
tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular))); Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)));
break; break;
case 2: case 2:
tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all))); Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
break; break;
} }
if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits || if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits)
&& sectionsPagerAdapter != null) { && sectionsPagerAdapter != null) {
if (position - tabCount < sectionsPagerAdapter.favoriteMultiReddits.size()) { if (position - tabCount < sectionsPagerAdapter.favoriteMultiReddits.size()) {
tab.setText(sectionsPagerAdapter.favoriteMultiReddits.get(position - tabCount).getName()); Utils.setTitleWithCustomFontToTab(typeface, tab, sectionsPagerAdapter.favoriteMultiReddits.get(position - tabCount).getName());
} else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size() < sectionsPagerAdapter.multiReddits.size()) { } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size() < sectionsPagerAdapter.multiReddits.size()) {
tab.setText(sectionsPagerAdapter.multiReddits.get(position - tabCount Utils.setTitleWithCustomFontToTab(typeface, tab, sectionsPagerAdapter.multiReddits.get(position - tabCount
- sectionsPagerAdapter.favoriteMultiReddits.size()).getName()); - sectionsPagerAdapter.favoriteMultiReddits.size()).getName());
} else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size() } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size()
- sectionsPagerAdapter.multiReddits.size() < sectionsPagerAdapter.favoriteSubscribedSubreddits.size()) { - sectionsPagerAdapter.multiReddits.size() < sectionsPagerAdapter.favoriteSubscribedSubreddits.size()) {
tab.setText(sectionsPagerAdapter.favoriteSubscribedSubreddits.get(position - tabCount Utils.setTitleWithCustomFontToTab(typeface, tab, sectionsPagerAdapter.favoriteSubscribedSubreddits.get(position - tabCount
- sectionsPagerAdapter.favoriteMultiReddits.size() - sectionsPagerAdapter.favoriteMultiReddits.size()
- sectionsPagerAdapter.multiReddits.size()).getName()); - sectionsPagerAdapter.multiReddits.size()).getName());
} else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size() } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size()
- sectionsPagerAdapter.multiReddits.size() - sectionsPagerAdapter.multiReddits.size()
- sectionsPagerAdapter.favoriteSubscribedSubreddits.size() < sectionsPagerAdapter.subscribedSubreddits.size()) { - sectionsPagerAdapter.favoriteSubscribedSubreddits.size() < sectionsPagerAdapter.subscribedSubreddits.size()) {
tab.setText(sectionsPagerAdapter.subscribedSubreddits.get(position - tabCount Utils.setTitleWithCustomFontToTab(typeface, tab, sectionsPagerAdapter.subscribedSubreddits.get(position - tabCount
- sectionsPagerAdapter.favoriteMultiReddits.size() - sectionsPagerAdapter.favoriteMultiReddits.size()
- sectionsPagerAdapter.multiReddits.size() - sectionsPagerAdapter.multiReddits.size()
- sectionsPagerAdapter.favoriteSubscribedSubreddits.size()).getName()); - sectionsPagerAdapter.favoriteSubscribedSubreddits.size()).getName());

View File

@ -98,7 +98,7 @@ public class PostFilterPreferenceActivity extends BaseActivity {
} }
}); });
adapter = new PostFilterRecyclerViewAdapter(postFilter -> { adapter = new PostFilterRecyclerViewAdapter(this, postFilter -> {
if (post != null) { if (post != null) {
showPostFilterOptions(post, postFilter); showPostFilterOptions(post, postFilter);
} else if (subredditName != null) { } else if (subredditName != null) {

View File

@ -425,6 +425,15 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
nsfwTextView.setTextColor(primaryTextColor); nsfwTextView.setTextColor(primaryTextColor);
titleEditText.setTextColor(primaryTextColor); titleEditText.setTextColor(primaryTextColor);
titleEditText.setHintTextColor(secondaryTextColor); titleEditText.setHintTextColor(secondaryTextColor);
if (typeface != null) {
subredditNameTextView.setTypeface(typeface);
rulesButton.setTypeface(typeface);
receivePostReplyNotificationsTextView.setTypeface(typeface);
flairTextView.setTypeface(typeface);
spoilerTextView.setTypeface(typeface);
nsfwTextView.setTypeface(typeface);
titleEditText.setTypeface(typeface);
}
} }
public void selectImage() { public void selectImage() {

View File

@ -409,6 +409,16 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
applyFABTheme(captureFab); applyFABTheme(captureFab);
applyFABTheme(selectFromLibraryFab); applyFABTheme(selectFromLibraryFab);
selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
if (typeface != null) {
subredditNameTextView.setTypeface(typeface);
rulesButton.setTypeface(typeface);
receivePostReplyNotificationsTextView.setTypeface(typeface);
flairTextView.setTypeface(typeface);
spoilerTextView.setTypeface(typeface);
nsfwTextView.setTypeface(typeface);
titleEditText.setTypeface(typeface);
selectAgainTextView.setTypeface(typeface);
}
} }
private void loadImage() { private void loadImage() {

View File

@ -384,6 +384,19 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
suggestTitleButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); suggestTitleButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
linkEditText.setTextColor(primaryTextColor); linkEditText.setTextColor(primaryTextColor);
linkEditText.setHintTextColor(secondaryTextColor); linkEditText.setHintTextColor(secondaryTextColor);
if (typeface != null) {
subredditNameTextView.setTypeface(typeface);
rulesButton.setTypeface(typeface);
receivePostReplyNotificationsTextView.setTypeface(typeface);
flairTextView.setTypeface(typeface);
spoilerTextView.setTypeface(typeface);
nsfwTextView.setTypeface(typeface);
titleEditText.setTypeface(typeface);
suggestTitleButton.setTypeface(typeface);
}
if (contentTypeface != null) {
linkEditText.setTypeface(contentTypeface);
}
} }
private void displaySubredditIcon() { private void displaySubredditIcon() {

View File

@ -406,6 +406,18 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
titleEditText.setHintTextColor(secondaryTextColor); titleEditText.setHintTextColor(secondaryTextColor);
contentEditText.setTextColor(primaryTextColor); contentEditText.setTextColor(primaryTextColor);
contentEditText.setHintTextColor(secondaryTextColor); contentEditText.setHintTextColor(secondaryTextColor);
if (typeface != null) {
subredditNameTextView.setTypeface(typeface);
rulesButton.setTypeface(typeface);
receivePostReplyNotificationsTextView.setTypeface(typeface);
flairTextView.setTypeface(typeface);
spoilerTextView.setTypeface(typeface);
nsfwTextView.setTypeface(typeface);
titleEditText.setTypeface(typeface);
}
if (contentTypeface != null) {
contentEditText.setTypeface(typeface);
}
} }
private void displaySubredditIcon() { private void displaySubredditIcon() {

View File

@ -424,6 +424,16 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
applyFABTheme(captureFab); applyFABTheme(captureFab);
applyFABTheme(selectFromLibraryFab); applyFABTheme(selectFromLibraryFab);
selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
if (typeface != null) {
subredditNameTextView.setTypeface(typeface);
rulesButton.setTypeface(typeface);
receivePostReplyNotificationsTextView.setTypeface(typeface);
flairTextView.setTypeface(typeface);
spoilerTextView.setTypeface(typeface);
nsfwTextView.setTypeface(typeface);
titleEditText.setTypeface(typeface);
selectAgainTextView.setTypeface(typeface);
}
} }
private void loadVideo() { private void loadVideo() {

View File

@ -4,6 +4,7 @@ import android.content.ActivityNotFoundException;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.media.AudioManager; import android.media.AudioManager;
@ -46,6 +47,7 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RPANBroadcast; import ml.docilealligator.infinityforreddit.RPANBroadcast;
@ -60,13 +62,14 @@ import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.fragments.ViewRPANBroadcastFragment; import ml.docilealligator.infinityforreddit.fragments.ViewRPANBroadcastFragment;
import ml.docilealligator.infinityforreddit.utils.JSONUtils; import ml.docilealligator.infinityforreddit.utils.JSONUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class RPANActivity extends AppCompatActivity { public class RPANActivity extends AppCompatActivity implements CustomFontReceiver {
public static final String EXTRA_RPAN_BROADCAST_FULLNAME_OR_ID = "ERBFOI"; public static final String EXTRA_RPAN_BROADCAST_FULLNAME_OR_ID = "ERBFOI";
@ -90,6 +93,7 @@ public class RPANActivity extends AppCompatActivity {
ArrayList<RPANBroadcast> rpanBroadcasts; ArrayList<RPANBroadcast> rpanBroadcasts;
@State @State
String nextCursor; String nextCursor;
public Typeface typeface;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
@Override @Override
@ -130,7 +134,7 @@ public class RPANActivity extends AppCompatActivity {
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
actionBar.setHomeAsUpIndicator(upArrow); actionBar.setHomeAsUpIndicator(upArrow);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000"))); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));
actionBar.setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.rpan_activity_label) + "</font>")); actionBar.setTitle(Utils.getTabTextWithCustomFont(typeface, Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.rpan_activity_label) + "</font>")));
if (rpanBroadcasts == null) { if (rpanBroadcasts == null) {
loadRPANVideos(); loadRPANVideos();
@ -337,6 +341,9 @@ public class RPANActivity extends AppCompatActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.rpan_activity, menu); getMenuInflater().inflate(R.menu.rpan_activity, menu);
for (int i = 0; i < menu.size(); i++) {
Utils.setTitleWithCustomFontToMenuItem(typeface, menu.getItem(i), null);
}
return true; return true;
} }
@ -382,6 +389,11 @@ public class RPANActivity extends AppCompatActivity {
} }
} }
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
}
private class SectionsPagerAdapter extends FragmentStateAdapter { private class SectionsPagerAdapter extends FragmentStateAdapter {
public SectionsPagerAdapter(FragmentActivity fa) { public SectionsPagerAdapter(FragmentActivity fa) {

View File

@ -112,9 +112,9 @@ public class ReportActivity extends BaseActivity {
} }
if (generalReasons != null) { if (generalReasons != null) {
mAdapter = new ReportReasonRecyclerViewAdapter(mCustomThemeWrapper, generalReasons); mAdapter = new ReportReasonRecyclerViewAdapter(this, mCustomThemeWrapper, generalReasons);
} else { } else {
mAdapter = new ReportReasonRecyclerViewAdapter(mCustomThemeWrapper, ReportReason.getGeneralReasons(this)); mAdapter = new ReportReasonRecyclerViewAdapter(this, mCustomThemeWrapper, ReportReason.getGeneralReasons(this));
} }
recyclerView.setAdapter(mAdapter); recyclerView.setAdapter(mAdapter);

View File

@ -160,6 +160,9 @@ public class RulesActivity extends BaseActivity {
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorAccent())); progressBar.setIndeterminateTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorAccent()));
errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (typeface != null) {
errorTextView.setTypeface(typeface);
}
} }
private void displayError() { private void displayError() {

View File

@ -51,6 +51,7 @@ import ml.docilealligator.infinityforreddit.subreddit.ParseSubredditData;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData; import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -360,6 +361,9 @@ public class SearchActivity extends BaseActivity {
searchInTextView.setTextColor(colorAccent); searchInTextView.setTextColor(colorAccent);
subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor()); divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
if (typeface != null) {
Utils.setFontToAllTextViews(coordinatorLayout, typeface);
}
} }
@Override @Override

View File

@ -258,13 +258,13 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> { new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) { switch (position) {
case 0: case 0:
tab.setText(R.string.posts); Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.posts));
break; break;
case 1: case 1:
tab.setText(R.string.subreddits); Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.subreddits));
break; break;
case 2: case 2:
tab.setText(R.string.users); Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.users));
break; break;
} }
}).attach(); }).attach();

View File

@ -129,7 +129,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
} }
private void instantiateRecyclerView() { private void instantiateRecyclerView() {
mAdapter = new UserFlairRecyclerViewAdapter(mCustomThemeWrapper, mUserFlairs, (userFlair, editUserFlair) -> { mAdapter = new UserFlairRecyclerViewAdapter(this, mCustomThemeWrapper, mUserFlairs, (userFlair, editUserFlair) -> {
if (editUserFlair) { if (editUserFlair) {
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_flair, null); View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_flair, null);
EditText flairEditText = dialogView.findViewById(R.id.flair_edit_text_edit_flair_dialog); EditText flairEditText = dialogView.findViewById(R.id.flair_edit_text_edit_flair_dialog);

View File

@ -90,7 +90,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
subreddits = getIntent().getStringArrayListExtra(EXTRA_SELECTED_SUBREDDITS); subreddits = getIntent().getStringArrayListExtra(EXTRA_SELECTED_SUBREDDITS);
} }
adapter = new SelectedSubredditsRecyclerViewAdapter(mCustomThemeWrapper, subreddits); adapter = new SelectedSubredditsRecyclerViewAdapter(this, mCustomThemeWrapper, subreddits);
linearLayoutManager = new LinearLayoutManagerBugFixed(this); linearLayoutManager = new LinearLayoutManagerBugFixed(this);
recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);

View File

@ -186,5 +186,10 @@ public class SendPrivateMessageActivity extends BaseActivity {
int dividerColor = mCustomThemeWrapper.getDividerColor(); int dividerColor = mCustomThemeWrapper.getDividerColor();
divider1.setBackgroundColor(dividerColor); divider1.setBackgroundColor(dividerColor);
divider2.setBackgroundColor(dividerColor); divider2.setBackgroundColor(dividerColor);
if (typeface != null) {
usernameEditText.setTypeface(typeface);
subjectEditText.setTypeface(typeface);
messageEditText.setTypeface(typeface);
}
} }
} }

View File

@ -418,6 +418,18 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
contentTextView.setHintTextColor(secondaryTextColor); contentTextView.setHintTextColor(secondaryTextColor);
playButton.setColorFilter(mCustomThemeWrapper.getMediaIndicatorIconColor(), PorterDuff.Mode.SRC_IN); playButton.setColorFilter(mCustomThemeWrapper.getMediaIndicatorIconColor(), PorterDuff.Mode.SRC_IN);
playButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getMediaIndicatorBackgroundColor())); playButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getMediaIndicatorBackgroundColor()));
if (typeface != null) {
subredditNameTextView.setTypeface(typeface);
rulesButton.setTypeface(typeface);
receivePostReplyNotificationsTextView.setTypeface(typeface);
flairTextView.setTypeface(typeface);
spoilerTextView.setTypeface(typeface);
nsfwTextView.setTypeface(typeface);
titleEditText.setTypeface(typeface);
}
if (contentTypeface != null) {
contentTextView.setTypeface(contentTypeface);
}
} }
private void displaySubredditIcon() { private void displaySubredditIcon() {

View File

@ -231,6 +231,9 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (typeface != null) {
mErrorTextView.setTypeface(typeface);
}
} }
@Override @Override

View File

@ -69,6 +69,7 @@ import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData; import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface { public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
@ -508,11 +509,11 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
public CharSequence getPageTitle(int position) { public CharSequence getPageTitle(int position) {
switch (position) { switch (position) {
case 0: case 0:
return getString(R.string.subreddits); return Utils.getTabTextWithCustomFont(typeface, getString(R.string.subreddits));
case 1: case 1:
return getString(R.string.users); return Utils.getTabTextWithCustomFont(typeface, getString(R.string.users));
case 2: case 2:
return getString(R.string.multi_reddits); return Utils.getTabTextWithCustomFont(typeface, getString(R.string.multi_reddits));
} }
return null; return null;

View File

@ -84,5 +84,10 @@ public class SuicidePreventionActivity extends BaseActivity {
doNotShowThisAgainTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); doNotShowThisAgainTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
continueButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); continueButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme()));
continueButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); continueButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
if (typeface != null) {
quoteTextView.setTypeface(typeface);
doNotShowThisAgainTextView.setTypeface(typeface);
continueButton.setTypeface(typeface);
}
} }
} }

View File

@ -332,6 +332,9 @@ public class TrendingActivity extends BaseActivity {
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (typeface != null) {
errorTextView.setTypeface(typeface);
}
} }
@Subscribe @Subscribe

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
@ -60,6 +61,7 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.BuildConfig; import ml.docilealligator.infinityforreddit.BuildConfig;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback; import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
@ -75,8 +77,9 @@ import ml.docilealligator.infinityforreddit.font.TitleFontFamily;
import ml.docilealligator.infinityforreddit.font.TitleFontStyle; import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.services.DownloadMediaService; import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback { public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
public static final String EXTRA_IMAGE_URL_KEY = "EIUK"; public static final String EXTRA_IMAGE_URL_KEY = "EIUK";
public static final String EXTRA_GIF_URL_KEY = "EGUK"; public static final String EXTRA_GIF_URL_KEY = "EGUK";
@ -114,6 +117,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
private String mSubredditName; private String mSubredditName;
private boolean isGif = true; private boolean isGif = true;
private boolean isNsfw; private boolean isNsfw;
private Typeface typeface;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -175,7 +179,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
if (useBottomAppBar) { if (useBottomAppBar) {
titleTextView.setText(title); titleTextView.setText(title);
} else { } else {
setTitle(title); setTitle(Utils.getTabTextWithCustomFont(typeface, title));
} }
} else { } else {
if (!useBottomAppBar) { if (!useBottomAppBar) {
@ -312,8 +316,12 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_image_or_gif_activity, menu); getMenuInflater().inflate(R.menu.view_image_or_gif_activity, menu);
if (!isGif) for (int i = 0; i < menu.size(); i++) {
Utils.setTitleWithCustomFontToMenuItem(typeface, menu.getItem(i), null);
}
if (!isGif) {
menu.findItem(R.id.action_set_wallpaper_view_image_or_gif_activity).setVisible(true); menu.findItem(R.id.action_set_wallpaper_view_image_or_gif_activity).setVisible(true);
}
return true; return true;
} }
@ -545,4 +553,9 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
super.onDestroy(); super.onDestroy();
BigImageViewer.imageLoader().cancelAll(); BigImageViewer.imageLoader().cancelAll();
} }
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
}
} }

View File

@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.activities; package ml.docilealligator.infinityforreddit.activities;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -36,6 +37,7 @@ import app.futured.hauler.DragDirection;
import app.futured.hauler.HaulerView; import app.futured.hauler.HaulerView;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.ImgurMedia; import ml.docilealligator.infinityforreddit.ImgurMedia;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
@ -54,12 +56,13 @@ import ml.docilealligator.infinityforreddit.fragments.ViewImgurVideoFragment;
import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.JSONUtils; import ml.docilealligator.infinityforreddit.utils.JSONUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.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;
public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWallpaperCallback { public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
public static final String EXTRA_IMGUR_TYPE = "EIT"; public static final String EXTRA_IMGUR_TYPE = "EIT";
public static final String EXTRA_IMGUR_ID = "EII"; public static final String EXTRA_IMGUR_ID = "EII";
@ -76,6 +79,7 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
ViewPagerBugFixed viewPager; ViewPagerBugFixed viewPager;
@BindView(R.id.load_image_error_linear_layout_view_imgur_media_activity) @BindView(R.id.load_image_error_linear_layout_view_imgur_media_activity)
LinearLayout errorLinearLayout; LinearLayout errorLinearLayout;
public Typeface typeface;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
private ArrayList<ImgurMedia> images; private ArrayList<ImgurMedia> images;
private boolean useBottomAppBar; private boolean useBottomAppBar;
@ -297,9 +301,9 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
private void setToolbarTitle(int position) { private void setToolbarTitle(int position) {
if (images != null && position >= 0 && position < images.size()) { if (images != null && position >= 0 && position < images.size()) {
if (images.get(position).getType() == ImgurMedia.TYPE_VIDEO) { if (images.get(position).getType() == ImgurMedia.TYPE_VIDEO) {
setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_imgur_media_activity_video_label, position + 1, images.size()) + "</font>")); setTitle(Utils.getTabTextWithCustomFont(typeface, Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_imgur_media_activity_video_label, position + 1, images.size()) + "</font>")));
} else { } else {
setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_imgur_media_activity_image_label, position + 1, images.size()) + "</font>")); setTitle(Utils.getTabTextWithCustomFont(typeface, Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_imgur_media_activity_image_label, position + 1, images.size()) + "</font>")));
} }
} }
} }
@ -383,6 +387,11 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
return viewPager.getCurrentItem(); return viewPager.getCurrentItem();
} }
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
}
private class SectionsPagerAdapter extends FragmentStatePagerAdapter { private class SectionsPagerAdapter extends FragmentStatePagerAdapter {
SectionsPagerAdapter(@NonNull FragmentManager fm) { SectionsPagerAdapter(@NonNull FragmentManager fm) {

View File

@ -289,6 +289,10 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
previousResultImageView.setColorFilter(searchPanelTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN); previousResultImageView.setColorFilter(searchPanelTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
nextResultImageView.setColorFilter(searchPanelTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN); nextResultImageView.setColorFilter(searchPanelTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
closeSearchPanelImageView.setColorFilter(searchPanelTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN); closeSearchPanelImageView.setColorFilter(searchPanelTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
if (typeface != null) {
searchTextInputLayout.setTypeface(typeface);
searchTextInputEditText.setTypeface(typeface);
}
} }
private void checkNewAccountAndBindView(Bundle savedInstanceState) { private void checkNewAccountAndBindView(Bundle savedInstanceState) {

View File

@ -298,6 +298,9 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
mEditTextLinearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); mEditTextLinearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
mSendMessageIconColor = mCustomThemeWrapper.getSendMessageIconColor(); mSendMessageIconColor = mCustomThemeWrapper.getSendMessageIconColor();
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN); mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
if (typeface != null) {
mEditText.setTypeface(typeface);
}
} }
@Override @Override

View File

@ -7,6 +7,7 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
@ -37,6 +38,7 @@ import app.futured.hauler.DragDirection;
import app.futured.hauler.HaulerView; import app.futured.hauler.HaulerView;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback; import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
@ -52,8 +54,9 @@ import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryImageOrGi
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment; import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment;
import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class ViewRedditGalleryActivity extends AppCompatActivity implements SetAsWallpaperCallback { public class ViewRedditGalleryActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
public static final String EXTRA_REDDIT_GALLERY = "ERG"; public static final String EXTRA_REDDIT_GALLERY = "ERG";
public static final String EXTRA_SUBREDDIT_NAME = "ESN"; public static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -68,6 +71,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
SharedPreferences sharedPreferences; SharedPreferences sharedPreferences;
@Inject @Inject
Executor executor; Executor executor;
public Typeface typeface;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
private ArrayList<Post.Gallery> gallery; private ArrayList<Post.Gallery> gallery;
private String subredditName; private String subredditName;
@ -194,11 +198,11 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
private void setToolbarTitle(int position) { private void setToolbarTitle(int position) {
if (gallery != null && position >= 0 && position < gallery.size()) { if (gallery != null && position >= 0 && position < gallery.size()) {
if (gallery.get(position).mediaType == Post.Gallery.TYPE_IMAGE) { if (gallery.get(position).mediaType == Post.Gallery.TYPE_IMAGE) {
setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_image_label, position + 1, gallery.size()) + "</font>")); setTitle(Utils.getTabTextWithCustomFont(typeface, Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_image_label, position + 1, gallery.size()) + "</font>")));
} else if (gallery.get(position).mediaType == Post.Gallery.TYPE_GIF) { } else if (gallery.get(position).mediaType == Post.Gallery.TYPE_GIF) {
setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_gif_label, position + 1, gallery.size()) + "</font>")); setTitle(Utils.getTabTextWithCustomFont(typeface, Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_gif_label, position + 1, gallery.size()) + "</font>")));
} else { } else {
setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_video_label, position + 1, gallery.size()) + "</font>")); setTitle(Utils.getTabTextWithCustomFont(typeface, Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_video_label, position + 1, gallery.size()) + "</font>")));
} }
} }
} }
@ -276,6 +280,11 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
return viewPager.getCurrentItem(); return viewPager.getCurrentItem();
} }
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
}
private class SectionsPagerAdapter extends FragmentStatePagerAdapter { private class SectionsPagerAdapter extends FragmentStatePagerAdapter {
SectionsPagerAdapter(@NonNull FragmentManager fm) { SectionsPagerAdapter(@NonNull FragmentManager fm) {

View File

@ -558,6 +558,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
option4BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN); option4BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
applyTabLayoutTheme(tabLayout); applyTabLayoutTheme(tabLayout);
applyFABTheme(fab); applyFABTheme(fab);
if (typeface != null) {
subredditNameTextView.setTypeface(typeface);
subscribeSubredditChip.setTypeface(typeface);
nSubscribersTextView.setTypeface(typeface);
nOnlineSubscribersTextView.setTypeface(typeface);
sinceTextView.setTypeface(typeface);
creationTimeTextView.setTypeface(typeface);
descriptionTextView.setTypeface(typeface);
}
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(); unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
subscribedColor = mCustomThemeWrapper.getSubscribed(); subscribedColor = mCustomThemeWrapper.getSubscribed();
} }

View File

@ -653,6 +653,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor()); subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
applyTabLayoutTheme(tabLayout); applyTabLayoutTheme(tabLayout);
if (typeface != null) {
userNameTextView.setTypeface(typeface);
karmaTextView.setTypeface(typeface);
cakedayTextView.setTypeface(typeface);
subscribeUserChip.setTypeface(typeface);
descriptionTextView.setTypeface(typeface);
}
} }
private void checkNewAccountAndInitializeViewPager() { private void checkNewAccountAndInitializeViewPager() {

View File

@ -14,6 +14,7 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.media.AudioManager; import android.media.AudioManager;
@ -81,6 +82,7 @@ import app.futured.hauler.HaulerView;
import app.futured.hauler.LockableNestedScrollView; import app.futured.hauler.LockableNestedScrollView;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
import ml.docilealligator.infinityforreddit.FetchStreamableVideo; import ml.docilealligator.infinityforreddit.FetchStreamableVideo;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
@ -106,7 +108,7 @@ import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class ViewVideoActivity extends AppCompatActivity { public class ViewVideoActivity extends AppCompatActivity implements CustomFontReceiver {
public static final int PLAYBACK_SPEED_25 = 25; public static final int PLAYBACK_SPEED_25 = 25;
public static final int PLAYBACK_SPEED_50 = 50; public static final int PLAYBACK_SPEED_50 = 50;
@ -168,6 +170,8 @@ public class ViewVideoActivity extends AppCompatActivity {
@BindView(R.id.lockable_nested_scroll_view_view_video_activity) @BindView(R.id.lockable_nested_scroll_view_view_video_activity)
LockableNestedScrollView nestedScrollView; LockableNestedScrollView nestedScrollView;
public Typeface typeface;
private Uri mVideoUri; private Uri mVideoUri;
private SimpleExoPlayer player; private SimpleExoPlayer player;
private DefaultTrackSelector trackSelector; private DefaultTrackSelector trackSelector;
@ -556,7 +560,7 @@ public class ViewVideoActivity extends AppCompatActivity {
if (useBottomAppBar) { if (useBottomAppBar) {
titleTextView.setText(Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", title))); titleTextView.setText(Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", title)));
} else { } else {
setTitle(Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", title))); setTitle(Utils.getTabTextWithCustomFont(typeface, Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", title))));
} }
} else { } else {
if (!useBottomAppBar) { if (!useBottomAppBar) {
@ -808,6 +812,9 @@ public class ViewVideoActivity extends AppCompatActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_video_activity, menu); getMenuInflater().inflate(R.menu.view_video_activity, menu);
for (int i = 0; i < menu.size(); i++) {
Utils.setTitleWithCustomFontToMenuItem(typeface, menu.getItem(i), null);
}
return true; return true;
} }
@ -941,4 +948,9 @@ public class ViewVideoActivity extends AppCompatActivity {
} }
outState.putInt(PLAYBACK_SPEED_STATE, playbackSpeed); outState.putInt(PLAYBACK_SPEED_STATE, playbackSpeed);
} }
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
}
} }

View File

@ -117,6 +117,7 @@ public class WebViewActivity extends BaseActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.web_view_activity, menu); getMenuInflater().inflate(R.menu.web_view_activity, menu);
applyMenuItemTheme(menu);
return true; return true;
} }

View File

@ -338,6 +338,9 @@ public class WikiActivity extends BaseActivity {
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
mFetchWikiInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); mFetchWikiInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (typeface != null) {
mFetchWikiInfoTextView.setTypeface(typeface);
}
} }
@Subscribe @Subscribe

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -14,16 +13,17 @@ import java.util.ArrayList;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.settings.Acknowledgement; import ml.docilealligator.infinityforreddit.settings.Acknowledgement;
public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<AcknowledgementRecyclerViewAdapter.AcknowledgementViewHolder> { public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<AcknowledgementRecyclerViewAdapter.AcknowledgementViewHolder> {
private ArrayList<Acknowledgement> acknowledgements; private ArrayList<Acknowledgement> acknowledgements;
private Context context; private BaseActivity activity;
public AcknowledgementRecyclerViewAdapter(Context context, ArrayList<Acknowledgement> acknowledgements) { public AcknowledgementRecyclerViewAdapter(BaseActivity activity, ArrayList<Acknowledgement> acknowledgements) {
this.context = context; this.activity = activity;
this.acknowledgements = acknowledgements; this.acknowledgements = acknowledgements;
} }
@ -40,10 +40,10 @@ public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<Ack
holder.nameTextView.setText(acknowledgement.getName()); holder.nameTextView.setText(acknowledgement.getName());
holder.introductionTextView.setText(acknowledgement.getIntroduction()); holder.introductionTextView.setText(acknowledgement.getIntroduction());
holder.itemView.setOnClickListener(view -> { holder.itemView.setOnClickListener(view -> {
if (context != null) { if (activity != null) {
Intent intent = new Intent(context, LinkResolverActivity.class); Intent intent = new Intent(activity, LinkResolverActivity.class);
intent.setData(acknowledgement.getLink()); intent.setData(acknowledgement.getLink());
context.startActivity(intent); activity.startActivity(intent);
} }
}); });
} }
@ -65,6 +65,11 @@ public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<Ack
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
this.itemView = itemView; this.itemView = itemView;
if (activity.typeface != null) {
nameTextView.setTypeface(activity.typeface);
introductionTextView.setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -8,20 +8,23 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
import java.util.ArrayList; import java.util.ArrayList;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.award.Award; import ml.docilealligator.infinityforreddit.award.Award;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<Award> awards; private ArrayList<Award> awards;
private BaseActivity activity;
private RequestManager glide; private RequestManager glide;
private ItemOnClickListener itemOnClickListener; private ItemOnClickListener itemOnClickListener;
private int primaryTextColor; private int primaryTextColor;
@ -31,10 +34,11 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
void onClick(Award award); void onClick(Award award);
} }
public AwardRecyclerViewAdapter(RequestManager glide, CustomThemeWrapper customThemeWrapper, public AwardRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
ItemOnClickListener itemOnClickListener) { ItemOnClickListener itemOnClickListener) {
awards = Award.getAvailableAwards(); awards = Award.getAvailableAwards();
this.glide = glide; this.activity = activity;
this.glide = Glide.with(activity);
primaryTextColor = customThemeWrapper.getPrimaryTextColor(); primaryTextColor = customThemeWrapper.getPrimaryTextColor();
secondaryTextColor = customThemeWrapper.getSecondaryTextColor(); secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
this.itemOnClickListener = itemOnClickListener; this.itemOnClickListener = itemOnClickListener;
@ -52,7 +56,7 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
Award award = awards.get(position); Award award = awards.get(position);
glide.load(award.getIconUrl()).into(((AwardViewHolder) holder).iconImageView); glide.load(award.getIconUrl()).into(((AwardViewHolder) holder).iconImageView);
((AwardViewHolder) holder).nameTextView.setText(award.getName()); ((AwardViewHolder) holder).nameTextView.setText(award.getName());
((AwardViewHolder) holder).desctiptionTextView.setText(award.getDescription()); ((AwardViewHolder) holder).descriptionTextView.setText(award.getDescription());
((AwardViewHolder) holder).coinTextView.setText(Integer.toString(award.getCoinPrice())); ((AwardViewHolder) holder).coinTextView.setText(Integer.toString(award.getCoinPrice()));
} }
} }
@ -68,7 +72,7 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
if (holder instanceof AwardViewHolder) { if (holder instanceof AwardViewHolder) {
glide.clear(((AwardViewHolder) holder).iconImageView); glide.clear(((AwardViewHolder) holder).iconImageView);
((AwardViewHolder) holder).nameTextView.setText(""); ((AwardViewHolder) holder).nameTextView.setText("");
((AwardViewHolder) holder).desctiptionTextView.setText(""); ((AwardViewHolder) holder).descriptionTextView.setText("");
} }
} }
@ -78,7 +82,7 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
@BindView(R.id.name_text_view_item_award) @BindView(R.id.name_text_view_item_award)
TextView nameTextView; TextView nameTextView;
@BindView(R.id.description_text_view_item_award) @BindView(R.id.description_text_view_item_award)
TextView desctiptionTextView; TextView descriptionTextView;
@BindView(R.id.coin_text_view_item_award) @BindView(R.id.coin_text_view_item_award)
TextView coinTextView; TextView coinTextView;
@ -86,8 +90,13 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (activity.typeface != null) {
nameTextView.setTypeface(activity.typeface);
descriptionTextView.setTypeface(activity.typeface);
coinTextView.setTypeface(activity.typeface);
}
nameTextView.setTextColor(primaryTextColor); nameTextView.setTextColor(primaryTextColor);
desctiptionTextView.setTextColor(secondaryTextColor); descriptionTextView.setTextColor(secondaryTextColor);
coinTextView.setTextColor(primaryTextColor); coinTextView.setTextColor(primaryTextColor);
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {

View File

@ -3,14 +3,9 @@ package ml.docilealligator.infinityforreddit.adapters;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -32,8 +27,6 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -54,6 +47,7 @@ import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing; import ml.docilealligator.infinityforreddit.VoteThing;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
@ -65,10 +59,9 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView; import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView; import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin; import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan; import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -87,7 +80,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
return comment.getCommentMarkdown().equals(t1.getCommentMarkdown()); return comment.getCommentMarkdown().equals(t1.getCommentMarkdown());
} }
}; };
private AppCompatActivity mActivity; private BaseActivity mActivity;
private Retrofit mOauthRetrofit; private Retrofit mOauthRetrofit;
private Locale mLocale; private Locale mLocale;
private Markwon mMarkwon; private Markwon mMarkwon;
@ -114,7 +107,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
private NetworkState networkState; private NetworkState networkState;
private RetryLoadingMoreCallback mRetryLoadingMoreCallback; private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
public CommentsListingRecyclerViewAdapter(AppCompatActivity activity, Retrofit oauthRetrofit, public CommentsListingRecyclerViewAdapter(BaseActivity activity, Retrofit oauthRetrofit,
CustomThemeWrapper customThemeWrapper, Locale locale, CustomThemeWrapper customThemeWrapper, Locale locale,
SharedPreferences sharedPreferences, String accessToken, SharedPreferences sharedPreferences, String accessToken,
String accountName, RetryLoadingMoreCallback retryLoadingMoreCallback) { String accountName, RetryLoadingMoreCallback retryLoadingMoreCallback) {
@ -421,6 +414,16 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
commentDivider.setVisibility(View.VISIBLE); commentDivider.setVisibility(View.VISIBLE);
} }
if (mActivity.typeface != null) {
authorTextView.setTypeface(mActivity.typeface);
authorFlairTextView.setTypeface(mActivity.typeface);
commentTimeTextView.setTypeface(mActivity.typeface);
awardsTextView.setTypeface(mActivity.typeface);
scoreTextView.setTypeface(mActivity.typeface);
}
if (mActivity.contentTypeface != null) {
commentMarkdownView.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mCommentBackgroundColor); itemView.setBackgroundColor(mCommentBackgroundColor);
authorTextView.setTextColor(mUsernameColor); authorTextView.setTextColor(mUsernameColor);
authorFlairTextView.setTextColor(mAuthorFlairColor); authorFlairTextView.setTextColor(mAuthorFlairColor);
@ -705,6 +708,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
ErrorViewHolder(View itemView) { ErrorViewHolder(View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
retryButton.setTypeface(mActivity.typeface);
}
errorTextView.setText(R.string.load_comments_failed); errorTextView.setText(R.string.load_comments_failed);
retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore()); retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
errorTextView.setTextColor(mSecondaryTextColor); errorTextView.setTextColor(mSecondaryTextColor);

View File

@ -22,7 +22,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.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet; import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
@ -45,7 +44,6 @@ import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin; import io.noties.markwon.html.HtmlPlugin;
import io.noties.markwon.html.tag.SuperScriptHandler; import io.noties.markwon.html.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.AutolinkInlineProcessor; import io.noties.markwon.inlineparser.AutolinkInlineProcessor;
import io.noties.markwon.inlineparser.BackslashInlineProcessor;
import io.noties.markwon.inlineparser.BangInlineProcessor; import io.noties.markwon.inlineparser.BangInlineProcessor;
import io.noties.markwon.inlineparser.HtmlInlineProcessor; import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin; import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
@ -55,6 +53,7 @@ import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing; import ml.docilealligator.infinityforreddit.VoteThing;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity; import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
@ -86,7 +85,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 16; private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 16;
private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 17; private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 17;
private AppCompatActivity mActivity; private BaseActivity mActivity;
private ViewPostDetailFragment mFragment; private ViewPostDetailFragment mFragment;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mRetrofit; private Retrofit mRetrofit;
@ -145,7 +144,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private int mSearchCommentIndex = -1; private int mSearchCommentIndex = -1;
public CommentsRecyclerViewAdapter(AppCompatActivity activity, ViewPostDetailFragment fragment, public CommentsRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
Executor executor, Retrofit retrofit, Retrofit oauthRetrofit, Executor executor, Retrofit retrofit, Retrofit oauthRetrofit,
String accessToken, String accountName, String accessToken, String accountName,
@ -1119,6 +1118,17 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
commentDivider.setVisibility(View.VISIBLE); commentDivider.setVisibility(View.VISIBLE);
} }
if (mActivity.typeface != null) {
authorTextView.setTypeface(mActivity.typeface);
commentTimeTextView.setTypeface(mActivity.typeface);
authorFlairTextView.setTypeface(mActivity.typeface);
topScoreTextView.setTypeface(mActivity.typeface);
awardsTextView.setTypeface(mActivity.typeface);
scoreTextView.setTypeface(mActivity.typeface);
}
if (mActivity.contentTypeface != null) {
commentMarkdownView.setTypeface(mActivity.contentTypeface);
}
itemView.setBackgroundColor(mCommentBackgroundColor); itemView.setBackgroundColor(mCommentBackgroundColor);
authorTextView.setTextColor(mUsernameColor); authorTextView.setTextColor(mUsernameColor);
commentTimeTextView.setTextColor(mSecondaryTextColor); commentTimeTextView.setTextColor(mSecondaryTextColor);
@ -1440,16 +1450,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
} }
}); });
/*commentMarkdownView.setMovementMethod(BetterLinkMovementMethod.newInstance().setOnLinkLongClickListener((textView, url) -> {
if (!mActivity.isDestroyed() && !mActivity.isFinishing()) {
UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
urlMenuBottomSheetFragment.setArguments(bundle);
urlMenuBottomSheetFragment.show(mActivity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
}
return true;
}));*/
if (mSwapTapAndLong) { if (mSwapTapAndLong) {
if (mCommentToolbarHideOnClick) { if (mCommentToolbarHideOnClick) {
View.OnLongClickListener hideToolbarOnLongClickListener = view -> hideToolbar(); View.OnLongClickListener hideToolbarOnLongClickListener = view -> hideToolbar();
@ -1547,6 +1547,11 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
usernameTextView.setTypeface(mActivity.typeface);
scoreTextView.setTypeface(mActivity.typeface);
commentTimeTextView.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mFullyCollapsedCommentBackgroundColor); itemView.setBackgroundColor(mFullyCollapsedCommentBackgroundColor);
usernameTextView.setTextColor(mUsernameColor); usernameTextView.setTextColor(mUsernameColor);
scoreTextView.setTextColor(mSecondaryTextColor); scoreTextView.setTextColor(mSecondaryTextColor);
@ -1602,6 +1607,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
commentDivider.setVisibility(View.VISIBLE); commentDivider.setVisibility(View.VISIBLE);
} }
if (mActivity.typeface != null) {
placeholderTextView.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mCommentBackgroundColor); itemView.setBackgroundColor(mCommentBackgroundColor);
placeholderTextView.setTextColor(mPrimaryTextColor); placeholderTextView.setTextColor(mPrimaryTextColor);
commentDivider.setBackgroundColor(mDividerColor); commentDivider.setBackgroundColor(mDividerColor);
@ -1628,6 +1636,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
itemView.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingComments()); itemView.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingComments());
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
}
errorTextView.setTextColor(mSecondaryTextColor); errorTextView.setTextColor(mSecondaryTextColor);
} }
} }
@ -1639,6 +1650,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
NoCommentViewHolder(@NonNull View itemView) { NoCommentViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
}
errorTextView.setTextColor(mSecondaryTextColor); errorTextView.setTextColor(mSecondaryTextColor);
} }
} }
@ -1663,6 +1677,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
LoadMoreCommentsFailedViewHolder(@NonNull View itemView) { LoadMoreCommentsFailedViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
retryButton.setTypeface(mActivity.typeface);
}
errorTextView.setText(R.string.load_comments_failed); errorTextView.setText(R.string.load_comments_failed);
retryButton.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingMoreComments()); retryButton.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingMoreComments());
errorTextView.setTextColor(mSecondaryTextColor); errorTextView.setTextColor(mSecondaryTextColor);
@ -1685,6 +1703,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
} }
}); });
if (mActivity.typeface != null) {
((TextView) itemView).setTypeface(mActivity.typeface);
}
itemView.setBackgroundTintList(ColorStateList.valueOf(mCommentBackgroundColor)); itemView.setBackgroundTintList(ColorStateList.valueOf(mCommentBackgroundColor));
((TextView) itemView).setTextColor(mColorAccent); ((TextView) itemView).setTextColor(mColorAccent);
} }

View File

@ -11,11 +11,14 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List; import java.util.List;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
public class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private List<String> crashReports; private List<String> crashReports;
public CrashReportsRecyclerViewAdapter(List<String> crashReports) { public CrashReportsRecyclerViewAdapter(BaseActivity activity, List<String> crashReports) {
this.activity = activity;
this.crashReports = crashReports; this.crashReports = crashReports;
} }
@ -40,6 +43,10 @@ public class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
public CrashReportViewHolder(@NonNull View itemView) { public CrashReportViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
crashReportTextView = (TextView) itemView; crashReportTextView = (TextView) itemView;
if (activity.typeface != null) {
crashReportTextView.setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -10,7 +10,6 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
@ -18,11 +17,12 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity; import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity;
import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity; import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CustomThemeOptionsBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.CustomThemeOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_PREDEFINED_THEME = 0; private static final int VIEW_TYPE_PREDEFINED_THEME = 0;
@ -30,11 +30,11 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
private static final int VIEW_TYPE_PREDEFINED_THEME_DIVIDER = 2; private static final int VIEW_TYPE_PREDEFINED_THEME_DIVIDER = 2;
private static final int VIEW_TYPE_USER_THEME_DIVIDER = 3; private static final int VIEW_TYPE_USER_THEME_DIVIDER = 3;
private AppCompatActivity activity; private BaseActivity activity;
private ArrayList<CustomTheme> predefinedCustomThemes; private ArrayList<CustomTheme> predefinedCustomThemes;
private ArrayList<CustomTheme> userCustomThemes; private ArrayList<CustomTheme> userCustomThemes;
public CustomThemeListingRecyclerViewAdapter(AppCompatActivity activity, ArrayList<CustomTheme> predefinedCustomThemes) { public CustomThemeListingRecyclerViewAdapter(BaseActivity activity, ArrayList<CustomTheme> predefinedCustomThemes) {
this.activity = activity; this.activity = activity;
this.predefinedCustomThemes = predefinedCustomThemes; this.predefinedCustomThemes = predefinedCustomThemes;
userCustomThemes = new ArrayList<>(); userCustomThemes = new ArrayList<>();
@ -134,6 +134,9 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
PredefinedCustomThemeViewHolder(@NonNull View itemView) { PredefinedCustomThemeViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (activity.typeface != null) {
nameTextView.setTypeface(activity.typeface);
}
} }
} }
@ -151,6 +154,9 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
UserCustomThemeViewHolder(@NonNull View itemView) { UserCustomThemeViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (activity.typeface != null) {
nameTextView.setTypeface(activity.typeface);
}
} }
} }
@ -158,6 +164,9 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
PreDefinedThemeDividerViewHolder(@NonNull View itemView) { PreDefinedThemeDividerViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
if (activity.typeface != null) {
((TextView) itemView).setTypeface(activity.typeface);
}
} }
} }
@ -165,6 +174,9 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
UserThemeDividerViewHolder(@NonNull View itemView) { UserThemeDividerViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
if (activity.typeface != null) {
((TextView) itemView).setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -7,33 +7,33 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.switchmaterial.SwitchMaterial;
import java.util.ArrayList; import java.util.ArrayList;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem;
import ml.docilealligator.infinityforreddit.customviews.ColorPickerDialog; import ml.docilealligator.infinityforreddit.customviews.ColorPickerDialog;
import ml.docilealligator.infinityforreddit.R;
public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_COLOR = 1; private static final int VIEW_TYPE_COLOR = 1;
private static final int VIEW_TYPE_SWITCH = 2; private static final int VIEW_TYPE_SWITCH = 2;
private static final int VIEW_TYPE_THEME_NAME = 3; private static final int VIEW_TYPE_THEME_NAME = 3;
private AppCompatActivity activity; private BaseActivity activity;
private ArrayList<CustomThemeSettingsItem> customThemeSettingsItems; private ArrayList<CustomThemeSettingsItem> customThemeSettingsItems;
private String themeName; private String themeName;
private boolean isPredefinedTheme; private boolean isPredefinedTheme;
public CustomizeThemeRecyclerViewAdapter(AppCompatActivity activity, String themeName, public CustomizeThemeRecyclerViewAdapter(BaseActivity activity, String themeName,
boolean isPredefinedTheme) { boolean isPredefinedTheme) {
this.activity = activity; this.activity = activity;
customThemeSettingsItems = new ArrayList<>(); customThemeSettingsItems = new ArrayList<>();
@ -148,6 +148,10 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
ThemeColorItemViewHolder(@NonNull View itemView) { ThemeColorItemViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (activity.typeface != null) {
themeItemNameTextView.setTypeface(activity.typeface);
themeItemInfoTextView.setTypeface(activity.typeface);
}
} }
} }
@ -157,11 +161,15 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@BindView(R.id.theme_item_info_text_view_item_custom_theme_switch_item) @BindView(R.id.theme_item_info_text_view_item_custom_theme_switch_item)
TextView themeItemInfoTextView; TextView themeItemInfoTextView;
@BindView(R.id.theme_item_switch_item_custom_theme_switch_item) @BindView(R.id.theme_item_switch_item_custom_theme_switch_item)
Switch themeItemSwitch; SwitchMaterial themeItemSwitch;
ThemeSwitchItemViewHolder(@NonNull View itemView) { ThemeSwitchItemViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (activity.typeface != null) {
themeItemNameTextView.setTypeface(activity.typeface);
themeItemInfoTextView.setTypeface(activity.typeface);
}
} }
} }
@ -173,6 +181,10 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
public ThemeNameItemViewHolder(@NonNull View itemView) { public ThemeNameItemViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (activity.typeface != null) {
themeNameTextView.setTypeface(activity.typeface);
descriptionTextView.setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -19,19 +19,20 @@ import java.util.ArrayList;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<FlairBottomSheetRecyclerViewAdapter.FlairViewHolder> { public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<FlairBottomSheetRecyclerViewAdapter.FlairViewHolder> {
private Context context; private BaseActivity activity;
private ArrayList<Flair> flairs; private ArrayList<Flair> flairs;
private int flairTextColor; private int flairTextColor;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public FlairBottomSheetRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper, public FlairBottomSheetRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
ItemClickListener itemClickListener) { ItemClickListener itemClickListener) {
this.context = context; this.activity = activity;
flairTextColor = customThemeWrapper.getPrimaryTextColor(); flairTextColor = customThemeWrapper.getPrimaryTextColor();
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
} }
@ -47,14 +48,14 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
if (flairs.get(holder.getBindingAdapterPosition()).isEditable()) { if (flairs.get(holder.getBindingAdapterPosition()).isEditable()) {
holder.editFlairImageView.setVisibility(View.VISIBLE); holder.editFlairImageView.setVisibility(View.VISIBLE);
holder.editFlairImageView.setOnClickListener(view -> { holder.editFlairImageView.setOnClickListener(view -> {
View dialogView = ((Activity) context).getLayoutInflater().inflate(R.layout.dialog_edit_flair, null); View dialogView = ((Activity) activity).getLayoutInflater().inflate(R.layout.dialog_edit_flair, null);
EditText flairEditText = dialogView.findViewById(R.id.flair_edit_text_edit_flair_dialog); EditText flairEditText = dialogView.findViewById(R.id.flair_edit_text_edit_flair_dialog);
flairEditText.requestFocus(); flairEditText.requestFocus();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) { if (imm != null) {
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
} }
new MaterialAlertDialogBuilder(context, R.style.MaterialAlertDialogTheme) new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.edit_flair) .setTitle(R.string.edit_flair)
.setView(dialogView) .setView(dialogView)
.setPositiveButton(R.string.ok, (dialogInterface, i) .setPositiveButton(R.string.ok, (dialogInterface, i)
@ -109,6 +110,10 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
this.itemView = itemView; this.itemView = itemView;
flairTextView.setTextColor(flairTextColor); flairTextView.setTextColor(flairTextColor);
if (activity.typeface != null) {
flairTextView.setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Handler; import android.os.Handler;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -27,6 +26,7 @@ import me.zhanghai.android.fastscroll.PopupTextProvider;
import ml.docilealligator.infinityforreddit.FavoriteThing; import ml.docilealligator.infinityforreddit.FavoriteThing;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData; import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData;
@ -41,7 +41,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
private List<SubscribedUserData> mSubscribedUserData; private List<SubscribedUserData> mSubscribedUserData;
private List<SubscribedUserData> mFavoriteSubscribedUserData; private List<SubscribedUserData> mFavoriteSubscribedUserData;
private Context mContext; private BaseActivity mActivity;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mOauthRetrofit; private Retrofit mOauthRetrofit;
private RedditDataRoomDatabase mRedditDataRoomDatabase; private RedditDataRoomDatabase mRedditDataRoomDatabase;
@ -50,16 +50,16 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
private int mPrimaryTextColor; private int mPrimaryTextColor;
private int mSecondaryTextColor; private int mSecondaryTextColor;
public FollowedUsersRecyclerViewAdapter(Context context, Executor executor, Retrofit oauthRetrofit, public FollowedUsersRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
String accessToken) { String accessToken) {
mContext = context; mActivity = activity;
mExecutor = executor; mExecutor = executor;
mOauthRetrofit = oauthRetrofit; mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase; mRedditDataRoomDatabase = redditDataRoomDatabase;
mAccessToken = accessToken; mAccessToken = accessToken;
glide = Glide.with(context); glide = Glide.with(activity);
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor(); mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(); mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
} }
@ -202,14 +202,17 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
FavoriteUserViewHolder(View itemView) { FavoriteUserViewHolder(View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
userNameTextView.setTypeface(mActivity.typeface);
}
userNameTextView.setTextColor(mPrimaryTextColor); userNameTextView.setTextColor(mPrimaryTextColor);
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {
int position = getBindingAdapterPosition() - 1; int position = getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteSubscribedUserData.size() > position) { if(position >= 0 && mFavoriteSubscribedUserData.size() > position) {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class); Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mFavoriteSubscribedUserData.get(position).getName()); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mFavoriteSubscribedUserData.get(position).getName());
mContext.startActivity(intent); mActivity.startActivity(intent);
} }
}); });
@ -234,7 +237,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
@Override @Override
public void failed() { public void failed() {
Toast.makeText(mContext, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
int position = getBindingAdapterPosition() - 1; int position = getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteSubscribedUserData.size() > position) { if(position >= 0 && mFavoriteSubscribedUserData.size() > position) {
mFavoriteSubscribedUserData.get(position).setFavorite(true); mFavoriteSubscribedUserData.get(position).setFavorite(true);
@ -260,7 +263,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
@Override @Override
public void failed() { public void failed() {
Toast.makeText(mContext, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
int position = getBindingAdapterPosition() - 1; int position = getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteSubscribedUserData.size() > position) { if(position >= 0 && mFavoriteSubscribedUserData.size() > position) {
mFavoriteSubscribedUserData.get(position).setFavorite(false); mFavoriteSubscribedUserData.get(position).setFavorite(false);
@ -285,6 +288,9 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
UserViewHolder(View itemView) { UserViewHolder(View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
userNameTextView.setTypeface(mActivity.typeface);
}
userNameTextView.setTextColor(mPrimaryTextColor); userNameTextView.setTextColor(mPrimaryTextColor);
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {
@ -292,9 +298,9 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
mFavoriteSubscribedUserData.size() + 2 : 0; mFavoriteSubscribedUserData.size() + 2 : 0;
int position = getBindingAdapterPosition() - offset; int position = getBindingAdapterPosition() - offset;
if(position >= 0 && mSubscribedUserData.size() > position) { if(position >= 0 && mSubscribedUserData.size() > position) {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class); Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mSubscribedUserData.get(position).getName()); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mSubscribedUserData.get(position).getName());
mContext.startActivity(intent); mActivity.startActivity(intent);
} }
}); });
@ -322,7 +328,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
@Override @Override
public void failed() { public void failed() {
Toast.makeText(mContext, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
int position = getBindingAdapterPosition() - offset; int position = getBindingAdapterPosition() - offset;
if(position >= 0 && mSubscribedUserData.size() > position) { if(position >= 0 && mSubscribedUserData.size() > position) {
mSubscribedUserData.get(position).setFavorite(true); mSubscribedUserData.get(position).setFavorite(true);
@ -348,7 +354,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
@Override @Override
public void failed() { public void failed() {
Toast.makeText(mContext, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
int position = getBindingAdapterPosition() - offset; int position = getBindingAdapterPosition() - offset;
if(position >= 0 && mSubscribedUserData.size() > position) { if(position >= 0 && mSubscribedUserData.size() > position) {
mSubscribedUserData.get(position).setFavorite(false); mSubscribedUserData.get(position).setFavorite(false);
@ -368,6 +374,9 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
FavoriteUsersDividerViewHolder(@NonNull View itemView) { FavoriteUsersDividerViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
dividerTextView.setTypeface(mActivity.typeface);
}
dividerTextView.setText(R.string.favorites); dividerTextView.setText(R.string.favorites);
dividerTextView.setTextColor(mSecondaryTextColor); dividerTextView.setTextColor(mSecondaryTextColor);
} }
@ -379,6 +388,9 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
AllUsersDividerViewHolder(@NonNull View itemView) { AllUsersDividerViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
dividerTextView.setTypeface(mActivity.typeface);
}
dividerTextView.setText(R.string.all); dividerTextView.setText(R.string.all);
dividerTextView.setTextColor(mSecondaryTextColor); dividerTextView.setTextColor(mSecondaryTextColor);
} }

View File

@ -1,15 +1,9 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -24,8 +18,6 @@ import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -43,16 +35,16 @@ import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin; import io.noties.markwon.linkify.LinkifyPlugin;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity; import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin; import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan; import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.message.FetchMessage; import ml.docilealligator.infinityforreddit.message.FetchMessage;
import ml.docilealligator.infinityforreddit.message.Message; import ml.docilealligator.infinityforreddit.message.Message;
import ml.docilealligator.infinityforreddit.message.ReadMessage; import ml.docilealligator.infinityforreddit.message.ReadMessage;
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -71,7 +63,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
return message.getBody().equals(t1.getBody()); return message.getBody().equals(t1.getBody());
} }
}; };
private Context mContext; private BaseActivity mActivity;
private Retrofit mOauthRetrofit; private Retrofit mOauthRetrofit;
private Markwon mMarkwon; private Markwon mMarkwon;
private String mAccessToken; private String mAccessToken;
@ -88,12 +80,12 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
private int mButtonTextColor; private int mButtonTextColor;
private boolean markAllMessagesAsRead = false; private boolean markAllMessagesAsRead = false;
public MessageRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, public MessageRecyclerViewAdapter(BaseActivity activity, Retrofit oauthRetrofit,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
String accessToken, String where, String accessToken, String where,
RetryLoadingMoreCallback retryLoadingMoreCallback) { RetryLoadingMoreCallback retryLoadingMoreCallback) {
super(DIFF_CALLBACK); super(DIFF_CALLBACK);
mContext = context; mActivity = activity;
mOauthRetrofit = oauthRetrofit; mOauthRetrofit = oauthRetrofit;
mRetryLoadingMoreCallback = retryLoadingMoreCallback; mRetryLoadingMoreCallback = retryLoadingMoreCallback;
@ -107,7 +99,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(); mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
mButtonTextColor = customThemeWrapper.getButtonTextColor(); mButtonTextColor = customThemeWrapper.getButtonTextColor();
mMarkwon = Markwon.builder(mContext) mMarkwon = Markwon.builder(mActivity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> { .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(AutolinkInlineProcessor.class); plugin.excludeInlineProcessor(AutolinkInlineProcessor.class);
plugin.excludeInlineProcessor(HtmlInlineProcessor.class); plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
@ -127,10 +119,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
@Override @Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) { public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> { builder.linkResolver((view, link) -> {
Intent intent = new Intent(mContext, LinkResolverActivity.class); Intent intent = new Intent(mActivity, LinkResolverActivity.class);
Uri uri = Uri.parse(link); Uri uri = Uri.parse(link);
intent.setData(uri); intent.setData(uri);
mContext.startActivity(intent); mActivity.startActivity(intent);
}); });
} }
@ -199,14 +191,14 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX
&& message.getContext() != null && !message.getContext().equals("")) { && message.getContext() != null && !message.getContext().equals("")) {
Uri uri = Uri.parse(message.getContext()); Uri uri = Uri.parse(message.getContext());
Intent intent = new Intent(mContext, LinkResolverActivity.class); Intent intent = new Intent(mActivity, LinkResolverActivity.class);
intent.setData(uri); intent.setData(uri);
mContext.startActivity(intent); mActivity.startActivity(intent);
} else if (mMessageType == FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE) { } else if (mMessageType == FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE) {
Intent intent = new Intent(mContext, ViewPrivateMessagesActivity.class); Intent intent = new Intent(mActivity, ViewPrivateMessagesActivity.class);
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_PRIVATE_MESSAGE, message); intent.putExtra(ViewPrivateMessagesActivity.EXTRA_PRIVATE_MESSAGE, message);
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_MESSAGE_POSITION, holder.getBindingAdapterPosition()); intent.putExtra(ViewPrivateMessagesActivity.EXTRA_MESSAGE_POSITION, holder.getBindingAdapterPosition());
mContext.startActivity(intent); mActivity.startActivity(intent);
} }
if (displayedMessage.isNew()) { if (displayedMessage.isNew()) {
@ -229,9 +221,9 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
}); });
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> { ((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class); Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor()); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
mContext.startActivity(intent); mActivity.startActivity(intent);
}); });
((DataViewHolder) holder).contentCustomMarkwonView.setOnClickListener(view -> { ((DataViewHolder) holder).contentCustomMarkwonView.setOnClickListener(view -> {
@ -325,6 +317,12 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
DataViewHolder(View itemView) { DataViewHolder(View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
authorTextView.setTypeface(mActivity.typeface);
subjectTextView.setTypeface(mActivity.typeface);
titleTextView.setTypeface(mActivity.titleTypeface);
contentCustomMarkwonView.setTypeface(mActivity.contentTypeface);
}
itemView.setBackgroundColor(mMessageBackgroundColor); itemView.setBackgroundColor(mMessageBackgroundColor);
authorTextView.setTextColor(mUsernameColor); authorTextView.setTextColor(mUsernameColor);
subjectTextView.setTextColor(mPrimaryTextColor); subjectTextView.setTextColor(mPrimaryTextColor);
@ -344,6 +342,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
ErrorViewHolder(View itemView) { ErrorViewHolder(View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
retryButton.setTypeface(mActivity.typeface);
}
errorTextView.setText(R.string.load_comments_failed); errorTextView.setText(R.string.load_comments_failed);
errorTextView.setTextColor(mSecondaryTextColor); errorTextView.setTextColor(mSecondaryTextColor);
retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore()); retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());

View File

@ -9,7 +9,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.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
@ -25,6 +24,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.zhanghai.android.fastscroll.PopupTextProvider; import me.zhanghai.android.fastscroll.PopupTextProvider;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit; import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.multireddit.FavoriteMultiReddit; import ml.docilealligator.infinityforreddit.multireddit.FavoriteMultiReddit;
@ -39,7 +39,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
private static final int VIEW_TYPE_MULTI_REDDIT_DIVIDER = 2; private static final int VIEW_TYPE_MULTI_REDDIT_DIVIDER = 2;
private static final int VIEW_TYPE_MULTI_REDDIT = 3; private static final int VIEW_TYPE_MULTI_REDDIT = 3;
private AppCompatActivity mActivity; private BaseActivity mActivity;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mOauthRetrofit; private Retrofit mOauthRetrofit;
private RedditDataRoomDatabase mRedditDataRoomDatabase; private RedditDataRoomDatabase mRedditDataRoomDatabase;
@ -57,7 +57,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
void onLongClick(MultiReddit multiReddit); void onLongClick(MultiReddit multiReddit);
} }
public MultiRedditListingRecyclerViewAdapter(AppCompatActivity activity, Executor executor, Retrofit oauthRetrofit, public MultiRedditListingRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
String accessToken, OnItemClickListener onItemClickListener) { String accessToken, OnItemClickListener onItemClickListener) {
@ -377,6 +377,9 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
MultiRedditViewHolder(@NonNull View itemView) { MultiRedditViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
multiRedditNameTextView.setTypeface(mActivity.typeface);
}
multiRedditNameTextView.setTextColor(mPrimaryTextColor); multiRedditNameTextView.setTextColor(mPrimaryTextColor);
} }
} }
@ -392,6 +395,9 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
FavoriteMultiRedditViewHolder(View itemView) { FavoriteMultiRedditViewHolder(View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
multiRedditNameTextView.setTypeface(mActivity.typeface);
}
multiRedditNameTextView.setTextColor(mPrimaryTextColor); multiRedditNameTextView.setTextColor(mPrimaryTextColor);
} }
} }
@ -402,6 +408,9 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
FavoriteMultiRedditsDividerViewHolder(@NonNull View itemView) { FavoriteMultiRedditsDividerViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
dividerTextView.setTypeface(mActivity.typeface);
}
dividerTextView.setText(R.string.favorites); dividerTextView.setText(R.string.favorites);
dividerTextView.setTextColor(mSecondaryTextColor); dividerTextView.setTextColor(mSecondaryTextColor);
} }
@ -413,6 +422,9 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
AllMultiRedditsDividerViewHolder(@NonNull View itemView) { AllMultiRedditsDividerViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
dividerTextView.setTypeface(mActivity.typeface);
}
dividerTextView.setText(R.string.all); dividerTextView.setText(R.string.all);
dividerTextView.setTextColor(mSecondaryTextColor); dividerTextView.setTextColor(mSecondaryTextColor);
} }

View File

@ -12,7 +12,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.biometric.BiometricManager; import androidx.biometric.BiometricManager;
import androidx.biometric.BiometricPrompt; import androidx.biometric.BiometricPrompt;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
@ -32,6 +31,7 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.InboxActivity; import ml.docilealligator.infinityforreddit.activities.InboxActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
@ -62,7 +62,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
private static final int POST_SECTION_ITEMS = 5; private static final int POST_SECTION_ITEMS = 5;
private static final int PREFERENCES_SECTION_ITEMS = 3; private static final int PREFERENCES_SECTION_ITEMS = 3;
private AppCompatActivity appCompatActivity; private BaseActivity baseActivity;
private Resources resources; private Resources resources;
private RequestManager glide; private RequestManager glide;
private String accountName; private String accountName;
@ -92,15 +92,15 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
private int dividerColor; private int dividerColor;
private int primaryIconColor; private int primaryIconColor;
public NavigationDrawerRecyclerViewAdapter(AppCompatActivity appCompatActivity, SharedPreferences sharedPreferences, public NavigationDrawerRecyclerViewAdapter(BaseActivity baseActivity, SharedPreferences sharedPreferences,
SharedPreferences nsfwAndSpoilerSharedPreferences, SharedPreferences nsfwAndSpoilerSharedPreferences,
SharedPreferences navigationDrawerSharedPreferences, SharedPreferences navigationDrawerSharedPreferences,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
String accountName, String accountName,
ItemClickListener itemClickListener) { ItemClickListener itemClickListener) {
this.appCompatActivity = appCompatActivity; this.baseActivity = baseActivity;
resources = appCompatActivity.getResources(); resources = baseActivity.getResources();
glide = Glide.with(appCompatActivity); glide = Glide.with(baseActivity);
this.accountName = accountName; this.accountName = accountName;
isNSFWEnabled = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false); isNSFWEnabled = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
requireAuthToAccountSection = sharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false); requireAuthToAccountSection = sharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
@ -238,7 +238,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
} }
((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params); ((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params);
if (isLoggedIn) { if (isLoggedIn) {
((NavHeaderViewHolder) holder).karmaTextView.setText(appCompatActivity.getString(R.string.karma_info, karma)); ((NavHeaderViewHolder) holder).karmaTextView.setText(baseActivity.getString(R.string.karma_info, karma));
((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName); ((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName);
if (profileImageUrl != null && !profileImageUrl.equals("")) { if (profileImageUrl != null && !profileImageUrl.equals("")) {
glide.load(profileImageUrl) glide.load(profileImageUrl)
@ -272,10 +272,10 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
holder.itemView.setOnClickListener(view -> { holder.itemView.setOnClickListener(view -> {
if (isInMainPage) { if (isInMainPage) {
if (requireAuthToAccountSection) { if (requireAuthToAccountSection) {
BiometricManager biometricManager = BiometricManager.from(appCompatActivity); BiometricManager biometricManager = BiometricManager.from(baseActivity);
if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) == BiometricManager.BIOMETRIC_SUCCESS) { if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) == BiometricManager.BIOMETRIC_SUCCESS) {
Executor executor = ContextCompat.getMainExecutor(appCompatActivity); Executor executor = ContextCompat.getMainExecutor(baseActivity);
BiometricPrompt biometricPrompt = new BiometricPrompt(appCompatActivity, BiometricPrompt biometricPrompt = new BiometricPrompt(baseActivity,
executor, new BiometricPrompt.AuthenticationCallback() { executor, new BiometricPrompt.AuthenticationCallback() {
@Override @Override
public void onAuthenticationSucceeded( public void onAuthenticationSucceeded(
@ -286,7 +286,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
}); });
BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder() BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder()
.setTitle(appCompatActivity.getString(R.string.unlock_account_section)) .setTitle(baseActivity.getString(R.string.unlock_account_section))
.setAllowedAuthenticators(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) .setAllowedAuthenticators(BIOMETRIC_STRONG | DEVICE_CREDENTIAL)
.build(); .build();
@ -473,14 +473,14 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
case 5: case 5:
setOnClickListener = false; setOnClickListener = false;
if (inboxCount > 0) { if (inboxCount > 0) {
((MenuItemViewHolder) holder).menuTextView.setText(appCompatActivity.getString(R.string.inbox_with_count, inboxCount)); ((MenuItemViewHolder) holder).menuTextView.setText(baseActivity.getString(R.string.inbox_with_count, inboxCount));
} else { } else {
((MenuItemViewHolder) holder).menuTextView.setText(R.string.inbox); ((MenuItemViewHolder) holder).menuTextView.setText(R.string.inbox);
} }
((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_inbox_24dp)); ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(baseActivity, R.drawable.ic_inbox_24dp));
holder.itemView.setOnClickListener(view -> { holder.itemView.setOnClickListener(view -> {
Intent intent = new Intent(appCompatActivity, InboxActivity.class); Intent intent = new Intent(baseActivity, InboxActivity.class);
appCompatActivity.startActivity(intent); baseActivity.startActivity(intent);
}); });
break; break;
case 7: case 7:
@ -534,12 +534,12 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
if (isNSFWEnabled) { if (isNSFWEnabled) {
isNSFWEnabled = false; isNSFWEnabled = false;
((MenuItemViewHolder) holder).menuTextView.setText(R.string.enable_nsfw); ((MenuItemViewHolder) holder).menuTextView.setText(R.string.enable_nsfw);
((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_nsfw_on_24dp)); ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(baseActivity, R.drawable.ic_nsfw_on_24dp));
itemClickListener.onMenuClick(R.string.disable_nsfw); itemClickListener.onMenuClick(R.string.disable_nsfw);
} else { } else {
isNSFWEnabled = true; isNSFWEnabled = true;
((MenuItemViewHolder) holder).menuTextView.setText(R.string.disable_nsfw); ((MenuItemViewHolder) holder).menuTextView.setText(R.string.disable_nsfw);
((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_nsfw_off_24dp)); ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(baseActivity, R.drawable.ic_nsfw_off_24dp));
itemClickListener.onMenuClick(R.string.enable_nsfw); itemClickListener.onMenuClick(R.string.enable_nsfw);
} }
}); });
@ -585,12 +585,12 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
if (isNSFWEnabled) { if (isNSFWEnabled) {
isNSFWEnabled = false; isNSFWEnabled = false;
((MenuItemViewHolder) holder).menuTextView.setText(R.string.enable_nsfw); ((MenuItemViewHolder) holder).menuTextView.setText(R.string.enable_nsfw);
((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_nsfw_on_24dp)); ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(baseActivity, R.drawable.ic_nsfw_on_24dp));
itemClickListener.onMenuClick(R.string.disable_nsfw); itemClickListener.onMenuClick(R.string.disable_nsfw);
} else { } else {
isNSFWEnabled = true; isNSFWEnabled = true;
((MenuItemViewHolder) holder).menuTextView.setText(R.string.disable_nsfw); ((MenuItemViewHolder) holder).menuTextView.setText(R.string.disable_nsfw);
((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_nsfw_off_24dp)); ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(baseActivity, R.drawable.ic_nsfw_off_24dp));
itemClickListener.onMenuClick(R.string.enable_nsfw); itemClickListener.onMenuClick(R.string.enable_nsfw);
} }
}); });
@ -621,7 +621,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
if (stringId != 0) { if (stringId != 0) {
((MenuItemViewHolder) holder).menuTextView.setText(stringId); ((MenuItemViewHolder) holder).menuTextView.setText(stringId);
((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, drawableId)); ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(baseActivity, drawableId));
if (setOnClickListener) { if (setOnClickListener) {
int finalStringId = stringId; int finalStringId = stringId;
holder.itemView.setOnClickListener(view -> itemClickListener.onMenuClick(finalStringId)); holder.itemView.setOnClickListener(view -> itemClickListener.onMenuClick(finalStringId));
@ -863,6 +863,11 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
NavHeaderViewHolder(@NonNull View itemView) { NavHeaderViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (baseActivity.typeface != null) {
accountNameTextView.setTypeface(baseActivity.typeface);
karmaTextView.setTypeface(baseActivity.typeface);
}
} }
} }
@ -875,6 +880,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
MenuGroupTitleViewHolder(@NonNull View itemView) { MenuGroupTitleViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (baseActivity.typeface != null) {
titleTextView.setTypeface(baseActivity.typeface);
}
titleTextView.setTextColor(secondaryTextColor); titleTextView.setTextColor(secondaryTextColor);
collapseIndicatorImageView.setColorFilter(secondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN); collapseIndicatorImageView.setColorFilter(secondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
} }
@ -889,6 +897,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
MenuItemViewHolder(@NonNull View itemView) { MenuItemViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (baseActivity.typeface != null) {
menuTextView.setTypeface(baseActivity.typeface);
}
menuTextView.setTextColor(primaryTextColor); menuTextView.setTextColor(primaryTextColor);
imageView.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); imageView.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
} }
@ -911,6 +922,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
FavoriteSubscribedThingViewHolder(@NonNull View itemView) { FavoriteSubscribedThingViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (baseActivity.typeface != null) {
subredditNameTextView.setTypeface(baseActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor); subredditNameTextView.setTextColor(primaryTextColor);
} }
} }
@ -924,6 +938,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
SubscribedThingViewHolder(@NonNull View itemView) { SubscribedThingViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (baseActivity.typeface != null) {
subredditNameTextView.setTypeface(baseActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor); subredditNameTextView.setTextColor(primaryTextColor);
} }
} }
@ -937,6 +954,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
AccountViewHolder(@NonNull View itemView) { AccountViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (baseActivity.typeface != null) {
usernameTextView.setTypeface(baseActivity.typeface);
}
usernameTextView.setTextColor(primaryTextColor); usernameTextView.setTextColor(primaryTextColor);
} }
} }

View File

@ -15,14 +15,17 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.button.MaterialButton; import com.google.android.material.button.MaterialButton;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
public class Paging3LoadingStateAdapter extends LoadStateAdapter<Paging3LoadingStateAdapter.LoadStateViewHolder> { public class Paging3LoadingStateAdapter extends LoadStateAdapter<Paging3LoadingStateAdapter.LoadStateViewHolder> {
private BaseActivity activity;
private CustomThemeWrapper mCustomThemeWrapper; private CustomThemeWrapper mCustomThemeWrapper;
private int mErrorStringId; private int mErrorStringId;
private View.OnClickListener mRetryCallback; private View.OnClickListener mRetryCallback;
public Paging3LoadingStateAdapter(CustomThemeWrapper customThemeWrapper, int errorStringId, View.OnClickListener retryCallback) { public Paging3LoadingStateAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper, int errorStringId, View.OnClickListener retryCallback) {
this.activity = activity;
this.mCustomThemeWrapper = customThemeWrapper; this.mCustomThemeWrapper = customThemeWrapper;
this.mErrorStringId = errorStringId; this.mErrorStringId = errorStringId;
this.mRetryCallback = retryCallback; this.mRetryCallback = retryCallback;
@ -59,6 +62,11 @@ public class Paging3LoadingStateAdapter extends LoadStateAdapter<Paging3LoadingS
mRetry.setTextColor(mCustomThemeWrapper.getButtonTextColor()); mRetry.setTextColor(mCustomThemeWrapper.getButtonTextColor());
mRetry.setOnClickListener(retryCallback); mRetry.setOnClickListener(retryCallback);
mErrorView.setOnClickListener(retryCallback); mErrorView.setOnClickListener(retryCallback);
if (activity.typeface != null) {
mErrorMsg.setTypeface(activity.typeface);
mRetry.setTypeface(activity.typeface);
}
} }
public void bind(LoadState loadState) { public void bind(LoadState loadState) {

View File

@ -27,7 +27,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.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet; import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
@ -90,6 +89,7 @@ import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStra
import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.StreamableVideo; import ml.docilealligator.infinityforreddit.StreamableVideo;
import ml.docilealligator.infinityforreddit.VoteThing; import ml.docilealligator.infinityforreddit.VoteThing;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity; import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity; import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
@ -131,7 +131,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 6; private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 6;
private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 7; private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 7;
private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 8; private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 8;
private AppCompatActivity mActivity; private BaseActivity mActivity;
private ViewPostDetailFragment mFragment; private ViewPostDetailFragment mFragment;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mRetrofit; private Retrofit mRetrofit;
@ -210,7 +210,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private boolean canStartActivity = true; private boolean canStartActivity = true;
private boolean canPlayVideo = true; private boolean canPlayVideo = true;
public PostDetailRecyclerViewAdapter(AppCompatActivity activity, ViewPostDetailFragment fragment, public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
Executor executor, CustomThemeWrapper customThemeWrapper, Executor executor, CustomThemeWrapper customThemeWrapper,
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit, Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
Retrofit redgifsRetrofit, Retrofit streamableRetrofit, Retrofit redgifsRetrofit, Retrofit streamableRetrofit,
@ -255,6 +255,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@Override @Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) { public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
if (mActivity.contentTypeface != null) {
textView.setTypeface(mActivity.typeface);
}
textView.setTextColor(markdownColor); textView.setTextColor(markdownColor);
textView.setOnLongClickListener(view -> { textView.setOnLongClickListener(view -> {
if (textView.getSelectionStart() == -1 && textView.getSelectionEnd() == -1) { if (textView.getSelectionStart() == -1 && textView.getSelectionEnd() == -1) {
@ -841,14 +844,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailGalleryViewHolder) holder).mCaptionConstraintLayout.setVisibility(View.VISIBLE); ((PostDetailGalleryViewHolder) holder).mCaptionConstraintLayout.setVisibility(View.VISIBLE);
} }
if (!previewCaptionIsEmpty) { if (!previewCaptionIsEmpty) {
((PostDetailGalleryViewHolder) holder).mCaption.setTextColor(mCommentColor); ((PostDetailGalleryViewHolder) holder).mCaptionTextView.setTextColor(mCommentColor);
((PostDetailGalleryViewHolder) holder).mCaption.setText(previewCaption); ((PostDetailGalleryViewHolder) holder).mCaptionTextView.setText(previewCaption);
((PostDetailGalleryViewHolder) holder).mCaption.setSelected(true); ((PostDetailGalleryViewHolder) holder).mCaptionTextView.setSelected(true);
} }
if (!previewCaptionUrlIsEmpty) { if (!previewCaptionUrlIsEmpty) {
String domain = Uri.parse(previewCaptionUrl).getHost(); String domain = Uri.parse(previewCaptionUrl).getHost();
domain = domain.startsWith("www.") ? domain.substring(4) : domain; domain = domain.startsWith("www.") ? domain.substring(4) : domain;
mPostDetailMarkwon.setMarkdown(((PostDetailGalleryViewHolder) holder).mCaptionUrl, String.format("[%s](%s)", domain, previewCaptionUrl)); mPostDetailMarkwon.setMarkdown(((PostDetailGalleryViewHolder) holder).mCaptionUrlTextView, String.format("[%s](%s)", domain, previewCaptionUrl));
} }
} }
} }
@ -1512,6 +1515,23 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
constraintSet.applyTo(mBottomConstraintLayout); constraintSet.applyTo(mBottomConstraintLayout);
} }
if (mActivity.typeface != null) {
mSubredditTextView.setTypeface(mActivity.typeface);
mUserTextView.setTypeface(mActivity.typeface);
mAuthorFlairTextView.setTypeface(mActivity.typeface);
mPostTimeTextView.setTypeface(mActivity.typeface);
mTypeTextView.setTypeface(mActivity.typeface);
mSpoilerTextView.setTypeface(mActivity.typeface);
mNSFWTextView.setTypeface(mActivity.typeface);
mFlairTextView.setTypeface(mActivity.typeface);
mAwardsTextView.setTypeface(mActivity.typeface);
mUpvoteRatioTextView.setTypeface(mActivity.typeface);
mScoreTextView.setTypeface(mActivity.typeface);
commentsCountTextView.setTypeface(mActivity.typeface);
}
if (mActivity.titleTypeface != null) {
mTitleTextView.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mCardViewColor); itemView.setBackgroundColor(mCardViewColor);
mSubredditTextView.setTextColor(mSubredditColor); mSubredditTextView.setTextColor(mSubredditColor);
mUserTextView.setTextColor(mUsernameColor); mUserTextView.setTextColor(mUsernameColor);
@ -2114,6 +2134,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSaveButton, mSaveButton,
mShareButton); mShareButton);
if (mActivity.typeface != null) {
mLinkTextView.setTypeface(mActivity.typeface);
}
mLinkTextView.setTextColor(mSecondaryTextColor); mLinkTextView.setTextColor(mSecondaryTextColor);
mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
mLoadImageErrorTextView.setTextColor(mPrimaryTextColor); mLoadImageErrorTextView.setTextColor(mPrimaryTextColor);
@ -2206,6 +2229,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSaveButton, mSaveButton,
mShareButton); mShareButton);
if (mActivity.typeface != null) {
mLinkTextView.setTypeface(mActivity.typeface);
}
mLinkTextView.setTextColor(mSecondaryTextColor); mLinkTextView.setTextColor(mSecondaryTextColor);
mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor); mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, PorterDuff.Mode.SRC_IN); mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, PorterDuff.Mode.SRC_IN);
@ -2311,9 +2337,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@BindView(R.id.caption_constraint_layout_item_post_detail_gallery) @BindView(R.id.caption_constraint_layout_item_post_detail_gallery)
ConstraintLayout mCaptionConstraintLayout; ConstraintLayout mCaptionConstraintLayout;
@BindView(R.id.caption_text_view_item_post_detail_gallery) @BindView(R.id.caption_text_view_item_post_detail_gallery)
TextView mCaption; TextView mCaptionTextView;
@BindView(R.id.caption_url_text_view_item_post_detail_gallery) @BindView(R.id.caption_url_text_view_item_post_detail_gallery)
TextView mCaptionUrl; TextView mCaptionUrlTextView;
@BindView(R.id.image_view_no_preview_link_item_post_detail_gallery) @BindView(R.id.image_view_no_preview_link_item_post_detail_gallery)
ImageView mNoPreviewPostTypeImageView; ImageView mNoPreviewPostTypeImageView;
@BindView(R.id.bottom_constraint_layout_item_post_detail_gallery) @BindView(R.id.bottom_constraint_layout_item_post_detail_gallery)
@ -2357,6 +2383,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSaveButton, mSaveButton,
mShareButton); mShareButton);
if (mActivity.typeface != null) {
mLoadImageErrorTextView.setTypeface(mActivity.typeface);
mCaptionTextView.setTypeface(mActivity.typeface);
mCaptionUrlTextView.setTypeface(mActivity.typeface);
}
videoOrGifIndicatorImageView.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN); videoOrGifIndicatorImageView.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN);
videoOrGifIndicatorImageView.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor)); videoOrGifIndicatorImageView.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor));
mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));

View File

@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List; import java.util.List;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter; import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -18,6 +19,7 @@ public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private static final int VIEW_TYPE_HEADER = 1; private static final int VIEW_TYPE_HEADER = 1;
private static final int VIEW_TYPE_POST_FILTER = 2; private static final int VIEW_TYPE_POST_FILTER = 2;
private BaseActivity activity;
private final OnItemClickListener onItemClickListener; private final OnItemClickListener onItemClickListener;
private List<PostFilter> postFilterList; private List<PostFilter> postFilterList;
@ -25,7 +27,8 @@ public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
void onItemClick(PostFilter postFilter); void onItemClick(PostFilter postFilter);
} }
public PostFilterRecyclerViewAdapter(OnItemClickListener onItemClickListener) { public PostFilterRecyclerViewAdapter(BaseActivity activity, OnItemClickListener onItemClickListener) {
this.activity = activity;
this.onItemClickListener = onItemClickListener; this.onItemClickListener = onItemClickListener;
} }
@ -70,6 +73,11 @@ public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public PostFilterViewHolder(@NonNull View itemView) { public PostFilterViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
textView = (TextView) itemView; textView = (TextView) itemView;
if (activity.typeface != null) {
textView.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {
onItemClickListener.onItemClick(postFilterList.get(getBindingAdapterPosition() - 1)); onItemClickListener.onItemClick(postFilterList.get(getBindingAdapterPosition() - 1));
}); });

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -12,20 +11,21 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List; import java.util.List;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage; import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
public class PostFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class PostFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<PostFilterUsage> postFilterUsages; private List<PostFilterUsage> postFilterUsages;
private OnItemClickListener onItemClickListener; private OnItemClickListener onItemClickListener;
private Context context; private BaseActivity activity;
public interface OnItemClickListener { public interface OnItemClickListener {
void onClick(PostFilterUsage postFilterUsage); void onClick(PostFilterUsage postFilterUsage);
} }
public PostFilterUsageRecyclerViewAdapter(Context context, public PostFilterUsageRecyclerViewAdapter(BaseActivity activity,
OnItemClickListener onItemClickListener) { OnItemClickListener onItemClickListener) {
this.context = context; this.activity = activity;
this.onItemClickListener = onItemClickListener; this.onItemClickListener = onItemClickListener;
} }
@ -46,21 +46,21 @@ public class PostFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter<Rec
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) { if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_subreddit_all); ((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_subreddit_all);
} else { } else {
((PostFilterUsageViewHolder) holder).usageTextView.setText(context.getString(R.string.post_filter_usage_subreddit, postFilterUsage.nameOfUsage)); ((PostFilterUsageViewHolder) holder).usageTextView.setText(activity.getString(R.string.post_filter_usage_subreddit, postFilterUsage.nameOfUsage));
} }
break; break;
case PostFilterUsage.USER_TYPE: case PostFilterUsage.USER_TYPE:
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) { if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_user_all); ((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_user_all);
} else { } else {
((PostFilterUsageViewHolder) holder).usageTextView.setText(context.getString(R.string.post_filter_usage_user, postFilterUsage.nameOfUsage)); ((PostFilterUsageViewHolder) holder).usageTextView.setText(activity.getString(R.string.post_filter_usage_user, postFilterUsage.nameOfUsage));
} }
break; break;
case PostFilterUsage.MULTIREDDIT_TYPE: case PostFilterUsage.MULTIREDDIT_TYPE:
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) { if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_multireddit_all); ((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_multireddit_all);
} else { } else {
((PostFilterUsageViewHolder) holder).usageTextView.setText(context.getString(R.string.post_filter_usage_multireddit, postFilterUsage.nameOfUsage)); ((PostFilterUsageViewHolder) holder).usageTextView.setText(activity.getString(R.string.post_filter_usage_multireddit, postFilterUsage.nameOfUsage));
} }
break; break;
case PostFilterUsage.SEARCH_TYPE: case PostFilterUsage.SEARCH_TYPE:
@ -85,6 +85,10 @@ public class PostFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter<Rec
super(itemView); super(itemView);
usageTextView = (TextView) itemView; usageTextView = (TextView) itemView;
if (activity.typeface != null) {
usageTextView.setTypeface(activity.typeface);
}
usageTextView.setOnClickListener(view -> { usageTextView.setOnClickListener(view -> {
onItemClickListener.onClick(postFilterUsages.get(getBindingAdapterPosition())); onItemClickListener.onClick(postFilterUsages.get(getBindingAdapterPosition()));
}); });

View File

@ -24,7 +24,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.constraintlayout.widget.Barrier; import androidx.constraintlayout.widget.Barrier;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet; import androidx.constraintlayout.widget.ConstraintSet;
@ -126,7 +125,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
}; };
private AppCompatActivity mActivity; private BaseActivity mActivity;
private PostFragment mFragment; private PostFragment mFragment;
private SharedPreferences mSharedPreferences; private SharedPreferences mSharedPreferences;
private Executor mExecutor; private Executor mExecutor;
@ -212,7 +211,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private Callback mCallback; private Callback mCallback;
private boolean canPlayVideo = true; private boolean canPlayVideo = true;
public PostRecyclerViewAdapter(AppCompatActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit, public PostRecyclerViewAdapter(BaseActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Retrofit streambleRetrofit, Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Retrofit streambleRetrofit,
CustomThemeWrapper customThemeWrapper, Locale locale, CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName, String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
@ -2105,23 +2104,20 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor)); itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
} }
if (((BaseActivity) mActivity).typeface != null) { if (mActivity.typeface != null) {
subredditTextView.setTypeface(((BaseActivity) mActivity).typeface); subredditTextView.setTypeface(mActivity.typeface);
userTextView.setTypeface(((BaseActivity) mActivity).typeface); userTextView.setTypeface(mActivity.typeface);
postTimeTextView.setTypeface(((BaseActivity) mActivity).typeface); postTimeTextView.setTypeface(mActivity.typeface);
typeTextView.setTypeface(((BaseActivity) mActivity).typeface); typeTextView.setTypeface(mActivity.typeface);
spoilerTextView.setTypeface(((BaseActivity) mActivity).typeface); spoilerTextView.setTypeface(mActivity.typeface);
nsfwTextView.setTypeface(((BaseActivity) mActivity).typeface); nsfwTextView.setTypeface(mActivity.typeface);
flairTextView.setTypeface(((BaseActivity) mActivity).typeface); flairTextView.setTypeface(mActivity.typeface);
awardsTextView.setTypeface(((BaseActivity) mActivity).typeface); awardsTextView.setTypeface(mActivity.typeface);
scoreTextView.setTypeface(((BaseActivity) mActivity).typeface); scoreTextView.setTypeface(mActivity.typeface);
commentsCountTextView.setTypeface(((BaseActivity) mActivity).typeface); commentsCountTextView.setTypeface(mActivity.typeface);
} }
if (((BaseActivity) mActivity).titleTypeface != null) { if (mActivity.titleTypeface != null) {
titleTextView.setTypeface(((BaseActivity) mActivity).titleTypeface); titleTextView.setTypeface(mActivity.titleTypeface);
}
if (((BaseActivity) mActivity).contentTypeface != null) {
} }
subredditTextView.setTextColor(mSubredditColor); subredditTextView.setTextColor(mSubredditColor);
@ -2933,6 +2929,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
saveButton, saveButton,
shareButton); shareButton);
if (mActivity.typeface != null) {
linkTextView.setTypeface(mActivity.typeface);
errorTextView.setTypeface(mActivity.typeface);
}
linkTextView.setTextColor(mSecondaryTextColor); linkTextView.setTextColor(mSecondaryTextColor);
noPreviewLinkImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor); noPreviewLinkImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
noPreviewLinkImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN); noPreviewLinkImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
@ -3053,6 +3053,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
saveButton, saveButton,
shareButton); shareButton);
if (mActivity.contentTypeface != null) {
contentTextView.setTypeface(mActivity.titleTypeface);
}
contentTextView.setTextColor(mPostContentColor); contentTextView.setTextColor(mPostContentColor);
} }
} }
@ -3169,6 +3172,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((ViewGroup) itemView).getLayoutTransition().setAnimateParentHierarchy(false); ((ViewGroup) itemView).getLayoutTransition().setAnimateParentHierarchy(false);
} }
if (mActivity.typeface != null) {
nameTextView.setTypeface(mActivity.typeface);
postTimeTextView.setTypeface(mActivity.typeface);
typeTextView.setTypeface(mActivity.typeface);
spoilerTextView.setTypeface(mActivity.typeface);
nsfwTextView.setTypeface(mActivity.typeface);
flairTextView.setTypeface(mActivity.typeface);
awardsTextView.setTypeface(mActivity.typeface);
linkTextView.setTypeface(mActivity.typeface);
scoreTextView.setTypeface(mActivity.typeface);
commentsCountTextView.setTypeface(mActivity.typeface);
}
if (mActivity.titleTypeface != null) {
titleTextView.setTypeface(mActivity.titleTypeface);
}
itemView.setBackgroundColor(mCardViewBackgroundColor); itemView.setBackgroundColor(mCardViewBackgroundColor);
postTimeTextView.setTextColor(mSecondaryTextColor); postTimeTextView.setTextColor(mSecondaryTextColor);
titleTextView.setTextColor(mPostTitleColor); titleTextView.setTextColor(mPostTitleColor);
@ -3790,6 +3809,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
}
if (mActivity.titleTypeface != null) {
titleTextView.setTypeface(mActivity.titleTypeface);
}
itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor)); itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
titleTextView.setTextColor(mPostTitleColor); titleTextView.setTextColor(mPostTitleColor);
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
@ -4221,6 +4246,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
shareButton, shareButton,
true); true);
if (mActivity.typeface != null) {
linkTextView.setTypeface(mActivity.typeface);
errorTextView.setTypeface(mActivity.typeface);
}
linkTextView.setTextColor(mSecondaryTextColor); linkTextView.setTextColor(mSecondaryTextColor);
noPreviewImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor); noPreviewImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN); noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
@ -4345,6 +4374,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
shareButton, shareButton,
true); true);
if (mActivity.contentTypeface != null) {
contentTextView.setTypeface(mActivity.contentTypeface);
}
contentTextView.setTextColor(mPostContentColor); contentTextView.setTextColor(mPostContentColor);
divider.setBackgroundColor(mDividerColor); divider.setBackgroundColor(mDividerColor);
} }

View File

@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.text.Spanned;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -40,9 +41,9 @@ import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity; import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.message.Message; import ml.docilealligator.infinityforreddit.message.Message;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -88,6 +89,13 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
return Utils.fixSuperScript(markdown); return Utils.fixSuperScript(markdown);
} }
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
if (mViewPrivateMessagesActivity.contentTypeface != null) {
textView.setTypeface(mViewPrivateMessagesActivity.contentTypeface);
}
}
@Override @Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) { public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> { builder.linkResolver((view, link) -> {

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -19,13 +18,16 @@ import java.util.ArrayList;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RPANComment; import ml.docilealligator.infinityforreddit.RPANComment;
import ml.docilealligator.infinityforreddit.activities.RPANActivity;
public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private RPANActivity activity;
private RequestManager glide; private RequestManager glide;
private ArrayList<RPANComment> rpanComments; private ArrayList<RPANComment> rpanComments;
public RPANCommentStreamRecyclerViewAdapter(Context context) { public RPANCommentStreamRecyclerViewAdapter(RPANActivity activity) {
glide = Glide.with(context); this.activity = activity;
glide = Glide.with(activity);
rpanComments = new ArrayList<>(); rpanComments = new ArrayList<>();
} }
@ -70,7 +72,6 @@ public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<R
class RPANCommentViewHolder extends RecyclerView.ViewHolder { class RPANCommentViewHolder extends RecyclerView.ViewHolder {
ImageView iconImageView; ImageView iconImageView;
TextView authorTextView; TextView authorTextView;
TextView timeTextView;
TextView contentTextView; TextView contentTextView;
public RPANCommentViewHolder(@NonNull View itemView) { public RPANCommentViewHolder(@NonNull View itemView) {
@ -78,6 +79,11 @@ public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<R
iconImageView = itemView.findViewById(R.id.icon_image_view_item_rpan_comment); iconImageView = itemView.findViewById(R.id.icon_image_view_item_rpan_comment);
authorTextView = itemView.findViewById(R.id.author_text_view_item_rpan_comment); authorTextView = itemView.findViewById(R.id.author_text_view_item_rpan_comment);
contentTextView = itemView.findViewById(R.id.content_text_view_item_rpan_comment); contentTextView = itemView.findViewById(R.id.content_text_view_item_rpan_comment);
if (activity.typeface != null) {
authorTextView.setTypeface(activity.typeface);
contentTextView.setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -14,18 +14,21 @@ import java.util.ArrayList;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.ReportReason; import ml.docilealligator.infinityforreddit.ReportReason;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private ArrayList<ReportReason> generalReasons; private ArrayList<ReportReason> generalReasons;
private ArrayList<ReportReason> rules; private ArrayList<ReportReason> rules;
private int primaryTextColor; private int primaryTextColor;
private int colorAccent; private int colorAccent;
public ReportReasonRecyclerViewAdapter(CustomThemeWrapper customThemeWrapper, ArrayList<ReportReason> generalReasons) { public ReportReasonRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper, ArrayList<ReportReason> generalReasons) {
this.activity = activity;
this.generalReasons = generalReasons; this.generalReasons = generalReasons;
primaryTextColor = customThemeWrapper.getPrimaryTextColor(); primaryTextColor = customThemeWrapper.getPrimaryTextColor();
colorAccent = customThemeWrapper.getColorAccent(); colorAccent = customThemeWrapper.getColorAccent();
@ -101,6 +104,10 @@ public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
reasonTextView.setTextColor(primaryTextColor); reasonTextView.setTextColor(primaryTextColor);
checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent)); checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
if (activity.typeface != null) {
reasonTextView.setTypeface(activity.typeface);
}
checkBox.setOnClickListener(view -> { checkBox.setOnClickListener(view -> {
for (int i = 0; i < generalReasons.size(); i++) { for (int i = 0; i < generalReasons.size(); i++) {
if (generalReasons.get(i).isSelected()) { if (generalReasons.get(i).isSelected()) {

View File

@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.adapters;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.Spanned;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -10,7 +11,6 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,6 +33,7 @@ import io.noties.markwon.movement.MovementMethodPlugin;
import me.saket.bettermovementmethod.BetterLinkMovementMethod; import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Rule; import ml.docilealligator.infinityforreddit.Rule;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@ -40,12 +41,14 @@ import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> { public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private BaseActivity activity;
private Markwon markwon; private Markwon markwon;
private ArrayList<Rule> rules; private ArrayList<Rule> rules;
private int mPrimaryTextColor; private int mPrimaryTextColor;
private int mSecondaryTextColor; private int mSecondaryTextColor;
public RulesRecyclerViewAdapter(AppCompatActivity activity, CustomThemeWrapper customThemeWrapper) { public RulesRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper) {
this.activity = activity;
markwon = Markwon.builder(activity) markwon = Markwon.builder(activity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> { .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(AutolinkInlineProcessor.class); plugin.excludeInlineProcessor(AutolinkInlineProcessor.class);
@ -63,6 +66,15 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
return Utils.fixSuperScript(markdown); return Utils.fixSuperScript(markdown);
} }
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
if (activity.typeface != null) {
textView.setTypeface(activity.typeface);
}
textView.setTextColor(mPrimaryTextColor);
}
@Override @Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) { public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> { builder.linkResolver((view, link) -> {
@ -138,6 +150,11 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
shortNameTextView.setTextColor(mPrimaryTextColor); shortNameTextView.setTextColor(mPrimaryTextColor);
descriptionMarkwonView.setTextColor(mSecondaryTextColor); descriptionMarkwonView.setTextColor(mSecondaryTextColor);
if (activity.typeface != null) {
shortNameTextView.setTypeface(activity.typeface);
descriptionMarkwonView.setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.app.Activity;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -15,12 +14,14 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQuery; import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQuery;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private List<RecentSearchQuery> recentSearchQueries; private List<RecentSearchQuery> recentSearchQueries;
private int primaryTextColor; private int primaryTextColor;
private Drawable historyIcon; private Drawable historyIcon;
@ -32,8 +33,9 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
void onDelete(RecentSearchQuery recentSearchQuery); void onDelete(RecentSearchQuery recentSearchQuery);
} }
public SearchActivityRecyclerViewAdapter(Activity activity, CustomThemeWrapper customThemeWrapper, public SearchActivityRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
ItemOnClickListener itemOnClickListener) { ItemOnClickListener itemOnClickListener) {
this.activity = activity;
this.primaryTextColor = customThemeWrapper.getPrimaryTextColor(); this.primaryTextColor = customThemeWrapper.getPrimaryTextColor();
this.historyIcon = Utils.getTintedDrawable(activity, R.drawable.ic_history_24dp, customThemeWrapper.getPrimaryIconColor()); this.historyIcon = Utils.getTintedDrawable(activity, R.drawable.ic_history_24dp, customThemeWrapper.getPrimaryIconColor());
this.deleteIcon = Utils.getTintedDrawable(activity, R.drawable.ic_delete_24dp, customThemeWrapper.getPrimaryIconColor()); this.deleteIcon = Utils.getTintedDrawable(activity, R.drawable.ic_delete_24dp, customThemeWrapper.getPrimaryIconColor());
@ -80,6 +82,10 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
recentSearchQueryTextView.setCompoundDrawablesWithIntrinsicBounds(historyIcon, null, null, null); recentSearchQueryTextView.setCompoundDrawablesWithIntrinsicBounds(historyIcon, null, null, null);
deleteImageView.setImageDrawable(deleteIcon); deleteImageView.setImageDrawable(deleteIcon);
if (activity.typeface != null) {
recentSearchQueryTextView.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) { if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()).getSearchQuery()); itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()).getSearchQuery());

View File

@ -13,14 +13,17 @@ import java.util.ArrayList;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private CustomThemeWrapper customThemeWrapper; private CustomThemeWrapper customThemeWrapper;
private ArrayList<String> subreddits; private ArrayList<String> subreddits;
public SelectedSubredditsRecyclerViewAdapter(CustomThemeWrapper customThemeWrapper, ArrayList<String> subreddits) { public SelectedSubredditsRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper, ArrayList<String> subreddits) {
this.activity = activity;
this.customThemeWrapper = customThemeWrapper; this.customThemeWrapper = customThemeWrapper;
if (subreddits == null) { if (subreddits == null) {
this.subreddits = new ArrayList<>(); this.subreddits = new ArrayList<>();
@ -79,6 +82,10 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<
subredditNameTextView.setTextColor(customThemeWrapper.getPrimaryIconColor()); subredditNameTextView.setTextColor(customThemeWrapper.getPrimaryIconColor());
deleteButton.setColorFilter(customThemeWrapper.getPrimaryIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); deleteButton.setColorFilter(customThemeWrapper.getPrimaryIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
if (activity.typeface != null) {
subredditNameTextView.setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -19,19 +18,22 @@ import java.util.List;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData; import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
public class SubredditAutocompleteRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class SubredditAutocompleteRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private List<SubredditData> subreddits; private List<SubredditData> subreddits;
private RequestManager glide; private RequestManager glide;
private CustomThemeWrapper customThemeWrapper; private CustomThemeWrapper customThemeWrapper;
private ItemOnClickListener itemOnClickListener; private ItemOnClickListener itemOnClickListener;
public SubredditAutocompleteRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper, public SubredditAutocompleteRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
ItemOnClickListener itemOnClickListener) { ItemOnClickListener itemOnClickListener) {
glide = Glide.with(context); this.activity = activity;
glide = Glide.with(activity);
this.customThemeWrapper = customThemeWrapper; this.customThemeWrapper = customThemeWrapper;
this.itemOnClickListener = itemOnClickListener; this.itemOnClickListener = itemOnClickListener;
} }
@ -91,6 +93,10 @@ public class SubredditAutocompleteRecyclerViewAdapter extends RecyclerView.Adapt
subredditNameTextView.setTextColor(customThemeWrapper.getPrimaryTextColor()); subredditNameTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
if (activity.typeface != null) {
subredditNameTextView.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {
itemOnClickListener.onClick(subreddits.get(getBindingAdapterPosition())); itemOnClickListener.onClick(subreddits.get(getBindingAdapterPosition()));
}); });

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.os.Handler; import android.os.Handler;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -32,6 +31,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
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.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsSubscribedToSubreddit; import ml.docilealligator.infinityforreddit.asynctasks.CheckIsSubscribedToSubreddit;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData; import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
@ -55,7 +55,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
} }
}; };
private RequestManager glide; private RequestManager glide;
private Context context; private BaseActivity activity;
private Executor executor; private Executor executor;
private Retrofit oauthRetrofit; private Retrofit oauthRetrofit;
private Retrofit retrofit; private Retrofit retrofit;
@ -73,13 +73,13 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
private NetworkState networkState; private NetworkState networkState;
private Callback callback; private Callback callback;
public SubredditListingRecyclerViewAdapter(Context context, Executor executor, Retrofit oauthRetrofit, Retrofit retrofit, public SubredditListingRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit, Retrofit retrofit,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
String accessToken, String accountName, String accessToken, String accountName,
RedditDataRoomDatabase redditDataRoomDatabase, RedditDataRoomDatabase redditDataRoomDatabase,
boolean isMultiSelection, Callback callback) { boolean isMultiSelection, Callback callback) {
super(DIFF_CALLBACK); super(DIFF_CALLBACK);
this.context = context; this.activity = activity;
this.executor = executor; this.executor = executor;
this.oauthRetrofit = oauthRetrofit; this.oauthRetrofit = oauthRetrofit;
this.retrofit = retrofit; this.retrofit = retrofit;
@ -88,7 +88,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
this.redditDataRoomDatabase = redditDataRoomDatabase; this.redditDataRoomDatabase = redditDataRoomDatabase;
this.isMultiSelection = isMultiSelection; this.isMultiSelection = isMultiSelection;
this.callback = callback; this.callback = callback;
glide = Glide.with(context); glide = Glide.with(this.activity);
colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(); colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
primaryTextColor = customThemeWrapper.getPrimaryTextColor(); primaryTextColor = customThemeWrapper.getPrimaryTextColor();
secondaryTextColor = customThemeWrapper.getSecondaryTextColor(); secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
@ -163,12 +163,12 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
@Override @Override
public void onSubredditSubscriptionSuccess() { public void onSubredditSubscriptionSuccess() {
((DataViewHolder) holder).subscribeButton.setVisibility(View.GONE); ((DataViewHolder) holder).subscribeButton.setVisibility(View.GONE);
Toast.makeText(context, R.string.subscribed, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.subscribed, Toast.LENGTH_SHORT).show();
} }
@Override @Override
public void onSubredditSubscriptionFail() { public void onSubredditSubscriptionFail() {
Toast.makeText(context, R.string.subscribe_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.subscribe_failed, Toast.LENGTH_SHORT).show();
} }
}); });
} else { } else {
@ -178,12 +178,12 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
@Override @Override
public void onSubredditSubscriptionSuccess() { public void onSubredditSubscriptionSuccess() {
((DataViewHolder) holder).subscribeButton.setVisibility(View.GONE); ((DataViewHolder) holder).subscribeButton.setVisibility(View.GONE);
Toast.makeText(context, R.string.subscribed, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.subscribed, Toast.LENGTH_SHORT).show();
} }
@Override @Override
public void onSubredditSubscriptionFail() { public void onSubredditSubscriptionFail() {
Toast.makeText(context, R.string.subscribe_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.subscribe_failed, Toast.LENGTH_SHORT).show();
} }
}); });
} }
@ -273,6 +273,10 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
if (isMultiSelection) { if (isMultiSelection) {
checkBox.setVisibility(View.VISIBLE); checkBox.setVisibility(View.VISIBLE);
} }
if (activity.typeface != null) {
subredditNameTextView.setTypeface(activity.typeface);
}
} }
} }
@ -290,6 +294,11 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
errorTextView.setTextColor(secondaryTextColor); errorTextView.setTextColor(secondaryTextColor);
retryButton.setBackgroundTintList(ColorStateList.valueOf(colorPrimaryLightTheme)); retryButton.setBackgroundTintList(ColorStateList.valueOf(colorPrimaryLightTheme));
retryButton.setTextColor(buttonTextColor); retryButton.setTextColor(buttonTextColor);
if (activity.typeface != null) {
retryButton.setTypeface(activity.typeface);
errorTextView.setTypeface(activity.typeface);
}
} }
} }

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -21,21 +20,24 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subreddit.SubredditWithSelection; import ml.docilealligator.infinityforreddit.subreddit.SubredditWithSelection;
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private ArrayList<SubredditWithSelection> subscribedSubreddits; private ArrayList<SubredditWithSelection> subscribedSubreddits;
private RequestManager glide; private RequestManager glide;
private int primaryTextColor; private int primaryTextColor;
private int colorAccent; private int colorAccent;
public SubredditMultiselectionRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper) { public SubredditMultiselectionRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper) {
glide = Glide.with(context); this.activity = activity;
glide = Glide.with(activity);
primaryTextColor = customThemeWrapper.getPrimaryTextColor(); primaryTextColor = customThemeWrapper.getPrimaryTextColor();
colorAccent = customThemeWrapper.getColorAccent(); colorAccent = customThemeWrapper.getColorAccent();
} }
@ -118,6 +120,10 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
nameTextView.setTextColor(primaryTextColor); nameTextView.setTextColor(primaryTextColor);
checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent)); checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
if (activity.typeface != null) {
nameTextView.setTypeface(activity.typeface);
}
} }
} }
} }

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Handler; import android.os.Handler;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -27,6 +26,7 @@ import me.zhanghai.android.fastscroll.PopupTextProvider;
import ml.docilealligator.infinityforreddit.FavoriteThing; import ml.docilealligator.infinityforreddit.FavoriteThing;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
@ -39,7 +39,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
private static final int VIEW_TYPE_SUBREDDIT_DIVIDER = 2; private static final int VIEW_TYPE_SUBREDDIT_DIVIDER = 2;
private static final int VIEW_TYPE_SUBREDDIT = 3; private static final int VIEW_TYPE_SUBREDDIT = 3;
private Context mContext; private BaseActivity mActivity;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mOauthRetrofit; private Retrofit mOauthRetrofit;
private RedditDataRoomDatabase mRedditDataRoomDatabase; private RedditDataRoomDatabase mRedditDataRoomDatabase;
@ -56,13 +56,13 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
private int primaryTextColor; private int primaryTextColor;
private int secondaryTextColor; private int secondaryTextColor;
public SubscribedSubredditsRecyclerViewAdapter(Context context, Executor executor, Retrofit oauthRetrofit, public SubscribedSubredditsRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
String accessToken) { String accessToken) {
mContext = context; mActivity = activity;
mExecutor = executor; mExecutor = executor;
glide = Glide.with(context); glide = Glide.with(activity);
mOauthRetrofit = oauthRetrofit; mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase; mRedditDataRoomDatabase = redditDataRoomDatabase;
this.accessToken = accessToken; this.accessToken = accessToken;
@ -70,12 +70,12 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
secondaryTextColor = customThemeWrapper.getSecondaryTextColor(); secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
} }
public SubscribedSubredditsRecyclerViewAdapter(Context context, Executor executor, Retrofit oauthRetrofit, public SubscribedSubredditsRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
String accessToken, boolean hasClearSelectionRow, String accessToken, boolean hasClearSelectionRow,
ItemClickListener itemClickListener) { ItemClickListener itemClickListener) {
this(context, executor, oauthRetrofit, redditDataRoomDatabase, customThemeWrapper, accessToken); this(activity, executor, oauthRetrofit, redditDataRoomDatabase, customThemeWrapper, accessToken);
this.hasClearSelectionRow = hasClearSelectionRow; this.hasClearSelectionRow = hasClearSelectionRow;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
} }
@ -208,7 +208,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
@Override @Override
public void failed() { public void failed() {
Toast.makeText(mContext, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
int position = viewHolder.getBindingAdapterPosition() - offset; int position = viewHolder.getBindingAdapterPosition() - offset;
if(position >= 0 && mSubscribedSubredditData.size() > position) { if(position >= 0 && mSubscribedSubredditData.size() > position) {
mSubscribedSubredditData.get(position).setFavorite(true); mSubscribedSubredditData.get(position).setFavorite(true);
@ -234,7 +234,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
@Override @Override
public void failed() { public void failed() {
Toast.makeText(mContext, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
int position = viewHolder.getBindingAdapterPosition() - offset; int position = viewHolder.getBindingAdapterPosition() - offset;
if(position >= 0 && mSubscribedSubredditData.size() > position) { if(position >= 0 && mSubscribedSubredditData.size() > position) {
mSubscribedSubredditData.get(position).setFavorite(false); mSubscribedSubredditData.get(position).setFavorite(false);
@ -252,9 +252,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
if (itemClickListener == null) { if (itemClickListener == null) {
viewHolder.itemView.setOnClickListener(view -> { viewHolder.itemView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class); Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, name); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, name);
mContext.startActivity(intent); mActivity.startActivity(intent);
}); });
} }
@ -307,7 +307,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
@Override @Override
public void failed() { public void failed() {
Toast.makeText(mContext, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
int position = viewHolder.getBindingAdapterPosition() - 1; int position = viewHolder.getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteSubscribedSubredditData.size() > position) { if(position >= 0 && mFavoriteSubscribedSubredditData.size() > position) {
mFavoriteSubscribedSubredditData.get(position).setFavorite(true); mFavoriteSubscribedSubredditData.get(position).setFavorite(true);
@ -332,7 +332,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
@Override @Override
public void failed() { public void failed() {
Toast.makeText(mContext, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
int position = viewHolder.getBindingAdapterPosition() - 1; int position = viewHolder.getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteSubscribedSubredditData.size() > position) { if(position >= 0 && mFavoriteSubscribedSubredditData.size() > position) {
mFavoriteSubscribedSubredditData.get(position).setFavorite(false); mFavoriteSubscribedSubredditData.get(position).setFavorite(false);
@ -347,9 +347,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, false)); viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, false));
} else { } else {
viewHolder.itemView.setOnClickListener(view -> { viewHolder.itemView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class); Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, name); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, name);
mContext.startActivity(intent); mActivity.startActivity(intent);
}); });
} }
@ -483,6 +483,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
SubredditViewHolder(View itemView) { SubredditViewHolder(View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor); subredditNameTextView.setTextColor(primaryTextColor);
} }
} }
@ -498,6 +501,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
FavoriteSubredditViewHolder(View itemView) { FavoriteSubredditViewHolder(View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor); subredditNameTextView.setTextColor(primaryTextColor);
} }
} }
@ -508,6 +514,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
FavoriteSubredditsDividerViewHolder(@NonNull View itemView) { FavoriteSubredditsDividerViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
dividerTextView.setTypeface(mActivity.typeface);
}
dividerTextView.setText(R.string.favorites); dividerTextView.setText(R.string.favorites);
dividerTextView.setTextColor(secondaryTextColor); dividerTextView.setTextColor(secondaryTextColor);
} }
@ -519,6 +528,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
AllSubredditsDividerViewHolder(@NonNull View itemView) { AllSubredditsDividerViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
dividerTextView.setTypeface(mActivity.typeface);
}
dividerTextView.setText(R.string.all); dividerTextView.setText(R.string.all);
dividerTextView.setTextColor(secondaryTextColor); dividerTextView.setTextColor(secondaryTextColor);
} }

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -16,18 +15,19 @@ import java.util.ArrayList;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.settings.Translation; import ml.docilealligator.infinityforreddit.settings.Translation;
public class TranslationFragmentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class TranslationFragmentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Activity activity; private BaseActivity activity;
private int primaryTextColor; private int primaryTextColor;
private int secondaryTextColor; private int secondaryTextColor;
private ArrayList<Translation> translationContributors; private ArrayList<Translation> translationContributors;
public TranslationFragmentRecyclerViewAdapter(Activity activity, CustomThemeWrapper customThemeWrapper) { public TranslationFragmentRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper) {
this.activity = activity; this.activity = activity;
primaryTextColor = customThemeWrapper.getPrimaryTextColor(); primaryTextColor = customThemeWrapper.getPrimaryTextColor();
secondaryTextColor = customThemeWrapper.getSecondaryTextColor(); secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
@ -73,6 +73,11 @@ public class TranslationFragmentRecyclerViewAdapter extends RecyclerView.Adapter
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
if (activity.typeface != null) {
languageNameTextView.setTypeface(activity.typeface);
contributorNamesTextView.setTypeface(activity.typeface);
}
languageNameTextView.setTextColor(primaryTextColor); languageNameTextView.setTextColor(primaryTextColor);
contributorNamesTextView.setTextColor(secondaryTextColor); contributorNamesTextView.setTextColor(secondaryTextColor);

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -29,11 +28,13 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.TrendingSearch; import ml.docilealligator.infinityforreddit.TrendingSearch;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.post.Post;
public class TrendingSearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class TrendingSearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private ArrayList<TrendingSearch> trendingSearches; private ArrayList<TrendingSearch> trendingSearches;
private CustomThemeWrapper customThemeWrapper; private CustomThemeWrapper customThemeWrapper;
private RequestManager glide; private RequestManager glide;
@ -43,15 +44,16 @@ public class TrendingSearchRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private float mScale; private float mScale;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public TrendingSearchRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper, public TrendingSearchRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
int imageViewWidth, boolean dataSavingMode, boolean disableImagePreview, int imageViewWidth, boolean dataSavingMode, boolean disableImagePreview,
ItemClickListener itemClickListener) { ItemClickListener itemClickListener) {
this.activity = activity;
this.customThemeWrapper = customThemeWrapper; this.customThemeWrapper = customThemeWrapper;
this.glide = Glide.with(context); this.glide = Glide.with(activity);
this.imageViewWidth = imageViewWidth; this.imageViewWidth = imageViewWidth;
this.dataSavingMode = dataSavingMode; this.dataSavingMode = dataSavingMode;
this.disableImagePreview = disableImagePreview; this.disableImagePreview = disableImagePreview;
mScale = context.getResources().getDisplayMetrics().density; mScale = activity.getResources().getDisplayMetrics().density;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
} }
@ -216,6 +218,11 @@ public class TrendingSearchRecyclerViewAdapter extends RecyclerView.Adapter<Recy
progressBar.setIndeterminateTintList(ColorStateList.valueOf(customThemeWrapper.getColorAccent())); progressBar.setIndeterminateTintList(ColorStateList.valueOf(customThemeWrapper.getColorAccent()));
errorTextView.setTextColor(customThemeWrapper.getPrimaryTextColor()); errorTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
if (activity.typeface != null) {
titleTextView.setTypeface(activity.typeface);
errorTextView.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {
itemClickListener.onClick(trendingSearches.get(getBindingAdapterPosition())); itemClickListener.onClick(trendingSearches.get(getBindingAdapterPosition()));
}); });

View File

@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.app.Activity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -12,12 +13,17 @@ import java.util.ArrayList;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.UploadedImage; import ml.docilealligator.infinityforreddit.UploadedImage;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
public class UploadedImagesRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class UploadedImagesRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private ArrayList<UploadedImage> uploadedImages; private ArrayList<UploadedImage> uploadedImages;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public UploadedImagesRecyclerViewAdapter(ArrayList<UploadedImage> uploadedImages, ItemClickListener itemClickListener) { public UploadedImagesRecyclerViewAdapter(Activity activity, ArrayList<UploadedImage> uploadedImages, ItemClickListener itemClickListener) {
if (activity instanceof BaseActivity) {
this.activity = (BaseActivity) activity;
}
this.uploadedImages = uploadedImages; this.uploadedImages = uploadedImages;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
} }
@ -49,6 +55,11 @@ public class UploadedImagesRecyclerViewAdapter extends RecyclerView.Adapter<Recy
imageNameTextView = itemView.findViewById(R.id.image_name_item_uploaded_image); imageNameTextView = itemView.findViewById(R.id.image_name_item_uploaded_image);
imageUrlTextView = itemView.findViewById(R.id.image_url_item_uploaded_image); imageUrlTextView = itemView.findViewById(R.id.image_url_item_uploaded_image);
if (activity != null && activity.typeface != null) {
imageNameTextView.setTypeface(activity.typeface);
imageUrlTextView.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {
itemClickListener.onClick(uploadedImages.get(getBindingAdapterPosition())); itemClickListener.onClick(uploadedImages.get(getBindingAdapterPosition()));
}); });

View File

@ -13,18 +13,21 @@ import java.util.ArrayList;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.UserFlair; import ml.docilealligator.infinityforreddit.UserFlair;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
public class UserFlairRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class UserFlairRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private CustomThemeWrapper customThemeWrapper; private CustomThemeWrapper customThemeWrapper;
private ArrayList<UserFlair> userFlairs; private ArrayList<UserFlair> userFlairs;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public UserFlairRecyclerViewAdapter(CustomThemeWrapper customThemeWrapper, ArrayList<UserFlair> userFlairs, public UserFlairRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper, ArrayList<UserFlair> userFlairs,
ItemClickListener itemClickListener) { ItemClickListener itemClickListener) {
this.activity = activity;
this.customThemeWrapper = customThemeWrapper; this.customThemeWrapper = customThemeWrapper;
this.userFlairs = userFlairs; this.userFlairs = userFlairs;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
@ -76,6 +79,10 @@ public class UserFlairRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerV
userFlairHtmlTextView.setTextColor(customThemeWrapper.getPrimaryTextColor()); userFlairHtmlTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
editUserFlairImageView.setColorFilter(customThemeWrapper.getPrimaryTextColor(), android.graphics.PorterDuff.Mode.SRC_IN); editUserFlairImageView.setColorFilter(customThemeWrapper.getPrimaryTextColor(), android.graphics.PorterDuff.Mode.SRC_IN);
if (activity.typeface != null) {
userFlairHtmlTextView.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> { itemView.setOnClickListener(view -> {
itemClickListener.onClick(userFlairs.get(getBindingAdapterPosition()), false); itemClickListener.onClick(userFlairs.get(getBindingAdapterPosition()), false);
}); });

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters; package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.os.Handler; import android.os.Handler;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -32,6 +31,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
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.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUser; import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUser;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.user.UserData; import ml.docilealligator.infinityforreddit.user.UserData;
@ -55,7 +55,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
} }
}; };
private RequestManager glide; private RequestManager glide;
private Context context; private BaseActivity activity;
private Executor executor; private Executor executor;
private Retrofit oauthRetrofit; private Retrofit oauthRetrofit;
private Retrofit retrofit; private Retrofit retrofit;
@ -73,12 +73,12 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
private NetworkState networkState; private NetworkState networkState;
private final Callback callback; private final Callback callback;
public UserListingRecyclerViewAdapter(Context context, Executor executor, Retrofit oauthRetrofit, Retrofit retrofit, public UserListingRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit, Retrofit retrofit,
CustomThemeWrapper customThemeWrapper, String accessToken, CustomThemeWrapper customThemeWrapper, String accessToken,
String accountName, RedditDataRoomDatabase redditDataRoomDatabase, String accountName, RedditDataRoomDatabase redditDataRoomDatabase,
boolean isMultiSelection, Callback callback) { boolean isMultiSelection, Callback callback) {
super(DIFF_CALLBACK); super(DIFF_CALLBACK);
this.context = context; this.activity = activity;
this.executor = executor; this.executor = executor;
this.oauthRetrofit = oauthRetrofit; this.oauthRetrofit = oauthRetrofit;
this.retrofit = retrofit; this.retrofit = retrofit;
@ -87,7 +87,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
this.redditDataRoomDatabase = redditDataRoomDatabase; this.redditDataRoomDatabase = redditDataRoomDatabase;
this.isMultiSelection = isMultiSelection; this.isMultiSelection = isMultiSelection;
this.callback = callback; this.callback = callback;
glide = Glide.with(context); glide = Glide.with(activity);
primaryTextColor = customThemeWrapper.getPrimaryTextColor(); primaryTextColor = customThemeWrapper.getPrimaryTextColor();
buttonTextColor = customThemeWrapper.getButtonTextColor(); buttonTextColor = customThemeWrapper.getButtonTextColor();
colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(); colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
@ -155,12 +155,12 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
@Override @Override
public void onUserFollowingSuccess() { public void onUserFollowingSuccess() {
((DataViewHolder) holder).subscribeButton.setVisibility(View.GONE); ((DataViewHolder) holder).subscribeButton.setVisibility(View.GONE);
Toast.makeText(context, R.string.followed, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.followed, Toast.LENGTH_SHORT).show();
} }
@Override @Override
public void onUserFollowingFail() { public void onUserFollowingFail() {
Toast.makeText(context, R.string.follow_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.follow_failed, Toast.LENGTH_SHORT).show();
} }
}); });
}); });
@ -246,6 +246,11 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
userNameTextView.setTextColor(primaryTextColor); userNameTextView.setTextColor(primaryTextColor);
subscribeButton.setColorFilter(unsubscribedColor, android.graphics.PorterDuff.Mode.SRC_IN); subscribeButton.setColorFilter(unsubscribedColor, android.graphics.PorterDuff.Mode.SRC_IN);
if (activity.typeface != null) {
userNameTextView.setTypeface(activity.typeface);
}
if (isMultiSelection) { if (isMultiSelection) {
checkBox.setVisibility(View.VISIBLE); checkBox.setVisibility(View.VISIBLE);
} }
@ -266,6 +271,11 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
errorTextView.setTextColor(primaryTextColor); errorTextView.setTextColor(primaryTextColor);
retryButton.setTextColor(buttonTextColor); retryButton.setTextColor(buttonTextColor);
retryButton.setBackgroundTintList(ColorStateList.valueOf(colorPrimaryLightTheme)); retryButton.setBackgroundTintList(ColorStateList.valueOf(colorPrimaryLightTheme));
if (activity.typeface != null) {
retryButton.setTypeface(activity.typeface);
errorTextView.setTypeface(activity.typeface);
}
} }
} }

View File

@ -14,13 +14,13 @@ 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.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity; import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.EditCommentActivity; import ml.docilealligator.infinityforreddit.activities.EditCommentActivity;
import ml.docilealligator.infinityforreddit.activities.FullMarkdownActivity; import ml.docilealligator.infinityforreddit.activities.FullMarkdownActivity;
@ -30,6 +30,7 @@ import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.comment.Comment; import ml.docilealligator.infinityforreddit.comment.Comment;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
@ -64,7 +65,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
TextView reportTextView; TextView reportTextView;
@BindView(R.id.see_removed_view_comment_more_bottom_sheet_fragment) @BindView(R.id.see_removed_view_comment_more_bottom_sheet_fragment)
TextView seeRemovedTextView; TextView seeRemovedTextView;
private AppCompatActivity activity; private BaseActivity activity;
public CommentMoreBottomSheetFragment() { public CommentMoreBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
@ -224,12 +225,16 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
}); });
} }
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
activity = (AppCompatActivity) context; activity = (BaseActivity) context;
} }
} }

View File

@ -1,12 +1,10 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -21,7 +19,9 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -39,7 +39,7 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
@BindView(R.id.copy_all_markdown_text_view_copy_text_bottom_sheet_fragment) @BindView(R.id.copy_all_markdown_text_view_copy_text_bottom_sheet_fragment)
TextView copyAllMarkdownTextView; TextView copyAllMarkdownTextView;
private Activity activity; private BaseActivity activity;
private String markdownText; private String markdownText;
public CopyTextBottomSheetFragment() { public CopyTextBottomSheetFragment() {
@ -88,6 +88,10 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
copyAllMarkdownTextView.setVisibility(View.GONE); copyAllMarkdownTextView.setVisibility(View.GONE);
} }
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@ -118,6 +122,6 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
activity = (Activity) context; activity = (BaseActivity) context;
} }
} }

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -15,8 +14,10 @@ import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity; import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -31,7 +32,7 @@ public class CreateThemeBottomSheetFragment extends LandscapeExpandedRoundedBott
TextView darkThemeTextView; TextView darkThemeTextView;
@BindView(R.id.amoled_theme_text_view_create_theme_bottom_sheet_fragment) @BindView(R.id.amoled_theme_text_view_create_theme_bottom_sheet_fragment)
TextView amoledThemeTextView; TextView amoledThemeTextView;
private Activity activity; private BaseActivity activity;
public interface SelectBaseThemeBottomSheetFragmentListener { public interface SelectBaseThemeBottomSheetFragmentListener {
void importTheme(); void importTheme();
@ -78,12 +79,16 @@ public class CreateThemeBottomSheetFragment extends LandscapeExpandedRoundedBott
startActivity(intent); startActivity(intent);
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
activity = (Activity) context; activity = (BaseActivity) context;
} }
} }

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -10,14 +9,15 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity; import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -36,7 +36,7 @@ public class CustomThemeOptionsBottomSheetFragment extends LandscapeExpandedRoun
@BindView(R.id.delete_theme_text_view_custom_theme_options_bottom_sheet_fragment) @BindView(R.id.delete_theme_text_view_custom_theme_options_bottom_sheet_fragment)
TextView deleteTextView; TextView deleteTextView;
private String themeName; private String themeName;
private Activity activity; private BaseActivity activity;
public CustomThemeOptionsBottomSheetFragment() { public CustomThemeOptionsBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
@ -79,12 +79,16 @@ public class CustomThemeOptionsBottomSheetFragment extends LandscapeExpandedRoun
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
activity = (AppCompatActivity) context; activity = (BaseActivity) context;
} }
} }

View File

@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,7 +13,9 @@ import androidx.annotation.NonNull;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@ -117,6 +120,13 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
dismiss(); dismiss();
}); });
Activity baseActivity = getActivity();
if (baseActivity instanceof BaseActivity) {
if (((BaseActivity) baseActivity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((BaseActivity) baseActivity).typeface);
}
}
return rootView; return rootView;
} }

View File

@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,7 +13,9 @@ import androidx.annotation.NonNull;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class FilteredThingFABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class FilteredThingFABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@ -47,6 +50,13 @@ public class FilteredThingFABMoreOptionsBottomSheetFragment extends LandscapeExp
dismiss(); dismiss();
}); });
Activity baseActivity = getActivity();
if (baseActivity instanceof BaseActivity) {
if (((BaseActivity) baseActivity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((BaseActivity) baseActivity).typeface);
}
}
return rootView; return rootView;
} }

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -30,9 +29,11 @@ import ml.docilealligator.infinityforreddit.FetchFlairs;
import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.adapters.FlairBottomSheetRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.adapters.FlairBottomSheetRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.FlairSelectedEvent; import ml.docilealligator.infinityforreddit.events.FlairSelectedEvent;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -60,7 +61,7 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
private String mAccessToken; private String mAccessToken;
private String mSubredditName; private String mSubredditName;
private Activity mActivity; private BaseActivity mActivity;
private FlairBottomSheetRecyclerViewAdapter mAdapter; private FlairBottomSheetRecyclerViewAdapter mAdapter;
public FlairBottomSheetFragment() { public FlairBottomSheetFragment() {
@ -76,6 +77,10 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
((Infinity) mActivity.getApplication()).getAppComponent().inject(this); ((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
if (mActivity.typeface != null) {
Utils.setFontToAllTextViews(rootView, mActivity.typeface);
}
long viewPostFragmentId = getArguments().getLong(EXTRA_VIEW_POST_DETAIL_FRAGMENT_ID, -1); long viewPostFragmentId = getArguments().getLong(EXTRA_VIEW_POST_DETAIL_FRAGMENT_ID, -1);
mAdapter = new FlairBottomSheetRecyclerViewAdapter(mActivity, mCustomThemeWrapper, flair -> { mAdapter = new FlairBottomSheetRecyclerViewAdapter(mActivity, mCustomThemeWrapper, flair -> {
if (viewPostFragmentId <= 0) { if (viewPostFragmentId <= 0) {
@ -133,7 +138,7 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
mActivity = (Activity) context; mActivity = (BaseActivity) context;
} }
public interface FlairSelectionCallback { public interface FlairSelectionCallback {

View File

@ -21,6 +21,7 @@ import ml.docilealligator.infinityforreddit.activities.EditMultiRedditActivity;
import ml.docilealligator.infinityforreddit.activities.SubscribedThingListingActivity; import ml.docilealligator.infinityforreddit.activities.SubscribedThingListingActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit; import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -79,6 +80,10 @@ public class MultiRedditOptionsBottomSheetFragment extends LandscapeExpandedRoun
dismiss(); dismiss();
}); });
if (subscribedThingListingActivity.typeface != null) {
Utils.setFontToAllTextViews(rootView, subscribedThingListingActivity.typeface);
}
return rootView; return rootView;
} }

View File

@ -15,6 +15,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity; import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage; import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class NewPostFilterUsageBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class NewPostFilterUsageBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@ -67,6 +68,10 @@ public class NewPostFilterUsageBottomSheetFragment extends LandscapeExpandedRoun
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }

View File

@ -14,10 +14,13 @@ import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.ViewImgurMediaActivity;
import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity;
import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity; import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewImgurVideoFragment; import ml.docilealligator.infinityforreddit.fragments.ViewImgurVideoFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment; import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class PlaybackSpeedBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class PlaybackSpeedBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@ -119,6 +122,20 @@ public class PlaybackSpeedBottomSheetFragment extends LandscapeExpandedRoundedBo
setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_200); setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_200);
dismiss(); dismiss();
}); });
if (activity instanceof ViewVideoActivity) {
if (((ViewVideoActivity) activity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((ViewVideoActivity) activity).typeface);
}
} else if (activity instanceof ViewImgurMediaActivity) {
if (((ViewImgurMediaActivity) activity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((ViewImgurMediaActivity) activity).typeface);
}
} else if (activity instanceof ViewRedditGalleryActivity) {
if (((ViewRedditGalleryActivity) activity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((ViewRedditGalleryActivity) activity).typeface);
}
}
return rootView; return rootView;
} }

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
@ -19,7 +18,9 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -44,7 +45,7 @@ public class PostCommentSortTypeBottomSheetFragment extends LandscapeExpandedRou
TextView qaTypeTextView; TextView qaTypeTextView;
@BindView(R.id.live_type_text_view_post_comment_sort_type_bottom_sheet_fragment) @BindView(R.id.live_type_text_view_post_comment_sort_type_bottom_sheet_fragment)
TextView liveTypeTextView; TextView liveTypeTextView;
private Activity activity; private BaseActivity activity;
public PostCommentSortTypeBottomSheetFragment() { public PostCommentSortTypeBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
} }
@ -107,12 +108,16 @@ public class PostCommentSortTypeBottomSheetFragment extends LandscapeExpandedRou
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
this.activity = (Activity) context; this.activity = (BaseActivity) context;
} }
} }

View File

@ -15,6 +15,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity; import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter; import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class PostFilterOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class PostFilterOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@ -56,6 +57,10 @@ public class PostFilterOptionsBottomSheetFragment extends LandscapeExpandedRound
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }

View File

@ -15,6 +15,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity; import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage; import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class PostFilterUsageOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class PostFilterUsageOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@ -54,6 +55,10 @@ public class PostFilterUsageOptionsBottomSheetFragment extends LandscapeExpanded
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -15,8 +14,10 @@ import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -31,7 +32,7 @@ public class PostLayoutBottomSheetFragment extends LandscapeExpandedRoundedBotto
TextView compactLayoutTextView; TextView compactLayoutTextView;
@BindView(R.id.gallery_layout_text_view_post_layout_bottom_sheet_fragment) @BindView(R.id.gallery_layout_text_view_post_layout_bottom_sheet_fragment)
TextView galleryLayoutTextView; TextView galleryLayoutTextView;
private Activity activity; private BaseActivity activity;
public PostLayoutBottomSheetFragment() { public PostLayoutBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
} }
@ -60,13 +61,17 @@ public class PostLayoutBottomSheetFragment extends LandscapeExpandedRoundedBotto
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD_2); ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD_2);
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
this.activity = (Activity) context; this.activity = (BaseActivity) context;
} }
public interface PostLayoutSelectionCallback { public interface PostLayoutSelectionCallback {

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
@ -17,7 +16,9 @@ import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
@ -40,7 +41,7 @@ public class PostTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
TextView videoTypeTextView; TextView videoTypeTextView;
@BindView(R.id.gallery_type_linear_layout_post_type_bottom_sheet_fragment) @BindView(R.id.gallery_type_linear_layout_post_type_bottom_sheet_fragment)
TextView galleryTypeTextView; TextView galleryTypeTextView;
private Activity activity; private BaseActivity activity;
public PostTypeBottomSheetFragment() { public PostTypeBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
@ -82,13 +83,17 @@ public class PostTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
this.activity = (Activity) context; this.activity = (BaseActivity) context;
} }
public interface PostTypeSelectionCallback { public interface PostTypeSelectionCallback {

View File

@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,7 +13,9 @@ import androidx.annotation.NonNull;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class RandomBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class RandomBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@ -72,6 +75,13 @@ public class RandomBottomSheetFragment extends LandscapeExpandedRoundedBottomShe
dismiss(); dismiss();
}); });
Activity baseActivity = getActivity();
if (baseActivity instanceof BaseActivity) {
if (((BaseActivity) activity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((BaseActivity) activity).typeface);
}
}
return rootView; return rootView;
} }

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
@ -19,7 +18,9 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
@ -37,7 +38,7 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
TextView newTypeTextView; TextView newTypeTextView;
@BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment) @BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment)
TextView commentsTypeTextView; TextView commentsTypeTextView;
private Activity activity; private BaseActivity activity;
public SearchPostSortTypeBottomSheetFragment() { public SearchPostSortTypeBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
} }
@ -78,12 +79,16 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
this.activity = (Activity) context; this.activity = (BaseActivity) context;
} }
} }

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments; package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
@ -19,7 +18,9 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/** /**
@ -32,7 +33,7 @@ public class SearchUserAndSubredditSortTypeBottomSheetFragment extends Landscape
TextView relevanceTypeTextView; TextView relevanceTypeTextView;
@BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) @BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment)
TextView activityTypeTextView; TextView activityTypeTextView;
private Activity activity; private BaseActivity activity;
public SearchUserAndSubredditSortTypeBottomSheetFragment() { public SearchUserAndSubredditSortTypeBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
} }
@ -64,12 +65,16 @@ public class SearchUserAndSubredditSortTypeBottomSheetFragment extends Landscape
dismiss(); dismiss();
}); });
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView; return rootView;
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
this.activity = (Activity) context; this.activity = (BaseActivity) context;
} }
} }

Some files were not shown because too many files have changed in this diff Show More