From 3930583637fb6d113e5cad8116943a949fcd77d8 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 31 Mar 2022 15:51:03 +0600 Subject: [PATCH] 147-Remove_UI_placement_settings issue: https://gitlab.e.foundation/e/os/backlog/-/issues/147 `UI Placement` preference causes UI elements overlapping. This commit remove `preference_ui_placement` from the preferenceScreen & return `UIPlacement.UIPLACEMENT_TOP` always. --- .../opencamera/test/MainActivityTest.java | 119 ------------------ .../opencamera/PreferenceKeys.java | 2 - .../net/sourceforge/opencamera/ui/MainUI.java | 11 +- app/src/main/res/xml/preferences.xml | 9 -- 4 files changed, 1 insertion(+), 140 deletions(-) diff --git a/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java b/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java index d2fc36ed2..b99fe6bf0 100644 --- a/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java +++ b/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java @@ -8184,125 +8184,6 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 0); - assertTrue(popup_height > 0); - assertEquals(popup_width, test_popup_width); - assertEquals(popup_height, test_popup_height); - - // now reopen popup view, and check the same dimensions - clickView(popupButton); - while( mActivity.popupIsOpen() ) { - } - - clickView(popupButton); - while( !mActivity.popupIsOpen() ) { - } - - int new_popup_width = popup_view.getWidth(); - int new_popup_height = popup_view.getHeight(); - test_popup_width = mActivity.getMainUI().test_saved_popup_width; - test_popup_height = mActivity.getMainUI().test_saved_popup_height; - Log.d(TAG, "new_popup_width: " + new_popup_width); - Log.d(TAG, "new_popup_height: " + new_popup_height); - Log.d(TAG, "test_popup_width: " + test_popup_width); - Log.d(TAG, "test_popup_height: " + test_popup_height); - assertEquals(popup_width, new_popup_width); - assertEquals(popup_height, new_popup_height); - assertEquals(popup_width, test_popup_width); - assertEquals(popup_height, test_popup_height); - } - - /* Tests with ui_right vs ui_top layout. - */ - public void testRightLayout() { - Log.d(TAG, "testRightLayout"); - - setToDefault(); - { - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mActivity); - SharedPreferences.Editor editor = settings.edit(); - editor.putString(PreferenceKeys.UIPlacementPreferenceKey, "ui_right"); - editor.apply(); - updateForSettings(); - } - - View popupButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.popup); - assertFalse(mActivity.popupIsOpen()); - clickView(popupButton); - while( !mActivity.popupIsOpen() ) { - } - - Point display_size = new Point(); - { - Display display = mActivity.getWindowManager().getDefaultDisplay(); - display.getSize(display_size); - Log.d(TAG, "display_size: " + display_size.x + " x " + display_size.y); - } - View settingsButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.settings); - View galleryButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.gallery); - - Log.d(TAG, "settings right: " + settingsButton.getRight()); - Log.d(TAG, "settings top: " + settingsButton.getTop()); - Log.d(TAG, "gallery right: " + galleryButton.getRight()); - Log.d(TAG, "gallery top: " + galleryButton.getTop()); - - assertTrue(settingsButton.getRight() > (int)(0.8*display_size.x)); - assertEquals(0, settingsButton.getTop()); - assertEquals(display_size.x, galleryButton.getRight()); - assertEquals(0, galleryButton.getTop()); - - { - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mActivity); - SharedPreferences.Editor editor = settings.edit(); - editor.putString(PreferenceKeys.UIPlacementPreferenceKey, "ui_top"); - editor.apply(); - updateForSettings(); - } - - Log.d(TAG, "settings right: " + settingsButton.getRight()); - Log.d(TAG, "settings top: " + settingsButton.getTop()); - Log.d(TAG, "gallery right: " + galleryButton.getRight()); - Log.d(TAG, "gallery top: " + galleryButton.getTop()); - - assertTrue(settingsButton.getRight() < (int)(0.2*display_size.x)); - assertEquals(0, settingsButton.getTop()); - assertEquals(display_size.x, galleryButton.getRight()); - assertEquals(0, galleryButton.getTop()); - - assertFalse(mActivity.popupIsOpen()); - clickView(popupButton); - while( !mActivity.popupIsOpen() ) { - } - } - /* Tests layout bug with popup menu. * Note, in practice this doesn't seem to reproduce the problem, but keep the test anyway. * Currently not autotested as the problem isn't fixed, and this would just be a test that diff --git a/app/src/main/java/net/sourceforge/opencamera/PreferenceKeys.java b/app/src/main/java/net/sourceforge/opencamera/PreferenceKeys.java index cc8732db0..bb283902b 100644 --- a/app/src/main/java/net/sourceforge/opencamera/PreferenceKeys.java +++ b/app/src/main/java/net/sourceforge/opencamera/PreferenceKeys.java @@ -174,8 +174,6 @@ public class PreferenceKeys { public static final String Camera2PhotoVideoRecordingPreferenceKey = "preference_camera2_photo_video_recording"; - public static final String UIPlacementPreferenceKey = "preference_ui_placement"; - public static final String TouchCapturePreferenceKey = "preference_touch_capture"; public static final String PausePreviewPreferenceKey = "preference_pause_preview"; diff --git a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java index 8e4246c95..818b2f3e2 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java @@ -168,16 +168,7 @@ public class MainUI { } private UIPlacement computeUIPlacement() { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main_activity); - String ui_placement_string = sharedPreferences.getString(PreferenceKeys.UIPlacementPreferenceKey, "ui_top"); - switch (ui_placement_string) { - case "ui_left": - return UIPlacement.UIPLACEMENT_LEFT; - case "ui_top": - return UIPlacement.UIPLACEMENT_TOP; - default: - return UIPlacement.UIPLACEMENT_RIGHT; - } + return UIPlacement.UIPLACEMENT_TOP; } private void layoutUI(boolean popup_container_only) { diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index f4e9ed12e..8086dc143 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -562,15 +562,6 @@ android:title="@string/preference_screen_gui" android:icon="@drawable/ic_more_horiz_white_48dp" android:persistent="false"> - -