mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Hide some entry editing settings by default to reduce user confusion
This commit is contained in:
parent
fd9a387b4e
commit
f4bdf4645b
4 changed files with 91 additions and 50 deletions
|
@ -1,7 +1,6 @@
|
|||
package com.beemdevelopment.aegis;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.espresso.ViewInteraction;
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions;
|
||||
import androidx.test.espresso.matcher.RootMatchers;
|
||||
|
@ -147,7 +146,7 @@ public class OverallTest extends AegisTest {
|
|||
onView(withText(resId)).perform(click());
|
||||
}
|
||||
|
||||
private void changeFilter(String text) {
|
||||
/*private void changeFilter(String text) {
|
||||
openContextualActionModeOverflowMenu();
|
||||
onView(withText(R.string.filter)).perform(click());
|
||||
onView(withText(text)).perform(click());
|
||||
|
@ -155,12 +154,13 @@ public class OverallTest extends AegisTest {
|
|||
|
||||
private void changeFilter(@IdRes int resId) {
|
||||
changeFilter(ApplicationProvider.getApplicationContext().getString(resId));
|
||||
}
|
||||
}*/
|
||||
|
||||
private void addEntry(VaultEntry entry) {
|
||||
onView(withId(R.id.fab)).perform(click());
|
||||
onView(withId(R.id.fab_enter)).perform(click());
|
||||
|
||||
onView(withId(R.id.accordian_header)).perform(click());
|
||||
onView(withId(R.id.text_name)).perform(typeText(entry.getName()), closeSoftKeyboard());
|
||||
onView(withId(R.id.text_issuer)).perform(typeText(entry.getIssuer()), closeSoftKeyboard());
|
||||
|
||||
|
|
|
@ -12,12 +12,14 @@ import android.text.TextWatcher;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -64,6 +66,7 @@ public class EditEntryActivity extends AegisActivity {
|
|||
private static final int PICK_IMAGE_REQUEST = 0;
|
||||
|
||||
private boolean _isNew = false;
|
||||
private boolean _isManual = false;
|
||||
private VaultEntry _origEntry;
|
||||
private TreeSet<String> _groups;
|
||||
private boolean _hasCustomIcon = false;
|
||||
|
@ -112,6 +115,7 @@ public class EditEntryActivity extends AegisActivity {
|
|||
_origEntry = _vault.getEntryByUUID(entryUUID);
|
||||
} else {
|
||||
_origEntry = (VaultEntry) intent.getSerializableExtra("newEntry");
|
||||
_isManual = intent.getBooleanExtra("isManual", false);
|
||||
_isNew = true;
|
||||
setTitle(R.string.add_new_entry);
|
||||
}
|
||||
|
@ -134,7 +138,25 @@ public class EditEntryActivity extends AegisActivity {
|
|||
updateGroupDropdownList();
|
||||
DropdownHelper.fillDropdown(this, _dropdownGroup, _dropdownGroupList);
|
||||
|
||||
// if this is NOT a manually entered entry, move the "Secret" field from basic to advanced settings
|
||||
if (!_isNew || (_isNew && !_isManual)) {
|
||||
LinearLayout layoutSecret = findViewById(R.id.layout_secret);
|
||||
LinearLayout layoutBasic = findViewById(R.id.layout_basic);
|
||||
LinearLayout layoutAdvanced = findViewById(R.id.layout_advanced);
|
||||
layoutBasic.removeView(layoutSecret);
|
||||
layoutAdvanced.addView(layoutSecret, 0);
|
||||
((LinearLayout.LayoutParams) layoutSecret.getLayoutParams()).topMargin = 0;
|
||||
|
||||
if (_isNew && !_isManual) {
|
||||
setViewEnabled(layoutAdvanced, false);
|
||||
}
|
||||
} else {
|
||||
LinearLayout layoutTypeAlgo = findViewById(R.id.layout_type_algo);
|
||||
((LinearLayout.LayoutParams) layoutTypeAlgo.getLayoutParams()).topMargin = 0;
|
||||
}
|
||||
|
||||
_advancedSettingsHeader = findViewById(R.id.accordian_header);
|
||||
_advancedSettingsHeader.setOnClickListener(v -> openAdvancedSettings());
|
||||
_advancedSettings = findViewById(R.id.expandableLayout);
|
||||
|
||||
// fill the fields with values if possible
|
||||
|
@ -204,13 +226,6 @@ public class EditEntryActivity extends AegisActivity {
|
|||
startIconSelectionActivity();
|
||||
});
|
||||
|
||||
_advancedSettingsHeader.setOnClickListener(v -> openAdvancedSettings());
|
||||
|
||||
// automatically open advanced settings since 'Secret' is required.
|
||||
if (_isNew) {
|
||||
openAdvancedSettings();
|
||||
}
|
||||
|
||||
_dropdownGroup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
private int prevPosition = _dropdownGroupList.indexOf(_dropdownGroup.getText().toString());
|
||||
|
||||
|
@ -579,6 +594,17 @@ public class EditEntryActivity extends AegisActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
private static void setViewEnabled(View view, boolean enabled) {
|
||||
view.setEnabled(enabled);
|
||||
|
||||
if (view instanceof ViewGroup) {
|
||||
ViewGroup group = (ViewGroup) view;
|
||||
for (int i = 0; i < group.getChildCount(); i++) {
|
||||
setViewEnabled(group.getChildAt(i), enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TextWatcher _iconChangeListener = new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
|
|
@ -129,7 +129,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
view.findViewById(R.id.fab_enter).setOnClickListener(v1 -> {
|
||||
dialog.dismiss();
|
||||
startEditEntryActivity(CODE_ADD_ENTRY, null, true);
|
||||
startEditEntryActivityForManual(CODE_ADD_ENTRY);
|
||||
});
|
||||
view.findViewById(R.id.fab_scan_image).setOnClickListener(v2 -> {
|
||||
dialog.dismiss();
|
||||
|
@ -242,20 +242,30 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
}
|
||||
}
|
||||
|
||||
private void startEditEntryActivity(int requestCode, VaultEntry entry, boolean isNew) {
|
||||
private void startEditEntryActivityForNew(int requestCode, VaultEntry entry) {
|
||||
Intent intent = new Intent(this, EditEntryActivity.class);
|
||||
if (isNew) {
|
||||
intent.putExtra("newEntry", entry != null ? entry : VaultEntry.getDefault());
|
||||
} else {
|
||||
intent.putExtra("entryUUID", entry.getUUID());
|
||||
intent.putExtra("newEntry", entry);
|
||||
intent.putExtra("isManual", false);
|
||||
startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
private void startEditEntryActivityForManual(int requestCode) {
|
||||
Intent intent = new Intent(this, EditEntryActivity.class);
|
||||
intent.putExtra("newEntry", VaultEntry.getDefault());
|
||||
intent.putExtra("isManual", true);
|
||||
startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
private void startEditEntryActivity(int requestCode, VaultEntry entry) {
|
||||
Intent intent = new Intent(this, EditEntryActivity.class);
|
||||
intent.putExtra("entryUUID", entry.getUUID());
|
||||
startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
private void onScanResult(Intent data) {
|
||||
List<VaultEntry> entries = (ArrayList<VaultEntry>) data.getSerializableExtra("entries");
|
||||
if (entries.size() == 1) {
|
||||
startEditEntryActivity(CODE_ADD_ENTRY, entries.get(0), true);
|
||||
startEditEntryActivityForNew(CODE_ADD_ENTRY, entries.get(0));
|
||||
} else {
|
||||
for (VaultEntry entry : entries) {
|
||||
_vault.addEntry(entry);
|
||||
|
@ -313,7 +323,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
GoogleAuthInfo info = GoogleAuthInfo.parseUri(result.getText());
|
||||
VaultEntry entry = new VaultEntry(info);
|
||||
|
||||
startEditEntryActivity(CODE_ADD_ENTRY, entry, true);
|
||||
startEditEntryActivityForNew(CODE_ADD_ENTRY, entry);
|
||||
} catch (NotFoundException | IOException | ChecksumException | FormatException | GoogleAuthInfoException e) {
|
||||
e.printStackTrace();
|
||||
Dialogs.showErrorDialog(this, R.string.unable_to_read_qrcode, e);
|
||||
|
@ -416,7 +426,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
if (info != null) {
|
||||
VaultEntry entry = new VaultEntry(info);
|
||||
startEditEntryActivity(CODE_ADD_ENTRY, entry, true);
|
||||
startEditEntryActivityForNew(CODE_ADD_ENTRY, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -737,7 +747,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
return true;
|
||||
|
||||
case R.id.action_edit:
|
||||
startEditEntryActivity(CODE_EDIT_ENTRY, _selectedEntries.get(0), false);
|
||||
startEditEntryActivity(CODE_EDIT_ENTRY, _selectedEntries.get(0));
|
||||
mode.finish();
|
||||
return true;
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
android:layout_height="1dp"
|
||||
android:background="@color/divider" />
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_basic"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
|
@ -129,6 +130,36 @@
|
|||
android:inputType="none"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_secret"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_vpn_key_black_24dp"
|
||||
app:tint="?attr/iconColorPrimary"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
app:passwordToggleTint="#949494"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/text_secret"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/secret"
|
||||
android:inputType="textPassword"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -166,13 +197,16 @@
|
|||
android:layout_height="match_parent"
|
||||
android:visibility="invisible">
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_advanced"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginHorizontal="10dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_type_algo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -249,35 +283,6 @@
|
|||
android:inputType="text"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_vpn_key_black_24dp"
|
||||
app:tint="?attr/iconColorPrimary"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
app:passwordToggleTint="#949494"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/text_secret"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/secret"
|
||||
android:inputType="textPassword"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue