diff --git a/app/build.gradle b/app/build.gradle index 0932bbfcb..571011414 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,7 @@ android { 'arm64-v8a', 'mips', 'mips64' } - buildConfigField "String[]", "ICON_PACK_ARRAY", "{\"classic\",\"material\"}" + buildConfigField "String[]", "ICON_PACKS", "{\"classic\",\"material\"}" } externalNativeBuild { @@ -47,18 +47,25 @@ android { versionNameSuffix "-libre" buildConfigField "boolean", "FULL_VERSION", "true" buildConfigField "boolean", "CLOSED_STORE", "false" + buildConfigField "String[]", "STYLES_DISABLED", "{\"KeepassDXStyle_Dark\",\"KeepassDXStyle_Purple\"}" + buildConfigField "String[]", "ICON_PACKS_DISABLED", "{}" + } pro { applicationIdSuffix = ".pro" versionNameSuffix "-pro" buildConfigField "boolean", "FULL_VERSION", "true" buildConfigField "boolean", "CLOSED_STORE", "true" + buildConfigField "String[]", "STYLES_DISABLED", "{}" + buildConfigField "String[]", "ICON_PACKS_DISABLED", "{}" } free { applicationIdSuffix = ".free" versionNameSuffix "-free" buildConfigField "boolean", "FULL_VERSION", "false" buildConfigField "boolean", "CLOSED_STORE", "true" + buildConfigField "String[]", "STYLES_DISABLED", "{\"KeepassDXStyle_Dark\",\"KeepassDXStyle_Blue\",\"KeepassDXStyle_Purple\"}" + buildConfigField "String[]", "ICON_PACKS_DISABLED", "{\"material\"}" } } @@ -105,6 +112,5 @@ dependencies { implementation 'com.google.guava:guava:23.0-android' // Icon pack, classic for all, material for libre and pro implementation project(path: ':icon-pack-classic') - libreImplementation project(path: ':icon-pack-material') - proImplementation project(path: ':icon-pack-material') + implementation project(path: ':icon-pack-material') } diff --git a/app/src/main/java/com/kunzisoft/keepass/dialogs/ProFeatureDialogFragment.java b/app/src/main/java/com/kunzisoft/keepass/dialogs/ProFeatureDialogFragment.java new file mode 100644 index 000000000..5784fa7ca --- /dev/null +++ b/app/src/main/java/com/kunzisoft/keepass/dialogs/ProFeatureDialogFragment.java @@ -0,0 +1,74 @@ +/* + * Copyright 2018 Jeremy Jamet / Kunzisoft. + * + * This file is part of KeePass DX. + * + * KeePass DX is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * KeePass DX is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KeePass DX. If not, see . + * + */ +package com.kunzisoft.keepass.dialogs; + +import android.app.Dialog; +import android.content.ActivityNotFoundException; +import android.os.Bundle; +import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; +import android.text.Html; +import android.text.SpannableStringBuilder; +import android.widget.Toast; + +import com.kunzisoft.keepass.BuildConfig; +import com.kunzisoft.keepass.R; +import com.kunzisoft.keepass.utils.Util; + +/** + * Custom Dialog that asks the user to download the pro version or make a donation. + */ +public class ProFeatureDialogFragment extends DialogFragment { + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + // Use the Builder class for convenient dialog construction + assert getActivity() != null; + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + + SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); + if (BuildConfig.CLOSED_STORE) { + stringBuilder.append(Html.fromHtml(getString(R.string.html_text_ad_free))).append("\n\n"); + stringBuilder.append(Html.fromHtml(getString(R.string.html_text_buy_pro))); + builder.setPositiveButton(R.string.download, (dialog, id) -> { + try { + Util.gotoUrl(getContext(), R.string.app_pro_url); + } catch (ActivityNotFoundException e) { + Toast.makeText(getContext(), R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show(); + } + }); + } + else { + stringBuilder.append(Html.fromHtml(getString(R.string.html_text_feature_generosity))).append("\n\n"); + stringBuilder.append(Html.fromHtml(getString(R.string.html_text_donation))); + builder.setPositiveButton(R.string.contribute, (dialog, id) -> { + try { + Util.gotoUrl(getContext(), R.string.donate_url); + } catch (ActivityNotFoundException e) { + Toast.makeText(getContext(), R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show(); + } + }); + } + builder.setMessage(stringBuilder); + builder.setNegativeButton(android.R.string.cancel, (dialog, id) -> dismiss()); + // Create the AlertDialog object and return it + return builder.create(); + } +} diff --git a/app/src/main/java/com/kunzisoft/keepass/fileselect/FileSelectActivity.java b/app/src/main/java/com/kunzisoft/keepass/fileselect/FileSelectActivity.java index ecac6519c..a8b5a6dcf 100644 --- a/app/src/main/java/com/kunzisoft/keepass/fileselect/FileSelectActivity.java +++ b/app/src/main/java/com/kunzisoft/keepass/fileselect/FileSelectActivity.java @@ -337,7 +337,7 @@ public class FileSelectActivity extends StylishActivity implements TapTarget.forView(openButtonView, getString(R.string.education_open_link_database_title), getString(R.string.education_open_link_database_summary)) - .tintTarget(false) + .tintTarget(true) .cancelable(true), new TapTargetView.Listener() { @Override diff --git a/app/src/main/java/com/kunzisoft/keepass/icons/IconPack.java b/app/src/main/java/com/kunzisoft/keepass/icons/IconPack.java index e0909568f..96cecae7c 100644 --- a/app/src/main/java/com/kunzisoft/keepass/icons/IconPack.java +++ b/app/src/main/java/com/kunzisoft/keepass/icons/IconPack.java @@ -31,8 +31,8 @@ import java.text.DecimalFormat; /** * Class who construct dynamically database icons contains in a separate library * - *

It only supports icons with specific nomenclature [prefix][%2d]_32dp - * where [prefix] contains in a string xml attribute with id resource_prefix and + *

It only supports icons with specific nomenclature [stringId]_[%2d]_32dp + * where [stringId] contains in a string xml attribute with id resource_id and * [%2d] 2 numerical numbers between 00 and 68 included, *

*

See icon-pack-classic module as sample @@ -44,39 +44,42 @@ public class IconPack { private static final int NB_ICONS = 68; private SparseIntArray icons; - private String resourcePrefix; + private String resourceStringId; private String name; private boolean tintable; private Resources resources; /** - * Construct dynamically the icon pack provide by the string resource prefix + * Construct dynamically the icon pack provide by the string resource id * * @param context Context of the app to retrieve the resources - * @param resourcePrefixId Id of the string prefix of the pack (ex : com.kunzisoft.keepass.icon.classic.R.string.resource_prefix) + * @param resourceId String Id of the pack (ex : com.kunzisoft.keepass.icon.classic.R.string.resource_id) */ - IconPack(Context context, int resourcePrefixId) { + IconPack(Context context, int resourceId) { resources = context.getResources(); icons = new SparseIntArray(); - resourcePrefix = context.getString(resourcePrefixId); + resourceStringId = context.getString(resourceId); + // If finish with a _ remove it + if (resourceStringId.lastIndexOf('_') == resourceStringId.length() - 1) + resourceStringId = resourceStringId.substring(0, resourceStringId.length() -1); // Build the list of icons int num = 0; while(num <= NB_ICONS) { - // To construct the id with prefix_ic_XX_32dp (ex : classic_ic_08_32dp ) + // To construct the id with name_ic_XX_32dp (ex : classic_ic_08_32dp ) int resId = resources.getIdentifier( - resourcePrefix + new DecimalFormat("00").format(num) + "_32dp", + resourceStringId + "_" + new DecimalFormat("00").format(num) + "_32dp", "drawable", context.getPackageName()); icons.put(num, resId); num++; } - // Get name + // Get visual name name = resources.getString( resources.getIdentifier( - resourcePrefix + "name", + resourceStringId + "_" + "name", "string", context.getPackageName() ) @@ -84,7 +87,7 @@ public class IconPack { // If icons are tintable tintable = resources.getBoolean( resources.getIdentifier( - resourcePrefix + "tintable", + resourceStringId + "_" + "tintable", "bool", context.getPackageName() ) @@ -106,7 +109,7 @@ public class IconPack { * @return String id of the pack */ public String getId() { - return resourcePrefix; + return resourceStringId; } /** diff --git a/app/src/main/java/com/kunzisoft/keepass/icons/IconPackChooser.java b/app/src/main/java/com/kunzisoft/keepass/icons/IconPackChooser.java index 2ac99b702..32967bea5 100644 --- a/app/src/main/java/com/kunzisoft/keepass/icons/IconPackChooser.java +++ b/app/src/main/java/com/kunzisoft/keepass/icons/IconPackChooser.java @@ -57,7 +57,7 @@ public class IconPackChooser { * *

Dynamic import can be done for each flavor by prefixing the 'implementation' command with the name of the flavor.< br/> * (ex : {@code libreImplementation project(path: ':icon-pack-classic')}
- * Each name of icon pack must be in {@code ICON_PACK_ARRAY} in the build.gradle file

+ * Each name of icon pack must be in {@code ICON_PACKS} in the build.gradle file

* * @param context Context to construct each pack with the resources * @return An unique instance of {@link IconPackChooser}, recall {@link #build(Context)} provide the same instance @@ -69,7 +69,7 @@ public class IconPackChooser { if (sIconPackBuilder == null) { sIconPackBuilder = new IconPackChooser(); - for (String iconPackString : BuildConfig.ICON_PACK_ARRAY) { + for (String iconPackString : BuildConfig.ICON_PACKS) { addOrCatchNewIconPack(context, iconPackString); } if (iconPackList.isEmpty()) { @@ -84,11 +84,11 @@ public class IconPackChooser { } /** - * Construct dynamically the icon pack provide by the default string resource "resource_prefix" + * Construct dynamically the icon pack provide by the default string resource "resource_id" */ private static void addDefaultIconPack(Context context) { - int resourcePrefixId = context.getResources().getIdentifier("resource_prefix", "string", context.getPackageName()); - iconPackList.add(new IconPack(context, resourcePrefixId)); + int resourceId = context.getResources().getIdentifier("resource_id", "string", context.getPackageName()); + iconPackList.add(new IconPack(context, resourceId)); } /** @@ -97,7 +97,7 @@ public class IconPackChooser { private static void addOrCatchNewIconPack(Context context, String iconPackString) { try { iconPackList.add(new IconPack(context, context.getResources().getIdentifier( - iconPackString + "_resource_prefix", + iconPackString + "_resource_id", "string", context.getPackageName()))); } catch (Exception e) { @@ -129,9 +129,13 @@ public class IconPackChooser { } /** - * @return Get the list of IconPack available + * Get the list of IconPack available + * + * @param context Context to build the icon pack if not already build + * @return IconPack available */ - public static List getIconPackList() { + public static List getIconPackList(Context context) { + build(context); return iconPackList; } } diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/NestedSettingsFragment.java b/app/src/main/java/com/kunzisoft/keepass/settings/NestedSettingsFragment.java index 7bf22cd2d..8bdca8e49 100644 --- a/app/src/main/java/com/kunzisoft/keepass/settings/NestedSettingsFragment.java +++ b/app/src/main/java/com/kunzisoft/keepass/settings/NestedSettingsFragment.java @@ -41,9 +41,11 @@ import android.util.Log; import android.view.autofill.AutofillManager; import android.widget.Toast; +import com.kunzisoft.keepass.BuildConfig; import com.kunzisoft.keepass.R; import com.kunzisoft.keepass.app.App; import com.kunzisoft.keepass.database.Database; +import com.kunzisoft.keepass.dialogs.ProFeatureDialogFragment; import com.kunzisoft.keepass.dialogs.StorageAccessFrameworkDialog; import com.kunzisoft.keepass.dialogs.UnavailableFeatureDialogFragment; import com.kunzisoft.keepass.fingerprint.FingerPrintHelper; @@ -140,8 +142,17 @@ public class NestedSettingsFragment extends PreferenceFragmentCompat Preference stylePreference = findPreference(getString(R.string.setting_style_key)); stylePreference.setOnPreferenceChangeListener((preference, newValue) -> { - String styleString = (String) newValue; - Stylish.assignStyle(styleString); + String styleIdString = (String) newValue; + for (String themeIdDisabled : BuildConfig.STYLES_DISABLED) { + if (themeIdDisabled.equals(styleIdString)) { + ProFeatureDialogFragment dialogFragment = new ProFeatureDialogFragment(); + if (getFragmentManager() != null) + dialogFragment.show(getFragmentManager(), "pro_feature_dialog"); + return false; + } + } + + Stylish.assignStyle(styleIdString); if (getActivity() != null) getActivity().recreate(); return true; @@ -149,7 +160,17 @@ public class NestedSettingsFragment extends PreferenceFragmentCompat Preference iconPackPreference = findPreference(getString(R.string.setting_icon_pack_choose_key)); iconPackPreference.setOnPreferenceChangeListener((preference, newValue) -> { - IconPackChooser.setSelectedIconPack((String) newValue); + String iconPackId = (String) newValue; + for (String iconPackIdDisabled : BuildConfig.ICON_PACKS_DISABLED) { + if (iconPackIdDisabled.equals(iconPackId)) { + ProFeatureDialogFragment dialogFragment = new ProFeatureDialogFragment(); + if (getFragmentManager() != null) + dialogFragment.show(getFragmentManager(), "pro_feature_dialog"); + return false; + } + } + + IconPackChooser.setSelectedIconPack(iconPackId); return true; }); diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/preference/IconPackListPreference.java b/app/src/main/java/com/kunzisoft/keepass/settings/preference/IconPackListPreference.java index a4a76d9ca..ea9f4c787 100644 --- a/app/src/main/java/com/kunzisoft/keepass/settings/preference/IconPackListPreference.java +++ b/app/src/main/java/com/kunzisoft/keepass/settings/preference/IconPackListPreference.java @@ -30,7 +30,7 @@ public class IconPackListPreference extends ListPreference { List entries = new ArrayList<>(); List values = new ArrayList<>(); - for (IconPack iconPack : IconPackChooser.getIconPackList()) { + for (IconPack iconPack : IconPackChooser.getIconPackList(context)) { entries.add(iconPack.getName()); values.add(iconPack.getId()); } diff --git a/app/src/main/res/layout/file_row.xml b/app/src/main/res/layout/file_row.xml index a44cc4288..88acb82e7 100644 --- a/app/src/main/res/layout/file_row.xml +++ b/app/src/main/res/layout/file_row.xml @@ -27,11 +27,11 @@ android:id="@+id/file_filename" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" android:layout_centerVertical="true" - android:layout_toLeftOf="@+id/file_information" - android:layout_toStartOf="@+id/file_information" + android:layout_toRightOf="@+id/file_information" + android:layout_toEndOf="@+id/file_information" android:paddingBottom="18dp" android:paddingEnd="18dp" android:paddingLeft="18dp" @@ -45,7 +45,7 @@ android:layout_centerVertical="true" android:padding="18dp" android:src="@drawable/ic_info_white_24dp" - android:layout_alignParentRight="true" - android:layout_alignParentEnd="true" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" android:tint="?android:attr/textColorPrimary"/> \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3a08893e3..483a2bc86 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -283,6 +283,13 @@ Participez Participer pour augmenter la stabilité, la sécurité et ajouter plus de fonctionnalités. + Contrairement à d\'autres applications de gestion de mots de passe, cette application est <strong>sans publicité</strong>, <strong>open source</strong> et ne récupère pas de données personnelles sur ses serveurs, même dans sa version gratuite. + En achetant la version pro, vous accéderez à cette <strong>fonctionnalité</strong> et bien plus et vous aiderez en particulier à <strong>la réalisation de projets communautaires.</strong> + Cette <strong>fonctionnalité</strong> et bien plus sont disponlibles grâce à votre générosité. + Afin de garder notre liberté et d\'être toujours actif, nous comptons sur votre <strong>contribution.</strong> + Télécharger + Contribuer + 5 secondes 10 secondes diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 5a1f8d717..4b0d80b43 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -20,6 +20,7 @@ KeePass DX + https://play.google.com/store/apps/details?id=com.kunzisoft.keepass.pro http://code.google.com/p/android/issues/detail?id=35732 https://www.kunzisoft.com/donation https://www.kunzisoft.com/KeepassDX/ @@ -151,7 +152,8 @@ @string/list_style_name_blue @string/list_style_name_purple - @string/classic_resource_prefix + + @string/classic_resource_id list_password_generator_options_key value_password_uppercase diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 46ff89ff4..3b19eb81d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -287,6 +287,13 @@ Participate Participate to increase the stability, the security and to add more features. + Unlike many password management applications, this app is <strong>ad-free</strong>, <strong>open source</strong> and does not recover personal data on its servers, even in its free version. + By buying the pro version, you will have access to this <strong>feature</strong> and many more and you will help especially to <strong>the realization of community projects.</strong> + This <strong>feature</strong> and many more are available thanks to your generosity. + In order to keep our freedom and to be always active, we count on your <strong>contribution.</strong> + Download + Contribute + 5 seconds 10 seconds diff --git a/icon-pack-classic/src/main/res/values/strings.xml b/icon-pack-classic/src/main/res/values/strings.xml index ff2880671..0759533b1 100644 --- a/icon-pack-classic/src/main/res/values/strings.xml +++ b/icon-pack-classic/src/main/res/values/strings.xml @@ -20,7 +20,7 @@ Classic Icon Pack - classic_ - @string/classic_resource_prefix + classic + @string/classic_resource_id false diff --git a/icon-pack-material/src/main/res/values/strings.xml b/icon-pack-material/src/main/res/values/strings.xml index 9c5f2f143..91a08bd18 100644 --- a/icon-pack-material/src/main/res/values/strings.xml +++ b/icon-pack-material/src/main/res/values/strings.xml @@ -20,7 +20,7 @@ Material Icon Pack - material_ - @string/material_resource_prefix + material + @string/material_resource_id true