Merge "Revert "Revert "Make status bar translucent. Make drawer appera below status bar."" with a fix for cts tests." into nyc-dev
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
android:padding="?android:attr/listPreferredItemPaddingEnd">
|
android:padding="?android:attr/listPreferredItemPaddingEnd">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:baselineAligned="false"
|
android:baselineAligned="false"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeightSmall">
|
android:minHeight="?android:attr/listPreferredItemHeightSmall">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
<item name="android:windowActionBar">false</item>
|
<item name="android:windowActionBar">false</item>
|
||||||
<item name="android:windowActionModeOverlay">true</item>
|
<item name="android:windowActionModeOverlay">true</item>
|
||||||
<item name="android:windowNoTitle">true</item>
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
<item name="android:windowTranslucentStatus">true</item>
|
||||||
|
<item name="android:fitsSystemWindows">false</item>
|
||||||
|
|
||||||
<item name="android:windowSoftInputMode">stateUnspecified|adjustUnspecified</item>
|
<item name="android:windowSoftInputMode">stateUnspecified|adjustUnspecified</item>
|
||||||
</style>
|
</style>
|
||||||
@@ -43,7 +45,7 @@
|
|||||||
<style name="TrimmedHorizontalProgressBar" parent="android:Widget.Material.ProgressBar.Horizontal">
|
<style name="TrimmedHorizontalProgressBar" parent="android:Widget.Material.ProgressBar.Horizontal">
|
||||||
<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_material_trimmed</item>
|
<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_material_trimmed</item>
|
||||||
<item name="android:minHeight">3dp</item>
|
<item name="android:minHeight">3dp</item>
|
||||||
<item name="android:maxHeight">3dp</item>
|
<item name="android:maxHeight">3dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public abstract class BaseActivity extends Activity
|
|||||||
mSearchManager = new SearchViewManager(this, icicle);
|
mSearchManager = new SearchViewManager(this, icicle);
|
||||||
|
|
||||||
DocumentsToolbar toolbar = (DocumentsToolbar) findViewById(R.id.toolbar);
|
DocumentsToolbar toolbar = (DocumentsToolbar) findViewById(R.id.toolbar);
|
||||||
|
Display.adjustToolbar(toolbar, this);
|
||||||
setActionBar(toolbar);
|
setActionBar(toolbar);
|
||||||
mNavigator = new NavigationView(
|
mNavigator = new NavigationView(
|
||||||
mDrawer,
|
mDrawer,
|
||||||
|
|||||||
@@ -20,13 +20,15 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convenience class for getting display related attributes
|
* Convenience class for getting display related attributes
|
||||||
*/
|
*/
|
||||||
public final class Display {
|
public final class Display {
|
||||||
/*
|
/*
|
||||||
* Returns the screen width in pixels.
|
* Returns the screen width in raw pixels.
|
||||||
*/
|
*/
|
||||||
public static float screenWidth(Activity activity) {
|
public static float screenWidth(Activity activity) {
|
||||||
Point size = new Point();
|
Point size = new Point();
|
||||||
@@ -42,15 +44,44 @@ public final class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns action bar height in pixels.
|
* Returns action bar height in raw pixels.
|
||||||
*/
|
*/
|
||||||
public static float actionBarHeight(Context context) {
|
public static float actionBarHeight(Context context) {
|
||||||
int actionBarHeight = 0;
|
int height = 0;
|
||||||
TypedValue tv = new TypedValue();
|
TypedValue tv = new TypedValue();
|
||||||
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
|
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
|
||||||
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
|
height = TypedValue.complexToDimensionPixelSize(tv.data,
|
||||||
context.getResources().getDisplayMetrics());
|
context.getResources().getDisplayMetrics());
|
||||||
}
|
}
|
||||||
return actionBarHeight;
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns status bar height in raw pixels.
|
||||||
|
*/
|
||||||
|
private static int statusBarHeight(Context context) {
|
||||||
|
int height = 0;
|
||||||
|
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen",
|
||||||
|
"android");
|
||||||
|
if (resourceId > 0) {
|
||||||
|
height = context.getResources().getDimensionPixelSize(resourceId);
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adjusts toolbar for the layout with translucent status bar. Increases the
|
||||||
|
* height of the toolbar and adds padding at the top to accommodate status bar visible above
|
||||||
|
* toolbar.
|
||||||
|
*/
|
||||||
|
public static void adjustToolbar(Toolbar toolbar, Activity activity) {
|
||||||
|
if ((activity.getWindow().getAttributes().flags
|
||||||
|
& WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) != 0) {
|
||||||
|
int statusBarHeight = Display.statusBarHeight(activity);
|
||||||
|
toolbar.getLayoutParams().height = (int) (Display.actionBarHeight(activity)
|
||||||
|
+ statusBarHeight);
|
||||||
|
toolbar.setPadding(toolbar.getPaddingLeft(), statusBarHeight, toolbar.getPaddingRight(),
|
||||||
|
toolbar.getPaddingBottom());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ abstract class DrawerController implements DrawerListener {
|
|||||||
|
|
||||||
View drawer = activity.findViewById(R.id.drawer_roots);
|
View drawer = activity.findViewById(R.id.drawer_roots);
|
||||||
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
|
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
|
||||||
|
Display.adjustToolbar(toolbar, activity);
|
||||||
drawer.getLayoutParams().width = calculateDrawerWidth(activity);
|
drawer.getLayoutParams().width = calculateDrawerWidth(activity);
|
||||||
|
|
||||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||||
|
|||||||
Reference in New Issue
Block a user