mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-21 22:39:12 +00:00
Fix the QR code background color for the light theme
This commit is contained in:
parent
e319a2eceb
commit
80bf5bc854
1 changed files with 13 additions and 2 deletions
|
@ -4,13 +4,17 @@ import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorInt;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.R;
|
import com.beemdevelopment.aegis.R;
|
||||||
|
import com.beemdevelopment.aegis.Theme;
|
||||||
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
||||||
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
|
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
|
||||||
import com.beemdevelopment.aegis.vault.VaultManager;
|
import com.beemdevelopment.aegis.vault.VaultManager;
|
||||||
|
@ -109,7 +113,7 @@ public class TransferEntriesActivity extends AegisActivity {
|
||||||
_entriesCount.setText(getResources().getQuantityString(R.plurals.entries_count, _authInfos.size(), _currentEntryCount, _authInfos.size()));
|
_entriesCount.setText(getResources().getQuantityString(R.plurals.entries_count, _authInfos.size(), _currentEntryCount, _authInfos.size()));
|
||||||
|
|
||||||
QRCodeWriter writer = new QRCodeWriter();
|
QRCodeWriter writer = new QRCodeWriter();
|
||||||
BitMatrix bitMatrix = null;
|
BitMatrix bitMatrix;
|
||||||
try {
|
try {
|
||||||
bitMatrix = writer.encode(selectedEntry.getUri().toString(), BarcodeFormat.QR_CODE, 512, 512);
|
bitMatrix = writer.encode(selectedEntry.getUri().toString(), BarcodeFormat.QR_CODE, 512, 512);
|
||||||
} catch (WriterException e) {
|
} catch (WriterException e) {
|
||||||
|
@ -117,13 +121,20 @@ public class TransferEntriesActivity extends AegisActivity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ColorInt int backgroundColor = Color.WHITE;
|
||||||
|
if (getConfiguredTheme() == Theme.LIGHT) {
|
||||||
|
TypedValue typedValue = new TypedValue();
|
||||||
|
getTheme().resolveAttribute(R.attr.background, typedValue, true);
|
||||||
|
backgroundColor = typedValue.data;
|
||||||
|
}
|
||||||
|
|
||||||
int width = bitMatrix.getWidth();
|
int width = bitMatrix.getWidth();
|
||||||
int height = bitMatrix.getHeight();
|
int height = bitMatrix.getHeight();
|
||||||
int[] pixels = new int[width * height];
|
int[] pixels = new int[width * height];
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
int offset = y * width;
|
int offset = y * width;
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
pixels[offset + x] = bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE;
|
pixels[offset + x] = bitMatrix.get(x, y) ? Color.BLACK : backgroundColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue