Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Remove Window and Max Window Size settings. Fixes #1822 (#1835)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin committed Sep 14, 2019
1 parent 560505e commit 6090cf4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
Expand Down
21 changes: 0 additions & 21 deletions app/src/main/res/layout/options_display.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,6 @@
app:description="@string/developer_options_display_dpi"
app:highlightedTextColor="@color/fog" />

<org.mozilla.vrbrowser.ui.views.settings.DoubleEditSetting
android:id="@+id/windowSize_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:width="75dp"
android:inputType="number"
android:maxLength="4"
app:by="@string/developer_options_by"
app:description="@string/developer_options_window_size"
app:highlightedTextColor="@color/fog" />

<org.mozilla.vrbrowser.ui.views.settings.DoubleEditSetting
android:id="@+id/maxWindowSize_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:width="75dp"
android:inputType="number"
android:maxLength="4"
app:by="@string/developer_options_by"
app:description="@string/developer_options_max_window_size"
app:highlightedTextColor="@color/fog" />
</LinearLayout>
</ScrollView>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/setting_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<TextView
Expand Down
6 changes: 1 addition & 5 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
<string name="settings_key_user_agent_version" translatable="false">settings_user_agent_version</string>
<string name="settings_key_input_mode" translatable="false">settings_touch_mode</string>
<string name="settings_key_display_density" translatable="false">settings_display_density</string>
<string name="settings_key_window_width" translatable="false">settings_window_width</string>
<string name="settings_key_window_height" translatable="false">settings_window_height</string>
<string name="settings_key_display_dpi" translatable="false">settings_display_dpi</string>
<string name="settings_key_max_window_width" translatable="false">settings_max_window_width</string>
<string name="settings_key_max_window_height" translatable="false">settings_max_window_height</string>
<string name="settings_key_display_dpi" translatable="false">settings_display_dpi</string>>
<string name="settings_key_env" translatable="false">settings_env</string>
<string name="settings_key_pointer_color" translatable="false">settings_pointer_color</string>
<string name="settings_key_scroll_direction" translatable="false">settings_scroll_direction</string>
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@
use for the display density. -->
<string name="developer_options_display_density">Display Density:</string>

<!-- This string is used to label two integer-entry fields where the default width and height of
the browser window may be set. -->
<string name="developer_options_window_size">Window Size:</string>

<!-- This string is used to label buttons to enable editing of text fields in the
'Developer Options' dialog. Pressing this button switches the text to
editable-text fields so their values may be changed. -->
Expand All @@ -324,10 +320,6 @@
for the virtual displays Dots Per Inch (DPI). -->
<string name="developer_options_display_dpi">Display DPI:</string>

<!-- This string is used to label two integer entry fields that will allow the user to adjust
the maximum window size in the X and Y dimensions. -->
<string name="developer_options_max_window_size">Max. Window Size:</string>

<!-- This string is used to label radio buttons for setting Multi-Sample Anti-Aliasing (MSAA) in
VR Immersive Mode. -->
<string name="developer_options_msaa">MSAA</string>
Expand Down

0 comments on commit 6090cf4

Please sign in to comment.