mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-06-08 07:37:44 +00:00
Improve GroupManagerActivity
This commit is contained in:
parent
c03d00695d
commit
227b5fd87c
5 changed files with 77 additions and 6 deletions
|
@ -3,6 +3,7 @@ package com.beemdevelopment.aegis.ui;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.R;
|
import com.beemdevelopment.aegis.R;
|
||||||
import com.beemdevelopment.aegis.ui.views.GroupAdapter;
|
import com.beemdevelopment.aegis.ui.views.GroupAdapter;
|
||||||
|
@ -18,6 +19,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
public class GroupManagerActivity extends AegisActivity implements GroupAdapter.Listener {
|
public class GroupManagerActivity extends AegisActivity implements GroupAdapter.Listener {
|
||||||
private GroupAdapter _adapter;
|
private GroupAdapter _adapter;
|
||||||
private TreeSet<String> _groups;
|
private TreeSet<String> _groups;
|
||||||
|
private RecyclerView _slotsView;
|
||||||
|
private View _emptyStateView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -35,15 +38,28 @@ public class GroupManagerActivity extends AegisActivity implements GroupAdapter.
|
||||||
|
|
||||||
// set up the recycler view
|
// set up the recycler view
|
||||||
_adapter = new GroupAdapter(this);
|
_adapter = new GroupAdapter(this);
|
||||||
RecyclerView slotsView = findViewById(R.id.list_slots);
|
_slotsView= findViewById(R.id.list_slots);
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||||
slotsView.setLayoutManager(layoutManager);
|
_slotsView.setLayoutManager(layoutManager);
|
||||||
slotsView.setAdapter(_adapter);
|
_slotsView.setAdapter(_adapter);
|
||||||
slotsView.setNestedScrollingEnabled(false);
|
_slotsView.setNestedScrollingEnabled(false);
|
||||||
|
|
||||||
for (String group : _groups) {
|
for (String group : _groups) {
|
||||||
_adapter.addGroup(group);
|
_adapter.addGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_emptyStateView = findViewById(R.id.vEmptyList);
|
||||||
|
updateEmptyState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateEmptyState() {
|
||||||
|
if (_adapter.getItemCount() > 0) {
|
||||||
|
_slotsView.setVisibility(View.VISIBLE);
|
||||||
|
_emptyStateView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
_slotsView.setVisibility(View.GONE);
|
||||||
|
_emptyStateView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,6 +70,7 @@ public class GroupManagerActivity extends AegisActivity implements GroupAdapter.
|
||||||
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
|
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
|
||||||
_groups.remove(group);
|
_groups.remove(group);
|
||||||
_adapter.removeGroup(group);
|
_adapter.removeGroup(group);
|
||||||
|
updateEmptyState();
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.no, null)
|
.setNegativeButton(android.R.string.no, null)
|
||||||
.create());
|
.create());
|
||||||
|
|
|
@ -710,6 +710,8 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
entry.setGroup(null);
|
entry.setGroup(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveVault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSelectEntriesResult(int resultCode, Intent data) {
|
private void onSelectEntriesResult(int resultCode, Intent data) {
|
||||||
|
|
9
app/src/main/res/drawable/ic_layers_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_layers_black_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M11.99,18.54l-7.37,-5.73L3,14.07l9,7 9,-7 -1.63,-1.27 -7.38,5.74zM12,16l7.36,-5.73L21,9l-9,-7 -9,7 1.63,1.27L12,16z"/>
|
||||||
|
</vector>
|
|
@ -23,9 +23,50 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:scrollbars="vertical"/>
|
android:scrollbars="vertical"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center|fill_vertical"
|
||||||
|
android:id="@+id/vEmptyList"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="150dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:src="@drawable/ic_layers_black_24dp"
|
||||||
|
app:tint="?attr/primaryText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/empty_group_list_title"
|
||||||
|
android:paddingTop="17dp"
|
||||||
|
android:textColor="?attr/primaryText"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView5"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lineSpacingExtra="5dp"
|
||||||
|
android:paddingTop="7dp"
|
||||||
|
android:text="@string/empty_group_list"
|
||||||
|
android:textAlignment="center" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
|
@ -287,6 +287,8 @@
|
||||||
</string>
|
</string>
|
||||||
<string name="empty_list">There are no codes to be shown. Start adding entries by tapping the plus sign in the bottom right corner</string>
|
<string name="empty_list">There are no codes to be shown. Start adding entries by tapping the plus sign in the bottom right corner</string>
|
||||||
<string name="empty_list_title">No entries found</string>
|
<string name="empty_list_title">No entries found</string>
|
||||||
|
<string name="empty_group_list">There are no groups to be shown. Add groups in the edit screen of an entry</string>
|
||||||
|
<string name="empty_group_list_title">No groups found</string>
|
||||||
<string name="done">Done</string>
|
<string name="done">Done</string>
|
||||||
<plurals name="entries_count">
|
<plurals name="entries_count">
|
||||||
<item quantity="one">%d / %d entry</item>
|
<item quantity="one">%d / %d entry</item>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue