use of com.android.settingslib.drawer.Tile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SummaryLoader method getTileFromCategory.
private Tile getTileFromCategory(List<DashboardCategory> categories, ComponentName component) {
if (categories == null) {
if (DEBUG) {
Log.d(TAG, "Category is null, can't find tile");
}
return null;
}
final int categorySize = categories.size();
for (int i = 0; i < categorySize; i++) {
final DashboardCategory category = categories.get(i);
final int tileCount = category.tiles.size();
for (int j = 0; j < tileCount; j++) {
final Tile tile = category.tiles.get(j);
if (component.equals(tile.intent.getComponent())) {
return tile;
}
}
}
return null;
}
use of com.android.settingslib.drawer.Tile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardSummary method onStart.
@Override
public void onStart() {
long startTime = System.currentTimeMillis();
super.onStart();
((SettingsDrawerActivity) getActivity()).addCategoryListener(this);
mSummaryLoader.setListening(true);
for (Condition c : mConditionManager.getConditions()) {
if (c.shouldShow()) {
MetricsLogger.visible(getContext(), c.getMetricsConstant());
}
}
if (mAdapter.getSuggestions() != null) {
for (Tile suggestion : mAdapter.getSuggestions()) {
MetricsLogger.action(getContext(), MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, DashboardAdapter.getSuggestionIdentifier(getContext(), suggestion));
}
}
if (DEBUG_TIMING)
Log.d(TAG, "onStart took " + (System.currentTimeMillis() - startTime) + " ms");
updateSettings();
}
use of com.android.settingslib.drawer.Tile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsActivity method doUpdateTilesList.
private void doUpdateTilesList() {
PackageManager pm = getPackageManager();
final UserManager um = UserManager.get(this);
final boolean isAdmin = um.isAdminUser();
String packageName = getPackageName();
setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()), pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.BluetoothSettingsActivity.class.getName()), pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.DataUsageSummaryActivity.class.getName()), Utils.isBandwidthControlEnabled(), isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.RoamingSettingsActivity.class.getName()), getResources().getBoolean(R.bool.config_roamingsettings_enabled), isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.SimSettingsActivity.class.getName()), Utils.showSimCardTile(this), isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.PowerUsageSummaryActivity.class.getName()), mBatteryPresent, isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.UserSettingsActivity.class.getName()), UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers() && !Utils.isMonkeyRunning(), isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.WirelessSettingsActivity.class.getName()), !UserManager.isDeviceInDemoMode(this), isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.DateTimeSettingsActivity.class.getName()), !UserManager.isDeviceInDemoMode(this), isAdmin, pm);
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
setTileEnabled(new ComponentName(packageName, Settings.PaymentSettingsActivity.class.getName()), pm.hasSystemFeature(PackageManager.FEATURE_NFC) && pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION) && adapter != null && adapter.isEnabled(), isAdmin, pm);
setTileEnabled(new ComponentName(packageName, Settings.PrintSettingsActivity.class.getName()), pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm);
final boolean showDev = mDevelopmentPreferences.getBoolean(DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng") || android.os.Build.TYPE.equals("userdebug")) && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES);
setTileEnabled(new ComponentName(packageName, Settings.DevelopmentSettingsActivity.class.getName()), showDev, isAdmin, pm);
boolean kapresent = false;
try {
kapresent = (getPackageManager().getPackageInfo("com.grarak.kerneladiutor", 0).versionCode > 0);
} catch (PackageManager.NameNotFoundException e) {
}
setTileEnabled(new ComponentName(packageName, Settings.KActivity.class.getName()), kapresent, isAdmin, pm);
boolean themesSupported = false;
try {
themesSupported = (getPackageManager().getPackageInfo("projekt.substratum", 0).versionCode > 0);
} catch (PackageManager.NameNotFoundException e) {
}
setTileEnabled(new ComponentName(packageName, Settings.ThemesActivity.class.getName()), themesSupported, isAdmin, pm);
// Reveal development-only quick settings tiles
DevelopmentTiles.setTilesEnabled(this, showDev);
// Magisk Manager
boolean magiskSupported = false;
try {
magiskSupported = (getPackageManager().getPackageInfo("com.topjohnwu.magisk", 0).versionCode > 0);
} catch (PackageManager.NameNotFoundException e) {
}
setTileEnabled(new ComponentName(packageName, Settings.MagiskActivity.class.getName()), magiskSupported, isAdmin, pm);
// Show scheduled power on and off if support
boolean showTimerSwitch = false;
Intent intent = new Intent(ACTION_TIMER_SWITCH);
List<ResolveInfo> infos = getBaseContext().getPackageManager().queryIntentActivities(intent, 0);
if (infos != null && !infos.isEmpty()) {
showTimerSwitch = true;
}
setTileEnabled(new ComponentName(packageName, Settings.TimerSwitchSettingsActivity.class.getName()), showTimerSwitch, isAdmin, pm);
if (UserHandle.MU_ENABLED && !isAdmin) {
// When on restricted users, disable all extra categories (but only the settings ones).
List<DashboardCategory> categories = getDashboardCategories();
for (DashboardCategory category : categories) {
for (Tile tile : category.tiles) {
ComponentName component = tile.intent.getComponent();
if (packageName.equals(component.getPackageName()) && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, component.getClassName())) {
setTileEnabled(component, false, isAdmin, pm);
}
}
}
}
String backupIntent = getResources().getString(R.string.config_backup_settings_intent);
boolean useDefaultBackup = TextUtils.isEmpty(backupIntent);
setTileEnabled(new ComponentName(packageName, Settings.PrivacySettingsActivity.class.getName()), useDefaultBackup, isAdmin, pm);
boolean hasBackupActivity = false;
if (!useDefaultBackup) {
try {
intent = Intent.parseUri(backupIntent, 0);
hasBackupActivity = !getPackageManager().queryIntentActivities(intent, 0).isEmpty();
} catch (URISyntaxException e) {
Log.e(LOG_TAG, "Invalid backup intent URI!", e);
}
}
setTileEnabled(new ComponentName(packageName, BackupSettingsActivity.class.getName()), hasBackupActivity, isAdmin || Utils.isCarrierDemoUser(this), pm);
}
use of com.android.settingslib.drawer.Tile in project android_frameworks_base by crdroidandroid.
the class SuggestionParser method readSuggestions.
private void readSuggestions(SuggestionCategory category, List<Tile> suggestions) {
int countBefore = suggestions.size();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(category.category);
if (category.pkg != null) {
intent.setPackage(category.pkg);
}
TileUtils.getTilesForIntent(mContext, new UserHandle(UserHandle.myUserId()), intent, addCache, null, suggestions, true, false);
for (int i = countBefore; i < suggestions.size(); i++) {
if (!isAvailable(suggestions.get(i)) || !isSupported(suggestions.get(i)) || !satisfiesRequiredAccount(suggestions.get(i)) || isDismissed(suggestions.get(i))) {
suggestions.remove(i--);
}
}
if (!category.multiple && suggestions.size() > (countBefore + 1)) {
// If there are too many, remove them all and only re-add the one with the highest
// priority.
Tile item = suggestions.remove(suggestions.size() - 1);
while (suggestions.size() > countBefore) {
Tile last = suggestions.remove(suggestions.size() - 1);
if (last.priority > item.priority) {
item = last;
}
}
// If category is marked as done, do not add any item.
if (!isCategoryDone(category.category)) {
suggestions.add(item);
}
}
}
use of com.android.settingslib.drawer.Tile in project android_frameworks_base by AOSPA.
the class SuggestionParser method readSuggestions.
private void readSuggestions(SuggestionCategory category, List<Tile> suggestions) {
int countBefore = suggestions.size();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(category.category);
if (category.pkg != null) {
intent.setPackage(category.pkg);
}
TileUtils.getTilesForIntent(mContext, new UserHandle(UserHandle.myUserId()), intent, addCache, null, suggestions, true, false);
for (int i = countBefore; i < suggestions.size(); i++) {
if (!isAvailable(suggestions.get(i)) || !isSupported(suggestions.get(i)) || !satisfiesRequiredAccount(suggestions.get(i)) || isDismissed(suggestions.get(i))) {
suggestions.remove(i--);
}
}
if (!category.multiple && suggestions.size() > (countBefore + 1)) {
// If there are too many, remove them all and only re-add the one with the highest
// priority.
Tile item = suggestions.remove(suggestions.size() - 1);
while (suggestions.size() > countBefore) {
Tile last = suggestions.remove(suggestions.size() - 1);
if (last.priority > item.priority) {
item = last;
}
}
// If category is marked as done, do not add any item.
if (!isCategoryDone(category.category)) {
suggestions.add(item);
}
}
}
Aggregations