use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project StreetComplete by westnordost.
the class LocationRequestFragment method requestLocationSettingsToBeOn.
private void requestLocationSettingsToBeOn() {
if (LocationUtil.isLocationOn(getContext())) {
state = LocationState.ENABLED;
nextStep();
} else {
final AlertDialog dlg = new AlertDialogBuilder(getContext()).setMessage(R.string.turn_on_location_request).setPositiveButton(android.R.string.yes, (dialog, which) -> {
dialog.dismiss();
Intent viewIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(viewIntent, LOCATION_TURN_ON_REQUEST);
}).setNegativeButton(android.R.string.no, (dialog, which) -> cancelTurnLocationOnDialog()).setOnCancelListener(dialog -> cancelTurnLocationOnDialog()).create();
// the user may turn on location in the pull-down-overlay, without actually going into
// settings dialog
registerForLocationProviderChanges(dlg);
dlg.show();
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project android_packages_apps_Settings by LineageOS.
the class LocationSettings method addLocationServices.
/**
* Add the settings injected by external apps into the "App Settings" category. Hides the
* category if there are no injected settings.
*
* Reloads the settings whenever receives
* {@link SettingInjectorService#ACTION_INJECTED_SETTING_CHANGED}.
*/
private void addLocationServices(Context context, PreferenceScreen root, boolean lockdownOnLocationAccess) {
PreferenceCategory categoryLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
injector = new SettingsInjector(context);
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
final Context prefContext = categoryLocationServices.getContext();
final List<Preference> locationServices = injector.getInjectedSettings(prefContext, lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Received settings change intent: " + intent);
}
injector.reloadStatusMessages();
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
context.registerReceiver(mReceiver, filter);
if (locationServices.size() > 0) {
addPreferencesSorted(locationServices, categoryLocationServices);
} else {
// If there's no item to display, remove the whole category.
root.removePreference(categoryLocationServices);
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project android_packages_apps_Dialer by LineageOS.
the class DialtactsActivity method enterSearchUi.
/**
* Shows the search fragment
*/
private void enterSearchUi(boolean smartDialSearch, String query, boolean animate) {
if (mStateSaved || getFragmentManager().isDestroyed()) {
// constructive here.
return;
}
if (DEBUG) {
LogUtil.v("DialtactsActivity.enterSearchUi", "smart dial " + smartDialSearch);
}
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
if (mInDialpadSearch && mSmartDialSearchFragment != null) {
transaction.remove(mSmartDialSearchFragment);
} else if (mInRegularSearch && mRegularSearchFragment != null) {
transaction.remove(mRegularSearchFragment);
}
final String tag;
boolean useNewSearch = ConfigProviderBindings.get(this).getBoolean("enable_new_search_fragment", false);
if (useNewSearch) {
tag = TAG_NEW_SEARCH_FRAGMENT;
} else if (smartDialSearch) {
tag = TAG_SMARTDIAL_SEARCH_FRAGMENT;
} else {
tag = TAG_REGULAR_SEARCH_FRAGMENT;
}
mInDialpadSearch = smartDialSearch;
mInRegularSearch = !smartDialSearch;
mFloatingActionButtonController.scaleOut();
if (animate) {
transaction.setCustomAnimations(android.R.animator.fade_in, 0);
} else {
transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
}
Fragment fragment = getFragmentManager().findFragmentByTag(tag);
if (fragment == null) {
if (useNewSearch) {
fragment = new NewSearchFragment();
} else if (smartDialSearch) {
fragment = new SmartDialSearchFragment();
} else {
fragment = Bindings.getLegacy(this).newRegularSearchFragment();
((SearchFragment) fragment).setOnTouchListener((v, event) -> {
// Show the FAB when the user touches the lists fragment and the soft
// keyboard is hidden.
hideDialpadFragment(true, false);
v.performClick();
return false;
});
}
transaction.add(R.id.dialtacts_frame, fragment, tag);
} else {
// TODO: if this is a transition from dialpad to searchbar, animate fragment
// down, and vice versa. Perhaps just add a coordinator behavior with the search bar.
transaction.show(fragment);
}
// DialtactsActivity will provide the options menu
fragment.setHasOptionsMenu(false);
// Will show empty list if P13nRanker is not enabled. Else, re-ranked list by the ranker.
if (!useNewSearch) {
((SearchFragment) fragment).setShowEmptyListForNullQuery(mP13nRanker.shouldShowEmptyListForNullQuery());
} else {
// TODO: add p13n ranker to new search.
}
if (!smartDialSearch && !useNewSearch) {
((SearchFragment) fragment).setQueryString(query);
} else if (useNewSearch) {
((NewSearchFragment) fragment).setQuery(query);
}
transaction.commit();
if (animate) {
Assert.isNotNull(mListsFragment.getView()).animate().alpha(0).withLayer();
}
mListsFragment.setUserVisibleHint(false);
if (smartDialSearch) {
Logger.get(this).logScreenView(ScreenEvent.Type.SMART_DIAL_SEARCH, this);
} else {
Logger.get(this).logScreenView(ScreenEvent.Type.REGULAR_SEARCH, this);
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project android_packages_apps_Settings by omnirom.
the class LocationSettings method addLocationServices.
/**
* Add the settings injected by external apps into the "App Settings" category. Hides the
* category if there are no injected settings.
*
* Reloads the settings whenever receives
* {@link SettingInjectorService#ACTION_INJECTED_SETTING_CHANGED}.
*/
private void addLocationServices(Context context, PreferenceScreen root, boolean lockdownOnLocationAccess) {
PreferenceCategory categoryLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
injector = new SettingsInjector(context);
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
final Context prefContext = categoryLocationServices.getContext();
final List<Preference> locationServices = injector.getInjectedSettings(prefContext, lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Received settings change intent: " + intent);
}
injector.reloadStatusMessages();
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
context.registerReceiver(mReceiver, filter);
if (locationServices.size() > 0) {
addPreferencesSorted(locationServices, categoryLocationServices);
} else {
// If there's no item to display, remove the whole category.
root.removePreference(categoryLocationServices);
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project android_packages_apps_Settings by crdroidandroid.
the class LocationSettings method addLocationServices.
/**
* Add the settings injected by external apps into the "App Settings" category. Hides the
* category if there are no injected settings.
*
* Reloads the settings whenever receives
* {@link SettingInjectorService#ACTION_INJECTED_SETTING_CHANGED}.
*/
private void addLocationServices(Context context, PreferenceScreen root, boolean lockdownOnLocationAccess) {
PreferenceCategory categoryLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
injector = new SettingsInjector(context);
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
final Context prefContext = categoryLocationServices.getContext();
final List<Preference> locationServices = injector.getInjectedSettings(prefContext, lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Received settings change intent: " + intent);
}
injector.reloadStatusMessages();
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
context.registerReceiver(mReceiver, filter);
if (locationServices.size() > 0) {
addPreferencesSorted(locationServices, categoryLocationServices);
} else {
// If there's no item to display, remove the whole category.
root.removePreference(categoryLocationServices);
}
}
Aggregations