OSDN Git Service

Add support for portrait screens for half fullscreen sizes
authorBraden Farmer <farmerbb@gmail.com>
Tue, 27 Sep 2016 04:26:48 +0000 (22:26 -0600)
committerBraden Farmer <farmerbb@gmail.com>
Tue, 27 Sep 2016 04:26:48 +0000 (22:26 -0600)
app/src/main/java/com/farmerbb/taskbar/util/U.java
app/src/main/res/values-ja-land/strings.xml [new file with mode: 0644]
app/src/main/res/values-ja-port/strings.xml [new file with mode: 0644]
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-land/strings.xml [new file with mode: 0644]
app/src/main/res/values-port/strings.xml [new file with mode: 0644]
app/src/main/res/values/donottranslate.xml
app/src/main/res/values/strings.xml

index 67163c7..50bd8b1 100644 (file)
@@ -27,6 +27,7 @@ import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.res.Configuration;
 import android.graphics.Rect;
 import android.hardware.display.DisplayManager;
 import android.net.Uri;
@@ -160,16 +161,31 @@ public class U {
         String position = getTaskbarPosition(context);
         boolean overridePad = position.equals("top_left") || position.equals("top_right");
 
-        int left = launchType == RIGHT ? display.getWidth() / 2 : 0;
-        int top = padStatusBar || overridePad ? statusBarHeight : 0;
-        int right = launchType == LEFT ? display.getWidth() / 2 : display.getWidth();
-        int bottom = display.getHeight() + (!padStatusBar && overridePad ? statusBarHeight : 0);
+        boolean isPortrait = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
+        boolean isLandscape = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
+
+        int left = launchType == RIGHT && isLandscape
+                ? display.getWidth() / 2
+                : 0;
+
+        int top = launchType == RIGHT && isPortrait
+                ? display.getHeight() / 2
+                : padStatusBar || overridePad ? statusBarHeight : 0;
+
+        int right = launchType == LEFT && isLandscape
+                ? display.getWidth() / 2
+                : display.getWidth();
+
+        int bottom = launchType == LEFT && isPortrait
+                ? display.getHeight() / 2
+                : display.getHeight() + (!padStatusBar && overridePad ? statusBarHeight : 0);
+
         int iconSize = context.getResources().getDimensionPixelSize(R.dimen.icon_size);
 
         if(position.contains("vertical_left")) {
-            if(launchType != RIGHT) left = left + iconSize;
+            if(launchType != RIGHT || isPortrait) left = left + iconSize;
         } else if(position.contains("vertical_right")) {
-            if(launchType != LEFT) right = right - iconSize;
+            if(launchType != LEFT || isPortrait) right = right - iconSize;
         } else if(position.contains("bottom"))
             bottom = bottom - iconSize;
         else
diff --git a/app/src/main/res/values-ja-land/strings.xml b/app/src/main/res/values-ja-land/strings.xml
new file mode 100644 (file)
index 0000000..0d1aa59
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2016 Braden Farmer
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <string name="window_size_half_left">Half screen (left)</string>
+    <string name="window_size_half_right">Half screen (right)</string>
+
+</resources>
diff --git a/app/src/main/res/values-ja-port/strings.xml b/app/src/main/res/values-ja-port/strings.xml
new file mode 100644 (file)
index 0000000..c368e27
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2016 Braden Farmer
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <string name="window_size_half_left">Half screen (top)</string>
+    <string name="window_size_half_right">Half screen (bottom)</string>
+
+</resources>
index 4376115..88de194 100644 (file)
     <string name="window_size_fullscreen">全画面</string>
     <string name="window_size_phone_size">電話サイズ</string>
     <string name="window_size_large">Large</string>
-    <string name="window_size_half_left">Half screen (left)</string>
-    <string name="window_size_half_right">Half screen (right)</string>
+    <string name="window_size_half_left">@string/window_size_half_left_alt</string>
+    <string name="window_size_half_left_alt">Half screen (left/top)</string>
+    <string name="window_size_half_right">@string/window_size_half_right_alt</string>
+    <string name="window_size_half_right_alt">Half screen (right/bottom)</string>
 
     <string name="pref_title_blacklist">スタートメニューからアプリを非表示</string>
     <string name="app_hidden">1 非表示アプリ</string>
diff --git a/app/src/main/res/values-land/strings.xml b/app/src/main/res/values-land/strings.xml
new file mode 100644 (file)
index 0000000..0d1aa59
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2016 Braden Farmer
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <string name="window_size_half_left">Half screen (left)</string>
+    <string name="window_size_half_right">Half screen (right)</string>
+
+</resources>
diff --git a/app/src/main/res/values-port/strings.xml b/app/src/main/res/values-port/strings.xml
new file mode 100644 (file)
index 0000000..c368e27
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2016 Braden Farmer
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <string name="window_size_half_left">Half screen (top)</string>
+    <string name="window_size_half_right">Half screen (bottom)</string>
+
+</resources>
index 38e6184..b430aec 100644 (file)
@@ -62,8 +62,8 @@
         <item>@string/window_size_standard</item>
         <item>@string/window_size_large</item>
         <item>@string/window_size_fullscreen</item>
-        <item>@string/window_size_half_left</item>
-        <item>@string/window_size_half_right</item>
+        <item>@string/window_size_half_left_alt</item>
+        <item>@string/window_size_half_right_alt</item>
         <item>@string/window_size_phone_size</item>
     </string-array>
 
index 066bc13..60841e4 100644 (file)
     <string name="window_size_fullscreen">Fullscreen</string>
     <string name="window_size_phone_size">Phone size</string>
     <string name="window_size_large">Large</string>
-    <string name="window_size_half_left">Half screen (left)</string>
-    <string name="window_size_half_right">Half screen (right)</string>
+    <string name="window_size_half_left">@string/window_size_half_left_alt</string>
+    <string name="window_size_half_left_alt">Half screen (left/top)</string>
+    <string name="window_size_half_right">@string/window_size_half_right_alt</string>
+    <string name="window_size_half_right_alt">Half screen (right/bottom)</string>
 
     <string name="pref_title_blacklist">Hide apps from start menu</string>
     <string name="app_hidden">1 app hidden</string>