Reorder notification tabs and remember selection (AND-82)

This commit is contained in:
Grishka 2023-10-17 03:00:05 +03:00
parent 02729fe02b
commit 1f7155a932
4 changed files with 25 additions and 27 deletions

View File

@ -268,4 +268,12 @@ public class AccountSession{
public void updateAccountInfo(){
AccountSessionManager.getInstance().updateSessionLocalInfo(this);
}
public boolean isNotificationsMentionsOnly(){
return getRawLocalPreferences().getBoolean("notificationsMentionsOnly", false);
}
public void setNotificationsMentionsOnly(boolean mentionsOnly){
getRawLocalPreferences().edit().putBoolean("notificationsMentionsOnly", mentionsOnly).apply();
}
}

View File

@ -44,7 +44,7 @@ import me.grishka.appkit.Nav;
import me.grishka.appkit.api.SimpleCallback;
public class NotificationsListFragment extends BaseStatusListFragment<Notification>{
private boolean onlyMentions=true;
private boolean onlyMentions;
private String maxID;
private View tabBar;
private View mentionsTab, allTab;
@ -58,9 +58,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
super.onCreate(savedInstanceState);
setLayout(R.layout.fragment_notifications);
E.register(this);
if(savedInstanceState!=null){
onlyMentions=savedInstanceState.getBoolean("onlyMentions", true);
}
onlyMentions=AccountSessionManager.get(accountID).isNotificationsMentionsOnly();
setHasOptionsMenu(true);
}
@ -133,12 +131,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
super.onShown();
unreadMarker=realUnreadMarker=AccountSessionManager.get(accountID).getLastKnownNotificationsMarker();
if(!dataLoading){
if(onlyMentions){
refresh();
}else{
reloadingFromCache=true;
refresh();
}
reloadingFromCache=true;
refresh();
}
}
@ -221,12 +215,6 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
return views;
}
@Override
public void onSaveInstanceState(Bundle outState){
super.onSaveInstanceState(outState);
outState.putBoolean("onlyMentions", onlyMentions);
}
private Notification getNotificationByID(String id){
for(Notification n:data){
if(n.id.equals(id))
@ -291,8 +279,10 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
allTab.setSelected(!onlyMentions);
maxID=null;
showProgress();
loadData(0, 20);
refreshing=true;
reloadingFromCache=true;
loadData(0, 20);
AccountSessionManager.get(accountID).setNotificationsMentionsOnly(onlyMentions);
}
@Override

View File

@ -31,7 +31,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
public StatusPrivacy visibility;
public boolean sensitive;
@RequiredField
public String spoilerText;
public String spoilerText="";
@RequiredField
public List<Attachment> mediaAttachments;
public Application application;

View File

@ -35,15 +35,6 @@
android:layout_gravity="center"
style="@style/Widget.Mastodon.M3.SegmentedButtonContainer">
<FrameLayout
android:id="@+id/mentions_tab"
style="@style/Widget.Mastodon.M3.SegmentedButton">
<org.joinmastodon.android.ui.views.CheckIconSelectableTextView
android:id="@+id/mentions_text"
style="@style/Widget.Mastodon.M3.SegmentedButtonText"
android:text="@string/mentions"/>
</FrameLayout>
<FrameLayout
android:id="@+id/all_tab"
style="@style/Widget.Mastodon.M3.SegmentedButton">
@ -53,6 +44,15 @@
android:text="@string/all_notifications"/>
</FrameLayout>
<FrameLayout
android:id="@+id/mentions_tab"
style="@style/Widget.Mastodon.M3.SegmentedButton">
<org.joinmastodon.android.ui.views.CheckIconSelectableTextView
android:id="@+id/mentions_text"
style="@style/Widget.Mastodon.M3.SegmentedButtonText"
android:text="@string/mentions"/>
</FrameLayout>
</LinearLayout>
</FrameLayout>