Search in sources :

Example 1 with DozeModeItem

use of org.cyanogenmod.cmparts.profiles.actions.item.DozeModeItem in project android_packages_apps_CMParts by LineageOS.

the class SetupActionsFragment method rebuildItemList.

private void rebuildItemList() {
    mItems.clear();
    // general prefs
    mItems.add(new Header(getString(R.string.profile_name_title)));
    mItems.add(new ProfileNameItem(mProfile));
    if (!mNewProfileMode) {
        // triggers
        mItems.add(new Header(getString(R.string.profile_triggers_header)));
        mItems.add(generateTriggerItem(TriggerItem.WIFI));
        if (DeviceUtils.deviceSupportsBluetooth()) {
            mItems.add(generateTriggerItem(TriggerItem.BLUETOOTH));
        }
        if (DeviceUtils.deviceSupportsNfc(getActivity())) {
            mItems.add(generateTriggerItem(TriggerItem.NFC));
        }
    }
    // connection overrides
    mItems.add(new Header(getString(R.string.wireless_networks_settings_title)));
    if (DeviceUtils.deviceSupportsBluetooth()) {
        mItems.add(new ConnectionOverrideItem(PROFILE_CONNECTION_BLUETOOTH, mProfile.getSettingsForConnection(PROFILE_CONNECTION_BLUETOOTH)));
    }
    mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_GPS));
    mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_WIFI));
    mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_SYNC));
    if (DeviceUtils.deviceSupportsMobileData(getActivity())) {
        mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_MOBILEDATA));
        mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_WIFIAP));
        final List<SubscriptionInfo> subs = SubscriptionManager.from(getContext()).getActiveSubscriptionInfoList();
        if (subs != null) {
            for (SubscriptionInfo sub : subs) {
                mItems.add(generatePreferredNetworkOverrideItem(sub.getSubscriptionId()));
            }
        } else {
            if (TelephonyManager.from(getContext()).getPhoneCount() == 1) {
                mItems.add(generatePreferredNetworkOverrideItem(SubscriptionManager.INVALID_SUBSCRIPTION_ID));
            }
        }
    }
    // }
    if (DeviceUtils.deviceSupportsNfc(getActivity())) {
        mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_NFC));
    }
    // add volume streams
    mItems.add(new Header(getString(R.string.profile_volumeoverrides_title)));
    mItems.add(generateVolumeStreamItem(AudioManager.STREAM_ALARM));
    mItems.add(generateVolumeStreamItem(AudioManager.STREAM_MUSIC));
    mItems.add(generateVolumeStreamItem(AudioManager.STREAM_RING));
    mItems.add(generateVolumeStreamItem(AudioManager.STREAM_NOTIFICATION));
    // system settings
    mItems.add(new Header(getString(R.string.profile_system_settings_title)));
    mItems.add(new RingModeItem(mProfile.getRingMode()));
    mItems.add(new AirplaneModeItem(mProfile.getAirplaneMode()));
    DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (!dpm.requireSecureKeyguard()) {
        mItems.add(new LockModeItem(mProfile));
    } else {
        mItems.add(new DisabledItem(R.string.profile_lockmode_title, R.string.profile_lockmode_policy_disabled_summary));
    }
    mItems.add(new BrightnessItem(mProfile.getBrightness()));
    final Activity activity = getActivity();
    if (DeviceUtils.isDozeAvailable(activity)) {
        mItems.add(new DozeModeItem(mProfile));
    }
    if (getResources().getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) {
        mItems.add(new NotificationLightModeItem(mProfile));
    }
    // app groups
    mItems.add(new Header(getString(R.string.profile_app_group_category_title)));
    int groupsAdded = 0;
    ProfileGroup[] profileGroups = mProfile.getProfileGroups();
    if (profileGroups != null && profileGroups.length > 1) {
        // it will always have "other"
        for (ProfileGroup profileGroup : profileGroups) {
            // and don't' show the wildcard group
            if (mProfileManager.getNotificationGroup(profileGroup.getUuid()) != null && !mProfile.getDefaultGroup().getUuid().equals(profileGroup.getUuid())) {
                mItems.add(new AppGroupItem(mProfile, profileGroup, mProfileManager.getNotificationGroup(profileGroup.getUuid())));
                groupsAdded++;
            }
        }
        if (groupsAdded > 0) {
            // add "Other" at the end
            mItems.add(new AppGroupItem(mProfile, mProfile.getDefaultGroup(), mProfileManager.getNotificationGroup(mProfile.getDefaultGroup().getUuid())));
        }
    }
    if (mProfileManager.getNotificationGroups().length > 0) {
        // if there are notification groups available, allow them to be configured
        mItems.add(new AppGroupItem());
    } else if (groupsAdded == 0) {
        // no notification groups available at all, nothing to add/remove
        mItems.remove(mItems.get(mItems.size() - 1));
    }
    mAdapter.notifyDataSetChanged();
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) AppGroupItem(org.cyanogenmod.cmparts.profiles.actions.item.AppGroupItem) AirplaneModeItem(org.cyanogenmod.cmparts.profiles.actions.item.AirplaneModeItem) ProfileNameItem(org.cyanogenmod.cmparts.profiles.actions.item.ProfileNameItem) ConnectionOverrideItem(org.cyanogenmod.cmparts.profiles.actions.item.ConnectionOverrideItem) PartsActivity(org.cyanogenmod.cmparts.PartsActivity) Activity(android.app.Activity) SubscriptionInfo(android.telephony.SubscriptionInfo) LockModeItem(org.cyanogenmod.cmparts.profiles.actions.item.LockModeItem) BrightnessItem(org.cyanogenmod.cmparts.profiles.actions.item.BrightnessItem) DozeModeItem(org.cyanogenmod.cmparts.profiles.actions.item.DozeModeItem) Header(org.cyanogenmod.cmparts.profiles.actions.item.Header) DisabledItem(org.cyanogenmod.cmparts.profiles.actions.item.DisabledItem) NotificationLightModeItem(org.cyanogenmod.cmparts.profiles.actions.item.NotificationLightModeItem) RingModeItem(org.cyanogenmod.cmparts.profiles.actions.item.RingModeItem) ProfileGroup(cyanogenmod.app.ProfileGroup)

Example 2 with DozeModeItem

use of org.cyanogenmod.cmparts.profiles.actions.item.DozeModeItem in project android_packages_apps_CMParts by LineageOS.

the class SetupActionsFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final Item itemAtPosition = (Item) parent.getItemAtPosition(position);
    mSelectedItem = itemAtPosition;
    mLastSelectedPosition = mAdapter.getPosition(itemAtPosition);
    if (itemAtPosition instanceof AirplaneModeItem) {
        showDialog(DIALOG_AIRPLANE_MODE);
    } else if (itemAtPosition instanceof BrightnessItem) {
        showDialog(DIALOG_BRIGHTNESS);
    } else if (itemAtPosition instanceof LockModeItem) {
        showDialog(DIALOG_LOCK_MODE);
    } else if (itemAtPosition instanceof DozeModeItem) {
        showDialog(DIALOG_DOZE_MODE);
    } else if (itemAtPosition instanceof NotificationLightModeItem) {
        showDialog(DIALOG_NOTIFICATION_LIGHT_MODE);
    } else if (itemAtPosition instanceof RingModeItem) {
        showDialog(DIALOG_RING_MODE);
    } else if (itemAtPosition instanceof ConnectionOverrideItem) {
        ConnectionOverrideItem connItem = (ConnectionOverrideItem) mSelectedItem;
        if (connItem.getConnectionType() == ConnectionSettings.PROFILE_CONNECTION_2G3G4G) {
            final Intent intent = new Intent(TelephonyUtils.ACTION_PICK_NETWORK_MODE);
            intent.putExtra(TelephonyUtils.EXTRA_NONE_TEXT, getString(R.string.profile_action_none));
            intent.putExtra(TelephonyUtils.EXTRA_SHOW_NONE, true);
            intent.putExtra(TelephonyUtils.EXTRA_SUBID, connItem.getSettings().getSubId());
            intent.putExtra(TelephonyUtils.EXTRA_INITIAL_NETWORK_VALUE, connItem.getSettings().isOverride() ? connItem.getSettings().getValue() : -1);
            startActivityForResult(intent, SET_NETWORK_MODE_REQUEST_CODE);
        } else {
            showDialog(DIALOG_CONNECTION_OVERRIDE);
        }
    } else if (itemAtPosition instanceof VolumeStreamItem) {
        showDialog(DIALOG_VOLUME_STREAM);
    } else if (itemAtPosition instanceof ProfileNameItem) {
        showDialog(DIALOG_PROFILE_NAME);
    } else if (itemAtPosition instanceof TriggerItem) {
        TriggerItem item = (TriggerItem) itemAtPosition;
        openTriggersFragment(item.getTriggerType());
    } else if (itemAtPosition instanceof AppGroupItem) {
        AppGroupItem item = (AppGroupItem) itemAtPosition;
        if (item.getGroupUuid() == null) {
            requestActiveAppGroupsDialog();
        } else {
            startProfileGroupActivity(item);
        }
    }
}
Also used : AppGroupItem(org.cyanogenmod.cmparts.profiles.actions.item.AppGroupItem) AirplaneModeItem(org.cyanogenmod.cmparts.profiles.actions.item.AirplaneModeItem) TriggerItem(org.cyanogenmod.cmparts.profiles.actions.item.TriggerItem) ConnectionOverrideItem(org.cyanogenmod.cmparts.profiles.actions.item.ConnectionOverrideItem) VolumeStreamItem(org.cyanogenmod.cmparts.profiles.actions.item.VolumeStreamItem) ProfileNameItem(org.cyanogenmod.cmparts.profiles.actions.item.ProfileNameItem) Intent(android.content.Intent) LockModeItem(org.cyanogenmod.cmparts.profiles.actions.item.LockModeItem) BrightnessItem(org.cyanogenmod.cmparts.profiles.actions.item.BrightnessItem) NotificationLightModeItem(org.cyanogenmod.cmparts.profiles.actions.item.NotificationLightModeItem) LockModeItem(org.cyanogenmod.cmparts.profiles.actions.item.LockModeItem) TriggerItem(org.cyanogenmod.cmparts.profiles.actions.item.TriggerItem) DozeModeItem(org.cyanogenmod.cmparts.profiles.actions.item.DozeModeItem) AppGroupItem(org.cyanogenmod.cmparts.profiles.actions.item.AppGroupItem) AirplaneModeItem(org.cyanogenmod.cmparts.profiles.actions.item.AirplaneModeItem) VolumeStreamItem(org.cyanogenmod.cmparts.profiles.actions.item.VolumeStreamItem) Item(org.cyanogenmod.cmparts.profiles.actions.item.Item) BrightnessItem(org.cyanogenmod.cmparts.profiles.actions.item.BrightnessItem) ProfileNameItem(org.cyanogenmod.cmparts.profiles.actions.item.ProfileNameItem) MenuItem(android.view.MenuItem) ConnectionOverrideItem(org.cyanogenmod.cmparts.profiles.actions.item.ConnectionOverrideItem) DisabledItem(org.cyanogenmod.cmparts.profiles.actions.item.DisabledItem) RingModeItem(org.cyanogenmod.cmparts.profiles.actions.item.RingModeItem) DozeModeItem(org.cyanogenmod.cmparts.profiles.actions.item.DozeModeItem) NotificationLightModeItem(org.cyanogenmod.cmparts.profiles.actions.item.NotificationLightModeItem) RingModeItem(org.cyanogenmod.cmparts.profiles.actions.item.RingModeItem)

Aggregations

AirplaneModeItem (org.cyanogenmod.cmparts.profiles.actions.item.AirplaneModeItem)2 AppGroupItem (org.cyanogenmod.cmparts.profiles.actions.item.AppGroupItem)2 BrightnessItem (org.cyanogenmod.cmparts.profiles.actions.item.BrightnessItem)2 ConnectionOverrideItem (org.cyanogenmod.cmparts.profiles.actions.item.ConnectionOverrideItem)2 DisabledItem (org.cyanogenmod.cmparts.profiles.actions.item.DisabledItem)2 DozeModeItem (org.cyanogenmod.cmparts.profiles.actions.item.DozeModeItem)2 LockModeItem (org.cyanogenmod.cmparts.profiles.actions.item.LockModeItem)2 NotificationLightModeItem (org.cyanogenmod.cmparts.profiles.actions.item.NotificationLightModeItem)2 ProfileNameItem (org.cyanogenmod.cmparts.profiles.actions.item.ProfileNameItem)2 RingModeItem (org.cyanogenmod.cmparts.profiles.actions.item.RingModeItem)2 Activity (android.app.Activity)1 DevicePolicyManager (android.app.admin.DevicePolicyManager)1 Intent (android.content.Intent)1 SubscriptionInfo (android.telephony.SubscriptionInfo)1 MenuItem (android.view.MenuItem)1 ProfileGroup (cyanogenmod.app.ProfileGroup)1 PartsActivity (org.cyanogenmod.cmparts.PartsActivity)1 Header (org.cyanogenmod.cmparts.profiles.actions.item.Header)1 Item (org.cyanogenmod.cmparts.profiles.actions.item.Item)1 TriggerItem (org.cyanogenmod.cmparts.profiles.actions.item.TriggerItem)1