diff options
author | Martin Brabham <optedoblivion@cyngn.com> | 2015-05-07 10:53:31 -0700 |
---|---|---|
committer | Martin Brabham <optedoblivion@cyngn.com> | 2015-05-28 14:35:18 -0700 |
commit | fff40f64168cacb55901ed4f0fe79add5efbc3dd (patch) | |
tree | 10df89b3b96229eb42b27908790ef35a7d152aa9 /src/com/android/launcher3/LauncherModel.java | |
parent | 347c6ec103f0f7781012a8ddac282bfbd319437d (diff) | |
download | android_packages_apps_Trebuchet-fff40f64168cacb55901ed4f0fe79add5efbc3dd.tar.gz android_packages_apps_Trebuchet-fff40f64168cacb55901ed4f0fe79add5efbc3dd.tar.bz2 android_packages_apps_Trebuchet-fff40f64168cacb55901ed4f0fe79add5efbc3dd.zip |
Trebuchet Statistics:
- Add plumbing for sending events.
- Add aggregation service that runs on some interval
- Hook send events into respective UX interactions
Change-Id: I77ba0ab75daf845621d800e0adf3e658096926af
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index a8bcb2c66..aca236155 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -62,6 +62,7 @@ import com.android.launcher3.compat.UserHandleCompat; import com.android.launcher3.compat.UserManagerCompat; import com.android.launcher3.settings.SettingsProvider; +import com.android.launcher3.stats.internal.service.AggregationIntentService; import java.lang.ref.WeakReference; import java.net.URISyntaxException; @@ -1066,10 +1067,22 @@ public class LauncherModel extends BroadcastReceiver } /** + * Saves the total widget count to a shared preference + * + * @param context {@link Context} + */ + /* package */ static void saveWidgetCount(Context context) { + int widgetCount = LauncherModel.sBgAppWidgets.size(); + SharedPreferences prefs = context.getSharedPreferences(LauncherAppState + .getSharedPreferencesKey(), Context.MODE_PRIVATE); + prefs.edit().putInt(AggregationIntentService.PREF_KEY_WIDGET_COUNT, widgetCount).apply(); + } + + /** * Add an item to the database in a specified container. Sets the container, screen, cellX and * cellY fields of the item. Also assigns an ID to the item. */ - static void addItemToDatabase(Context context, final ItemInfo item, final long container, + static void addItemToDatabase(final Context context, final ItemInfo item, final long container, final long screenId, final int cellX, final int cellY, final boolean notify) { item.container = container; item.cellX = cellX; @@ -1121,6 +1134,7 @@ public class LauncherModel extends BroadcastReceiver break; case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: sBgAppWidgets.add((LauncherAppWidgetInfo) item); + saveWidgetCount(context); break; } } @@ -1173,7 +1187,7 @@ public class LauncherModel extends BroadcastReceiver * @param context * @param item */ - static void deleteItemsFromDatabase(Context context, final ArrayList<ItemInfo> items) { + static void deleteItemsFromDatabase(final Context context, final ArrayList<ItemInfo> items) { final ContentResolver cr = context.getContentResolver(); Runnable r = new Runnable() { @@ -1204,6 +1218,7 @@ public class LauncherModel extends BroadcastReceiver break; case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: sBgAppWidgets.remove((LauncherAppWidgetInfo) item); + saveWidgetCount(context); break; } sBgItemsIdMap.remove(item.id); @@ -1216,10 +1231,22 @@ public class LauncherModel extends BroadcastReceiver } /** + * Saves the count of workspace pages + * + * @param context {@link Context} + */ + /* package */ static void savePageCount(Context context) { + int pageCount = LauncherModel.sBgWorkspaceScreens.size(); + SharedPreferences prefs = context.getSharedPreferences(LauncherAppState + .getSharedPreferencesKey(), Context.MODE_PRIVATE); + prefs.edit().putInt(AggregationIntentService.PREF_KEY_PAGE_COUNT, pageCount).apply(); + } + + /** * Update the order of the workspace screens in the database. The array list contains * a list of screen ids in the order that they should appear. */ - void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) { + void updateWorkspaceScreenOrder(final Context context, final ArrayList<Long> screens) { // Log to disk Launcher.addDumpLog(TAG, "11683562 - updateWorkspaceScreenOrder()", true); Launcher.addDumpLog(TAG, "11683562 - screens: " + TextUtils.join(", ", screens), true); @@ -1261,6 +1288,7 @@ public class LauncherModel extends BroadcastReceiver synchronized (sBgLock) { sBgWorkspaceScreens.clear(); sBgWorkspaceScreens.addAll(screensCopy); + savePageCount(context); } } }; |