Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java

Issue 934183002: Make the ShortcutHelper toast instead of send the user home for web app banners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
index f953e8ffc85fb78e3684de30c422470852f7dde0..d59e45d91b6e4dc8c63374fa6022b1b5df2481fe 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
@@ -8,11 +8,16 @@ import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.os.Handler;
+import android.os.Looper;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
+import android.widget.Toast;
+import org.chromium.base.ApplicationStatus;
import org.chromium.base.CalledByNative;
+import org.chromium.chrome.R;
import org.chromium.content_public.common.ScreenOrientationConstants;
import java.io.ByteArrayOutputStream;
@@ -161,11 +166,17 @@ public class ShortcutHelper {
context.sendBroadcast(BookmarkUtils.createAddToHomeIntent(context, shortcutIntent, title,
icon, red, green, blue));
- // User is sent to the homescreen as soon as the shortcut is created.
- Intent homeIntent = new Intent(Intent.ACTION_MAIN);
- homeIntent.addCategory(Intent.CATEGORY_HOME);
- homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(homeIntent);
+ // Alert the user about adding the shortcut.
+ Handler handler = new Handler(Looper.getMainLooper());
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ Context applicationContext = ApplicationStatus.getApplicationContext();
+ String toastText = applicationContext.getString(R.string.added_to_homescreen);
+ Toast toast = Toast.makeText(applicationContext, toastText, Toast.LENGTH_SHORT);
+ toast.show();
+ }
+ });
}
private native long nativeInitialize(long tabAndroidPtr);

Powered by Google App Engine
This is Rietveld 408576698