Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements to the entry sharing activity #1510

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
import android.os.Build;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.ColorInt;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.Theme;
Expand All @@ -27,14 +28,16 @@
import com.beemdevelopment.aegis.otp.GoogleAuthInfoException;
import com.beemdevelopment.aegis.otp.Transferable;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
import com.google.android.material.color.MaterialColors;
import com.google.android.material.imageview.ShapeableImageView;
import com.google.zxing.WriterException;

import java.util.ArrayList;
import java.util.List;

public class TransferEntriesActivity extends AegisActivity {
private List<Transferable> _authInfos;
private ImageView _qrImage;
private ShapeableImageView _qrImage;
private TextView _description;
private TextView _issuer;
private TextView _accountName;
Expand Down Expand Up @@ -62,7 +65,7 @@ protected void onCreate(Bundle savedInstanceState) {
_previousButton = findViewById(R.id.btnPrevious);
_copyButton = findViewById(R.id.btnCopyClipboard);

if (getSupportActionBar() != null){
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
Expand All @@ -88,7 +91,7 @@ protected void onCreate(Bundle savedInstanceState) {
});

_previousButton.setOnClickListener(v -> {
if (_currentEntryCount > 1 ) {
if (_currentEntryCount > 1) {
_nextButton.setText(R.string.next);
_currentEntryCount--;
generateQR();
Expand Down Expand Up @@ -116,14 +119,39 @@ protected void onCreate(Bundle savedInstanceState) {
if (clipboard != null) {
clipboard.setPrimaryClip(clip);
}
Toast.makeText(this,R.string.uri_copied_to_clipboard, Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.uri_copied_to_clipboard, Toast.LENGTH_SHORT).show();

} catch (GoogleAuthInfoException e) {
Dialogs.showErrorDialog(this, R.string.unable_to_copy_uri_to_clipboard, e);
}
});

generateQR();
// Calculate sensible dimensions for the QR code depending on whether we're in landscape
_qrImage.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
ConstraintLayout layout = findViewById(R.id.layoutShareEntry);
if (layout.getWidth() > layout.getHeight()) {
int squareSize = (int) (0.5 * layout.getHeight());
ViewGroup.LayoutParams params = _qrImage.getLayoutParams();
params.width = squareSize;
params.height = squareSize;
_qrImage.setLayoutParams(params);
}

generateQR();

_qrImage.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
}

@Override
public void onAttachedToWindow() {
// Max brightness to make the QR codes easier to scan
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.screenBrightness = 1.0f;
getWindow().setAttributes(attrs);
}

@Override
Expand Down Expand Up @@ -151,16 +179,13 @@ private void generateQR() {

_entriesCount.setText(getResources().getQuantityString(R.plurals.qr_count, _authInfos.size(), _currentEntryCount, _authInfos.size()));

@ColorInt int backgroundColor = Color.WHITE;
if (_themeHelper.getConfiguredTheme() == Theme.LIGHT) {
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(androidx.appcompat.R.attr.background, typedValue, true);
backgroundColor = typedValue.data;
}
int backgroundColor = _themeHelper.getConfiguredTheme() == Theme.LIGHT
? MaterialColors.getColor(_qrImage, com.google.android.material.R.attr.colorSurfaceContainer)
: Color.WHITE;

Bitmap bitmap;
try {
bitmap = QrCodeHelper.encodeToBitmap(selectedEntry.getUri().toString(), 512, 512, backgroundColor);
bitmap = QrCodeHelper.encodeToBitmap(selectedEntry.getUri().toString(), _qrImage.getWidth(), _qrImage.getWidth(), backgroundColor);
} catch (WriterException | GoogleAuthInfoException e) {
Dialogs.showErrorDialog(this, R.string.unable_to_generate_qrcode, e);
return;
Expand Down
44 changes: 18 additions & 26 deletions app/src/main/res/layout/activity_share_entry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,40 @@
</com.google.android.material.appbar.AppBarLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutShareEntry"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/ivQrCode"
android:layout_width="250dp"
android:layout_height="250dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tvTransfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/transfer_entry"
android:textSize="22sp"
android:textStyle="bold"
android:layout_marginBottom="5dp"
app:layout_constraintBottom_toTopOf="@+id/tvDescription"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
android:layout_height="match_parent"
android:paddingHorizontal="30dp"
android:layout_marginTop="?attr/actionBarSize">

<TextView
android:id="@+id/tvDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="@string/transfer_entry_description"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/ivQrCode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivQrCode"
android:layout_width="0dp"
android:layout_height="0dp"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Rounded"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintVertical_bias="0.3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />

<TextView
android:id="@+id/tvIssuer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginTop="20dp"
tools:text="Issuer"
android:textSize="18sp"
android:textStyle="bold"
Expand Down Expand Up @@ -95,7 +89,6 @@
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_marginBottom="4dp"
style="@style/Widget.Material3.Button.TextButton"
android:text="@string/next"
Expand Down Expand Up @@ -123,7 +116,6 @@
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/btnNext"
app:layout_constraintHorizontal_bias="0.506"
app:layout_constraintStart_toStartOf="@+id/btnPrevious" />

</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ar-rSA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@
<string name="copy_uri">نسخ URI</string>
<string name="unable_to_copy_uri_to_clipboard">تعذر نسخ URI إلى الحافظة</string>
<string name="uri_copied_to_clipboard">نُسخ URI إلى الحافظة</string>
<string name="transfer_entry">نقل المدخل</string>
<string name="transfer_entry_description">امسح كود QR هذا بتطبيق المصادقة الذي ترغب بنقل ذلك المدخل إليه</string>
<string name="google_auth_compatible_transfer_description">امسح رموز ال QR هذه بواسطة Aegis أو Google Authenticator.\n\nبسبب القيود في تطبيق Google Authenticator، فقط رموز TOTP &amp; HOTP التي تستعمل SHA1 وتنتِج كود من 6 خانات هي من سيتم إدراجها</string>
<string name="password_strength_very_weak">ضعيف جدًا</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ast-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@
<string name="previous">Anterior</string>
<string name="unable_to_copy_uri_to_clipboard">Nun ye posible copiar la URI al cartafueyu</string>
<string name="uri_copied_to_clipboard">La URI copióse al cartafueyu</string>
<string name="transfer_entry">Tresferencia d\'una entrada</string>
<string name="transfer_entry_description">Escania esti códígu QR cola aplicación autenticadora a la que quies tresferir esta entrada</string>
<string name="google_auth_compatible_transfer_description">Escania estos códigos QR con Aegis o con Google Authenticator.\n\nPola mor de les llendes de l\'aplicación Google Authenticator, namás s\'inclúin pases TOTP ya HOTP qu\'usen el hash SHA1 ya produzan códigos de 6 díxitos</string>
<string name="password_strength_very_weak">Perpoco segura</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-bg-rBG/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@
<string name="copy_uri">Копиране на адреса</string>
<string name="unable_to_copy_uri_to_clipboard">Грешка при копиране на адреса</string>
<string name="uri_copied_to_clipboard">Адресът е копиран</string>
<string name="transfer_entry">Прехвърляне на запис</string>
<string name="transfer_entry_description">Сканирайте QR кода с приложението за удостоверяване, в което искате да прехвърлите този запис</string>
<string name="google_auth_compatible_transfer_description">Сканирайте тези кодове в Aegis или Google Authenticator.\n\nПоради ограничения в приложението на Google Authenticator са включени само кодовете, които използват SHA1 и извеждат 6 цифри</string>
<string name="password_strength_very_weak">Много слаба</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ca-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@
<string name="copy_uri">Copiar URI</string>
<string name="unable_to_copy_uri_to_clipboard">No s\'ha pogut copiar la URI</string>
<string name="uri_copied_to_clipboard">URI copiada al porta-retalls</string>
<string name="transfer_entry">Transferir entrada</string>
<string name="transfer_entry_description">Escaneja aquest codi QR amb l\'aplicació d\'autenticació a la que vols transferir aquesta entrada</string>
<string name="google_auth_compatible_transfer_description">Escanegeu aquests codis QR amb Aegis o Google Authenticator.\n\n A causa de les limitacions de l\'aplicació Google Authenticator, només s\'inclouen tokens TOTP &amp; HOTP que utilitzen SHA1 i produeixen codis de 6 dígits</string>
<string name="password_strength_very_weak">Molt feble</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@
<string name="copy_uri">Kopírovat URI</string>
<string name="unable_to_copy_uri_to_clipboard">Nepodařilo se zkopírovat URI do schránky</string>
<string name="uri_copied_to_clipboard">URI zkopírována do schránky</string>
<string name="transfer_entry">Přenést položku</string>
<string name="transfer_entry_description">Naskenujte tento QR kód ověřovací aplikací, do které chcete položku přenést</string>
<string name="google_auth_compatible_transfer_description">Naskenujte tyto QR kódy s aplikací Aegis nebo Google Authenticator.\n\nKvůli limitacím aplikace Google Authenticator jsou zahrnuty pouze 6-místné tokeny TOTP a HOTP využívající SHA1</string>
<string name="password_strength_very_weak">Velmi slabé</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-da-rDK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@
<string name="copy_uri">Kopiér URI</string>
<string name="unable_to_copy_uri_to_clipboard">Kunne ikke kopiere URI til udklipsholder</string>
<string name="uri_copied_to_clipboard">URI kopieret til udklipsholder</string>
<string name="transfer_entry">Overfør post</string>
<string name="transfer_entry_description">Scan denne QR-kode med den autentificerings-app, du gerne vil overføre denne post til</string>
<string name="google_auth_compatible_transfer_description">Skan disse QR-koder med Aegis eller Google Authenticator.\n\nGrundet begrænsninger i Google Authenticator-appen inkluderes kun TOTP- og HOTP-tokener, som bruger SHA1 og genererer 6-cifrede koder</string>
<string name="password_strength_very_weak">Meget svag</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@
<string name="copy_uri">URI kopieren</string>
<string name="unable_to_copy_uri_to_clipboard">URI konnte nicht in die Zwischenablage kopiert werden</string>
<string name="uri_copied_to_clipboard">URI in die Zwischenablage kopiert</string>
<string name="transfer_entry">Eintrag übertragen</string>
<string name="transfer_entry_description">Scanne diesen QR-Code mit der Authentifizierungs-App, zu der du diesen Eintrag übertragen möchtest</string>
<string name="google_auth_compatible_transfer_description">Scanne diese QR-Codes mit Aegis oder Google Authenticator.\n\nAufgrund der Einschränkungen der Google Authenticator-App sind nur TOTP- und HOTP-Token enthalten, die SHA1 verwenden und 6-stellige Codes erzeugen</string>
<string name="password_strength_very_weak">Sehr schwach</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-el-rGR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@
<string name="copy_uri">Αντιγραφή URI</string>
<string name="unable_to_copy_uri_to_clipboard">Αδυναμία αντιγραφής του URI στο πρόχειρο</string>
<string name="uri_copied_to_clipboard">Το URI αντιγράφηκε στο πρόχειρο</string>
<string name="transfer_entry">Μεταφορά καταχώρησης</string>
<string name="transfer_entry_description">Σαρώστε αυτόν τον κωδικό QR με την εφαρμογή ελέγχου ταυτότητας στην οποία θέλετε να μεταφέρετε αυτήν την καταχώριση</string>
<string name="google_auth_compatible_transfer_description">Σαρώστε αυτούς τους κωδικούς QR με το Aegis ή το Google Authenticator.\n\nΛόγω περιορισμών της εφαρμογής Google Authenticator, περιλαμβάνονται μόνο αναγνωριστικά TOTP &amp; HOTP που χρησιμοποιούν SHA1 και παράγουν 6ψήφιους κωδικούς</string>
<string name="password_strength_very_weak">Πολύ αδύναμος</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@
<string name="copy_uri">Copiar URI</string>
<string name="unable_to_copy_uri_to_clipboard">No se puede copiar el URI al portapapeles</string>
<string name="uri_copied_to_clipboard">Se ha copiado el URI al portapapeles</string>
<string name="transfer_entry">Transferir clave</string>
<string name="transfer_entry_description">Escanea este código QR con la aplicación de autenticación a la que vayas a importar esta clave</string>
<string name="google_auth_compatible_transfer_description">Escanea estos códigos QR con Aegis o Google Authenticator.\n\nDebido a limitaciones técnicas de Google Authenticator solo se incluirán claves de tipo TOTP y HOTP que usen SHA1 y produzcan códigos de 6 dígitos</string>
<string name="password_strength_very_weak">Muy débil</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-eu-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@
<string name="copy_uri">Kopiatu URIa</string>
<string name="unable_to_copy_uri_to_clipboard">Ezin da URIa arbelean kopiatu</string>
<string name="uri_copied_to_clipboard">URIa arbelean kopiatu da</string>
<string name="transfer_entry">Transferitu sarrera</string>
<string name="transfer_entry_description">Eskaneatu QR kode hau sarrera transferitu nahi diozun aitentifikazio-aplikazioarekin</string>
<string name="google_auth_compatible_transfer_description">Eskaneatu QR kode hauek Aegis edo Google Authenticator erabiliz.\n\nGoogle Authenticator aplikazioaren mugak direla eta, SHA1 darabilten eta 6 zenbakiko kodeak erabiltzen dituzten TOTP &amp; HOTP tokenak bakarrik sartzen dira</string>
<string name="password_strength_very_weak">Oso ahula</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fa-rIR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@
<string name="done">انجام شد</string>
<string name="next">بعدی</string>
<string name="previous">قبلی</string>
<string name="transfer_entry">انتقال آیتم‌ها</string>
<string name="transfer_entry_description">این بارکد دوبعدی را توسط برنامه ای که علاقه دارید توکن منتقل شود اسکن کنید.</string>
<string name="password_strength_very_weak">خیلی ضعیف</string>
<string name="password_strength_weak">ضعیف</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fi-rFI/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@
<string name="copy_uri">Kopioi URI</string>
<string name="unable_to_copy_uri_to_clipboard">URI:a ei voitu kopioida leikepöydälle</string>
<string name="uri_copied_to_clipboard">URI kopioitiin leikepöydälle</string>
<string name="transfer_entry">Siirrä kohde</string>
<string name="transfer_entry_description">Skannaa tämä QR-koodi todennussovelluksella, johon haluat siirtää tämän kohteen</string>
<string name="google_auth_compatible_transfer_description">Skannaa nämä QR-koodit Aegisilla tai Google Authenticatorilla.\n\nGoogle Authenticator -sovelluksen rajoitusten vuoksi, vain SHA1-suojausta ja 6-numeroisia koodeja tuottavat TOTP- ja HOTP-todennuskoodit sisällytetään</string>
<string name="password_strength_very_weak">Erittäin heikko</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fr-rFR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@
<string name="copy_uri">Copier l\'URI</string>
<string name="unable_to_copy_uri_to_clipboard">Impossible de copier l\'URI dans le presse-papier</string>
<string name="uri_copied_to_clipboard">URI copiée dans le presse-papier</string>
<string name="transfer_entry">Transférer une entrée</string>
<string name="transfer_entry_description">Scannez ce code QR avec l\'application d\'authentification vers laquelle vous souhaitez transférer cette entrée</string>
<string name="google_auth_compatible_transfer_description">Scannez ces codes QR avec Aegis ou Google Authenticator.\n\nEn raison des limitations de l\'application Google Authenticator, seuls les jetons TOTP &amp; HOTP qui utilisent SHA1 et produisent des codes à 6 chiffres sont inclus</string>
<string name="password_strength_very_weak">Très faible</string>
Expand Down
Loading