Tablet support
This commit is contained in:
@@ -95,11 +95,13 @@ public class MainActivity extends AppCompatActivity
|
||||
private CustomAccountManager mAccountManager;
|
||||
private boolean isPaused = false;
|
||||
private boolean isLoggedInBeforePause = false;
|
||||
private boolean isDrawerFixed = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mAccountManager = new CustomAccountManager(AccountManager.get(this), () -> MainActivity.this);
|
||||
isDrawerFixed = getResources().getBoolean(R.bool.isDrawerFixed);
|
||||
int desiredPage = getDefaultFragmentAfterLogin();
|
||||
String desiredData = "";
|
||||
Intent intent = getIntent();
|
||||
@@ -120,11 +122,13 @@ public class MainActivity extends AppCompatActivity
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (!isDrawerFixed) {
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawer.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
}
|
||||
|
||||
mNavigationView = findViewById(R.id.nav_view);
|
||||
mNavigationView.setNavigationItemSelectedListener(this);
|
||||
@@ -210,7 +214,7 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
if (drawer.isDrawerOpen(GravityCompat.START) && !isDrawerFixed) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
if (mFragmentPage == FRAGMENT_MODULES_DETAILS) {
|
||||
@@ -305,8 +309,10 @@ public class MainActivity extends AppCompatActivity
|
||||
break;
|
||||
|
||||
}
|
||||
if (!isDrawerFixed) {
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
}
|
||||
|
||||
int size = mNavigationView.getMenu().size();
|
||||
for (int k = 0; k < size; k++) {
|
||||
@@ -544,7 +550,7 @@ public class MainActivity extends AppCompatActivity
|
||||
if (!viewBtn.hasOnClickListeners())
|
||||
viewBtn.setOnClickListener(v -> {
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
if (drawer.isDrawerOpen(GravityCompat.START) && !isDrawerFixed) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
}
|
||||
mAccountManager.getTokenByType(AccountGeneral.ACCOUNT_TYPE, AccountGeneral.AUTHTOKEN_TYPE_KVV, null, null);
|
||||
|
||||
32
app/src/main/res/layout-sw600dp/activity_main.xml
Normal file
32
app/src/main/res/layout-sw600dp/activity_main.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:openDrawer="start">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
app:itemTextColor="@color/menu_text_color"
|
||||
app:itemIconTint="@color/menu_text_color"
|
||||
app:headerLayout="@layout/nav_header_main"
|
||||
app:menu="@menu/activity_main_drawer" />
|
||||
|
||||
<include
|
||||
layout="@layout/app_bar_main"
|
||||
android:id="@+id/app_bar_include"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
4
app/src/main/res/values-sw600dp/config_ui.xml
Normal file
4
app/src/main/res/values-sw600dp/config_ui.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isDrawerFixed">true</bool>
|
||||
</resources>
|
||||
4
app/src/main/res/values/config_ui.xml
Normal file
4
app/src/main/res/values/config_ui.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isDrawerFixed">false</bool>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user