mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-22 06:49:12 +00:00
Add seperate dialog for creating groups
To improve layout
This commit is contained in:
parent
324df53df5
commit
ae0b4b5a37
4 changed files with 40 additions and 18 deletions
|
@ -58,12 +58,8 @@ public class Dialogs {
|
|||
showSecureDialog(new AlertDialog.Builder(context)
|
||||
.setTitle(titleId)
|
||||
.setView(input)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
listener.onTextInputResult(input.getText().toString());
|
||||
}
|
||||
})
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) ->
|
||||
listener.onTextInputResult(input.getText().toString()))
|
||||
.create());
|
||||
}
|
||||
|
||||
|
@ -141,6 +137,20 @@ public class Dialogs {
|
|||
showSecureDialog(dialog);
|
||||
}
|
||||
|
||||
public static void showCreateNewGroupDialog(Activity activity, TextInputListener listener) {
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.dialog_newgroup, null);
|
||||
EditText groupName = view.findViewById(R.id.text_groupname);
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(activity)
|
||||
.setTitle(R.string.set_password)
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok, (dialog1, which) ->
|
||||
listener.onTextInputResult(groupName.getText().toString()))
|
||||
.create();
|
||||
|
||||
showSecureDialog(dialog);
|
||||
}
|
||||
|
||||
public static void showFingerprintDialog(Activity activity, Dialogs.SlotListener listener) {
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.dialog_fingerprint, null);
|
||||
TextView textFingerprint = view.findViewById(R.id.text_fingerprint);
|
||||
|
|
|
@ -219,18 +219,15 @@ public class EditEntryActivity extends AegisActivity {
|
|||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (position == _spinnerGroupList.size() - 1) {
|
||||
Dialogs.showTextInputDialog(activity, R.string.enter_group_name, new Dialogs.TextInputListener() {
|
||||
@Override
|
||||
public void onTextInputResult(String text) {
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
_groups.add(text);
|
||||
// reset the selection to "No group" to work around a quirk
|
||||
_spinnerGroup.setSelection(0, false);
|
||||
updateGroupSpinnerList();
|
||||
_spinnerGroup.setSelection(_spinnerGroupList.indexOf(text), false);
|
||||
Dialogs.showCreateNewGroupDialog(activity, text -> {
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
_groups.add(text);
|
||||
// reset the selection to "No group" to work around a quirk
|
||||
_spinnerGroup.setSelection(0, false);
|
||||
updateGroupSpinnerList();
|
||||
_spinnerGroup.setSelection(_spinnerGroupList.indexOf(text), false);
|
||||
});
|
||||
_spinnerGroup.setSelection(prevPosition, false);
|
||||
} else {
|
||||
|
|
14
app/src/main/res/layout/dialog_newgroup.xml
Normal file
14
app/src/main/res/layout/dialog_newgroup.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingTop="20dp">
|
||||
<EditText
|
||||
android:id="@+id/text_groupname"
|
||||
android:hint="@string/group_name_hint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
|
@ -139,6 +139,7 @@
|
|||
<string name="all">All</string>
|
||||
<string name="name">Name</string>
|
||||
<string name="no_group">No group</string>
|
||||
<string name="new_group">New group</string>
|
||||
<string name="new_group">New group...</string>
|
||||
<string name="enter_group_name">Enter a group name</string>
|
||||
<string name="group_name_hint">Group name</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue