mirror of https://github.com/M66B/FairEmail.git
Made nav accounts collapsible
This commit is contained in:
parent
57dca80bfb
commit
2b668ee753
|
@ -49,7 +49,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
@ -93,6 +92,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
private DrawerLayoutEx drawerLayout;
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
private ScrollView drawerContainer;
|
||||
private ImageButton ibExpanderAccount;
|
||||
private RecyclerView rvAccount;
|
||||
private ImageButton ibExpanderUnified;
|
||||
private RecyclerView rvUnified;
|
||||
|
@ -100,7 +100,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
private RecyclerView rvMenu;
|
||||
private ImageButton ibExpanderExtra;
|
||||
private RecyclerView rvMenuExtra;
|
||||
private Group grpUnified;
|
||||
|
||||
private AdapterNavAccount adapterNavAccount;
|
||||
private AdapterNavUnified adapterNavUnified;
|
||||
|
@ -198,17 +197,29 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
drawerContainer = findViewById(R.id.drawer_container);
|
||||
|
||||
// Accounts
|
||||
ibExpanderAccount = drawerContainer.findViewById(R.id.ibExpanderAccount);
|
||||
|
||||
rvAccount = drawerContainer.findViewById(R.id.rvAccount);
|
||||
rvAccount.setLayoutManager(new LinearLayoutManager(this));
|
||||
adapterNavAccount = new AdapterNavAccount(this, this);
|
||||
rvAccount.setAdapter(adapterNavAccount);
|
||||
|
||||
boolean nav_account = prefs.getBoolean("nav_account", true);
|
||||
ibExpanderAccount.setImageLevel(nav_account ? 0 /* less */ : 1 /* more */);
|
||||
rvAccount.setVisibility(nav_account ? View.VISIBLE : View.GONE);
|
||||
|
||||
ibExpanderAccount.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean nav_account = !prefs.getBoolean("nav_account", true);
|
||||
prefs.edit().putBoolean("nav_account", nav_account).apply();
|
||||
ibExpanderAccount.setImageLevel(nav_account ? 0 /* less */ : 1 /* more */);
|
||||
rvAccount.setVisibility(nav_account ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
// Unified system folders
|
||||
ibExpanderUnified = drawerContainer.findViewById(R.id.ibExpanderUnified);
|
||||
ibExpanderUnified.setVisibility(View.GONE);
|
||||
|
||||
grpUnified = drawerContainer.findViewById(R.id.grpUnified);
|
||||
grpUnified.setVisibility(View.GONE);
|
||||
|
||||
rvUnified = drawerContainer.findViewById(R.id.rvUnified);
|
||||
rvUnified.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
@ -217,7 +228,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
|
||||
boolean unified_system = prefs.getBoolean("unified_system", true);
|
||||
ibExpanderUnified.setImageLevel(unified_system ? 0 /* less */ : 1 /* more */);
|
||||
grpUnified.setVisibility(unified_system ? View.VISIBLE : View.GONE);
|
||||
rvUnified.setVisibility(unified_system ? View.VISIBLE : View.GONE);
|
||||
|
||||
ibExpanderUnified.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -225,7 +236,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
boolean unified_system = !prefs.getBoolean("unified_system", true);
|
||||
prefs.edit().putBoolean("unified_system", unified_system).apply();
|
||||
ibExpanderUnified.setImageLevel(unified_system ? 0 /* less */ : 1 /* more */);
|
||||
grpUnified.setVisibility(unified_system ? View.VISIBLE : View.GONE);
|
||||
rvUnified.setVisibility(unified_system ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -533,9 +544,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
public void onChanged(List<TupleFolderUnified> folders) {
|
||||
if (folders == null)
|
||||
folders = new ArrayList<>();
|
||||
ibExpanderUnified.setVisibility(folders.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
boolean unified_system = prefs.getBoolean("unified_system", true);
|
||||
grpUnified.setVisibility(unified_system && folders.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
adapterNavUnified.set(folders);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,6 +4,17 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibExpanderAccount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@string/title_legend_expander"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/expander" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvAccount"
|
||||
android:layout_width="0dp"
|
||||
|
@ -11,7 +22,7 @@
|
|||
android:nestedScrollingEnabled="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/ibExpanderAccount" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorAccount"
|
||||
|
@ -106,10 +117,4 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/ibExpanderExtra" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpUnified"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="rvUnified,vSeparatorUnified" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
Loading…
Reference in New Issue