Skip to content

Commit

Permalink
Bug 1290029 - go back to the playing tab when double clicking the con…
Browse files Browse the repository at this point in the history
…trol interface. r=sebastian

MozReview-Commit-ID: JfXm7vBKqfW
  • Loading branch information
alastor0325 committed Aug 9, 2016
1 parent 368131b commit 0c6ab3e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public abstract class GeckoApp
public static final String ACTION_LAUNCH_SETTINGS = "org.mozilla.gecko.SETTINGS";
public static final String ACTION_LOAD = "org.mozilla.gecko.LOAD";
public static final String ACTION_INIT_PW = "org.mozilla.gecko.INIT_PW";
public static final String ACTION_SWITCH_TAB = "org.mozilla.gecko.SWITCH_TAB";

public static final String INTENT_REGISTER_STUMBLER_LISTENER = "org.mozilla.gecko.STUMBLER_REGISTER_LOCAL_LISTENER";

Expand Down Expand Up @@ -2077,6 +2078,9 @@ public void run() {
// Copy extras.
settingsIntent.putExtras(intent.getUnsafe());
startActivity(settingsIntent);
} else if (ACTION_SWITCH_TAB.equals(action)) {
final int tabId = intent.getIntExtra("TabId", -1);
Tabs.getInstance().selectTab(tabId);
}

recordStartupActionTelemetry(passedUri, action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.GeckoApp;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.PrefsHelper;
import org.mozilla.gecko.R;
Expand Down Expand Up @@ -297,7 +298,7 @@ private void updateNotification(Tab tab, String action) {
.setLargeIcon(generateCoverArt(tab))
.setContentTitle(tab.getTitle())
.setContentText(tab.getURL())
.setContentIntent(createContentIntent())
.setContentIntent(createContentIntent(tab.getId()))
.setDeleteIntent(createDeleteIntent())
.setStyle(style)
.addAction(createNotificationAction(action))
Expand Down Expand Up @@ -330,9 +331,11 @@ private Notification.Action createNotificationAction(String action) {
return new Notification.Action.Builder(icon, title, pendingIntent).build();
}

private PendingIntent createContentIntent() {
private PendingIntent createContentIntent(int tabId) {
Intent intent = new Intent(getApplicationContext(), BrowserApp.class);
return PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
intent.setAction(GeckoApp.ACTION_SWITCH_TAB);
intent.putExtra("TabId", tabId);
return PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

private PendingIntent createDeleteIntent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ public boolean getBooleanExtra(final String name, final boolean defaultValue) {
}
}

public int getIntExtra(final String name, final int defaultValue) {
try {
return intent.getIntExtra(name, defaultValue);
} catch (OutOfMemoryError e) {
Log.w(LOGTAG, "Couldn't get intent extras: OOM. Malformed?");
return defaultValue;
} catch (RuntimeException e) {
Log.w(LOGTAG, "Couldn't get intent extras.", e);
return defaultValue;
}
}

public String getStringExtra(final String name) {
try {
return intent.getStringExtra(name);
Expand Down

0 comments on commit 0c6ab3e

Please sign in to comment.