Merge branch 'master' into feature/pkpass

This commit is contained in:
Sylvia van Os
2020-02-21 15:33:12 +01:00
committed by GitHub
9 changed files with 254 additions and 80 deletions

View File

@@ -1,3 +1,10 @@
## v0.27 (2020-01-26)
Changes:
- Tapping on a barcode now moves it to the top of the screen ([#348](https://github.com/brarcher/loyalty-card-locker/pull/348))
- Add white space around barcodes to improve scanning in dark mode ([#328](https://github.com/brarcher/loyalty-card-locker/issues/328))
- Fix swapped import buttons. ([#346](https://github.com/brarcher/loyalty-card-locker/pull/346))
## v0.26.1 (2020-01-09)
Changes:

View File

@@ -13,8 +13,8 @@ android {
applicationId "protect.card_locker"
minSdkVersion 16
targetSdkVersion 29
versionCode 37
versionName "0.26.1"
versionCode 38
versionName "0.27"
}
buildTypes {
release {

View File

@@ -81,36 +81,14 @@ public class ImportExportActivity extends AppCompatActivity
}
});
// Check that there is an activity that can bring up a file chooser
final Intent intentPickAction = new Intent(Intent.ACTION_PICK);
Button importFilesystem = findViewById(R.id.importOptionFilesystemButton);
importFilesystem.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
chooseFileWithIntent(intentPickAction);
}
});
if(isCallable(getApplicationContext(), intentPickAction) == false)
{
findViewById(R.id.dividerImportFilesystem).setVisibility(View.GONE);
findViewById(R.id.importOptionFilesystemTitle).setVisibility(View.GONE);
findViewById(R.id.importOptionFilesystemExplanation).setVisibility(View.GONE);
importFilesystem.setVisibility(View.GONE);
}
// Check that there is an application that can find content
// Check that there is a file manager available
final Intent intentGetContentAction = new Intent(Intent.ACTION_GET_CONTENT);
intentGetContentAction.addCategory(Intent.CATEGORY_OPENABLE);
intentGetContentAction.setType("*/*");
Button importApplication = findViewById(R.id.importOptionApplicationButton);
importApplication.setOnClickListener(new View.OnClickListener()
Button importFilesystem = findViewById(R.id.importOptionFilesystemButton);
importFilesystem.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
@@ -120,6 +98,27 @@ public class ImportExportActivity extends AppCompatActivity
});
if(isCallable(getApplicationContext(), intentGetContentAction) == false)
{
findViewById(R.id.dividerImportFilesystem).setVisibility(View.GONE);
findViewById(R.id.importOptionFilesystemTitle).setVisibility(View.GONE);
findViewById(R.id.importOptionFilesystemExplanation).setVisibility(View.GONE);
importFilesystem.setVisibility(View.GONE);
}
// Check that there is an app that data can be imported from
final Intent intentPickAction = new Intent(Intent.ACTION_PICK);
Button importApplication = findViewById(R.id.importOptionApplicationButton);
importApplication.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
chooseFileWithIntent(intentPickAction);
}
});
if(isCallable(getApplicationContext(), intentPickAction) == false)
{
findViewById(R.id.dividerImportApplication).setVisibility(View.GONE);
findViewById(R.id.importOptionApplicationTitle).setVisibility(View.GONE);
@@ -127,7 +126,6 @@ public class ImportExportActivity extends AppCompatActivity
importApplication.setVisibility(View.GONE);
}
// This option, to import from the fixed location, should always be present
Button importButton = findViewById(R.id.importOptionFixedButton);

View File

@@ -10,6 +10,7 @@ import android.os.Build;
import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.graphics.ColorUtils;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.widget.TextViewCompat;
@@ -22,6 +23,7 @@ import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
@@ -58,7 +60,12 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
ImportURIHelper importURIHelper;
Settings settings;
String cardIdString;
BarcodeFormat format;
boolean backgroundNeedsDarkIcons;
boolean barcodeIsFullscreen = false;
ViewGroup.LayoutParams barcodeImageState;
private void extractIntentFields(Intent intent)
{
@@ -113,6 +120,21 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
collapsingToolbarLayout = findViewById(R.id.collapsingToolbarLayout);
rotationEnabled = true;
// Allow making barcode fullscreen on tap
barcodeImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(barcodeIsFullscreen)
{
setFullscreen(false);
}
else
{
setFullscreen(true);
}
}
});
}
@Override
@@ -131,6 +153,15 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
Log.i(TAG, "To view card: " + loyaltyCardId);
if(barcodeIsFullscreen)
{
// Completely reset state
//
// This prevents the barcode from taking up the entire screen
// on resume and thus being stretched out of proportion.
recreate();
}
// The brightness value is on a scale from [0, ..., 1], where
// '1' is the brightest. We attempt to maximize the brightness
// to help barcode readers scan the barcode.
@@ -152,8 +183,8 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
}
String formatString = loyaltyCard.barcodeType;
final BarcodeFormat format = !formatString.isEmpty() ? BarcodeFormat.valueOf(formatString) : null;
final String cardIdString = loyaltyCard.cardId;
format = !formatString.isEmpty() ? BarcodeFormat.valueOf(formatString) : null;
cardIdString = loyaltyCard.cardId;
cardIdFieldView.setText(loyaltyCard.cardId);
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(cardIdFieldView,
@@ -253,6 +284,18 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
}
}
@Override
public void onBackPressed() {
if (barcodeIsFullscreen)
{
setFullscreen(false);
return;
}
super.onBackPressed();
return;
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
@@ -372,4 +415,72 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
})
.show();
}
/**
* When enabled, hides the status bar and moves the barcode to the top of the screen.
*
* The purpose of this function is to make sure the barcode can be scanned from the phone
* by machines which offer no space to insert the complete device.
*/
private void setFullscreen(boolean enable)
{
ActionBar actionBar = getSupportActionBar();
if(enable && !barcodeIsFullscreen)
{
// Save previous barcodeImage state
barcodeImageState = barcodeImage.getLayoutParams();
// Hide actionbar
if(actionBar != null)
{
actionBar.hide();
}
// Hide collapsingToolbar
collapsingToolbarLayout.setVisibility(View.GONE);
// Set Android to fullscreen mode
getWindow().getDecorView().setSystemUiVisibility(
getWindow().getDecorView().getSystemUiVisibility()
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN
);
// Make barcode take all space
barcodeImage.setLayoutParams(new ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT,
ConstraintLayout.LayoutParams.MATCH_PARENT
));
// Move barcode to top
barcodeImage.setScaleType(ImageView.ScaleType.FIT_START);
// Set current state
barcodeIsFullscreen = true;
}
else if(!enable && barcodeIsFullscreen)
{
// Show actionbar
if(actionBar != null)
{
actionBar.show();
}
// Show collapsingToolbar
collapsingToolbarLayout.setVisibility(View.VISIBLE);
// Unset fullscreen mode
getWindow().getDecorView().setSystemUiVisibility(
getWindow().getDecorView().getSystemUiVisibility()
& ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
& ~View.SYSTEM_UI_FLAG_FULLSCREEN
);
// Turn barcode back to normal
barcodeImage.setLayoutParams(barcodeImageState);
// Set current state
barcodeIsFullscreen = false;
}
}
}

View File

@@ -355,6 +355,8 @@
android:layout_width="0dp"
android:layout_height="@dimen/barcode_disp_height"
android:layout_gravity="center_horizontal"
android:padding="10.0dp"
android:background="#ffffff"
android:id="@+id/barcode"
android:contentDescription="@string/barcodeImageDescription"
android:layout_weight="1.0"/>

View File

@@ -35,6 +35,8 @@
android:layout_marginBottom="10.0dip"
android:layout_marginStart="15.0dip"
android:layout_marginEnd="15.0dip"
android:padding="10.0dp"
android:background="#ffffff"
app:layout_constraintBottom_toTopOf="@+id/centerGuideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@@ -1,19 +1,15 @@
<resources
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">Kundekortknippe</string>
<string name="action_add">Legg til</string>
<string name="noGiftCards">Du har ingen kundekort for øyeblikket. Klikk på \"+\" (pluss)-knappen øverst for å komme igang.\n\nDa har du dem alltid hendig.</string>
<string name="storeName">Butikk</string>
<string name="note">Merknad</string>
<string name="cardId">Kort-ID</string>
<string name="barcodeType">Strekkodetype</string>
<string name="cancel">Avbryt</string>
<string name="save">Lagre</string>
<string name="capture">Fang opp kort</string>
<string name="capture">Les inn kort</string>
<string name="enterCard">Skriv inn kort</string>
<string name="editCard">Rediger kort</string>
<string name="edit">Rediger</string>
@@ -25,25 +21,19 @@
<string name="deleteConfirmation">Bekreft at du ønsker å slette dette kortet.</string>
<string name="ok">OK</string>
<string name="copy_to_clipboard">Kopier ID til utklippstavle</string>
<string name="sendLabel">Send&#8230;</string>
<string name="sendLabel">Send</string>
<string name="addedShortcut">Lagt til på hjemmeskjerm</string>
<string name="editCardTitle">Rediger kundekort</string>
<string name="addCardTitle">Legg til kundekort</string>
<string name="viewCardTitle">Vis kundekort</string>
<string name="scanCardBarcode">Skann kortets strekkode</string>
<string name="cardShortcut">Kort-snarvei</string>
<string name="noCardsMessage">Legg til et kort først</string>
<string name="barcodeImageDescription">Bilde av kortets strekkode</string>
<string name="noStoreError">Ingen butikk angitt</string>
<string name="noCardIdError">Ingen kort-ID innskrevet</string>
<string name="noCardExistsError">Kunne ikke finne kundekort</string>
<string name="cardIdFormat">%1$s: %2$s</string>
<string name="storeNameAndNoteFormat" translatable="false">%1$s - %2$s</string>
<string name="importExport">Import/eksport</string>
<string name="importName">Importer</string>
<string name="exportName">Eksporter</string>
@@ -57,9 +47,9 @@
<string name="exportSuccessfulTitle">Eksportert</string>
<string name="exportFailedTitle">Kunne ikke eksportere</string>
<string name="exportFailed">Klarte ikke å eksportere: %1$s</string>
<string name="importing">Importerer&#8230;</string>
<string name="exporting">Exporterer&#8230;</string>
<string name="noExternalStoragePermissionError">Kunne ikke importere eller eksportere kort uten tilgang til ekstern lagring.</string>
<string name="importing">Importerer</string>
<string name="exporting">Exporterer</string>
<string name="noExternalStoragePermissionError">Kan ikke importere eller eksportere kort uten tilgang til ekstern lagring</string>
<string name="exportOptionExplanation">Data skrives til rotmappen i eksternt lagringsområde.</string>
<string name="importOptionFilesystemTitle">Importer fra filsystem</string>
<string name="importOptionFilesystemExplanation">Velg spesifikk fil fra filsystemet.</string>
@@ -70,57 +60,57 @@
<string name="importOptionFixedTitle">Importer fra eksporteringsområde</string>
<string name="importOptionFixedExplanation">Importer fra området i filsystemet eksporter skrives til.</string>
<string name="importOptionFixedButton">Bruk eksporteringsplassering</string>
<string name="about">About</string>
<string name="app_copyright_fmt">Copyright 2016-<xliff:g>%d</xliff:g> Branden Archer</string>
<string name="about">Om</string>
<string name="app_copyright_fmt">Kopirett 2016-<xliff:g>%d</xliff:g> Branden Archer</string>
<string name="app_license">Lisensiert GPLv3+.</string>
<string name="about_title_fmt">Om <xliff:g id="app_name">%s</xliff:g></string>
<string name="debug_version_fmt">Versjon: <xliff:g id="version">%s</xliff:g></string>
<string name="app_revision_fmt">Slippinformasjon: <xliff:g id="app_revision_url">%s</xliff:g></string>
<string name="app_libraries"><xliff:g id="app_name">%s</xliff:g> brukfer følgende tredjepartsbibliotek: <xliff:g id="app_libraries_list">%s</xliff:g></string>
<string name="app_resources"><xliff:g id="app_name">%s</xliff:g> bruker følgende tredjepartsressurser: <xliff:g id="app_resources_list">%s</xliff:g></string>
<string name="about_title_fmt">Om <xliff:g id="app_name">%s</xliff:g>
</string>
<string name="debug_version_fmt">Versjon: <xliff:g id="version">%s</xliff:g>
</string>
<string name="app_revision_fmt">Utgivelsesinfo: <xliff:g id="app_revision_url">%s</xliff:g></string>
<string name="app_libraries">
<xliff:g id="app_name">%s</xliff:g> brukfer følgende tredjepartsbibliotek: <xliff:g id="app_libraries_list">%s</xliff:g>
</string>
<string name="app_resources">
<xliff:g id="app_name">%s</xliff:g> bruker følgende tredjepartsressurser: <xliff:g id="app_resources_list">%s</xliff:g>
</string>
<string name="selectBarcodeTitle">Velg strekkode</string>
<string name="enterBarcodeInstructions">Skriv inn strekkodeverdien og velg så bildet som representerer strekkoden du ønsker å bruke.</string>
<string name="copy_to_clipboard_toast">Kort-ID kopiert til utklippstavle</string>
<string name="thumbnailDescription">Miniatyrbilde for kort</string>
<string name="startIntro">Start intro</string>
<string name="intro1Title">Velkommen til Kundekortknippe\n</string>
<string name="intro1Description">Håndter strekkodekodekundekort på din enhet.\n\n</string>
<string name="intro2Title">Tillegg av kort\n</string>
<string name="intro2Description">Legg til et nytt kort ved å trykke på pluss-tegnet i kortlisten.\n\n</string>
<string name="intro2Description">Legg til et nytt kort ved å trykke på + i kortlisten.
\n
\n</string>
<string name="intro3Title">Tillegg av kort\n</string>
<string name="intro3Description">For å legge til en strekkode, ta bilde av den med kamera, eller skriv den inn manuelt.\n\n</string>
<string name="intro3Description">Legg til strekkoder med kamera eller skriv dem inn manuelt.
\n
\n</string>
<string name="intro4Title">Vis kort\n</string>
<string name="intro4Description">For å vise et kort, klikk på butikknavnet fra hovedskjermen\n\n</string>
<string name="intro5Title">Sikkerhetskopi\n</string>
<string name="intro5Description">Kortene kan sikkerhetskopieres. For å eksportere eller importere kortdata, trykk på \"Importer/eksporter\" i menyen på hovedsiden.\n\n</string>
<string name="intro5Description">Kortene kan sikkerhetskopieres. For å eksportere eller importere kortdata, trykk på \"Importer/eksporter\" i hovedsidemenyen.
\n
\n</string>
<string name="intro6Title">Tilbakemeldinger\n</string>
<string name="intro6Description">Dette programmet er reklamefri og gratis fri programvare. Se flere detaljer ved å trykke på \"Om\"-skjermen på hovedsiden.\n\nLevn en vurdering i programbutikken. (:</string>
<string name="intro6Description">Dette programmet er reklamefri og gratis genenslig fri programvare. Se flere detaljer ved å trykke på \"Om\"-skjermen på hovedsiden.
\n
\nLevn en vurdering i programbutikken. (:</string>
<string name="change">Endre</string>
<string name="storeTextColorTitle">Butikktekstfarge</string>
<string name="storeTextColorTitle">Skriftstørrelse for butikktekst</string>
<string name="storeTextBackgroundColorTitle">Overskriftsfarge</string>
<string name="storeNameBackgroundColorDescription">Farge for butikktekstbakgrunn</string>
<string name="storeNameColorDescription">Butikktekstfarge</string>
<string name="settings">Innstillinger</string>
<string name="settings_category_title_ui">Brukergrensesnitt</string>
<string name="settings_card_title_list_font_size">Korttittelskriftstørrelse</string>
<string name="settings_key_card_title_list_font_size" translatable="false">pref_card_title_list_font_size_sp</string>
<string name="settings_card_note_list_font_size">Kortmerknadsskriftstørrelse</string>
<string name="settings_key_card_note_list_font_size" translatable="false">pref_card_note_list_font_size_sp</string>
<string name="settings_card_title_font_size">Korttittelskriftstørrelse</string>
<string name="settings_key_card_title_font_size" translatable="false">pref_card_title_font_size_sp</string>
<string name="settings_card_id_font_size">Kort-ID-skriftstørrelse</string>
<string name="settings_key_card_id_font_size" translatable="false">pref_card_id_font_size_sp</string>
<string name="settings_card_note_font_size">Kortmerknadsskriftstørrelse</string>
<string name="settings_key_card_note_font_size" translatable="false">pref_card_note_font_size_sp</string>
<string name="settings_card_note_list_font_size">Skriftstørrelse for kortmerknadsliste</string>
<string name="settings_card_title_font_size">Skriftstørrelse for korttittel</string>
<string name="settings_card_id_font_size">Skriftstørrelse for kort-ID</string>
<string name="settings_card_note_font_size">Skriftstørrelse for kortmerknad</string>
<string name="settings_display_barcode_max_brightness">Lysere strekkodevisning</string>
<string name="settings_key_display_barcode_max_brightness" translatable="false">pref_display_card_max_brightness</string>
<string name="settings_lock_barcode_orientation">Lås strekkodesideretning</string>
<string name="settings_key_lock_barcode_orientation" translatable="false">pref_lock_barcode_orientation</string>
</resources>

View File

@@ -71,7 +71,7 @@ public class ImportExportActivityTest
if(isInstalled)
{
registerIntentHandler(Intent.ACTION_PICK);
registerIntentHandler(Intent.ACTION_GET_CONTENT);
}
Activity activity = Robolectric.setupActivity(ImportExportActivity.class);
@@ -102,7 +102,7 @@ public class ImportExportActivityTest
if(isInstalled)
{
registerIntentHandler(Intent.ACTION_GET_CONTENT);
registerIntentHandler(Intent.ACTION_PICK);
}
Activity activity = Robolectric.setupActivity(ImportExportActivity.class);

View File

@@ -1,6 +1,7 @@
package protect.card_locker;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.robolectric.Shadows.shadowOf;
@@ -22,6 +23,7 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.widget.TextViewCompat;
import com.google.zxing.BarcodeFormat;
@@ -728,6 +730,68 @@ public class LoyaltyCardViewActivityTest
assertEquals(true, item.isVisible());
}
@Test
public void checkBarcodeFullscreenWorkflow()
ActivityController activityController = createActivityWithLoyaltyCard(false);
Activity activity = (Activity)activityController.get();
DBHelper db = new DBHelper(activity);
db.insertLoyaltyCard("store", "note", BARCODE_DATA, BARCODE_TYPE, Color.BLACK, Color.WHITE);
activityController.start();
activityController.visible();
activityController.resume();
assertEquals(false, activity.isFinishing());
ImageView barcodeImage = activity.findViewById(R.id.barcode);
View collapsingToolbarLayout = activity.findViewById(R.id.collapsingToolbarLayout);
// Android should not be in fullscreen mode
int uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions);
assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions);
// Elements should be visible
assertEquals(View.VISIBLE, collapsingToolbarLayout.getVisibility());
// Click barcode to toggle fullscreen
barcodeImage.performClick();
// Android should be in fullscreen mode
uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
assertEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions);
assertEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions);
// Elements should not be visible
assertEquals(View.GONE, collapsingToolbarLayout.getVisibility());
// Clicking barcode again should deactivate fullscreen mode
barcodeImage.performClick();
uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions);
assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions);
assertEquals(View.VISIBLE, collapsingToolbarLayout.getVisibility());
// Another click back to fullscreen
barcodeImage.performClick();
uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
assertEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions);
assertEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions);
assertEquals(View.GONE, collapsingToolbarLayout.getVisibility());
// In full screen mode, back button should disable fullscreen
activity.onBackPressed();
uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions);
assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions);
assertEquals(View.VISIBLE, collapsingToolbarLayout.getVisibility());
// Pressing back when not in full screen should finish activity
activity.onBackPressed();
assertEquals(true, activity.isFinishing());
}
@Test
public void importCard()
{