mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-11 10:47:11 +01:00
Display a toast to indicate the user to login before voting, replying and commeting.
This commit is contained in:
parent
1179cb50fa
commit
4c21eea852
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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("")) {
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user