diff options
Diffstat (limited to 'app/src/main')
7 files changed, 57 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java index 0360abe8..25005db0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java @@ -721,6 +721,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie }); mUpvoteButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + if(mPost.isArchived()) { Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show(); return; @@ -780,6 +785,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie }); mDownvoteButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + if(mPost.isArchived()) { Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show(); return; @@ -882,6 +892,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie }); replyButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + Intent intent = new Intent(mActivity, CommentActivity.class); intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, mVisibleComments.get(getAdapterPosition() - 1).getDepth() + 1); intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, mVisibleComments.get(getAdapterPosition() - 1).getCommentContent()); @@ -892,6 +907,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie }); upvoteButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + int previousVoteType = mVisibleComments.get(getAdapterPosition() - 1).getVoteType(); String newVoteType; @@ -932,6 +952,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie }); downvoteButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + int previousVoteType = mVisibleComments.get(getAdapterPosition() - 1).getVoteType(); String newVoteType; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java index e61cca11..6cd7d189 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java @@ -9,6 +9,7 @@ import android.widget.Button; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.cardview.widget.CardView; @@ -205,6 +206,11 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R replyButton.setVisibility(View.GONE); upvoteButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + int previousVoteType = getItem(getAdapterPosition()).getVoteType(); String newVoteType; @@ -245,6 +251,11 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R }); downvoteButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + int previousVoteType = getItem(getAdapterPosition()).getVoteType(); String newVoteType; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index a2e19cdc..07e545b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -68,6 +68,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe @BindView(R.id.all_drawer_items_linear_layout_main_activity) LinearLayout allDrawerItemsLinearLayout; @BindView(R.id.profile_linear_layout_main_activity) LinearLayout profileLinearLayout; @BindView(R.id.subscriptions_linear_layout_main_activity) LinearLayout subscriptionLinearLayout; + @BindView(R.id.divider_main_activity) View divider; @BindView(R.id.settings_linear_layout_main_activity) LinearLayout settingsLinearLayout; @BindView(R.id.account_recycler_view_main_activity) RecyclerView accountRecyclerView; @BindView(R.id.tab_layout_main_activity) TabLayout tabLayout; @@ -168,11 +169,6 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { if(account == null) { mNullAccessToken = true; - mAccessToken = null; - mAccountName = null; - mProfileImageUrl = null; - mBannerImageUrl = null; - mKarma = 0; } else { mNullAccessToken = false; mAccessToken = account.getAccessToken(); @@ -303,6 +299,9 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe } else { mKarmaTextView.setText(R.string.press_here_to_login); mAccountNameTextView.setText(R.string.anonymous_account); + profileLinearLayout.setVisibility(View.GONE); + subscriptionLinearLayout.setVisibility(View.GONE); + divider.setVisibility(View.GONE); } if (mProfileImageUrl != null && !mProfileImageUrl.equals("")) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java index 3519633e..c669d14a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java @@ -452,6 +452,11 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo } ((DataViewHolder) holder).upvoteButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + if(isArchived) { Toast.makeText(mContext, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show(); return; @@ -511,6 +516,11 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo }); ((DataViewHolder) holder).downvoteButton.setOnClickListener(view -> { + if(mAccessToken == null) { + Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show(); + return; + } + if(isArchived) { Toast.makeText(mContext, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show(); return; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index 40f6bc07..77be5762 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -415,6 +415,11 @@ public class ViewPostDetailActivity extends AppCompatActivity { refresh(); return true; case R.id.action_comment_view_post_detail_activity: + if(mAccessToken == null) { + Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show(); + return true; + } + Intent intent = new Intent(this, CommentActivity.class); intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, mPost.getTitle()); intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, mPost.getFullName()); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ba4d146c..b1572144 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -91,6 +91,7 @@ </LinearLayout> <View + android:id="@+id/divider_main_activity" android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/dividerColor" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 32b68cbd..f76c1e66 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -177,4 +177,5 @@ <string name="manage_accounts">Manage accounts</string> <string name="log_out">Log out</string> <string name="press_here_to_login">Press here to login</string> + <string name="login_first">Login first</string> </resources> |