mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Automatically adding managed profile shortcuts to homescreen.
When the managed profile is created, a "Work" folder is created and added to the homescreen. All work profile apps are added to this folder and icons for subsequent installs (withing a fixed time frame) are automatically added to this folder. If this folder get deleted or the time-frame expires, icon for any new install is placed on the homescreen. Bug: 17410319 Change-Id: I49f4e437707d5eabe4eec85320765bf6ba7fde97
This commit is contained in:
@@ -18,21 +18,27 @@
|
||||
package com.android.launcher3.compat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class UserManagerCompatVL extends UserManagerCompatV17 {
|
||||
private static final String USER_CREATION_TIME_KEY = "user_creation_time_";
|
||||
|
||||
private final PackageManager mPm;
|
||||
private final Context mContext;
|
||||
|
||||
UserManagerCompatVL(Context context) {
|
||||
super(context);
|
||||
mPm = context.getPackageManager();
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,5 +67,17 @@ public class UserManagerCompatVL extends UserManagerCompatV17 {
|
||||
}
|
||||
return mPm.getUserBadgedLabel(label, user.getUser());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUserCreationTime(UserHandleCompat user) {
|
||||
// TODO: Use system API once available.
|
||||
SharedPreferences prefs = mContext.getSharedPreferences(
|
||||
LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE);
|
||||
String key = USER_CREATION_TIME_KEY + getSerialNumberForUser(user);
|
||||
if (!prefs.contains(key)) {
|
||||
prefs.edit().putLong(key, System.currentTimeMillis()).apply();
|
||||
}
|
||||
return prefs.getLong(key, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user