Fix notification intent flags

pull/1051/head
Alex Baker 4 years ago
parent 2027ab6858
commit 2408a1e6c5

@ -293,9 +293,8 @@
<activity <activity
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:launchMode="singleTask"
android:name=".reminders.NotificationActivity" android:name=".reminders.NotificationActivity"
android:taskAffinity="" android:taskAffinity=":notification"
android:theme="@style/TranslucentDialog"/> android:theme="@style/TranslucentDialog"/>
<activity android:name=".activities.NavigationDrawerCustomization" /> <activity android:name=".activities.NavigationDrawerCustomization" />

@ -1,7 +1,5 @@
package org.tasks.notifications; package org.tasks.notifications;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static androidx.core.app.NotificationCompat.FLAG_INSISTENT; import static androidx.core.app.NotificationCompat.FLAG_INSISTENT;
import static androidx.core.app.NotificationCompat.FLAG_NO_CLEAR; import static androidx.core.app.NotificationCompat.FLAG_NO_CLEAR;
import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Iterables.concat;
@ -371,11 +369,7 @@ public class NotificationManager {
.setShowWhen(true) .setShowWhen(true)
.setTicker(taskTitle); .setTicker(taskTitle);
final Intent intent = new Intent(context, NotificationActivity.class); Intent intent = NotificationActivity.newIntent(context, taskTitle, id);
intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
intent.setAction("NOTIFY" + id); // $NON-NLS-1$
intent.putExtra(NotificationActivity.EXTRA_TASK_ID, id);
intent.putExtra(NotificationActivity.EXTRA_TITLE, taskTitle);
builder.setContentIntent( builder.setContentIntent(
PendingIntent.getActivity(context, (int) id, intent, PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getActivity(context, (int) id, intent, PendingIntent.FLAG_UPDATE_CURRENT));

@ -1,5 +1,6 @@
package org.tasks.reminders; package org.tasks.reminders;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -28,6 +29,14 @@ public class NotificationActivity extends InjectingAppCompatActivity
@Inject TaskDaoBlocking taskDao; @Inject TaskDaoBlocking taskDao;
@Inject ThemeAccent themeAccent; @Inject ThemeAccent themeAccent;
public static Intent newIntent(Context context, String title, long id) {
Intent intent = new Intent(context, NotificationActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra(NotificationActivity.EXTRA_TASK_ID, id);
intent.putExtra(NotificationActivity.EXTRA_TITLE, title);
return intent;
}
private long taskId; private long taskId;
private CompositeDisposable disposables; private CompositeDisposable disposables;
@ -37,17 +46,7 @@ public class NotificationActivity extends InjectingAppCompatActivity
themeAccent.applyStyle(getTheme()); themeAccent.applyStyle(getTheme());
setup(getIntent()); Intent intent = getIntent();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setup(intent);
}
private void setup(Intent intent) {
taskId = intent.getLongExtra(EXTRA_TASK_ID, 0L); taskId = intent.getLongExtra(EXTRA_TASK_ID, 0L);

Loading…
Cancel
Save