mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-22 23:09:13 +00:00
Replace the FAB with a bottom sheet dialog
This also removes the dependency on ``com.getbase:floatingactionbutton``.
This commit is contained in:
parent
dea13f56f5
commit
e324f649ee
9 changed files with 120 additions and 102 deletions
|
@ -134,8 +134,8 @@ dependencies {
|
|||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||
implementation 'com.getbase:floatingactionbutton:1.10.1'
|
||||
implementation 'com.github.avito-tech:krop:0.51'
|
||||
|
||||
implementation "com.github.bumptech.glide:annotations:${glideVersion}"
|
||||
implementation "com.github.bumptech.glide:glide:${glideVersion}"
|
||||
implementation("com.github.bumptech.glide:recyclerview-integration:${glideVersion}") {
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.View;
|
|||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
||||
|
||||
public class FabScrollHelper {
|
||||
private View _fabMenu;
|
||||
|
|
|
@ -7,14 +7,12 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -39,7 +37,8 @@ import com.beemdevelopment.aegis.vault.VaultEntry;
|
|||
import com.beemdevelopment.aegis.vault.VaultFile;
|
||||
import com.beemdevelopment.aegis.vault.VaultManager;
|
||||
import com.beemdevelopment.aegis.vault.VaultManagerException;
|
||||
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.FormatException;
|
||||
|
@ -86,7 +85,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
private Menu _menu;
|
||||
private SearchView _searchView;
|
||||
private FloatingActionsMenu _fabMenu;
|
||||
private EntryListView _entryListView;
|
||||
private LinearLayout _btnBackupError;
|
||||
|
||||
|
@ -108,7 +106,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
_isDoingIntro = savedInstanceState.getBoolean("isDoingIntro");
|
||||
}
|
||||
|
||||
// set up the entry view
|
||||
_entryListView = (EntryListView) getSupportFragmentManager().findFragmentById(R.id.key_profiles);
|
||||
_entryListView.setListener(this);
|
||||
_entryListView.setCodeGroupSize(getPreferences().getCodeGroupSize());
|
||||
|
@ -121,27 +118,34 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
_entryListView.setViewMode(getPreferences().getCurrentViewMode());
|
||||
_entryListView.setIsCopyOnTapEnabled(getPreferences().isCopyOnTapEnabled());
|
||||
|
||||
// set up the floating action button
|
||||
_fabMenu = findViewById(R.id.fab);
|
||||
findViewById(R.id.fab_enter).setOnClickListener(view -> {
|
||||
_fabMenu.collapse();
|
||||
startEditEntryActivity(CODE_ADD_ENTRY, null, true);
|
||||
});
|
||||
findViewById(R.id.fab_scan_image).setOnClickListener(view -> {
|
||||
_fabMenu.collapse();
|
||||
startScanImageActivity();
|
||||
});
|
||||
findViewById(R.id.fab_scan).setOnClickListener(view -> {
|
||||
_fabMenu.collapse();
|
||||
startScanActivity();
|
||||
});
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(v -> {
|
||||
View view = getLayoutInflater().inflate(R.layout.dialog_add_entry, null);
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(this);
|
||||
dialog.setContentView(view);
|
||||
|
||||
view.findViewById(R.id.fab_enter).setOnClickListener(v1 -> {
|
||||
dialog.dismiss();
|
||||
startEditEntryActivity(CODE_ADD_ENTRY, null, true);
|
||||
});
|
||||
view.findViewById(R.id.fab_scan_image).setOnClickListener(v2 -> {
|
||||
dialog.dismiss();
|
||||
startScanImageActivity();
|
||||
});
|
||||
view.findViewById(R.id.fab_scan).setOnClickListener(v3 -> {
|
||||
dialog.dismiss();
|
||||
startScanActivity();
|
||||
});
|
||||
|
||||
Dialogs.showSecureDialog(dialog);
|
||||
});
|
||||
|
||||
_btnBackupError = findViewById(R.id.btn_backup_error);
|
||||
_btnBackupError.setOnClickListener(view -> {
|
||||
startPreferencesActivity("pref_backups");
|
||||
});
|
||||
|
||||
_fabScrollHelper = new FabScrollHelper(_fabMenu);
|
||||
_fabScrollHelper = new FabScrollHelper(fab);
|
||||
_selectedEntries = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -158,23 +162,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
// collapse the fab menu on touch
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (_fabMenu.isExpanded()) {
|
||||
Rect rect = new Rect();
|
||||
_fabMenu.getGlobalVisibleRect(rect);
|
||||
|
||||
if (!rect.contains((int) event.getRawX(), (int) event.getRawY())) {
|
||||
_fabMenu.collapse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
_isAuthenticating = false;
|
||||
|
|
|
@ -21,11 +21,10 @@ import com.beemdevelopment.aegis.helpers.FabScrollHelper;
|
|||
import com.beemdevelopment.aegis.importers.DatabaseImporterEntryException;
|
||||
import com.beemdevelopment.aegis.ui.models.ImportEntry;
|
||||
import com.beemdevelopment.aegis.ui.views.ImportEntriesAdapter;
|
||||
import com.getbase.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class SelectEntriesActivity extends AegisActivity {
|
||||
private ImportEntriesAdapter _adapter;
|
||||
|
@ -69,15 +68,15 @@ public class SelectEntriesActivity extends AegisActivity {
|
|||
showErrorDialog(errors);
|
||||
}
|
||||
|
||||
FloatingActionButton fabMenu = findViewById(R.id.fab);
|
||||
fabMenu.setOnClickListener(v -> {
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(v -> {
|
||||
if (_vaultContainsEntries) {
|
||||
showWipeEntriesDialog();
|
||||
} else {
|
||||
returnSelectedEntries(false);
|
||||
}
|
||||
});
|
||||
_fabScrollHelper = new FabScrollHelper(fabMenu);
|
||||
_fabScrollHelper = new FabScrollHelper(fab);
|
||||
}
|
||||
|
||||
private void showErrorDialog(List<DatabaseImporterEntryException> errors) {
|
||||
|
|
|
@ -46,50 +46,13 @@
|
|||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- note: the fab should always be the last element to be sure it's displayed on top -->
|
||||
<com.getbase.floatingactionbutton.FloatingActionsMenu
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
style="@style/FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:src="@drawable/ic_add_black_24dp"
|
||||
app:fab_addButtonColorNormal="@color/colorAccent"
|
||||
app:fab_addButtonColorPressed="@color/colorAccent"
|
||||
app:fab_labelStyle="@style/fab_label_style">
|
||||
|
||||
<com.getbase.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab_scan"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:fab_title="@string/scan"
|
||||
app:fab_size="mini"
|
||||
app:fab_colorNormal="@color/background"
|
||||
app:fab_colorPressed="@color/background"
|
||||
app:fab_icon="@drawable/ic_qrcode_scan"/>
|
||||
|
||||
<com.getbase.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab_scan_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:fab_title="@string/scan_image"
|
||||
app:fab_size="mini"
|
||||
app:fab_colorNormal="@color/background"
|
||||
app:fab_colorPressed="@color/background"
|
||||
app:fab_icon="@drawable/ic_add_photo_24px"/>
|
||||
|
||||
|
||||
<com.getbase.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab_enter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:fab_title="@string/enter_manually"
|
||||
app:fab_size="mini"
|
||||
app:fab_colorNormal="@color/background"
|
||||
app:fab_colorPressed="@color/background"
|
||||
app:fab_icon="@drawable/ic_create_black_24dp"/>
|
||||
|
||||
</com.getbase.floatingactionbutton.FloatingActionsMenu>
|
||||
android:tint="@color/icon_primary_dark" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -18,16 +18,12 @@
|
|||
android:clipToPadding="false"
|
||||
android:scrollbars="vertical"/>
|
||||
|
||||
<com.getbase.floatingactionbutton.FloatingActionButton
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:fab_icon="@drawable/ic_check_black_24dp"
|
||||
app:fab_colorNormal="@color/colorAccent"
|
||||
app:fab_colorPressed="@color/colorAccent"
|
||||
app:fab_labelStyle="@style/fab_label_style"
|
||||
app:fab_labelsPosition="left">
|
||||
</com.getbase.floatingactionbutton.FloatingActionButton>
|
||||
android:src="@drawable/ic_check_black_24dp"
|
||||
android:tint="@color/icon_primary_dark" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
84
app/src/main/res/layout/dialog_add_entry.xml
Normal file
84
app/src/main/res/layout/dialog_add_entry.xml
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="?attr/background">
|
||||
<LinearLayout
|
||||
android:id="@+id/fab_scan"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="65dp"
|
||||
android:paddingHorizontal="15dp"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="7.5dp"
|
||||
android:orientation="horizontal"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground">
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_qrcode_scan"
|
||||
app:tint="?attr/iconColorPrimary" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/scan"
|
||||
android:textSize="17sp"
|
||||
android:textColor="?attr/primaryText"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginStart="20dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/fab_scan_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="65dp"
|
||||
android:paddingHorizontal="15dp"
|
||||
android:paddingTop="7.5dp"
|
||||
android:paddingBottom="7.5dp"
|
||||
android:orientation="horizontal"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground">
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_add_photo_24px"
|
||||
app:tint="?attr/iconColorPrimary" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/scan_image"
|
||||
android:textSize="17sp"
|
||||
android:textColor="?attr/primaryText"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginStart="20dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/fab_enter"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="65dp"
|
||||
android:paddingHorizontal="15dp"
|
||||
android:paddingTop="7.5dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:orientation="horizontal"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground">
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_create_black_24dp"
|
||||
app:tint="?attr/iconColorPrimary" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/enter_manually"
|
||||
android:textSize="17sp"
|
||||
android:textColor="?attr/primaryText"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginStart="20dp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="FloatingActionButton">
|
||||
<item name="fab_labelsPosition">right</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -230,8 +230,4 @@
|
|||
|
||||
<style name="AppTheme.NoActionBar.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
<style name="FloatingActionButton">
|
||||
<item name="fab_labelsPosition">left</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue