Notification Click Handling

This commit is contained in:
Caesar2011
2019-02-05 17:20:57 +01:00
parent 42f460a2e1
commit d67542d93a

View File

@@ -19,8 +19,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
@@ -40,7 +38,6 @@ import de.sebse.fuplanner.fragments.ScheduleFragment;
import de.sebse.fuplanner.fragments.StartupFragment;
import de.sebse.fuplanner.fragments.canteen.DaySwitcherFragment;
import de.sebse.fuplanner.fragments.moddetails.ModDetailFragment;
import de.sebse.fuplanner.fragments.moddetails.ModulePart;
import de.sebse.fuplanner.services.canteen.CanteenBrowser;
import de.sebse.fuplanner.services.canteen.types.Canteen;
import de.sebse.fuplanner.services.canteen.types.CanteenListener;
@@ -102,11 +99,13 @@ public class MainActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
log.d("onCreate start");
mAccountManager = new CustomAccountManager(AccountManager.get(this), () -> MainActivity.this);
int desiredPage = getDefaultFragmentAfterLogin();
String desiredData = "";
Intent intent = getIntent();
if (intent != null) {
log.d("onCreate", intent);
if (CustomNotificationManager.NOTIFICATION_TYPE_NAVIGATE.equals(intent.getStringExtra(CustomNotificationManager.NOTIFICATION_INTENT))) {
int page = intent.getIntExtra(CustomNotificationManager.NOTIFICATION_PAGE, 0);
if (page == FRAGMENT_STARTUP || page == FRAGMENT_NONE)
@@ -159,6 +158,22 @@ public class MainActivity extends AppCompatActivity
Preferences.setBoolean(this, R.string.pref_set_auto_sync_on_startup, true);
}
CustomNotificationManager.createNotificationChannel(this);
/*getKVV().modules().list().recv(list -> {
Modules.Module module = list.getByIndex(0);
CustomNotificationManager.sendNotification(this, "Test", module.title, FRAGMENT_MODULES_DETAILS, module.getID()+"."+ModulePart.getPageByPart(ModulePart.ASSIGNMENT));
}, log::e);*/
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (CustomNotificationManager.NOTIFICATION_TYPE_NAVIGATE.equals(intent.getStringExtra(CustomNotificationManager.NOTIFICATION_INTENT))) {
int page = intent.getIntExtra(CustomNotificationManager.NOTIFICATION_PAGE, 0);
String data = intent.getStringExtra(CustomNotificationManager.NOTIFICATION_DATA);
if (page == FRAGMENT_STARTUP || page == FRAGMENT_NONE)
page = getDefaultFragmentAfterLogin();
changeFragment(page, data);
}
}
@Override