diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index dc1cf897d..98a72b6a2 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -344,8 +344,7 @@ + android:theme="@style/Tasks" /> items; - public static final String BEAST_MODE_ORDER_PREF = "beast_mode_order"; //$NON-NLS-1$ + public static final String BEAST_MODE_ORDER_PREF = "beast_mode_order_v2"; //$NON-NLS-1$ public static final String BEAST_MODE_PREF_ITEM_SEPARATOR = ";"; //$NON-NLS-1$ diff --git a/src/main/java/org/tasks/preferences/BasicPreferences.java b/src/main/java/org/tasks/preferences/BasicPreferences.java index 64f764342..1f7c84dbb 100644 --- a/src/main/java/org/tasks/preferences/BasicPreferences.java +++ b/src/main/java/org/tasks/preferences/BasicPreferences.java @@ -1,12 +1,18 @@ package org.tasks.preferences; +import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import org.tasks.R; import org.tasks.injection.InjectingPreferenceActivity; +import javax.inject.Inject; + public class BasicPreferences extends InjectingPreferenceActivity { + @Inject DeviceInfo deviceInfo; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -14,6 +20,14 @@ public class BasicPreferences extends InjectingPreferenceActivity { String action = getIntent().getAction(); if (action == null) { addPreferencesFromResource(R.xml.preferences); + findPreference(getString(R.string.contact_developer)).setIntent( + new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "Alex Baker", null)) {{ + putExtra(Intent.EXTRA_SUBJECT, "Tasks Feedback"); + putExtra(Intent.EXTRA_TEXT, deviceInfo.getDebugInfo()); + }}); + if (!deviceInfo.isPlayStoreAvailable()) { + getPreferenceScreen().removePreference(findPreference(getString(R.string.rate_tasks))); + } } else if (action.equals(getString(R.string.EPr_appearance_header))) { toolbar.setTitle(getString(R.string.EPr_appearance_header)); addPreferencesFromResource(R.xml.preferences_appearance); diff --git a/src/main/java/org/tasks/preferences/DeviceInfo.java b/src/main/java/org/tasks/preferences/DeviceInfo.java new file mode 100644 index 000000000..a6bd424ef --- /dev/null +++ b/src/main/java/org/tasks/preferences/DeviceInfo.java @@ -0,0 +1,87 @@ +package org.tasks.preferences; + +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.os.Build; + +import com.google.api.client.repackaged.com.google.common.base.Joiner; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tasks.BuildConfig; +import org.tasks.injection.ForApplication; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import static java.util.Arrays.asList; + +@Singleton +public class DeviceInfo { + + private static final Logger log = LoggerFactory.getLogger(DeviceInfo.class); + + private Context context; + private Boolean isPlayStoreAvailable; + private String debugInfo; + + @Inject + public DeviceInfo(@ForApplication Context context) { + this.context = context; + } + + public boolean isPlayStoreAvailable() { + if (isPlayStoreAvailable == null) { + isPlayStoreAvailable = checkForPlayStore(); + } + + return isPlayStoreAvailable; + } + + public String getDebugInfo() { + if (debugInfo == null) { + debugInfo = buildDebugString(); + } + + return debugInfo; + } + + private String buildDebugString() { + try { + return Joiner.on("\n").join(asList( + "", + "", + "----------", + "Tasks: " + BuildConfig.VERSION_NAME + " (build " + BuildConfig.VERSION_CODE + ")", + "Android: " + Build.VERSION.RELEASE, + "Model: " + Build.MANUFACTURER + " " + Build.MODEL, + "Product: " + Build.PRODUCT + " (" + Build.DEVICE + ")", + "Kernel: " + System.getProperty("os.version") + " (" + Build.VERSION.INCREMENTAL + ")", + "----------", + "", + "" + )); + } catch(Exception e) { + log.error(e.getMessage(), e); + } + return ""; + } + + private boolean checkForPlayStore() { + try { + PackageManager packageManager = context.getPackageManager(); + List packages = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES); + for (PackageInfo packageInfo : packages) { + if ("com.google.market".equals(packageInfo.packageName) || "com.android.vending".equals(packageInfo.packageName)) { + return true; + } + } + } catch(Exception e) { + log.error(e.getMessage(), e); + } + return false; + } +} diff --git a/src/main/java/org/tasks/preferences/Preferences.java b/src/main/java/org/tasks/preferences/Preferences.java index 20ee613fc..1be6a4186 100644 --- a/src/main/java/org/tasks/preferences/Preferences.java +++ b/src/main/java/org/tasks/preferences/Preferences.java @@ -62,10 +62,6 @@ public class Preferences { return getBoolean(WidgetConfigActivity.PREF_DARK_THEME + widgetId, legacySetting); } - public SharedPreferences getPrefs() { - return prefs; - } - public void clear() { prefs .edit() diff --git a/src/main/res/values/keys.xml b/src/main/res/values/keys.xml index 0caf8eb11..d47ccde90 100644 --- a/src/main/res/values/keys.xml +++ b/src/main/res/values/keys.xml @@ -57,7 +57,6 @@ p_calendar_reminder - p_show_my_tasks_f p_show_today_f p_show_recently_modified_f p_show_no_list_f diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 26c18eaca..d771ac1b5 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -82,6 +82,12 @@ Enabled Font size Customize edit screen + Source code + Translations + Report an issue + Help & Feedback + Contact developer + Rate Tasks diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 0aec43e6f..9b14fc1a7 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -45,4 +45,38 @@ android:targetPackage="org.tasks" /> + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/res/xml/preferences_appearance.xml b/src/main/res/xml/preferences_appearance.xml index 82f97565d..a4c7e298c 100644 --- a/src/main/res/xml/preferences_appearance.xml +++ b/src/main/res/xml/preferences_appearance.xml @@ -46,11 +46,6 @@ -