packages/apps/Taskbar
Revision | d1d3cec18bfc28a92c2aa44e03fec2aee722135b (tree) |
---|---|
Time | 2019-08-20 13:52:39 |
Author | Braden Farmer <farmerbb@gmai...> |
Commiter | Braden Farmer |
Workaround for incorrect display size on devices with notches in landscape mode
@@ -49,6 +49,7 @@ import com.farmerbb.taskbar.activity.dark.DesktopIconSelectAppActivityDark; | ||
49 | 49 | import com.farmerbb.taskbar.activity.dark.SelectAppActivityDark; |
50 | 50 | import com.farmerbb.taskbar.util.AppEntry; |
51 | 51 | import com.farmerbb.taskbar.util.ApplicationType; |
52 | +import com.farmerbb.taskbar.util.CompatUtils; | |
52 | 53 | import com.farmerbb.taskbar.util.DesktopIconInfo; |
53 | 54 | import com.farmerbb.taskbar.util.DisplayInfo; |
54 | 55 | import com.farmerbb.taskbar.util.FreeformHackHelper; |
@@ -116,6 +117,7 @@ public class ContextMenuActivity extends PreferenceActivity implements Preferenc | ||
116 | 117 | |
117 | 118 | // Determine where to position the dialog on screen |
118 | 119 | WindowManager.LayoutParams params = getWindow().getAttributes(); |
120 | + CompatUtils.applyDisplayCutoutModeTo(params); | |
119 | 121 | DisplayInfo display = U.getDisplayInfo(this); |
120 | 122 | |
121 | 123 | int statusBarHeight = 0; |
@@ -854,7 +854,7 @@ public class TaskbarController implements UIController { | ||
854 | 854 | handler.post(() -> { |
855 | 855 | if(numOfEntries > 0 || fullLength) { |
856 | 856 | ViewGroup.LayoutParams params = scrollView.getLayoutParams(); |
857 | - DisplayInfo display = U.getDisplayInfo(context); | |
857 | + DisplayInfo display = U.getDisplayInfo(context, true); | |
858 | 858 | int recentsSize = context.getResources().getDimensionPixelSize(R.dimen.icon_size) * numOfEntries; |
859 | 859 | float maxRecentsSize = fullLength ? Float.MAX_VALUE : recentsSize; |
860 | 860 |
@@ -1048,12 +1048,12 @@ public class U { | ||
1048 | 1048 | |
1049 | 1049 | return getActivityOptionsBundle(context, type, pref.getString("window_size", "standard"), view); |
1050 | 1050 | } |
1051 | - | |
1051 | + | |
1052 | 1052 | private static Bundle getActivityOptionsBundle(Context context, ApplicationType type, String windowSize, View view) { |
1053 | 1053 | SharedPreferences pref = getSharedPreferences(context); |
1054 | 1054 | if(!canEnableFreeform() || !pref.getBoolean("freeform_hack", false)) |
1055 | 1055 | return getActivityOptions(view).toBundle(); |
1056 | - | |
1056 | + | |
1057 | 1057 | switch(windowSize) { |
1058 | 1058 | case "large": |
1059 | 1059 | return launchMode1(context, type, view); |
@@ -1286,6 +1286,10 @@ public class U { | ||
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | public static DisplayInfo getDisplayInfo(Context context) { |
1289 | + return getDisplayInfo(context, false); | |
1290 | + } | |
1291 | + | |
1292 | + public static DisplayInfo getDisplayInfo(Context context, boolean fromTaskbar) { | |
1289 | 1293 | context = context.getApplicationContext(); |
1290 | 1294 | |
1291 | 1295 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); |
@@ -1309,6 +1313,10 @@ public class U { | ||
1309 | 1313 | return display; |
1310 | 1314 | } |
1311 | 1315 | |
1316 | + // Workaround for incorrect display size on devices with notches in landscape mode | |
1317 | + if(fromTaskbar && context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) | |
1318 | + return display; | |
1319 | + | |
1312 | 1320 | boolean sameWidth = metrics.widthPixels == realMetrics.widthPixels; |
1313 | 1321 | boolean sameHeight = metrics.heightPixels == realMetrics.heightPixels; |
1314 | 1322 |