@@ -93,30 +93,6 @@ private void initialize(Context aContext) {
9393 mBinding .dpiEdit .setFirstText (Integer .toString (SettingsStore .getInstance (getContext ()).getDisplayDpi ()));
9494 mBinding .dpiEdit .setOnClickListener (mDpiListener );
9595 setDisplayDpi (SettingsStore .getInstance (getContext ()).getDisplayDpi ());
96-
97- mBinding .windowSizeEdit .setHint1 (String .valueOf (SettingsStore .WINDOW_WIDTH_DEFAULT ));
98- mBinding .windowSizeEdit .setHint2 (String .valueOf (SettingsStore .WINDOW_HEIGHT_DEFAULT ));
99- mBinding .windowSizeEdit .setDefaultFirstValue (String .valueOf (SettingsStore .WINDOW_WIDTH_DEFAULT ));
100- mBinding .windowSizeEdit .setDefaultSecondValue (String .valueOf (SettingsStore .WINDOW_HEIGHT_DEFAULT ));
101- mBinding .windowSizeEdit .setFirstText (Integer .toString (SettingsStore .getInstance (getContext ()).getWindowWidth ()));
102- mBinding .windowSizeEdit .setSecondText (Integer .toString (SettingsStore .getInstance (getContext ()).getWindowHeight ()));
103- mBinding .windowSizeEdit .setOnClickListener (mWindowSizeListener );
104- setWindowSize (
105- SettingsStore .getInstance (getContext ()).getWindowWidth (),
106- SettingsStore .getInstance (getContext ()).getWindowHeight (),
107- false );
108-
109- mBinding .maxWindowSizeEdit .setHint1 (String .valueOf (SettingsStore .MAX_WINDOW_WIDTH_DEFAULT ));
110- mBinding .maxWindowSizeEdit .setHint2 (String .valueOf (SettingsStore .MAX_WINDOW_HEIGHT_DEFAULT ));
111- mBinding .maxWindowSizeEdit .setDefaultFirstValue (String .valueOf (SettingsStore .MAX_WINDOW_WIDTH_DEFAULT ));
112- mBinding .maxWindowSizeEdit .setDefaultSecondValue (String .valueOf (SettingsStore .MAX_WINDOW_HEIGHT_DEFAULT ));
113- mBinding .maxWindowSizeEdit .setFirstText (Integer .toString (SettingsStore .getInstance (getContext ()).getMaxWindowWidth ()));
114- mBinding .maxWindowSizeEdit .setSecondText (Integer .toString (SettingsStore .getInstance (getContext ()).getMaxWindowHeight ()));
115- mBinding .maxWindowSizeEdit .setOnClickListener (mMaxWindowSizeListener );
116- setMaxWindowSize (
117- SettingsStore .getInstance (getContext ()).getMaxWindowWidth (),
118- SettingsStore .getInstance (getContext ()).getMaxWindowHeight (),
119- false );
12096 }
12197
12298 @ Override
@@ -147,16 +123,6 @@ public boolean isEditing() {
147123 mBinding .dpiEdit .cancel ();
148124 }
149125
150- if (mBinding .windowSizeEdit .isEditing ()) {
151- editing = true ;
152- mBinding .windowSizeEdit .cancel ();
153- }
154-
155- if (mBinding .maxWindowSizeEdit .isEditing ()) {
156- editing = true ;
157- mBinding .maxWindowSizeEdit .cancel ();
158- }
159-
160126 if (mBinding .homepageEdit .isEditing ()) {
161127 editing = true ;
162128 mBinding .homepageEdit .cancel ();
@@ -214,28 +180,6 @@ public boolean isEditing() {
214180 }
215181 };
216182
217- private OnClickListener mWindowSizeListener = (view ) -> {
218- try {
219- int newWindowWidth = Integer .parseInt (mBinding .windowSizeEdit .getFirstText ());
220- int newWindowHeight = Integer .parseInt (mBinding .windowSizeEdit .getSecondText ());
221- setWindowSize (newWindowWidth , newWindowHeight , true );
222-
223- } catch (NumberFormatException e ) {
224- setWindowSize (SettingsStore .WINDOW_WIDTH_DEFAULT , SettingsStore .WINDOW_HEIGHT_DEFAULT , true );
225- }
226- };
227-
228- private OnClickListener mMaxWindowSizeListener = (view ) -> {
229- try {
230- int newMaxWindowWidth = Integer .parseInt (mBinding .maxWindowSizeEdit .getFirstText ());
231- int newMaxWindowHeight = Integer .parseInt (mBinding .maxWindowSizeEdit .getSecondText ());
232- setMaxWindowSize (newMaxWindowWidth , newMaxWindowHeight , true );
233-
234- } catch (NumberFormatException e ) {
235- setMaxWindowSize (SettingsStore .MAX_WINDOW_WIDTH_DEFAULT , SettingsStore .MAX_WINDOW_HEIGHT_DEFAULT , true );
236- }
237- };
238-
239183 private SwitchSetting .OnCheckedChangeListener mCurvedDisplayListener = (compoundButton , enabled , apply ) ->
240184 setCurvedDisplay (enabled , true );
241185
@@ -260,19 +204,6 @@ public boolean isEditing() {
260204 restart = restart | setDisplayDensity (SettingsStore .DISPLAY_DENSITY_DEFAULT );
261205 restart = restart | setDisplayDpi (SettingsStore .DISPLAY_DPI_DEFAULT );
262206
263- try {
264- if (Integer .parseInt (mBinding .windowSizeEdit .getFirstText ()) != SettingsStore .WINDOW_WIDTH_DEFAULT ||
265- Integer .parseInt (mBinding .windowSizeEdit .getSecondText ()) != SettingsStore .WINDOW_HEIGHT_DEFAULT ) {
266- setWindowSize (SettingsStore .WINDOW_WIDTH_DEFAULT , SettingsStore .WINDOW_HEIGHT_DEFAULT , true );
267- }
268- if (Integer .parseInt (mBinding .maxWindowSizeEdit .getFirstText ()) != SettingsStore .MAX_WINDOW_WIDTH_DEFAULT ||
269- Integer .parseInt (mBinding .maxWindowSizeEdit .getSecondText ()) != SettingsStore .MAX_WINDOW_HEIGHT_DEFAULT ) {
270- setMaxWindowSize (SettingsStore .MAX_WINDOW_WIDTH_DEFAULT , SettingsStore .MAX_WINDOW_HEIGHT_DEFAULT , true );
271- }
272- } catch (NumberFormatException ex ) {
273- setWindowSize (SettingsStore .WINDOW_WIDTH_DEFAULT , SettingsStore .WINDOW_HEIGHT_DEFAULT , true );
274- setMaxWindowSize (SettingsStore .MAX_WINDOW_WIDTH_DEFAULT , SettingsStore .MAX_WINDOW_HEIGHT_DEFAULT , true );
275- }
276207
277208 setHomepage (mDefaultHomepageUrl );
278209 setAutoplay (SettingsStore .AUTOPLAY_ENABLED , true );
@@ -393,81 +324,6 @@ private boolean setDisplayDpi(int newDpi) {
393324 return restart ;
394325 }
395326
396- private void setWindowSize (int newWindowWidth , int newWindowHeight , boolean doApply ) {
397- int prevWindowWidth = SettingsStore .getInstance (getContext ()).getWindowWidth ();
398- if (newWindowWidth <= 0 ) {
399- newWindowWidth = prevWindowWidth ;
400- }
401-
402- int prevWindowHeight = SettingsStore .getInstance (getContext ()).getWindowHeight ();
403- if (newWindowHeight <= 0 ) {
404- newWindowHeight = prevWindowHeight ;
405- }
406-
407- int maxWindowWidth = SettingsStore .getInstance (getContext ()).getMaxWindowWidth ();
408- if (newWindowWidth > maxWindowWidth ) {
409- newWindowWidth = maxWindowWidth ;
410- }
411-
412- int maxWindowHeight = SettingsStore .getInstance (getContext ()).getMaxWindowHeight ();
413- if (newWindowHeight > maxWindowHeight ) {
414- newWindowHeight = maxWindowHeight ;
415- }
416-
417- if (prevWindowWidth != newWindowWidth || prevWindowHeight != newWindowHeight ) {
418- SettingsStore .getInstance (getContext ()).setWindowWidth (newWindowWidth );
419- SettingsStore .getInstance (getContext ()).setWindowHeight (newWindowHeight );
420-
421- if (doApply ) {
422- mWidgetManager .setWindowSize (newWindowWidth , newWindowHeight );
423- }
424- }
425-
426- String newWindowWidthStr = Integer .toString (newWindowWidth );
427- mBinding .windowSizeEdit .setFirstText (newWindowWidthStr );
428- String newWindowHeightStr = Integer .toString (newWindowHeight );
429- mBinding .windowSizeEdit .setSecondText (newWindowHeightStr );
430- }
431-
432- private void setMaxWindowSize (int newMaxWindowWidth , int newMaxWindowHeight , boolean doApply ) {
433- int prevMaxWindowWidth = SettingsStore .getInstance (getContext ()).getMaxWindowWidth ();
434- if (newMaxWindowWidth <= 0 ) {
435- newMaxWindowWidth = prevMaxWindowWidth ;
436- }
437-
438- int prevMaxWindowHeight = SettingsStore .getInstance (getContext ()).getMaxWindowHeight ();
439- if (newMaxWindowHeight <= 0 ) {
440- newMaxWindowHeight = prevMaxWindowHeight ;
441- }
442-
443- int windowWidth = SettingsStore .getInstance (getContext ()).getWindowWidth ();
444- if (newMaxWindowWidth < windowWidth ) {
445- newMaxWindowWidth = windowWidth ;
446- }
447-
448- int windowHeight = SettingsStore .getInstance (getContext ()).getWindowHeight ();
449- if (newMaxWindowHeight < windowHeight ) {
450- newMaxWindowHeight = windowHeight ;
451- }
452-
453- if (newMaxWindowWidth != prevMaxWindowWidth ||
454- newMaxWindowHeight != prevMaxWindowHeight ) {
455- SettingsStore .getInstance (getContext ()).setMaxWindowWidth (newMaxWindowWidth );
456- SettingsStore .getInstance (getContext ()).setMaxWindowHeight (newMaxWindowHeight );
457-
458- if (doApply ) {
459- SettingsStore .getInstance (getContext ()).setMaxWindowWidth (newMaxWindowWidth );
460- SettingsStore .getInstance (getContext ()).setMaxWindowHeight (newMaxWindowHeight );
461- showRestartDialog ();
462- }
463- }
464-
465- String newMaxWindowWidthStr = Integer .toString (newMaxWindowWidth );
466- mBinding .maxWindowSizeEdit .setFirstText (newMaxWindowWidthStr );
467- String newMaxWindowHeightStr = Integer .toString (newMaxWindowHeight );
468- mBinding .maxWindowSizeEdit .setSecondText (newMaxWindowHeightStr );
469- }
470-
471327 @ Override
472328 public void onGlobalFocusChanged (View oldFocus , View newFocus ) {
473329 if (oldFocus != null ) {
@@ -477,16 +333,6 @@ public void onGlobalFocusChanged(View oldFocus, View newFocus) {
477333 if (mBinding .dpiEdit .contains (oldFocus ) && mBinding .dpiEdit .isEditing ()) {
478334 mBinding .dpiEdit .cancel ();
479335 }
480- if (mBinding .windowSizeEdit .contains (oldFocus ) &&
481- (newFocus != null && !mBinding .windowSizeEdit .contains (newFocus )) &&
482- mBinding .windowSizeEdit .isEditing ()) {
483- mBinding .windowSizeEdit .cancel ();
484- }
485- if (mBinding .maxWindowSizeEdit .contains (oldFocus ) &&
486- (newFocus != null && !mBinding .maxWindowSizeEdit .contains (newFocus )) &&
487- mBinding .maxWindowSizeEdit .isEditing ()) {
488- mBinding .maxWindowSizeEdit .cancel ();
489- }
490336 if (mBinding .homepageEdit .contains (oldFocus ) && mBinding .homepageEdit .isEditing ()) {
491337 mBinding .homepageEdit .cancel ();
492338 }
0 commit comments