diff options
Diffstat (limited to '')
16 files changed, 282 insertions, 461 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java index ff2d24f7..a8568668 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java @@ -11,11 +11,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -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.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; @@ -24,7 +20,6 @@ import java.util.ArrayList; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.FetchUserFlairs; @@ -36,6 +31,7 @@ import ml.docilealligator.infinityforreddit.adapters.UserFlairRecyclerViewAdapte import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivitySelectUserFlairBinding; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; import retrofit2.Retrofit; @@ -45,14 +41,6 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo public static final String EXTRA_SUBREDDIT_NAME = "ESN"; private static final String USER_FLAIRS_STATE = "UFS"; - @BindView(R.id.coordinator_layout_select_user_flair_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_select_user_flair_activity) - AppBarLayout appBarLayout; - @BindView(R.id.toolbar_select_user_flair_activity) - Toolbar toolbar; - @BindView(R.id.recycler_view_select_user_flair_activity) - RecyclerView recyclerView; @Inject @Named("oauth") Retrofit mOauthRetrofit; @@ -68,6 +56,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo private ArrayList<UserFlair> mUserFlairs; private String mSubredditName; private UserFlairRecyclerViewAdapter mAdapter; + private ActivitySelectUserFlairBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -76,23 +65,25 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo setImmersiveModeNotApplicable(); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_select_user_flair); + + binding = ActivitySelectUserFlairBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); ButterKnife.bind(this); applyCustomTheme(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutSelectUserFlairActivity); } if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) { Slidr.attach(this); } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarSelectUserFlairActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.toolbarSelectUserFlairActivity); mSubredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); setTitle(mSubredditName); @@ -165,8 +156,8 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo } }); mLinearLayoutManager = new LinearLayoutManagerBugFixed(SelectUserFlairActivity.this); - recyclerView.setLayoutManager(mLinearLayoutManager); - recyclerView.setAdapter(mAdapter); + binding.recyclerViewSelectUserFlairActivity.setLayoutManager(mLinearLayoutManager); + binding.recyclerViewSelectUserFlairActivity.setAdapter(mAdapter); } private void selectUserFlair(@Nullable UserFlair userFlair) { @@ -186,12 +177,12 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo public void failed(String errorMessage) { if (errorMessage == null || errorMessage.equals("")) { if (userFlair == null) { - Snackbar.make(coordinatorLayout, R.string.clear_user_flair_success, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.getRoot(), R.string.clear_user_flair_success, Snackbar.LENGTH_SHORT).show(); } else { - Snackbar.make(coordinatorLayout, R.string.select_user_flair_success, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.getRoot(), R.string.select_user_flair_success, Snackbar.LENGTH_SHORT).show(); } } else { - Snackbar.make(coordinatorLayout, errorMessage, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.getRoot(), errorMessage, Snackbar.LENGTH_SHORT).show(); } } }); @@ -229,8 +220,8 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSelectUserFlairActivity, null, binding.toolbarSelectUserFlairActivity); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java index 6eeb7363..98009c46 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java @@ -9,22 +9,14 @@ import android.view.MenuItem; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -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 com.google.android.material.floatingactionbutton.FloatingActionButton; - import java.util.ArrayList; import java.util.Collections; 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.R; @@ -33,6 +25,7 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SelectSubreddit import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivitySelectedSubredditsBinding; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class SelectedSubredditsAndUsersActivity extends BaseActivity implements ActivityToolbarInterface { @@ -43,18 +36,6 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements private static final int USER_SELECTION_REQUEST_CODE = 2; private static final String SELECTED_SUBREDDITS_STATE = "SSS"; - @BindView(R.id.coordinator_layout_selected_subreddits_and_users_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_selected_subreddits_and_users_activity) - AppBarLayout appBarLayout; - @BindView(R.id.collapsing_toolbar_layout_selected_subreddits_and_users_activity) - CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.toolbar_selected_subreddits_and_users_activity) - Toolbar toolbar; - @BindView(R.id.recycler_view_selected_subreddits_and_users_activity) - RecyclerView recyclerView; - @BindView(R.id.fab_selected_subreddits_and_users_activity) - FloatingActionButton fab; @Inject @Named("default") SharedPreferences mSharedPreferences; @@ -66,6 +47,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements private LinearLayoutManagerBugFixed linearLayoutManager; private SelectedSubredditsRecyclerViewAdapter adapter; private ArrayList<String> subreddits; + private ActivitySelectedSubredditsBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -74,9 +56,9 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements setImmersiveModeNotApplicable(); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_selected_subreddits); - ButterKnife.bind(this); + binding = ActivitySelectedSubredditsBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); applyCustomTheme(); @@ -84,9 +66,9 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements Slidr.attach(this); } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarSelectedSubredditsAndUsersActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.toolbarSelectedSubredditsAndUsersActivity); if (savedInstanceState != null) { subreddits = savedInstanceState.getStringArrayList(SELECTED_SUBREDDITS_STATE); @@ -98,21 +80,21 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements adapter = new SelectedSubredditsRecyclerViewAdapter(this, mCustomThemeWrapper, subreddits); linearLayoutManager = new LinearLayoutManagerBugFixed(this); - recyclerView.setLayoutManager(linearLayoutManager); - recyclerView.setAdapter(adapter); - recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + binding.recyclerViewSelectedSubredditsAndUsersActivity.setLayoutManager(linearLayoutManager); + binding.recyclerViewSelectedSubredditsAndUsersActivity.setAdapter(adapter); + binding.recyclerViewSelectedSubredditsAndUsersActivity.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (dy > 0) { - fab.hide(); + binding.fabSelectedSubredditsAndUsersActivity.hide(); } else { - fab.show(); + binding.fabSelectedSubredditsAndUsersActivity.show(); } } }); - fab.setOnClickListener(view -> { + binding.fabSelectedSubredditsAndUsersActivity.setOnClickListener(view -> { SelectSubredditsOrUsersOptionsBottomSheetFragment selectSubredditsOrUsersOptionsBottomSheetFragment = new SelectSubredditsOrUsersOptionsBottomSheetFragment(); selectSubredditsOrUsersOptionsBottomSheetFragment.show(getSupportFragmentManager(), selectSubredditsOrUsersOptionsBottomSheetFragment.getTag()); }); @@ -200,9 +182,10 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyFABTheme(fab); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSelectedSubredditsAndUsersActivity, + binding.collapsingToolbarLayoutSelectedSubredditsAndUsersActivity, binding.toolbarSelectedSubredditsAndUsersActivity); + applyFABTheme(binding.fabSelectedSubredditsAndUsersActivity); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java index a47bcb15..551d056c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java @@ -5,47 +5,26 @@ import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; -import android.view.View; -import android.widget.EditText; import android.widget.Toast; 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.snackbar.Snackbar; 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.ActivitySendPrivateMessageBinding; import ml.docilealligator.infinityforreddit.message.ComposeMessage; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import retrofit2.Retrofit; public class SendPrivateMessageActivity extends BaseActivity { public static final String EXTRA_RECIPIENT_USERNAME = "ERU"; - @BindView(R.id.coordinator_layout_send_private_message_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_send_private_message_activity) - AppBarLayout appBarLayout; - @BindView(R.id.toolbar_send_private_message_activity) - Toolbar toolbar; - @BindView(R.id.username_edit_text_send_private_message_activity) - EditText usernameEditText; - @BindView(R.id.divider_1_send_private_message_activity) - View divider1; - @BindView(R.id.subjet_edit_text_send_private_message_activity) - EditText subjectEditText; - @BindView(R.id.divider_2_send_private_message_activity) - View divider2; - @BindView(R.id.content_edit_text_send_private_message_activity) - EditText messageEditText; + @Inject @Named("oauth") Retrofit mOauthRetrofit; @@ -59,6 +38,7 @@ public class SendPrivateMessageActivity extends BaseActivity { CustomThemeWrapper mCustomThemeWrapper; private String mAccessToken; private boolean isSubmitting = false; + private ActivitySendPrivateMessageBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -67,23 +47,23 @@ public class SendPrivateMessageActivity extends BaseActivity { setImmersiveModeNotApplicable(); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_send_private_message); - ButterKnife.bind(this); + binding = ActivitySendPrivateMessageBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); applyCustomTheme(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutSendPrivateMessageActivity); } mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarSendPrivateMessageActivity); String username = getIntent().getStringExtra(EXTRA_RECIPIENT_USERNAME); if (username != null) { - usernameEditText.setText(username); + binding.usernameEditTextSendPrivateMessageActivity.setText(username); } } @@ -102,32 +82,32 @@ public class SendPrivateMessageActivity extends BaseActivity { } else if (item.getItemId() == R.id.action_send_send_private_message_activity) { if (!isSubmitting) { isSubmitting = true; - if (usernameEditText.getText() == null || usernameEditText.getText().toString().equals("")) { + if (binding.usernameEditTextSendPrivateMessageActivity.getText() == null || binding.usernameEditTextSendPrivateMessageActivity.getText().toString().equals("")) { isSubmitting = false; - Snackbar.make(coordinatorLayout, R.string.message_username_required, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.getRoot(), R.string.message_username_required, Snackbar.LENGTH_LONG).show(); return true; } - if (subjectEditText.getText() == null || subjectEditText.getText().toString().equals("")) { + if (binding.subjetEditTextSendPrivateMessageActivity.getText() == null || binding.subjetEditTextSendPrivateMessageActivity.getText().toString().equals("")) { isSubmitting = false; - Snackbar.make(coordinatorLayout, R.string.message_subject_required, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.getRoot(), R.string.message_subject_required, Snackbar.LENGTH_LONG).show(); return true; } - if (messageEditText.getText() == null || messageEditText.getText().toString().equals("")) { + if (binding.contentEditTextSendPrivateMessageActivity.getText() == null || binding.contentEditTextSendPrivateMessageActivity.getText().toString().equals("")) { isSubmitting = false; - Snackbar.make(coordinatorLayout, R.string.message_content_required, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.getRoot(), R.string.message_content_required, Snackbar.LENGTH_LONG).show(); return true; } item.setEnabled(false); item.getIcon().setAlpha(130); - Snackbar sendingSnackbar = Snackbar.make(coordinatorLayout, R.string.sending_message, Snackbar.LENGTH_INDEFINITE); + Snackbar sendingSnackbar = Snackbar.make(binding.getRoot(), R.string.sending_message, Snackbar.LENGTH_INDEFINITE); sendingSnackbar.show(); ComposeMessage.composeMessage(mOauthRetrofit, mAccessToken, getResources().getConfiguration().locale, - usernameEditText.getText().toString(), subjectEditText.getText().toString(), - messageEditText.getText().toString(), new ComposeMessage.ComposeMessageListener() { + binding.usernameEditTextSendPrivateMessageActivity.getText().toString(), binding.subjetEditTextSendPrivateMessageActivity.getText().toString(), + binding.contentEditTextSendPrivateMessageActivity.getText().toString(), new ComposeMessage.ComposeMessageListener() { @Override public void composeMessageSuccess() { isSubmitting = false; @@ -145,9 +125,9 @@ public class SendPrivateMessageActivity extends BaseActivity { item.getIcon().setAlpha(255); if (errorMessage == null || errorMessage.equals("")) { - Snackbar.make(coordinatorLayout, R.string.send_message_failed, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.getRoot(), R.string.send_message_failed, Snackbar.LENGTH_LONG).show(); } else { - Snackbar.make(coordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.getRoot(), errorMessage, Snackbar.LENGTH_LONG).show(); } } }); @@ -178,23 +158,24 @@ public class SendPrivateMessageActivity extends BaseActivity { @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSendPrivateMessageActivity, + null, binding.toolbarSendPrivateMessageActivity); int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); - usernameEditText.setTextColor(primaryTextColor); - subjectEditText.setTextColor(primaryTextColor); - messageEditText.setTextColor(primaryTextColor); + binding.usernameEditTextSendPrivateMessageActivity.setTextColor(primaryTextColor); + binding.subjetEditTextSendPrivateMessageActivity.setTextColor(primaryTextColor); + binding.contentEditTextSendPrivateMessageActivity.setTextColor(primaryTextColor); int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor(); - usernameEditText.setHintTextColor(secondaryTextColor); - subjectEditText.setHintTextColor(secondaryTextColor); - messageEditText.setHintTextColor(secondaryTextColor); + binding.usernameEditTextSendPrivateMessageActivity.setHintTextColor(secondaryTextColor); + binding.subjetEditTextSendPrivateMessageActivity.setHintTextColor(secondaryTextColor); + binding.contentEditTextSendPrivateMessageActivity.setHintTextColor(secondaryTextColor); int dividerColor = mCustomThemeWrapper.getDividerColor(); - divider1.setBackgroundColor(dividerColor); - divider2.setBackgroundColor(dividerColor); + binding.divider1SendPrivateMessageActivity.setBackgroundColor(dividerColor); + binding.divider2SendPrivateMessageActivity.setBackgroundColor(dividerColor); if (typeface != null) { - usernameEditText.setTypeface(typeface); - subjectEditText.setTypeface(typeface); - messageEditText.setTypeface(typeface); + binding.usernameEditTextSendPrivateMessageActivity.setTypeface(typeface); + binding.subjetEditTextSendPrivateMessageActivity.setTypeface(typeface); + binding.contentEditTextSendPrivateMessageActivity.setTypeface(typeface); } } }
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java index 267d6fc4..c53356ed 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java @@ -13,16 +13,9 @@ import android.os.Handler; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.widget.EditText; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; -import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.ContextCompat; import com.bumptech.glide.Glide; @@ -31,13 +24,8 @@ import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; import com.davemorrissey.labs.subscaleview.ImageSource; -import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.button.MaterialButton; import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.materialswitch.MaterialSwitch; import com.google.android.material.snackbar.Snackbar; -import com.libRG.CustomTextView; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -48,8 +36,6 @@ import java.util.concurrent.Executor; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; -import butterknife.ButterKnife; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Infinity; @@ -60,12 +46,12 @@ import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIcon; import ml.docilealligator.infinityforreddit.bottomsheetfragments.AccountChooserBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.databinding.ActivitySubmitCrosspostBinding; import ml.docilealligator.infinityforreddit.events.SubmitCrosspostEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.services.SubmitPostService; import ml.docilealligator.infinityforreddit.utils.APIUtils; -import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; public class SubmitCrosspostActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback, @@ -86,54 +72,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0; - @BindView(R.id.coordinator_layout_submit_crosspost_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_submit_crosspost_activity) - AppBarLayout appBarLayout; - @BindView(R.id.toolbar_submit_crosspost_activity) - Toolbar toolbar; - @BindView(R.id.account_linear_layout_submit_crosspost_activity) - LinearLayout accountLinearLayout; - @BindView(R.id.account_icon_gif_image_view_submit_crosspost_activity) - GifImageView accountIconImageView; - @BindView(R.id.account_name_text_view_submit_crosspost_activity) - TextView accountNameTextView; - @BindView(R.id.subreddit_icon_gif_image_view_submit_crosspost_activity) - GifImageView iconGifImageView; - @BindView(R.id.subreddit_name_text_view_submit_crosspost_activity) - TextView subredditNameTextView; - @BindView(R.id.rules_button_submit_crosspost_activity) - MaterialButton rulesButton; - @BindView(R.id.divider_1_submit_crosspost_activity) - View divider1; - @BindView(R.id.flair_custom_text_view_submit_crosspost_activity) - CustomTextView flairTextView; - @BindView(R.id.spoiler_custom_text_view_submit_crosspost_activity) - CustomTextView spoilerTextView; - @BindView(R.id.nsfw_custom_text_view_submit_crosspost_activity) - CustomTextView nsfwTextView; - @BindView(R.id.divider_2_submit_crosspost_activity) - View divider2; - @BindView(R.id.receive_post_reply_notifications_linear_layout_submit_crosspost_activity) - LinearLayout receivePostReplyNotificationsLinearLayout; - @BindView(R.id.receive_post_reply_notifications_text_view_submit_crosspost_activity) - TextView receivePostReplyNotificationsTextView; - @BindView(R.id.receive_post_reply_notifications_switch_material_submit_crosspost_activity) - MaterialSwitch receivePostReplyNotificationsSwitchMaterial; - @BindView(R.id.divider_3_submit_crosspost_activity) - View divider3; - @BindView(R.id.post_title_edit_text_submit_crosspost_activity) - EditText titleEditText; - @BindView(R.id.divider_4_submit_crosspost_activity) - View divider4; - @BindView(R.id.post_content_text_view_submit_crosspost_activity) - TextView contentTextView; - @BindView(R.id.frame_layout_submit_crosspost_activity) - FrameLayout frameLayout; - @BindView(R.id.image_view_submit_crosspost_activity) - SubsamplingScaleImageView imageView; - @BindView(R.id.play_button_image_view_submit_crosspost_activity) - ImageView playButton; @Inject @Named("no_oauth") Retrofit mRetrofit; @@ -175,6 +113,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom private RequestManager mGlide; private FlairBottomSheetFragment flairSelectionBottomSheetFragment; private Snackbar mPostingSnackbar; + private ActivitySubmitCrosspostBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -183,24 +122,24 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom setImmersiveModeNotApplicable(); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_submit_crosspost); - ButterKnife.bind(this); + binding = ActivitySubmitCrosspostBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); EventBus.getDefault().register(this); applyCustomTheme(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutSubmitCrosspostActivity); } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarSubmitCrosspostActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mGlide = Glide.with(this); - mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); + mPostingSnackbar = Snackbar.make(binding.getRoot(), R.string.posting, Snackbar.LENGTH_INDEFINITE); resources = getResources(); @@ -223,17 +162,17 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom .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.accountIconGifImageViewSubmitCrosspostActivity); - accountNameTextView.setText(selectedAccount.getAccountName()); + binding.accountNameTextViewSubmitCrosspostActivity.setText(selectedAccount.getAccountName()); } else { loadCurrentAccount(); } if (subredditName != null) { - subredditNameTextView.setTextColor(primaryTextColor); - subredditNameTextView.setText(subredditName); - flairTextView.setVisibility(View.VISIBLE); + binding.subredditNameTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.subredditNameTextViewSubmitCrosspostActivity.setText(subredditName); + binding.flairCustomTextViewSubmitCrosspostActivity.setVisibility(View.VISIBLE); if (!loadSubredditIconSuccessful) { loadSubredditIcon(); } @@ -245,20 +184,20 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom } if (flair != null) { - flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairBackgroundColor); - flairTextView.setBorderColor(flairBackgroundColor); - flairTextView.setTextColor(flairTextColor); + binding.flairCustomTextViewSubmitCrosspostActivity.setText(flair.getText()); + binding.flairCustomTextViewSubmitCrosspostActivity.setBackgroundColor(flairBackgroundColor); + binding.flairCustomTextViewSubmitCrosspostActivity.setBorderColor(flairBackgroundColor); + binding.flairCustomTextViewSubmitCrosspostActivity.setTextColor(flairTextColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerBackgroundColor); - spoilerTextView.setBorderColor(spoilerBackgroundColor); - spoilerTextView.setTextColor(spoilerTextColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setBackgroundColor(spoilerBackgroundColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setBorderColor(spoilerBackgroundColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setTextColor(spoilerTextColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(nsfwBackgroundColor); - nsfwTextView.setBorderColor(nsfwBackgroundColor); - nsfwTextView.setTextColor(nsfwTextColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setBackgroundColor(nsfwBackgroundColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setBorderColor(nsfwBackgroundColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setTextColor(nsfwTextColor); } } else { isPosting = false; @@ -267,36 +206,36 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) - .into(iconGifImageView); + .into(binding.subredditIconGifImageViewSubmitCrosspostActivity); if (post.isSpoiler()) { - spoilerTextView.setBackgroundColor(spoilerBackgroundColor); - spoilerTextView.setBorderColor(spoilerBackgroundColor); - spoilerTextView.setTextColor(spoilerTextColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setBackgroundColor(spoilerBackgroundColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setBorderColor(spoilerBackgroundColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setTextColor(spoilerTextColor); } if (post.isNSFW()) { - nsfwTextView.setBackgroundColor(nsfwBackgroundColor); - nsfwTextView.setBorderColor(nsfwBackgroundColor); - nsfwTextView.setTextColor(nsfwTextColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setBackgroundColor(nsfwBackgroundColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setBorderColor(nsfwBackgroundColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setTextColor(nsfwTextColor); } - titleEditText.setText(post.getTitle()); + binding.postTitleEditTextSubmitCrosspostActivity.setText(post.getTitle()); } if (post.getPostType() == Post.TEXT_TYPE) { - contentTextView.setVisibility(View.VISIBLE); - contentTextView.setText(post.getSelfTextPlain()); + binding.postContentTextViewSubmitCrosspostActivity.setVisibility(View.VISIBLE); + binding.postContentTextViewSubmitCrosspostActivity.setText(post.getSelfTextPlain()); } else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) { - contentTextView.setVisibility(View.VISIBLE); - contentTextView.setText(post.getUrl()); + binding.postContentTextViewSubmitCrosspostActivity.setVisibility(View.VISIBLE); + binding.postContentTextViewSubmitCrosspostActivity.setText(post.getUrl()); } else { Post.Preview preview = getPreview(post); if (preview != null) { - frameLayout.setVisibility(View.VISIBLE); + binding.frameLayoutSubmitCrosspostActivity.setVisibility(View.VISIBLE); mGlide.asBitmap().load(preview.getPreviewUrl()).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { - imageView.setImage(ImageSource.bitmap(resource)); + binding.imageViewSubmitCrosspostActivity.setImage(ImageSource.bitmap(resource)); } @Override @@ -306,33 +245,33 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom }); if (post.getPostType() == Post.VIDEO_TYPE || post.getPostType() == Post.GIF_TYPE) { - playButton.setVisibility(View.VISIBLE); - playButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_play_circle_36dp)); + binding.playButtonImageViewSubmitCrosspostActivity.setVisibility(View.VISIBLE); + binding.playButtonImageViewSubmitCrosspostActivity.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_play_circle_36dp)); } else if (post.getPostType() == Post.GALLERY_TYPE) { - playButton.setVisibility(View.VISIBLE); - playButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_gallery_24dp)); + binding.playButtonImageViewSubmitCrosspostActivity.setVisibility(View.VISIBLE); + binding.playButtonImageViewSubmitCrosspostActivity.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_gallery_24dp)); } } } - accountLinearLayout.setOnClickListener(view -> { + binding.accountLinearLayoutSubmitCrosspostActivity.setOnClickListener(view -> { AccountChooserBottomSheetFragment fragment = new AccountChooserBottomSheetFragment(); fragment.show(getSupportFragmentManager(), fragment.getTag()); }); - iconGifImageView.setOnClickListener(view -> { - subredditNameTextView.performClick(); + binding.subredditIconGifImageViewSubmitCrosspostActivity.setOnClickListener(view -> { + binding.subredditNameTextViewSubmitCrosspostActivity.performClick(); }); - subredditNameTextView.setOnClickListener(view -> { + binding.subredditNameTextViewSubmitCrosspostActivity.setOnClickListener(view -> { Intent intent = new Intent(this, SubredditSelectionActivity.class); intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); }); - rulesButton.setOnClickListener(view -> { + binding.rulesButtonSubmitCrosspostActivity.setOnClickListener(view -> { if (subredditName == null) { - Snackbar.make(coordinatorLayout, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.getRoot(), R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show(); } else { Intent intent = new Intent(this, RulesActivity.class); if (subredditIsUser) { @@ -344,7 +283,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom } }); - flairTextView.setOnClickListener(view -> { + binding.flairCustomTextViewSubmitCrosspostActivity.setOnClickListener(view -> { if (flair == null) { flairSelectionBottomSheetFragment = new FlairBottomSheetFragment(); Bundle bundle = new Bundle(); @@ -356,41 +295,41 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom flairSelectionBottomSheetFragment.setArguments(bundle); flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); } else { - flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); - flairTextView.setTextColor(primaryTextColor); - flairTextView.setText(getString(R.string.flair)); + binding.flairCustomTextViewSubmitCrosspostActivity.setBackgroundColor(resources.getColor(android.R.color.transparent)); + binding.flairCustomTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.flairCustomTextViewSubmitCrosspostActivity.setText(getString(R.string.flair)); flair = null; } }); - spoilerTextView.setOnClickListener(view -> { + binding.spoilerCustomTextViewSubmitCrosspostActivity.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerBackgroundColor); - spoilerTextView.setBorderColor(spoilerBackgroundColor); - spoilerTextView.setTextColor(spoilerTextColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setBackgroundColor(spoilerBackgroundColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setBorderColor(spoilerBackgroundColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setTextColor(spoilerTextColor); isSpoiler = true; } else { - spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); - spoilerTextView.setTextColor(primaryTextColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setBackgroundColor(resources.getColor(android.R.color.transparent)); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); isSpoiler = false; } }); - nsfwTextView.setOnClickListener(view -> { + binding.nsfwCustomTextViewSubmitCrosspostActivity.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(nsfwBackgroundColor); - nsfwTextView.setBorderColor(nsfwBackgroundColor); - nsfwTextView.setTextColor(nsfwTextColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setBackgroundColor(nsfwBackgroundColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setBorderColor(nsfwBackgroundColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setTextColor(nsfwTextColor); isNSFW = true; } else { - nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); - nsfwTextView.setTextColor(primaryTextColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setBackgroundColor(resources.getColor(android.R.color.transparent)); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); isNSFW = false; } }); - receivePostReplyNotificationsLinearLayout.setOnClickListener(view -> { - receivePostReplyNotificationsSwitchMaterial.performClick(); + binding.receivePostReplyNotificationsLinearLayoutSubmitCrosspostActivity.setOnClickListener(view -> { + binding.receivePostReplyNotificationsSwitchMaterialSubmitCrosspostActivity.performClick(); }); } @@ -405,9 +344,9 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom .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.accountIconGifImageViewSubmitCrosspostActivity); - accountNameTextView.setText(account.getAccountName()); + binding.accountNameTextViewSubmitCrosspostActivity.setText(account.getAccountName()); } }); }); @@ -440,46 +379,47 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSubmitCrosspostActivity, + null, binding.toolbarSubmitCrosspostActivity); primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); - accountNameTextView.setTextColor(primaryTextColor); + binding.accountNameTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor(); - subredditNameTextView.setTextColor(secondaryTextColor); - rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); - rulesButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme()); - receivePostReplyNotificationsTextView.setTextColor(primaryTextColor); + binding.subredditNameTextViewSubmitCrosspostActivity.setTextColor(secondaryTextColor); + binding.rulesButtonSubmitCrosspostActivity.setTextColor(mCustomThemeWrapper.getButtonTextColor()); + binding.rulesButtonSubmitCrosspostActivity.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme()); + binding.receivePostReplyNotificationsTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); int dividerColor = mCustomThemeWrapper.getDividerColor(); - divider1.setBackgroundColor(dividerColor); - divider2.setBackgroundColor(dividerColor); - divider3.setBackgroundColor(dividerColor); - divider4.setBackgroundColor(dividerColor); + binding.divider1SubmitCrosspostActivity.setBackgroundColor(dividerColor); + binding.divider2SubmitCrosspostActivity.setBackgroundColor(dividerColor); + binding.divider3SubmitCrosspostActivity.setBackgroundColor(dividerColor); + binding.divider4SubmitCrosspostActivity.setBackgroundColor(dividerColor); flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor(); flairTextColor = mCustomThemeWrapper.getFlairTextColor(); spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor(); spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor(); nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor(); nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor(); - flairTextView.setTextColor(primaryTextColor); - spoilerTextView.setTextColor(primaryTextColor); - nsfwTextView.setTextColor(primaryTextColor); - titleEditText.setTextColor(primaryTextColor); - titleEditText.setHintTextColor(secondaryTextColor); - contentTextView.setTextColor(primaryTextColor); - contentTextView.setHintTextColor(secondaryTextColor); - playButton.setColorFilter(mCustomThemeWrapper.getMediaIndicatorIconColor(), PorterDuff.Mode.SRC_IN); - playButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getMediaIndicatorBackgroundColor())); + binding.flairCustomTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.postTitleEditTextSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.postTitleEditTextSubmitCrosspostActivity.setHintTextColor(secondaryTextColor); + binding.postContentTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.postContentTextViewSubmitCrosspostActivity.setHintTextColor(secondaryTextColor); + binding.playButtonImageViewSubmitCrosspostActivity.setColorFilter(mCustomThemeWrapper.getMediaIndicatorIconColor(), PorterDuff.Mode.SRC_IN); + binding.playButtonImageViewSubmitCrosspostActivity.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); + binding.subredditNameTextViewSubmitCrosspostActivity.setTypeface(typeface); + binding.rulesButtonSubmitCrosspostActivity.setTypeface(typeface); + binding.receivePostReplyNotificationsTextViewSubmitCrosspostActivity.setTypeface(typeface); + binding.flairCustomTextViewSubmitCrosspostActivity.setTypeface(typeface); + binding.spoilerCustomTextViewSubmitCrosspostActivity.setTypeface(typeface); + binding.nsfwCustomTextViewSubmitCrosspostActivity.setTypeface(typeface); + binding.postTitleEditTextSubmitCrosspostActivity.setTypeface(typeface); } if (contentTypeface != null) { - contentTextView.setTypeface(contentTypeface); + binding.postContentTextViewSubmitCrosspostActivity.setTypeface(contentTypeface); } } @@ -489,11 +429,11 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(iconGifImageView); + .into(binding.subredditIconGifImageViewSubmitCrosspostActivity); } else { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) - .into(iconGifImageView); + .into(binding.subredditIconGifImageViewSubmitCrosspostActivity); } } @@ -536,7 +476,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail); return true; } else { - if (!titleEditText.getText().toString().equals("")) { + if (!binding.postTitleEditTextSubmitCrosspostActivity.getText().toString().equals("")) { promptAlertDialog(R.string.discard, R.string.discard_detail); return true; } @@ -545,12 +485,12 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom return true; } else if (itemId == R.id.action_send_submit_crosspost_activity) { if (!subredditSelected) { - Snackbar.make(coordinatorLayout, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.getRoot(), R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show(); return true; } - if (titleEditText.getText() == null || titleEditText.getText().toString().equals("")) { - Snackbar.make(coordinatorLayout, R.string.title_required, Snackbar.LENGTH_SHORT).show(); + if (binding.postTitleEditTextSubmitCrosspostActivity.getText() == null || binding.postTitleEditTextSubmitCrosspostActivity.getText().toString().equals("")) { + Snackbar.make(binding.getRoot(), R.string.title_required, Snackbar.LENGTH_SHORT).show(); return true; } @@ -563,15 +503,15 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom String subredditName; if (subredditIsUser) { - subredditName = "u_" + subredditNameTextView.getText().toString(); + subredditName = "u_" + binding.subredditNameTextViewSubmitCrosspostActivity.getText().toString(); } else { - subredditName = subredditNameTextView.getText().toString(); + subredditName = binding.subredditNameTextViewSubmitCrosspostActivity.getText().toString(); } Intent intent = new Intent(this, SubmitPostService.class); intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount); intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName); - intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString()); + intent.putExtra(SubmitPostService.EXTRA_TITLE, binding.postTitleEditTextSubmitCrosspostActivity.getText().toString()); if (post.isCrosspost()) { intent.putExtra(SubmitPostService.EXTRA_CONTENT, "t3_" + post.getCrosspostParentId()); } else { @@ -581,7 +521,8 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair); intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler); intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW); - intent.putExtra(SubmitPostService.EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS, receivePostReplyNotificationsSwitchMaterial.isChecked()); + intent.putExtra(SubmitPostService.EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS, + binding.receivePostReplyNotificationsSwitchMaterialSubmitCrosspostActivity.isChecked()); intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_CROSSPOST); ContextCompat.startForegroundService(this, intent); @@ -596,7 +537,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom if (isPosting) { promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail); } else { - if (!titleEditText.getText().toString().equals("")) { + if (!binding.postTitleEditTextSubmitCrosspostActivity.getText().toString().equals("")) { promptAlertDialog(R.string.discard, R.string.discard_detail); } else { finish(); @@ -629,14 +570,14 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom subredditSelected = true; subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER); - subredditNameTextView.setTextColor(primaryTextColor); - subredditNameTextView.setText(subredditName); + binding.subredditNameTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.subredditNameTextViewSubmitCrosspostActivity.setText(subredditName); displaySubredditIcon(); - flairTextView.setVisibility(View.VISIBLE); - flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); - flairTextView.setTextColor(primaryTextColor); - flairTextView.setText(getString(R.string.flair)); + binding.flairCustomTextViewSubmitCrosspostActivity.setVisibility(View.VISIBLE); + binding.flairCustomTextViewSubmitCrosspostActivity.setBackgroundColor(resources.getColor(android.R.color.transparent)); + binding.flairCustomTextViewSubmitCrosspostActivity.setTextColor(primaryTextColor); + binding.flairCustomTextViewSubmitCrosspostActivity.setText(getString(R.string.flair)); flair = null; } } @@ -651,10 +592,10 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom @Override public void flairSelected(Flair flair) { this.flair = flair; - flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairBackgroundColor); - flairTextView.setBorderColor(flairBackgroundColor); - flairTextView.setTextColor(flairTextColor); + binding.flairCustomTextViewSubmitCrosspostActivity.setText(flair.getText()); + binding.flairCustomTextViewSubmitCrosspostActivity.setBackgroundColor(flairBackgroundColor); + binding.flairCustomTextViewSubmitCrosspostActivity.setBorderColor(flairBackgroundColor); + binding.flairCustomTextViewSubmitCrosspostActivity.setTextColor(flairTextColor); } @Override @@ -666,9 +607,9 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom .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.accountIconGifImageViewSubmitCrosspostActivity); - accountNameTextView.setText(selectedAccount.getAccountName()); + binding.accountNameTextViewSubmitCrosspostActivity.setText(selectedAccount.getAccountName()); } } @@ -690,9 +631,9 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom mMenu.findItem(R.id.action_send_submit_crosspost_activity).setEnabled(true); mMenu.findItem(R.id.action_send_submit_crosspost_activity).getIcon().setAlpha(255); if (submitCrosspostEvent.errorMessage == null || submitCrosspostEvent.errorMessage.equals("")) { - Snackbar.make(coordinatorLayout, R.string.post_failed, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(binding.getRoot(), R.string.post_failed, Snackbar.LENGTH_SHORT).show(); } else { - Snackbar.make(coordinatorLayout, submitCrosspostEvent.errorMessage.substring(0, 1).toUpperCase() + Snackbar.make(binding.getRoot(), submitCrosspostEvent.errorMessage.substring(0, 1).toUpperCase() + submitCrosspostEvent.errorMessage.substring(1), Snackbar.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java index dda07d4f..1a984793 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java @@ -41,6 +41,7 @@ import ml.docilealligator.infinityforreddit.adapters.SubredditMultiselectionRecy import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivitySubscribedSubredditsMultiselectionBinding; import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditViewModel; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import retrofit2.Retrofit; @@ -51,24 +52,6 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 1; - @BindView(R.id.coordinator_layout_subreddits_multiselection_activity) - CoordinatorLayout mCoordinatorLayout; - @BindView(R.id.appbar_layout_subreddits_multiselection_activity) - AppBarLayout mAppBarLayout; - @BindView(R.id.collapsing_toolbar_layout_subscribed_subreddits_multiselection_activity) - CollapsingToolbarLayout mCollapsingToolbarLayout; - @BindView(R.id.toolbar_subscribed_subreddits_multiselection_activity) - Toolbar mToolbar; - @BindView(R.id.swipe_refresh_layout_subscribed_subscribed_subreddits_multiselection_activity) - SwipeRefreshLayout mSwipeRefreshLayout; - @BindView(R.id.recycler_view_subscribed_subscribed_subreddits_multiselection_activity) - RecyclerView mRecyclerView; - @BindView(R.id.no_subscriptions_linear_layout_subscribed_subreddits_multiselection_activity) - LinearLayout mLinearLayout; - @BindView(R.id.no_subscriptions_image_view_subscribed_subreddits_multiselection_activity) - ImageView mImageView; - @BindView(R.id.error_text_view_subscribed_subreddits_multiselection_activity) - TextView mErrorTextView; @Inject @Named("oauth") Retrofit mOauthRetrofit; @@ -86,14 +69,15 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act private LinearLayoutManagerBugFixed mLinearLayoutManager; private SubredditMultiselectionRecyclerViewAdapter mAdapter; private RequestManager mGlide; + private ActivitySubscribedSubredditsMultiselectionBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_subscribed_subreddits_multiselection); - ButterKnife.bind(this); + binding = ActivitySubscribedSubredditsMultiselectionBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); applyCustomTheme(); @@ -105,7 +89,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(mAppBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutSubredditsMultiselectionActivity); } if (isImmersiveInterface()) { @@ -114,44 +98,44 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(mToolbar); + adjustToolbar(binding.toolbarSubscribedSubredditsMultiselectionActivity); int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { - mRecyclerView.setPadding(0, 0, 0, navBarHeight); + binding.recyclerViewSubscribedSubscribedSubredditsMultiselectionActivity.setPadding(0, 0, 0, navBarHeight); } } } - setSupportActionBar(mToolbar); + setSupportActionBar(binding.toolbarSubscribedSubredditsMultiselectionActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mGlide = Glide.with(this); - mSwipeRefreshLayout.setEnabled(false); + binding.swipeRefreshLayoutSubscribedSubscribedSubredditsMultiselectionActivity.setEnabled(false); bindView(); } private void bindView() { mLinearLayoutManager = new LinearLayoutManagerBugFixed(this); - mRecyclerView.setLayoutManager(mLinearLayoutManager); + binding.recyclerViewSubscribedSubscribedSubredditsMultiselectionActivity.setLayoutManager(mLinearLayoutManager); mAdapter = new SubredditMultiselectionRecyclerViewAdapter(this, mCustomThemeWrapper); - mRecyclerView.setAdapter(mAdapter); + binding.recyclerViewSubscribedSubscribedSubredditsMultiselectionActivity.setAdapter(mAdapter); mSubscribedSubredditViewModel = new ViewModelProvider(this, new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, accountName)) .get(SubscribedSubredditViewModel.class); mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, subscribedSubredditData -> { - mSwipeRefreshLayout.setRefreshing(false); + binding.swipeRefreshLayoutSubscribedSubscribedSubredditsMultiselectionActivity.setRefreshing(false); if (subscribedSubredditData == null || subscribedSubredditData.size() == 0) { - mRecyclerView.setVisibility(View.GONE); - mLinearLayout.setVisibility(View.VISIBLE); - mGlide.load(R.drawable.error_image).into(mImageView); + binding.recyclerViewSubscribedSubscribedSubredditsMultiselectionActivity.setVisibility(View.GONE); + binding.noSubscriptionsLinearLayoutSubscribedSubredditsMultiselectionActivity.setVisibility(View.VISIBLE); + mGlide.load(R.drawable.error_image).into(binding.noSubscriptionsImageViewSubscribedSubredditsMultiselectionActivity); } else { - mLinearLayout.setVisibility(View.GONE); - mRecyclerView.setVisibility(View.VISIBLE); - mGlide.clear(mImageView); + binding.noSubscriptionsLinearLayoutSubscribedSubredditsMultiselectionActivity.setVisibility(View.GONE); + binding.recyclerViewSubscribedSubscribedSubredditsMultiselectionActivity.setVisibility(View.VISIBLE); + mGlide.clear(binding.noSubscriptionsImageViewSubscribedSubredditsMultiselectionActivity); } mAdapter.setSubscribedSubreddits(subscribedSubredditData); @@ -228,11 +212,12 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act @Override protected void applyCustomTheme() { - mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar); - mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSubredditsMultiselectionActivity, + binding.collapsingToolbarLayoutSubscribedSubredditsMultiselectionActivity, binding.toolbarSubscribedSubredditsMultiselectionActivity); + binding.errorTextViewSubscribedSubredditsMultiselectionActivity.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); if (typeface != null) { - mErrorTextView.setTypeface(typeface); + binding.errorTextViewSubscribedSubredditsMultiselectionActivity.setTypeface(typeface); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java index fdd69a5c..af3c5cde 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java @@ -13,13 +13,8 @@ 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 com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.appbar.CollapsingToolbarLayout; - import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -30,8 +25,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.AnyAccountAccessTokenAuthenticator; import ml.docilealligator.infinityforreddit.FetchSubscribedThing; @@ -42,6 +35,7 @@ import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThings; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivitySubredditSelectionBinding; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.SubscribedSubredditsListingFragment; import ml.docilealligator.infinityforreddit.subreddit.SubredditData; @@ -64,14 +58,6 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS"; private static final String FRAGMENT_OUT_STATE = "FOS"; - @BindView(R.id.coordinator_layout_subreddit_selection_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_subreddit_selection_activity) - AppBarLayout appBarLayout; - @BindView(R.id.collapsing_toolbar_layout_subreddit_selection_activity) - CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.toolbar_subreddit_selection_activity) - Toolbar toolbar; @Inject @Named("no_oauth") Retrofit mRetrofit; @@ -93,6 +79,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity private String mAccountProfileImageUrl; private boolean mInsertSuccess = false; private Fragment mFragment; + private ActivitySubredditSelectionBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -100,9 +87,8 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity super.onCreate(savedInstanceState); - setContentView(R.layout.activity_subreddit_selection); - - ButterKnife.bind(this); + binding = ActivitySubredditSelectionBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); EventBus.getDefault().register(this); @@ -116,7 +102,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutSubredditSelectionActivity); } if (isImmersiveInterface()) { @@ -125,11 +111,11 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); + adjustToolbar(binding.toolbarSubredditSelectionActivity); } } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarSubredditSelectionActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (getIntent().hasExtra(EXTRA_SPECIFIED_ACCOUNT)) { @@ -181,8 +167,9 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSubredditSelectionActivity, + binding.collapsingToolbarLayoutSubredditSelectionActivity, binding.toolbarSubredditSelectionActivity); } private void bindView(boolean initializeFragment) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java index c995bd59..4b8d1a93 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java @@ -15,11 +15,9 @@ import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.view.inputmethod.EditorInfoCompat; import androidx.fragment.app.Fragment; @@ -27,11 +25,7 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.android.material.tabs.TabLayout; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -42,8 +36,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.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.FragmentCommunicator; @@ -55,8 +47,8 @@ import ml.docilealligator.infinityforreddit.asynctasks.DeleteMultiredditInDataba import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit; import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThings; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.customviews.ViewPagerBugFixed; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivitySubscribedThingListingBinding; import ml.docilealligator.infinityforreddit.events.GoBackToMainPageEvent; import ml.docilealligator.infinityforreddit.events.RefreshMultiRedditsEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; @@ -79,22 +71,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS"; private static final String INSERT_MULTIREDDIT_STATE = "IMS"; - @BindView(R.id.coordinator_layout_subscribed_thing_listing_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_subscribed_thing_listing_activity) - AppBarLayout appBarLayout; - @BindView(R.id.collapsing_toolbar_layout_subscribed_thing_listing_activity) - CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.toolbar_subscribed_thing_listing_activity) - Toolbar toolbar; - @BindView(R.id.search_edit_text_subscribed_thing_listing_activity) - EditText searchEditText; - @BindView(R.id.tab_layout_subscribed_thing_listing_activity) - TabLayout tabLayout; - @BindView(R.id.view_pager_subscribed_thing_listing_activity) - ViewPagerBugFixed viewPager; - @BindView(R.id.fab_subscribed_thing_listing_activity) - FloatingActionButton fab; @Inject @Named("oauth") Retrofit mOauthRetrofit; @@ -115,6 +91,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti private boolean showMultiReddits = false; private SectionsPagerAdapter sectionsPagerAdapter; private Menu mMenu; + private ActivitySubscribedThingListingBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -122,9 +99,8 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti super.onCreate(savedInstanceState); - setContentView(R.layout.activity_subscribed_thing_listing); - - ButterKnife.bind(this); + binding = ActivitySubscribedThingListingBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); EventBus.getDefault().register(this); @@ -138,7 +114,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutSubscribedThingListingActivity); } if (isImmersiveInterface()) { @@ -147,20 +123,20 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); + adjustToolbar(binding.toolbarSubscribedThingListingActivity); int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { - CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) binding.fabSubscribedThingListingActivity.getLayoutParams(); params.bottomMargin += navBarHeight; - fab.setLayoutParams(params); + binding.fabSubscribedThingListingActivity.setLayoutParams(params); } } } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarSubscribedThingListingActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.toolbarSubscribedThingListingActivity); if (savedInstanceState != null) { mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE); @@ -170,10 +146,10 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } if (accountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - searchEditText.setImeOptions(searchEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); + binding.searchEditTextSubscribedThingListingActivity.setImeOptions(binding.searchEditTextSubscribedThingListingActivity.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); } - searchEditText.addTextChangedListener(new TextWatcher() { + binding.searchEditTextSubscribedThingListingActivity.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { @@ -209,45 +185,46 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyTabLayoutTheme(tabLayout); - applyFABTheme(fab); - searchEditText.setTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); - searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarSecondaryTextColor()); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSubscribedThingListingActivity, + binding.collapsingToolbarLayoutSubscribedThingListingActivity, binding.toolbarSubscribedThingListingActivity); + applyTabLayoutTheme(binding.tabLayoutSubscribedThingListingActivity); + applyFABTheme(binding.fabSubscribedThingListingActivity); + binding.searchEditTextSubscribedThingListingActivity.setTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); + binding.searchEditTextSubscribedThingListingActivity.setHintTextColor(mCustomThemeWrapper.getToolbarSecondaryTextColor()); } private void initializeViewPagerAndLoadSubscriptions() { - fab.setOnClickListener(view -> { + binding.fabSubscribedThingListingActivity.setOnClickListener(view -> { Intent intent = new Intent(this, CreateMultiRedditActivity.class); startActivity(intent); }); sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); - viewPager.setAdapter(sectionsPagerAdapter); - viewPager.setOffscreenPageLimit(3); - if (viewPager.getCurrentItem() != 2) { - fab.hide(); + binding.viewPagerSubscribedThingListingActivity.setAdapter(sectionsPagerAdapter); + binding.viewPagerSubscribedThingListingActivity.setOffscreenPageLimit(3); + if (binding.viewPagerSubscribedThingListingActivity.getCurrentItem() != 2) { + binding.fabSubscribedThingListingActivity.hide(); } - viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { + binding.viewPagerSubscribedThingListingActivity.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (position == 0) { unlockSwipeRightToGoBack(); - fab.hide(); + binding.fabSubscribedThingListingActivity.hide(); } else { lockSwipeRightToGoBack(); if (position != 2) { - fab.hide(); + binding.fabSubscribedThingListingActivity.hide(); } else { - fab.show(); + binding.fabSubscribedThingListingActivity.show(); } } } }); - tabLayout.setupWithViewPager(viewPager); + binding.tabLayoutSubscribedThingListingActivity.setupWithViewPager(binding.viewPagerSubscribedThingListingActivity); if (showMultiReddits) { - viewPager.setCurrentItem(2, false); + binding.viewPagerSubscribedThingListingActivity.setCurrentItem(2, false); } loadSubscriptions(false); @@ -265,18 +242,18 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == R.id.action_search_subscribed_thing_listing_activity) { item.setVisible(false); - searchEditText.setVisibility(View.VISIBLE); - searchEditText.requestFocus(); - if (searchEditText.requestFocus()) { + binding.searchEditTextSubscribedThingListingActivity.setVisibility(View.VISIBLE); + binding.searchEditTextSubscribedThingListingActivity.requestFocus(); + if (binding.searchEditTextSubscribedThingListingActivity.requestFocus()) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(searchEditText, InputMethodManager.SHOW_IMPLICIT); + imm.showSoftInput(binding.searchEditTextSubscribedThingListingActivity, InputMethodManager.SHOW_IMPLICIT); } return true; } else if (item.getItemId() == android.R.id.home) { - if (searchEditText.getVisibility() == View.VISIBLE) { + if (binding.searchEditTextSubscribedThingListingActivity.getVisibility() == View.VISIBLE) { Utils.hideKeyboard(this); - searchEditText.setVisibility(View.GONE); - searchEditText.setText(""); + binding.searchEditTextSubscribedThingListingActivity.setVisibility(View.GONE); + binding.searchEditTextSubscribedThingListingActivity.setText(""); mMenu.findItem(R.id.action_search_subscribed_thing_listing_activity).setVisible(true); sectionsPagerAdapter.changeSearchQuery(""); return true; @@ -290,10 +267,10 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti @Override public void onBackPressed() { - if (searchEditText.getVisibility() == View.VISIBLE) { + if (binding.searchEditTextSubscribedThingListingActivity.getVisibility() == View.VISIBLE) { Utils.hideKeyboard(this); - searchEditText.setVisibility(View.GONE); - searchEditText.setText(""); + binding.searchEditTextSubscribedThingListingActivity.setVisibility(View.GONE); + binding.searchEditTextSubscribedThingListingActivity.setText(""); mMenu.findItem(R.id.action_search_subscribed_thing_listing_activity).setVisible(true); sectionsPagerAdapter.changeSearchQuery(""); } else { @@ -359,14 +336,14 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } public void showFabInMultiredditTab() { - if (viewPager.getCurrentItem() == 2) { - fab.show(); + if (binding.viewPagerSubscribedThingListingActivity.getCurrentItem() == 2) { + binding.fabSubscribedThingListingActivity.show(); } } public void hideFabInMultiredditTab() { - if (viewPager.getCurrentItem() == 2) { - fab.hide(); + if (binding.viewPagerSubscribedThingListingActivity.getCurrentItem() == 2) { + binding.fabSubscribedThingListingActivity.hide(); } } @@ -545,9 +522,9 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } void goBackToTop() { - if (viewPager.getCurrentItem() == 0) { + if (binding.viewPagerSubscribedThingListingActivity.getCurrentItem() == 0) { subscribedSubredditsListingFragment.goBackToTop(); - } else if (viewPager.getCurrentItem() == 1) { + } else if (binding.viewPagerSubscribedThingListingActivity.getCurrentItem() == 1) { followedUsersListingFragment.goBackToTop(); } else { multiRedditListingFragment.goBackToTop(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java index b192a6c6..d49682c5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java @@ -4,38 +4,20 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.os.Bundle; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.google.android.material.button.MaterialButton; -import com.google.android.material.checkbox.MaterialCheckBox; 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.ActivitySuicidePreventionBinding; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class SuicidePreventionActivity extends BaseActivity { static final String EXTRA_QUERY = "EQ"; static final String EXTRA_RETURN_QUERY = "ERQ"; - @BindView(R.id.linear_layout_suicide_prevention_activity) - LinearLayout linearLayout; - @BindView(R.id.quote_text_view_suicide_prevention_activity) - TextView quoteTextView; - @BindView(R.id.linear_layout_check_box_wrapper_suicide_prevention_activity) - LinearLayout checkBoxWrapperlinearLayout; - @BindView(R.id.do_not_show_this_again_check_box) - MaterialCheckBox doNotShowThisAgainCheckBox; - @BindView(R.id.do_not_show_this_again_text_view) - TextView doNotShowThisAgainTextView; - @BindView(R.id.continue_button_suicide_prevention_activity) - MaterialButton continueButton; + @Inject @Named("default") SharedPreferences mSharedPreferences; @@ -44,23 +26,25 @@ public class SuicidePreventionActivity extends BaseActivity { SharedPreferences mCurrentAccountSharedPreferences; @Inject CustomThemeWrapper mCustomThemeWrapper; + private ActivitySuicidePreventionBinding binding; + @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplicationContext()).getAppComponent().inject(this); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_suicide_prevention); - ButterKnife.bind(this); + binding = ActivitySuicidePreventionBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); applyCustomTheme(); - checkBoxWrapperlinearLayout.setOnClickListener(view -> { - doNotShowThisAgainCheckBox.performClick(); + binding.linearLayoutCheckBoxWrapperSuicidePreventionActivity.setOnClickListener(view -> { + binding.doNotShowThisAgainCheckBox.performClick(); }); - continueButton.setOnClickListener(view -> { - if (doNotShowThisAgainCheckBox.isChecked()) { + binding.continueButtonSuicidePreventionActivity.setOnClickListener(view -> { + if (binding.doNotShowThisAgainCheckBox.isChecked()) { mSharedPreferences.edit().putBoolean(SharedPreferencesUtils.SHOW_SUICIDE_PREVENTION_ACTIVITY, false).apply(); } Intent returnIntent = new Intent(); @@ -87,15 +71,15 @@ public class SuicidePreventionActivity extends BaseActivity { @Override protected void applyCustomTheme() { - linearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - quoteTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); - doNotShowThisAgainTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); - continueButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); - continueButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + binding.quoteTextViewSuicidePreventionActivity.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); + binding.doNotShowThisAgainTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); + binding.continueButtonSuicidePreventionActivity.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); + binding.continueButtonSuicidePreventionActivity.setTextColor(mCustomThemeWrapper.getButtonTextColor()); if (typeface != null) { - quoteTextView.setTypeface(typeface); - doNotShowThisAgainTextView.setTypeface(typeface); - continueButton.setTypeface(typeface); + binding.quoteTextViewSuicidePreventionActivity.setTypeface(typeface); + binding.doNotShowThisAgainTextView.setTypeface(typeface); + binding.continueButtonSuicidePreventionActivity.setTypeface(typeface); } } }
\ No newline at end of file diff --git a/app/src/main/res/layout/activity_select_user_flair.xml b/app/src/main/res/layout/activity_select_user_flair.xml index 92649ebf..09617b58 100644 --- a/app/src/main/res/layout/activity_select_user_flair.xml +++ b/app/src/main/res/layout/activity_select_user_flair.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_select_user_flair_activity" tools:context=".activities.SelectUserFlairActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_selected_subreddits.xml b/app/src/main/res/layout/activity_selected_subreddits.xml index 66dfa6f8..c9700c72 100644 --- a/app/src/main/res/layout/activity_selected_subreddits.xml +++ b/app/src/main/res/layout/activity_selected_subreddits.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_selected_subreddits_and_users_activity" tools:context=".activities.AccountPostsActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_send_private_message.xml b/app/src/main/res/layout/activity_send_private_message.xml index b70f857b..6f9c5e46 100644 --- a/app/src/main/res/layout/activity_send_private_message.xml +++ b/app/src/main/res/layout/activity_send_private_message.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_send_private_message_activity" tools:context=".activities.SendPrivateMessageActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_submit_crosspost.xml b/app/src/main/res/layout/activity_submit_crosspost.xml index d4771915..5412697e 100644 --- a/app/src/main/res/layout/activity_submit_crosspost.xml +++ b/app/src/main/res/layout/activity_submit_crosspost.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_submit_crosspost_activity" tools:context=".activities.SubmitCrosspostActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_subreddit_selection.xml b/app/src/main/res/layout/activity_subreddit_selection.xml index 78bac0d3..ea677d17 100644 --- a/app/src/main/res/layout/activity_subreddit_selection.xml +++ b/app/src/main/res/layout/activity_subreddit_selection.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_subreddit_selection_activity" tools:application=".SubredditSelectionActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml b/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml index 428047f4..4f7a26ad 100644 --- a/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml +++ b/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.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_subreddits_multiselection_activity" tools:application=".SubscribedSubredditsListingFragment"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_subscribed_thing_listing.xml b/app/src/main/res/layout/activity_subscribed_thing_listing.xml index 1d7c4fdd..dc645f64 100644 --- a/app/src/main/res/layout/activity_subscribed_thing_listing.xml +++ b/app/src/main/res/layout/activity_subscribed_thing_listing.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_subscribed_thing_listing_activity" tools:application=".SubscribedThingListingActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_suicide_prevention.xml b/app/src/main/res/layout/activity_suicide_prevention.xml index 1e48cb12..67577aab 100644 --- a/app/src/main/res/layout/activity_suicide_prevention.xml +++ b/app/src/main/res/layout/activity_suicide_prevention.xml @@ -5,7 +5,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:id="@+id/linear_layout_suicide_prevention_activity" tools:context=".activities.SuicidePreventionActivity"> <com.airbnb.lottie.LottieAnimationView |