private void switchTo(UUID uuid) { Profile p = mProfileManager.getProfile(uuid); if (p != null) { mProfileManager.setActiveProfile(uuid); Toast.makeText( this, String.format(getResources().getString(R.string.profile_selected), p.getName()), Toast.LENGTH_LONG) .show(); NFCProfileUtils.vibrate(this); } }
private void handleProfileMimeType(byte[] payload) { UUID profileUuid = NFCProfileUtils.toUUID(payload); Profile currentProfile = mProfileManager.getActiveProfile(); if (currentProfile == null || !currentProfile.getUuid().equals(profileUuid)) { saveCurrentProfile(); switchTo(profileUuid); } else if (currentProfile.getUuid().equals(profileUuid)) { Profile lastProfile = getPreviouslySelectedProfile(); if (lastProfile != null) { switchTo(lastProfile.getUuid()); clearPreviouslySelectedProfile(); } } }
public static int getSummaryString(Profile profile) { switch (profile.getExpandedDesktopMode()) { case Profile.ExpandedDesktopMode.DEFAULT: return R.string.profile_action_none; case Profile.ExpandedDesktopMode.ENABLE: return R.string.profile_action_enable; case Profile.ExpandedDesktopMode.DISABLE: return R.string.profile_action_disabled; default: return 0; } }
public static int getSummaryString(Profile profile) { switch (profile.getDozeMode()) { case Profile.DozeMode.DEFAULT: return R.string.profile_action_none; // "leave unchanged" case Profile.DozeMode.ENABLE: return R.string.profile_action_enable; case Profile.DozeMode.DISABLE: return R.string.profile_action_disable; default: return 0; } }
private void saveCurrentProfile() { Profile currentProfile = mProfileManager.getActiveProfile(); SharedPreferences.Editor editor = getSharedPreferences(PREFS_NAME, 0).edit(); editor.putString(PREFS_PREVIOUS_PROFILE, currentProfile.getUuid().toString()); editor.commit(); }
/** @hide */ public static Profile fromXml(XmlPullParser xpp, Context context) throws XmlPullParserException, IOException { String value = xpp.getAttributeValue(null, "nameres"); int profileNameResId = -1; String profileName = null; if (value != null) { profileNameResId = context.getResources().getIdentifier(value, "string", "android"); if (profileNameResId > 0) { profileName = context.getResources().getString(profileNameResId); } } if (profileName == null) { profileName = xpp.getAttributeValue(null, "name"); } UUID profileUuid = UUID.randomUUID(); try { profileUuid = UUID.fromString(xpp.getAttributeValue(null, "uuid")); } catch (NullPointerException e) { Log.w( TAG, "Null Pointer - UUID not found for " + profileName + ". New UUID generated: " + profileUuid.toString()); } catch (IllegalArgumentException e) { Log.w( TAG, "UUID not recognized for " + profileName + ". New UUID generated: " + profileUuid.toString()); } Profile profile = new Profile(profileName, profileNameResId, profileUuid); int event = xpp.next(); while (event != XmlPullParser.END_TAG) { if (event == XmlPullParser.START_TAG) { String name = xpp.getName(); if (name.equals("statusbar")) { profile.setStatusBarIndicator(xpp.nextText() == "yes"); } if (name.equals("profileGroup")) { ProfileGroup pg = ProfileGroup.fromXml(xpp, context); profile.addProfileGroup(pg); } if (name.equals("streamDescriptor")) { StreamSettings sd = StreamSettings.fromXml(xpp, context); profile.setStreamSettings(sd); } if (name.equals("connectionDescriptor")) { ConnectionSettings cs = ConnectionSettings.fromXml(xpp, context); profile.connections.put(cs.getConnectionId(), cs); } } event = xpp.next(); } /* we just loaded from XML, so nothing needs saving */ profile.mDirty = false; return profile; }