float maxRecentsSize = fullLength ? Float.MAX_VALUE : recentsSize;
int maxScreenSize;
+ float baseStart = U.getBaseTaskbarSizeStart(context);
+ float baseEnd = U.getBaseTaskbarSizeEnd(context, sysTrayIconStates);
+ int baseTotal = Math.round(baseStart + baseEnd);
+
+ int diff = Math.round(Math.max(baseStart, baseEnd) - Math.min(baseStart, baseEnd));
+ boolean startIsBigger = Math.max(baseStart, baseEnd) == baseStart;
+
if(TaskbarPosition.isVertical(context)) {
maxScreenSize = Math.max(0, display.height
- U.getStatusBarHeight(context)
- - U.getBaseTaskbarSize(context, sysTrayIconStates));
+ - baseTotal);
params.height = (int) Math.min(maxRecentsSize, maxScreenSize)
+ context.getResources().getDimensionPixelSize(R.dimen.tb_divider_size);
if(fullLength) {
try {
- Space whitespaceTop = layout.findViewById(R.id.whitespace_top);
- Space whitespaceBottom = layout.findViewById(R.id.whitespace_bottom);
+ Space whitespaceStart = layout.findViewById(R.id.whitespace_start);
+ Space whitespaceEnd = layout.findViewById(R.id.whitespace_end);
int height = maxScreenSize - recentsSize;
if(pref.getBoolean(PREF_CENTERED_ICONS, false)) {
- ViewGroup.LayoutParams topParams = whitespaceTop.getLayoutParams();
- topParams.height = height / 2;
- whitespaceTop.setLayoutParams(topParams);
-
- ViewGroup.LayoutParams bottomParams = whitespaceBottom.getLayoutParams();
- bottomParams.height = height / 2;
- whitespaceBottom.setLayoutParams(bottomParams);
- } else if(TaskbarPosition.isBottom(context)) {
- ViewGroup.LayoutParams topParams = whitespaceTop.getLayoutParams();
- topParams.height = height;
- whitespaceTop.setLayoutParams(topParams);
+ ViewGroup.LayoutParams startParams = whitespaceStart.getLayoutParams();
+ startParams.height = (height / 2) + (diff / (startIsBigger ? -2 : 2));
+ whitespaceStart.setLayoutParams(startParams);
+
+ ViewGroup.LayoutParams endParams = whitespaceEnd.getLayoutParams();
+ endParams.height = (height / 2) + (diff / (startIsBigger ? 2 : -2));
+ whitespaceEnd.setLayoutParams(endParams);
} else {
- ViewGroup.LayoutParams bottomParams = whitespaceBottom.getLayoutParams();
- bottomParams.height = height;
- whitespaceBottom.setLayoutParams(bottomParams);
+ ViewGroup.LayoutParams endParams = whitespaceEnd.getLayoutParams();
+ endParams.height = height;
+ whitespaceEnd.setLayoutParams(endParams);
}
} catch (NullPointerException ignored) {}
}
} else {
- maxScreenSize = Math.max(0, display.width - U.getBaseTaskbarSize(context, sysTrayIconStates));
+ maxScreenSize = Math.max(0, display.width - baseTotal);
params.width = (int) Math.min(maxRecentsSize, maxScreenSize)
+ context.getResources().getDimensionPixelSize(R.dimen.tb_divider_size);
if(fullLength) {
try {
- Space whitespaceLeft = layout.findViewById(R.id.whitespace_left);
- Space whitespaceRight = layout.findViewById(R.id.whitespace_right);
+ Space whitespaceStart = layout.findViewById(R.id.whitespace_start);
+ Space whitespaceEnd = layout.findViewById(R.id.whitespace_end);
int width = maxScreenSize - recentsSize;
if(pref.getBoolean(PREF_CENTERED_ICONS, false)) {
- ViewGroup.LayoutParams leftParams = whitespaceLeft.getLayoutParams();
- leftParams.width = width / 2;
- whitespaceLeft.setLayoutParams(leftParams);
-
- ViewGroup.LayoutParams rightParams = whitespaceRight.getLayoutParams();
- rightParams.width = width / 2;
- whitespaceRight.setLayoutParams(rightParams);
- } else if(TaskbarPosition.isRight(context)) {
- ViewGroup.LayoutParams leftParams = whitespaceLeft.getLayoutParams();
- leftParams.width = width;
- whitespaceLeft.setLayoutParams(leftParams);
+ ViewGroup.LayoutParams startParams = whitespaceStart.getLayoutParams();
+ startParams.width = (width / 2) + (diff / (startIsBigger ? -2 : 2));
+ whitespaceStart.setLayoutParams(startParams);
+
+ ViewGroup.LayoutParams endParams = whitespaceEnd.getLayoutParams();
+ endParams.width = (width / 2) + (diff / (startIsBigger ? 2 : -2));
+ whitespaceEnd.setLayoutParams(endParams);
} else {
- ViewGroup.LayoutParams rightParams = whitespaceRight.getLayoutParams();
- rightParams.width = width;
- whitespaceRight.setLayoutParams(rightParams);
+ ViewGroup.LayoutParams endParams = whitespaceEnd.getLayoutParams();
+ endParams.width = width;
+ whitespaceEnd.setLayoutParams(endParams);
}
} catch (NullPointerException ignored) {}
}
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
SharedPreferences pref = getSharedPreferences(context);
DisplayInfo display = getDisplayInfo(context);
float density = display.currentDensity / 160.0f;
- float baseTaskbarSize = getBaseTaskbarSizeFloat(context) / density;
+ float baseTaskbarSize = getBaseTaskbarSize(context, null) / density;
int numOfColumns = 0;
float maxScreenSize = TaskbarPosition.isVertical(context)
}
}
- public static int getBaseTaskbarSize(Context context, Map<Integer, Boolean> sysTrayIconStates) {
- return Math.round(getBaseTaskbarSizeFloat(context, sysTrayIconStates));
- }
-
- private static float getBaseTaskbarSizeFloat(Context context) {
- return getBaseTaskbarSizeFloat(context, new HashMap<>());
- }
-
- private static float getBaseTaskbarSizeFloat(Context context, Map<Integer, Boolean> sysTrayIconStates) {
+ private static float getBaseTaskbarSize(Context context, Map<Integer, Boolean> sysTrayIconStates) {
return getBaseTaskbarSizeStart(context) + getBaseTaskbarSizeEnd(context, sysTrayIconStates);
}
- private static float getBaseTaskbarSizeStart(Context context) {
+ public static float getBaseTaskbarSizeStart(Context context) {
SharedPreferences pref = getSharedPreferences(context);
float baseTaskbarSize = context.getResources().getDimension(R.dimen.tb_base_size_start_plus_divider);
return baseTaskbarSize;
}
- private static float getBaseTaskbarSizeEnd(Context context, Map<Integer, Boolean> sysTrayIconStates) {
+ public static float getBaseTaskbarSizeEnd(Context context, Map<Integer, Boolean> sysTrayIconStates) {
SharedPreferences pref = getSharedPreferences(context);
float baseTaskbarSize = pref.getBoolean(PREF_ALT_BUTTON_CONFIG, false)
? 0 : context.getResources().getDimension(R.dimen.tb_base_size_collapse_button);
if(isSystemTrayEnabled(context)) {
float sysTraySize = context.getResources().getDimension(R.dimen.tb_systray_size);
- for(Integer key : sysTrayIconStates.keySet()) {
- if(!sysTrayIconStates.get(key))
- sysTraySize -= context.getResources().getDimension(R.dimen.tb_systray_icon_size);
+ if(sysTrayIconStates != null) {
+ for(Integer key : sysTrayIconStates.keySet()) {
+ if(!sysTrayIconStates.get(key))
+ sysTraySize -= context.getResources().getDimension(R.dimen.tb_systray_icon_size);
+ }
}
baseTaskbarSize += sysTraySize;
android:layout_marginRight="2dp" />
<Space
- android:id="@+id/whitespace_left"
+ android:id="@+id/whitespace_start"
android:layout_height="0dp"
android:layout_width="0dp" />
android:clickable="false" />
<Space
- android:id="@+id/whitespace_right"
+ android:id="@+id/whitespace_end"
android:layout_height="0dp"
android:layout_width="0dp" />
android:clickable="false">
<Space
- android:id="@+id/whitespace_left"
+ android:id="@+id/whitespace_end"
android:layout_height="0dp"
android:layout_width="0dp" />
android:clickable="false" />
<Space
- android:id="@+id/whitespace_right"
+ android:id="@+id/whitespace_start"
android:layout_height="0dp"
android:layout_width="0dp" />
android:layout_marginBottom="2dp" />
<Space
- android:id="@+id/whitespace_top"
+ android:id="@+id/whitespace_start"
android:layout_width="0dp"
android:layout_height="0dp" />
android:clickable="false" />
<Space
- android:id="@+id/whitespace_bottom"
+ android:id="@+id/whitespace_end"
android:layout_width="0dp"
android:layout_height="0dp" />
android:clickable="false">
<Space
- android:id="@+id/whitespace_top"
+ android:id="@+id/whitespace_end"
android:layout_width="0dp"
android:layout_height="0dp" />
android:clickable="false" />
<Space
- android:id="@+id/whitespace_bottom"
+ android:id="@+id/whitespace_start"
android:layout_width="0dp"
android:layout_height="0dp" />
import org.robolectric.shadows.ShadowToast;
import org.robolectric.util.ReflectionHelpers;
-import java.util.HashMap;
-
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
float initialSize = context.getResources().getDimension(R.dimen.tb_base_size_start_plus_divider);
initialSize += context.getResources().getDimension(R.dimen.tb_base_size_collapse_button);
initialSize += context.getResources().getDimension(R.dimen.tb_dashboard_button_size);
- assertEquals(Math.round(initialSize), U.getBaseTaskbarSize(context, new HashMap<>()));
+ assertEquals(Math.round(initialSize), U.getBaseTaskbarSize(context, null));
}
@Test
isSystemTrayEnabledAnswer.answer = false;
float initialSize = context.getResources().getDimension(R.dimen.tb_base_size_start_plus_divider);
initialSize += context.getResources().getDimension(R.dimen.tb_base_size_collapse_button);
- assertEquals(Math.round(initialSize), U.getBaseTaskbarSize(context, new HashMap<>()));
+ assertEquals(Math.round(initialSize), U.getBaseTaskbarSize(context, null));
SharedPreferences prefs = U.getSharedPreferences(context);
prefs.edit().putBoolean(PREF_DASHBOARD, true).apply();
float dashboardButtonSize =
context.getResources().getDimension(R.dimen.tb_dashboard_button_size);
- assertEquals(Math.round(initialSize + dashboardButtonSize), U.getBaseTaskbarSize(context, new HashMap<>()));
+ assertEquals(Math.round(initialSize + dashboardButtonSize), U.getBaseTaskbarSize(context, null));
prefs.edit().remove(PREF_DASHBOARD).apply();
float navbarButtonsMargin =
context.getResources().getDimension(R.dimen.tb_navbar_buttons_margin);
prefs.edit().putBoolean(PREF_BUTTON_BACK, true).apply();
assertEquals(
Math.round(initialSize + navbarButtonsMargin + iconSize),
- U.getBaseTaskbarSize(context, new HashMap<>())
+ U.getBaseTaskbarSize(context, null)
);
prefs.edit().remove(PREF_BUTTON_BACK).apply();
prefs.edit().putBoolean(PREF_BUTTON_HOME, true).apply();
assertEquals(
Math.round(initialSize + navbarButtonsMargin + iconSize),
- U.getBaseTaskbarSize(context, new HashMap<>())
+ U.getBaseTaskbarSize(context, null)
);
prefs.edit().remove(PREF_BUTTON_HOME).apply();
prefs.edit().putBoolean(PREF_BUTTON_RECENTS, true).apply();
assertEquals(
Math.round(initialSize + navbarButtonsMargin + iconSize),
- U.getBaseTaskbarSize(context, new HashMap<>())
+ U.getBaseTaskbarSize(context, null)
);
prefs.edit().remove(PREF_BUTTON_RECENTS).apply();
isSystemTrayEnabledAnswer.answer = true;
float systemTraySize = context.getResources().getDimension(R.dimen.tb_systray_size);
- assertEquals(Math.round(initialSize + systemTraySize), U.getBaseTaskbarSize(context, new HashMap<>()));
+ assertEquals(Math.round(initialSize + systemTraySize), U.getBaseTaskbarSize(context, null));
}
@Test