mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-11 18:57:11 +01:00
Set post layout for subreddit and user posts individually.
This commit is contained in:
parent
d7928436fe
commit
74ae9a8b68
@ -286,7 +286,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
@Override
|
||||
public void postLayoutSelected(int postLayout) {
|
||||
if (mFragment != null) {
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST, postLayout).apply();
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + mAccountName, postLayout).apply();
|
||||
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
||||
}
|
||||
}
|
||||
|
@ -384,10 +384,10 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply();
|
||||
break;
|
||||
case PostDataSource.TYPE_SUBREDDIT:
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST, postLayout).apply();
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + name, postLayout).apply();
|
||||
break;
|
||||
case PostDataSource.TYPE_USER:
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST, postLayout).apply();
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + name, postLayout).apply();
|
||||
break;
|
||||
case PostDataSource.TYPE_SEARCH:
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, postLayout).apply();
|
||||
|
@ -626,7 +626,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
@Override
|
||||
public void postLayoutSelected(int postLayout) {
|
||||
if (mFragment != null) {
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST, postLayout).apply();
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, postLayout).apply();
|
||||
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
||||
}
|
||||
}
|
||||
|
@ -808,7 +808,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
void changePostLayout(int postLayout) {
|
||||
if (postFragment != null) {
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST, postLayout).apply();
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, postLayout).apply();
|
||||
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
||||
}
|
||||
}
|
||||
|
@ -260,8 +260,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
}
|
||||
}
|
||||
|
||||
((PostViewHolder) holder).subredditTextView.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
|
||||
|
||||
((PostViewHolder) holder).subredditTextView.setOnClickListener(view -> {
|
||||
if (canStartActivity) {
|
||||
canStartActivity = false;
|
||||
@ -273,7 +271,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
} else {
|
||||
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
||||
post.getSubredditNamePrefixed().substring(2));
|
||||
post.getSubredditName());
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@ -315,19 +313,24 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
.into(((PostViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
|
||||
((PostViewHolder) holder).subredditTextView.setTextColor(mContext.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme));
|
||||
|
||||
((PostViewHolder) holder).subredditTextView.setOnClickListener(view -> {
|
||||
if (canStartActivity) {
|
||||
canStartActivity = false;
|
||||
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
|
||||
mContext.startActivity(intent);
|
||||
if (post.getSubredditNamePrefixed().startsWith("u/")) {
|
||||
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
||||
post.getSubredditName());
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
((PostViewHolder) holder).iconGifImageView.setOnClickListener(view ->
|
||||
((PostViewHolder) holder).subredditTextView.performClick());
|
||||
((PostViewHolder) holder).userTextView.performClick());
|
||||
}
|
||||
|
||||
((PostViewHolder) holder).postTimeTextView.setText(postTime);
|
||||
|
@ -345,7 +345,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST, SortType.Time.ALL.name());
|
||||
}
|
||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
||||
}
|
||||
|
||||
if(sortTime != null) {
|
||||
@ -398,7 +398,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
} else {
|
||||
sortType = new SortType(SortType.Type.valueOf(sort));
|
||||
}
|
||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
||||
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
||||
|
@ -50,8 +50,8 @@ public class SharedPreferencesUtils {
|
||||
public static final String POST_LAYOUT_FRONT_PAGE_POST = "post_layout_best_post";
|
||||
public static final String POST_LAYOUT_POPULAR_POST = "post_layout_popular_post";
|
||||
public static final String POST_LAYOUT_ALL_POST = "post_layout_all_post";
|
||||
public static final String POST_LAYOUT_SUBREDDIT_POST = "post_layout_subreddit_post";
|
||||
public static final String POST_LAYOUT_USER_POST = "post_layout_user_post";
|
||||
public static final String POST_LAYOUT_SUBREDDIT_POST_BASE = "post_layout_subreddit_post_";
|
||||
public static final String POST_LAYOUT_USER_POST_BASE = "post_layout_user_post_";
|
||||
public static final String POST_LAYOUT_SEARCH_POST = "post_layout_search_post";
|
||||
public static final int POST_LAYOUT_CARD = 0;
|
||||
public static final int POST_LAYOUT_COMPACT = 1;
|
||||
|
@ -113,7 +113,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="?attr/font_12"
|
||||
android:textSize="?attr/font_10"
|
||||
app:lib_setRadius="3dp"
|
||||
app:lib_setRoundedBGColor="@color/backgroundColorPrimaryDark"
|
||||
app:lib_setRoundedBorderColor="@color/backgroundColorPrimaryDark"
|
||||
@ -128,7 +128,7 @@
|
||||
android:padding="4dp"
|
||||
android:text="@string/spoiler"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="?attr/font_12"
|
||||
android:textSize="?attr/font_10"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="3dp"
|
||||
app:lib_setRoundedBGColor="@color/spoilerBackgroundColor"
|
||||
@ -143,7 +143,7 @@
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="?attr/font_12"
|
||||
android:textSize="?attr/font_10"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="3dp"
|
||||
app:lib_setRoundedBGColor="@color/colorAccent"
|
||||
@ -158,7 +158,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:padding="4dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="?attr/font_12"
|
||||
android:textSize="?attr/font_10"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="3dp"
|
||||
app:lib_setRoundedBGColor="@color/flairBackgroundColor"
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
<declare-styleable name="FontStyle">
|
||||
<attr name="font_default" format="dimension"/>
|
||||
<attr name="font_10" format="dimension" />
|
||||
<attr name="font_12" format="dimension"/>
|
||||
<attr name="font_16" format="dimension"/>
|
||||
<attr name="font_18" format="dimension"/>
|
||||
|
@ -95,6 +95,7 @@
|
||||
|
||||
<style name="FontStyle.Small">
|
||||
<item name="font_default">12sp</item>
|
||||
<item name="font_10">10sp</item>
|
||||
<item name="font_12">12sp</item>
|
||||
<item name="font_16">14sp</item>
|
||||
<item name="font_18">16sp</item>
|
||||
@ -103,6 +104,7 @@
|
||||
|
||||
<style name="FontStyle.Normal">
|
||||
<item name="font_default">14sp</item>
|
||||
<item name="font_10">10sp</item>
|
||||
<item name="font_12">12sp</item>
|
||||
<item name="font_16">16sp</item>
|
||||
<item name="font_18">18sp</item>
|
||||
@ -111,6 +113,7 @@
|
||||
|
||||
<style name="FontStyle.Large">
|
||||
<item name="font_default">16sp</item>
|
||||
<item name="font_10">12sp</item>
|
||||
<item name="font_12">14sp</item>
|
||||
<item name="font_16">18sp</item>
|
||||
<item name="font_18">20sp</item>
|
||||
@ -119,6 +122,7 @@
|
||||
|
||||
<style name="FontStyle.XLarge">
|
||||
<item name="font_default">18sp</item>
|
||||
<item name="font_10">14sp</item>
|
||||
<item name="font_12">16sp</item>
|
||||
<item name="font_16">20sp</item>
|
||||
<item name="font_18">22sp</item>
|
||||
|
Loading…
Reference in New Issue
Block a user