Search in sources :

Example 1 with PackageItem

use of org.cyanogenmod.cmparts.widget.PackageListAdapter.PackageItem in project android_packages_apps_CMParts by LineageOS.

the class AppGroupConfig method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo aMenuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    PackageItem selectedGroup = (PackageItem) mListView.getItemAtPosition(aMenuInfo.position);
    switch(item.getItemId()) {
        case R.string.profile_menu_delete_title:
            deleteAppFromGroup(selectedGroup);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) PackageItem(org.cyanogenmod.cmparts.widget.PackageListAdapter.PackageItem)

Example 2 with PackageItem

use of org.cyanogenmod.cmparts.widget.PackageListAdapter.PackageItem in project android_packages_apps_CMParts by LineageOS.

the class AppGroupConfig method onCreateDialog.

@Override
public Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final Dialog dialog;
    switch(id) {
        case DIALOG_APPS:
            final ListView list = new ListView(getActivity());
            list.setAdapter(mAppAdapter);
            builder.setTitle(R.string.profile_choose_app);
            builder.setView(list);
            dialog = builder.create();
            list.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    PackageItem info = (PackageItem) parent.getItemAtPosition(position);
                    mNotificationGroup.addPackage(info.packageName);
                    updatePackages();
                    dialog.cancel();
                }
            });
            break;
        case DELETE_CONFIRM:
            builder.setMessage(R.string.profile_app_delete_confirm);
            builder.setTitle(R.string.profile_menu_delete_title);
            builder.setIconAttribute(android.R.attr.alertDialogIcon);
            builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    doDelete();
                }
            });
            builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            dialog = builder.create();
            break;
        case DELETE_GROUP_CONFIRM:
            builder.setMessage(R.string.profile_delete_appgroup);
            builder.setTitle(R.string.profile_menu_delete_title);
            builder.setIconAttribute(android.R.attr.alertDialogIcon);
            builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mProfileManager.removeNotificationGroup(mNotificationGroup);
                    mNotificationGroup = null;
                    finish();
                }
            });
            builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            dialog = builder.create();
            break;
        default:
            dialog = null;
    }
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) PackageItem(org.cyanogenmod.cmparts.widget.PackageListAdapter.PackageItem) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog)

Example 3 with PackageItem

use of org.cyanogenmod.cmparts.widget.PackageListAdapter.PackageItem in project android_packages_apps_CMParts by LineageOS.

the class NotificationLightSettings method onCreateDialog.

/**
 * Utility classes and supporting methods
 */
@Override
public Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final Dialog dialog;
    switch(id) {
        case DIALOG_APPS:
            final ListView list = new ListView(getActivity());
            list.setAdapter(mPackageAdapter);
            builder.setTitle(R.string.choose_app);
            builder.setView(list);
            dialog = builder.create();
            list.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    // Add empty application definition, the user will be able to edit it later
                    PackageItem info = (PackageItem) parent.getItemAtPosition(position);
                    addCustomApplicationPref(info.packageName);
                    dialog.cancel();
                }
            });
            break;
        default:
            dialog = null;
    }
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) PackageItem(org.cyanogenmod.cmparts.widget.PackageListAdapter.PackageItem) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

PackageItem (org.cyanogenmod.cmparts.widget.PackageListAdapter.PackageItem)3 AlertDialog (android.app.AlertDialog)2 Dialog (android.app.Dialog)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)2 ListView (android.widget.ListView)2 DialogInterface (android.content.DialogInterface)1 AdapterContextMenuInfo (android.widget.AdapterView.AdapterContextMenuInfo)1