]> git.ktnx.net Git - mobile-ledger.git/commitdiff
add a copy of the navigation drawer header to the welcome screen
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 3 May 2020 12:55:09 +0000 (15:55 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 3 May 2020 12:57:45 +0000 (15:57 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
app/src/main/res/layout/main_navigation.xml
app/src/main/res/layout/nav_header_layout.xml [new file with mode: 0644]
app/src/main/res/layout/no_profiles.xml

index 64d32be4797a45c16249ac77f9b49c8d93467f96..21ed55884181b8814a5e8e33fd358f4134e770c5 100644 (file)
@@ -185,12 +185,14 @@ public class MainActivity extends ProfileThemedActivity {
         }
         barDrawerToggle.syncState();
 
-        TextView ver = drawer.findViewById(R.id.drawer_version_text);
 
         try {
             PackageInfo pi = getApplicationContext().getPackageManager()
                                                     .getPackageInfo(getPackageName(), 0);
-            ver.setText(pi.versionName);
+            ((TextView) findViewById(R.id.nav_upper).findViewById(
+                    R.id.drawer_version_text)).setText(pi.versionName);
+            ((TextView) findViewById(R.id.no_profiles_layout).findViewById(
+                    R.id.drawer_version_text)).setText(pi.versionName);
         }
         catch (Exception e) {
             e.printStackTrace();
index 8de14e2e7651c577edf5b8a3af4a33c068b642c5..fb30743c8420a1711e2d20247499b911d995d352 100644 (file)
                 app:layout_constraintBottom_toTopOf="@+id/nav_fixed_items"
                 app:layout_constraintTop_toBottomOf="@+id/nav_header">
 
-                <LinearLayout
-                    android:id="@+id/nav_header"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:background="@drawable/side_nav_bar"
-                    android:gravity="center_vertical"
-                    android:orientation="horizontal"
-                    android:padding="@dimen/activity_vertical_margin"
-                    android:theme="@style/ThemeOverlay.AppCompat.Dark"
-                    app:layout_constraintTop_toTopOf="parent">
-
-                    <include layout="@layout/nav_header_logo" />
-
-                    <LinearLayout
-                        android:layout_width="match_parent"
-                        android:layout_height="match_parent"
-                        android:layout_marginStart="@dimen/activity_horizontal_margin"
-                        android:layout_marginEnd="@dimen/activity_horizontal_margin"
-                        android:gravity="center_vertical"
-                        android:orientation="vertical">
-
-                        <TextView
-                            android:layout_width="match_parent"
-                            android:layout_height="wrap_content"
-                            android:text="@string/app_name"
-                            android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
-
-                        <TextView
-                            android:id="@+id/drawer_version_text"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:text="dummy version"
-                            tools:ignore="HardcodedText" />
-                    </LinearLayout>
-
-                </LinearLayout>
+                <include layout="@layout/nav_header_layout" />
 
                 <LinearLayout
                     android:id="@+id/nav_actions"
diff --git a/app/src/main/res/layout/nav_header_layout.xml b/app/src/main/res/layout/nav_header_layout.xml
new file mode 100644 (file)
index 0000000..f51fdb8
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright © 2020 Damyan Ivanov.
+  ~ This file is part of MoLe.
+  ~ MoLe is free software: you can distribute it and/or modify it
+  ~ under the term of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ (at your opinion), any later version.
+  ~
+  ~ MoLe is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  ~ GNU General Public License terms for details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+  -->
+
+<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/nav_header"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@drawable/side_nav_bar"
+    android:gravity="center_vertical"
+    android:orientation="horizontal"
+    android:padding="@dimen/activity_vertical_margin"
+    android:theme="@style/ThemeOverlay.AppCompat.Dark"
+    app:layout_constraintTop_toTopOf="parent"
+    tools:showIn="@layout/main_navigation">
+
+    <include layout="@layout/nav_header_logo" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_marginStart="@dimen/activity_horizontal_margin"
+        android:layout_marginEnd="@dimen/activity_horizontal_margin"
+        android:gravity="center_vertical"
+        android:orientation="vertical">
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/app_name"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
+
+        <TextView
+            android:id="@+id/drawer_version_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="dummy version"
+            tools:ignore="HardcodedText" />
+    </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
index f3a4d4d6defb898a765d7c5ed3fc421615c4da9d..a072d151dffc1fefe8f958237fb62645234c24f1 100644 (file)
 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/no_profiles_layout"
-    android:visibility="gone"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="?table_row_dark_bg"
-    android:padding="@dimen/activity_horizontal_margin">
+    android:visibility="gone">
 
-    <TextView
-        android:id="@+id/textView"
-        android:layout_width="wrap_content"
+    <FrameLayout
+        android:id="@+id/welcome_header"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="48dp"
-        android:text="@string/text_welcome"
-        android:textColor="?textColor"
-        android:textSize="48sp"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
+        app:layout_constraintTop_toTopOf="parent">
 
-    <TextView
-        android:id="@+id/textView3"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="8dp"
-        android:layout_marginTop="24dp"
-        android:layout_marginEnd="8dp"
-        android:text="@string/text_welcome_profile_needed"
-        android:textColor="?textColor"
-        android:textSize="20sp"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/textView" />
+        <include layout="@layout/nav_header_layout" />
+    </FrameLayout>
 
-    <Button
-        android:id="@+id/btn_no_profiles_add"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="8dp"
-        android:layout_marginTop="24dp"
-        android:layout_marginEnd="8dp"
-        android:layout_marginBottom="8dp"
-        android:backgroundTint="?colorAccent"
-        android:drawablePadding="16dp"
-        android:text="@string/create_profile_label"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintTop_toBottomOf="@id/welcome_header"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/textView3" />
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:padding="@dimen/activity_horizontal_margin">
+
+        <TextView
+            android:id="@+id/textView"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="48dp"
+            android:text="@string/text_welcome"
+            android:textColor="?textColor"
+            android:textSize="48sp"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <TextView
+            android:id="@+id/textView3"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="8dp"
+            android:layout_marginTop="24dp"
+            android:layout_marginEnd="8dp"
+            android:text="@string/text_welcome_profile_needed"
+            android:textColor="?textColor"
+            android:textSize="20sp"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/textView" />
+
+        <Button
+            android:id="@+id/btn_no_profiles_add"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="8dp"
+            android:layout_marginTop="24dp"
+            android:layout_marginEnd="8dp"
+            android:layout_marginBottom="8dp"
+            android:backgroundTint="?colorAccent"
+            android:drawablePadding="16dp"
+            android:text="@string/create_profile_label"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/textView3" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file