Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +50 −42 Original line number Diff line number Diff line Loading @@ -278,6 +278,34 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt mamageNewIntent(intent); } /** * Open notifications tab when coming from a notification device * * @param intent - Intent intent that will be cancelled */ private void openNotifications(Intent intent) { final Handler handler = new Handler(); handler.postDelayed(() -> { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); if (!singleBar) { binding.bottomNavView.setSelectedItemId(R.id.nav_notifications); } else { int position = 0; for (int i = 0; i < binding.tabLayout.getTabCount(); i++) { TabLayout.Tab tab = binding.tabLayout.getTabAt(i); if (tab != null && tab.getTag() != null && tab.getTag().equals(Timeline.TimeLineEnum.NOTIFICATION.getValue())) { break; } position++; } binding.viewPager.setCurrentItem(position); } }, 1000); intent.removeExtra(Helper.INTENT_ACTION); } @SuppressLint("ApplySharedPref") private void mamageNewIntent(Intent intent) { if (intent == null) Loading @@ -290,6 +318,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt userIdIntent = extras.getString(Helper.PREF_KEY_ID); //Id of the account in the intent instanceIntent = extras.getString(Helper.PREF_INSTANCE); if (extras.getInt(Helper.INTENT_ACTION) == Helper.NOTIFICATION_INTENT) { if (userIdIntent != null && instanceIntent != null && userIdIntent.equals(currentUserID) && instanceIntent.equals(currentInstance)) { openNotifications(intent); } else { try { BaseAccount account = new Account(BaseMainActivity.this).getUniqAccount(userIdIntent, instanceIntent); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); Loading @@ -308,32 +339,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } catch (DBException e) { e.printStackTrace(); } } else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) { final Handler handler = new Handler(); handler.postDelayed(() -> { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); if (!singleBar) { int position = BottomMenu.getPosition(bottomMenu, R.id.nav_notifications); if (position > 0 && binding.bottomNavView.getMenu().size() < position) { binding.bottomNavView.getMenu().getItem(position).setChecked(true); binding.viewPager.setCurrentItem(position); } } else { int position = 0; for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) { if (pinnedTimeline.type == Timeline.TimeLineEnum.NOTIFICATION && binding.bottomNavView.getMenu().size() < position) { binding.bottomNavView.getMenu().getItem(position).setChecked(true); binding.viewPager.setCurrentItem(position); break; } position++; } } }, 2000); intent.removeExtra(Helper.INTENT_ACTION); } else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) { openNotifications(intent); } } else if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { Loading app/src/main/java/app/fedilab/android/helper/Helper.java +2 −3 Original line number Diff line number Diff line Loading @@ -1550,17 +1550,16 @@ public class Helper { notificationBuilder.setLargeIcon(icon); Notification summaryNotification = summaryNotification = new NotificationCompat.Builder(context, channelId) Notification summaryNotification = new NotificationCompat.Builder(context, channelId) .setContentTitle(title) .setContentText(channelTitle) .setContentIntent(pIntent) .setLargeIcon(icon) .setSmallIcon(R.drawable.ic_notification) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setGroup(account.mastodon_account != null ? account.mastodon_account.acct : "" + "@" + account.instance) .setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "" + "@" + account.instance) .setGroupSummary(true) .build(); notificationManager.notify(notificationId++, notificationBuilder.build()); notificationManager.notify(0, summaryNotification); } Loading app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java +0 −4 Original line number Diff line number Diff line Loading @@ -40,8 +40,6 @@ import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.transition.Transition; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.IOException; import java.util.ArrayList; Loading Loading @@ -137,7 +135,6 @@ public class NotificationsHelper { .connectTimeout(60, TimeUnit.SECONDS) .proxy(Helper.getProxy(context)) .build(); Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create(); Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://" + instance + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) Loading Loading @@ -180,7 +177,6 @@ public class NotificationsHelper { Helper.NotifType notifType = Helper.NotifType.MENTION; switch (notification.type) { case "mention": notifType = Helper.NotifType.MENTION; if (notif_mention) { if (notification.account.display_name != null && notification.account.display_name.length() > 0) title = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_mention)); Loading Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +50 −42 Original line number Diff line number Diff line Loading @@ -278,6 +278,34 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt mamageNewIntent(intent); } /** * Open notifications tab when coming from a notification device * * @param intent - Intent intent that will be cancelled */ private void openNotifications(Intent intent) { final Handler handler = new Handler(); handler.postDelayed(() -> { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); if (!singleBar) { binding.bottomNavView.setSelectedItemId(R.id.nav_notifications); } else { int position = 0; for (int i = 0; i < binding.tabLayout.getTabCount(); i++) { TabLayout.Tab tab = binding.tabLayout.getTabAt(i); if (tab != null && tab.getTag() != null && tab.getTag().equals(Timeline.TimeLineEnum.NOTIFICATION.getValue())) { break; } position++; } binding.viewPager.setCurrentItem(position); } }, 1000); intent.removeExtra(Helper.INTENT_ACTION); } @SuppressLint("ApplySharedPref") private void mamageNewIntent(Intent intent) { if (intent == null) Loading @@ -290,6 +318,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt userIdIntent = extras.getString(Helper.PREF_KEY_ID); //Id of the account in the intent instanceIntent = extras.getString(Helper.PREF_INSTANCE); if (extras.getInt(Helper.INTENT_ACTION) == Helper.NOTIFICATION_INTENT) { if (userIdIntent != null && instanceIntent != null && userIdIntent.equals(currentUserID) && instanceIntent.equals(currentInstance)) { openNotifications(intent); } else { try { BaseAccount account = new Account(BaseMainActivity.this).getUniqAccount(userIdIntent, instanceIntent); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); Loading @@ -308,32 +339,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } catch (DBException e) { e.printStackTrace(); } } else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) { final Handler handler = new Handler(); handler.postDelayed(() -> { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); if (!singleBar) { int position = BottomMenu.getPosition(bottomMenu, R.id.nav_notifications); if (position > 0 && binding.bottomNavView.getMenu().size() < position) { binding.bottomNavView.getMenu().getItem(position).setChecked(true); binding.viewPager.setCurrentItem(position); } } else { int position = 0; for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) { if (pinnedTimeline.type == Timeline.TimeLineEnum.NOTIFICATION && binding.bottomNavView.getMenu().size() < position) { binding.bottomNavView.getMenu().getItem(position).setChecked(true); binding.viewPager.setCurrentItem(position); break; } position++; } } }, 2000); intent.removeExtra(Helper.INTENT_ACTION); } else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) { openNotifications(intent); } } else if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { Loading
app/src/main/java/app/fedilab/android/helper/Helper.java +2 −3 Original line number Diff line number Diff line Loading @@ -1550,17 +1550,16 @@ public class Helper { notificationBuilder.setLargeIcon(icon); Notification summaryNotification = summaryNotification = new NotificationCompat.Builder(context, channelId) Notification summaryNotification = new NotificationCompat.Builder(context, channelId) .setContentTitle(title) .setContentText(channelTitle) .setContentIntent(pIntent) .setLargeIcon(icon) .setSmallIcon(R.drawable.ic_notification) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setGroup(account.mastodon_account != null ? account.mastodon_account.acct : "" + "@" + account.instance) .setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "" + "@" + account.instance) .setGroupSummary(true) .build(); notificationManager.notify(notificationId++, notificationBuilder.build()); notificationManager.notify(0, summaryNotification); } Loading
app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java +0 −4 Original line number Diff line number Diff line Loading @@ -40,8 +40,6 @@ import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.transition.Transition; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.IOException; import java.util.ArrayList; Loading Loading @@ -137,7 +135,6 @@ public class NotificationsHelper { .connectTimeout(60, TimeUnit.SECONDS) .proxy(Helper.getProxy(context)) .build(); Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create(); Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://" + instance + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) Loading Loading @@ -180,7 +177,6 @@ public class NotificationsHelper { Helper.NotifType notifType = Helper.NotifType.MENTION; switch (notification.type) { case "mention": notifType = Helper.NotifType.MENTION; if (notif_mention) { if (notification.account.display_name != null && notification.account.display_name.length() > 0) title = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_mention)); Loading