diff --git a/src/generic/AndroidManifest.xml b/src/generic/AndroidManifest.xml
index 88f3c863f..562d64975 100644
--- a/src/generic/AndroidManifest.xml
+++ b/src/generic/AndroidManifest.xml
@@ -2,12 +2,6 @@
-
-
-
-
-
+
diff --git a/src/generic/java/org/tasks/activities/DonationActivity.java b/src/generic/java/org/tasks/activities/DonationActivity.java
deleted file mode 100644
index e46c15272..000000000
--- a/src/generic/java/org/tasks/activities/DonationActivity.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.tasks.activities;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-
-public class DonationActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://tasks.org/donate")));
- finish();
- }
-}
diff --git a/src/generic/java/org/tasks/preferences/BasicPreferences.java b/src/generic/java/org/tasks/preferences/BasicPreferences.java
index c74c0ba8a..52a9d01ea 100644
--- a/src/generic/java/org/tasks/preferences/BasicPreferences.java
+++ b/src/generic/java/org/tasks/preferences/BasicPreferences.java
@@ -1,7 +1,9 @@
package org.tasks.preferences;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
-import android.preference.PreferenceScreen;
+import android.preference.Preference;
import org.tasks.R;
import org.tasks.injection.ActivityComponent;
@@ -12,12 +14,17 @@ public class BasicPreferences extends BaseBasicPreferences {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- PreferenceScreen preferenceScreen = getPreferenceScreen();
- preferenceScreen.removePreference(findPreference(getString(R.string.synchronization)));
- preferenceScreen.removePreference(findPreference(getString(R.string.p_tesla_unread_enabled)));
- preferenceScreen.removePreference(findPreference(getString(R.string.p_purchased_tasker)));
- preferenceScreen.removePreference(findPreference(getString(R.string.p_purchased_dashclock)));
- preferenceScreen.removePreference(findPreference(getString(R.string.p_collect_statistics)));
+ getPref(R.string.TLA_menu_donate).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://tasks.org/donate")));
+ return false;
+ }
+ });
+
+ requires(false, R.string.synchronization);
+ requires(R.string.get_plugins, false, R.string.p_tesla_unread_enabled, R.string.p_purchased_tasker, R.string.p_purchased_dashclock);
+ requires(R.string.privacy, false, R.string.p_collect_statistics);
}
@Override
diff --git a/src/googleplay/AndroidManifest.xml b/src/googleplay/AndroidManifest.xml
index 8cea210bb..de8c6d3a5 100644
--- a/src/googleplay/AndroidManifest.xml
+++ b/src/googleplay/AndroidManifest.xml
@@ -38,10 +38,6 @@
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBq82FiK4U8Ke2TV_F8UjDZwgtSy8K9cyQ"/>
-
-
values = new ArrayList<>();
- for (int i = 1 ; i <= 100 ; i++) {
- values.add(String.format("$%s USD", Integer.toString(i)));
- }
- return values.toArray(new String[values.size()]);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == RC_REQUEST) {
- purchaseHelper.handleActivityResult(this, requestCode, resultCode, data);
- } else {
- super.onActivityResult(requestCode, resultCode, data);
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- if (!isChangingConfigurations()) {
- purchaseHelper.disposeIabHelper();
- }
- }
-
- @Override
- public void purchaseCompleted(boolean success, String sku) {
- finish();
- }
-}
diff --git a/src/googleplay/java/org/tasks/preferences/BasicPreferences.java b/src/googleplay/java/org/tasks/preferences/BasicPreferences.java
index 19450331c..337290759 100644
--- a/src/googleplay/java/org/tasks/preferences/BasicPreferences.java
+++ b/src/googleplay/java/org/tasks/preferences/BasicPreferences.java
@@ -1,5 +1,6 @@
package org.tasks.preferences;
+import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
@@ -15,6 +16,12 @@ import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.ActivityComponent;
import org.tasks.receivers.TeslaUnreadReceiver;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import javax.inject.Inject;
import timber.log.Timber;
@@ -35,6 +42,29 @@ public class BasicPreferences extends BaseBasicPreferences implements PurchaseHe
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ getPref(R.string.TLA_menu_donate).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ final String[] donationValues = getDonationValues();
+ dialogBuilder.newDialog()
+ .setTitle(R.string.select_amount)
+ .setItems(donationValues, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String value = donationValues[which];
+ Pattern pattern = Pattern.compile("\\$(\\d+) USD");
+ Matcher matcher = pattern.matcher(value);
+ //noinspection ResultOfMethodCallIgnored
+ matcher.matches();
+ String sku = String.format(Locale.ENGLISH, "%03d", Integer.parseInt(matcher.group(1)));
+ purchaseHelper.purchase(dialogBuilder, BasicPreferences.this, sku, null, REQUEST_PURCHASE, BasicPreferences.this);
+ }
+ })
+ .show();
+ return false;
+ }
+ });
+
getPref(R.string.p_tesla_unread_enabled).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -60,21 +90,15 @@ public class BasicPreferences extends BaseBasicPreferences implements PurchaseHe
}
});
- Preference dashClock = getPref(R.string.p_purchased_dashclock);
- if (atLeastJellybeanMR1()) {
- dashClock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (newValue != null && (boolean) newValue && !preferences.hasPurchase(R.string.p_purchased_dashclock)) {
- purchaseHelper.purchase(dialogBuilder, BasicPreferences.this, getString(R.string.sku_dashclock), getString(R.string.p_purchased_dashclock), REQUEST_PURCHASE, BasicPreferences.this);
- }
- return false;
+ getPref(R.string.p_purchased_dashclock).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (newValue != null && (boolean) newValue && !preferences.hasPurchase(R.string.p_purchased_dashclock)) {
+ purchaseHelper.purchase(dialogBuilder, BasicPreferences.this, getString(R.string.sku_dashclock), getString(R.string.p_purchased_dashclock), REQUEST_PURCHASE, BasicPreferences.this);
}
- });
- } else {
- PreferenceCategory iapCategory = (PreferenceCategory) findPreference(getString(R.string.get_plugins));
- iapCategory.removePreference(dashClock);
- }
+ return false;
+ }
+ });
findPreference(getString(R.string.p_collect_statistics)).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
@@ -108,6 +132,8 @@ public class BasicPreferences extends BaseBasicPreferences implements PurchaseHe
}
});
}
+
+ requires(R.string.get_plugins, atLeastJellybeanMR1(), R.string.p_purchased_dashclock);
}
@Override
@@ -136,7 +162,7 @@ public class BasicPreferences extends BaseBasicPreferences implements PurchaseHe
} else if (getString(R.string.sku_dashclock).equals(sku)) {
((TwoStatePreference) getPref(R.string.p_purchased_dashclock)).setChecked(success);
} else {
- Timber.e("Unhandled sku: %s", sku);
+ Timber.d("Unhandled sku: %s", sku);
}
}
});
@@ -151,7 +177,11 @@ public class BasicPreferences extends BaseBasicPreferences implements PurchaseHe
}
}
- private Preference getPref(int resId) {
- return findPreference(getString(resId));
+ private String[] getDonationValues() {
+ List values = new ArrayList<>();
+ for (int i = 1 ; i <= 100 ; i++) {
+ values.add(String.format("$%s USD", Integer.toString(i)));
+ }
+ return values.toArray(new String[values.size()]);
}
}
diff --git a/src/main/java/org/tasks/injection/BaseActivityComponent.java b/src/main/java/org/tasks/injection/BaseActivityComponent.java
index 146c431f3..0ed9f2b97 100644
--- a/src/main/java/org/tasks/injection/BaseActivityComponent.java
+++ b/src/main/java/org/tasks/injection/BaseActivityComponent.java
@@ -26,7 +26,6 @@ import org.tasks.activities.DatePickerActivity;
import org.tasks.activities.DeleteAllCalendarEventsActivity;
import org.tasks.activities.DeleteCompletedActivity;
import org.tasks.activities.DeleteCompletedEventsActivity;
-import org.tasks.activities.DonationActivity;
import org.tasks.activities.ExportTaskActivity;
import org.tasks.activities.FilterSelectionActivity;
import org.tasks.activities.ImportTaskActivity;
@@ -114,8 +113,6 @@ public interface BaseActivityComponent {
void inject(VoiceCommandActivity voiceCommandActivity);
- void inject(DonationActivity donationActivity);
-
void inject(ClearGtaskDataActivity clearGtaskDataActivity);
void inject(ReminderPreferences reminderPreferences);
diff --git a/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java b/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java
index 2cb123a33..81e55c326 100644
--- a/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java
+++ b/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java
@@ -2,6 +2,9 @@ package org.tasks.injection;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceCategory;
+import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.Toolbar;
@@ -69,12 +72,25 @@ public abstract class InjectingPreferenceActivity extends AppCompatPreferenceAct
tracker.showScreen(getClass().getSimpleName());
}
+ protected void requires(int prefGroup, boolean passesCheck, int... resIds) {
+ if (!passesCheck) {
+ remove((PreferenceCategory) findPreference(getString(prefGroup)), resIds);
+ }
+ }
+
protected void requires(boolean passesCheck, int... resIds) {
if (!passesCheck) {
- PreferenceScreen preferenceScreen = getPreferenceScreen();
- for (int resId : resIds) {
- preferenceScreen.removePreference(findPreference(getString(resId)));
- }
+ remove(getPreferenceScreen(), resIds);
}
}
+
+ private void remove(PreferenceGroup preferenceGroup, int[] resIds) {
+ for (int resId : resIds) {
+ preferenceGroup.removePreference(getPref(resId));
+ }
+ }
+
+ protected Preference getPref(int resId) {
+ return findPreference(getString(resId));
+ }
}
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 0c7da132f..4061174b3 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -858,7 +858,7 @@ File %1$s contained %2$s.\n\n
(No title)
Back button saves task
Default list
- Tasks is an open source project maintained by a single developer. Niche features are offered as in-app purchases in order to support their development.
+ Tasks is an open source project maintained by one developer. Some features are offered as in-app purchases in order to support development.
Display a badge for the number of active tasks in your default list. Requires TeslaUnread for Nova Launcher
Context-aware list notifications. Requires Tasker or Locale
Donations are greatly appreciated
diff --git a/src/main/res/xml/preferences_addons.xml b/src/main/res/xml/preferences_addons.xml
index 7180cdbd9..5b5ebe2b2 100644
--- a/src/main/res/xml/preferences_addons.xml
+++ b/src/main/res/xml/preferences_addons.xml
@@ -2,40 +2,36 @@
+ android:key="@string/get_plugins"
+ android:title="@string/get_plugins">
+ android:summary="@string/plugin_description" />
-
-
+ android:key="@string/TLA_menu_donate"
+ android:summary="@string/donate_summary"
+ android:title="@string/TLA_menu_donate" />
+ android:key="@string/p_purchased_dashclock"
+ android:summary="@string/dashclock_purchase_description"
+ android:title="@string/dashclock" />
+ android:key="@string/p_purchased_tasker"
+ android:summary="@string/tasker_description"
+ android:title="@string/tasker_locale" />
+ android:summary="@string/tesla_unread_description"
+ android:title="@string/tesla_unread" />
diff --git a/src/main/res/xml/preferences_privacy.xml b/src/main/res/xml/preferences_privacy.xml
index b35f9306e..6ca696606 100644
--- a/src/main/res/xml/preferences_privacy.xml
+++ b/src/main/res/xml/preferences_privacy.xml
@@ -1,7 +1,9 @@
-
+