Skip to content

Commit

Permalink
Material 3
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Schättgen <[email protected]>
  • Loading branch information
alexbakker and michaelschattgen committed Jan 20, 2024
1 parent 566bcac commit a7bc5a9
Show file tree
Hide file tree
Showing 109 changed files with 955 additions and 974 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ dependencies {
implementation "androidx.camera:camera-camera2:$cameraxVersion"
implementation "androidx.camera:camera-lifecycle:$cameraxVersion"
implementation "androidx.camera:camera-view:$cameraxVersion"
implementation 'androidx.cardview:cardview:1.0.0'
implementation "androidx.core:core:1.12.0"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.documentfile:documentfile:1.0.1'
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
android:icon="@mipmap/${iconName}"
android:label="Aegis"
android:supportsRtl="true"
android:theme="@style/Theme.Aegis.Launch"
tools:replace="android:theme"
tools:targetApi="tiramisu">
<activity android:name=".ui.TransferEntriesActivity"
android:label="@string/title_activity_transfer" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.beemdevelopment.aegis.ui.MainActivity;
import com.beemdevelopment.aegis.util.IOUtils;
import com.beemdevelopment.aegis.vault.VaultManager;
import com.google.android.material.color.DynamicColors;
import com.google.android.material.color.DynamicColorsOptions;
import com.mikepenz.iconics.Iconics;
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic;
import com.topjohnwu.superuser.Shell;
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/com/beemdevelopment/aegis/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public CodeGrouping getCodeGroupSize() {
return CodeGrouping.valueOf(value);
}

public void setCodeGroupSize(CodeGrouping codeGroupSize) {
_prefs.edit().putString("pref_code_group_size_string", codeGroupSize.name()).apply();
}

public boolean isIntroDone() {
return _prefs.getBoolean("pref_intro", false);
}
Expand Down Expand Up @@ -198,6 +202,10 @@ public void setCurrentTheme(Theme theme) {
_prefs.edit().putInt("pref_current_theme", theme.ordinal()).apply();
}

public boolean isDynamicColorsEnabled() {
return _prefs.getBoolean("pref_dynamic_colors", false);
}

public ViewMode getCurrentViewMode() {
return ViewMode.fromInteger(_prefs.getInt("pref_current_view_mode", 0));
}
Expand Down Expand Up @@ -266,8 +274,16 @@ public int getTimeout() {
return _prefs.getInt("pref_timeout", -1);
}

public String getLanguage() {
return _prefs.getString("pref_lang", "system");
}

public void setLanguage(String lang) {
_prefs.edit().putString("pref_lang", lang).apply();
}

public Locale getLocale() {
String lang = _prefs.getString("pref_lang", "system");
String lang = getLanguage();

if (lang.equals("system")) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/beemdevelopment/aegis/ThemeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ private ThemeMap() {

}

public static final Map<Theme, Integer> DEFAULT = ImmutableMap.of(
/*public static final Map<Theme, Integer> DEFAULT = ImmutableMap.of(
Theme.LIGHT, R.style.Theme_Aegis_Light_Default,
Theme.DARK, R.style.Theme_Aegis_Dark_Default,
Theme.AMOLED, R.style.Theme_Aegis_TrueDark_Default
Expand All @@ -25,5 +25,5 @@ private ThemeMap() {
Theme.LIGHT, R.style.Theme_Aegis_Light_Fullscreen,
Theme.DARK, R.style.Theme_Aegis_Dark_Fullscreen,
Theme.AMOLED, R.style.Theme_Aegis_TrueDark_Fullscreen
);
);*/
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/beemdevelopment/aegis/ViewMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public float getDividerHeight() {
return 4;
}

return 20;
return 8;
}

public int getColumnSpan() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@ public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull Recycle
// It's not clear when this can happen, but sometimes the ViewHolder
// that's passed to this function has a position of -1, leading
// to a crash down the line.
int position = viewHolder.getAdapterPosition();
int position = viewHolder.getBindingAdapterPosition();
if (position == NO_POSITION) {
return 0;
}

int swipeFlags = 0;

EntryAdapter adapter = (EntryAdapter) recyclerView.getAdapter();
if (adapter == null) {
return 0;
}

int swipeFlags = 0;
if (adapter.isPositionFooter(position)
|| adapter.getEntryAt(position) != _selectedEntry
|| adapter.isPositionErrorCard(position)
|| adapter.getEntryAtPos(position) != _selectedEntry
|| !isLongPressDragEnabled()) {
return makeMovementFlags(0, swipeFlags);
}
Expand All @@ -76,12 +80,13 @@ public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull Recycle
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
RecyclerView.ViewHolder target) {
if (target.getAdapterPosition() < _adapter.getShownFavoritesCount()){
int targetIndex = _adapter.translateEntryPosToIndex(target.getBindingAdapterPosition());
if (targetIndex < _adapter.getShownFavoritesCount()) {
return false;
}

int firstPosition = viewHolder.getLayoutPosition();
int secondPosition = target.getAdapterPosition();
int secondPosition = target.getBindingAdapterPosition();

_adapter.onItemMove(firstPosition, secondPosition);
_positionChanged = true;
Expand All @@ -90,15 +95,15 @@ public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHol

@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
_adapter.onItemDismiss(viewHolder.getAdapterPosition());
_adapter.onItemDismiss(viewHolder.getBindingAdapterPosition());
}

@Override
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);

if (_positionChanged) {
_adapter.onItemDrop(viewHolder.getAdapterPosition());
_adapter.onItemDrop(viewHolder.getBindingAdapterPosition());
_positionChanged = false;
_adapter.refresh(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.beemdevelopment.aegis.ui.tasks.PBKDFTask;
import com.beemdevelopment.aegis.util.IOUtils;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.topjohnwu.superuser.io.SuFile;

import org.json.JSONArray;
Expand Down Expand Up @@ -182,7 +183,7 @@ public void decrypt(Context context, DecryptListener listener) {
context.getResources().getString(R.string.andotp_old_format)
};

Dialogs.showSecureDialog(new AlertDialog.Builder(context)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(context)
.setTitle(R.string.choose_andotp_importer)
.setSingleChoiceItems(choices, 0, null)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.content.pm.PackageManager;
import android.util.Xml;

import androidx.appcompat.app.AlertDialog;

import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.crypto.CryptoUtils;
import com.beemdevelopment.aegis.encoding.Base32;
Expand All @@ -18,6 +16,7 @@
import com.beemdevelopment.aegis.util.IOUtils;
import com.beemdevelopment.aegis.util.PreferenceParser;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.topjohnwu.superuser.io.SuFile;

import org.json.JSONArray;
Expand Down Expand Up @@ -154,7 +153,7 @@ protected DecryptedState decrypt(char[] password) throws DatabaseImporterExcepti

@Override
public void decrypt(Context context, DecryptListener listener) {
Dialogs.showSecureDialog(new AlertDialog.Builder(context)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(context)
.setMessage(R.string.choose_totpauth_importer)
.setPositiveButton(R.string.yes, (dialog, which) -> {
Dialogs.showPasswordInputDialog(context, password -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ private void openMail(String mailaddress) {

private void showThirdPartyLicenseDialog() {
String stylesheet = getString(R.string.custom_notices_format_style);
int backgroundColorResource = getConfiguredTheme() == Theme.AMOLED ? R.attr.cardBackgroundFocused : R.attr.cardBackground;
String backgroundColor = getThemeColorAsHex(backgroundColorResource);
String textColor = getThemeColorAsHex(R.attr.primaryText);
String licenseColor = getThemeColorAsHex(R.attr.cardBackgroundFocused);
String linkColor = getThemeColorAsHex(androidx.appcompat.R.attr.colorAccent);
String backgroundColor = getThemeColorAsHex(com.google.android.material.R.attr.colorSurfaceContainerLow);
String textColor = getThemeColorAsHex(com.google.android.material.R.attr.colorOnSurface);
String licenseColor = getThemeColorAsHex(com.google.android.material.R.attr.colorSurfaceContainerLow);
String linkColor = getThemeColorAsHex(com.google.android.material.R.attr.colorAccent);

stylesheet = String.format(stylesheet, backgroundColor, textColor, licenseColor, linkColor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.Theme;
import com.beemdevelopment.aegis.ThemeMap;
import com.beemdevelopment.aegis.icons.IconPackManager;
import com.beemdevelopment.aegis.vault.VaultManager;
import com.beemdevelopment.aegis.vault.VaultRepositoryException;
import com.google.android.material.color.DynamicColors;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -96,7 +96,10 @@ public void onLocked(boolean userInitiated) {
* Called when the activity is expected to set its theme.
*/
protected void onSetTheme() {
setTheme(ThemeMap.DEFAULT);
setTheme(R.style.Theme_Aegis);
if (_prefs.isDynamicColorsEnabled()) {
DynamicColors.applyToActivityIfAvailable(this);
}
}

/**
Expand Down
16 changes: 3 additions & 13 deletions app/src/main/java/com/beemdevelopment/aegis/ui/AuthActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
import android.view.KeyEvent;
Expand All @@ -20,11 +19,9 @@

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.biometric.BiometricPrompt;

import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.ThemeMap;
import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
import com.beemdevelopment.aegis.crypto.MasterKey;
Expand All @@ -43,6 +40,7 @@
import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.beemdevelopment.aegis.vault.slots.SlotIntegrityException;
import com.beemdevelopment.aegis.vault.slots.SlotList;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import java.util.List;

Expand Down Expand Up @@ -163,7 +161,7 @@ protected void onCreate(Bundle savedInstanceState) {

biometricsButton.setOnClickListener(v -> {
if (_prefs.isPasswordReminderNeeded()) {
Dialogs.showSecureDialog(new AlertDialog.Builder(this)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this)
.setTitle(getString(R.string.password_reminder_dialog_title))
.setMessage(getString(R.string.password_reminder_dialog_message))
.setCancelable(false)
Expand All @@ -183,11 +181,6 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
outState.putBoolean("inhibitBioPrompt", _inhibitBioPrompt);
}

@Override
protected void onSetTheme() {
setTheme(ThemeMap.NO_ACTION_BAR);
}

private void selectPassword() {
_textPassword.selectAll();

Expand Down Expand Up @@ -240,9 +233,6 @@ private void showPasswordReminder() {
PopupWindow popup = new PopupWindow(popupLayout, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
popup.setFocusable(false);
popup.setOutsideTouchable(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
popup.setElevation(5.0f);
}
_textPassword.post(() -> {
if (isFinishing()) {
return;
Expand Down Expand Up @@ -302,7 +292,7 @@ private void finish(MasterKey key, boolean isSlotRepaired) {
}

private void onInvalidPassword() {
Dialogs.showSecureDialog(new AlertDialog.Builder(AuthActivity.this)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(AuthActivity.this)
.setTitle(getString(R.string.unlock_vault_error))
.setMessage(getString(R.string.unlock_vault_error_description))
.setCancelable(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;

Expand Down Expand Up @@ -483,7 +484,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
} else if (itemId == R.id.action_edit_icon) {
startIconSelection();
} else if (itemId == R.id.action_reset_usage_count) {
Dialogs.showSecureDialog(new AlertDialog.Builder(this)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this)
.setTitle(R.string.action_reset_usage_count)
.setMessage(R.string.action_reset_usage_count_dialog)
.setPositiveButton(android.R.string.yes, (dialog, which) -> resetUsageCount())
Expand Down Expand Up @@ -769,7 +770,7 @@ private VaultEntry parseEntry() throws ParseException {
}

private void onSaveError(String msg) {
Dialogs.showSecureDialog(new AlertDialog.Builder(this)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this)
.setTitle(getString(R.string.saving_profile_error))
.setMessage(msg)
.setPositiveButton(android.R.string.ok, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
import com.beemdevelopment.aegis.ui.views.GroupAdapter;
import com.beemdevelopment.aegis.vault.VaultGroup;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -84,7 +84,7 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {

@Override
public void onRemoveGroup(VaultGroup group) {
Dialogs.showSecureDialog(new AlertDialog.Builder(this)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this)
.setTitle(R.string.remove_group)
.setMessage(R.string.remove_group_description)
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
Expand All @@ -98,7 +98,7 @@ public void onRemoveGroup(VaultGroup group) {
}

public void onRemoveUnusedGroups() {
Dialogs.showSecureDialog(new AlertDialog.Builder(this)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this)
.setTitle(R.string.remove_unused_groups)
.setMessage(R.string.remove_unused_groups_description)
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

Expand All @@ -28,6 +27,7 @@
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.vault.VaultGroup;
import com.beemdevelopment.aegis.vault.VaultRepository;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

Expand Down Expand Up @@ -101,7 +101,7 @@ private void startImport(DatabaseImporter.Definition importerDef, @Nullable File
if (importer.isInstalledAppVersionSupported()) {
startImportApp(importer);
} else {
Dialogs.showSecureDialog(new AlertDialog.Builder(this)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this)
.setTitle(R.string.warning)
.setMessage(getString(R.string.app_version_error, importerDef.getName()))
.setCancelable(false)
Expand Down Expand Up @@ -296,7 +296,7 @@ private void saveAndFinish(boolean wipeEntries) {

assignIconIntent.putExtra("entries", assignIconEntriesIds);

Dialogs.showSecureDialog(new AlertDialog.Builder(this)
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this)
.setTitle(R.string.import_assign_icons_dialog_title)
.setMessage(R.string.import_assign_icons_dialog_text)
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
Expand Down
Loading

0 comments on commit a7bc5a9

Please sign in to comment.