Compare commits

...

13 Commits
v0.12 ... v0.13

Author SHA1 Message Date
Branden Archer
e822ab0b56 Merge pull request #133 from brarcher/pre-v0.13
Update for v0.13
2017-07-25 10:04:44 -04:00
Branden Archer
e33ab682a6 Update for v0.13 2017-07-25 09:58:19 -04:00
Branden Archer
0d50ad6d10 Merge pull request #132 from brarcher/check-for-card
Verify card exists before displaying it
2017-07-23 10:27:06 -04:00
Branden Archer
4143e5c286 Bail if loyalty card could not be found
This case was hit at least once by a user, though the scenario
is not known. If it is hit, post a message and bail gracefully,
until the reason can be determined.
2017-07-23 10:05:05 -04:00
Branden Archer
15425d51aa Add debugging when entering view activity 2017-07-22 23:52:21 -04:00
Branden Archer
3abcb32a75 Merge pull request #130 from brarcher/text-update
Change lock/unlock text to say block/unblock
2017-07-18 22:25:47 -04:00
Branden Archer
93124a88a5 Change lock/unlock text to say block/unblock 2017-07-18 22:18:52 -04:00
Branden Archer
29b00e3b59 Merge pull request #129 from airon90/patch-1
Update strings.xml
2017-07-18 22:06:08 -04:00
Michael Moroni
04174154d6 Update strings.xml
Instead of "Block screen" I translated "Block rotation" because I think it's more intuitive
2017-07-17 12:49:39 +02:00
Branden Archer
bf60976d10 Merge pull request #128 from brarcher/lock-orientation
Add option to lock screen orientation
2017-07-16 21:32:55 -04:00
Branden Archer
fb7e3e12f2 Add menu option to lock screen when viewing card
When passing a phone to a clerk to scan the barcode, if the
phone is rotated and the screen reloads it can be bothersome
or confusion. To avoid this situation, a new option is
added to lock the screen.

A menu icon is now added which defaults as unlocked. When
touched the app sets its orientation to the "natural" orientation
of the device. When touched again the sensor dictates the
orientation of the device.
2017-07-16 21:26:40 -04:00
Branden Archer
641d29a6f8 Remove usage of depreated location of ActivityController 2017-07-16 21:26:40 -04:00
Branden Archer
0f2ee296b4 Remove container class for intro slides
Even with passing a bundle with the layout ID sometimes
some users will encounter a situation where the _layout
variable is null. To avoid further issues, creating a
class for each intro slide, so the layout is encoded
into the class itself.
2017-07-16 21:26:40 -04:00
32 changed files with 252 additions and 62 deletions

View File

@@ -14,8 +14,8 @@ android {
applicationId "protect.card_locker"
minSdkVersion 17
targetSdkVersion 23
versionCode 13
versionName "0.12"
versionCode 14
versionName "0.13"
}
buildTypes {
release {

View File

@@ -49,7 +49,7 @@
android:configChanges="orientation|screenSize"
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".IntroActivity"
android:name=".intro.IntroActivity"
android:label=""
android:configChanges="orientation|screenSize"
android:theme="@style/AppTheme.NoActionBar"/>

View File

@@ -1,43 +0,0 @@
package protect.card_locker;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.v4.app.Fragment;
import com.github.paolorotolo.appintro.AppIntro;
public class IntroActivity extends AppIntro
{
@Override
public void init(Bundle savedInstanceState)
{
addIntroSlide(R.layout.intro1_layout);
addIntroSlide(R.layout.intro2_layout);
addIntroSlide(R.layout.intro3_layout);
addIntroSlide(R.layout.intro4_layout);
addIntroSlide(R.layout.intro5_layout);
addIntroSlide(R.layout.intro6_layout);
}
private void addIntroSlide(@LayoutRes int layout)
{
Fragment slide = new IntroSlide();
Bundle args = new Bundle();
args.putInt("layout", layout);
slide.setArguments(args);
addSlide(slide);
}
@Override
public void onSkipPressed(Fragment fragment) {
finish();
}
@Override
public void onDonePressed(Fragment fragment) {
finish();
}
}

View File

@@ -2,8 +2,11 @@ package protect.card_locker;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
@@ -22,6 +25,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.integration.android.IntentIntegrator;
@@ -53,6 +57,8 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
boolean updateLoyaltyCard;
boolean viewLoyaltyCard;
boolean rotationEnabled;
DBHelper db;
@Override
@@ -74,6 +80,10 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
updateLoyaltyCard = b != null && b.getBoolean("update", false);
viewLoyaltyCard = b != null && b.getBoolean("view", false);
Log.d(TAG, "View activity: id=" + loyaltyCardId
+ ", updateLoyaltyCard=" + Boolean.toString(updateLoyaltyCard)
+ ", viewLoyaltyCard=" + Boolean.toString(viewLoyaltyCard));
db = new DBHelper(this);
}
@@ -116,6 +126,13 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
if(updateLoyaltyCard || viewLoyaltyCard)
{
final LoyaltyCard loyaltyCard = db.getLoyaltyCard(loyaltyCardId);
if(loyaltyCard == null)
{
Log.w(TAG, "Could not lookup loyalty card " + loyaltyCardId);
Toast.makeText(this, R.string.noCardExistsError, Toast.LENGTH_LONG).show();
finish();
return;
}
if(storeFieldEdit.getText().length() == 0)
{
@@ -305,6 +322,8 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
getMenuInflater().inflate(R.menu.card_add_menu, menu);
}
rotationEnabled = true;
return super.onCreateOptionsMenu(menu);
}
@@ -361,6 +380,22 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
finish();
return true;
case R.id.action_lock_unlock:
if(rotationEnabled)
{
item.setIcon(R.drawable.ic_lock_outline_white_24dp);
item.setTitle(R.string.unlockScreen);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
}
else
{
item.setIcon(R.drawable.ic_lock_open_white_24dp);
item.setTitle(R.string.lockScreen);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}
rotationEnabled = !rotationEnabled;
return true;
case R.id.action_save:
doSave();
return true;

View File

@@ -29,6 +29,8 @@ import com.google.common.collect.ImmutableMap;
import java.util.Calendar;
import java.util.Map;
import protect.card_locker.intro.IntroActivity;
public class MainActivity extends AppCompatActivity
{
private static final String TAG = "LoyaltyCardLocker";

View File

@@ -0,0 +1,36 @@
package protect.card_locker.intro;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.v4.app.Fragment;
import com.github.paolorotolo.appintro.AppIntro;
import protect.card_locker.R;
public class IntroActivity extends AppIntro
{
@Override
public void init(Bundle savedInstanceState)
{
addSlide(new IntroSlide1());
addSlide(new IntroSlide2());
addSlide(new IntroSlide3());
addSlide(new IntroSlide4());
addSlide(new IntroSlide5());
addSlide(new IntroSlide6());
}
@Override
public void onSkipPressed(Fragment fragment) {
finish();
}
@Override
public void onDonePressed(Fragment fragment) {
finish();
}
}

View File

@@ -0,0 +1,19 @@
package protect.card_locker.intro;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import protect.card_locker.R;
public class IntroSlide1 extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.intro1_layout, container, false);
return v;
}
}

View File

@@ -1,4 +1,4 @@
package protect.card_locker;
package protect.card_locker.intro;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@@ -6,20 +6,15 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class IntroSlide extends Fragment
{
int _layout;
import protect.card_locker.R;
@Override
public void setArguments(Bundle bundle)
{
_layout = bundle.getInt("layout");
}
public class IntroSlide2 extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(_layout, container, false);
View v = inflater.inflate(R.layout.intro2_layout, container, false);
return v;
}
}

View File

@@ -0,0 +1,19 @@
package protect.card_locker.intro;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import protect.card_locker.R;
public class IntroSlide3 extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.intro3_layout, container, false);
return v;
}
}

View File

@@ -0,0 +1,19 @@
package protect.card_locker.intro;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import protect.card_locker.R;
public class IntroSlide4 extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.intro4_layout, container, false);
return v;
}
}

View File

@@ -0,0 +1,19 @@
package protect.card_locker.intro;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import protect.card_locker.R;
public class IntroSlide5 extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.intro5_layout, container, false);
return v;
}
}

View File

@@ -0,0 +1,19 @@
package protect.card_locker.intro;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import protect.card_locker.R;
public class IntroSlide6 extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.intro6_layout, container, false);
return v;
}
}

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

View File

@@ -2,6 +2,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_lock_unlock"
android:icon="@drawable/ic_lock_open_white_24dp"
android:title="@string/lockScreen"
app:showAsAction="always"/>
<item
android:id="@+id/action_edit"
android:icon="@drawable/ic_mode_edit_white_24dp"

View File

@@ -19,6 +19,8 @@
<string name="edit">Editovat</string>
<string name="delete">Smazat</string>
<string name="confirm">Potvrdit</string>
<!-- NEEDS TRANSLATED --><string name="lockScreen">Block Rotation</string>
<!-- NEEDS TRANSLATED --><string name="unlockScreen">Unblock Rotation</string>
<string name="deleteTitle">Odstzranit věrnostní kartu</string>
<string name="deleteConfirmation">Opravdu chcete smazat tuto věrnostní kartu?</string>
<string name="ok">Ano</string>
@@ -33,6 +35,7 @@
<string name="noStoreError">Nebyl zadán Obchod</string>
<string name="noCardIdError">Nebylo zadáno ID karty</string>
<!-- NEEDS TRANSLATED --><string name="noCardExistsError">Could not lookup loyalty card</string>
<string name="cardIdFormat">%1$s: %2$s</string>

View File

@@ -25,6 +25,7 @@
<string name="importName">Import</string>
<string name="importedFrom">Importiert von: %1$s</string>
<string name="noCardIdError">Keine Kartennummer angegeben</string>
<!-- NEEDS TRANSLATED --><string name="noCardExistsError">Could not lookup loyalty card</string>
<string name="noExternalStoragePermissionError">Ohne die Berechtigung für den externen Speicher kann kein Import oder Export erfolgen.</string>
<string name="noGiftCards">Sie haben noch keine Kundenkarte angelegt. Über den "+" Button oben rechts, können welche angelegt werden.\n\nDiese App ermöglicht es, Kundenkarten immer mit zu führen.</string>
<string name="cancel">Abbrechen</string>
@@ -33,9 +34,11 @@
<string name="cardIdFormat">%1$s: %2$s</string>
<string name="confirm">Bestätigen</string>
<string name="copy_to_clipboard">Kopiere die Nummer in die Zwischenablage</string>
<!-- NEEDS TRANSLATED --><string name="lockScreen">Block Rotation</string>
<!-- NEEDS TRANSLATED --><string name="unlockScreen">Unblock Rotation</string>
<string name="delete">Löschen</string>
<string name="deleteConfirmation">Bitte bestätigen Sie, dass diese Karte gelöscht werden soll.</string>
<string name="deleteTitle">Lösche die Kundenkarte</string>
<string name="deleteTitle">Lösche die Kundenkarte</string><!-- NEEDS TRANSLATED -->
<string name="edit">Bearbeiten</string>
<string name="editCardTitle">Kundenkarte bearbeiten</string>
<string name="enterCard">Karte einfügen</string>

View File

@@ -18,6 +18,8 @@
<string name="editCard">Modifier</string>
<string name="edit">Modifier</string>
<string name="delete">Supprimer</string>
<!-- NEEDS TRANSLATED --><string name="lockScreen">Block Rotation</string>
<!-- NEEDS TRANSLATED --><string name="unlockScreen">Unblock Rotation</string>
<string name="confirm">Confirmer</string>
<string name="deleteTitle">Supprimer la carte de fidélité</string>
<string name="deleteConfirmation">Confirmez que vous souhaitez supprimer cette carte</string>
@@ -33,6 +35,7 @@
<string name="noStoreError">Aucun nom n\'a été saisi</string>
<string name="noCardIdError">Aucun numéro n\'a été saisi</string>
<!-- NEEDS TRANSLATED --><string name="noCardExistsError">Could not lookup loyalty card</string>
<string name="cardIdFormat">%1$s: %2$s</string>

View File

@@ -25,6 +25,7 @@
<string name="noStoreError">Nessun negozio inserito</string>
<string name="noCardIdError">Nessun codice carta inserito</string>
<!-- NEEDS TRANSLATED --><string name="noCardExistsError">Could not lookup loyalty card</string>
<string name="cardIdFormat">%1$s: %2$s</string>
<string name="note">Note</string>
@@ -47,7 +48,7 @@
<string name="debug_version_fmt">Versione: <xliff:g id="version">%s</xliff:g></string>
<string name="app_revision_fmt">Informazione sulla revisione: <xliff:g id="app_revision_url">%s</xliff:g></string>
<string name="app_libraries"><xliff:g id="app_name">%s</xliff:g> usa le seguenti librerie di terze parti: <xliff:g id="app_libraries_list">%s</xliff:g></string>
<!-- NEEDS TRANSLATED --><string name="app_resources"><xliff:g id="app_name">%s</xliff:g> uses the following third-party resources: <xliff:g id="app_resources_list">%s</xliff:g></string>
<string name="app_resources"><xliff:g id="app_name">%s</xliff:g> usa le seguenti risorse di terze parti: <xliff:g id="app_resources_list">%s</xliff:g></string>
<string name="ok">Ok</string>
<string name="enterCard">Inserisci carta</string>
<string name="editCard">Modifica carta</string>
@@ -56,6 +57,8 @@
<string name="copy_to_clipboard">Copia ID negli appunti</string>
<string name="copy_to_clipboard_toast">ID della carta copiato negli appunti</string>
<string name="confirm">Conferma</string>
<string name="lockScreen">Blocca rotazione</string>
<string name="unlockScreen">Sblocca rotazione</string>
<string name="deleteTitle">Rimuovi carta fedeltà</string>
<string name="deleteConfirmation">Conferma che vuoi eliminare questa carta.</string>
<string name="importExportHelp">Fare il backup dei dati ti permette di spostare le tue tessere da un dispositivo ad un altro.</string>

View File

@@ -19,6 +19,8 @@
<string name="edit">Redaguoti</string>
<string name="delete">Ištrinti</string>
<string name="confirm">Patvirtinti</string>
<!-- NEEDS TRANSLATED --><string name="lockScreen">Block Rotation</string>
<!-- NEEDS TRANSLATED --><string name="unlockScreen">Unblock Rotation</string>
<string name="deleteTitle">Panaikinti lojalumo kortelę</string>
<string name="deleteConfirmation">Prašome patvirtinti jog Jūs norite panaikinti šią lojalumo kortelę.</string>
<string name="ok">Gerai</string>
@@ -33,6 +35,7 @@
<string name="noStoreError">Parduotuvė neįvesta</string>
<string name="noCardIdError">Neįvestas kortelės ID</string>
<!-- NEEDS TRANSLATED --><string name="noCardExistsError">Could not lookup loyalty card</string>
<string name="cardIdFormat">%1$s: %2$s</string>

View File

@@ -25,6 +25,7 @@
<string name="noStoreError">Geen winkel toegevoegd</string>
<string name="noCardIdError">Geen kaart-ID toegevoegd</string>
<!-- NEEDS TRANSLATED --><string name="noCardExistsError">Could not lookup loyalty card</string>
<string name="cardIdFormat">%1$s: %2$s</string>
<string name="note">Notitie</string>
@@ -58,7 +59,8 @@
<string name="confirm">Bevestig</string>
<string name="deleteConfirmation">Bevestig deze kaart te verwijderen.</string>
<string name="deleteTitle">Verwijder kaart</string>
<!-- NEEDS TRANSLATED --><string name="lockScreen">Block Rotation</string>
<!-- NEEDS TRANSLATED --><string name="unlockScreen">Unblock Rotation</string>
<string name="importExportHelp">Data die is geback-upt maakt het mogelijk om je klantenkaarten naar een ander apparaat te verplaatsen.</string>
<string name="importSuccessfulTitle">Importeren succesvol</string>
<string name="importFailedTitle">Importeren mislukte</string>

View File

@@ -19,6 +19,8 @@
<string name="edit">Edit</string>
<string name="delete">Delete</string>
<string name="confirm">Confirm</string>
<string name="lockScreen">Block Rotation</string>
<string name="unlockScreen">Unblock Rotation</string>
<string name="deleteTitle">Remove Loyalty Card</string>
<string name="deleteConfirmation">Please confirm that you want to delete this card.</string>
<string name="ok">OK</string>
@@ -34,6 +36,7 @@
<string name="noStoreError">No Store entered</string>
<string name="noCardIdError">No Card ID entered</string>
<string name="noCardExistsError">Could not lookup loyalty card</string>
<string name="cardIdFormat">%1$s: %2$s</string>
<string name="storeNameAndNoteFormat" translatable="false">%1$s - %2$s</string>

View File

@@ -6,6 +6,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@@ -24,12 +25,13 @@ import org.robolectric.annotation.Config;
import org.robolectric.res.builder.RobolectricPackageManager;
import org.robolectric.shadows.ShadowActivity;
import org.robolectric.shadows.ShadowLog;
import org.robolectric.util.ActivityController;
import org.robolectric.android.controller.ActivityController;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
@@ -414,4 +416,47 @@ public class LoyaltyCardViewActivityTest
shadowOf(activity).clickMenuItem(android.R.id.home);
assertEquals(true, activity.isFinishing());
}
@Test
public void checkMenu() throws IOException
{
ActivityController activityController = createActivityWithLoyaltyCard(false);
Activity activity = (Activity)activityController.get();
DBHelper db = new DBHelper(activity);
db.insertLoyaltyCard("store", "note", BARCODE_DATA, BARCODE_TYPE);
activityController.start();
activityController.visible();
activityController.resume();
final Menu menu = shadowOf(activity).getOptionsMenu();
assertTrue(menu != null);
// The settings and add button should be present
assertEquals(menu.size(), 2);
assertEquals("Block Rotation", menu.findItem(R.id.action_lock_unlock).getTitle().toString());
assertEquals("Edit", menu.findItem(R.id.action_edit).getTitle().toString());
}
@Test
public void startWithMissingLoyaltyCard() throws IOException
{
ActivityController activityController = createActivityWithLoyaltyCard(true);
Activity activity = (Activity)activityController.get();
activityController.start();
activityController.visible();
activityController.resume();
// The activity should find that the card is missing and shut down
assertTrue(activity.isFinishing());
// Make sure the activity can close down
activityController.pause();
activityController.stop();
activityController.destroy();
}
}

View File

@@ -21,7 +21,7 @@ import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.util.ActivityController;
import org.robolectric.android.controller.ActivityController;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -131,7 +131,7 @@ public class MainActivityTest
ComponentName componentName = next.getComponent();
String name = componentName.flattenToShortString();
assertEquals("protect.card_locker/.IntroActivity", name);
assertEquals("protect.card_locker/.intro.IntroActivity", name);
Bundle extras = next.getExtras();
assertNull(extras);