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();
}
}
}
}
}
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();
}
}
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);
}
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);
}
}
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();
}
Aggregations