Collapsible unified system folders

pull/159/head
M66B 6 years ago
parent 12c47070fd
commit 9c13eee4b5

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

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

Loading…
Cancel
Save