Search in sources :

Example 1 with NotificationGroup

use of android.app.NotificationGroup in project android_packages_apps_CMParts by LineageOS.

the class AppGroupList method addAppGroup.

private void addAppGroup() {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View content = inflater.inflate(R.layout.profile_name_dialog, null);
    final TextView prompt = (TextView) content.findViewById(R.id.prompt);
    final EditText entry = (EditText) content.findViewById(R.id.name);
    prompt.setText(R.string.profile_appgroup_name_prompt);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.profile_new_appgroup);
    builder.setView(content);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String name = entry.getText().toString();
            if (!mProfileManager.notificationGroupExists(name)) {
                NotificationGroup newGroup = new NotificationGroup(name);
                mProfileManager.addNotificationGroup(newGroup);
                refreshList();
            } else {
                Toast.makeText(getActivity(), R.string.duplicate_appgroup_name, Toast.LENGTH_LONG).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    AlertDialog dialog = builder.create();
    dialog.show();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) NotificationGroup(android.app.NotificationGroup) TextView(android.widget.TextView) View(android.view.View) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView)

Example 2 with NotificationGroup

use of android.app.NotificationGroup in project android_packages_apps_CMParts by LineageOS.

the class AppGroupList method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(Preference preference) {
    if (preference instanceof PreferenceScreen) {
        NotificationGroup group = mProfileManager.getNotificationGroup(UUID.fromString(preference.getKey()));
        editGroup(group);
    }
    return super.onPreferenceTreeClick(preference);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) NotificationGroup(android.app.NotificationGroup)

Example 3 with NotificationGroup

use of android.app.NotificationGroup in project android_packages_apps_CMParts by LineageOS.

the class SetupActionsFragment method requestActiveAppGroupsDialog.

private void requestActiveAppGroupsDialog() {
    final NotificationGroup[] notificationGroups = mProfileManager.getNotificationGroups();
    CharSequence[] items = new CharSequence[notificationGroups.length];
    boolean[] checked = new boolean[notificationGroups.length];
    for (int i = 0; i < notificationGroups.length; i++) {
        items[i] = notificationGroups[i].getName();
        checked[i] = mProfile.getProfileGroup(notificationGroups[i].getUuid()) != null;
    }
    DialogInterface.OnMultiChoiceClickListener listener = new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                mProfile.addProfileGroup(new ProfileGroup(notificationGroups[which].getUuid(), false));
            } else {
                mProfile.removeProfileGroup(notificationGroups[which].getUuid());
            }
            updateProfile();
            rebuildItemList();
        }
    };
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setMultiChoiceItems(items, checked, listener).setTitle(R.string.profile_appgroups_title).setPositiveButton(android.R.string.ok, null);
    builder.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) NotificationGroup(android.app.NotificationGroup) ProfileGroup(cyanogenmod.app.ProfileGroup)

Example 4 with NotificationGroup

use of android.app.NotificationGroup in project android_packages_apps_CMParts by LineageOS.

the class AppGroupList method refreshList.

public void refreshList() {
    PreferenceScreen appgroupList = getPreferenceScreen();
    appgroupList.removeAll();
    // Add the existing app groups
    for (NotificationGroup group : mProfileManager.getNotificationGroups()) {
        PreferenceScreen pref = new PreferenceScreen(getActivity(), null);
        pref.setKey(group.getUuid().toString());
        pref.setTitle(group.getName());
        pref.setPersistent(false);
        appgroupList.addPreference(pref);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) NotificationGroup(android.app.NotificationGroup)

Aggregations

NotificationGroup (android.app.NotificationGroup)4 AlertDialog (android.app.AlertDialog)2 DialogInterface (android.content.DialogInterface)2 PreferenceScreen (android.support.v7.preference.PreferenceScreen)2 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 EditText (android.widget.EditText)1 TextView (android.widget.TextView)1 ProfileGroup (cyanogenmod.app.ProfileGroup)1