Add option to disable statistics block and post/comment score

As per users requested, I've added two options to the interface section:
1. Disable statistics (under users and community pages): Disables the statistics block on user/community pages
2. Disable post and comment scores: Disables the post and comment scores show on users pages
This commit is contained in:
Balazs Toldi 2023-08-19 22:25:26 +02:00
parent 0384914c16
commit 3322b5b4e8
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
11 changed files with 64 additions and 16 deletions

View File

@ -27,6 +27,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@ -184,6 +185,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@BindView(R.id.comment_count_image_view_view_subreddit_detail_activity)
ImageView nCommentsImageView;
@BindView(R.id.community_statistics_block_view_subreddit_detail_activity)
ConstraintLayout communityStatisticsBlock;
@BindView(R.id.description_text_view_view_subreddit_detail_activity)
TextView descriptionTextView;
@ -257,6 +261,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private int fabOption;
private MaterialAlertDialogBuilder nsfwWarningBuilder;
private boolean showStatistics;
private boolean hideSubredditDescription;
@Override
@ -270,6 +276,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
ButterKnife.bind(this);
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
showStatistics = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_STATISTICS, true);
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar),
findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar),
@ -592,17 +599,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
String nSubscribers = getString(R.string.subscribers_number_detail, subredditData.getNSubscribers());
nSubscribersTextView.setText(nSubscribers);
if (mCommunityStats != null) {
if (mCommunityStats != null && showStatistics) {
nActiveUsersTextView.setText(getString(R.string.active_users_number_detail, mCommunityStats.getActiveUsers()));
nPostsTextView.setText(getString(R.string.post_count_detail, mCommunityStats.getPosts()));
nCommentsTextView.setText(getString(R.string.comment_count_detail, mCommunityStats.getComments()));
} else {
nActiveUsersTextView.setVisibility(View.GONE);
nPostsTextView.setVisibility(View.GONE);
nCommentsTextView.setVisibility(View.GONE);
nActiveUsersImageView.setVisibility(View.GONE);
nPostsImageView.setVisibility(View.GONE);
nCommentsImageView.setVisibility(View.GONE);
communityStatisticsBlock.setVisibility(View.GONE);
}
description = subredditData.getDescription();

View File

@ -29,6 +29,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@ -197,9 +198,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
ImageView postsCountIconImageView;
@BindView(R.id.comments_count_icon_image_view_view_user_detail_activity)
ImageView commentsCountIconImageView;
@BindView(R.id.upvote_count_posts_icon_image_view_view_user_detail_activity)
ImageView postUpvoteCountIconImageView;
@BindView(R.id.upvote_count_comments_icon_image_view_view_user_detail_activity)
ImageView commentUpvoteCountIconImageView;
@BindView(R.id.account_created_cake_icon_image_view_view_user_detail_activity)
ImageView accountCreatedCakeIconImageView;
@BindView(R.id.user_statistics_block_view_user_detail_activity)
ConstraintLayout userStatisticsBlock;
@BindView(R.id.cake_day_text_view_view_user_detail_activity)
TextView cakedayTextView;
@BindView(R.id.description_text_view_view_user_detail_activity)
@ -250,6 +259,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private String qualifiedName;
private String description;
private boolean showStatistics;
private boolean showScore;
private boolean subscriptionReady = false;
private boolean mFetchUserInfoSuccess = false;
private int expandedTabTextColor;
@ -314,6 +326,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
showStatistics = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_STATISTICS, true);
showScore = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_POST_AND_COMMENT_SCORE, true);
if (savedInstanceState == null) {
mMessageId = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
@ -614,11 +628,20 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
cakedayTextView.setText((String) userData.getCakeday());
UserStats userStats = mUserData.getStats();
if (userStats != null) {
if (userStats != null && showStatistics) {
postCountTextView.setText(String.valueOf(userStats.getPostCount()));
commentCountTextView.setText(String.valueOf(userStats.getCommentCount()));
upvoteCountPostTextView.setText(String.valueOf(userStats.getPostScore()));
upvoteCountCommentTextView.setText(String.valueOf(userStats.getCommentScore()));
if (showScore) {
upvoteCountPostTextView.setText(String.valueOf(userStats.getPostScore()));
upvoteCountCommentTextView.setText(String.valueOf(userStats.getCommentScore()));
} else {
upvoteCountPostTextView.setVisibility(View.GONE);
upvoteCountCommentTextView.setVisibility(View.GONE);
postUpvoteCountIconImageView.setVisibility(View.GONE);
commentUpvoteCountIconImageView.setVisibility(View.GONE);
}
} else {
userStatisticsBlock.setVisibility(View.GONE);
}
if (userData.getDescription() == null || userData.getDescription().equals("")) {

View File

@ -411,4 +411,6 @@ public class SharedPreferencesUtils {
public static final String ACCOUNT_INSTANCE = "account_instance";
public static final String ACCOUNT_QUALIFIED_NAME = "account_qualified_name";
public static final String CAN_DOWNVOTE = "can_downvote";
public static final String SHOW_STATISTICS = "show_statistics";
public static final String SHOW_POST_AND_COMMENT_SCORE = "show_score";
}

View File

@ -79,7 +79,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp">
android:layout_marginBottom="16dp"
android:id="@+id/community_statistics_block_view_subreddit_detail_activity">
<ImageView
android:id="@+id/subscriber_count_image_view_view_subreddit_detail_activity"

View File

@ -85,7 +85,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:id="@+id/user_statistics_block_view_user_detail_activity">
<TextView
android:id="@+id/post_stats_text_view_view_user_detail_activity"

View File

@ -79,7 +79,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp">
android:layout_marginBottom="16dp"
android:id="@+id/community_statistics_block_view_subreddit_detail_activity">
<ImageView
android:id="@+id/subscriber_count_image_view_view_subreddit_detail_activity"

View File

@ -85,7 +85,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:id="@+id/user_statistics_block_view_user_detail_activity">
<TextView
android:id="@+id/post_stats_text_view_view_user_detail_activity"

View File

@ -78,7 +78,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp">
android:layout_marginBottom="16dp"
android:id="@+id/community_statistics_block_view_subreddit_detail_activity">
<ImageView
android:id="@+id/subscriber_count_image_view_view_subreddit_detail_activity"

View File

@ -85,7 +85,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:id="@+id/user_statistics_block_view_user_detail_activity">
<TextView
android:id="@+id/post_stats_text_view_view_user_detail_activity"

View File

@ -1372,4 +1372,7 @@
<string name="settings_show_display_name_instead_of_user_name">Show community and user display names</string>
<string name="report_post">Report Post</string>
<string name="send_report">Send Report</string>
<string name="settings_category_community_and_user_pages_title">Community and User pages</string>
<string name="settings_show_statistics">Show Statistics</string>
<string name="settings_show_post_and_comment_score">Show post and comment scores</string>
</resources>

View File

@ -86,4 +86,16 @@
app:key="show_absolute_number_of_votes"
app:title="@string/settings_show_absolute_number_of_votes_title" />
<eu.toldi.infinityforlemmy.customviews.CustomFontPreferenceCategory app:title="@string/settings_category_community_and_user_pages_title" />
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
app:defaultValue="true"
app:key="show_statistics"
app:title="@string/settings_show_statistics" />
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
app:defaultValue="true"
app:key="show_score"
app:title="@string/settings_show_post_and_comment_score" />
</PreferenceScreen>