下面列出了android.content.res.Configuration#KEYBOARD_QWERTY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (mUrlHasFocus && mUrlFocusedWithoutAnimations
&& newConfig.keyboard != Configuration.KEYBOARD_QWERTY) {
// If we lose the hardware keyboard and the focus animations were not run, then the
// user has not typed any text, so we will just clear the focus instead.
setUrlBarFocus(false);
}
}
private boolean shouldShowCusrsorInLocationBar() {
Tab tab = mToolbarModel.getTab();
if (tab == null) return false;
NativePage nativePage = tab.getNativePage();
if (!(nativePage instanceof NewTabPage) && !(nativePage instanceof IncognitoNewTabPage)) {
return false;
}
Context context = mToolbar.getContext();
return DeviceFormFactor.isTablet(context)
&& context.getResources().getConfiguration().keyboard
== Configuration.KEYBOARD_QWERTY;
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (mUrlHasFocus && mUrlFocusedWithoutAnimations
&& newConfig.keyboard != Configuration.KEYBOARD_QWERTY) {
// If we lose the hardware keyboard and the focus animations were not run, then the
// user has not typed any text, so we will just clear the focus instead.
setUrlBarFocus(false);
}
}
private boolean shouldShowCusrsorInLocationBar() {
Tab tab = mToolbarModel.getTab();
if (tab == null) return false;
NativePage nativePage = tab.getNativePage();
if (!(nativePage instanceof NewTabPage) && !(nativePage instanceof IncognitoNewTabPage)) {
return false;
}
Context context = mToolbar.getContext();
return DeviceFormFactor.isTablet(context)
&& context.getResources().getConfiguration().keyboard
== Configuration.KEYBOARD_QWERTY;
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (mUrlHasFocus && mUrlFocusedWithoutAnimations
&& newConfig.keyboard != Configuration.KEYBOARD_QWERTY) {
// If we lose the hardware keyboard and the focus animations were not run, then the
// user has not typed any text, so we will just clear the focus instead.
setUrlBarFocus(false);
}
}
private boolean shouldShowCusrsorInLocationBar() {
Tab tab = mToolbarModel.getTab();
if (tab == null) return false;
NativePage nativePage = tab.getNativePage();
if (!(nativePage instanceof NewTabPage) && !(nativePage instanceof IncognitoNewTabPage)) {
return false;
}
Context context = mToolbar.getContext();
return DeviceFormFactor.isTablet()
&& context.getResources().getConfiguration().keyboard
== Configuration.KEYBOARD_QWERTY;
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
DialerApp.setTheme(this);
setContentView(R.layout.main);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
if (!preferences.getBoolean("privacy_policy", false)) {
showPrivacyPolicyDialog(preferences.edit());
}
if (Build.VERSION.SDK_INT >= 23 && !hasRequiredPermissions()) {
requestPermissions(PERMISSIONS, 0);
for (int i = 0; i < 5; i++) {
if (checkSelfPermission(PERMISSIONS[i]) == PackageManager.PERMISSION_GRANTED) {
continue;
} else {
finish();
}
}
}
numberField = (EditText)findViewById(R.id.number_field);
parseIntent(getIntent());
telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
setButtonListeners();
numberField.setCursorVisible(false);
numberField.requestFocus();
numberField.addTextChangedListener(this);
list = (ListView) findViewById(R.id.log_entries_list);
onCallLogScrollListener = new OnCallLogScrollListener(this);
list.setOnScrollListener(onCallLogScrollListener);
TypedValue outValue = new TypedValue();
getTheme().resolveAttribute(R.attr.drawableContactImage, outValue, true);
int defaultContactImageId = outValue.resourceId;
mAsyncContactImageLoader = new AsyncContactImageLoader(this, getResources().getDrawable(defaultContactImageId, getTheme()));
logEntryAdapter = new LogEntryAdapter(this, null, mAsyncContactImageLoader);
list.setAdapter(logEntryAdapter);
list.setOnItemClickListener(this);
list.setOnItemLongClickListener(this);
String t9Locale = preferences.getString("t9_locale", "system");
Context t9LocaleContext = null;
if (!t9Locale.equals("system")) {
Configuration t9Configuration = getResources().getConfiguration();
t9Configuration.setLocale(new Locale(t9Locale, t9Locale));
t9LocaleContext = createConfigurationContext(t9Configuration);
Resources t9Resources = t9LocaleContext.getResources();
// For numpad buttons (2...9)
int[] numpadLettersIds = new int[] {
R.string.numpad_2,
R.string.numpad_3,
R.string.numpad_4,
R.string.numpad_5,
R.string.numpad_6,
R.string.numpad_7,
R.string.numpad_8,
R.string.numpad_9
};
for (int i = 2; i <= 9; i++) {
((NumpadButton)(findViewById(buttonIds[i])))
.setLetters(t9Resources.getString(numpadLettersIds[i-2]));
}
}
contactsEntryAdapter = new ContactsEntryAdapter(this, mAsyncContactImageLoader, t9LocaleContext);
int keyboardType = getResources().getConfiguration().keyboard;
if (keyboardType == Configuration.KEYBOARD_QWERTY) {
numberField.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
contactsEntryAdapter.setRawFiltering(true);
findViewById(R.id.btn_toggle_numpad).setVisibility(View.INVISIBLE);
findViewById(R.id.numpad).setVisibility(View.GONE);
} else if (keyboardType == Configuration.KEYBOARD_12KEY) {
findViewById(R.id.btn_toggle_numpad).setVisibility(View.INVISIBLE);
findViewById(R.id.numpad).setVisibility(View.GONE);
}
getLoaderManager().initLoader(0, null, this);
getLoaderManager().initLoader(1, null, this);
getLoaderManager().getLoader(0).forceLoad();
getLoaderManager().getLoader(1).forceLoad();
}