aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java28
-rw-r--r--app/src/main/res/menu/account_saved_thing_activity.xml6
2 files changed, 33 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
index 36a61624..1641c449 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
@@ -34,6 +34,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
@@ -47,7 +48,8 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
-public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface {
+public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface,
+ PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
private static final String ACCESS_TOKEN_STATE = "ATS";
@@ -75,6 +77,9 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
+ @Named("post_layout")
+ SharedPreferences mPostLayoutSharedPreferences;
+ @Inject
CustomThemeWrapper mCustomThemeWrapper;
private SectionsPagerAdapter sectionsPagerAdapter;
private SlidrInterface mSlidrInterface;
@@ -84,6 +89,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
private String mAccessToken;
private String mAccountName;
private boolean isInLazyMode = false;
+ private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -122,6 +128,8 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
+ postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
+
if (savedInstanceState != null) {
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
@@ -252,6 +260,9 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
}
return true;
+ case R.id.action_change_post_layout_account_saved_thing_activity:
+ postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
+ return true;
}
return false;
}
@@ -300,6 +311,14 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
}
+ @Override
+ public void postLayoutSelected(int postLayout) {
+ if (sectionsPagerAdapter != null) {
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + mAccountName, postLayout).apply();
+ sectionsPagerAdapter.changePostLayout(postLayout);
+ }
+ }
+
private class SectionsPagerAdapter extends FragmentPagerAdapter {
private PostFragment postFragment;
private CommentsListingFragment commentsListingFragment;
@@ -409,6 +428,13 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
}
+ public void changePostLayout(int postLayout) {
+ if (postFragment != null) {
+ ((FragmentCommunicator) postFragment).changePostLayout(postLayout);
+ }
+ }
+
+
public void goBackToTop() {
if (viewPager.getCurrentItem() == 0) {
postFragment.goBackToTop();
diff --git a/app/src/main/res/menu/account_saved_thing_activity.xml b/app/src/main/res/menu/account_saved_thing_activity.xml
index 0ec48123..b1e828b7 100644
--- a/app/src/main/res/menu/account_saved_thing_activity.xml
+++ b/app/src/main/res/menu/account_saved_thing_activity.xml
@@ -13,4 +13,10 @@
android:orderInCategory="2"
android:title="@string/action_start_lazy_mode"
app:showAsAction="never" />
+
+ <item
+ android:id="@+id/action_change_post_layout_account_saved_thing_activity"
+ android:orderInCategory="3"
+ android:title="@string/action_change_post_layout"
+ app:showAsAction="never" />
</menu>