aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-09 09:15:41 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-09 09:15:41 +0000
commit4c21eea852e08d0c65b3eb917b04404722d28f5d (patch)
treef5bd7cab804018e8e332de55677bb4d7e02b0d16 /app/src
parent1179cb50fa939c296e14233a9e8109babefe8760 (diff)
downloadinfinity-for-reddit-4c21eea852e08d0c65b3eb917b04404722d28f5d.tar
infinity-for-reddit-4c21eea852e08d0c65b3eb917b04404722d28f5d.tar.gz
infinity-for-reddit-4c21eea852e08d0c65b3eb917b04404722d28f5d.tar.bz2
infinity-for-reddit-4c21eea852e08d0c65b3eb917b04404722d28f5d.tar.lz
infinity-for-reddit-4c21eea852e08d0c65b3eb917b04404722d28f5d.tar.xz
infinity-for-reddit-4c21eea852e08d0c65b3eb917b04404722d28f5d.tar.zst
infinity-for-reddit-4c21eea852e08d0c65b3eb917b04404722d28f5d.zip
Display a toast to indicate the user to login before voting, replying and commeting.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java5
-rw-r--r--app/src/main/res/layout/activity_main.xml1
-rw-r--r--app/src/main/res/values/strings.xml1
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>