diff options
Diffstat (limited to 'app/src/main')
6 files changed, 116 insertions, 171 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java index 1bf8f036..68d59855 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java @@ -6,17 +6,12 @@ import android.os.Bundle; import android.view.KeyEvent; import android.view.Menu; 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 androidx.fragment.app.Fragment; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.appbar.CollapsingToolbarLayout; import com.r0adkll.slidr.Slidr; import org.greenrobot.eventbus.EventBus; @@ -25,8 +20,6 @@ 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.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; @@ -35,6 +28,7 @@ import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.databinding.ActivityAccountPostsBinding; import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.PostFragment; @@ -48,14 +42,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect private static final String FRAGMENT_OUT_STATE = "FOS"; - @BindView(R.id.coordinator_layout_account_posts_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_account_posts_activity) - AppBarLayout appBarLayout; - @BindView(R.id.collapsing_toolbar_layout_account_posts_activity) - CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.toolbar_account_posts_activity) - Toolbar toolbar; @Inject @Named("default") SharedPreferences mSharedPreferences; @@ -72,6 +58,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect private String mUserWhere; private Fragment mFragment; private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment; + private ActivityAccountPostsBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -79,9 +66,8 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect super.onCreate(savedInstanceState); - setContentView(R.layout.activity_account_posts); - - ButterKnife.bind(this); + binding = ActivityAccountPostsBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); EventBus.getDefault().register(this); @@ -95,7 +81,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.accountPostsAppbarLayout); } if (isImmersiveInterface()) { @@ -104,24 +90,24 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); + adjustToolbar(binding.accountPostsToolbar); } } mUserWhere = getIntent().getExtras().getString(EXTRA_USER_WHERE); if (mUserWhere.equals(PostPagingSource.USER_WHERE_UPVOTED)) { - toolbar.setTitle(R.string.upvoted); + binding.accountPostsToolbar.setTitle(R.string.upvoted); } else if (mUserWhere.equals(PostPagingSource.USER_WHERE_DOWNVOTED)) { - toolbar.setTitle(R.string.downvoted); + binding.accountPostsToolbar.setTitle(R.string.downvoted); } else if (mUserWhere.equals(PostPagingSource.USER_WHERE_HIDDEN)) { - toolbar.setTitle(R.string.hidden); + binding.accountPostsToolbar.setTitle(R.string.hidden); } else if (mUserWhere.equals(PostPagingSource.USER_WHERE_GILDED)) { - toolbar.setTitle(R.string.gilded); + binding.accountPostsToolbar.setTitle(R.string.gilded); } - setSupportActionBar(toolbar); + setSupportActionBar(binding.accountPostsToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.accountPostsToolbar); postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment(); @@ -130,7 +116,9 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect if (savedInstanceState != null) { mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit(); + getSupportFragmentManager().beginTransaction() + .replace(binding.accountPostsFrameLayout.getId(), mFragment) + .commit(); } else { initializeFragment(); } @@ -157,8 +145,10 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); + binding.accountPostsCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme( + binding.accountPostsAppbarLayout, binding.accountPostsCollapsingToolbarLayout, + binding.accountPostsToolbar); } private void initializeFragment() { @@ -171,7 +161,9 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true); mFragment.setArguments(bundle); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit(); + getSupportFragmentManager().beginTransaction() + .replace(binding.accountPostsFrameLayout.getId(), mFragment) + .commit(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java index 8230620c..c4a3d0fc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java @@ -11,17 +11,12 @@ 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 com.google.android.material.tabs.TabLayoutMediator; import com.r0adkll.slidr.Slidr; import com.r0adkll.slidr.model.SlidrInterface; @@ -34,8 +29,6 @@ import java.util.concurrent.Executor; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface; @@ -43,6 +36,7 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.databinding.ActivityAccountSavedThingBinding; import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.CommentsListingFragment; @@ -57,18 +51,6 @@ import retrofit2.Retrofit; public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, MarkPostAsReadInterface { - @BindView(R.id.coordinator_layout_account_saved_thing_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_account_saved_thing_activity) - AppBarLayout appBarLayout; - @BindView(R.id.collapsing_toolbar_layout_account_saved_thing_activity) - CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.toolbar_account_saved_thing_activity) - Toolbar toolbar; - @BindView(R.id.tab_layout_tab_layout_account_saved_thing_activity_activity) - TabLayout tabLayout; - @BindView(R.id.view_pager_account_saved_thing_activity) - ViewPager2 viewPager2; @Inject @Named("oauth") Retrofit mOauthRetrofit; @@ -93,16 +75,15 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT private String mAccessToken; private String mAccountName; private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment; + private ActivityAccountSavedThingBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); super.onCreate(savedInstanceState); - - setContentView(R.layout.activity_account_saved_thing); - - ButterKnife.bind(this); + binding = ActivityAccountSavedThingBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); EventBus.getDefault().register(this); @@ -116,7 +97,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.accountSavedThingAppbarLayout); } if (isImmersiveInterface()) { @@ -125,13 +106,13 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); + adjustToolbar(binding.accountSavedThingToolbar); } } - setSupportActionBar(toolbar); + setSupportActionBar(binding.accountSavedThingToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.accountSavedThingToolbar); postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment(); @@ -164,17 +145,20 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyTabLayoutTheme(tabLayout); + binding.accountSavedThingCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme( + binding.accountSavedThingAppbarLayout, + binding.accountSavedThingCollapsingToolbarLayout, + binding.accountSavedThingToolbar); + applyTabLayoutTheme(binding.accountSavedThingTabLayout); } private void initializeViewPager() { sectionsPagerAdapter = new SectionsPagerAdapter(this); - viewPager2.setAdapter(sectionsPagerAdapter); - viewPager2.setOffscreenPageLimit(2); - viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false)); - new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> { + binding.accountSavedThingViewPager2.setAdapter(sectionsPagerAdapter); + binding.accountSavedThingViewPager2.setOffscreenPageLimit(2); + binding.accountSavedThingViewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false)); + new TabLayoutMediator(binding.accountSavedThingTabLayout, binding.accountSavedThingViewPager2, (tab, position) -> { switch (position) { case 0: Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.posts)); @@ -185,7 +169,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT } }).attach(); - viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { + binding.accountSavedThingViewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { @Override public void onPageSelected(int position) { if (position == 0) { @@ -196,7 +180,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT } }); - fixViewPager2Sensitivity(viewPager2); + fixViewPager2Sensitivity(binding.accountSavedThingViewPager2); } @Override @@ -303,14 +287,14 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT @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.accountSavedThingViewPager2.getCurrentItem()); } public boolean handleKeyDown(int keyCode) { - if (viewPager2.getCurrentItem() == 0) { + if (binding.accountSavedThingViewPager2.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/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java index 9bec2c5b..78d4af7b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java @@ -16,22 +16,16 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; -import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.FileProvider; -import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; import com.bumptech.glide.request.RequestOptions; -import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; @@ -48,8 +42,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; -import butterknife.ButterKnife; import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; import io.noties.markwon.MarkwonConfiguration; @@ -81,6 +73,7 @@ import ml.docilealligator.infinityforreddit.comment.Comment; import ml.docilealligator.infinityforreddit.comment.SendComment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; +import ml.docilealligator.infinityforreddit.databinding.ActivityCommentBinding; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.markdown.RedditHeadingPlugin; import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin; @@ -89,7 +82,6 @@ import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; import okhttp3.ConnectionPool; import okhttp3.OkHttpClient; -import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; public class CommentActivity extends BaseActivity implements UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener { @@ -111,28 +103,6 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA private static final String SELECTED_ACCOUNT_STATE = "SAS"; private static final String UPLOADED_IMAGES_STATE = "UIS"; - @BindView(R.id.coordinator_layout_comment_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_comment_activity) - AppBarLayout appBarLayout; - @BindView(R.id.toolbar_comment_activity) - Toolbar toolbar; - @BindView(R.id.comment_parent_markwon_view_comment_activity) - TextView commentParentMarkwonView; - @BindView(R.id.divider_comment_activity) - View divider; - @BindView(R.id.content_markdown_view_comment_activity) - RecyclerView contentMarkdownRecyclerView; - @BindView(R.id.account_linear_layout_comment_activity) - LinearLayout accountLinearLayout; - @BindView(R.id.account_icon_gif_image_view_comment_activity) - GifImageView accountIconImageView; - @BindView(R.id.account_name_text_view_comment_activity) - TextView accountNameTextView; - @BindView(R.id.comment_edit_text_comment_activity) - EditText commentEditText; - @BindView(R.id.markdown_bottom_bar_recycler_view_comment_activity) - RecyclerView markdownBottomBarRecyclerView; @Inject @Named("no_oauth") Retrofit mRetrofit; @@ -169,6 +139,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA private Menu mMenu; private int commentColor; private int commentSpoilerBackgroundColor; + private ActivityCommentBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -177,17 +148,15 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA setImmersiveModeNotApplicable(); super.onCreate(savedInstanceState); - - setContentView(R.layout.activity_comment); - - ButterKnife.bind(this); + binding = ActivityCommentBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); EventBus.getDefault().register(this); applyCustomTheme(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.commentAppbarLayout); } mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); @@ -239,7 +208,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)) .build(); if (parentTextMarkdown != null) { - commentParentMarkwonView.setOnLongClickListener(view -> { + binding.commentCommentParentMarkwonView.setOnLongClickListener(view -> { Utils.hideKeyboard(CommentActivity.this); if (parentText == null) { CopyTextBottomSheetFragment.show(getSupportFragmentManager(), @@ -250,13 +219,13 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA } return true; }); - markwon.setMarkdown(commentParentMarkwonView, parentTextMarkdown); + markwon.setMarkdown(binding.commentCommentParentMarkwonView, parentTextMarkdown); } String parentBodyMarkdown = intent.getStringExtra(EXTRA_COMMENT_PARENT_BODY_MARKDOWN_KEY); String parentBody = intent.getStringExtra(EXTRA_COMMENT_PARENT_BODY_KEY); if (parentBodyMarkdown != null && !parentBodyMarkdown.equals("")) { - contentMarkdownRecyclerView.setVisibility(View.VISIBLE); - contentMarkdownRecyclerView.setNestedScrollingEnabled(false); + binding.commentContentMarkdownView.setVisibility(View.VISIBLE); + binding.commentContentMarkdownView.setNestedScrollingEnabled(false); Markwon postBodyMarkwon = Markwon.builder(this) .usePlugin(MarkwonInlineParserPlugin.create(plugin -> { plugin.excludeInlineProcessor(AutolinkInlineProcessor.class); @@ -314,8 +283,8 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA .tableLayout(R.layout.adapter_table_block, R.id.table_layout) .textLayoutIsRoot(R.layout.view_table_entry_cell))) .build(); - contentMarkdownRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this)); - contentMarkdownRecyclerView.setAdapter(markwonAdapter); + binding.commentContentMarkdownView.setLayoutManager(new LinearLayoutManagerBugFixed(this)); + binding.commentContentMarkdownView.setAdapter(markwonAdapter); markwonAdapter.setMarkdown(postBodyMarkwon, parentBodyMarkdown); markwonAdapter.notifyDataSetChanged(); } @@ -324,10 +293,10 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA parentPosition = intent.getExtras().getInt(EXTRA_PARENT_POSITION_KEY); isReplying = intent.getExtras().getBoolean(EXTRA_IS_REPLYING_KEY); if (isReplying) { - toolbar.setTitle(getString(R.string.comment_activity_label_is_replying)); + binding.commentToolbar.setTitle(getString(R.string.comment_activity_label_is_replying)); } - setSupportActionBar(toolbar); + setSupportActionBar(binding.commentToolbar); mGlide = Glide.with(this); @@ -340,9 +309,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(accountIconImageView); + .into(binding.commentAccountIconGifImageView); - accountNameTextView.setText(selectedAccount.getAccountName()); + binding.commentAccountNameTextView.setText(selectedAccount.getAccountName()); } else { loadCurrentAccount(); } @@ -355,7 +324,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA @Override public void onClick(int item) { MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener( - CommentActivity.this, commentEditText, item); + CommentActivity.this, binding.commentCommentEditText, item); } @Override @@ -370,16 +339,16 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA } }); - markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this, + binding.commentMarkdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this, LinearLayoutManagerBugFixed.HORIZONTAL, false)); - markdownBottomBarRecyclerView.setAdapter(adapter); + binding.commentMarkdownBottomBarRecyclerView.setAdapter(adapter); - accountLinearLayout.setOnClickListener(view -> { + binding.commentAccountLinearLayout.setOnClickListener(view -> { AccountChooserBottomSheetFragment fragment = new AccountChooserBottomSheetFragment(); fragment.show(getSupportFragmentManager(), fragment.getTag()); }); - commentEditText.requestFocus(); + binding.commentCommentEditText.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); @@ -397,9 +366,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(accountIconImageView); + .into(binding.commentAccountIconGifImageView); - accountNameTextView.setText(account.getAccountName()); + binding.commentAccountNameTextView.setText(account.getAccountName()); } }); }); @@ -424,22 +393,22 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); + binding.commentCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.commentAppbarLayout, null, binding.commentToolbar); commentColor = mCustomThemeWrapper.getCommentColor(); commentSpoilerBackgroundColor = commentColor | 0xFF000000; - commentParentMarkwonView.setTextColor(commentColor); - divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor()); - commentEditText.setTextColor(mCustomThemeWrapper.getCommentColor()); + binding.commentCommentParentMarkwonView.setTextColor(commentColor); + binding.commentDivider.setBackgroundColor(mCustomThemeWrapper.getDividerColor()); + binding.commentCommentEditText.setTextColor(mCustomThemeWrapper.getCommentColor()); int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor(); - commentEditText.setHintTextColor(secondaryTextColor); + binding.commentCommentEditText.setHintTextColor(secondaryTextColor); markdownColor = secondaryTextColor; spoilerBackgroundColor = markdownColor | 0xFF000000; - accountNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); + binding.commentAccountNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); if (typeface != null) { - commentParentMarkwonView.setTypeface(typeface); - commentEditText.setTypeface(typeface); + binding.commentCommentParentMarkwonView.setTypeface(typeface); + binding.commentCommentEditText.setTypeface(typeface); } } @@ -448,7 +417,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA super.onPause(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { - imm.hideSoftInputFromWindow(commentEditText.getWindowToken(), 0); + imm.hideSoftInputFromWindow(binding.commentCommentEditText.getWindowToken(), 0); } } @@ -468,7 +437,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA return true; } else if (itemId == R.id.action_preview_comment_activity) { Intent intent = new Intent(this, FullMarkdownActivity.class); - intent.putExtra(FullMarkdownActivity.EXTRA_COMMENT_MARKDOWN, commentEditText.getText().toString()); + intent.putExtra(FullMarkdownActivity.EXTRA_COMMENT_MARKDOWN, binding.commentCommentEditText.getText().toString()); intent.putExtra(FullMarkdownActivity.EXTRA_SUBMIT_POST, true); startActivityForResult(intent, MARKDOWN_PREVIEW_REQUEST_CODE); } else if (itemId == R.id.action_send_comment_activity) { @@ -482,9 +451,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA public void sendComment(@Nullable MenuItem item) { if (!isSubmitting) { isSubmitting = true; - if (commentEditText.getText() == null || commentEditText.getText().toString().equals("")) { + if (binding.commentCommentEditText.getText() == null || binding.commentCommentEditText.getText().toString().equals("")) { isSubmitting = false; - Snackbar.make(coordinatorLayout, R.string.comment_content_required, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.commentCoordinatorLayout, R.string.comment_content_required, Snackbar.LENGTH_SHORT).show(); return; } @@ -492,7 +461,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA item.setEnabled(false); item.getIcon().setAlpha(130); } - Snackbar sendingSnackbar = Snackbar.make(coordinatorLayout, R.string.sending_comment, Snackbar.LENGTH_INDEFINITE); + Snackbar sendingSnackbar = Snackbar.make(binding.commentCoordinatorLayout, R.string.sending_comment, Snackbar.LENGTH_INDEFINITE); sendingSnackbar.show(); Retrofit newAuthenticatorOauthRetrofit = mOauthRetrofit.newBuilder().client(new OkHttpClient.Builder().authenticator(new AnyAccountAccessTokenAuthenticator(mRetrofit, mRedditDataRoomDatabase, selectedAccount, mCurrentAccountSharedPreferences)) @@ -502,7 +471,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA .connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS)) .build()) .build(); - SendComment.sendComment(mExecutor, new Handler(), commentEditText.getText().toString(), + SendComment.sendComment(mExecutor, new Handler(), binding.commentCommentEditText.getText().toString(), parentFullname, parentDepth, newAuthenticatorOauthRetrofit, selectedAccount, new SendComment.SendCommentListener() { @Override @@ -533,9 +502,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA } if (errorMessage == null || !errorMessage.equals("")) { - Snackbar.make(coordinatorLayout, R.string.send_comment_failed, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.commentCoordinatorLayout, R.string.send_comment_failed, Snackbar.LENGTH_SHORT).show(); } else { - Snackbar.make(coordinatorLayout, errorMessage, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.commentCoordinatorLayout, errorMessage, Snackbar.LENGTH_SHORT).show(); } } }); @@ -562,10 +531,10 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA return; } Utils.uploadImageToReddit(this, mExecutor, mOauthRetrofit, mUploadMediaRetrofit, - mAccessToken, commentEditText, coordinatorLayout, data.getData(), uploadedImages); + mAccessToken, binding.commentCommentEditText, binding.commentCoordinatorLayout, data.getData(), uploadedImages); } else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) { Utils.uploadImageToReddit(this, mExecutor, mOauthRetrofit, mUploadMediaRetrofit, - mAccessToken, commentEditText, coordinatorLayout, capturedImageUri, uploadedImages); + mAccessToken, binding.commentCommentEditText, binding.commentCoordinatorLayout, capturedImageUri, uploadedImages); } else if (requestCode == MARKDOWN_PREVIEW_REQUEST_CODE) { sendComment(mMenu == null ? null : mMenu.findItem(R.id.action_send_comment_activity)); } @@ -577,7 +546,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA if (isSubmitting) { promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_edit_comment_detail); } else { - if (commentEditText.getText().toString().equals("")) { + if (binding.commentCommentEditText.getText().toString().equals("")) { finish(); } else { promptAlertDialog(R.string.discard, R.string.discard_detail); @@ -622,9 +591,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA @Override public void insertImageUrl(UploadedImage uploadedImage) { - int start = Math.max(commentEditText.getSelectionStart(), 0); - int end = Math.max(commentEditText.getSelectionEnd(), 0); - commentEditText.getText().replace(Math.min(start, end), Math.max(start, end), + int start = Math.max(binding.commentCommentEditText.getSelectionStart(), 0); + int end = Math.max(binding.commentCommentEditText.getSelectionEnd(), 0); + binding.commentCommentEditText.getText().replace(Math.min(start, end), Math.max(start, end), "[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")", 0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length()); } @@ -638,9 +607,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(accountIconImageView); + .into(binding.commentAccountIconGifImageView); - accountNameTextView.setText(selectedAccount.getAccountName()); + binding.commentAccountNameTextView.setText(selectedAccount.getAccountName()); } } } diff --git a/app/src/main/res/layout/activity_account_posts.xml b/app/src/main/res/layout/activity_account_posts.xml index a15dbc52..8e8d45c6 100644 --- a/app/src/main/res/layout/activity_account_posts.xml +++ b/app/src/main/res/layout/activity_account_posts.xml @@ -4,25 +4,25 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/coordinator_layout_account_posts_activity" + android:id="@+id/account_posts_coordinator_layout" tools:context=".activities.AccountPostsActivity"> <com.google.android.material.appbar.AppBarLayout - android:id="@+id/appbar_layout_account_posts_activity" + android:id="@+id/account_posts_appbar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <com.google.android.material.appbar.CollapsingToolbarLayout - android:id="@+id/collapsing_toolbar_layout_account_posts_activity" + android:id="@+id/account_posts_collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|enterAlways" app:titleEnabled="false" - app:toolbarId="@+id/toolbar_account_posts_activity"> + app:toolbarId="@+id/account_posts_toolbar"> <androidx.appcompat.widget.Toolbar - android:id="@+id/toolbar_account_posts_activity" + android:id="@+id/account_posts_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" @@ -34,7 +34,7 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.fragment.app.FragmentContainerView - android:id="@+id/frame_layout_account_posts_activity" + android:id="@+id/account_posts_frame_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> diff --git a/app/src/main/res/layout/activity_account_saved_thing.xml b/app/src/main/res/layout/activity_account_saved_thing.xml index 4f12aa4e..f6660c4b 100644 --- a/app/src/main/res/layout/activity_account_saved_thing.xml +++ b/app/src/main/res/layout/activity_account_saved_thing.xml @@ -4,25 +4,25 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/coordinator_layout_account_saved_thing_activity" + android:id="@+id/account_saved_thing_coordinator_layout" tools:context=".activities.AccountPostsActivity"> <com.google.android.material.appbar.AppBarLayout - android:id="@+id/appbar_layout_account_saved_thing_activity" + android:id="@+id/account_saved_thing_appbar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <com.google.android.material.appbar.CollapsingToolbarLayout - android:id="@+id/collapsing_toolbar_layout_account_saved_thing_activity" + android:id="@+id/account_saved_thing_collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|enterAlways" app:titleEnabled="false" - app:toolbarId="@+id/toolbar_account_saved_thing_activity"> + app:toolbarId="@+id/account_saved_thing_toolbar"> <androidx.appcompat.widget.Toolbar - android:id="@+id/toolbar_account_saved_thing_activity" + android:id="@+id/account_saved_thing_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" @@ -34,7 +34,7 @@ </com.google.android.material.appbar.CollapsingToolbarLayout> <com.google.android.material.tabs.TabLayout - android:id="@+id/tab_layout_tab_layout_account_saved_thing_activity_activity" + android:id="@+id/account_saved_thing_tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" @@ -48,7 +48,7 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.viewpager2.widget.ViewPager2 - android:id="@+id/view_pager_account_saved_thing_activity" + android:id="@+id/account_saved_thing_view_pager_2" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> diff --git a/app/src/main/res/layout/activity_comment.xml b/app/src/main/res/layout/activity_comment.xml index 73a755a8..7087b13f 100644 --- a/app/src/main/res/layout/activity_comment.xml +++ b/app/src/main/res/layout/activity_comment.xml @@ -2,19 +2,19 @@ <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/coordinator_layout_comment_activity" + android:id="@+id/comment_coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:application=".CommentActivity"> <com.google.android.material.appbar.AppBarLayout - android:id="@+id/appbar_layout_comment_activity" + android:id="@+id/comment_appbar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <androidx.appcompat.widget.Toolbar - android:id="@+id/toolbar_comment_activity" + android:id="@+id/comment_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" @@ -40,7 +40,7 @@ android:orientation="vertical"> <TextView - android:id="@+id/comment_parent_markwon_view_comment_activity" + android:id="@+id/comment_comment_parent_markwon_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" @@ -48,7 +48,7 @@ android:fontFamily="?attr/content_font_family" /> <androidx.recyclerview.widget.RecyclerView - android:id="@+id/content_markdown_view_comment_activity" + android:id="@+id/comment_content_markdown_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" @@ -57,12 +57,12 @@ android:visibility="gone" /> <View - android:id="@+id/divider_comment_activity" + android:id="@+id/comment_divider" android:layout_width="match_parent" android:layout_height="1dp" /> <LinearLayout - android:id="@+id/account_linear_layout_comment_activity" + android:id="@+id/comment_account_linear_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="16dp" @@ -72,13 +72,13 @@ android:background="?attr/selectableItemBackground"> <pl.droidsonroids.gif.GifImageView - android:id="@+id/account_icon_gif_image_view_comment_activity" + android:id="@+id/comment_account_icon_gif_image_view" android:layout_width="24dp" android:layout_height="24dp" android:layout_marginStart="16dp" /> <TextView - android:id="@+id/account_name_text_view_comment_activity" + android:id="@+id/comment_account_name_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" @@ -89,7 +89,7 @@ </LinearLayout> <EditText - android:id="@+id/comment_edit_text_comment_activity" + android:id="@+id/comment_comment_edit_text" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00000000" @@ -106,7 +106,7 @@ </androidx.core.widget.NestedScrollView> <androidx.recyclerview.widget.RecyclerView - android:id="@+id/markdown_bottom_bar_recycler_view_comment_activity" + android:id="@+id/comment_markdown_bottom_bar_recycler_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="horizontal" |