Add theme colour support

This commit is contained in:
Subhashish Anand
2021-08-22 04:44:24 +05:30
committed by GitHub
parent f625efc76d
commit 110b3bcef3
35 changed files with 390 additions and 151 deletions

View File

@@ -83,7 +83,8 @@
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".preferences.SettingsActivity"
android:label="@string/settings"/>
android:label="@string/settings"
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".ImportExportActivity"
android:label="@string/importExport"

View File

@@ -9,16 +9,15 @@ import android.util.Log;
import android.view.MenuItem;
import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
public class AboutActivity extends AppCompatActivity
public class AboutActivity extends CatimaAppCompatActivity
{
private static final String TAG = "Catima";

View File

@@ -15,6 +15,9 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import com.google.zxing.BarcodeFormat;
import java.util.Arrays;
@@ -24,17 +27,13 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
/**
* This activity is callable and will allow a user to enter
* barcode data and generate all barcodes possible for
* the data. The user may then select any barcode, where its
* data and type will be returned to the caller.
*/
public class BarcodeSelectorActivity extends AppCompatActivity
public class BarcodeSelectorActivity extends CatimaAppCompatActivity
{
private static final String TAG = "Catima";

View File

@@ -6,8 +6,6 @@ import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.pm.ShortcutInfoCompat;
@@ -16,6 +14,8 @@ import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
/**
* The configuration screen for creating a shortcut.
*/

View File

@@ -0,0 +1,48 @@
package protect.card_locker;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.util.TypedValue;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;
public class CatimaAppCompatActivity extends AppCompatActivity {
SharedPreferences pref;
@Override
public Resources.Theme getTheme() {
Resources.Theme theme = super.getTheme();
pref = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
String themeName = pref.getString("pref_theme_color", getString(R.string.settings_key_catima_theme));
if(themeName.equals(getString(R.string.settings_key_brown_theme))){
theme.applyStyle(R.style.AppTheme_brown, true);
}else if(themeName.equals(getString(R.string.settings_key_pink_theme))){
theme.applyStyle(R.style.AppTheme_pink, true);
}else if(themeName.equals(getString(R.string.settings_key_magenta_theme))){
theme.applyStyle(R.style.AppTheme_magenta, true);
}else if(themeName.equals(getString(R.string.settings_key_violet_theme))){
theme.applyStyle(R.style.AppTheme_violet, true);
}else if(themeName.equals(getString(R.string.settings_key_blue_theme))){
theme.applyStyle(R.style.AppTheme_blue, true);
}else if(themeName.equals(getString(R.string.settings_key_sky_blue_theme))){
theme.applyStyle(R.style.AppTheme_sky_blue, true);
}else if(themeName.equals(getString(R.string.settings_key_green_theme))){
theme.applyStyle(R.style.AppTheme_green, true);
}else if(themeName.equals(getString(R.string.settings_key_grey_theme))){
theme.applyStyle(R.style.AppTheme_grey, true);
}else {
theme.applyStyle(R.style.AppTheme_NoActionBar, true);
}
// you could also use a switch if you have many themes that could apply
return theme;
}
public int getThemeColor(){
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getTheme();
theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
return typedValue.data;
}
}

View File

@@ -10,6 +10,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.recyclerview.widget.RecyclerView;
import protect.card_locker.preferences.Settings;
class GroupCursorAdapter extends BaseCursorAdapter<GroupCursorAdapter.GroupListItemViewHolder>

View File

@@ -17,6 +17,12 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -26,16 +32,10 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import protect.card_locker.importexport.DataFormat;
import protect.card_locker.importexport.ImportExportResult;
public class ImportExportActivity extends AppCompatActivity
public class ImportExportActivity extends CatimaAppCompatActivity
{
private static final String TAG = "Catima";

View File

@@ -4,14 +4,14 @@ import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import com.google.zxing.BarcodeFormat;
import java.math.BigDecimal;
import java.util.Currency;
import java.util.Date;
import androidx.annotation.Nullable;
public class LoyaltyCard implements Parcelable {
public final int id;
public final String store;

View File

@@ -14,13 +14,14 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.ArrayList;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import protect.card_locker.preferences.Settings;

View File

@@ -35,6 +35,14 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.FileProvider;
import androidx.exifinterface.media.ExifInterface;
import androidx.fragment.app.DialogFragment;
import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
@@ -63,16 +71,7 @@ import java.util.Locale;
import java.util.NoSuchElementException;
import java.util.concurrent.Callable;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.FileProvider;
import androidx.exifinterface.media.ExifInterface;
import androidx.fragment.app.DialogFragment;
public class LoyaltyCardEditActivity extends AppCompatActivity
public class LoyaltyCardEditActivity extends CatimaAppCompatActivity
{
private static final String TAG = "Catima";
@@ -245,6 +244,8 @@ public class LoyaltyCardEditActivity extends AppCompatActivity
cardImageBack = findViewById(R.id.backImage);
enterButton = findViewById(R.id.enterButton);
cardImageFront.setBackgroundColor(getThemeColor());
cardImageBack.setBackgroundColor(getThemeColor());
warnOnInvalidBarcodeType = () -> {
if (!(boolean) barcodeImage.getTag()) {

View File

@@ -2,6 +2,7 @@ package protect.card_locker;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.multidex.MultiDexApplication;
import protect.card_locker.preferences.Settings;
public class LoyaltyCardLockerApplication extends MultiDexApplication {

View File

@@ -26,6 +26,15 @@ import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.Guideline;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.widget.TextViewCompat;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
@@ -38,18 +47,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.Guideline;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.widget.TextViewCompat;
import protect.card_locker.preferences.Settings;
public class LoyaltyCardViewActivity extends AppCompatActivity
public class LoyaltyCardViewActivity extends CatimaAppCompatActivity
{
private static final String TAG = "Catima";
@@ -175,6 +175,9 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
centerGuideline.setGuidelinePercent(0.5f);
barcodeScaler = findViewById(R.id.barcodeScaler);
barcodeScaler.setProgress(100);
minimizeButton.setBackgroundColor(getThemeColor());
maximizeButton.setBackgroundColor(getThemeColor());
bottomSheetButton.setBackgroundColor(getThemeColor());
barcodeScaler.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

View File

@@ -18,14 +18,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
import java.io.UnsupportedEncodingException;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
@@ -33,9 +26,16 @@ import androidx.core.app.ActivityCompat;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
import java.io.UnsupportedEncodingException;
import java.util.List;
import protect.card_locker.preferences.SettingsActivity;
public class MainActivity extends AppCompatActivity implements LoyaltyCardCursorAdapter.CardAdapterListener, GestureDetector.OnGestureListener
public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCardCursorAdapter.CardAdapterListener, GestureDetector.OnGestureListener
{
private static final String TAG = "Catima";

View File

@@ -10,19 +10,18 @@ import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.List;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class ManageGroupsActivity extends AppCompatActivity implements GroupCursorAdapter.GroupAdapterListener
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.List;
public class ManageGroupsActivity extends CatimaAppCompatActivity implements GroupCursorAdapter.GroupAdapterListener
{
private static final String TAG = "Catima";
@@ -116,7 +115,7 @@ public class ManageGroupsActivity extends AppCompatActivity implements GroupCurs
}
private void createGroup() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.AlertDialogTheme);
builder.setTitle(R.string.enter_group_name);
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT);

View File

@@ -11,6 +11,9 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import com.google.zxing.ResultPoint;
import com.google.zxing.client.android.Intents;
import com.journeyapps.barcodescanner.BarcodeCallback;
@@ -20,17 +23,13 @@ import com.journeyapps.barcodescanner.DecoratedBarcodeView;
import java.util.List;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
/**
* Custom Scannner Activity extending from Activity to display a custom layout form scanner view.
*
* Based on https://github.com/journeyapps/zxing-android-embedded/blob/0fdfbce9fb3285e985bad9971c5f7c0a7a334e7b/sample/src/main/java/example/zxing/CustomScannerActivity.java
* originally licensed under Apache 2.0
*/
public class ScanActivity extends AppCompatActivity {
public class ScanActivity extends CatimaAppCompatActivity {
private static final String TAG = "Catima";
private CaptureManager capture;

View File

@@ -5,15 +5,15 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;
class ShortcutHelper
{
// Android documentation says that no more than 5 shortcuts

View File

@@ -15,6 +15,9 @@ import android.provider.MediaStore;
import android.util.Log;
import android.widget.Toast;
import androidx.core.graphics.ColorUtils;
import androidx.exifinterface.media.ExifInterface;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
@@ -37,9 +40,7 @@ import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Locale;
import androidx.core.graphics.ColorUtils;
import protect.card_locker.preferences.Settings;
import androidx.exifinterface.media.ExifInterface;
public class Utils {
private static final String TAG = "Catima";

View File

@@ -3,12 +3,13 @@ package protect.card_locker.preferences;
import android.content.Context;
import android.content.SharedPreferences;
import java.util.Locale;
import androidx.annotation.IntegerRes;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.preference.PreferenceManager;
import java.util.Locale;
import protect.card_locker.R;
import protect.card_locker.Utils;

View File

@@ -1,36 +1,31 @@
package protect.card_locker.preferences;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import com.journeyapps.barcodescanner.Util;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import nl.invissvenska.numberpickerpreference.NumberDialogPreference;
import nl.invissvenska.numberpickerpreference.NumberPickerPreferenceDialogFragment;
import protect.card_locker.MainActivity;
import protect.card_locker.CatimaAppCompatActivity;
import protect.card_locker.R;
import protect.card_locker.Utils;
public class SettingsActivity extends AppCompatActivity
public class SettingsActivity extends CatimaAppCompatActivity
{
@Override
protected void attachBaseContext(Context base) {
@@ -43,7 +38,8 @@ public class SettingsActivity extends AppCompatActivity
super.onCreate(savedInstanceState);
setTitle(R.string.settings);
setContentView(R.layout.settings_activity);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null)
{
@@ -120,6 +116,15 @@ public class SettingsActivity extends AppCompatActivity
return true;
});
Preference colorPreference = findPreference(getResources().getString(R.string.setting_key_theme_color));
assert colorPreference != null;
colorPreference.setOnPreferenceChangeListener((preference, o) -> {
FragmentActivity activity = getActivity();
if (activity != null) {
ActivityCompat.recreate(activity);
}
return true;
});
localePreference.setOnPreferenceChangeListener((preference, newValue) -> {
// Refresh the activity
parent.finish();

View File

@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabSave"
@@ -365,7 +366,6 @@
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:minHeight="50dp"
android:background="@color/colorPrimary"
android:contentDescription="@string/frontImageDescription"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_camera_white" />
@@ -401,7 +401,6 @@
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:minHeight="50dp"
android:background="@color/colorPrimary"
android:contentDescription="@string/backImageDescription"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_camera_white" />

View File

@@ -55,7 +55,6 @@
app:srcCompat="@drawable/ic_baseline_arrow_drop_up_24"
android:contentDescription="@string/moveBarcodeToTopOfScreen"
app:tint="#ffffff"
android:background="@color/colorPrimary"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/barcode"
app:layout_constraintEnd_toEndOf="parent"
@@ -86,7 +85,6 @@
app:srcCompat="@drawable/ic_baseline_arrow_drop_down_24"
android:contentDescription="@string/moveBarcodeToCenterOfScreen"
app:tint="#ffffff"
android:background="@color/colorPrimary"
app:layout_constraintTop_toBottomOf="@+id/barcode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
@@ -149,7 +147,6 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_gravity="top|start"
android:background="@color/colorPrimary"
android:scaleType="fitCenter"
app:tint="#ffffff"
app:srcCompat="@drawable/ic_baseline_arrow_drop_up_24" />

View File

@@ -2,8 +2,23 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/settings_container"
android:layout_width="match_parent"

View File

@@ -12,6 +12,31 @@
<item>@string/settings_dark_theme</item>
</string-array>
<string-array name="color_values">
<item>@string/settings_key_catima_theme</item>
<item>@string/settings_key_pink_theme</item>
<item>@string/settings_key_magenta_theme</item>
<item>@string/settings_key_violet_theme</item>
<item>@string/settings_key_blue_theme</item>
<item>@string/settings_key_sky_blue_theme</item>
<item>@string/settings_key_green_theme</item>
<item>@string/settings_key_grey_theme</item>
<item>@string/settings_key_brown_theme</item>
</string-array>
<string-array name="color_value_strings">
<item>@string/settings_catima_theme</item>
<item>@string/settings_pink_theme</item>
<item>@string/settings_magenta_theme</item>
<item>@string/settings_violet_theme</item>
<item>@string/settings_blue_theme</item>
<item>@string/settings_sky_blue_theme</item>
<item>@string/settings_green_theme</item>
<item>@string/settings_grey_theme</item>
<item>@string/settings_brown_theme</item>
</string-array>
<string-array name="locale_values">
<item />
<item>bg</item>

View File

@@ -216,4 +216,26 @@
<string name="settings_locale">Language</string>
<string name="settings_key_locale" translatable="false">pref_locale</string>
<string name="settings_system_locale">System</string>
<string name="setting_key_theme_color" translatable="false">pref_theme_color</string>
<string name="settings_theme_color">Theme color</string>
<string name="settings_catima_theme">Catima</string>
<string name="settings_pink_theme">Pink</string>
<string name="settings_magenta_theme">Magenta</string>
<string name="settings_violet_theme">Violet</string>
<string name="settings_blue_theme">Blue</string>
<string name="settings_sky_blue_theme">Sky blue</string>
<string name="settings_green_theme">Green</string>
<string name="settings_grey_theme">Grey</string>
<string name="settings_brown_theme">Brown</string>
<string name="settings_key_catima_theme" translatable="false">catima_theme</string>
<string name="settings_key_pink_theme" translatable="false">pink_theme</string>
<string name="settings_key_magenta_theme" translatable="false">magenta_theme</string>
<string name="settings_key_violet_theme" translatable="false">violet_theme</string>
<string name="settings_key_blue_theme" translatable="false">blue_theme</string>
<string name="settings_key_sky_blue_theme" translatable="false">sky_blue_theme</string>
<string name="settings_key_green_theme" translatable="false">green_theme</string>
<string name="settings_key_grey_theme" translatable="false">grey_theme</string>
<string name="settings_key_brown_theme" translatable="false">brown_theme</string>
</resources>

View File

@@ -1,16 +1,81 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="colorAccent">@color/colorSecondary</item>
<item name="colorAccent">@color/colorPrimary</item>
<item name="actionModeBackground">@color/colorPrimary</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeCloseDrawable">@drawable/ic_close</item>
</style>
<style name="AppTheme_pink" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/pink_colorPrimary</item>
<item name="colorPrimaryDark">@color/pink_colorPrimaryDark</item>
<item name="colorAccent">@color/pink_colorPrimary</item>
<item name="actionModeBackground">@color/pink_colorPrimary</item>
</style>
<style name="AppTheme_magenta" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/magenta_colorPrimary</item>
<item name="colorPrimaryDark">@color/magenta_colorPrimaryDark</item>
<item name="colorAccent">@color/magenta_colorPrimary</item>
<item name="actionModeBackground">@color/magenta_colorPrimary</item>
</style>
<style name="AppTheme_violet" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/violet_colorPrimary</item>
<item name="colorPrimaryDark">@color/violet_colorPrimaryDark</item>
<item name="colorAccent">@color/violet_colorPrimary</item>
<item name="actionModeBackground">@color/violet_colorPrimary</item>
</style>
<style name="AppTheme_blue" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/blue_colorPrimary</item>
<item name="colorPrimaryDark">@color/blue_colorPrimaryDark</item>
<item name="colorAccent">@color/blue_colorPrimary</item>
<item name="actionModeBackground">@color/blue_colorPrimary</item>
</style>
<style name="AppTheme_sky_blue" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/skyblue_colorPrimary</item>
<item name="colorPrimaryDark">@color/skyblue_colorPrimaryDark</item>
<item name="colorAccent">@color/skyblue_colorPrimary</item>
<item name="actionModeBackground">@color/skyblue_colorPrimary</item>
</style>
<style name="AppTheme_green" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/green_colorPrimary</item>
<item name="colorPrimaryDark">@color/green_colorPrimaryDark</item>
<item name="colorAccent">@color/green_colorPrimary</item>
<item name="actionModeBackground">@color/green_colorPrimary</item>
</style>
<style name="AppTheme_grey" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/grey_colorPrimary</item>
<item name="colorPrimaryDark">@color/grey_colorPrimaryDark</item>
<item name="colorAccent">@color/grey_colorPrimary</item>
<item name="actionModeBackground">@color/grey_colorPrimary</item>
</style>
<style name="AppTheme_brown" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/brown_colorPrimary</item>
<item name="colorPrimaryDark">@color/brown_colorPrimaryDark</item>
<item name="colorAccent">@color/brown_colorPrimary</item>
<item name="actionModeBackground">@color/brown_colorPrimary</item>
</style>
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
@@ -35,4 +100,52 @@
<item name="android:padding">@dimen/no_data_padding</item>
<item name="android:textSize">@dimen/no_data_textSize</item>
</style>
<style name="AlertDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
<item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
<item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
</style>
<style name="NegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/colorSecondaryText</item>
</style>
<style name="PositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/colorSecondaryText</item>
</style>
<color name="red_colorPrimary">#ff0000</color>
<color name="red_colorPrimaryDark">#DF0000</color>
<color name="pink_colorPrimary">#e91e63</color>
<color name="pink_colorPrimaryDark">#CB1755</color>
<color name="magenta_colorPrimary">#9b26af</color>
<color name="magenta_colorPrimaryDark">#7a1ea1</color>
<color name="violet_colorPrimary">#6639b6</color>
<color name="violet_colorPrimaryDark">#502ca7</color>
<color name="blue_colorPrimary">#3F51B5</color>
<color name="blue_colorPrimaryDark">#3445A2</color>
<color name="skyblue_colorPrimary">#03A9F4</color>
<color name="skyblue_colorPrimaryDark">#0094D7</color>
<color name="green_colorPrimary">#4CAF50</color>
<color name="green_colorPrimaryDark">#419744</color>
<!--<color name="colorPrimary">#3F51B5</color>-->
<!--<color name="colorPrimaryDark">#3445A2</color>-->
<color name="grey_colorPrimary">#9d9d9d</color>
<color name="grey_colorPrimaryDark">#606060</color>
<color name="grey_colorAccent">#f90</color>
<color name="brown_colorPrimary">#795548</color>
<color name="brown_colorPrimaryDark">#63453B</color>
<color name="brown_colorAccent">#e81d62</color>
</resources>

View File

@@ -16,6 +16,16 @@
app:iconSpaceReserved="false"
app:singleLineTitle="false" />
<ListPreference
android:key="@string/setting_key_theme_color"
android:title="@string/settings_theme_color"
android:defaultValue="@string/settings_key_catima_theme"
android:entries="@array/color_value_strings"
android:entryValues="@array/color_values"
app:iconSpaceReserved="false"
app:singleLineTitle="false" />
<ListPreference
android:key="@string/settings_key_locale"
android:title="@string/settings_locale"

View File

@@ -1,5 +1,8 @@
package protect.card_locker;
import static org.junit.Assert.assertEquals;
import static org.robolectric.Shadows.shadowOf;
import android.app.Activity;
import android.content.Intent;
import android.os.Looper;
@@ -14,9 +17,6 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class BarcodeSelectorActivityTest {

View File

@@ -1,5 +1,11 @@
package protect.card_locker;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
@@ -20,12 +26,6 @@ import java.util.ArrayList;
import java.util.Currency;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class DatabaseTest

View File

@@ -1,5 +1,8 @@
package protect.card_locker;
import static org.junit.Assert.assertEquals;
import static org.robolectric.Shadows.shadowOf;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -15,9 +18,6 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class ImportExportActivityTest

View File

@@ -1,5 +1,10 @@
package protect.card_locker;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import android.app.Activity;
import android.database.Cursor;
import android.graphics.Bitmap;
@@ -9,6 +14,8 @@ import android.graphics.drawable.BitmapDrawable;
import android.os.Environment;
import android.util.DisplayMetrics;
import androidx.core.content.res.ResourcesCompat;
import com.google.zxing.BarcodeFormat;
import org.json.JSONException;
@@ -41,17 +48,11 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import androidx.core.content.res.ResourcesCompat;
import protect.card_locker.importexport.DataFormat;
import protect.card_locker.importexport.ImportExportResult;
import protect.card_locker.importexport.MultiFormatExporter;
import protect.card_locker.importexport.MultiFormatImporter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class ImportExportTest

View File

@@ -1,5 +1,9 @@
package protect.card_locker;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import android.app.Activity;
import android.graphics.Color;
import android.net.Uri;
@@ -19,10 +23,6 @@ import java.math.BigDecimal;
import java.util.Currency;
import java.util.Date;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class ImportURITest {

View File

@@ -1,5 +1,9 @@
package protect.card_locker;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
@@ -9,6 +13,8 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.preference.PreferenceManager;
import com.google.zxing.BarcodeFormat;
import org.junit.Before;
@@ -24,16 +30,8 @@ import java.text.DateFormat;
import java.util.Currency;
import java.util.Date;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import protect.card_locker.preferences.Settings;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class LoyaltyCardCursorAdapterTest

View File

@@ -1,5 +1,13 @@
package protect.card_locker;
import static android.os.Looper.getMainLooper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.robolectric.Shadows.shadowOf;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Context;
@@ -26,6 +34,10 @@ import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.core.widget.TextViewCompat;
import androidx.preference.PreferenceManager;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
@@ -52,18 +64,6 @@ import java.text.ParseException;
import java.util.Currency;
import java.util.Date;
import androidx.appcompat.app.AlertDialog;
import androidx.core.widget.TextViewCompat;
import androidx.preference.PreferenceManager;
import static android.os.Looper.getMainLooper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class LoyaltyCardViewActivityTest

View File

@@ -1,5 +1,10 @@
package protect.card_locker;
import static android.os.Looper.getMainLooper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.robolectric.Shadows.shadowOf;
import android.app.Activity;
import android.content.ComponentName;
import android.content.SharedPreferences;
@@ -8,6 +13,8 @@ import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.tabs.TabLayout;
import com.google.zxing.BarcodeFormat;
@@ -23,13 +30,6 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView;
import static android.os.Looper.getMainLooper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class MainActivityTest

View File

@@ -1,5 +1,7 @@
package protect.card_locker;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -8,8 +10,6 @@ import org.robolectric.annotation.Config;
import java.math.BigDecimal;
import java.util.Currency;
import static org.junit.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23)
public class UtilsTest