From 832f747a83f1a0e3efcf1c78623752f4ee42c5d8 Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Fri, 13 Sep 2019 16:50:30 -0700 Subject: [PATCH] Remove Window and Max Window Size settings. Fixes #1822 --- .../vrbrowser/browser/SettingsStore.java | 36 +--- .../widgets/settings/DisplayOptionsView.java | 154 ------------------ app/src/main/res/layout/options_display.xml | 21 --- app/src/main/res/layout/setting_edit.xml | 2 +- app/src/main/res/values/non_L10n.xml | 6 +- app/src/main/res/values/strings.xml | 8 - 6 files changed, 6 insertions(+), 221 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java index 9535d5b56..eb74987b8 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java @@ -266,25 +266,11 @@ public void setDisplayDensity(float aDensity) { } public int getWindowWidth() { - return mPrefs.getInt( - mContext.getString(R.string.settings_key_window_width), WINDOW_WIDTH_DEFAULT); - } - - public void setWindowWidth(int aWindowWidth) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putInt(mContext.getString(R.string.settings_key_window_width), aWindowWidth); - editor.commit(); + return WINDOW_WIDTH_DEFAULT; } public int getWindowHeight() { - return mPrefs.getInt( - mContext.getString(R.string.settings_key_window_height), WINDOW_HEIGHT_DEFAULT); - } - - public void setWindowHeight(int aWindowHeight) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putInt(mContext.getString(R.string.settings_key_window_height), aWindowHeight); - editor.commit(); + return WINDOW_HEIGHT_DEFAULT; } public float getWindowAspect() { @@ -303,25 +289,11 @@ public void setDisplayDpi(int aDpi) { } public int getMaxWindowWidth() { - return mPrefs.getInt( - mContext.getString(R.string.settings_key_max_window_width), MAX_WINDOW_WIDTH_DEFAULT); - } - - public void setMaxWindowWidth(int aMaxWindowWidth) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putInt(mContext.getString(R.string.settings_key_max_window_width), aMaxWindowWidth); - editor.commit(); + return MAX_WINDOW_WIDTH_DEFAULT; } public int getMaxWindowHeight() { - return mPrefs.getInt( - mContext.getString(R.string.settings_key_max_window_height), MAX_WINDOW_HEIGHT_DEFAULT); - } - - public void setMaxWindowHeight(int aMaxWindowHeight) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putInt(mContext.getString(R.string.settings_key_max_window_height), aMaxWindowHeight); - editor.commit(); + return MAX_WINDOW_HEIGHT_DEFAULT; } public String getEnvironment() { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java index 2aea905c0..f45938308 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java @@ -93,30 +93,6 @@ private void initialize(Context aContext) { mBinding.dpiEdit.setFirstText(Integer.toString(SettingsStore.getInstance(getContext()).getDisplayDpi())); mBinding.dpiEdit.setOnClickListener(mDpiListener); setDisplayDpi(SettingsStore.getInstance(getContext()).getDisplayDpi()); - - mBinding.windowSizeEdit.setHint1(String.valueOf(SettingsStore.WINDOW_WIDTH_DEFAULT)); - mBinding.windowSizeEdit.setHint2(String.valueOf(SettingsStore.WINDOW_HEIGHT_DEFAULT)); - mBinding.windowSizeEdit.setDefaultFirstValue(String.valueOf(SettingsStore.WINDOW_WIDTH_DEFAULT)); - mBinding.windowSizeEdit.setDefaultSecondValue(String.valueOf(SettingsStore.WINDOW_HEIGHT_DEFAULT)); - mBinding.windowSizeEdit.setFirstText(Integer.toString(SettingsStore.getInstance(getContext()).getWindowWidth())); - mBinding.windowSizeEdit.setSecondText(Integer.toString(SettingsStore.getInstance(getContext()).getWindowHeight())); - mBinding.windowSizeEdit.setOnClickListener(mWindowSizeListener); - setWindowSize( - SettingsStore.getInstance(getContext()).getWindowWidth(), - SettingsStore.getInstance(getContext()).getWindowHeight(), - false); - - mBinding.maxWindowSizeEdit.setHint1(String.valueOf(SettingsStore.MAX_WINDOW_WIDTH_DEFAULT)); - mBinding.maxWindowSizeEdit.setHint2(String.valueOf(SettingsStore.MAX_WINDOW_HEIGHT_DEFAULT)); - mBinding.maxWindowSizeEdit.setDefaultFirstValue(String.valueOf(SettingsStore.MAX_WINDOW_WIDTH_DEFAULT)); - mBinding.maxWindowSizeEdit.setDefaultSecondValue(String.valueOf(SettingsStore.MAX_WINDOW_HEIGHT_DEFAULT)); - mBinding.maxWindowSizeEdit.setFirstText(Integer.toString(SettingsStore.getInstance(getContext()).getMaxWindowWidth())); - mBinding.maxWindowSizeEdit.setSecondText(Integer.toString(SettingsStore.getInstance(getContext()).getMaxWindowHeight())); - mBinding.maxWindowSizeEdit.setOnClickListener(mMaxWindowSizeListener); - setMaxWindowSize( - SettingsStore.getInstance(getContext()).getMaxWindowWidth(), - SettingsStore.getInstance(getContext()).getMaxWindowHeight(), - false); } @Override @@ -147,16 +123,6 @@ public boolean isEditing() { mBinding.dpiEdit.cancel(); } - if (mBinding.windowSizeEdit.isEditing()) { - editing = true; - mBinding.windowSizeEdit.cancel(); - } - - if (mBinding.maxWindowSizeEdit.isEditing()) { - editing = true; - mBinding.maxWindowSizeEdit.cancel(); - } - if (mBinding.homepageEdit.isEditing()) { editing = true; mBinding.homepageEdit.cancel(); @@ -214,28 +180,6 @@ public boolean isEditing() { } }; - private OnClickListener mWindowSizeListener = (view) -> { - try { - int newWindowWidth = Integer.parseInt(mBinding.windowSizeEdit.getFirstText()); - int newWindowHeight = Integer.parseInt(mBinding.windowSizeEdit.getSecondText()); - setWindowSize(newWindowWidth, newWindowHeight, true); - - } catch (NumberFormatException e) { - setWindowSize(SettingsStore.WINDOW_WIDTH_DEFAULT, SettingsStore.WINDOW_HEIGHT_DEFAULT, true); - } - }; - - private OnClickListener mMaxWindowSizeListener = (view) -> { - try { - int newMaxWindowWidth = Integer.parseInt(mBinding.maxWindowSizeEdit.getFirstText()); - int newMaxWindowHeight = Integer.parseInt(mBinding.maxWindowSizeEdit.getSecondText()); - setMaxWindowSize(newMaxWindowWidth, newMaxWindowHeight, true); - - } catch (NumberFormatException e) { - setMaxWindowSize(SettingsStore.MAX_WINDOW_WIDTH_DEFAULT, SettingsStore.MAX_WINDOW_HEIGHT_DEFAULT, true); - } - }; - private SwitchSetting.OnCheckedChangeListener mCurvedDisplayListener = (compoundButton, enabled, apply) -> setCurvedDisplay(enabled, true); @@ -260,19 +204,6 @@ public boolean isEditing() { restart = restart | setDisplayDensity(SettingsStore.DISPLAY_DENSITY_DEFAULT); restart = restart | setDisplayDpi(SettingsStore.DISPLAY_DPI_DEFAULT); - try { - if (Integer.parseInt(mBinding.windowSizeEdit.getFirstText()) != SettingsStore.WINDOW_WIDTH_DEFAULT || - Integer.parseInt(mBinding.windowSizeEdit.getSecondText()) != SettingsStore.WINDOW_HEIGHT_DEFAULT) { - setWindowSize(SettingsStore.WINDOW_WIDTH_DEFAULT, SettingsStore.WINDOW_HEIGHT_DEFAULT, true); - } - if (Integer.parseInt(mBinding.maxWindowSizeEdit.getFirstText()) != SettingsStore.MAX_WINDOW_WIDTH_DEFAULT || - Integer.parseInt(mBinding.maxWindowSizeEdit.getSecondText()) != SettingsStore.MAX_WINDOW_HEIGHT_DEFAULT) { - setMaxWindowSize(SettingsStore.MAX_WINDOW_WIDTH_DEFAULT, SettingsStore.MAX_WINDOW_HEIGHT_DEFAULT, true); - } - } catch (NumberFormatException ex) { - setWindowSize(SettingsStore.WINDOW_WIDTH_DEFAULT, SettingsStore.WINDOW_HEIGHT_DEFAULT, true); - setMaxWindowSize(SettingsStore.MAX_WINDOW_WIDTH_DEFAULT, SettingsStore.MAX_WINDOW_HEIGHT_DEFAULT, true); - } setHomepage(mDefaultHomepageUrl); setAutoplay(SettingsStore.AUTOPLAY_ENABLED, true); @@ -393,81 +324,6 @@ private boolean setDisplayDpi(int newDpi) { return restart; } - private void setWindowSize(int newWindowWidth, int newWindowHeight, boolean doApply) { - int prevWindowWidth = SettingsStore.getInstance(getContext()).getWindowWidth(); - if (newWindowWidth <= 0) { - newWindowWidth = prevWindowWidth; - } - - int prevWindowHeight = SettingsStore.getInstance(getContext()).getWindowHeight(); - if (newWindowHeight <= 0) { - newWindowHeight = prevWindowHeight; - } - - int maxWindowWidth = SettingsStore.getInstance(getContext()).getMaxWindowWidth(); - if (newWindowWidth > maxWindowWidth) { - newWindowWidth = maxWindowWidth; - } - - int maxWindowHeight = SettingsStore.getInstance(getContext()).getMaxWindowHeight(); - if (newWindowHeight > maxWindowHeight) { - newWindowHeight = maxWindowHeight; - } - - if (prevWindowWidth != newWindowWidth || prevWindowHeight != newWindowHeight) { - SettingsStore.getInstance(getContext()).setWindowWidth(newWindowWidth); - SettingsStore.getInstance(getContext()).setWindowHeight(newWindowHeight); - - if (doApply) { - mWidgetManager.setWindowSize(newWindowWidth, newWindowHeight); - } - } - - String newWindowWidthStr = Integer.toString(newWindowWidth); - mBinding.windowSizeEdit.setFirstText(newWindowWidthStr); - String newWindowHeightStr = Integer.toString(newWindowHeight); - mBinding.windowSizeEdit.setSecondText(newWindowHeightStr); - } - - private void setMaxWindowSize(int newMaxWindowWidth, int newMaxWindowHeight, boolean doApply) { - int prevMaxWindowWidth = SettingsStore.getInstance(getContext()).getMaxWindowWidth(); - if (newMaxWindowWidth <= 0) { - newMaxWindowWidth = prevMaxWindowWidth; - } - - int prevMaxWindowHeight = SettingsStore.getInstance(getContext()).getMaxWindowHeight(); - if (newMaxWindowHeight <= 0) { - newMaxWindowHeight = prevMaxWindowHeight; - } - - int windowWidth = SettingsStore.getInstance(getContext()).getWindowWidth(); - if (newMaxWindowWidth < windowWidth) { - newMaxWindowWidth = windowWidth; - } - - int windowHeight = SettingsStore.getInstance(getContext()).getWindowHeight(); - if (newMaxWindowHeight < windowHeight) { - newMaxWindowHeight = windowHeight; - } - - if (newMaxWindowWidth != prevMaxWindowWidth || - newMaxWindowHeight != prevMaxWindowHeight) { - SettingsStore.getInstance(getContext()).setMaxWindowWidth(newMaxWindowWidth); - SettingsStore.getInstance(getContext()).setMaxWindowHeight(newMaxWindowHeight); - - if (doApply) { - SettingsStore.getInstance(getContext()).setMaxWindowWidth(newMaxWindowWidth); - SettingsStore.getInstance(getContext()).setMaxWindowHeight(newMaxWindowHeight); - showRestartDialog(); - } - } - - String newMaxWindowWidthStr = Integer.toString(newMaxWindowWidth); - mBinding.maxWindowSizeEdit.setFirstText(newMaxWindowWidthStr); - String newMaxWindowHeightStr = Integer.toString(newMaxWindowHeight); - mBinding.maxWindowSizeEdit.setSecondText(newMaxWindowHeightStr); - } - @Override public void onGlobalFocusChanged(View oldFocus, View newFocus) { if (oldFocus != null) { @@ -477,16 +333,6 @@ public void onGlobalFocusChanged(View oldFocus, View newFocus) { if (mBinding.dpiEdit.contains(oldFocus) && mBinding.dpiEdit.isEditing()) { mBinding.dpiEdit.cancel(); } - if (mBinding.windowSizeEdit.contains(oldFocus) && - (newFocus != null && !mBinding.windowSizeEdit.contains(newFocus)) && - mBinding.windowSizeEdit.isEditing()) { - mBinding.windowSizeEdit.cancel(); - } - if (mBinding.maxWindowSizeEdit.contains(oldFocus) && - (newFocus != null && !mBinding.maxWindowSizeEdit.contains(newFocus)) && - mBinding.maxWindowSizeEdit.isEditing()) { - mBinding.maxWindowSizeEdit.cancel(); - } if (mBinding.homepageEdit.contains(oldFocus) && mBinding.homepageEdit.isEditing()) { mBinding.homepageEdit.cancel(); } diff --git a/app/src/main/res/layout/options_display.xml b/app/src/main/res/layout/options_display.xml index 21d85e551..7fc3b4579 100644 --- a/app/src/main/res/layout/options_display.xml +++ b/app/src/main/res/layout/options_display.xml @@ -112,27 +112,6 @@ app:description="@string/developer_options_display_dpi" app:highlightedTextColor="@color/fog" /> - - - diff --git a/app/src/main/res/layout/setting_edit.xml b/app/src/main/res/layout/setting_edit.xml index 1b2ae91d4..10ed01d6d 100644 --- a/app/src/main/res/layout/setting_edit.xml +++ b/app/src/main/res/layout/setting_edit.xml @@ -25,7 +25,7 @@ android:id="@+id/setting_description" style="@style/settingsText" android:layout_marginEnd="5dp" - android:text="@string/developer_options_window_size" + android:text="@string/developer_options_display_dpi" tools:text="Setting Description" /> settings_user_agent_version settings_touch_mode settings_display_density - settings_window_width - settings_window_height - settings_display_dpi - settings_max_window_width - settings_max_window_height + settings_display_dpi> settings_env settings_pointer_color settings_scroll_direction diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 974dd6ac0..cddfa3dd6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -302,10 +302,6 @@ use for the display density. --> Display Density: - - Window Size: - @@ -324,10 +320,6 @@ for the virtual displays Dots Per Inch (DPI). --> Display DPI: - - Max. Window Size: - MSAA