Browse Source

Commonize activity toolbar layouts

Peter Cai 1 year ago
parent
commit
4a32f53c06

+ 1 - 16
app-common/src/main/res/layout/activity_logs.xml

@@ -5,22 +5,7 @@
     android:layout_height="match_parent"
     android:layout_height="match_parent"
     xmlns:app="http://schemas.android.com/apk/res-auto">
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
 
-    <View
-        android:id="@+id/toolbar_spacer"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:background="?attr/colorSurfaceVariant"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintBottom_toTopOf="@id/toolbar" />
-
-    <com.google.android.material.appbar.MaterialToolbar
-        android:id="@+id/toolbar"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintWidth_percent="1" />
+    <include layout="@layout/toolbar_activity" />
 
 
     <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
     <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
         android:id="@+id/swipe_refresh"
         android:id="@+id/swipe_refresh"

+ 1 - 16
app-common/src/main/res/layout/activity_main.xml

@@ -5,22 +5,7 @@
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
     android:layout_height="match_parent">
 
 
-    <View
-        android:id="@+id/toolbar_spacer"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:background="?attr/colorSurfaceVariant"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintBottom_toTopOf="@id/toolbar" />
-
-    <com.google.android.material.appbar.MaterialToolbar
-        android:id="@+id/toolbar"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintWidth_percent="1" />
+    <include layout="@layout/toolbar_activity" />
 
 
     <com.google.android.material.tabs.TabLayout
     <com.google.android.material.tabs.TabLayout
         android:id="@+id/main_tabs"
         android:id="@+id/main_tabs"

+ 1 - 16
app-common/src/main/res/layout/activity_notifications.xml

@@ -4,22 +4,7 @@
     android:layout_height="match_parent"
     android:layout_height="match_parent"
     xmlns:app="http://schemas.android.com/apk/res-auto">
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
 
-    <View
-        android:id="@+id/toolbar_spacer"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:background="?attr/colorSurfaceVariant"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintBottom_toTopOf="@id/toolbar" />
-
-    <com.google.android.material.appbar.MaterialToolbar
-        android:id="@+id/toolbar"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintWidth_percent="1" />
+    <include layout="@layout/toolbar_activity" />
 
 
     <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
     <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
         android:id="@+id/swipe_refresh"
         android:id="@+id/swipe_refresh"

+ 1 - 16
app-common/src/main/res/layout/activity_settings.xml

@@ -4,22 +4,7 @@
     android:layout_height="match_parent"
     android:layout_height="match_parent"
     xmlns:app="http://schemas.android.com/apk/res-auto">
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
 
-    <View
-        android:id="@+id/toolbar_spacer"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:background="?attr/colorSurfaceVariant"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintBottom_toTopOf="@id/toolbar" />
-
-    <com.google.android.material.appbar.MaterialToolbar
-        android:id="@+id/toolbar"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintWidth_percent="1" />
+    <include layout="@layout/toolbar_activity" />
 
 
     <FrameLayout
     <FrameLayout
         android:id="@+id/settings_container"
         android:id="@+id/settings_container"

+ 22 - 0
app-common/src/main/res/layout/toolbar_activity.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <View
+        android:id="@+id/toolbar_spacer"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:background="?attr/colorSurfaceVariant"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintBottom_toTopOf="@id/toolbar" />
+
+    <com.google.android.material.appbar.MaterialToolbar
+        android:id="@+id/toolbar"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintWidth_percent="1" />
+
+</merge>

+ 1 - 16
app-unpriv/src/main/res/layout/activity_compatibility_check.xml

@@ -4,22 +4,7 @@
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
     android:layout_height="match_parent">
 
 
-    <View
-        android:id="@+id/toolbar_spacer"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:background="?attr/colorSurfaceVariant"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintBottom_toTopOf="@id/toolbar" />
-
-    <com.google.android.material.appbar.MaterialToolbar
-        android:id="@+id/toolbar"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintWidth_percent="1" />
+    <include layout="@layout/toolbar_activity" />
 
 
     <androidx.recyclerview.widget.RecyclerView
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/recycler_view"
         android:id="@+id/recycler_view"