Search in sources :

Example 6 with Profile

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

the class SetupDefaultProfileReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    if (CMSettings.System.getInt(context.getContentResolver(), CMSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1) {
        ProfileManager profileManager = ProfileManager.getInstance(context);
        Profile defaultProfile = profileManager.getProfile(UUID.fromString("0230226d-0d05-494a-a9bd-d222a1117655"));
        if (defaultProfile != null) {
            SetupActionsFragment.fillProfileWithCurrentSettings(context, defaultProfile);
            profileManager.updateProfile(defaultProfile);
        }
    }
}
Also used : ProfileManager(cyanogenmod.app.ProfileManager) Profile(cyanogenmod.app.Profile)

Example 7 with Profile

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

the class NFCProfile method getPreviouslySelectedProfile.

private Profile getPreviouslySelectedProfile() {
    Profile previous = null;
    SharedPreferences prefs = getSharedPreferences(PREFS_NAME, 0);
    String uuid = prefs.getString(PREFS_PREVIOUS_PROFILE, null);
    if (uuid != null) {
        previous = mProfileManager.getProfile(UUID.fromString(uuid));
    }
    return previous;
}
Also used : SharedPreferences(android.content.SharedPreferences) Profile(cyanogenmod.app.Profile)

Example 8 with Profile

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

the class NFCProfile method switchTo.

private void switchTo(UUID uuid) {
    Profile p = mProfileManager.getProfile(uuid);
    if (p != null) {
        mProfileManager.setActiveProfile(uuid);
        Toast.makeText(this, getString(R.string.profile_selected, p.getName()), Toast.LENGTH_LONG).show();
        NFCProfileUtils.vibrate(this);
    }
}
Also used : Profile(cyanogenmod.app.Profile)

Example 9 with Profile

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

the class NFCProfileSelect method showProfileSelectionDialog.

void showProfileSelectionDialog() {
    final Profile[] profiles = mProfileManager.getProfiles();
    final String[] profileNames = new String[profiles.length];
    for (int i = 0; i < profiles.length; i++) {
        profileNames[i] = profiles[i].getName();
    }
    Builder builder = new Builder(this);
    builder.setTitle(R.string.profile_settings_title);
    builder.setSingleChoiceItems(profileNames, currentChoice, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            currentChoice = which;
        }
    });
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (currentChoice != defaultChoice) {
                Profile profile = profiles[currentChoice];
                profile.addSecondaryUuid(mProfileUuid);
                mProfileManager.updateProfile(profile);
                Toast.makeText(NFCProfileSelect.this, R.string.profile_write_success, Toast.LENGTH_LONG).show();
            }
            finish();
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }
    });
    builder.show();
}
Also used : DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) 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