move post notifications into home
closes sk22#314
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
|
import static org.joinmastodon.android.GlobalUserPreferences.showFederatedTimeline;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.AnimatorSet;
|
import android.animation.AnimatorSet;
|
||||||
@@ -109,7 +111,12 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
|||||||
|
|
||||||
fragments.add(new HomeTimelineFragment());
|
fragments.add(new HomeTimelineFragment());
|
||||||
fragments.add(new LocalTimelineFragment());
|
fragments.add(new LocalTimelineFragment());
|
||||||
if (GlobalUserPreferences.showFederatedTimeline) fragments.add(new FederatedTimelineFragment());
|
if (showFederatedTimeline) fragments.add(new FederatedTimelineFragment());
|
||||||
|
args=new Bundle(args);
|
||||||
|
args.putBoolean("onlyPosts", true);
|
||||||
|
NotificationsListFragment postsFragment=new NotificationsListFragment();
|
||||||
|
postsFragment.setArguments(args);
|
||||||
|
fragments.add(postsFragment);
|
||||||
|
|
||||||
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
|
||||||
for (int i = 0; i < fragments.size(); i++) {
|
for (int i = 0; i < fragments.size(); i++) {
|
||||||
@@ -302,7 +309,7 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
|||||||
|
|
||||||
private void updateSwitcherMenu() {
|
private void updateSwitcherMenu() {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
switcherPopup.getMenu().findItem(R.id.federated).setVisible(GlobalUserPreferences.showFederatedTimeline);
|
switcherPopup.getMenu().findItem(R.id.federated).setVisible(showFederatedTimeline);
|
||||||
|
|
||||||
if (!listItems.isEmpty()) {
|
if (!listItems.isEmpty()) {
|
||||||
MenuItem listsItem = switcherPopup.getMenu().findItem(R.id.lists);
|
MenuItem listsItem = switcherPopup.getMenu().findItem(R.id.lists);
|
||||||
@@ -342,6 +349,8 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
|||||||
} else if (id == R.id.federated) {
|
} else if (id == R.id.federated) {
|
||||||
navigateTo(2);
|
navigateTo(2);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (id == R.id.post_notifications) {
|
||||||
|
navigateTo(showFederatedTimeline ? 3 : 2);
|
||||||
} else if ((list = listItems.get(id)) != null) {
|
} else if ((list = listItems.get(id)) != null) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
@@ -365,16 +374,22 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateSwitcherIcon(int i) {
|
private void updateSwitcherIcon(int i) {
|
||||||
timelineIcon.setImageResource(switch (i) {
|
// todo: refactor when implementing pinned tabs
|
||||||
default -> R.drawable.ic_fluent_home_24_regular;
|
if (i == (showFederatedTimeline ? 3 : 2)) {
|
||||||
case 1 -> R.drawable.ic_fluent_people_community_24_regular;
|
timelineIcon.setImageResource(R.drawable.ic_fluent_alert_24_regular);
|
||||||
case 2 -> R.drawable.ic_fluent_earth_24_regular;
|
timelineTitle.setText(R.string.sk_notify_posts);
|
||||||
});
|
} else {
|
||||||
timelineTitle.setText(switch (i) {
|
timelineIcon.setImageResource(switch (i) {
|
||||||
default -> R.string.sk_timeline_home;
|
default -> R.drawable.ic_fluent_home_24_regular;
|
||||||
case 1 -> R.string.sk_timeline_local;
|
case 1 -> R.drawable.ic_fluent_people_community_24_regular;
|
||||||
case 2 -> R.string.sk_timeline_federated;
|
case 2 -> R.drawable.ic_fluent_earth_24_regular;
|
||||||
});
|
});
|
||||||
|
timelineTitle.setText(switch (i) {
|
||||||
|
default -> R.string.sk_timeline_home;
|
||||||
|
case 1 -> R.string.sk_timeline_local;
|
||||||
|
case 2 -> R.string.sk_timeline_federated;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
private FrameLayout[] tabViews;
|
private FrameLayout[] tabViews;
|
||||||
private TabLayoutMediator tabLayoutMediator;
|
private TabLayoutMediator tabLayoutMediator;
|
||||||
|
|
||||||
private NotificationsListFragment allNotificationsFragment, mentionsFragment, postsFragment;
|
private NotificationsListFragment allNotificationsFragment, mentionsFragment;
|
||||||
|
|
||||||
private String accountID;
|
private String accountID;
|
||||||
|
|
||||||
@@ -104,13 +104,12 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
pager=view.findViewById(R.id.pager);
|
pager=view.findViewById(R.id.pager);
|
||||||
UiUtils.reduceSwipeSensitivity(pager);
|
UiUtils.reduceSwipeSensitivity(pager);
|
||||||
|
|
||||||
tabViews=new FrameLayout[3];
|
tabViews=new FrameLayout[2];
|
||||||
for(int i=0;i<tabViews.length;i++){
|
for(int i=0;i<tabViews.length;i++){
|
||||||
FrameLayout tabView=new FrameLayout(getActivity());
|
FrameLayout tabView=new FrameLayout(getActivity());
|
||||||
tabView.setId(switch(i){
|
tabView.setId(switch(i){
|
||||||
case 0 -> R.id.notifications_all;
|
case 0 -> R.id.notifications_all;
|
||||||
case 1 -> R.id.notifications_mentions;
|
case 1 -> R.id.notifications_mentions;
|
||||||
case 2 -> R.id.notifications_posts;
|
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+i);
|
default -> throw new IllegalStateException("Unexpected value: "+i);
|
||||||
});
|
});
|
||||||
tabView.setVisibility(View.GONE);
|
tabView.setVisibility(View.GONE);
|
||||||
@@ -150,15 +149,9 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
mentionsFragment=new NotificationsListFragment();
|
mentionsFragment=new NotificationsListFragment();
|
||||||
mentionsFragment.setArguments(args);
|
mentionsFragment.setArguments(args);
|
||||||
|
|
||||||
args=new Bundle(args);
|
|
||||||
args.putBoolean("onlyPosts", true);
|
|
||||||
postsFragment=new NotificationsListFragment();
|
|
||||||
postsFragment.setArguments(args);
|
|
||||||
|
|
||||||
getChildFragmentManager().beginTransaction()
|
getChildFragmentManager().beginTransaction()
|
||||||
.add(R.id.notifications_all, allNotificationsFragment)
|
.add(R.id.notifications_all, allNotificationsFragment)
|
||||||
.add(R.id.notifications_mentions, mentionsFragment)
|
.add(R.id.notifications_mentions, mentionsFragment)
|
||||||
.add(R.id.notifications_posts, postsFragment)
|
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +161,6 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
tab.setText(switch(position){
|
tab.setText(switch(position){
|
||||||
case 0 -> R.string.all_notifications;
|
case 0 -> R.string.all_notifications;
|
||||||
case 1 -> R.string.mentions;
|
case 1 -> R.string.mentions;
|
||||||
case 2 -> R.string.posts;
|
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+position);
|
default -> throw new IllegalStateException("Unexpected value: "+position);
|
||||||
});
|
});
|
||||||
tab.view.textView.setAllCaps(true);
|
tab.view.textView.setAllCaps(true);
|
||||||
@@ -217,7 +209,6 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
return switch(page){
|
return switch(page){
|
||||||
case 0 -> allNotificationsFragment;
|
case 0 -> allNotificationsFragment;
|
||||||
case 1 -> mentionsFragment;
|
case 1 -> mentionsFragment;
|
||||||
case 2 -> postsFragment;
|
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+page);
|
default -> throw new IllegalStateException("Unexpected value: "+page);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -238,7 +229,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount(){
|
public int getItemCount(){
|
||||||
return 3;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.joinmastodon.android.ui.displayitems.AccountCardStatusDisplayItem;
|
|||||||
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.ImageStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.ImageStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
||||||
|
import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper;
|
||||||
import org.joinmastodon.android.ui.utils.InsetStatusItemDecoration;
|
import org.joinmastodon.android.ui.utils.InsetStatusItemDecoration;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
private boolean onlyMentions;
|
private boolean onlyMentions;
|
||||||
private boolean onlyPosts;
|
private boolean onlyPosts;
|
||||||
private String maxID;
|
private String maxID;
|
||||||
|
private final DiscoverInfoBannerHelper bannerHelper = new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.POST_NOTIFICATIONS);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
@@ -175,6 +177,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
public void onViewCreated(View view, Bundle savedInstanceState){
|
public void onViewCreated(View view, Bundle savedInstanceState){
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
list.addItemDecoration(new InsetStatusItemDecoration(this));
|
list.addItemDecoration(new InsetStatusItemDecoration(this));
|
||||||
|
if (onlyPosts) bannerHelper.maybeAddBanner(contentWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Notification getNotificationByID(String id){
|
private Notification getNotificationByID(String id){
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public class DiscoverInfoBannerHelper{
|
|||||||
case TRENDING_LINKS -> R.string.trending_links_info_banner;
|
case TRENDING_LINKS -> R.string.trending_links_info_banner;
|
||||||
case LOCAL_TIMELINE -> R.string.local_timeline_info_banner;
|
case LOCAL_TIMELINE -> R.string.local_timeline_info_banner;
|
||||||
case FEDERATED_TIMELINE -> R.string.sk_federated_timeline_info_banner;
|
case FEDERATED_TIMELINE -> R.string.sk_federated_timeline_info_banner;
|
||||||
|
case POST_NOTIFICATIONS -> R.string.sk_notify_posts_info_banner;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,6 +62,7 @@ public class DiscoverInfoBannerHelper{
|
|||||||
TRENDING_LINKS,
|
TRENDING_LINKS,
|
||||||
LOCAL_TIMELINE,
|
LOCAL_TIMELINE,
|
||||||
FEDERATED_TIMELINE,
|
FEDERATED_TIMELINE,
|
||||||
|
POST_NOTIFICATIONS,
|
||||||
// ACCOUNTS
|
// ACCOUNTS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<item android:id="@+id/home" android:icon="@drawable/ic_fluent_home_24_regular" android:title="@string/sk_timeline_home" />
|
<item android:id="@+id/home" android:icon="@drawable/ic_fluent_home_24_regular" android:title="@string/sk_timeline_home" />
|
||||||
<item android:id="@+id/local" android:icon="@drawable/ic_fluent_people_community_24_regular" android:title="@string/sk_timeline_local" />
|
<item android:id="@+id/local" android:icon="@drawable/ic_fluent_people_community_24_regular" android:title="@string/sk_timeline_local" />
|
||||||
<item android:id="@+id/federated" android:icon="@drawable/ic_fluent_earth_24_regular" android:title="@string/sk_timeline_federated" />
|
<item android:id="@+id/federated" android:icon="@drawable/ic_fluent_earth_24_regular" android:title="@string/sk_timeline_federated" />
|
||||||
|
<item android:id="@+id/post_notifications" android:icon="@drawable/ic_fluent_alert_24_regular" android:title="@string/sk_notify_posts" />
|
||||||
<item android:id="@+id/lists" android:icon="@drawable/ic_fluent_people_list_24_regular" android:title="@string/sk_list_timelines" android:visible="false">
|
<item android:id="@+id/lists" android:icon="@drawable/ic_fluent_people_list_24_regular" android:title="@string/sk_list_timelines" android:visible="false">
|
||||||
<menu />
|
<menu />
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
<item name="notifications_all" type="id"/>
|
<item name="notifications_all" type="id"/>
|
||||||
<item name="notifications_mentions" type="id"/>
|
<item name="notifications_mentions" type="id"/>
|
||||||
<item name="notifications_posts" type="id"/>
|
|
||||||
|
|
||||||
<item name="timeline_home" type="id" />
|
<item name="timeline_home" type="id" />
|
||||||
</resources>
|
</resources>
|
||||||
@@ -153,4 +153,5 @@
|
|||||||
<string name="sk_alt_text_missing">At least one attachment does not contain a description.</string>
|
<string name="sk_alt_text_missing">At least one attachment does not contain a description.</string>
|
||||||
<string name="sk_publish_anyway">Publish anyway</string>
|
<string name="sk_publish_anyway">Publish anyway</string>
|
||||||
<string name="sk_settings_disable_alt_text_reminder">Disable alt text reminder</string>
|
<string name="sk_settings_disable_alt_text_reminder">Disable alt text reminder</string>
|
||||||
|
<string name="sk_notify_posts_info_banner">If you enable post notifications for some people, their new posts will appear here.</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user