use of com.farmerbb.taskbar.util.DisplayInfo in project Taskbar by farmerbb.
the class DashboardActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
contextMenuFix = getIntent().hasExtra(EXTRA_CONTEXT_MENU_FIX);
// Detect outside touches, and finish the activity when one is detected
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
DisplayInfo display = U.getDisplayInfo(this);
setContentView(R.layout.tb_incognito);
LinearLayout layout = findViewById(R.id.incognitoLayout);
layout.setLayoutParams(new FrameLayout.LayoutParams(display.width, display.height));
U.registerReceiver(this, addWidgetReceiver, ACTION_ADD_WIDGET_REQUESTED);
U.registerReceiver(this, removeWidgetReceiver, ACTION_REMOVE_WIDGET_REQUESTED);
U.registerReceiver(this, finishReceiver, ACTION_DASHBOARD_DISAPPEARING);
if (!DashboardHelper.getInstance().isDashboardOpen())
finish();
}
use of com.farmerbb.taskbar.util.DisplayInfo in project Taskbar by farmerbb.
the class TaskbarController method calculateScrollViewParams.
@VisibleForTesting
void calculateScrollViewParams(Context context, SharedPreferences pref, ViewGroup.LayoutParams params, boolean fullLength, int numOfEntries) {
DisplayInfo display = U.getDisplayInfo(context, true);
int recentsSize = context.getResources().getDimensionPixelSize(R.dimen.tb_icon_size) * numOfEntries;
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) - baseTotal);
params.height = (int) Math.min(maxRecentsSize, maxScreenSize) + context.getResources().getDimensionPixelSize(R.dimen.tb_divider_size);
if (fullLength) {
try {
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)) {
int startHeight = (height / 2) + (diff / (startIsBigger ? -2 : 2));
int endHeight = (height / 2) + (diff / (startIsBigger ? 2 : -2));
if (startHeight < 0) {
startHeight = 0;
endHeight = height;
}
if (endHeight < 0) {
startHeight = height;
endHeight = 0;
}
ViewGroup.LayoutParams startParams = whitespaceStart.getLayoutParams();
startParams.height = startHeight;
whitespaceStart.setLayoutParams(startParams);
ViewGroup.LayoutParams endParams = whitespaceEnd.getLayoutParams();
endParams.height = endHeight;
whitespaceEnd.setLayoutParams(endParams);
} else {
ViewGroup.LayoutParams endParams = whitespaceEnd.getLayoutParams();
endParams.height = height;
whitespaceEnd.setLayoutParams(endParams);
}
} catch (NullPointerException ignored) {
}
}
} else {
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 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)) {
int startWidth = (width / 2) + (diff / (startIsBigger ? -2 : 2));
int endWidth = (width / 2) + (diff / (startIsBigger ? 2 : -2));
if (startWidth < 0) {
startWidth = 0;
endWidth = width;
}
if (endWidth < 0) {
startWidth = width;
endWidth = 0;
}
ViewGroup.LayoutParams startParams = whitespaceStart.getLayoutParams();
startParams.width = startWidth;
whitespaceStart.setLayoutParams(startParams);
ViewGroup.LayoutParams endParams = whitespaceEnd.getLayoutParams();
endParams.width = endWidth;
whitespaceEnd.setLayoutParams(endParams);
} else {
ViewGroup.LayoutParams endParams = whitespaceEnd.getLayoutParams();
endParams.width = width;
whitespaceEnd.setLayoutParams(endParams);
}
} catch (NullPointerException ignored) {
}
}
}
boolean realMatchParent = maxRecentsSize >= maxScreenSize && pref.getBoolean(PREF_COLLAPSED, false) && !(TaskbarPosition.isVertical(context) && U.isChromeOs(context));
if (realMatchParent != matchParent) {
matchParent = realMatchParent;
U.newHandler().post(updateParamsRunnable);
}
}
Aggregations