List of usage examples for android.content.res Configuration KEYBOARD_NOKEYS
int KEYBOARD_NOKEYS
To view the source code for android.content.res Configuration KEYBOARD_NOKEYS.
Click Source Link
From source file:Main.java
/** * @param context/*from www . ja v a 2 s . c o m*/ * @return true if Hardware keyboard is available */ public static boolean isHardwareKeyboardAvailable(Context context) { return context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS; }
From source file:org.easyaccess.SwipingUtils.java
@Override public void onResume() { super.onResume(); // check if keyboard is connected or accessibility services are enabled if (Utils.isAccessibilityEnabled(getApplicationContext()) || getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) { TTS.speak(getResources().getString(R.string.appNameTalkBackFriendly)); }//from w ww . j a va 2s. c om WindowManager windowManager = getWindowManager(); LayoutInflater inflater = getLayoutInflater(); LayoutParamsAndViewUtils layoutParamsAndView = ScreenCurtainFunctions.prepareForCurtainCheck(inflater); ScreenCurtainFunctions appState = ((ScreenCurtainFunctions) getApplicationContext()); if (appState.getState() && !curtainSet) { curtainView = layoutParamsAndView.getView(); windowManager.addView(curtainView, layoutParamsAndView.getLayoutParams()); curtainSet = true; } else if (!appState.getState() && curtainSet) { windowManager.removeView(curtainView); curtainSet = false; } }
From source file:org.easyaccess.phonedialer.CallingScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_calling); recipientTextView = (TextView) findViewById(R.id.recipientTextView); btnAnswerCall = (Button) findViewById(R.id.btnAnswerCall); btnRejectCall = (Button) findViewById(R.id.btnRejectCall); tv_dailer_called_timer = (TextView) findViewById(R.id.tv_dailer_called_timer); gestureDetector = new GestureDetector(getApplicationContext(), new GestureListener()); mHandler = new Handler() { public void handleMessage(Message msg) { tv_dailer_called_timer.setText("" + time); }//from w w w . ja va2 s . c om }; if (getIntent().getExtras() != null) { if (Utils.callingDetails != null && Utils.callingDetails.get("name") != null) { // Retrieve the name of the recipient and the type of the number from the Bundle String name = Utils.callingDetails.get("name"); String typeOfNumber = Utils.callingDetails.get("type"); if (getIntent().getExtras().getInt("type", -1) == Utils.OUTGOING) { // outgoing call callerDetails = getString(R.string.calling) + " " + name + ": " + typeOfNumber; hideAnswerButton(); } else { // incoming call callerDetails = getString(R.string.call_from) + name + ": " + typeOfNumber; showAnswerAndRejectButtons(); } } else if (Utils.callingDetails != null) { // Retrieve the name of the recipient and the type of the number from the Bundle if (getIntent().getExtras().getInt("type", -1) == Utils.OUTGOING) { // outgoing call callerDetails = getString(R.string.calling) + Utils.callingDetails.get("number"); hideAnswerButton(); } else { // incoming call callerDetails = getString(R.string.call_from) + Utils.callingDetails.get("number"); showAnswerAndRejectButtons(); } } if (Utils.callingDetails != null) { displayCall(callerDetails, Utils.callingDetails.get("number")); } } else { recipientTextView.setVisibility(View.VISIBLE); recipientTextView.setText(getString(R.string.error) + "!"); recipientTextView.setContentDescription(getString(R.string.error)); } btnAnswerCall.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { answerCall(); } }); btnRejectCall.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { rejectCall(); } }); this.bReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Utils.CALL_ENDED)) { // check if keyboard is connected but accessibility services // are disabled //call end stop timer if (myTimer != null) { myTimer = null; } System.out.println("calling " + intent.getExtras().getString("message")); if (!Utils.isAccessibilityEnabled(getApplicationContext()) && getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) TTS.speak(intent.getExtras().getString("message")); Toast.makeText(getApplicationContext(), intent.getExtras().getString("message"), Toast.LENGTH_SHORT).show(); // check if there is any active call (no. of calls); if so, // activate the current call, if (Utils.off_hook == 1 || Utils.ringing == 1) { } else { // All calls ended, finish activity finish(); Utils.off_hook = 0; } } } }; }
From source file:com.farmerbb.taskbar.service.StartMenuService.java
@SuppressLint("RtlHardcoded") private void drawStartMenu() { IconCache.getInstance(this).clearCache(); final SharedPreferences pref = U.getSharedPreferences(this); final boolean hasHardwareKeyboard = getResources() .getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS; switch (pref.getString("show_search_bar", "keyboard")) { case "always": shouldShowSearchBox = true;/*from www . j a v a 2 s . co m*/ break; case "keyboard": shouldShowSearchBox = hasHardwareKeyboard; break; case "never": shouldShowSearchBox = false; break; } // Initialize layout params windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); U.setCachedRotation(windowManager.getDefaultDisplay().getRotation()); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE, shouldShowSearchBox ? 0 : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, PixelFormat.TRANSLUCENT); // Determine where to show the start menu on screen switch (U.getTaskbarPosition(this)) { case "bottom_left": layoutId = R.layout.start_menu_left; params.gravity = Gravity.BOTTOM | Gravity.LEFT; break; case "bottom_vertical_left": layoutId = R.layout.start_menu_vertical_left; params.gravity = Gravity.BOTTOM | Gravity.LEFT; break; case "bottom_right": layoutId = R.layout.start_menu_right; params.gravity = Gravity.BOTTOM | Gravity.RIGHT; break; case "bottom_vertical_right": layoutId = R.layout.start_menu_vertical_right; params.gravity = Gravity.BOTTOM | Gravity.RIGHT; break; case "top_left": layoutId = R.layout.start_menu_top_left; params.gravity = Gravity.TOP | Gravity.LEFT; break; case "top_vertical_left": layoutId = R.layout.start_menu_vertical_left; params.gravity = Gravity.TOP | Gravity.LEFT; break; case "top_right": layoutId = R.layout.start_menu_top_right; params.gravity = Gravity.TOP | Gravity.RIGHT; break; case "top_vertical_right": layoutId = R.layout.start_menu_vertical_right; params.gravity = Gravity.TOP | Gravity.RIGHT; break; } // Initialize views int theme = 0; switch (pref.getString("theme", "light")) { case "light": theme = R.style.AppTheme; break; case "dark": theme = R.style.AppTheme_Dark; break; } ContextThemeWrapper wrapper = new ContextThemeWrapper(this, theme); layout = (StartMenuLayout) LayoutInflater.from(wrapper).inflate(layoutId, null); startMenu = (GridView) layout.findViewById(R.id.start_menu); if ((shouldShowSearchBox && !hasHardwareKeyboard) || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) layout.viewHandlesBackButton(); boolean scrollbar = pref.getBoolean("scrollbar", false); startMenu.setFastScrollEnabled(scrollbar); startMenu.setFastScrollAlwaysVisible(scrollbar); startMenu.setScrollBarStyle(scrollbar ? View.SCROLLBARS_OUTSIDE_INSET : View.SCROLLBARS_INSIDE_OVERLAY); if (pref.getBoolean("transparent_start_menu", false)) startMenu.setBackgroundColor(0); searchView = (SearchView) layout.findViewById(R.id.search); int backgroundTint = U.getBackgroundTint(this); FrameLayout startMenuFrame = (FrameLayout) layout.findViewById(R.id.start_menu_frame); FrameLayout searchViewLayout = (FrameLayout) layout.findViewById(R.id.search_view_layout); startMenuFrame.setBackgroundColor(backgroundTint); searchViewLayout.setBackgroundColor(backgroundTint); if (shouldShowSearchBox) { if (!hasHardwareKeyboard) searchView.setIconifiedByDefault(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { if (!hasSubmittedQuery) { ListAdapter adapter = startMenu.getAdapter(); if (adapter != null) { hasSubmittedQuery = true; if (adapter.getCount() > 0) { View view = adapter.getView(0, null, startMenu); LinearLayout layout = (LinearLayout) view.findViewById(R.id.entry); layout.performClick(); } else { if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_TASKBAR")); else LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, query); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (intent.resolveActivity(getPackageManager()) != null) startActivity(intent); else { Uri uri = new Uri.Builder().scheme("https").authority("www.google.com") .path("search").appendQueryParameter("q", query).build(); intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(intent); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } } } } } return true; } @Override public boolean onQueryTextChange(String newText) { searchView.setIconified(false); View closeButton = searchView.findViewById(R.id.search_close_btn); if (closeButton != null) closeButton.setVisibility(View.GONE); refreshApps(newText, false); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { new Handler().postDelayed(() -> { EditText editText = (EditText) searchView.findViewById(R.id.search_src_text); if (editText != null) { editText.requestFocus(); editText.setSelection(editText.getText().length()); } }, 50); } return true; } }); searchView.setOnQueryTextFocusChangeListener((view, b) -> { if (!hasHardwareKeyboard) { ViewGroup.LayoutParams params1 = startMenu.getLayoutParams(); params1.height = getResources().getDimensionPixelSize(b && !U.isServiceRunning(this, "com.farmerbb.secondscreen.service.DisableKeyboardService") ? R.dimen.start_menu_height_half : R.dimen.start_menu_height); startMenu.setLayoutParams(params1); } if (!b) { if (hasHardwareKeyboard && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); else { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } }); searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI); LinearLayout powerButton = (LinearLayout) layout.findViewById(R.id.power_button); powerButton.setOnClickListener(view -> { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(location); }); powerButton.setOnGenericMotionListener((view, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(location); } return false; }); searchViewLayout.setOnClickListener(view -> searchView.setIconified(false)); startMenu.setOnItemClickListener((parent, view, position, id) -> { hideStartMenu(); AppEntry entry = (AppEntry) parent.getAdapter().getItem(position); U.launchApp(StartMenuService.this, entry.getPackageName(), entry.getComponentName(), entry.getUserId(StartMenuService.this), null, false, false); }); if (pref.getBoolean("transparent_start_menu", false)) layout.findViewById(R.id.search_view_child_layout).setBackgroundColor(0); } else searchViewLayout.setVisibility(View.GONE); textView = (TextView) layout.findViewById(R.id.no_apps_found); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiverAlt); LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver, new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU")); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiverAlt, new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU_ALT")); LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_START_MENU")); handler = new Handler(); refreshApps(true); windowManager.addView(layout, params); }
From source file:com.mobicage.rogerthat.util.ui.UIUtils.java
public static boolean hasHardKeyboard(Context pContext) { T.UI();/*w ww. j ava 2 s .c o m*/ if (!sHardKeyboardInitialized) { sHasHardKeyboard = (pContext.getResources() .getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); sHardKeyboardInitialized = true; L.d("Hard keyboard detection = " + sHasHardKeyboard); } return sHasHardKeyboard; }
From source file:kr.wdream.storyshop.AndroidUtilities.java
public static void checkDisplaySize(Context context, Configuration newConfiguration) { try {//w ww . ja v a 2s . co m density = context.getResources().getDisplayMetrics().density; Configuration configuration = newConfiguration; if (configuration == null) { configuration = context.getResources().getConfiguration(); } usingHardwareInput = configuration.keyboard != Configuration.KEYBOARD_NOKEYS && configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO; WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); if (manager != null) { Display display = manager.getDefaultDisplay(); if (display != null) { display.getMetrics(displayMetrics); display.getSize(displaySize); } } if (configuration.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) { int newSize = (int) Math.ceil(configuration.screenWidthDp * density); if (Math.abs(displaySize.x - newSize) > 3) { displaySize.x = newSize; } } if (configuration.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) { int newSize = (int) Math.ceil(configuration.screenHeightDp * density); if (Math.abs(displaySize.y - newSize) > 3) { displaySize.y = newSize; } } FileLog.e("tmessages", "display size = " + displaySize.x + " " + displaySize.y + " " + displayMetrics.xdpi + "x" + displayMetrics.ydpi); } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:com.ferdi2005.secondgram.AndroidUtilities.java
public static void checkDisplaySize(Context context, Configuration newConfiguration) { try {//from w w w . j a v a 2s. co m density = context.getResources().getDisplayMetrics().density; Configuration configuration = newConfiguration; if (configuration == null) { configuration = context.getResources().getConfiguration(); } usingHardwareInput = configuration.keyboard != Configuration.KEYBOARD_NOKEYS && configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO; WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); if (manager != null) { Display display = manager.getDefaultDisplay(); if (display != null) { display.getMetrics(displayMetrics); display.getSize(displaySize); } } if (configuration.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) { int newSize = (int) Math.ceil(configuration.screenWidthDp * density); if (Math.abs(displaySize.x - newSize) > 3) { displaySize.x = newSize; } } if (configuration.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) { int newSize = (int) Math.ceil(configuration.screenHeightDp * density); if (Math.abs(displaySize.y - newSize) > 3) { displaySize.y = newSize; } } FileLog.e("display size = " + displaySize.x + " " + displaySize.y + " " + displayMetrics.xdpi + "x" + displayMetrics.ydpi); } catch (Exception e) { FileLog.e(e); } }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
/** * */// ww w.j a v a 2 s.c o m private void configureOrientation() { String rotateDefault; if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) rotateDefault = PreferenceConstants.ROTATION_PORTRAIT; else rotateDefault = PreferenceConstants.ROTATION_LANDSCAPE; String rotate = prefs.getString(PreferenceConstants.ROTATION, rotateDefault); if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate)) rotate = rotateDefault; // request a forced orientation if requested by user if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); forcedOrientation = true; } else if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); forcedOrientation = true; } else if (PreferenceConstants.ROTATION_SENSOR.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); forcedOrientation = false; } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); forcedOrientation = false; } }
From source file:android.support.v7.internal.view.menu.MenuBuilder.java
private void setShortcutsVisibleInner(boolean shortcutsVisible) { mShortcutsVisible = shortcutsVisible && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS && mResources.getBoolean(R.bool.abc_config_showMenuShortcutsWhenKeyboardPresent); }