mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-06 08:33:45 -04:00
Merge branch 'master' into feature/barcodeless_cards
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
android:required="false" />
|
||||
|
||||
<application
|
||||
android:name=".LoyaltyCardLockerApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
||||
@@ -182,4 +182,4 @@ class BarcodeImageWriterTask extends AsyncTask<Void, Void, Bitmap>
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.app.Application;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
|
||||
import protect.card_locker.preferences.Settings;
|
||||
|
||||
public class LoyaltyCardLockerApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
Settings settings = new Settings(getApplicationContext());
|
||||
AppCompatDelegate.setDefaultNightMode(settings.getTheme());
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,13 @@ import android.content.ClipboardManager;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
@@ -34,6 +36,7 @@ import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
import protect.card_locker.intro.IntroActivity;
|
||||
import protect.card_locker.preferences.Settings;
|
||||
import protect.card_locker.preferences.SettingsActivity;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
@@ -89,6 +92,9 @@ public class MainActivity extends AppCompatActivity
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
searchItem.collapseActionView();
|
||||
}
|
||||
|
||||
// In case the theme changed
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,8 +341,19 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
WebView wv = new WebView(this);
|
||||
|
||||
// Set CSS for dark mode if dark mode
|
||||
String css = "";
|
||||
Configuration config = getResources().getConfiguration();
|
||||
int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
if(currentNightMode == Configuration.UI_MODE_NIGHT_YES)
|
||||
{
|
||||
css = "<style>body {color:white; background-color:black;}</style>";
|
||||
}
|
||||
|
||||
String html =
|
||||
"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />" +
|
||||
css +
|
||||
"<img src=\"file:///android_res/mipmap/ic_launcher.png\" alt=\"" + appName + "\"/>" +
|
||||
"<h1>" +
|
||||
String.format(getString(R.string.about_title_fmt),
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.IntegerRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
|
||||
import protect.card_locker.R;
|
||||
|
||||
@@ -29,6 +30,11 @@ public class Settings
|
||||
return context.getResources().getInteger(resId);
|
||||
}
|
||||
|
||||
private String getString(@StringRes int keyId, String defaultValue)
|
||||
{
|
||||
return settings.getString(getResString(keyId), defaultValue);
|
||||
}
|
||||
|
||||
private int getInt(@StringRes int keyId, @IntegerRes int defaultId)
|
||||
{
|
||||
return settings.getInt(getResString(keyId), getResInt(defaultId));
|
||||
@@ -39,6 +45,22 @@ public class Settings
|
||||
return settings.getBoolean(getResString(keyId), defaultValue);
|
||||
}
|
||||
|
||||
public int getTheme()
|
||||
{
|
||||
String value = getString(R.string.settings_key_theme, getResString(R.string.settings_key_system_theme));
|
||||
|
||||
if(value.equals(getResString(R.string.settings_key_light_theme)))
|
||||
{
|
||||
return AppCompatDelegate.MODE_NIGHT_NO;
|
||||
}
|
||||
else if(value.equals(getResString(R.string.settings_key_dark_theme)))
|
||||
{
|
||||
return AppCompatDelegate.MODE_NIGHT_YES;
|
||||
}
|
||||
|
||||
return AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
|
||||
}
|
||||
|
||||
public int getCardTitleListFontSize()
|
||||
{
|
||||
return getInt(R.string.settings_key_card_title_list_font_size, R.integer.settings_card_title_list_font_size_sp);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package protect.card_locker.preferences;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import protect.card_locker.R;
|
||||
@@ -44,12 +46,35 @@ public class SettingsActivity extends AppCompatActivity
|
||||
public static class SettingsFragment extends PreferenceFragment
|
||||
{
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
public void onCreate(final Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
findPreference(getResources().getString(R.string.settings_key_theme)).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o)
|
||||
{
|
||||
if(o.toString().equals(getResources().getString(R.string.settings_key_light_theme)))
|
||||
{
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
}
|
||||
else if(o.toString().equals(getResources().getString(R.string.settings_key_dark_theme)))
|
||||
{
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||
}
|
||||
|
||||
getActivity().recreate();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,7 +362,8 @@
|
||||
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/inputBackground">
|
||||
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:padding="10.0dip"
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
android:id="@+id/store"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/storeNameTextSize"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
|
||||
18
app/src/main/res/values-night/colors.xml
Normal file
18
app/src/main/res/values-night/colors.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Palette generated by Material IO https://material.io/color/#!/?view.left=0&view.right=0&primary.color=3F51B5&secondary.color=FFC107 -->
|
||||
<!-- Colors manually flipped to dark variants -->
|
||||
<resources>
|
||||
<color name="colorPrimary">#3f51b5</color>
|
||||
<color name="colorPrimaryLight">#757de8</color>
|
||||
<color name="colorPrimaryDark">#002984</color>
|
||||
<color name="colorSecondary">#ffc107</color>
|
||||
<color name="colorSecondaryLight">#fff350</color>
|
||||
<color name="colorSecondaryDark">#c79100</color>
|
||||
<color name="colorPrimaryText">#000000</color>
|
||||
<color name="colorSecondaryText">#ffffff</color>
|
||||
|
||||
<color name="inputContrastBackground">#070707</color>
|
||||
<color name="inputBackground">#000000</color>
|
||||
<color name="inputBorder">#222222</color>
|
||||
<color name="inputDividerBorder">#666666</color>
|
||||
</resources>
|
||||
@@ -1,5 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="theme_values">
|
||||
<item>@string/settings_key_system_theme</item>
|
||||
<item>@string/settings_key_light_theme</item>
|
||||
<item>@string/settings_key_dark_theme</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="theme_value_strings">
|
||||
<item>@string/settings_system_theme</item>
|
||||
<item>@string/settings_light_theme</item>
|
||||
<item>@string/settings_dark_theme</item>
|
||||
</string-array>
|
||||
|
||||
<array name="letter_tile_colors">
|
||||
<item>#f16364</item>
|
||||
<item>#f58559</item>
|
||||
|
||||
@@ -114,6 +114,14 @@
|
||||
|
||||
<string name="settings">Settings</string>
|
||||
<string name="settings_category_title_ui">User interface</string>
|
||||
<string name="settings_theme">Theme</string>
|
||||
<string name="settings_key_theme" translatable="false">pref_theme</string>
|
||||
<string name="settings_system_theme">System theme</string>
|
||||
<string name="settings_key_system_theme" translatable="false">system</string>
|
||||
<string name="settings_light_theme">Light theme</string>
|
||||
<string name="settings_key_light_theme" translatable="false">light</string>
|
||||
<string name="settings_dark_theme">Dark theme</string>
|
||||
<string name="settings_key_dark_theme" translatable="false">dark</string>
|
||||
<string name="settings_card_title_list_font_size">Card title list font size</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">Card note list font size</string>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_category_title_ui">
|
||||
|
||||
<ListPreference
|
||||
android:key="@string/settings_key_theme"
|
||||
android:title="@string/settings_theme"
|
||||
android:defaultValue="@string/settings_key_system_theme"
|
||||
android:entries="@array/theme_value_strings"
|
||||
android:entryValues="@array/theme_values"/>
|
||||
|
||||
<com.vanniktech.vntnumberpickerpreference.VNTNumberPickerPreference
|
||||
android:key="@string/settings_key_card_title_list_font_size"
|
||||
android:title="@string/settings_card_title_list_font_size"
|
||||
|
||||
Reference in New Issue
Block a user