improve broken status bar layouting

This commit is contained in:
Vincent Breitmoser
2022-12-22 14:51:33 +01:00
parent a17a6e9131
commit 6f987f2920
22 changed files with 50 additions and 105 deletions

View File

@@ -55,16 +55,11 @@ public class MainActivity extends BaseSecurityTokenActivity implements FabContai
public static final String EXTRA_INIT_FRAG = "init_frag";
public Drawer mDrawer;
private Toolbar mToolbar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
mToolbar = findViewById(R.id.toolbar);
mToolbar.setTitle(R.string.app_name);
setSupportActionBar(mToolbar);
setTitle(R.string.app_name);
mDrawer = new DrawerBuilder()
.withActivity(this)
@@ -159,6 +154,11 @@ public class MainActivity extends BaseSecurityTokenActivity implements FabContai
}
@Override
protected void initLayout() {
setContentView(R.layout.main_activity);
}
@Override
public void onNewIntent(Intent data) {
super.onNewIntent(data);

View File

@@ -185,7 +185,6 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList
}
}
mToolbar.setBackgroundColor(color);
mStatusBar.setBackgroundColor(ViewKeyActivity.getStatusBarBackgroundColor(color));
slidingTabLayout.setBackgroundColor(color);
invalidateOptionsMenu();

View File

@@ -39,7 +39,6 @@ import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
*/
public abstract class BaseActivity extends AppCompatActivity {
protected Toolbar mToolbar;
protected View mStatusBar;
protected ThemeChanger mThemeChanger;
@Override
@@ -83,7 +82,6 @@ public abstract class BaseActivity extends AppCompatActivity {
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
mStatusBar = findViewById(R.id.status_bar);
}
/**

View File

@@ -34,6 +34,8 @@ import android.graphics.Bitmap;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -41,6 +43,7 @@ import android.os.Messenger;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
@@ -154,6 +157,10 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity {
@SuppressLint("InflateParams")
@Override
protected void onCreate(Bundle savedInstanceState) {
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
super.onCreate(savedInstanceState);
keyRepository = KeyRepository.create(this);

View File

@@ -1,27 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<include
android:id="@+id/toolbar_include"
layout="@layout/toolbar_standalone" />
<!--
fitsSystemWindows and layout_marginTop from
https://medium.com/@ngdelamo/using-drawerlayout-the-material-way-i-716bba2b5705
-->
<FrameLayout
android:layout_below="@id/toolbar_include"
android:fitsSystemWindows="true"
android:layout_marginTop="@dimen/minus_statusbar_height"
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
tools:ignore="UnusedAttribute" />
<FrameLayout
android:id="@+id/create_key_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/create_key_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</RelativeLayout>
</LinearLayout>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/custom_actionbar_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=""
android:textSize="18sp" />
</LinearLayout>

View File

@@ -7,14 +7,8 @@
android:id="@+id/toolbar_include"
layout="@layout/toolbar_standalone_white" />
<!--
fitsSystemWindows and layout_marginTop from
https://medium.com/@ngdelamo/using-drawerlayout-the-material-way-i-716bba2b5705
-->
<LinearLayout
android:layout_below="@id/toolbar_include"
android:fitsSystemWindows="true"
android:layout_marginTop="@dimen/minus_statusbar_height"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

View File

@@ -13,8 +13,6 @@
-->
<LinearLayout
android:layout_below="@id/toolbar_include"
android:fitsSystemWindows="true"
android:layout_marginTop="@dimen/minus_statusbar_height"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

View File

@@ -14,8 +14,6 @@
<LinearLayout
android:layout_below="@id/toolbar_include"
android:id="@+id/content_frame"
android:fitsSystemWindows="true"
android:layout_marginTop="@dimen/minus_statusbar_height"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

View File

@@ -14,8 +14,6 @@
<LinearLayout
android:layout_below="@id/toolbar_include"
android:id="@+id/content_frame"
android:fitsSystemWindows="true"
android:layout_marginTop="@dimen/minus_statusbar_height"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

View File

@@ -7,16 +7,10 @@
android:id="@+id/toolbar_include"
layout="@layout/toolbar_standalone" />
<!--
fitsSystemWindows and layout_marginTop from
https://medium.com/@ngdelamo/using-drawerlayout-the-material-way-i-716bba2b5705
-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar_include"
android:layout_marginTop="@dimen/minus_statusbar_height"
android:fitsSystemWindows="true"
android:orientation="vertical">
<include layout="@layout/notify_area" />

View File

@@ -2,16 +2,16 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
@@ -19,8 +19,7 @@
<FrameLayout
android:id="@+id/main_fragment_container"
android:layout_gravity="center"
android:layout_height="match_parent"
android:layout_width="match_parent" />
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@@ -3,23 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<!--
We always have windowTranslucentStatus=true to get under the status bar.
Thus this ImageView is the part under the status bar!
-->
<ImageView
android:id="@+id/status_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/statusbar_height"
android:background="@color/transparent" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_below="@+id/status_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/transparent"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
tools:ignore="UnusedAttribute" />

View File

@@ -3,23 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<!--
We always have windowTranslucentStatus=true to get under the status bar.
Thus this ImageView is the part under the status bar!
-->
<ImageView
android:id="@+id/status_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/statusbar_height"
android:background="@color/transparent" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_below="@+id/status_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/transparent"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
tools:ignore="UnusedAttribute" />

View File

@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar_include"
android:elevation="4dp"
android:background="?attr/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
>
<include
android:id="@+id/toolbar_inner_layout"
layout="@layout/toolbar_inner_layout" />
</RelativeLayout>
</FrameLayout>

View File

@@ -4,7 +4,8 @@
android:elevation="4dp"
android:background="@color/android_orange_light"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
>
<include
android:id="@+id/toolbar_inner_layout"

View File

@@ -4,7 +4,8 @@
android:elevation="4dp"
android:background="?attr/colorBrightToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
>
<include
android:id="@+id/toolbar_inner_layout"

View File

@@ -5,7 +5,8 @@
android:elevation="4dp"
android:background="?attr/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
>
<include
android:id="@+id/toolbar_inner_layout"

View File

@@ -20,7 +20,6 @@
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/primary"
app:expandedTitleMarginBottom="102dp"
app:expandedTitleMarginEnd="128dp"
@@ -31,7 +30,6 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="238dp"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<TextView

View File

@@ -8,5 +8,4 @@
<!-- 120dp + statusbar_height -->
<dimen name="big_toolbar">141dp</dimen>
<dimen name="huge_toolbar">243dp</dimen>
<dimen name="minus_statusbar_height">-25dp</dimen>
</resources>

View File

@@ -2,8 +2,6 @@
<resources>
<style name="Theme.Keychain.Light" parent="Base.Theme.Keychain.Light">
<item name="android:windowTranslucentStatus">true</item>
<!-- enable window content transitions -->
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
@@ -14,7 +12,6 @@
</style>
<style name="Theme.Keychain.Dark" parent="Base.Theme.Keychain.Dark">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:navigationBarColor">#33cccccc</item>
<!-- enable window content transitions -->

View File

@@ -4,5 +4,4 @@
<dimen name="statusbar_height">0dp</dimen>
<dimen name="big_toolbar">120dp</dimen>
<dimen name="huge_toolbar">222dp</dimen>
<dimen name="minus_statusbar_height">0dp</dimen>
</resources>