Search in sources :

Example 51 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project android_packages_apps_Settings by omnirom.

the class TextToSpeechSettings method initSettings.

private void initSettings() {
    final ContentResolver resolver = getContentResolver();
    // Set up the default rate and pitch.
    mDefaultRate = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_RATE, TextToSpeech.Engine.DEFAULT_RATE);
    mDefaultPitch = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_PITCH, TextToSpeech.Engine.DEFAULT_PITCH);
    mDefaultRatePref.setProgress(getSeekBarProgressFromValue(KEY_DEFAULT_RATE, mDefaultRate));
    mDefaultRatePref.setOnPreferenceChangeListener(this);
    mDefaultRatePref.setMax(getSeekBarProgressFromValue(KEY_DEFAULT_RATE, MAX_SPEECH_RATE));
    mDefaultPitchPref.setProgress(getSeekBarProgressFromValue(KEY_DEFAULT_PITCH, mDefaultPitch));
    mDefaultPitchPref.setOnPreferenceChangeListener(this);
    mDefaultPitchPref.setMax(getSeekBarProgressFromValue(KEY_DEFAULT_PITCH, MAX_SPEECH_PITCH));
    if (mTts != null) {
        mCurrentEngine = mTts.getCurrentEngine();
        mTts.setSpeechRate(mDefaultRate / 100.0f);
        mTts.setPitch(mDefaultPitch / 100.0f);
    }
    SettingsActivity activity = null;
    if (getActivity() instanceof SettingsActivity) {
        activity = (SettingsActivity) getActivity();
    } else {
        throw new IllegalStateException("TextToSpeechSettings used outside a " + "Settings");
    }
    if (mCurrentEngine != null) {
        EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
        Preference mEnginePreference = findPreference(KEY_TTS_ENGINE_PREFERENCE);
        ((GearPreference) mEnginePreference).setOnGearClickListener(this);
        mEnginePreference.setSummary(info.label);
    }
    checkVoiceData(mCurrentEngine);
}
Also used : GearPreference(com.android.settings.widget.GearPreference) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) SeekBarPreference(com.android.settings.widget.SeekBarPreference) ListPreference(android.support.v7.preference.ListPreference) LayoutPreference(com.android.settings.applications.LayoutPreference) GearPreference(com.android.settings.widget.GearPreference) Preference(android.support.v7.preference.Preference) SettingsActivity(com.android.settings.SettingsActivity) ContentResolver(android.content.ContentResolver)

Example 52 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project AndroidChromium by JackyAndroid.

the class NewTabPageView method initializeSearchBoxTextView.

/**
 * Sets up the hint text and event handlers for the search box text view.
 */
private void initializeSearchBoxTextView() {
    final TextView searchBoxTextView = (TextView) mSearchBoxView.findViewById(R.id.search_box_text);
    String hintText = getResources().getString(R.string.search_or_type_url);
    if (!DeviceFormFactor.isTablet(getContext()) || mManager.isFakeOmniboxTextEnabledTablet()) {
        searchBoxTextView.setHint(hintText);
    } else {
        searchBoxTextView.setContentDescription(hintText);
    }
    searchBoxTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mManager.focusSearchBox(false, null);
        }
    });
    searchBoxTextView.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) {
            if (s.length() == 0)
                return;
            mManager.focusSearchBox(false, s.toString());
            searchBoxTextView.setText("");
        }
    });
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) NewTabPageRecyclerView(org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 53 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project AndroidChromium by JackyAndroid.

the class SelectionToolbar method initActionBarDrawerToggle.

/**
 * Set up ActionBarDrawerToggle, a.k.a. hamburger button.
 */
private void initActionBarDrawerToggle() {
    // Sadly, the only way to set correct toolbar button listener for ActionBarDrawerToggle
    // is constructing, so we will need to construct every time we re-show this button.
    mActionBarDrawerToggle = new ActionBarDrawerToggle((Activity) getContext(), mDrawerLayout, this, R.string.accessibility_drawer_toggle_btn_open, R.string.accessibility_drawer_toggle_btn_close);
    mDrawerLayout.addDrawerListener(mActionBarDrawerToggle);
    mActionBarDrawerToggle.syncState();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Activity(android.app.Activity)

Example 54 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project android_packages_apps_Settings by SudaMod.

the class MobileNetworkPreferenceControllerTest method serviceStateChange_shouldUpdatePrefSummary.

@Test
public void serviceStateChange_shouldUpdatePrefSummary() {
    final String testCarrierName = "test";
    final Preference mPreference = mock(Preference.class);
    mController = spy(new MobileNetworkPreferenceController(mContext));
    mLifecycle.addObserver(mController);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    doReturn(true).when(mController).isAvailable();
    // Display pref and go through lifecycle to set up listener.
    mController.displayPreference(mScreen);
    mLifecycle.onResume();
    verify(mController).onResume();
    verify(mTelephonyManager).listen(mController.mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
    // Trigger listener update
    when(mTelephonyManager.getNetworkOperatorName()).thenReturn(testCarrierName);
    mController.mPhoneStateListener.onServiceStateChanged(null);
    // Carrier name should be set.
    verify(mPreference).setSummary(testCarrierName);
}
Also used : Preference(android.support.v7.preference.Preference) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 55 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project android_packages_apps_Settings by SudaMod.

the class PowerUsageAnomalyDetailsTest method testRefreshUi_displayCorrectTitleAndSummary.

@Test
public void testRefreshUi_displayCorrectTitleAndSummary() {
    final List<Preference> testPreferences = new ArrayList<>();
    final ArgumentCaptor<Preference> preferenceCaptor = ArgumentCaptor.forClass(Preference.class);
    Answer<Void> prefCallable = new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            testPreferences.add(preferenceCaptor.getValue());
            return null;
        }
    };
    doAnswer(prefCallable).when(mAbnormalListGroup).addPreference(preferenceCaptor.capture());
    mFragment.refreshUi();
    final Preference wakelockPreference = testPreferences.get(0);
    assertThat(wakelockPreference.getTitle()).isEqualTo(NAME_APP_1);
    assertThat(wakelockPreference.getSummary()).isEqualTo("Keeping device awake");
    final Preference wakeupPreference = testPreferences.get(1);
    assertThat(wakeupPreference.getTitle()).isEqualTo(NAME_APP_2);
    assertThat(wakeupPreference.getSummary()).isEqualTo("Waking up device in background");
    final Preference bluetoothPreference = testPreferences.get(2);
    assertThat(bluetoothPreference.getTitle()).isEqualTo(NAME_APP_3);
    assertThat(bluetoothPreference.getSummary()).isEqualTo("Requesting location frequently");
}
Also used : Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Preference(android.support.v7.preference.Preference) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

View (android.view.View)135 RecyclerView (android.support.v7.widget.RecyclerView)97 TextView (android.widget.TextView)69 Toolbar (android.support.v7.widget.Toolbar)51 ActionBar (android.support.v7.app.ActionBar)49 Intent (android.content.Intent)44 ImageView (android.widget.ImageView)41 AdapterView (android.widget.AdapterView)33 ArrayList (java.util.ArrayList)30 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)29 DialogInterface (android.content.DialogInterface)25 AlertDialog (android.support.v7.app.AlertDialog)25 ListView (android.widget.ListView)25 Bundle (android.os.Bundle)22 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 SharedPreferences (android.content.SharedPreferences)21 Preference (android.support.v7.preference.Preference)20 GridLayoutManager (android.support.v7.widget.GridLayoutManager)19 SuppressLint (android.annotation.SuppressLint)16 Point (android.graphics.Point)16