This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

1.7 kB 41 lines
1package us.lassul.assist; 2 3import android.app.Activity; 4import android.graphics.Insets; 5import android.util.TypedValue; 6import android.view.View; 7import android.view.ViewGroup; 8import android.view.WindowInsets; 9 10/** Layout helpers shared by the screens. */ 11final class Ui { 12 private Ui() {} 13 14 static int dp(Activity activity, int value) { 15 return (int) (value * activity.getResources().getDisplayMetrics().density); 16 } 17 18 /** 19 * Pads a screen's root view clear of the status bar, the action bar, the navigation bar and 20 * the keyboard: apps targeting Android 15+ are drawn edge to edge, under all of them. 21 */ 22 static void fitBars(Activity activity, View root, final int pad) { 23 TypedValue size = new TypedValue(); 24 activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, size, true); 25 final int actionBar = TypedValue.complexToDimensionPixelSize( 26 size.data, activity.getResources().getDisplayMetrics()); 27 if (root instanceof ViewGroup) { 28 ((ViewGroup) root).setClipToPadding(false); 29 } 30 root.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { 31 @Override 32 public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { 33 Insets bars = insets.getInsets(WindowInsets.Type.systemBars() 34 | WindowInsets.Type.displayCutout() | WindowInsets.Type.ime()); 35 view.setPadding(bars.left + pad, bars.top + actionBar + pad / 2, 36 bars.right + pad, bars.bottom + pad); 37 return WindowInsets.CONSUMED; 38 } 39 }); 40 } 41}