Search in sources :

Example 11 with DOWN

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();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) PackageManager(android.content.pm.PackageManager) Fragment(android.support.v4.app.Fragment) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) BroadcastReceiver(android.content.BroadcastReceiver) Manifest(android.Manifest) R(de.westnordost.streetcomplete.R) AlertDialog(android.support.v7.app.AlertDialog) Settings(android.provider.Settings) Nullable(android.support.annotation.Nullable) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Intent(android.content.Intent)

Example 12 with DOWN

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);
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PreferenceCategory(android.support.v7.preference.PreferenceCategory) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 13 with DOWN

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);
    }
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) AnimUtils(com.android.dialer.animation.AnimUtils) RegularSearchFragment(com.android.dialer.app.list.RegularSearchFragment) CallIntentBuilder(com.android.dialer.callintent.CallIntentBuilder) Uri(android.net.Uri) DialerSettingsActivity(com.android.dialer.app.settings.DialerSettingsActivity) OldSpeedDialFragment(com.android.dialer.app.list.OldSpeedDialFragment) DialtactsPagerAdapter(com.android.dialer.app.list.DialtactsPagerAdapter) ActionBarController(com.android.dialer.app.widget.ActionBarController) Simulator(com.android.dialer.simulator.Simulator) PhoneNumberInteraction(com.android.dialer.interactions.PhoneNumberInteraction) PopupMenu(android.widget.PopupMenu) MainThread(android.support.annotation.MainThread) TabIndex(com.android.dialer.app.list.DialtactsPagerAdapter.TabIndex) Database(com.android.dialer.database.Database) FloatingActionButton(android.support.design.widget.FloatingActionButton) DragEvent(android.view.DragEvent) ScreenEvent(com.android.dialer.logging.ScreenEvent) PhoneFavoriteSquareTileView(com.android.dialer.app.list.PhoneFavoriteSquareTileView) ActivityCompat(android.support.v4.app.ActivityCompat) PhoneNumberListAdapter(com.android.contacts.common.list.PhoneNumberListAdapter) CallSpecificAppData(com.android.dialer.callintent.CallSpecificAppData) OnLoadFinishedListener(com.android.contacts.common.list.PhoneNumberPickerFragment.OnLoadFinishedListener) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) Snackbar(android.support.design.widget.Snackbar) TextWatcher(android.text.TextWatcher) Assert(com.android.dialer.common.Assert) OnListFragmentScrolledListener(com.android.dialer.app.list.OnListFragmentScrolledListener) SystemClock(android.os.SystemClock) CallLogFragment(com.android.dialer.app.calllog.CallLogFragment) FragmentTransaction(android.app.FragmentTransaction) NonNull(android.support.annotation.NonNull) ViewUtil(com.android.dialer.util.ViewUtil) Editable(android.text.Editable) ArrayList(java.util.ArrayList) IntentProvider(com.android.dialer.app.calllog.IntentProvider) InteractionErrorCode(com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorCode) SearchFragment(com.android.dialer.app.list.SearchFragment) P13nLogging(com.android.dialer.p13n.logging.P13nLogging) Toast(android.widget.Toast) Menu(android.view.Menu) ConfigProviderBindings(com.android.dialer.configprovider.ConfigProviderBindings) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) Fragment(android.app.Fragment) OnPhoneNumberPickerActionListener(com.android.contacts.common.list.OnPhoneNumberPickerActionListener) DialpadFragment(com.android.dialer.app.dialpad.DialpadFragment) SmartDialPrefix(com.android.dialer.smartdial.SmartDialPrefix) TextUtils(android.text.TextUtils) CallDetailsActivity(com.android.dialer.calldetails.CallDetailsActivity) P13nRefreshCompleteListener(com.android.dialer.p13n.inference.protocol.P13nRanker.P13nRefreshCompleteListener) Gravity(android.view.Gravity) P13nLogger(com.android.dialer.p13n.logging.P13nLogger) PhoneAccount(android.telecom.PhoneAccount) CallComposerActivity(com.android.dialer.callcomposer.CallComposerActivity) Configuration(android.content.res.Configuration) Calls(android.provider.CallLog.Calls) Main(com.android.dialer.main.Main) EditText(android.widget.EditText) KeyguardManager(android.app.KeyguardManager) Trace(android.os.Trace) ImageButton(android.widget.ImageButton) P13nRanker(com.android.dialer.p13n.inference.protocol.P13nRanker) CallLogNotificationsService(com.android.dialer.app.calllog.CallLogNotificationsService) PackageManager(android.content.pm.PackageManager) OnDragDropListener(com.android.dialer.app.list.OnDragDropListener) OnDragListener(android.view.View.OnDragListener) VisibleForTesting(android.support.annotation.VisibleForTesting) CallLogAdapter(com.android.dialer.app.calllog.CallLogAdapter) ListsFragment(com.android.dialer.app.list.ListsFragment) Locale(java.util.Locale) TransactionSafeActivity(com.android.dialer.util.TransactionSafeActivity) PermissionsUtil(com.android.dialer.util.PermissionsUtil) View(android.view.View) Animation(android.view.animation.Animation) CursorReranker(com.android.contacts.common.list.PhoneNumberPickerFragment.CursorReranker) SmartDialNameMatcher(com.android.dialer.smartdial.SmartDialNameMatcher) SearchEditTextLayout(com.android.dialer.app.widget.SearchEditTextLayout) CallLogActivity(com.android.dialer.app.calllog.CallLogActivity) DialerImpression(com.android.dialer.logging.DialerImpression) TouchPointManager(com.android.dialer.util.TouchPointManager) ClearFrequentsDialog(com.android.contacts.common.dialog.ClearFrequentsDialog) DragDropController(com.android.dialer.app.list.DragDropController) AnimationListenerAdapter(com.android.dialer.animation.AnimationListenerAdapter) PerformanceReport(com.android.dialer.performancereport.PerformanceReport) OnScrollListener(android.widget.AbsListView.OnScrollListener) List(java.util.List) TextView(android.widget.TextView) ActivityNotFoundException(android.content.ActivityNotFoundException) UiAction(com.android.dialer.logging.UiAction) TelecomUtil(com.android.dialer.telecom.TelecomUtil) Context(android.content.Context) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) LogUtil(com.android.dialer.common.LogUtil) KeyEvent(android.view.KeyEvent) ViewPager(android.support.v4.view.ViewPager) DialerDatabaseHelper(com.android.dialer.database.DialerDatabaseHelper) Intent(android.content.Intent) MainComponent(com.android.dialer.main.MainComponent) MenuItem(android.view.MenuItem) AnimationUtils(android.view.animation.AnimationUtils) MotionEvent(android.view.MotionEvent) RecognizerIntent(android.speech.RecognizerIntent) Logger(com.android.dialer.logging.Logger) ActionBar(android.support.v7.app.ActionBar) Cursor(android.database.Cursor) SimulatorComponent(com.android.dialer.simulator.SimulatorComponent) PostCall(com.android.dialer.postcall.PostCall) UsedByReflection(com.android.dialer.proguard.UsedByReflection) FloatingActionButtonController(com.android.contacts.common.widget.FloatingActionButtonController) ResolveInfo(android.content.pm.ResolveInfo) TimeUnit(java.util.concurrent.TimeUnit) DialerUtils(com.android.dialer.util.DialerUtils) Resources(android.content.res.Resources) P13nRanking(com.android.dialer.p13n.inference.P13nRanking) FragmentTransaction(android.app.FragmentTransaction) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) RegularSearchFragment(com.android.dialer.app.list.RegularSearchFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) SearchFragment(com.android.dialer.app.list.SearchFragment) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) RegularSearchFragment(com.android.dialer.app.list.RegularSearchFragment) OldSpeedDialFragment(com.android.dialer.app.list.OldSpeedDialFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) CallLogFragment(com.android.dialer.app.calllog.CallLogFragment) SearchFragment(com.android.dialer.app.list.SearchFragment) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) Fragment(android.app.Fragment) DialpadFragment(com.android.dialer.app.dialpad.DialpadFragment) ListsFragment(com.android.dialer.app.list.ListsFragment)

Example 14 with DOWN

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);
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PreferenceCategory(android.support.v7.preference.PreferenceCategory) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 15 with DOWN

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);
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PreferenceCategory(android.support.v7.preference.PreferenceCategory) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)37 View (android.view.View)37 Intent (android.content.Intent)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)18 TextView (android.widget.TextView)16 ImageView (android.widget.ImageView)15 Preference (android.support.v7.preference.Preference)14 Context (android.content.Context)13 PreferenceCategory (android.support.v7.preference.PreferenceCategory)12 BroadcastReceiver (android.content.BroadcastReceiver)8 IntentFilter (android.content.IntentFilter)7 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 Button (android.widget.Button)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)6 OnClickListener (android.view.View.OnClickListener)6 FrameLayout (android.widget.FrameLayout)6 SharedPreferences (android.content.SharedPreferences)5 SwitchPreference (android.support.v14.preference.SwitchPreference)5