From ef3c6c62c327938335bf923d3d1e4e1300ebfac4 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Thu, 10 Dec 2015 01:39:47 -0500 Subject: [PATCH] Prompt user to install SIA if not installed and they try enabling the setting --- .../transaction/NotificationManager.java | 4 +++ .../QKSMS/ui/settings/SettingsFragment.java | 26 +++++++++++++++++++ QKSMS/src/main/res/values/strings.xml | 2 ++ 3 files changed, 32 insertions(+) diff --git a/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java b/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java index d1d0bedf..e0b6c88a 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java @@ -665,6 +665,10 @@ public class NotificationManager { */ public static void initQuickCompose(Context context, boolean override, boolean overrideCancel) { + if (sPrefs == null) { + init(context); + } + if (sPrefs.getBoolean(SettingsFragment.QUICKCOMPOSE, false) || override) { Intent composeIntent = new Intent(context, QKComposeActivity.class); PendingIntent composePI = PendingIntent.getActivity(context, 9, composeIntent, PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java index bc369add..9521a806 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java @@ -12,6 +12,8 @@ import android.content.res.Resources; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.Handler; +import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; @@ -36,6 +38,7 @@ import com.moez.QKSMS.common.ListviewHelper; import com.moez.QKSMS.common.LiveViewManager; import com.moez.QKSMS.common.utils.DateFormatter; import com.moez.QKSMS.common.utils.KeyboardUtils; +import com.moez.QKSMS.common.utils.PackageUtils; import com.moez.QKSMS.interfaces.LiveView; import com.moez.QKSMS.receiver.NightModeAutoReceiver; import com.moez.QKSMS.transaction.EndlessJabber; @@ -531,6 +534,29 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O case BLOCKED_FUTURE: BlockedNumberDialog.showDialog(mContext); break; + case SHOULD_I_ANSWER: + final String packageName = "org.mistergroup.muzutozvednout"; + if (!PackageUtils.isAppInstalled(mContext, packageName)) { + new QKDialog() + .setContext(mContext) + .setTitle(R.string.dialog_should_i_answer_title) + .setMessage(R.string.dialog_should_i_answer_message) + .setNegativeButton(R.string.cancel, null) + .setPositiveButton(R.string.okay, v -> { + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName))); + } catch (android.content.ActivityNotFoundException anfe) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName))); + } + }) + .show(); + + new Handler().postDelayed(() -> { + mPrefs.edit().putBoolean(SHOULD_I_ANSWER, false).commit(); + ((CheckBoxPreference) preference).setChecked(false); + }, 500); + } + break; case NOTIFICATION_LED_COLOR: mLedColorPickerDialog.show(getActivity().getFragmentManager(), "colorpicker"); break; diff --git a/QKSMS/src/main/res/values/strings.xml b/QKSMS/src/main/res/values/strings.xml index 3db9621e..a59920a7 100644 --- a/QKSMS/src/main/res/values/strings.xml +++ b/QKSMS/src/main/res/values/strings.xml @@ -577,6 +577,8 @@ Last message date Message count Recipients (%s) + Should I Answer? not installed + Would you like to download the app from Google Play now? Choose audio