From 72661d2cd04cc3fcb378f22c3cdbc290a5171d8e Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 3 May 2020 22:27:41 +0300 Subject: [PATCH] reorganize main activity layout to let the CoordinatorLayout do its job with the Snackbars also leads to a cleaner situation on new installs - no drawer until a profile is created --- .../ui/activity/MainActivity.java | 24 ++- app/src/main/res/layout/activity_main.xml | 151 ++--------------- app/src/main/res/layout/main_app_layout.xml | 157 ++++++++++++++++++ app/src/main/res/layout/main_navigation.xml | 6 +- app/src/main/res/layout/no_profiles.xml | 3 +- 5 files changed, 192 insertions(+), 149 deletions(-) create mode 100644 app/src/main/res/layout/main_app_layout.xml diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index bc481a6d..a1939961 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -37,6 +37,7 @@ import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.widget.Toolbar; import androidx.core.view.GravityCompat; @@ -184,6 +185,23 @@ public class MainActivity extends ProfileThemedActivity { drawer.addDrawerListener(barDrawerToggle); } barDrawerToggle.syncState(); + drawer.addDrawerListener(new DrawerLayout.DrawerListener() { + @Override + public void onDrawerSlide(@NonNull View drawerView, float slideOffset) { + if (slideOffset > 0.2) + fabHide(); + } + @Override + public void onDrawerOpened(@NonNull View drawerView) { + fabHide(); + } + @Override + public void onDrawerClosed(@NonNull View drawerView) { + fabShouldShow(); + } + @Override + public void onDrawerStateChanged(int newState) {} + }); try { @@ -364,18 +382,18 @@ public class MainActivity extends ProfileThemedActivity { // profiles not yet loaded from DB findViewById(R.id.loading_layout).setVisibility(View.VISIBLE); findViewById(R.id.no_profiles_layout).setVisibility(View.GONE); - findViewById(R.id.pager_layout).setVisibility(View.GONE); + findViewById(R.id.main_app_layout).setVisibility(View.GONE); return; } if (newList.isEmpty()) { findViewById(R.id.no_profiles_layout).setVisibility(View.VISIBLE); - findViewById(R.id.pager_layout).setVisibility(View.GONE); + findViewById(R.id.main_app_layout).setVisibility(View.GONE); findViewById(R.id.loading_layout).setVisibility(View.GONE); return; } - findViewById(R.id.pager_layout).setVisibility(View.VISIBLE); + findViewById(R.id.main_app_layout).setVisibility(View.VISIBLE); findViewById(R.id.no_profiles_layout).setVisibility(View.GONE); findViewById(R.id.loading_layout).setVisibility(View.GONE); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 61592e84..9c4bcb90 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -14,148 +14,17 @@ ~ You should have received a copy of the GNU General Public License ~ along with MoLe. If not, see . --> - + android:layout_height="match_parent"> - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + \ No newline at end of file diff --git a/app/src/main/res/layout/main_app_layout.xml b/app/src/main/res/layout/main_app_layout.xml new file mode 100644 index 00000000..86e91870 --- /dev/null +++ b/app/src/main/res/layout/main_app_layout.xml @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/main_navigation.xml b/app/src/main/res/layout/main_navigation.xml index fb30743c..afbd199a 100644 --- a/app/src/main/res/layout/main_navigation.xml +++ b/app/src/main/res/layout/main_navigation.xml @@ -23,8 +23,7 @@ android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" - android:theme="@style/ThemeOverlay.AppCompat.Light" - tools:showIn="@layout/activity_main"> + android:theme="@style/ThemeOverlay.AppCompat.Light"> + android:orientation="vertical"> diff --git a/app/src/main/res/layout/no_profiles.xml b/app/src/main/res/layout/no_profiles.xml index a072d151..8a704961 100644 --- a/app/src/main/res/layout/no_profiles.xml +++ b/app/src/main/res/layout/no_profiles.xml @@ -21,7 +21,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="?table_row_dark_bg" - android:visibility="gone"> + android:visibility="visible">