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);
}
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("");
}
});
}
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();
}
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);
}
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");
}
Aggregations