Merge "Adding broadcast to indicate first launcher load" into ub-now-master

This commit is contained in:
Adam Cohen
2014-07-24 15:58:26 +00:00
committed by Android (Google) Code Review
4 changed files with 27 additions and 4 deletions
+3 -1
View File
@@ -50,11 +50,13 @@
android:protectionLevel="signatureOrSystem"
android:label="@string/permlab_write_settings"
android:description="@string/permdesc_write_settings"/>
<permission
android:name="com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS"
android:protectionLevel="signature"
/>
<permission
android:name="com.android.launcher3.permission.RECEIVE_FIRST_LOAD_BROADCAST"
android:protectionLevel="signatureOrSystem" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
+3
View File
@@ -27,6 +27,9 @@
<!-- Permission to receive the com.android.launcher3.action.LAUNCH intent -->
<string name="receive_launch_broadcasts_permission" translatable="false">com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS</string>
<!-- Permission to receive the com.android.launcher3.action.FIRST_LOAD_COMPLETE intent -->
<string name="receive_first_load_broadcast_permission" translatable="false">com.android.launcher3.permission.RECEIVE_FIRST_LOAD_BROADCAST</string>
<!-- Application name -->
<string name="application_name">Launcher3</string>
<!-- Accessibility-facing application name -->
+17
View File
@@ -209,6 +209,10 @@ public class Launcher extends Activity
static final String INTRO_SCREEN_DISMISSED = "launcher.intro_screen_dismissed";
static final String FIRST_RUN_ACTIVITY_DISPLAYED = "launcher.first_run_activity_displayed";
static final String FIRST_LOAD_COMPLETE = "launcher.first_load_complete";
static final String ACTION_FIRST_LOAD_COMPLETE =
"com.android.launcher3.action.FIRST_LOAD_COMPLETE";
private static final String TOOLBAR_ICON_METADATA_NAME = "com.android.launcher.toolbar_icon";
private static final String TOOLBAR_SEARCH_ICON_METADATA_NAME =
"com.android.launcher.toolbar_search_icon";
@@ -4454,6 +4458,7 @@ public class Launcher extends Activity
}
setWorkspaceLoading(false);
sendLoadingCompleteBroadcastIfNecessary();
// If we received the result of any pending adds while the loader was running (e.g. the
// widget configuration forced an orientation change), process them now.
@@ -4478,6 +4483,18 @@ public class Launcher extends Activity
}
}
private void sendLoadingCompleteBroadcastIfNecessary() {
if (!mSharedPrefs.getBoolean(FIRST_LOAD_COMPLETE, false)) {
String permission =
getResources().getString(R.string.receive_first_load_broadcast_permission);
Intent intent = new Intent(ACTION_FIRST_LOAD_COMPLETE);
sendBroadcast(intent, permission);
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(FIRST_LOAD_COMPLETE, true);
editor.apply();
}
}
public boolean isAllAppsButtonRank(int rank) {
if (mHotseat != null) {
return mHotseat.isAllAppsButtonRank(rank);
@@ -1275,14 +1275,15 @@ public class LauncherProvider extends ContentProvider {
if (cn != null) {
try {
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {
return false;
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
if (appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {
return true;
}
} catch (RuntimeException e) {
Log.e(TAG, "Failed to initialize external widget", e);
return false;
}
}
return false;
}
return true;
}