Added tablet landscape two column layout

This commit is contained in:
M66B 2018-11-09 15:59:01 +00:00
parent 3fee71b289
commit d56296eda3
2 changed files with 72 additions and 1 deletions

View File

@ -81,7 +81,9 @@ import javax.net.ssl.HttpsURLConnection;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.constraintlayout.widget.Group;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
@ -92,6 +94,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
public class ActivityView extends ActivityBilling implements FragmentManager.OnBackStackChangedListener {
private View view;
private DrawerLayout drawerLayout;
private Group grpPane;
private ListView drawerList;
private ActionBarDrawerToggle drawerToggle;
@ -135,6 +138,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
drawerLayout = findViewById(R.id.drawer_layout);
drawerLayout.setScrimColor(Helper.resolveColor(this, R.attr.colorDrawerScrim));
grpPane = findViewById(R.id.grpPane);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.app_name, R.string.app_name) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
@ -422,6 +427,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (drawerLayout.isDrawerOpen(drawerList))
drawerLayout.closeDrawer(drawerList);
drawerToggle.setDrawerIndicatorEnabled(count == 1);
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content_pane);
grpPane.setVisibility(fragment == null ? View.GONE : View.VISIBLE);
}
}
@ -862,8 +870,16 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
FragmentMessages fragment = new FragmentMessages();
fragment.setArguments(args);
int pane;
if (findViewById(R.id.content_pane) == null)
pane = R.id.content_frame;
else {
pane = R.id.content_pane;
grpPane.setVisibility(View.VISIBLE);
}
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("thread");
fragmentTransaction.replace(pane, fragment).addToBackStack("thread");
fragmentTransaction.commit();
}

View File

@ -0,0 +1,55 @@
<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"
tools:context=".ActivityView">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintEnd_toStartOf="@+id/content_separator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/content_separator"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toStartOf="@+id/content_pane"
app:layout_constraintStart_toEndOf="@id/content_frame"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/content_pane"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/content_separator"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpPane"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:constraint_referenced_ids="content_separator,content_pane" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ListView
android:id="@+id/drawer_list"
android:layout_width="270dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/colorDrawerBackground"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</androidx.drawerlayout.widget.DrawerLayout>