mirror of https://github.com/M66B/FairEmail.git
Three column layout - proof of concept
This commit is contained in:
parent
6256a22691
commit
e1884a6e8e
|
@ -88,7 +88,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
private View content_separator;
|
||||
private View content_pane;
|
||||
|
||||
private DrawerLayout drawerLayout;
|
||||
private DrawerLayoutEx drawerLayout;
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
private ScrollView drawerContainer;
|
||||
private RecyclerView rvAccount;
|
||||
|
@ -154,7 +154,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
content_pane = findViewById(R.id.content_pane);
|
||||
|
||||
drawerLayout = findViewById(R.id.drawer_layout);
|
||||
drawerLayout.setScrimColor(Helper.resolveColor(this, R.attr.colorDrawerScrim));
|
||||
drawerLayout.setup(getResources().getConfiguration());
|
||||
// drawerLayout.setScrimColor(Helper.resolveColor(this, R.attr.colorDrawerScrim));
|
||||
|
||||
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.app_name, R.string.app_name) {
|
||||
public void onDrawerClosed(View view) {
|
||||
|
@ -541,6 +542,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
drawerLayout.setup(newConfig);
|
||||
drawerToggle.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
package eu.faircode.email;
|
||||
|
||||
/*
|
||||
This file is part of FairEmail.
|
||||
|
||||
FairEmail is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FairEmail 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
public class DrawerLayoutEx extends DrawerLayout {
|
||||
private boolean locked;
|
||||
|
||||
public DrawerLayoutEx(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public DrawerLayoutEx(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public DrawerLayoutEx(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
void setup(Configuration config) {
|
||||
Log.i("Drawer setup orientation=" + config.orientation);
|
||||
ViewGroup childContent = (ViewGroup) getChildAt(0);
|
||||
ViewGroup childDrawer = (ViewGroup) getChildAt(1);
|
||||
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
locked = true;
|
||||
setDrawerLockMode(LOCK_MODE_LOCKED_OPEN);
|
||||
setScrimColor(Color.TRANSPARENT);
|
||||
childContent.setPaddingRelative(childDrawer.getLayoutParams().width, 0, 0, 0);
|
||||
} else {
|
||||
locked = false;
|
||||
setDrawerLockMode(LOCK_MODE_UNLOCKED);
|
||||
setScrimColor(Helper.resolveColor(getContext(), R.attr.colorDrawerScrim));
|
||||
childContent.setPaddingRelative(0, 0, 0, 0);
|
||||
closeDrawers();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDrawerOpen(@NonNull View drawer) {
|
||||
return (!locked && super.isDrawerOpen(drawer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDrawerOpen(int drawerGravity) {
|
||||
return (!locked && super.isDrawerOpen(drawerGravity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(final MotionEvent ev) {
|
||||
return (!locked && super.onInterceptTouchEvent(ev));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeDrawer(@NonNull View drawerView) {
|
||||
if (!locked)
|
||||
super.closeDrawer(drawerView);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<eu.faircode.email.DrawerLayoutEx xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -42,4 +42,4 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</ScrollView>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
</eu.faircode.email.DrawerLayoutEx>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<eu.faircode.email.DrawerLayoutEx xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -23,4 +23,4 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</ScrollView>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
</eu.faircode.email.DrawerLayoutEx>
|
||||
|
|
Loading…
Reference in New Issue