use of android.support.v7.widget.helper.ItemTouchHelper.START in project android_packages_apps_Settings by omnirom.
the class AccountTypePreferenceLoader method updatePreferenceIntents.
/**
* Recursively filters through the preference list provided by GoogleLoginService.
*
* This method removes all the invalid intent from the list, adds account name as extra into the
* intent, and hack the location settings to start it as a fragment.
*/
public void updatePreferenceIntents(PreferenceGroup prefs, final String acccountType, Account account) {
final PackageManager pm = mFragment.getActivity().getPackageManager();
for (int i = 0; i < prefs.getPreferenceCount(); ) {
Preference pref = prefs.getPreference(i);
if (pref instanceof PreferenceGroup) {
updatePreferenceIntents((PreferenceGroup) pref, acccountType, account);
}
Intent intent = pref.getIntent();
if (intent != null) {
// preference click event here directly.
if (intent.getAction().equals(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)) {
// The OnPreferenceClickListener overrides the click event completely. No intent
// will get fired.
pref.setOnPreferenceClickListener(new FragmentStarter(LocationSettings.class.getName(), R.string.location_settings_title));
} else {
ResolveInfo ri = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, mUserHandle.getIdentifier());
if (ri == null) {
prefs.removePreference(pref);
continue;
}
intent.putExtra(ACCOUNT_KEY, account);
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent prefIntent = preference.getIntent();
/*
* Check the intent to see if it resolves to a exported=false
* activity that doesn't share a uid with the authenticator.
*
* Otherwise the intent is considered unsafe in that it will be
* exploiting the fact that settings has system privileges.
*/
if (isSafeIntent(pm, prefIntent, acccountType)) {
mFragment.getActivity().startActivityAsUser(prefIntent, mUserHandle);
} else {
Log.e(TAG, "Refusing to launch authenticator intent because" + "it exploits Settings permissions: " + prefIntent);
}
return true;
}
});
}
}
i++;
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project android_packages_apps_Settings by omnirom.
the class ZenModeScheduleRuleSettings method onCreateInternal.
@Override
protected void onCreateInternal() {
addPreferencesFromResource(R.xml.zen_mode_schedule_rule_settings);
final PreferenceScreen root = getPreferenceScreen();
mDays = root.findPreference(KEY_DAYS);
mDays.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDaysDialog();
return true;
}
});
final FragmentManager mgr = getFragmentManager();
mStart = new TimePickerPreference(getPrefContext(), mgr);
mStart.setKey(KEY_START_TIME);
mStart.setTitle(R.string.zen_mode_start_time);
mStart.setCallback(new TimePickerPreference.Callback() {
@Override
public boolean onSetTime(final int hour, final int minute) {
if (mDisableListeners)
return true;
if (!ZenModeConfig.isValidHour(hour))
return false;
if (!ZenModeConfig.isValidMinute(minute))
return false;
if (hour == mSchedule.startHour && minute == mSchedule.startMinute) {
return true;
}
if (DEBUG)
Log.d(TAG, "onPrefChange start h=" + hour + " m=" + minute);
mSchedule.startHour = hour;
mSchedule.startMinute = minute;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
root.addPreference(mStart);
mStart.setDependency(mDays.getKey());
mEnd = new TimePickerPreference(getPrefContext(), mgr);
mEnd.setKey(KEY_END_TIME);
mEnd.setTitle(R.string.zen_mode_end_time);
mEnd.setCallback(new TimePickerPreference.Callback() {
@Override
public boolean onSetTime(final int hour, final int minute) {
if (mDisableListeners)
return true;
if (!ZenModeConfig.isValidHour(hour))
return false;
if (!ZenModeConfig.isValidMinute(minute))
return false;
if (hour == mSchedule.endHour && minute == mSchedule.endMinute) {
return true;
}
if (DEBUG)
Log.d(TAG, "onPrefChange end h=" + hour + " m=" + minute);
mSchedule.endHour = hour;
mSchedule.endMinute = minute;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
root.addPreference(mEnd);
mEnd.setDependency(mDays.getKey());
mExitAtAlarm = (SwitchPreference) root.findPreference(KEY_EXIT_AT_ALARM);
mExitAtAlarm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
mSchedule.exitAtAlarm = (Boolean) o;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project WordPress-Login-Flow-Android by wordpress-mobile.
the class LoginHttpAuthDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder alert = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme));
alert.setTitle(R.string.http_authorization_required);
// noinspection InflateParams
View httpAuth = getActivity().getLayoutInflater().inflate(R.layout.login_alert_http_auth, null);
alert.setView(httpAuth);
final EditText usernameEditText = (EditText) httpAuth.findViewById(R.id.login_http_username);
final EditText passwordEditText = (EditText) httpAuth.findViewById(R.id.login_http_password);
passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
String username = EditTextUtils.getText(usernameEditText);
String password = EditTextUtils.getText(passwordEditText);
sendResult(username, password);
dismiss();
return true;
}
});
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
alert.setPositiveButton(R.string.next, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String username = EditTextUtils.getText(usernameEditText);
String password = EditTextUtils.getText(passwordEditText);
sendResult(username, password);
}
});
final AlertDialog alertDialog = alert.create();
// update the Next button when username edit box changes
usernameEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
updateButton(alertDialog, usernameEditText);
}
});
// update the Next button on first appearance
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
updateButton(alertDialog, usernameEditText);
}
});
return alertDialog;
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project android_packages_apps_Settings by crdroidandroid.
the class AccountTypePreferenceLoader method updatePreferenceIntents.
/**
* Recursively filters through the preference list provided by GoogleLoginService.
*
* This method removes all the invalid intent from the list, adds account name as extra into the
* intent, and hack the location settings to start it as a fragment.
*/
public void updatePreferenceIntents(PreferenceGroup prefs, final String acccountType, Account account) {
final PackageManager pm = mFragment.getActivity().getPackageManager();
for (int i = 0; i < prefs.getPreferenceCount(); ) {
Preference pref = prefs.getPreference(i);
if (pref instanceof PreferenceGroup) {
updatePreferenceIntents((PreferenceGroup) pref, acccountType, account);
}
Intent intent = pref.getIntent();
if (intent != null) {
// preference click event here directly.
if (TextUtils.equals(intent.getAction(), android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)) {
// The OnPreferenceClickListener overrides the click event completely. No intent
// will get fired.
pref.setOnPreferenceClickListener(new FragmentStarter(LocationSettings.class.getName(), R.string.location_settings_title));
} else {
ResolveInfo ri = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, mUserHandle.getIdentifier());
if (ri == null) {
prefs.removePreference(pref);
continue;
}
intent.putExtra(ACCOUNT_KEY, account);
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent prefIntent = preference.getIntent();
/*
* Check the intent to see if it resolves to a exported=false
* activity that doesn't share a uid with the authenticator.
*
* Otherwise the intent is considered unsafe in that it will be
* exploiting the fact that settings has system privileges.
*/
if (isSafeIntent(pm, prefIntent, acccountType)) {
mFragment.getActivity().startActivityAsUser(prefIntent, mUserHandle);
} else {
Log.e(TAG, "Refusing to launch authenticator intent because" + "it exploits Settings permissions: " + prefIntent);
}
return true;
}
});
}
}
i++;
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project Android-InAppBilling by LiteKite.
the class StoreActivity method start.
/**
* Launches StoreActivity.
*
* @param context An Activity Context.
*/
public static void start(Context context) {
if (context instanceof AppCompatActivity) {
Intent intent = new Intent(context, StoreActivity.class);
context.startActivity(intent);
startActivityAnimation(context);
}
}
Aggregations