зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1395841 - Part 2: Support creating a shortcut from page option in menu. r=nechen
When page option 'add page shortcut' is clicked, creating a shortcut(not PWA) on launcher. Also make sure that heavy tasks are executed in background thread. MozReview-Commit-ID: 8KtwdXENtEd --HG-- extra : rebase_source : 12a427f549a41f9d8650b4b8d95394bdc4192c4b
This commit is contained in:
Родитель
fa9bbb0da2
Коммит
2baa51b8c6
|
@ -1506,7 +1506,7 @@ public class BrowserApp extends GeckoApp
|
|||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GeckoApplication.createShortcut(title, url);
|
||||
GeckoApplication.createBrowserShortcut(title, url);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.mozilla.gecko.util.GeckoBundle;
|
|||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
import org.mozilla.gecko.util.PRNGFixes;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
import org.mozilla.gecko.util.UIAsyncTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -570,12 +571,21 @@ public class GeckoApplication extends Application
|
|||
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
context.sendBroadcast(intent);
|
||||
|
||||
// Remember interaction
|
||||
final UrlAnnotations urlAnnotations = BrowserDB.from(context).getUrlAnnotations();
|
||||
urlAnnotations.insertHomeScreenShortcut(context.getContentResolver(), aURI, true);
|
||||
(new UIAsyncTask.WithoutParams<Void>(ThreadUtils.getBackgroundHandler()) {
|
||||
@Override
|
||||
public Void doInBackground() {
|
||||
// Remember interaction, post to background thread to prevent violating StrictMode policy.
|
||||
final UrlAnnotations urlAnnotations = BrowserDB.from(context).getUrlAnnotations();
|
||||
urlAnnotations.insertHomeScreenShortcut(context.getContentResolver(), aURI, true);
|
||||
return null;
|
||||
}
|
||||
|
||||
// After shortcut is created, show the mobile desktop.
|
||||
ActivityUtils.goToHomeScreen(context);
|
||||
@Override
|
||||
public void onPostExecute(Void aVoid) {
|
||||
// After shortcut is created and db entry is inserted, show the mobile desktop.
|
||||
ActivityUtils.goToHomeScreen(context);
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
private static Bitmap getLauncherIcon(Bitmap aSource, int size) {
|
||||
|
|
|
@ -284,7 +284,12 @@ public abstract class ActivityStreamContextMenu
|
|||
break;
|
||||
|
||||
case R.id.add_homescreen:
|
||||
GeckoApplication.createShortcut(item.getTitle(), item.getUrl());
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GeckoApplication.createBrowserShortcut(item.getTitle(), item.getUrl());
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case R.id.open_new_tab:
|
||||
|
|
|
@ -185,7 +185,7 @@ public class BookmarkStateChangeDelegate extends BrowserAppDelegateWithReference
|
|||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GeckoApplication.createShortcut(title, url);
|
||||
GeckoApplication.createBrowserShortcut(title, url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -312,8 +312,7 @@ public abstract class HomeFragment extends Fragment {
|
|||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GeckoApplication.createShortcut(displayTitle, info.url);
|
||||
|
||||
GeckoApplication.createBrowserShortcut(displayTitle, info.url);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ public class HomeScreenPrompt extends Locales.LocaleAwareActivity implements Ico
|
|||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GeckoApplication.createShortcut(title, url);
|
||||
GeckoApplication.createBrowserShortcut(title, url);
|
||||
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, TELEMETRY_EXTRA);
|
||||
|
||||
|
@ -131,8 +131,6 @@ public class HomeScreenPrompt extends Locales.LocaleAwareActivity implements Ico
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void loadShortcutIcon() {
|
||||
Icons.with(this)
|
||||
.pageUrl(url)
|
||||
|
|
Загрузка…
Ссылка в новой задаче