Collapsible unified system folders

This commit is contained in:
M66B 2019-07-20 22:22:21 +02:00
parent 12c47070fd
commit 9c13eee4b5
2 changed files with 65 additions and 10 deletions

View File

@ -85,11 +85,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private ActionBarDrawerToggle drawerToggle;
private ScrollView drawerContainer;
private RecyclerView rvAccount;
private ImageView ivExpanderUnified;
private RecyclerView rvUnified;
private RecyclerView rvFolder;
private RecyclerView rvMenu;
private ImageView ivExpander;
private ImageView ivExpanderExtra;
private RecyclerView rvMenuExtra;
private Group grpUnified;
private boolean exit = false;
private boolean searching = false;
@ -155,11 +157,31 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
final AdapterNavAccount aadapter = new AdapterNavAccount(this, this);
rvAccount.setAdapter(aadapter);
ivExpanderUnified = drawerContainer.findViewById(R.id.ivExpanderUnified);
ivExpanderUnified.setVisibility(View.GONE);
grpUnified = drawerContainer.findViewById(R.id.grpUnified);
grpUnified.setVisibility(View.GONE);
rvUnified = drawerContainer.findViewById(R.id.rvUnified);
rvUnified.setLayoutManager(new LinearLayoutManager(this));
final AdapterNavUnified uadapter = new AdapterNavUnified(this, this);
rvUnified.setAdapter(uadapter);
boolean unified_system = prefs.getBoolean("unified_system", false);
ivExpanderUnified.setImageLevel(unified_system ? 0 /* less */ : 1 /* more */);
grpUnified.setVisibility(unified_system ? View.VISIBLE : View.GONE);
ivExpanderUnified.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean unified_system = !prefs.getBoolean("unified_system", false);
prefs.edit().putBoolean("unified_system", unified_system).apply();
ivExpanderUnified.setImageLevel(unified_system ? 0 /* less */ : 1 /* more */);
grpUnified.setVisibility(unified_system ? View.VISIBLE : View.GONE);
}
});
rvFolder = drawerContainer.findViewById(R.id.rvFolder);
rvFolder.setLayoutManager(new LinearLayoutManager(this));
final AdapterNavFolder fadapter = new AdapterNavFolder(this, this);
@ -170,7 +192,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
final AdapterNavMenu madapter = new AdapterNavMenu(this, this);
rvMenu.setAdapter(madapter);
ivExpander = drawerContainer.findViewById(R.id.ivExpander);
ivExpanderExtra = drawerContainer.findViewById(R.id.ivExpanderExtra);
rvMenuExtra = drawerContainer.findViewById(R.id.rvMenuExtra);
LinearLayoutManager llm = new LinearLayoutManager(this);
@ -191,16 +213,23 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
rvMenuExtra.addItemDecoration(itemDecorator);
boolean minimal = prefs.getBoolean("minimal", false);
ivExpanderExtra.setImageLevel(minimal ? 1 /* more */ : 0 /* less */);
rvMenuExtra.setVisibility(minimal ? View.GONE : View.VISIBLE);
ivExpander.setImageLevel(minimal ? 1 /* more */ : 0 /* less */);
ivExpander.setOnClickListener(new View.OnClickListener() {
ivExpanderExtra.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean minimal = !prefs.getBoolean("minimal", false);
prefs.edit().putBoolean("minimal", minimal).apply();
ivExpanderExtra.setImageLevel(minimal ? 1 /* more */ : 0 /* less */);
rvMenuExtra.setVisibility(minimal ? View.GONE : View.VISIBLE);
ivExpander.setImageLevel(minimal ? 1 /* more */ : 0 /* less */);
if (!minimal)
new Handler().post(new Runnable() {
@Override
public void run() {
drawerContainer.fullScroll(View.FOCUS_DOWN);
}
});
}
});
@ -363,6 +392,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
public void onChanged(List<String> types) {
if (types == null)
types = new ArrayList<>();
ivExpanderUnified.setVisibility(types.size() > 0 ? View.VISIBLE : View.GONE);
boolean unified_system = prefs.getBoolean("unified_system", false);
grpUnified.setVisibility(unified_system && types.size() > 0 ? View.VISIBLE : View.GONE);
uadapter.set(types);
}
});

View File

@ -12,16 +12,33 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vSeparatorAccount"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvAccount" />
<ImageView
android:id="@+id/ivExpanderUnified"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_expander"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorAccount"
app:srcCompat="@drawable/expander" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvUnified"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvAccount" />
app:layout_constraintTop_toBottomOf="@id/ivExpanderUnified" />
<View
android:id="@+id/vSeparatorAccount"
android:id="@+id/vSeparatorUnified"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
@ -34,7 +51,7 @@
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorAccount" />
app:layout_constraintTop_toBottomOf="@id/vSeparatorUnified" />
<View
android:id="@+id/vSeparatorFolder"
@ -61,7 +78,7 @@
app:layout_constraintTop_toBottomOf="@id/rvMenu" />
<ImageView
android:id="@+id/ivExpander"
android:id="@+id/ivExpanderExtra"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_expander"
@ -75,5 +92,11 @@
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivExpander" />
app:layout_constraintTop_toBottomOf="@id/ivExpanderExtra" />
<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>