Skip to content

Commit

Permalink
Fix possible issue related to Proguard ID obfuscation
Browse files Browse the repository at this point in the history
Sometimes tapping notifications opened the wrong section
  • Loading branch information
gbl08ma committed Nov 3, 2017
1 parent 4ce0914 commit 92c2804
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
34 changes: 32 additions & 2 deletions app/src/main/java/im/tny/segvault/disturbances/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ protected void onCreate(Bundle savedInstanceState) {
// show initial fragment
Fragment newFragment = null;
if (getIntent() != null) {
newFragment = getNewFragment(getIntent().getIntExtra(EXTRA_INITIAL_FRAGMENT, R.id.nav_home));
String id = getIntent().getStringExtra(EXTRA_INITIAL_FRAGMENT);
if (id != null) {
newFragment = getNewFragment(pageStringToResourceId(id));
}
}
if (newFragment == null) {
newFragment = new HomeFragment();
Expand Down Expand Up @@ -216,7 +219,7 @@ public boolean onCreateOptionsMenu(Menu menu) {

SharedPreferences sharedPref = getSharedPreferences("settings", MODE_PRIVATE);
boolean devMode = sharedPref.getBoolean("pref_developer_mode", false);
if(!devMode) {
if (!devMode) {
menu.findItem(R.id.menu_debug).setVisible(false);
}

Expand Down Expand Up @@ -255,6 +258,33 @@ private Fragment getNewFragment(int id) {
}
}

private static int pageStringToResourceId(String id) {
switch (id) {
case "nav_home":
return R.id.nav_home;
case "nav_plan_route":
return R.id.nav_plan_route;
case "nav_trip_history":
return R.id.nav_trip_history;
case "nav_map":
return R.id.nav_map;
case "nav_announcements":
return R.id.nav_announcements;
case "nav_disturbances":
return R.id.nav_disturbances;
case "nav_notif":
return R.id.nav_notif;
case "nav_settings":
return R.id.nav_settings;
case "nav_help":
return R.id.nav_help;
case "nav_about":
return R.id.nav_about;
default:
return R.id.nav_home;
}
}

private void replaceFragment(Fragment newFragment, boolean addToBackStack) {
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.main_fragment_container);
if (currentFragment == null || !currentFragment.isAdded()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ private void handleDisturbanceNotification(String network, String line,
}

Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_INITIAL_FRAGMENT, R.id.nav_disturbances);
intent.putExtra(MainActivity.EXTRA_INITIAL_FRAGMENT, "nav_disturbances");
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

String title = String.format(getString(R.string.notif_disturbance_title), sline.getName());
Expand Down Expand Up @@ -1031,7 +1031,7 @@ private void updateRouteNotification(S2LS loc) {

private void updateRouteNotification(S2LS loc, boolean highPriorityNotification) {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_INITIAL_FRAGMENT, R.id.nav_home);
intent.putExtra(MainActivity.EXTRA_INITIAL_FRAGMENT, "nav_home");
PendingIntent pendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
intent, 0);

Expand Down

0 comments on commit 92c2804

Please sign in to comment.