public void checkScreenSize() { int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; switch (screenSize) { case Configuration.SCREENLAYOUT_SIZE_XLARGE: column_no = 4; break; case Configuration.SCREENLAYOUT_SIZE_UNDEFINED: column_no = 3; break; case Configuration.SCREENLAYOUT_SIZE_LARGE: column_no = 3; break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: column_no = 2; break; case Configuration.SCREENLAYOUT_SIZE_SMALL: column_no = 2; break; default: column_no = 2; } }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); //当屏幕变为横屏时 if (isLandscape()) { //设置为全屏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); mControlLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); mRoomInfoLayout.setVisibility(View.GONE); mFullScreen.setVisibility(View.GONE); mDanmakuView.show(); isShowDanmu = true; } else { //退出全屏 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); mRoomInfoLayout.setVisibility(View.VISIBLE); mFullScreen.setVisibility(View.VISIBLE); mDanmakuView.hide(); isShowDanmu = false; } updateVideoLayoutParams(); }
/** * Adjusts immersive full-screen flags depending on the screen orientation. * * @param config The current {@link Configuration}. */ private void adjustFullScreen(Configuration config) { final View decorView = getWindow().getDecorView(); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); mScrollView.setVisibility(View.GONE); mMovieView.setAdjustViewBounds(false); } else { decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE); mScrollView.setVisibility(View.VISIBLE); mMovieView.setAdjustViewBounds(true); } }
private void resetRecyclerViewPadding(int orientation) { if (mRecyclerView == null) return; int padding = 0; int navBar = 0; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { padding = getActivity().getResources().getDimensionPixelSize(R.dimen.content_padding); navBar = padding; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { boolean tabletMode = getResources().getBoolean(R.bool.android_helpers_tablet_mode); if (tabletMode || orientation == Configuration.ORIENTATION_PORTRAIT) { navBar = WindowHelper.getNavigationBarHeight(getActivity()); } } mRecyclerView.setPadding(padding, padding, 0, navBar); }
@SuppressWarnings("deprecation") public static void detectLanguage(Context context) { SharedPreferences setting = PreferenceManager .getDefaultSharedPreferences(context); String language = setting.getString(Util.PREF_LANGUAGE, "auto"); Resources res = context.getResources(); Configuration conf = res.getConfiguration(); switch (language) { case "en": case "zh": if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { conf.setLocale(new Locale(language)); } else { conf.locale = new Locale(language); } break; default: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { conf.setLocale(Resources.getSystem().getConfiguration().getLocales().get(0)); } else { conf.locale = Resources.getSystem().getConfiguration().locale; } } DisplayMetrics dm = res.getDisplayMetrics(); res.updateConfiguration(conf, dm); }
void simulateDayNight(int currentSetting) { final int DAY = 0; final int NIGHT = 1; final int FOLLOW_SYSTEM = 3; int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; if (currentSetting == DAY && currentNightMode != Configuration.UI_MODE_NIGHT_NO) { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_NO); } else if (currentSetting == NIGHT && currentNightMode != Configuration.UI_MODE_NIGHT_YES) { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_YES); } else if (currentSetting == FOLLOW_SYSTEM) { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); } }
@Override public void onCreate() { super.onCreate(); Resources resources = getResources(); DisplayMetrics dm = resources.getDisplayMetrics(); Configuration config = resources.getConfiguration(); // 应用用户选择语言 String language = SPUtil.getInstance(this).getLanguage(); if ("".equals(language)){ language =Locale.getDefault().getLanguage(); } if (language.equals(SPUtil.LANGUAGE_CHINESE)) { config.setLocale(Locale.getDefault()); } else { config.setLocale(Locale.ENGLISH); } resources.updateConfiguration(config, dm); mContext=getApplicationContext(); }
/** * Populates poster in screen. * @param container TVShowData * @param callback callback */ private void PopulateDetailsPoster(final TVShowData container, Callback callback) { ActivityUtils.loadImage(this, TMDB_IMAGE_URL + SIZE_W342 + container.getPosterPath(), true, R.drawable.disk_reel, tvShowPoster, null); String backgroundPosterPath = container.getBackgroundPath(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, true, R.drawable.no_background_poster, backgroundPoster, callback); } else { ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, false, R.drawable.no_background_poster, backgroundPoster, callback); } // Save background movie image poster to use in PersonProfile page. ActivityUtils.saveStringToPreferences(this, KNOWN_FOR_BACKGROUND_POSTER, container.getBackgroundPath()); }
/** * apply the gravity for window params. * * @param expectGravity the expect gravity * @param applyWlp the window layout params. */ private static void applyGravity(Context context,int expectGravity, WindowManager.LayoutParams applyWlp) { if (Build.VERSION.SDK_INT >= 17) { final Configuration configuration = context.getResources().getConfiguration(); final int gravity = Gravity.getAbsoluteGravity(expectGravity, configuration.getLayoutDirection()); applyWlp.gravity = gravity; if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) { applyWlp.horizontalWeight = 1.0f; } if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) { applyWlp.verticalWeight = 1.0f; } } else { applyWlp.gravity = expectGravity; } }
/** * We need to do locale work here, because we need to intercept * each hit to onConfigurationChanged. */ @Override public void onConfigurationChanged(Configuration config) { // Do nothing if we're in the background. It'll simply cause a loop // (Bug 936756 Comment 11), and it's not necessary. if (mInBackground) { super.onConfigurationChanged(config); return; } // Otherwise, correct the locale. This catches some cases that the current Activity // doesn't get a chance to. try { LocaleManager.getInstance().correctLocale(this, getResources(), config); } catch (IllegalStateException ex) { // Activity hasn't started yey, so we have no ContextGetter in LocaleManager. } super.onConfigurationChanged(config); }
static int getNavBarHeight(Context c) { int result = 0; boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if (!hasMenuKey && !hasBackKey) { // The device has a navigation bar Resources res = c.getResources(); int orientation = res.getConfiguration().orientation; int resourceId; if (isTablet(c)) { resourceId = res.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); } else { resourceId = res.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android"); } if (resourceId > 0) { return res.getDimensionPixelSize(resourceId); } } return result; }
protected void setFullScreenForSmallLandscape() { int nScreenSizeCategory = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; int nScreenOrientation = getResources().getConfiguration().orientation; if (nScreenOrientation != Configuration.ORIENTATION_LANDSCAPE) { if (nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_SMALL) { // making it full screen in portrait mode if small screen getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } } else { if (nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_SMALL || nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // making it full screen in landscape mode if small or normal screen getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } } }
/** * Function fire on system update widget * * @param context Context of application * @param appWidgetManager App widget manger * @param appWidgetIds Widget system ids */ @Override public void onUpdate(Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int count = appWidgetIds.length; //set widget language with the system language Locale locale = new Locale(Resources.getSystem().getConfiguration().locale.getLanguage()); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); this.context = context; //loop in all widgets for (int i = 0; i < count; i++) { svcIntent = new Intent(context, CalenderRemoteViewsService.class); final int widgetId = appWidgetIds[i]; remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_calender); remoteViews.setRemoteAdapter(R.id.calendar_pager, svcIntent); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds[i], R.id.calendar_pager); HGDate hgDate = new HGDate(); hgDate.toHigri(); remoteViews.setTextViewText(R.id.textView8, Dates.getCurrentWeekDay()); remoteViews.setTextViewText(R.id.textView7, NumbersLocal.convertToNumberTypeSystem(context, hgDate.getDay() + "")); remoteViews.setTextViewText(R.id.textView24, NumbersLocal.convertToNumberTypeSystem(context, hgDate.getYear() + "")); remoteViews.setTextViewText(R.id.curr_month_txt, Dates.islamicMonthName(context, hgDate.getMonth() - 1)); remoteViews.setTextViewText(R.id.curr_month_txt_other, showOtherMonth(hgDate)); PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0); remoteViews.setOnClickPendingIntent(R.id.relativeLayout, configPendingIntent); appWidgetManager.updateAppWidget(widgetId, remoteViews); } }
public static void resetViewBottomPadding(@Nullable View view, boolean scroll) { if (view == null) return; Context context = ContextHelper.getBaseContext(view); int orientation = context.getResources().getConfiguration().orientation; int left = view.getPaddingLeft(); int right = view.getPaddingRight(); int bottom = view.getPaddingTop(); int top = view.getPaddingTop(); int navBar = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { boolean tabletMode = context.getResources().getBoolean(R.bool.android_helpers_tablet_mode); if (tabletMode || orientation == Configuration.ORIENTATION_PORTRAIT) { navBar = getNavigationBarHeight(context); } if (!scroll) { navBar += getStatusBarHeight(context); } } if (!scroll) { navBar += getToolbarHeight(context); } view.setPadding(left, top, right, (bottom + navBar)); }
private void drawResizedBitmap(final Bitmap src, final Bitmap dst) { Display getOrient = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; Point point = new Point(); getOrient.getSize(point); int screen_width = point.x; int screen_height = point.y; Log.d(TAG, String.format("screen size (%d,%d)", screen_width, screen_height)); if (screen_width < screen_height) { orientation = Configuration.ORIENTATION_PORTRAIT; mScreenRotation = -90; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; mScreenRotation = 0; } Assert.assertEquals(dst.getWidth(), dst.getHeight()); final float minDim = Math.min(src.getWidth(), src.getHeight()); final Matrix matrix = new Matrix(); // We only want the center square out of the original rectangle. final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2); final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2); matrix.preTranslate(translateX, translateY); final float scaleFactor = dst.getHeight() / minDim; matrix.postScale(scaleFactor, scaleFactor); // Rotate around the center if necessary. if (mScreenRotation != 0) { matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f); matrix.postRotate(mScreenRotation); matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f); } final Canvas canvas = new Canvas(dst); canvas.drawBitmap(src, matrix, null); }
public static int getDeviceDefaultOrientation(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Configuration config = context.getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && config.orientation == Configuration.ORIENTATION_LANDSCAPE) || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && config.orientation == Configuration.ORIENTATION_PORTRAIT)) { return Configuration.ORIENTATION_LANDSCAPE; } else { return Configuration.ORIENTATION_PORTRAIT; } }
@Override public void onConfigurationChanged(Configuration paramConfiguration) { super.onConfigurationChanged(paramConfiguration); if (this.j != null) { try { this.j.getClass().getDeclaredMethod("onConfigurationChanged", new Class[]{Configuration.class}) .invoke(this.j, new Object[]{paramConfiguration}); return; } catch (Exception localException) { Log.e(TAG, "onLowMemory()" + localException); } } }
public void hideKeyboardVisibleMode() { boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; //contactPicture.setVisibility(View.VISIBLE); if (isOrientationLandscape && topBar != null) { //topBar.setVisibility(View.VISIBLE); } LinphoneActivity.instance().hideTabBar(false); }
@Override public void onConfigurationChanged(Configuration newConfig) { MLog.d(TAG, "changing conf"); removeFragment(mConnectionInfoFragment); removeFragment(mEmptyFragment); removeFragment(mProjectListFragment); removeFragment(mFolderListFragment); if (mCombinedFolderAndProjectFragment != null) removeFragment(mCombinedFolderAndProjectFragment); RelativeLayout mainContent = (RelativeLayout) findViewById(R.id.main_content); mainContent.removeAllViews(); super.onConfigurationChanged(newConfig); loadUI(); }
private boolean isPortraitMode() { int orientation = mContext.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { return false; } if (orientation == Configuration.ORIENTATION_PORTRAIT) { return true; } Log.d(TAG, "isPortraitMode returning false by default"); return false; }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); ViewHelper.resetSpanCount(mRecyclerView, getActivity().getResources().getInteger( R.integer.wallpapers_column_count)); resetViewBottomPadding(mRecyclerView, true); }
public void onConfigurationChanged(Configuration newConfig) { updateConfiguration(); if (this.mRemoteFragment != null) { this.mRemoteFragment.onConfigurationChanged(newConfig); } super.onConfigurationChanged(newConfig); }
@Override protected void onCreate(Bundle bundle) { SciChartBuilder.init(this); super.onCreate(bundle); setContentView(R.layout.activity_main); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } TextView titleView = (TextView) findViewById(R.id.title); titleView.setText(getTitle().toString()); setUpDrawerAndToolbar(); settingsButton = (ImageButton) findViewById(R.id.toolbar_button); settingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View item) { drawerLayout.onMenuItemClick(); } }); drawerLayout.setViewsClickableAction(new Action1<Boolean>() { @Override public void execute(Boolean isEnabled) { settingsButton.setEnabled(isEnabled); } }); exampleFragment = (ExampleBaseFragment) getFragmentManager().findFragmentById(R.id.fragment_id); }
public BarConfig(Activity activity) { Resources res = activity.getResources(); mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); mSmallestWidthDp = getSmallestWidthDp(activity); mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME); mActionBarHeight = getActionBarHeight(activity); mNavigationBarHeight = getNavigationBarHeight(activity); mNavigationBarWidth = getNavigationBarWidth(activity); mHasNavigationBar = (mNavigationBarHeight > 0); }
private String convertDoubanContent() { if (doubanMomentStory.getContent() == null) { return null; } String css; if ((context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES) { css = "<link rel=\"stylesheet\" href=\"file:///android_asset/douban_dark.css\" type=\"text/css\">"; } else { css = "<link rel=\"stylesheet\" href=\"file:///android_asset/douban_light.css\" type=\"text/css\">"; } String content = doubanMomentStory.getContent(); ArrayList<DoubanMomentNews.posts.thumbs> imageList = doubanMomentStory.getPhotos(); for (int i = 0; i < imageList.size(); i++) { String old = "<img id=\"" + imageList.get(i).getTag_name() + "\" />"; String newStr = "<img id=\"" + imageList.get(i).getTag_name() + "\" " + "src=\"" + imageList.get(i).getMedium().getUrl() + "\"/>"; content = content.replace(old, newStr); } StringBuilder builder = new StringBuilder(); builder.append( "<!DOCTYPE html>\n"); builder.append("<html lang=\"ZH-CN\" xmlns=\"http://www.w3.org/1999/xhtml\">\n"); builder.append("<head>\n<meta charset=\"utf-8\" />\n"); builder.append(css); builder.append("\n</head>\n<body>\n"); builder.append("<div class=\"container bs-docs-container\">\n"); builder.append("<div class=\"post-container\">\n"); builder.append(content); builder.append("</div>\n</div>\n</body>\n</html>"); return builder.toString(); }
/** * Called by the system when the device configuration changes while your activity is running. * * @param newConfig The new device configuration */ public void onConfigurationChanged(Configuration newConfig) { for (CordovaPlugin plugin : this.pluginMap.values()) { if (plugin != null) { plugin.onConfigurationChanged(newConfig); } } }
@Override public void onConfigurationChanged(final Configuration conf) { SettingsValues settingsValues = mSettings.getCurrent(); if (settingsValues.mHasHardwareKeyboard != Settings.readHasHardwareKeyboard(conf)) { // If the state of having a hardware keyboard changed, then we want to reload the // settings to adjust for that. // TODO: we should probably do this unconditionally here, rather than only when we // have a change in hardware keyboard configuration. loadSettings(); } super.onConfigurationChanged(conf); }
private void fixLayoutInternal() { if (getParentActivity() == null) { return; } WindowManager manager = (WindowManager) Gallery.applicationContext .getSystemService(Activity.WINDOW_SERVICE); int rotation = manager.getDefaultDisplay().getRotation(); columnsCount = 2; if (!AndroidUtilities.isTablet() && (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90)) { columnsCount = 4; } listAdapter.notifyDataSetChanged(); if (dropDownContainer != null) { if (!AndroidUtilities.isTablet()) { FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer .getLayoutParams(); layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); dropDownContainer.setLayoutParams(layoutParams); } if (!AndroidUtilities.isTablet() && Gallery.applicationContext.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { dropDown.setTextSize(18); } else { dropDown.setTextSize(20); } } }
@TargetApi(Build.VERSION_CODES.N) private static Context updateResources(Context context, String language) { Locale locale = new Locale(language); Locale.setDefault(locale); Configuration configuration = context.getResources().getConfiguration(); configuration.setLocale(locale); configuration.setLayoutDirection(locale); return context.createConfigurationContext(configuration); }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (mLocale != null && !newConfig.locale.getLanguage().equals("en")) { Resources res = getBaseContext().getResources(); Configuration config = res.getConfiguration(); Locale.setDefault(mLocale); config.locale = mLocale; res.updateConfiguration(config, res.getDisplayMetrics()); } }
@Override public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); Bundle bundle = getArguments(); pos = bundle.getInt("pos"); bean = (AppBean) bundle.getSerializable("bean"); contentView = View.inflate(getContext(), R.layout.fragment_req_menu, null); dialog.setContentView(contentView); ((TextView) contentView.findViewById(R.id.tv_title)).setText(bean.getLabel()); if (bean.isMark()) { contentView.findViewById(R.id.view_menu_mark).setVisibility(View.GONE); contentView.findViewById(R.id.view_menu_undo_mark).setOnClickListener(this); contentView.findViewById(R.id.view_hint_undo_mark) .setVisibility(bean.isHintUndoMark() ? View.VISIBLE : View.GONE); } else { contentView.findViewById(R.id.view_menu_undo_mark).setVisibility(View.GONE); contentView.findViewById(R.id.view_menu_mark).setOnClickListener(this); contentView.findViewById(R.id.view_hint_mark) .setVisibility(bean.isHintMark() ? View.VISIBLE : View.GONE); } contentView.findViewById(R.id.view_hint_lost) .setVisibility(bean.isHintLost() ? View.VISIBLE : View.GONE); contentView.findViewById(R.id.view_menu_goto_market).setOnClickListener(this); contentView.findViewById(R.id.view_menu_copy_code).setOnClickListener(this); BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior .from((View) contentView.getParent()); if (bean.isHintLost()) { // In landscape, STATE_EXPANDED doesn't make sheet expanded. // Maybe it's a bug. So do this to fix it. if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { contentView.measure(0, 0); bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight()); } bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); } else { bottomSheetBehavior.setPeekHeight(getResources() .getDimensionPixelSize(R.dimen.req_bottom_menu_height)); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String languageToLoad = ConfigPreferences.getApplicationLanguage(this); Locale locale = new Locale(languageToLoad); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(getString(R.string.title_activity_settings)); getFragmentManager().beginTransaction().replace(android.R.id.content, new MainSettings()).commit(); }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (player != null) { player.onConfigurationChanged(newConfig); } }
public void setLocale(String lang) { Locale myLocale = new Locale(lang); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale; res.updateConfiguration(conf, dm); Intent refresh = new Intent(getContext(), MainActivity.class); startActivity(refresh); getActivity().finish(); }
private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) { Resources res = activity.getResources(); mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); mSmallestWidthDp = getSmallestWidthDp(activity); mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME); mActionBarHeight = getActionBarHeight(activity); mNavigationBarHeight = getNavigationBarHeight(activity); mNavigationBarWidth = getNavigationBarWidth(activity); mHasNavigationBar = (mNavigationBarHeight > 0); mTranslucentStatusBar = translucentStatusBar; mTranslucentNavBar = traslucentNavBar; }
private void invertGravityIfNecessary() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return; Configuration config = getResources().getConfiguration(); if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { switch (buttonGravity) { case START: buttonGravity = GravityEnum.END; break; case END: buttonGravity = GravityEnum.START; break; } } }