Search in sources :

Example 1 with Profile

use of cyanogenmod.app.Profile in project android_packages_apps_CMParts by LineageOS.

the class NFCProfile method handleProfileMimeType.

private void handleProfileMimeType(byte[] payload) {
    UUID profileUuid = NFCProfileUtils.toUUID(payload);
    boolean enabled = CMSettings.System.getInt(getContentResolver(), CMSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1;
    if (enabled) {
        // Only do NFC profile changing if System Profile support is enabled
        Profile currentProfile = mProfileManager.getActiveProfile();
        Profile targetProfile = mProfileManager.getProfile(profileUuid);
        if (targetProfile == null) {
            // show profile selection for unknown tag
            Intent i = new Intent(this, NFCProfileSelect.class);
            i.putExtra(NFCProfileSelect.EXTRA_PROFILE_UUID, profileUuid.toString());
            i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            this.startActivity(i);
        } else {
            // switch to profile
            if (currentProfile == null || !currentProfile.getUuid().equals(profileUuid)) {
                saveCurrentProfile();
                switchTo(profileUuid);
            } else {
                Profile lastProfile = getPreviouslySelectedProfile();
                if (lastProfile != null) {
                    switchTo(lastProfile.getUuid());
                    clearPreviouslySelectedProfile();
                }
            }
        }
    }
}
Also used : Intent(android.content.Intent) UUID(java.util.UUID) Profile(cyanogenmod.app.Profile)

Example 2 with Profile

use of cyanogenmod.app.Profile in project android_packages_apps_CMParts by LineageOS.

the class NFCProfile method saveCurrentProfile.

private void saveCurrentProfile() {
    Profile currentProfile = mProfileManager.getActiveProfile();
    if (currentProfile != null) {
        SharedPreferences.Editor editor = getSharedPreferences(PREFS_NAME, 0).edit();
        editor.putString(PREFS_PREVIOUS_PROFILE, currentProfile.getUuid().toString());
        editor.commit();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) Profile(cyanogenmod.app.Profile)

Example 3 with Profile

use of cyanogenmod.app.Profile in project android_packages_apps_CMParts by LineageOS.

the class ProfilesSettings method addProfile.

private void addProfile() {
    Bundle args = new Bundle();
    args.putBoolean(EXTRA_NEW_PROFILE, true);
    args.putParcelable(EXTRA_PROFILE, new Profile(getString(R.string.new_profile_name)));
    PartsActivity pa = (PartsActivity) getActivity();
    pa.startPreferencePanel(SetupTriggersFragment.class.getCanonicalName(), args, 0, null, this, 0);
}
Also used : Bundle(android.os.Bundle) PartsActivity(org.cyanogenmod.cmparts.PartsActivity) Profile(cyanogenmod.app.Profile)

Example 4 with Profile

use of cyanogenmod.app.Profile in project android_packages_apps_CMParts by LineageOS.

the class ProfilesSettings method refreshList.

public void refreshList() {
    PreferenceScreen plist = getPreferenceScreen();
    plist.removeAll();
    // Get active profile, if null
    Profile prof = mProfileManager.getActiveProfile();
    String selectedKey = prof != null ? prof.getUuid().toString() : null;
    for (Profile profile : mProfileManager.getProfiles()) {
        Bundle args = new Bundle();
        args.putParcelable(ProfilesSettings.EXTRA_PROFILE, profile);
        args.putBoolean(ProfilesSettings.EXTRA_NEW_PROFILE, false);
        ProfilesPreference ppref = new ProfilesPreference(this, args);
        ppref.setKey(profile.getUuid().toString());
        ppref.setTitle(profile.getName());
        ppref.setPersistent(false);
        ppref.setOnPreferenceChangeListener(this);
        ppref.setSelectable(true);
        ppref.setEnabled(true);
        if (TextUtils.equals(selectedKey, ppref.getKey())) {
            ppref.setChecked(true);
        }
        plist.addPreference(ppref);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Bundle(android.os.Bundle) Profile(cyanogenmod.app.Profile)

Example 5 with Profile

use of cyanogenmod.app.Profile in project android_packages_apps_CMParts by LineageOS.

the class SetupActionsFragment method requestRemoveProfileDialog.

private AlertDialog requestRemoveProfileDialog() {
    Profile current = mProfileManager.getActiveProfile();
    if (mProfile.getUuid().equals(current.getUuid())) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(getString(R.string.profile_remove_current_profile));
        builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        return builder.create();
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage(getString(R.string.profile_remove_dialog_message, mProfile.getName()));
    builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            mProfileManager.removeProfile(mProfile);
            finishFragment();
        }
    });
    builder.setNegativeButton(R.string.no, null);
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Profile(cyanogenmod.app.Profile)

Aggregations

Profile (cyanogenmod.app.Profile)9 DialogInterface (android.content.DialogInterface)2 SharedPreferences (android.content.SharedPreferences)2 Bundle (android.os.Bundle)2 AlertDialog (android.app.AlertDialog)1 Builder (android.app.AlertDialog.Builder)1 Intent (android.content.Intent)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 ProfileManager (cyanogenmod.app.ProfileManager)1 UUID (java.util.UUID)1 PartsActivity (org.cyanogenmod.cmparts.PartsActivity)1