diff options
Diffstat (limited to '')
11 files changed, 95 insertions, 149 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java index 1e27c968..93d13128 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java @@ -4,7 +4,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; -import android.widget.RelativeLayout; import android.widget.Toast; import java.util.concurrent.Executor; @@ -12,12 +11,12 @@ import java.util.concurrent.Executor; 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.bottomsheetfragments.RandomBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.databinding.ActivityFetchRandomSubredditOrPostBinding; import ml.docilealligator.infinityforreddit.post.FetchPost; import retrofit2.Retrofit; @@ -25,8 +24,6 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity { public static final String EXTRA_RANDOM_OPTION = "ERO"; - @BindView(R.id.relative_layout_fetch_random_subreddit_or_post_activity) - RelativeLayout relativeLayout; @Inject @Named("no_oauth") Retrofit mRetrofit; @@ -41,12 +38,14 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity { @Inject Executor mExecutor; private boolean isCanceled = false; + private ActivityFetchRandomSubredditOrPostBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplicationContext()).getAppComponent().inject(this); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_fetch_random_subreddit_or_post); + binding = ActivityFetchRandomSubredditOrPostBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); ButterKnife.bind(this); @@ -109,6 +108,6 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity { @Override protected void applyCustomTheme() { - relativeLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); } }
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java index c55962c7..a2999c75 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java @@ -48,6 +48,7 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomS import ml.docilealligator.infinityforreddit.bottomsheetfragments.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivityFilteredThingBinding; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.PostFragment; import ml.docilealligator.infinityforreddit.post.Post; @@ -74,16 +75,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec private static final String FRAGMENT_OUT_STATE = "FOS"; private static final int CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE = 1000; - @BindView(R.id.coordinator_layout_filtered_thing_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_filtered_posts_activity) - AppBarLayout appBarLayout; - @BindView(R.id.collapsing_toolbar_layout_filtered_posts_activity) - CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.toolbar_filtered_posts_activity) - Toolbar toolbar; - @BindView(R.id.fab_filtered_thing_activity) - FloatingActionButton fab; @Inject RedditDataRoomDatabase mRedditDataRoomDatabase; @Inject @@ -109,6 +100,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec private PostFragment mFragment; private Menu mMenu; private boolean isNsfwSubreddit = false; + private ActivityFilteredThingBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -116,7 +108,8 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec super.onCreate(savedInstanceState); - setContentView(R.layout.activity_filtered_thing); + binding = ActivityFilteredThingBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); ButterKnife.bind(this); @@ -132,7 +125,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutFilteredPostsActivity); } if (isImmersiveInterface()) { @@ -141,20 +134,20 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); + adjustToolbar(binding.toolbarFilteredPostsActivity); int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { - CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) binding.fabFilteredThingActivity.getLayoutParams(); params.bottomMargin += navBarHeight; - fab.setLayoutParams(params); + binding.fabFilteredThingActivity.setLayoutParams(params); } } } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarFilteredPostsActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.toolbarFilteredPostsActivity); name = getIntent().getStringExtra(EXTRA_NAME); postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE); @@ -266,9 +259,10 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyFABTheme(fab); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutFilteredPostsActivity, + binding.collapsingToolbarLayoutFilteredPostsActivity, binding.toolbarFilteredPostsActivity); + applyFABTheme(binding.fabFilteredThingActivity); } private void bindView(PostFilter postFilter, boolean initializeFragment) { @@ -334,7 +328,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit(); } - fab.setOnClickListener(view -> { + binding.fabFilteredThingActivity.setOnClickListener(view -> { Intent intent = new Intent(this, CustomizePostFilterActivity.class); if (mFragment != null) { intent.putExtra(CustomizePostFilterActivity.EXTRA_POST_FILTER, mFragment.getPostFilter()); @@ -343,7 +337,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec }); if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) { - fab.setOnLongClickListener(view -> { + binding.fabFilteredThingActivity.setOnLongClickListener(view -> { FilteredThingFABMoreOptionsBottomSheetFragment filteredThingFABMoreOptionsBottomSheetFragment = new FilteredThingFABMoreOptionsBottomSheetFragment(); filteredThingFABMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), filteredThingFABMoreOptionsBottomSheetFragment.getTag()); @@ -494,12 +488,12 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec @Override public void contentScrollUp() { - fab.show(); + binding.fabFilteredThingActivity.show(); } @Override public void contentScrollDown() { - fab.hide(); + binding.fabFilteredThingActivity.hide(); } public boolean isNsfwSubreddit() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java index 66133e1d..84fed183 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java @@ -14,12 +14,6 @@ import android.view.WindowManager; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.appcompat.widget.Toolbar; -import androidx.coordinatorlayout.widget.CoordinatorLayout; -import androidx.recyclerview.widget.RecyclerView; - -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.appbar.CollapsingToolbarLayout; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -27,7 +21,6 @@ import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; import butterknife.ButterKnife; import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; @@ -41,6 +34,7 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivityCommentFullMarkdownBinding; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.markdown.CustomMarkwonAdapter; import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils; @@ -52,16 +46,6 @@ public class FullMarkdownActivity extends BaseActivity { public static final String EXTRA_IS_NSFW = "EIN"; public static final String EXTRA_SUBMIT_POST = "ESP"; - @BindView(R.id.coordinator_layout_comment_full_markdown_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_comment_full_markdown_activity) - AppBarLayout appBarLayout; - @BindView(R.id.collapsing_toolbar_layout_comment_full_markdown_activity) - CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.toolbar_comment_full_markdown_activity) - Toolbar toolbar; - @BindView(R.id.content_markdown_view_comment_full_markdown_activity) - RecyclerView markdownRecyclerView; @Inject @Named("default") SharedPreferences mSharedPreferences; @@ -70,13 +54,15 @@ public class FullMarkdownActivity extends BaseActivity { SharedPreferences mCurrentAccountSharedPreferences; @Inject CustomThemeWrapper mCustomThemeWrapper; + private ActivityCommentFullMarkdownBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_comment_full_markdown); + binding = ActivityCommentFullMarkdownBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); ButterKnife.bind(this); @@ -84,7 +70,7 @@ public class FullMarkdownActivity extends BaseActivity { applyCustomTheme(); - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarCommentFullMarkdownActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setTitle(" "); @@ -97,7 +83,7 @@ public class FullMarkdownActivity extends BaseActivity { Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutCommentFullMarkdownActivity); } if (isImmersiveInterface()) { @@ -106,8 +92,8 @@ public class FullMarkdownActivity extends BaseActivity { } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); - markdownRecyclerView.setPadding(markdownRecyclerView.getPaddingLeft(), 0, markdownRecyclerView.getPaddingRight(), getNavBarHeight()); + adjustToolbar(binding.toolbarCommentFullMarkdownActivity); + binding.contentRecyclerViewCommentFullMarkdownActivity.setPadding(binding.contentRecyclerViewCommentFullMarkdownActivity.getPaddingLeft(), 0, binding.contentRecyclerViewCommentFullMarkdownActivity.getPaddingRight(), getNavBarHeight()); } } @@ -158,8 +144,8 @@ public class FullMarkdownActivity extends BaseActivity { } } }); - markdownRecyclerView.setLayoutManager(linearLayoutManager); - markdownRecyclerView.setAdapter(markwonAdapter); + binding.contentRecyclerViewCommentFullMarkdownActivity.setLayoutManager(linearLayoutManager); + binding.contentRecyclerViewCommentFullMarkdownActivity.setAdapter(markwonAdapter); markwonAdapter.setMarkdown(markwon, markdown); // noinspection NotifyDataSetChanged markwonAdapter.notifyDataSetChanged(); @@ -206,8 +192,8 @@ public class FullMarkdownActivity extends BaseActivity { @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutCommentFullMarkdownActivity, binding.collapsingToolbarLayoutCommentFullMarkdownActivity, binding.toolbarCommentFullMarkdownActivity); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java index 0190b9f5..55f2eadc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java @@ -12,25 +12,18 @@ import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; -import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.widget.ViewPager2; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.appbar.CollapsingToolbarLayout; -import com.google.android.material.tabs.TabLayout; - import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.Infinity; @@ -38,6 +31,7 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivityHistoryBinding; import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.CommentsListingFragment; @@ -48,18 +42,6 @@ import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class HistoryActivity extends BaseActivity implements ActivityToolbarInterface, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback { - @BindView(R.id.coordinator_layout_history_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_history_activity) - AppBarLayout appBarLayout; - @BindView(R.id.collapsing_toolbar_layout_history_activity) - CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.toolbar_history_activity) - Toolbar toolbar; - @BindView(R.id.tab_layout_tab_layout_history_activity_activity) - TabLayout tabLayout; - @BindView(R.id.view_pager_history_activity) - ViewPager2 viewPager2; @Inject @Named("default") SharedPreferences mSharedPreferences; @@ -73,6 +55,7 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte CustomThemeWrapper mCustomThemeWrapper; private FragmentManager fragmentManager; private SectionsPagerAdapter sectionsPagerAdapter; + private ActivityHistoryBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -80,7 +63,8 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte super.onCreate(savedInstanceState); - setContentView(R.layout.activity_history); + binding = ActivityHistoryBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); ButterKnife.bind(this); @@ -98,7 +82,7 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutHistoryActivity); } if (isImmersiveInterface()) { @@ -107,13 +91,13 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); + adjustToolbar(binding.toolbarHistoryActivity); } } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarHistoryActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.toolbarHistoryActivity); fragmentManager = getSupportFragmentManager(); @@ -146,18 +130,19 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyTabLayoutTheme(tabLayout); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutHistoryActivity, + binding.collapsingToolbarLayoutHistoryActivity, binding.toolbarHistoryActivity); + applyTabLayoutTheme(binding.tabLayoutTabLayoutHistoryActivityActivity); } private void initializeViewPager() { sectionsPagerAdapter = new SectionsPagerAdapter(this); - tabLayout.setVisibility(View.GONE); - viewPager2.setAdapter(sectionsPagerAdapter); - viewPager2.setOffscreenPageLimit(2); + binding.tabLayoutTabLayoutHistoryActivityActivity.setVisibility(View.GONE); + binding.viewPagerHistoryActivity.setAdapter(sectionsPagerAdapter); + binding.viewPagerHistoryActivity.setOffscreenPageLimit(2); //viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false)); - viewPager2.setUserInputEnabled(false); + binding.viewPagerHistoryActivity.setUserInputEnabled(false); /*new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> { switch (position) { case 0: @@ -166,7 +151,7 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte } }).attach();*/ - viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { + binding.viewPagerHistoryActivity.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { @Override public void onPageSelected(int position) { if (position == 0) { @@ -177,7 +162,7 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte } }); - fixViewPager2Sensitivity(viewPager2); + fixViewPager2Sensitivity(binding.viewPagerHistoryActivity); } @Override @@ -275,14 +260,14 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte @Nullable private Fragment getCurrentFragment() { - if (viewPager2 == null || fragmentManager == null) { + if (fragmentManager == null) { return null; } - return fragmentManager.findFragmentByTag("f" + viewPager2.getCurrentItem()); + return fragmentManager.findFragmentByTag("f" + binding.viewPagerHistoryActivity.getCurrentItem()); } public boolean handleKeyDown(int keyCode) { - if (viewPager2.getCurrentItem() == 0) { + if (binding.viewPagerHistoryActivity.getCurrentItem() == 0) { Fragment fragment = getCurrentFragment(); if (fragment instanceof PostFragment) { return ((PostFragment) fragment).handleKeyDown(keyCode); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java index 8461698f..ffc74caa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java @@ -51,6 +51,7 @@ import ml.docilealligator.infinityforreddit.apis.RedditAPI; import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivityInboxBinding; import ml.docilealligator.infinityforreddit.events.ChangeInboxCountEvent; import ml.docilealligator.infinityforreddit.events.PassPrivateMessageEvent; import ml.docilealligator.infinityforreddit.events.PassPrivateMessageIndexEvent; @@ -74,20 +75,6 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf private static final String NEW_ACCOUNT_NAME_STATE = "NANS"; private static final int SEARCH_USER_REQUEST_CODE = 1; - @BindView(R.id.coordinator_layout_inbox_activity) - CoordinatorLayout mCoordinatorLayout; - @BindView(R.id.appbar_layout_inbox_activity) - AppBarLayout mAppBarLayout; - @BindView(R.id.collapsing_toolbar_layout_inbox_activity) - CollapsingToolbarLayout mCollapsingToolbarLayout; - @BindView(R.id.toolbar_inbox_activity) - Toolbar mToolbar; - @BindView(R.id.tab_layout_inbox_activity) - TabLayout tabLayout; - @BindView(R.id.view_pager_inbox_activity) - ViewPager2 viewPager2; - @BindView(R.id.fab_inbox_activity) - FloatingActionButton fab; @Inject @Named("oauth") Retrofit mOauthRetrofit; @@ -106,6 +93,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf private SectionsPagerAdapter sectionsPagerAdapter; private FragmentManager fragmentManager; private String mNewAccountName; + private ActivityInboxBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -113,7 +101,8 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf super.onCreate(savedInstanceState); - setContentView(R.layout.activity_inbox); + binding = ActivityInboxBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); ButterKnife.bind(this); @@ -129,7 +118,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(mAppBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutInboxActivity); } if (isImmersiveInterface()) { @@ -138,20 +127,20 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(mToolbar); + adjustToolbar(binding.toolbarInboxActivity); int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { - CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) binding.fabInboxActivity.getLayoutParams(); params.bottomMargin += navBarHeight; - fab.setLayoutParams(params); + binding.fabInboxActivity.setLayoutParams(params); } } } - mToolbar.setTitle(R.string.inbox); - setSupportActionBar(mToolbar); - setToolbarGoToTop(mToolbar); + binding.toolbarInboxActivity.setTitle(R.string.inbox); + setSupportActionBar(binding.toolbarInboxActivity); + setToolbarGoToTop(binding.toolbarInboxActivity); fragmentManager = getSupportFragmentManager(); @@ -162,15 +151,15 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf } getCurrentAccountAndFetchMessage(savedInstanceState); - viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { + binding.viewPagerInboxActivity.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { @Override public void onPageSelected(int position) { - fab.show(); + binding.fabInboxActivity.show(); } }); - fab.setOnClickListener(view -> { - View rootView = getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, mCoordinatorLayout, false); + binding.fabInboxActivity.setOnClickListener(view -> { + View rootView = getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, binding.getRoot(), false); TextInputEditText thingEditText = rootView.findViewById(R.id.text_input_edit_text_go_to_thing_edit_text); thingEditText.requestFocus(); Utils.showKeyboard(this, new Handler(), thingEditText); @@ -225,9 +214,10 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf @Override protected void applyCustomTheme() { - mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar); - applyTabLayoutTheme(tabLayout); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutInboxActivity, + binding.collapsingToolbarLayoutInboxActivity, binding.toolbarInboxActivity); + applyTabLayoutTheme(binding.tabLayoutInboxActivity); applyFABTheme(fab); } @@ -256,7 +246,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf private void bindView(Bundle savedInstanceState) { sectionsPagerAdapter = new SectionsPagerAdapter(this); - viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { + binding.viewPagerInboxActivity.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { @Override public void onPageSelected(int position) { if (position == 0) { @@ -266,9 +256,9 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf } } }); - viewPager2.setAdapter(sectionsPagerAdapter); - viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT); - new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> { + binding.viewPagerInboxActivity.setAdapter(sectionsPagerAdapter); + binding.viewPagerInboxActivity.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT); + new TabLayoutMediator(binding.tabLayoutInboxActivity, binding.viewPagerInboxActivity, (tab, position) -> { switch (position) { case 0: Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.notifications)); @@ -279,10 +269,10 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf } }).attach(); if (savedInstanceState == null && getIntent().getBooleanExtra(EXTRA_VIEW_MESSAGE, false)) { - viewPager2.setCurrentItem(1, false); + binding.viewPagerInboxActivity.setCurrentItem(1, false); } - fixViewPager2Sensitivity(viewPager2); + fixViewPager2Sensitivity(binding.viewPagerInboxActivity); } @Override @@ -394,12 +384,12 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf @Override public void contentScrollUp() { - fab.show(); + binding.fabInboxActivity.show(); } @Override public void contentScrollDown() { - fab.hide(); + binding.fabInboxActivity.hide(); } private class SectionsPagerAdapter extends FragmentStateAdapter { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java index 8d0129c7..fe4f175d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java @@ -5,32 +5,25 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI import android.content.SharedPreferences; import android.os.Bundle; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.biometric.BiometricManager; import androidx.biometric.BiometricPrompt; import androidx.core.content.ContextCompat; -import com.google.android.material.button.MaterialButton; - import java.util.concurrent.Executor; 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.databinding.ActivityLockScreenBinding; public class LockScreenActivity extends BaseActivity { - @BindView(R.id.text_view_lock_screen_activity) - TextView textView; - @BindView(R.id.unlock_button_lock_screen_activity) - MaterialButton unlockButton; @Inject @Named("default") SharedPreferences mSharedPreferences; @@ -39,6 +32,7 @@ public class LockScreenActivity extends BaseActivity { SharedPreferences mCurrentAccountSharedPreferences; @Inject CustomThemeWrapper mCustomThemeWrapper; + private ActivityLockScreenBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -47,13 +41,15 @@ public class LockScreenActivity extends BaseActivity { setImmersiveModeNotApplicable(); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_lock_screen); + + binding = ActivityLockScreenBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); ButterKnife.bind(this); applyCustomTheme(); - unlockButton.setOnClickListener(view -> { + binding.unlockButtonLockScreenActivity.setOnClickListener(view -> { authenticate(); }); @@ -103,12 +99,12 @@ public class LockScreenActivity extends BaseActivity { @Override protected void applyCustomTheme() { - textView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); - unlockButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); - unlockButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme()); + binding.textViewLockScreenActivity.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); + binding.unlockButtonLockScreenActivity.setTextColor(mCustomThemeWrapper.getButtonTextColor()); + binding.unlockButtonLockScreenActivity.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme()); if (typeface != null) { - textView.setTypeface(typeface); - unlockButton.setTypeface(typeface); + binding.textViewLockScreenActivity.setTypeface(typeface); + binding.unlockButtonLockScreenActivity.setTypeface(typeface); } } diff --git a/app/src/main/res/layout/activity_comment_full_markdown.xml b/app/src/main/res/layout/activity_comment_full_markdown.xml index df690767..1e463e81 100644 --- a/app/src/main/res/layout/activity_comment_full_markdown.xml +++ b/app/src/main/res/layout/activity_comment_full_markdown.xml @@ -34,7 +34,7 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.recyclerview.widget.RecyclerView - android:id="@+id/content_markdown_view_comment_full_markdown_activity" + android:id="@+id/content_recycler_view_comment_full_markdown_activity" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="16dp" diff --git a/app/src/main/res/layout/activity_fetch_random_subreddit_or_post.xml b/app/src/main/res/layout/activity_fetch_random_subreddit_or_post.xml index a08f1f35..bacfdc81 100644 --- a/app/src/main/res/layout/activity_fetch_random_subreddit_or_post.xml +++ b/app/src/main/res/layout/activity_fetch_random_subreddit_or_post.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/relative_layout_fetch_random_subreddit_or_post_activity" tools:context=".activities.FetchRandomSubredditOrPostActivity"> <com.airbnb.lottie.LottieAnimationView diff --git a/app/src/main/res/layout/activity_filtered_thing.xml b/app/src/main/res/layout/activity_filtered_thing.xml index bc2160ff..2632342e 100644 --- a/app/src/main/res/layout/activity_filtered_thing.xml +++ b/app/src/main/res/layout/activity_filtered_thing.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/coordinator_layout_filtered_thing_activity" tools:application=".FilteredPostsActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_history.xml b/app/src/main/res/layout/activity_history.xml index c03e976f..12504405 100644 --- a/app/src/main/res/layout/activity_history.xml +++ b/app/src/main/res/layout/activity_history.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/coordinator_layout_history_activity" tools:context=".activities.HistoryActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_inbox.xml b/app/src/main/res/layout/activity_inbox.xml index 256fee87..88c95af6 100644 --- a/app/src/main/res/layout/activity_inbox.xml +++ b/app/src/main/res/layout/activity_inbox.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/coordinator_layout_inbox_activity" tools:context=".activities.InboxActivity"> <com.google.android.material.appbar.AppBarLayout |