This commit is contained in:
Michael Schättgen 2025-02-25 21:53:32 +00:00 committed by GitHub
commit f30b13c14c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 19 deletions

View file

@ -10,6 +10,7 @@ import android.graphics.Color;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import android.provider.Settings;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -47,6 +48,8 @@ public class TransferEntriesActivity extends AegisActivity {
private Button _previousButton; private Button _previousButton;
private Button _copyButton; private Button _copyButton;
private int _currentEntryCount = 1; private int _currentEntryCount = 1;
private float _deviceBrightness;
private boolean isMaxBrightnessSet = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -146,14 +149,35 @@ public class TransferEntriesActivity extends AegisActivity {
_qrImage.getViewTreeObserver().removeOnGlobalLayoutListener(this); _qrImage.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} }
}); });
_deviceBrightness = getSystemBrightness();
_qrImage.setOnClickListener(v -> {
if (!isMaxBrightnessSet) {
setBrightness(1f);
isMaxBrightnessSet = true;
} else {
setBrightness(_deviceBrightness);
isMaxBrightnessSet = false;
}
});
} }
@Override private float getSystemBrightness() {
public void onAttachedToWindow() { int brightness = 0;
// Max brightness to make the QR codes easier to scan try {
brightness = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return brightness / 255f;
}
private void setBrightness(float brightnessAmount) {
WindowManager.LayoutParams attrs = getWindow().getAttributes(); WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.screenBrightness = 1.0f; attrs.screenBrightness = brightnessAmount;
getWindow().setAttributes(attrs); getWindow().setAttributes(attrs);
getSystemBrightness();
} }
@Override @Override

View file

@ -25,8 +25,8 @@
android:id="@+id/layoutShareEntry" android:id="@+id/layoutShareEntry"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingHorizontal="30dp" android:layout_marginTop="?attr/actionBarSize"
android:layout_marginTop="?attr/actionBarSize"> android:paddingHorizontal="30dp">
<TextView <TextView
android:id="@+id/tvDescription" android:id="@+id/tvDescription"
@ -34,44 +34,44 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="@string/transfer_entry_description" android:text="@string/transfer_entry_description"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/ivQrCode" app:layout_constraintBottom_toTopOf="@+id/ivQrCode"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.imageview.ShapeableImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivQrCode" android:id="@+id/ivQrCode"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Rounded" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1" app:layout_constraintDimensionRatio="1:1"
app:layout_constraintVertical_bias="0.3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" /> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Rounded" />
<TextView <TextView
android:id="@+id/tvIssuer" android:id="@+id/tvIssuer"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
tools:text="Issuer"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ivQrCode" /> app:layout_constraintTop_toBottomOf="@+id/ivQrCode"
tools:text="Issuer" />
<TextView <TextView
android:id="@+id/tvAccountName" android:id="@+id/tvAccountName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
tools:text="Accountname"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvIssuer" /> app:layout_constraintTop_toBottomOf="@+id/tvIssuer"
tools:text="Accountname" />
<Button <Button
android:id="@+id/btnCopyClipboard" android:id="@+id/btnCopyClipboard"
@ -80,17 +80,19 @@
android:text="@string/copy_uri" android:text="@string/copy_uri"
android:textAllCaps="false" android:textAllCaps="false"
android:visibility="invisible" android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@id/tvEntriesCount"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAccountName" app:layout_constraintTop_toBottomOf="@id/tvAccountName"
app:layout_constraintBottom_toTopOf="@id/tvEntriesCount" /> app:layout_constraintVertical_bias="0.134" />
<Button <Button
android:id="@+id/btnNext" android:id="@+id/btnNext"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
style="@style/Widget.Material3.Button.TextButton"
android:text="@string/next" android:text="@string/next"
android:textAllCaps="false" android:textAllCaps="false"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@ -98,11 +100,11 @@
<Button <Button
android:id="@+id/btnPrevious" android:id="@+id/btnPrevious"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
style="@style/Widget.Material3.Button.TextButton"
android:text="@string/previous" android:text="@string/previous"
android:textAllCaps="false" android:textAllCaps="false"
android:visibility="invisible" android:visibility="invisible"
@ -118,6 +120,16 @@
app:layout_constraintEnd_toEndOf="@+id/btnNext" app:layout_constraintEnd_toEndOf="@+id/btnNext"
app:layout_constraintStart_toStartOf="@+id/btnPrevious" /> app:layout_constraintStart_toStartOf="@+id/btnPrevious" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/transfer_entry_brightness"
app:layout_constraintBottom_toTopOf="@+id/tvEntriesCount"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnCopyClipboard" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -497,6 +497,7 @@
<string name="unable_to_copy_uri_to_clipboard">Unable to copy URI to clipboard</string> <string name="unable_to_copy_uri_to_clipboard">Unable to copy URI to clipboard</string>
<string name="uri_copied_to_clipboard">URI copied to clipboard</string> <string name="uri_copied_to_clipboard">URI copied to clipboard</string>
<string name="transfer_entry_description">Scan this QR code with the authenticator app you would like to transfer this entry to</string> <string name="transfer_entry_description">Scan this QR code with the authenticator app you would like to transfer this entry to</string>
<string name="transfer_entry_brightness">Tap the QR code to toggle full screen brightness</string>
<string name="google_auth_compatible_transfer_description">Scan these QR codes with Aegis or Google Authenticator.\n\nDue to limitations of the Google Authenticator app, only TOTP &amp; HOTP tokens that use SHA1 and produce 6-digit codes are included</string> <string name="google_auth_compatible_transfer_description">Scan these QR codes with Aegis or Google Authenticator.\n\nDue to limitations of the Google Authenticator app, only TOTP &amp; HOTP tokens that use SHA1 and produce 6-digit codes are included</string>
<string name="password_strength_very_weak">Very weak</string> <string name="password_strength_very_weak">Very weak</string>