Search in sources :

Example 6 with Tile

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;
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Tile(com.android.settingslib.drawer.Tile)

Example 7 with Tile

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();
}
Also used : Condition(com.android.settings.dashboard.conditional.Condition) Tile(com.android.settingslib.drawer.Tile) SettingsDrawerActivity(com.android.settingslib.drawer.SettingsDrawerActivity)

Example 8 with Tile

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);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) URISyntaxException(java.net.URISyntaxException) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) UserManager(android.os.UserManager) ComponentName(android.content.ComponentName) NfcAdapter(android.nfc.NfcAdapter) ZenModeAutomationSettings(com.android.settings.notification.ZenModeAutomationSettings) NotificationAccessSettings(com.android.settings.notification.NotificationAccessSettings) HWSettings(com.android.settings.rr.input.HWSettings) AccountSettings(com.android.settings.accounts.AccountSettings) SmartbarSettings(com.android.settings.rr.navbar.SmartbarSettings) GestureSettings(com.android.settings.gestures.GestureSettings) AccessibilitySettings(com.android.settings.accessibility.AccessibilitySettings) LocationSettings(com.android.settings.location.LocationSettings) OtherSoundSettings(com.android.settings.notification.OtherSoundSettings) ZenModeEventRuleSettings(com.android.settings.notification.ZenModeEventRuleSettings) InputMethodAndLanguageSettings(com.android.settings.inputmethod.InputMethodAndLanguageSettings) ManagedProfileSettings(com.android.settings.accounts.ManagedProfileSettings) GestureAnywhereSettings(com.android.settings.rr.gestureanywhere.GestureAnywhereSettings) PaymentSettings(com.android.settings.nfc.PaymentSettings) AccountSyncSettings(com.android.settings.accounts.AccountSyncSettings) SimSettings(com.android.settings.sim.SimSettings) UserSettings(com.android.settings.users.UserSettings) WifiSettings(com.android.settings.wifi.WifiSettings) SavedAccessPointsWifiSettings(com.android.settings.wifi.SavedAccessPointsWifiSettings) ZenModeSettings(com.android.settings.notification.ZenModeSettings) FlingSettings(com.android.settings.rr.navbar.FlingSettings) StorageSettings(com.android.settings.deviceinfo.StorageSettings) AmbientSettings(com.android.settings.rr.ambientdisplay.AmbientSettings) VrListenerSettings(com.android.settings.applications.VrListenerSettings) ZenAccessSettings(com.android.settings.notification.ZenAccessSettings) PrivateVolumeSettings(com.android.settings.deviceinfo.PrivateVolumeSettings) SpellCheckersSettings(com.android.settings.inputmethod.SpellCheckersSettings) NavbarSettings(com.android.settings.rr.navbar.NavbarSettings) NightDisplaySettings(com.android.settings.display.NightDisplaySettings) BatterySaverSettings(com.android.settings.fuelgauge.BatterySaverSettings) AdvancedAppSettings(com.android.settings.applications.AdvancedAppSettings) ZenModeVisualInterruptionSettings(com.android.settings.notification.ZenModeVisualInterruptionSettings) WifiDisplaySettings(com.android.settings.wfd.WifiDisplaySettings) AutomaticStorageManagerSettings(com.android.settings.deletionhelper.AutomaticStorageManagerSettings) ZenModePrioritySettings(com.android.settings.notification.ZenModePrioritySettings) SoundSettings(com.android.settings.notification.SoundSettings) AppNotificationSettings(com.android.settings.notification.AppNotificationSettings) AdvancedWifiSettings(com.android.settings.wifi.AdvancedWifiSettings) TextToSpeechSettings(com.android.settings.tts.TextToSpeechSettings) WifiP2pSettings(com.android.settings.wifi.p2p.WifiP2pSettings) PulseSettings(com.android.settings.rr.navbar.PulseSettings) MainSettings(com.android.settings.rr.MainSettings) ZenModeScheduleRuleSettings(com.android.settings.notification.ZenModeScheduleRuleSettings) VpnSettings(com.android.settings.vpn2.VpnSettings) BluetoothSettings(com.android.settings.bluetooth.BluetoothSettings) PublicVolumeSettings(com.android.settings.deviceinfo.PublicVolumeSettings) ConfigureNotificationSettings(com.android.settings.notification.ConfigureNotificationSettings)

Example 9 with Tile

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);
        }
    }
}
Also used : UserHandle(android.os.UserHandle) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent)

Example 10 with Tile

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);
        }
    }
}
Also used : UserHandle(android.os.UserHandle) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent)

Aggregations

Tile (com.android.settingslib.drawer.Tile)13 Intent (android.content.Intent)6 UserHandle (android.os.UserHandle)5 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)3 SettingsDrawerActivity (com.android.settingslib.drawer.SettingsDrawerActivity)3 ComponentName (android.content.ComponentName)2 Condition (com.android.settings.dashboard.conditional.Condition)2 PackageManager (android.content.pm.PackageManager)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 ResolveInfo (android.content.pm.ResolveInfo)1 NfcAdapter (android.nfc.NfcAdapter)1 UserManager (android.os.UserManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 AccessibilitySettings (com.android.settings.accessibility.AccessibilitySettings)1 AccountSettings (com.android.settings.accounts.AccountSettings)1 AccountSyncSettings (com.android.settings.accounts.AccountSyncSettings)1