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
android:name=".activities.LockScreenActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.AnonymousSubscriptionsActivity"
android:label="@string/subscriptions"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.WebViewActivity"
android:label=""

View File

@ -5,7 +5,6 @@ import javax.inject.Singleton;
import dagger.Component;
import ml.docilealligator.infinityforreddit.activities.AccountPostsActivity;
import ml.docilealligator.infinityforreddit.activities.AccountSavedThingActivity;
import ml.docilealligator.infinityforreddit.activities.AnonymousSubscriptionsActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.CreateMultiRedditActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity;
@ -271,8 +270,6 @@ public interface AppComponent {
void inject(CrashReportsFragment crashReportsFragment);
void inject(AnonymousSubscriptionsActivity anonymousSubscriptionsActivity);
void inject(LockScreenActivity lockScreenActivity);
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() {
@Override
public void onActivityPreCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
if (activity instanceof BaseActivity) {
((BaseActivity) activity).setCustomFont(typeface, titleTypeface, contentTypeface);
if (activity instanceof CustomFontReceiver) {
((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.readpost.InsertReadPost;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface,
@ -179,10 +180,10 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) {
case 0:
tab.setText(R.string.posts);
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.posts));
break;
case 1:
tab.setText(R.string.comments);
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.comments));
break;
}
}).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.ViewGroup;
import android.view.Window;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
@ -40,6 +41,7 @@ import java.util.Locale;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
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.utils.CustomThemeSharedPreferencesUtils;
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 changeStatusBarIconColor;
private boolean transparentStatusBarAfterToolbarCollapsed;
@ -321,13 +324,21 @@ public abstract class BaseActivity extends AppCompatActivity {
if (toolbar.getOverflowIcon() != null) {
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")
protected boolean applyMenuItemTheme(Menu menu) {
if (customThemeWrapper != null) {
int size = Math.min(menu.size(), 2);
for (int i = 0; i < size; i++) {
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
if (((MenuItemImpl) item).requestsActionButton()) {
Drawable drawable = item.getIcon();
@ -336,6 +347,7 @@ public abstract class BaseActivity extends AppCompatActivity {
item.setIcon(drawable);
}
}
Utils.setTitleWithCustomFontToMenuItem(typeface, item, null);
}
}
return true;
@ -372,6 +384,7 @@ public abstract class BaseActivity extends AppCompatActivity {
} catch (NoSuchFieldException | IllegalAccessException ignore) {}
}
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
this.titleTypeface = titleTypeface;

View File

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

View File

@ -38,6 +38,7 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.multireddit.CreateMultiReddit;
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
public class CreateMultiRedditActivity extends BaseActivity {
@ -235,5 +236,9 @@ public class CreateMultiRedditActivity extends BaseActivity {
descriptionEditText.setHintTextColor(secondaryTextColor);
visibilityTextView.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.Configuration;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
@ -48,6 +49,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
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.ThemePreviewPostsFragment;
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 Typeface typeface;
public Typeface titleTypeface;
public Typeface contentTypeface;
@BindView(R.id.coordinator_layout_theme_preview_activity)
CoordinatorLayout coordinatorLayout;
@ -357,6 +363,13 @@ public class CustomThemePreviewActivity extends AppCompatActivity {
applyFABTheme(fab);
unsubscribedColor = customTheme.unsubscribed;
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) {
@ -369,6 +382,15 @@ public class CustomThemePreviewActivity extends AppCompatActivity {
if (toolbar.getOverflowIcon() != null) {
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) {
@ -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 ThemePreviewPostsFragment themePreviewPostsFragment;
private ThemePreviewCommentsFragment themePreviewCommentsFragment;
@ -450,9 +479,9 @@ public class CustomThemePreviewActivity extends AppCompatActivity {
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "Posts";
return Utils.getTabTextWithCustomFont(typeface, "Posts");
case 1:
return "Comments";
return Utils.getTabTextWithCustomFont(typeface, "Comments");
}
return null;
}

View File

@ -498,6 +498,10 @@ public class CustomizePostFilterActivity extends BaseActivity {
setCursorDrawableColor(minAwardsTextInputEditText, primaryTextColor);
setCursorDrawableColor(maxAwardsTextInputEditText, primaryTextColor);
}
if (typeface != null) {
Utils.setFontToAllTextViews(coordinatorLayout, typeface);
}
}
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());
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
contentEditText.setTextColor(mCustomThemeWrapper.getCommentColor());
if (contentTypeface != null) {
contentEditText.setTypeface(contentTypeface);
}
}
@Override

View File

@ -41,6 +41,7 @@ import ml.docilealligator.infinityforreddit.multireddit.FetchMultiRedditInfo;
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
public class EditMultiRedditActivity extends BaseActivity {
@ -288,5 +289,9 @@ public class EditMultiRedditActivity extends BaseActivity {
descriptionEditText.setHintTextColor(secondaryTextColor);
visibilityTextView.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());
divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor());
contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
if (titleTypeface != null) {
titleTextView.setTypeface(titleTypeface);
}
if (contentTypeface != null) {
contentEditText.setTypeface(contentTypeface);
}
}
@Override

View File

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

View File

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

View File

@ -19,7 +19,6 @@ import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.switchmaterial.SwitchMaterial;
@ -113,7 +112,7 @@ public class GiveAwardActivity extends BaseActivity {
}
private void bindView() {
adapter = new AwardRecyclerViewAdapter(Glide.with(this), mCustomThemeWrapper, award -> {
adapter = new AwardRecyclerViewAdapter(this, mCustomThemeWrapper, award -> {
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.dialog_give_award, null);
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.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@ -283,10 +284,10 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) {
case 0:
tab.setText(R.string.notifications);
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.notifications));
break;
case 1:
tab.setText(R.string.messages);
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.messages));
break;
}
}).attach();

View File

@ -98,6 +98,10 @@ public class LockScreenActivity extends BaseActivity {
textView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
unlockButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
unlockButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
if (typeface != null) {
textView.setTypeface(typeface);
unlockButton.setTypeface(typeface);
}
}
@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());
twoFAInfoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null);
applyFABTheme(fab);
if (typeface != null) {
twoFAInfoTextView.setTypeface(typeface);
}
}
@Override

View File

@ -25,7 +25,6 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -355,12 +354,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
applyTabLayoutTheme(tabLayout);
bottomAppBar.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
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) {
@ -858,32 +851,32 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) {
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;
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;
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;
}
if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits)
&& sectionsPagerAdapter != null) {
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()) {
tab.setText(sectionsPagerAdapter.multiReddits.get(position - tabCount
Utils.setTitleWithCustomFontToTab(typeface, tab, sectionsPagerAdapter.multiReddits.get(position - tabCount
- sectionsPagerAdapter.favoriteMultiReddits.size()).getName());
} else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.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.multiReddits.size()).getName());
} else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size()
- sectionsPagerAdapter.multiReddits.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.multiReddits.size()
- 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) {
showPostFilterOptions(post, postFilter);
} else if (subredditName != null) {

View File

@ -425,6 +425,15 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
nsfwTextView.setTextColor(primaryTextColor);
titleEditText.setTextColor(primaryTextColor);
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() {

View File

@ -409,6 +409,16 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
applyFABTheme(captureFab);
applyFABTheme(selectFromLibraryFab);
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() {

View File

@ -384,6 +384,19 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
suggestTitleButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
linkEditText.setTextColor(primaryTextColor);
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() {

View File

@ -406,6 +406,18 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
titleEditText.setHintTextColor(secondaryTextColor);
contentEditText.setTextColor(primaryTextColor);
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() {

View File

@ -424,6 +424,16 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
applyFABTheme(captureFab);
applyFABTheme(selectFromLibraryFab);
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() {

View File

@ -4,6 +4,7 @@ import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
@ -46,6 +47,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
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.utils.JSONUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
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";
@ -90,6 +93,7 @@ public class RPANActivity extends AppCompatActivity {
ArrayList<RPANBroadcast> rpanBroadcasts;
@State
String nextCursor;
public Typeface typeface;
private SectionsPagerAdapter sectionsPagerAdapter;
@Override
@ -130,7 +134,7 @@ public class RPANActivity extends AppCompatActivity {
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
actionBar.setHomeAsUpIndicator(upArrow);
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) {
loadRPANVideos();
@ -337,6 +341,9 @@ public class RPANActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu 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;
}
@ -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 {
public SectionsPagerAdapter(FragmentActivity fa) {

View File

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

View File

@ -160,6 +160,9 @@ public class RulesActivity extends BaseActivity {
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorAccent()));
errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (typeface != null) {
errorTextView.setTypeface(typeface);
}
}
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.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@ -360,6 +361,9 @@ public class SearchActivity extends BaseActivity {
searchInTextView.setTextColor(colorAccent);
subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
if (typeface != null) {
Utils.setFontToAllTextViews(coordinatorLayout, typeface);
}
}
@Override

View File

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

View File

@ -129,7 +129,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
}
private void instantiateRecyclerView() {
mAdapter = new UserFlairRecyclerViewAdapter(mCustomThemeWrapper, mUserFlairs, (userFlair, editUserFlair) -> {
mAdapter = new UserFlairRecyclerViewAdapter(this, mCustomThemeWrapper, mUserFlairs, (userFlair, editUserFlair) -> {
if (editUserFlair) {
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_flair, null);
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);
}
adapter = new SelectedSubredditsRecyclerViewAdapter(mCustomThemeWrapper, subreddits);
adapter = new SelectedSubredditsRecyclerViewAdapter(this, mCustomThemeWrapper, subreddits);
linearLayoutManager = new LinearLayoutManagerBugFixed(this);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(adapter);

View File

@ -186,5 +186,10 @@ public class SendPrivateMessageActivity extends BaseActivity {
int dividerColor = mCustomThemeWrapper.getDividerColor();
divider1.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);
playButton.setColorFilter(mCustomThemeWrapper.getMediaIndicatorIconColor(), PorterDuff.Mode.SRC_IN);
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() {

View File

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

View File

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

View File

@ -84,5 +84,10 @@ public class SuicidePreventionActivity extends BaseActivity {
doNotShowThisAgainTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
continueButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme()));
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.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (typeface != null) {
errorTextView.setTypeface(typeface);
}
}
@Subscribe

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@ -60,6 +61,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.BuildConfig;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
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.services.DownloadMediaService;
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_GIF_URL_KEY = "EGUK";
@ -114,6 +117,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
private String mSubredditName;
private boolean isGif = true;
private boolean isNsfw;
private Typeface typeface;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -175,7 +179,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
if (useBottomAppBar) {
titleTextView.setText(title);
} else {
setTitle(title);
setTitle(Utils.getTabTextWithCustomFont(typeface, title));
}
} else {
if (!useBottomAppBar) {
@ -312,8 +316,12 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
@Override
public boolean onCreateOptionsMenu(Menu 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);
}
return true;
}
@ -545,4 +553,9 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
super.onDestroy();
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;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@ -36,6 +37,7 @@ import app.futured.hauler.DragDirection;
import app.futured.hauler.HaulerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.ImgurMedia;
import ml.docilealligator.infinityforreddit.Infinity;
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.JSONUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
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_ID = "EII";
@ -76,6 +79,7 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
ViewPagerBugFixed viewPager;
@BindView(R.id.load_image_error_linear_layout_view_imgur_media_activity)
LinearLayout errorLinearLayout;
public Typeface typeface;
private SectionsPagerAdapter sectionsPagerAdapter;
private ArrayList<ImgurMedia> images;
private boolean useBottomAppBar;
@ -297,9 +301,9 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
private void setToolbarTitle(int position) {
if (images != null && position >= 0 && position < images.size()) {
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 {
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();
}
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
}
private class SectionsPagerAdapter extends FragmentStatePagerAdapter {
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);
nextResultImageView.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) {

View File

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

View File

@ -7,6 +7,7 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
@ -37,6 +38,7 @@ import app.futured.hauler.DragDirection;
import app.futured.hauler.HaulerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
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.post.Post;
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_SUBREDDIT_NAME = "ESN";
@ -68,6 +71,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
SharedPreferences sharedPreferences;
@Inject
Executor executor;
public Typeface typeface;
private SectionsPagerAdapter sectionsPagerAdapter;
private ArrayList<Post.Gallery> gallery;
private String subredditName;
@ -194,11 +198,11 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
private void setToolbarTitle(int position) {
if (gallery != null && position >= 0 && position < gallery.size()) {
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) {
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 {
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();
}
@Override
public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
this.typeface = typeface;
}
private class SectionsPagerAdapter extends FragmentStatePagerAdapter {
SectionsPagerAdapter(@NonNull FragmentManager fm) {

View File

@ -558,6 +558,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
option4BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
applyTabLayoutTheme(tabLayout);
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();
subscribedColor = mCustomThemeWrapper.getSubscribed();
}

View File

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

View File

@ -14,6 +14,7 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
@ -81,6 +82,7 @@ import app.futured.hauler.HaulerView;
import app.futured.hauler.LockableNestedScrollView;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
import ml.docilealligator.infinityforreddit.FetchStreamableVideo;
import ml.docilealligator.infinityforreddit.Infinity;
@ -106,7 +108,7 @@ import retrofit2.Callback;
import retrofit2.Response;
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_50 = 50;
@ -168,6 +170,8 @@ public class ViewVideoActivity extends AppCompatActivity {
@BindView(R.id.lockable_nested_scroll_view_view_video_activity)
LockableNestedScrollView nestedScrollView;
public Typeface typeface;
private Uri mVideoUri;
private SimpleExoPlayer player;
private DefaultTrackSelector trackSelector;
@ -556,7 +560,7 @@ public class ViewVideoActivity extends AppCompatActivity {
if (useBottomAppBar) {
titleTextView.setText(Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", title)));
} 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 {
if (!useBottomAppBar) {
@ -808,6 +812,9 @@ public class ViewVideoActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu 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;
}
@ -941,4 +948,9 @@ public class ViewVideoActivity extends AppCompatActivity {
}
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
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.web_view_activity, menu);
applyMenuItemTheme(menu);
return true;
}

View File

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

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
@ -14,16 +13,17 @@ import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.settings.Acknowledgement;
public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<AcknowledgementRecyclerViewAdapter.AcknowledgementViewHolder> {
private ArrayList<Acknowledgement> acknowledgements;
private Context context;
private BaseActivity activity;
public AcknowledgementRecyclerViewAdapter(Context context, ArrayList<Acknowledgement> acknowledgements) {
this.context = context;
public AcknowledgementRecyclerViewAdapter(BaseActivity activity, ArrayList<Acknowledgement> acknowledgements) {
this.activity = activity;
this.acknowledgements = acknowledgements;
}
@ -40,10 +40,10 @@ public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<Ack
holder.nameTextView.setText(acknowledgement.getName());
holder.introductionTextView.setText(acknowledgement.getIntroduction());
holder.itemView.setOnClickListener(view -> {
if (context != null) {
Intent intent = new Intent(context, LinkResolverActivity.class);
if (activity != null) {
Intent intent = new Intent(activity, LinkResolverActivity.class);
intent.setData(acknowledgement.getLink());
context.startActivity(intent);
activity.startActivity(intent);
}
});
}
@ -65,6 +65,11 @@ public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<Ack
super(itemView);
ButterKnife.bind(this, 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.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.award.Award;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R;
import pl.droidsonroids.gif.GifImageView;
public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<Award> awards;
private BaseActivity activity;
private RequestManager glide;
private ItemOnClickListener itemOnClickListener;
private int primaryTextColor;
@ -31,10 +34,11 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
void onClick(Award award);
}
public AwardRecyclerViewAdapter(RequestManager glide, CustomThemeWrapper customThemeWrapper,
public AwardRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
ItemOnClickListener itemOnClickListener) {
awards = Award.getAvailableAwards();
this.glide = glide;
this.activity = activity;
this.glide = Glide.with(activity);
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
this.itemOnClickListener = itemOnClickListener;
@ -52,7 +56,7 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
Award award = awards.get(position);
glide.load(award.getIconUrl()).into(((AwardViewHolder) holder).iconImageView);
((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()));
}
}
@ -68,7 +72,7 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
if (holder instanceof AwardViewHolder) {
glide.clear(((AwardViewHolder) holder).iconImageView);
((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)
TextView nameTextView;
@BindView(R.id.description_text_view_item_award)
TextView desctiptionTextView;
TextView descriptionTextView;
@BindView(R.id.coin_text_view_item_award)
TextView coinTextView;
@ -86,8 +90,13 @@ public class AwardRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.
super(itemView);
ButterKnife.bind(this, itemView);
if (activity.typeface != null) {
nameTextView.setTypeface(activity.typeface);
descriptionTextView.setTypeface(activity.typeface);
coinTextView.setTypeface(activity.typeface);
}
nameTextView.setTextColor(primaryTextColor);
desctiptionTextView.setTextColor(secondaryTextColor);
descriptionTextView.setTextColor(secondaryTextColor);
coinTextView.setTextColor(primaryTextColor);
itemView.setOnClickListener(view -> {

View File

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

View File

@ -22,7 +22,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
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.tag.SuperScriptHandler;
import io.noties.markwon.inlineparser.AutolinkInlineProcessor;
import io.noties.markwon.inlineparser.BackslashInlineProcessor;
import io.noties.markwon.inlineparser.BangInlineProcessor;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
@ -55,6 +53,7 @@ import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
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_VIEW_ALL_COMMENTS = 17;
private AppCompatActivity mActivity;
private BaseActivity mActivity;
private ViewPostDetailFragment mFragment;
private Executor mExecutor;
private Retrofit mRetrofit;
@ -145,7 +144,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private int mSearchCommentIndex = -1;
public CommentsRecyclerViewAdapter(AppCompatActivity activity, ViewPostDetailFragment fragment,
public CommentsRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
CustomThemeWrapper customThemeWrapper,
Executor executor, Retrofit retrofit, Retrofit oauthRetrofit,
String accessToken, String accountName,
@ -1119,6 +1118,17 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
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);
authorTextView.setTextColor(mUsernameColor);
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 (mCommentToolbarHideOnClick) {
View.OnLongClickListener hideToolbarOnLongClickListener = view -> hideToolbar();
@ -1547,6 +1547,11 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
super(itemView);
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
usernameTextView.setTypeface(mActivity.typeface);
scoreTextView.setTypeface(mActivity.typeface);
commentTimeTextView.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mFullyCollapsedCommentBackgroundColor);
usernameTextView.setTextColor(mUsernameColor);
scoreTextView.setTextColor(mSecondaryTextColor);
@ -1602,6 +1607,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
commentDivider.setVisibility(View.VISIBLE);
}
if (mActivity.typeface != null) {
placeholderTextView.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mCommentBackgroundColor);
placeholderTextView.setTextColor(mPrimaryTextColor);
commentDivider.setBackgroundColor(mDividerColor);
@ -1628,6 +1636,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
super(itemView);
ButterKnife.bind(this, itemView);
itemView.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingComments());
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
}
errorTextView.setTextColor(mSecondaryTextColor);
}
}
@ -1639,6 +1650,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
NoCommentViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
}
errorTextView.setTextColor(mSecondaryTextColor);
}
}
@ -1663,6 +1677,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
LoadMoreCommentsFailedViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
errorTextView.setTypeface(mActivity.typeface);
retryButton.setTypeface(mActivity.typeface);
}
errorTextView.setText(R.string.load_comments_failed);
retryButton.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingMoreComments());
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));
((TextView) itemView).setTextColor(mColorAccent);
}

View File

@ -11,11 +11,14 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
public class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private List<String> crashReports;
public CrashReportsRecyclerViewAdapter(List<String> crashReports) {
public CrashReportsRecyclerViewAdapter(BaseActivity activity, List<String> crashReports) {
this.activity = activity;
this.crashReports = crashReports;
}
@ -40,6 +43,10 @@ public class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
public CrashReportViewHolder(@NonNull View itemView) {
super(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 androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
@ -18,11 +17,12 @@ import java.util.List;
import butterknife.BindView;
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.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
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> {
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_USER_THEME_DIVIDER = 3;
private AppCompatActivity activity;
private BaseActivity activity;
private ArrayList<CustomTheme> predefinedCustomThemes;
private ArrayList<CustomTheme> userCustomThemes;
public CustomThemeListingRecyclerViewAdapter(AppCompatActivity activity, ArrayList<CustomTheme> predefinedCustomThemes) {
public CustomThemeListingRecyclerViewAdapter(BaseActivity activity, ArrayList<CustomTheme> predefinedCustomThemes) {
this.activity = activity;
this.predefinedCustomThemes = predefinedCustomThemes;
userCustomThemes = new ArrayList<>();
@ -134,6 +134,9 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
PredefinedCustomThemeViewHolder(@NonNull View itemView) {
super(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) {
super(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) {
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) {
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.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.switchmaterial.SwitchMaterial;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem;
import ml.docilealligator.infinityforreddit.customviews.ColorPickerDialog;
import ml.docilealligator.infinityforreddit.R;
public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_COLOR = 1;
private static final int VIEW_TYPE_SWITCH = 2;
private static final int VIEW_TYPE_THEME_NAME = 3;
private AppCompatActivity activity;
private BaseActivity activity;
private ArrayList<CustomThemeSettingsItem> customThemeSettingsItems;
private String themeName;
private boolean isPredefinedTheme;
public CustomizeThemeRecyclerViewAdapter(AppCompatActivity activity, String themeName,
public CustomizeThemeRecyclerViewAdapter(BaseActivity activity, String themeName,
boolean isPredefinedTheme) {
this.activity = activity;
customThemeSettingsItems = new ArrayList<>();
@ -148,6 +148,10 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
ThemeColorItemViewHolder(@NonNull View itemView) {
super(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)
TextView themeItemInfoTextView;
@BindView(R.id.theme_item_switch_item_custom_theme_switch_item)
Switch themeItemSwitch;
SwitchMaterial themeItemSwitch;
ThemeSwitchItemViewHolder(@NonNull View itemView) {
super(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) {
super(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.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Flair;
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> {
private Context context;
private BaseActivity activity;
private ArrayList<Flair> flairs;
private int flairTextColor;
private ItemClickListener itemClickListener;
public FlairBottomSheetRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper,
public FlairBottomSheetRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
ItemClickListener itemClickListener) {
this.context = context;
this.activity = activity;
flairTextColor = customThemeWrapper.getPrimaryTextColor();
this.itemClickListener = itemClickListener;
}
@ -47,14 +48,14 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
if (flairs.get(holder.getBindingAdapterPosition()).isEditable()) {
holder.editFlairImageView.setVisibility(View.VISIBLE);
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);
flairEditText.requestFocus();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
new MaterialAlertDialogBuilder(context, R.style.MaterialAlertDialogTheme)
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.edit_flair)
.setView(dialogView)
.setPositiveButton(R.string.ok, (dialogInterface, i)
@ -109,6 +110,10 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
ButterKnife.bind(this, itemView);
this.itemView = itemView;
flairTextView.setTextColor(flairTextColor);
if (activity.typeface != null) {
flairTextView.setTypeface(activity.typeface);
}
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.graphics.drawable.DrawableCompat;
@ -90,6 +89,7 @@ import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStra
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.StreamableVideo;
import ml.docilealligator.infinityforreddit.VoteThing;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
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_GALLERY = 7;
private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 8;
private AppCompatActivity mActivity;
private BaseActivity mActivity;
private ViewPostDetailFragment mFragment;
private Executor mExecutor;
private Retrofit mRetrofit;
@ -210,7 +210,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private boolean canStartActivity = true;
private boolean canPlayVideo = true;
public PostDetailRecyclerViewAdapter(AppCompatActivity activity, ViewPostDetailFragment fragment,
public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
Executor executor, CustomThemeWrapper customThemeWrapper,
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
Retrofit redgifsRetrofit, Retrofit streamableRetrofit,
@ -255,6 +255,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
if (mActivity.contentTypeface != null) {
textView.setTypeface(mActivity.typeface);
}
textView.setTextColor(markdownColor);
textView.setOnLongClickListener(view -> {
if (textView.getSelectionStart() == -1 && textView.getSelectionEnd() == -1) {
@ -841,14 +844,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailGalleryViewHolder) holder).mCaptionConstraintLayout.setVisibility(View.VISIBLE);
}
if (!previewCaptionIsEmpty) {
((PostDetailGalleryViewHolder) holder).mCaption.setTextColor(mCommentColor);
((PostDetailGalleryViewHolder) holder).mCaption.setText(previewCaption);
((PostDetailGalleryViewHolder) holder).mCaption.setSelected(true);
((PostDetailGalleryViewHolder) holder).mCaptionTextView.setTextColor(mCommentColor);
((PostDetailGalleryViewHolder) holder).mCaptionTextView.setText(previewCaption);
((PostDetailGalleryViewHolder) holder).mCaptionTextView.setSelected(true);
}
if (!previewCaptionUrlIsEmpty) {
String domain = Uri.parse(previewCaptionUrl).getHost();
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);
}
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);
mSubredditTextView.setTextColor(mSubredditColor);
mUserTextView.setTextColor(mUsernameColor);
@ -2114,6 +2134,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSaveButton,
mShareButton);
if (mActivity.typeface != null) {
mLinkTextView.setTypeface(mActivity.typeface);
}
mLinkTextView.setTextColor(mSecondaryTextColor);
mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
mLoadImageErrorTextView.setTextColor(mPrimaryTextColor);
@ -2206,6 +2229,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSaveButton,
mShareButton);
if (mActivity.typeface != null) {
mLinkTextView.setTypeface(mActivity.typeface);
}
mLinkTextView.setTextColor(mSecondaryTextColor);
mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
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)
ConstraintLayout mCaptionConstraintLayout;
@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)
TextView mCaptionUrl;
TextView mCaptionUrlTextView;
@BindView(R.id.image_view_no_preview_link_item_post_detail_gallery)
ImageView mNoPreviewPostTypeImageView;
@BindView(R.id.bottom_constraint_layout_item_post_detail_gallery)
@ -2357,6 +2383,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSaveButton,
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.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor));
mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));

View File

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

View File

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

View File

@ -24,7 +24,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.Barrier;
import androidx.constraintlayout.widget.ConstraintLayout;
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 SharedPreferences mSharedPreferences;
private Executor mExecutor;
@ -212,7 +211,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private Callback mCallback;
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,
CustomThemeWrapper customThemeWrapper, Locale locale,
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));
}
if (((BaseActivity) mActivity).typeface != null) {
subredditTextView.setTypeface(((BaseActivity) mActivity).typeface);
userTextView.setTypeface(((BaseActivity) mActivity).typeface);
postTimeTextView.setTypeface(((BaseActivity) mActivity).typeface);
typeTextView.setTypeface(((BaseActivity) mActivity).typeface);
spoilerTextView.setTypeface(((BaseActivity) mActivity).typeface);
nsfwTextView.setTypeface(((BaseActivity) mActivity).typeface);
flairTextView.setTypeface(((BaseActivity) mActivity).typeface);
awardsTextView.setTypeface(((BaseActivity) mActivity).typeface);
scoreTextView.setTypeface(((BaseActivity) mActivity).typeface);
commentsCountTextView.setTypeface(((BaseActivity) mActivity).typeface);
if (mActivity.typeface != null) {
subredditTextView.setTypeface(mActivity.typeface);
userTextView.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);
scoreTextView.setTypeface(mActivity.typeface);
commentsCountTextView.setTypeface(mActivity.typeface);
}
if (((BaseActivity) mActivity).titleTypeface != null) {
titleTextView.setTypeface(((BaseActivity) mActivity).titleTypeface);
}
if (((BaseActivity) mActivity).contentTypeface != null) {
if (mActivity.titleTypeface != null) {
titleTextView.setTypeface(mActivity.titleTypeface);
}
subredditTextView.setTextColor(mSubredditColor);
@ -2933,6 +2929,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
saveButton,
shareButton);
if (mActivity.typeface != null) {
linkTextView.setTypeface(mActivity.typeface);
errorTextView.setTypeface(mActivity.typeface);
}
linkTextView.setTextColor(mSecondaryTextColor);
noPreviewLinkImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
noPreviewLinkImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
@ -3053,6 +3053,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
saveButton,
shareButton);
if (mActivity.contentTypeface != null) {
contentTextView.setTypeface(mActivity.titleTypeface);
}
contentTextView.setTextColor(mPostContentColor);
}
}
@ -3169,6 +3172,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((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);
postTimeTextView.setTextColor(mSecondaryTextColor);
titleTextView.setTextColor(mPostTitleColor);
@ -3790,6 +3809,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
super(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));
titleTextView.setTextColor(mPostTitleColor);
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
@ -4221,6 +4246,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
shareButton,
true);
if (mActivity.typeface != null) {
linkTextView.setTypeface(mActivity.typeface);
errorTextView.setTypeface(mActivity.typeface);
}
linkTextView.setTextColor(mSecondaryTextColor);
noPreviewImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
@ -4345,6 +4374,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
shareButton,
true);
if (mActivity.contentTypeface != null) {
contentTextView.setTypeface(mActivity.contentTypeface);
}
contentTextView.setTextColor(mPostContentColor);
divider.setBackgroundColor(mDividerColor);
}

View File

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

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -19,13 +18,16 @@ import java.util.ArrayList;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RPANComment;
import ml.docilealligator.infinityforreddit.activities.RPANActivity;
public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private RPANActivity activity;
private RequestManager glide;
private ArrayList<RPANComment> rpanComments;
public RPANCommentStreamRecyclerViewAdapter(Context context) {
glide = Glide.with(context);
public RPANCommentStreamRecyclerViewAdapter(RPANActivity activity) {
this.activity = activity;
glide = Glide.with(activity);
rpanComments = new ArrayList<>();
}
@ -70,7 +72,6 @@ public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<R
class RPANCommentViewHolder extends RecyclerView.ViewHolder {
ImageView iconImageView;
TextView authorTextView;
TextView timeTextView;
TextView contentTextView;
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);
authorTextView = itemView.findViewById(R.id.author_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.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R;
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> {
private BaseActivity activity;
private ArrayList<ReportReason> generalReasons;
private ArrayList<ReportReason> rules;
private int primaryTextColor;
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;
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
colorAccent = customThemeWrapper.getColorAccent();
@ -101,6 +104,10 @@ public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
reasonTextView.setTextColor(primaryTextColor);
checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
if (activity.typeface != null) {
reasonTextView.setTypeface(activity.typeface);
}
checkBox.setOnClickListener(view -> {
for (int i = 0; i < generalReasons.size(); i++) {
if (generalReasons.get(i).isSelected()) {

View File

@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.adapters;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Spanned;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
@ -10,7 +11,6 @@ import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
@ -33,6 +33,7 @@ import io.noties.markwon.movement.MovementMethodPlugin;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Rule;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@ -40,12 +41,14 @@ import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private BaseActivity activity;
private Markwon markwon;
private ArrayList<Rule> rules;
private int mPrimaryTextColor;
private int mSecondaryTextColor;
public RulesRecyclerViewAdapter(AppCompatActivity activity, CustomThemeWrapper customThemeWrapper) {
public RulesRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper) {
this.activity = activity;
markwon = Markwon.builder(activity)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(AutolinkInlineProcessor.class);
@ -63,6 +66,15 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
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
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
@ -138,6 +150,11 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
ButterKnife.bind(this, itemView);
shortNameTextView.setTextColor(mPrimaryTextColor);
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;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
@ -15,12 +14,14 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
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.utils.Utils;
public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private List<RecentSearchQuery> recentSearchQueries;
private int primaryTextColor;
private Drawable historyIcon;
@ -32,8 +33,9 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
void onDelete(RecentSearchQuery recentSearchQuery);
}
public SearchActivityRecyclerViewAdapter(Activity activity, CustomThemeWrapper customThemeWrapper,
public SearchActivityRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
ItemOnClickListener itemOnClickListener) {
this.activity = activity;
this.primaryTextColor = customThemeWrapper.getPrimaryTextColor();
this.historyIcon = Utils.getTintedDrawable(activity, R.drawable.ic_history_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);
deleteImageView.setImageDrawable(deleteIcon);
if (activity.typeface != null) {
recentSearchQueryTextView.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> {
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()).getSearchQuery());

View File

@ -13,14 +13,17 @@ import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
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> {
private BaseActivity activity;
private CustomThemeWrapper customThemeWrapper;
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;
if (subreddits == null) {
this.subreddits = new ArrayList<>();
@ -79,6 +82,10 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<
subredditNameTextView.setTextColor(customThemeWrapper.getPrimaryIconColor());
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;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -19,19 +18,22 @@ import java.util.List;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
import pl.droidsonroids.gif.GifImageView;
public class SubredditAutocompleteRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private List<SubredditData> subreddits;
private RequestManager glide;
private CustomThemeWrapper customThemeWrapper;
private ItemOnClickListener itemOnClickListener;
public SubredditAutocompleteRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper,
public SubredditAutocompleteRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
ItemOnClickListener itemOnClickListener) {
glide = Glide.with(context);
this.activity = activity;
glide = Glide.with(activity);
this.customThemeWrapper = customThemeWrapper;
this.itemOnClickListener = itemOnClickListener;
}
@ -91,6 +93,10 @@ public class SubredditAutocompleteRecyclerViewAdapter extends RecyclerView.Adapt
subredditNameTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
if (activity.typeface != null) {
subredditNameTextView.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> {
itemOnClickListener.onClick(subreddits.get(getBindingAdapterPosition()));
});

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.res.ColorStateList;
import android.os.Handler;
import android.view.LayoutInflater;
@ -32,6 +31,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsSubscribedToSubreddit;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
@ -55,7 +55,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
}
};
private RequestManager glide;
private Context context;
private BaseActivity activity;
private Executor executor;
private Retrofit oauthRetrofit;
private Retrofit retrofit;
@ -73,13 +73,13 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
private NetworkState networkState;
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,
String accessToken, String accountName,
RedditDataRoomDatabase redditDataRoomDatabase,
boolean isMultiSelection, Callback callback) {
super(DIFF_CALLBACK);
this.context = context;
this.activity = activity;
this.executor = executor;
this.oauthRetrofit = oauthRetrofit;
this.retrofit = retrofit;
@ -88,7 +88,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.isMultiSelection = isMultiSelection;
this.callback = callback;
glide = Glide.with(context);
glide = Glide.with(this.activity);
colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
@ -163,12 +163,12 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
@Override
public void onSubredditSubscriptionSuccess() {
((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
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 {
@ -178,12 +178,12 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
@Override
public void onSubredditSubscriptionSuccess() {
((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
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) {
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);
retryButton.setBackgroundTintList(ColorStateList.valueOf(colorPrimaryLightTheme));
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;
import android.content.Context;
import android.content.res.ColorStateList;
import android.view.LayoutInflater;
import android.view.View;
@ -21,21 +20,24 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
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.subscribedsubreddit.SubscribedSubredditData;
import pl.droidsonroids.gif.GifImageView;
public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private ArrayList<SubredditWithSelection> subscribedSubreddits;
private RequestManager glide;
private int primaryTextColor;
private int colorAccent;
public SubredditMultiselectionRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper) {
glide = Glide.with(context);
public SubredditMultiselectionRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper) {
this.activity = activity;
glide = Glide.with(activity);
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
colorAccent = customThemeWrapper.getColorAccent();
}
@ -118,6 +120,10 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
ButterKnife.bind(this, itemView);
nameTextView.setTextColor(primaryTextColor);
checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
if (activity.typeface != null) {
nameTextView.setTypeface(activity.typeface);
}
}
}
}

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.adapters;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -12,12 +13,17 @@ import java.util.ArrayList;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.UploadedImage;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
public class UploadedImagesRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private ArrayList<UploadedImage> uploadedImages;
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.itemClickListener = itemClickListener;
}
@ -49,6 +55,11 @@ public class UploadedImagesRecyclerViewAdapter extends RecyclerView.Adapter<Recy
imageNameTextView = itemView.findViewById(R.id.image_name_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 -> {
itemClickListener.onClick(uploadedImages.get(getBindingAdapterPosition()));
});

View File

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

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.adapters;
import android.content.Context;
import android.content.res.ColorStateList;
import android.os.Handler;
import android.view.LayoutInflater;
@ -32,6 +31,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUser;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.user.UserData;
@ -55,7 +55,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
}
};
private RequestManager glide;
private Context context;
private BaseActivity activity;
private Executor executor;
private Retrofit oauthRetrofit;
private Retrofit retrofit;
@ -73,12 +73,12 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
private NetworkState networkState;
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,
String accountName, RedditDataRoomDatabase redditDataRoomDatabase,
boolean isMultiSelection, Callback callback) {
super(DIFF_CALLBACK);
this.context = context;
this.activity = activity;
this.executor = executor;
this.oauthRetrofit = oauthRetrofit;
this.retrofit = retrofit;
@ -87,7 +87,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.isMultiSelection = isMultiSelection;
this.callback = callback;
glide = Glide.with(context);
glide = Glide.with(activity);
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
buttonTextColor = customThemeWrapper.getButtonTextColor();
colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
@ -155,12 +155,12 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
@Override
public void onUserFollowingSuccess() {
((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
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);
userNameTextView.setTextColor(primaryTextColor);
subscribeButton.setColorFilter(unsubscribedColor, android.graphics.PorterDuff.Mode.SRC_IN);
if (activity.typeface != null) {
userNameTextView.setTypeface(activity.typeface);
}
if (isMultiSelection) {
checkBox.setVisibility(View.VISIBLE);
}
@ -266,6 +271,11 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
errorTextView.setTextColor(primaryTextColor);
retryButton.setTextColor(buttonTextColor);
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 androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.EditCommentActivity;
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.comment.Comment;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
/**
@ -64,7 +65,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
TextView reportTextView;
@BindView(R.id.see_removed_view_comment_more_bottom_sheet_fragment)
TextView seeRemovedTextView;
private AppCompatActivity activity;
private BaseActivity activity;
public CommentMoreBottomSheetFragment() {
// Required empty public constructor
@ -224,12 +225,16 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
});
}
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
return rootView;
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
activity = (AppCompatActivity) context;
activity = (BaseActivity) context;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -30,9 +29,11 @@ import ml.docilealligator.infinityforreddit.FetchFlairs;
import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.adapters.FlairBottomSheetRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.FlairSelectedEvent;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
@ -60,7 +61,7 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
CustomThemeWrapper mCustomThemeWrapper;
private String mAccessToken;
private String mSubredditName;
private Activity mActivity;
private BaseActivity mActivity;
private FlairBottomSheetRecyclerViewAdapter mAdapter;
public FlairBottomSheetFragment() {
@ -76,6 +77,10 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
((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);
mAdapter = new FlairBottomSheetRecyclerViewAdapter(mActivity, mCustomThemeWrapper, flair -> {
if (viewPostFragmentId <= 0) {
@ -133,7 +138,7 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
mActivity = (Activity) context;
mActivity = (BaseActivity) context;
}
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.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
import ml.docilealligator.infinityforreddit.utils.Utils;
/**
* A simple {@link Fragment} subclass.
@ -79,6 +80,10 @@ public class MultiRedditOptionsBottomSheetFragment extends LandscapeExpandedRoun
dismiss();
});
if (subscribedThingListingActivity.typeface != null) {
Utils.setFontToAllTextViews(rootView, subscribedThingListingActivity.typeface);
}
return rootView;
}

View File

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

View File

@ -14,10 +14,13 @@ import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.ButterKnife;
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.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewImgurVideoFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class PlaybackSpeedBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@ -119,6 +122,20 @@ public class PlaybackSpeedBottomSheetFragment extends LandscapeExpandedRoundedBo
setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_200);
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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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