diff --git a/QKSMS/build.gradle b/QKSMS/build.gradle index b7249429..9bc04125 100644 --- a/QKSMS/build.gradle +++ b/QKSMS/build.gradle @@ -30,8 +30,8 @@ android { buildToolsVersion '23.0.2' defaultConfig { - versionCode 119 - versionName "2.3.1" + versionCode 121 + versionName "2.4.1" minSdkVersion 15 targetSdkVersion 22 multiDexEnabled true diff --git a/QKSMS/src/main/AndroidManifest.xml b/QKSMS/src/main/AndroidManifest.xml index c926e8d6..a01f1a85 100644 --- a/QKSMS/src/main/AndroidManifest.xml +++ b/QKSMS/src/main/AndroidManifest.xml @@ -450,6 +450,13 @@ android:name=".receiver.UnreadBadgeService" android:exported="false" /> + + + + + + { + if (mCursor == null) { + // The pdu has probably loaded after shutting down the fragment. Don't try to bind anything now + return; + } if (messageItem1 != null && messageItem1.getMessageId() == messageItem1.getMessageId()) { messageItem1.setCachedFormattedMessage(null); bindGrouping(holder, messageItem); 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 f5c2f2d8..5d444a64 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; @@ -107,6 +110,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O public static final String BLOCKED_ENABLED = "pref_key_blocked_enabled"; public static final String BLOCKED_SENDERS = "pref_key_blocked_senders"; public static final String BLOCKED_FUTURE = "pref_key_block_future"; + public static final String SHOULD_I_ANSWER = "pref_key_should_i_answer"; public static final String MOBILE_ONLY = "pref_key_mobile_only"; public static final String COMPOSE_GROUP = "pref_key_compose_group"; public static final String SPLIT_SMS = "pref_key_split"; @@ -526,6 +530,30 @@ 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)) { + String referrer="referrer=utm_source%3Dqksms%26utm_medium%3Dapp%26utm_campaign%3Dqksmssettings"; + 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 + "&" + referrer))); + } catch (android.content.ActivityNotFoundException anfe) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName + "&" + referrer))); + } + }) + .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/java/org/mistergroup/muzutozvednout/ShouldIAnswerBinder.java b/QKSMS/src/main/java/org/mistergroup/muzutozvednout/ShouldIAnswerBinder.java new file mode 100644 index 00000000..8524f814 --- /dev/null +++ b/QKSMS/src/main/java/org/mistergroup/muzutozvednout/ShouldIAnswerBinder.java @@ -0,0 +1,98 @@ +package org.mistergroup.muzutozvednout; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.os.Bundle; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.Messenger; +import android.os.RemoteException; + +/** + * Created by Mister Group s.r.o. on 30.11.2015. + */ +public class ShouldIAnswerBinder { + public static final int RATING_UNKNOWN = 0; + public static final int RATING_POSITIVE = 1; + public static final int RATING_NEGATIVE = 2; + public static final int RATING_NEUTRAL = 3; + + private Callback callback; + public boolean isBound; + + public interface Callback { + void onNumberRating(String number, int rating); + + void onServiceConnected(); + + void onServiceDisconnected(); + } + + public void setCallback(Callback callback) { + this.callback = callback; + } + + public void bind(Context context) { + Intent intent=new Intent("org.mistergroup.muzutozvednout.PublicService"); + intent.setPackage("org.mistergroup.muzutozvednout"); + context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); + } + + public void unbind(Context context) { + if ((isBound) && (serviceMessenger != null)) { + context.unbindService(mConnection); + } + } + + public void getNumberRating(String number) throws RemoteException { + Message msg = new Message(); + msg.what = 1; + Bundle data = new Bundle(); + data.putString("number", number); + msg.setData(data); + msg.replyTo = messenger; + serviceMessenger.send(msg); + } + + private final Messenger messenger = new Messenger(new IncomingHandler()); + private static Messenger serviceMessenger = null; + + private ServiceConnection mConnection = new ServiceConnection() { + public void onServiceConnected(ComponentName className, IBinder service) { + serviceMessenger = new Messenger(service); + isBound = true; + if (callback != null) + callback.onServiceConnected(); + } + + public void onServiceDisconnected(ComponentName className) { + serviceMessenger = null; + isBound = false; + if (callback != null) + callback.onServiceDisconnected(); + } + }; + + private class IncomingHandler extends Handler { + static final int GET_NUMBER_RATING = 1; + + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case GET_NUMBER_RATING: + Bundle inData = msg.getData(); + String number = inData.getString("number"); + int rating = inData.getInt("rating"); + if (callback != null) + callback.onNumberRating(number, rating); + + break; + default: + super.handleMessage(msg); + } + } + } +} diff --git a/QKSMS/src/main/res/drawable/ic_accept.xml b/QKSMS/src/main/res/drawable/ic_accept.xml index 1d3d920b..f672338b 100644 --- a/QKSMS/src/main/res/drawable/ic_accept.xml +++ b/QKSMS/src/main/res/drawable/ic_accept.xml @@ -4,6 +4,6 @@ android:viewportHeight="24.0" android:viewportWidth="24.0"> diff --git a/QKSMS/src/main/res/drawable/ic_call.xml b/QKSMS/src/main/res/drawable/ic_call.xml index ebf9de60..28914c6f 100644 --- a/QKSMS/src/main/res/drawable/ic_call.xml +++ b/QKSMS/src/main/res/drawable/ic_call.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> diff --git a/QKSMS/src/main/res/drawable/ic_compose.xml b/QKSMS/src/main/res/drawable/ic_compose.xml index b49930dd..231ae2ad 100644 --- a/QKSMS/src/main/res/drawable/ic_compose.xml +++ b/QKSMS/src/main/res/drawable/ic_compose.xml @@ -4,6 +4,6 @@ android:viewportHeight="24.0" android:viewportWidth="24.0"> diff --git a/QKSMS/src/main/res/drawable/ic_notification.xml b/QKSMS/src/main/res/drawable/ic_notification.xml index f81ed0bf..3bc7b925 100644 --- a/QKSMS/src/main/res/drawable/ic_notification.xml +++ b/QKSMS/src/main/res/drawable/ic_notification.xml @@ -4,6 +4,6 @@ android:viewportHeight="24.0" android:viewportWidth="24.0"> diff --git a/QKSMS/src/main/res/drawable/ic_notification_failed.xml b/QKSMS/src/main/res/drawable/ic_notification_failed.xml index 4b1898b3..f216814e 100644 --- a/QKSMS/src/main/res/drawable/ic_notification_failed.xml +++ b/QKSMS/src/main/res/drawable/ic_notification_failed.xml @@ -4,6 +4,6 @@ android:viewportHeight="24.0" android:viewportWidth="24.0"> diff --git a/QKSMS/src/main/res/drawable/ic_notification_mms.xml b/QKSMS/src/main/res/drawable/ic_notification_mms.xml index b201cced..3c5dfe15 100644 --- a/QKSMS/src/main/res/drawable/ic_notification_mms.xml +++ b/QKSMS/src/main/res/drawable/ic_notification_mms.xml @@ -4,6 +4,6 @@ android:viewportHeight="24.0" android:viewportWidth="24.0"> diff --git a/QKSMS/src/main/res/drawable/ic_reply.xml b/QKSMS/src/main/res/drawable/ic_reply.xml index bac2f916..3fa79ab6 100644 --- a/QKSMS/src/main/res/drawable/ic_reply.xml +++ b/QKSMS/src/main/res/drawable/ic_reply.xml @@ -4,6 +4,6 @@ android:viewportHeight="24.0" android:viewportWidth="24.0"> diff --git a/QKSMS/src/main/res/values/strings.xml b/QKSMS/src/main/res/values/strings.xml index ac825bb1..d2ada51a 100644 --- a/QKSMS/src/main/res/values/strings.xml +++ b/QKSMS/src/main/res/values/strings.xml @@ -110,6 +110,7 @@ Themes, fonts, colors, avatars, and more General Delivery, message sending, formatting + Message blocking Notifications Sounds, LED, privacy MMS @@ -170,6 +171,8 @@ Long-press on a conversation and block to move to blocked inbox and stop notifications Block future messages Add additional phone numbers to block + Should I Answer? Integration + Automatically delete incoming messages from numbers which are blocked through Should I Answer? Mobile numbers Only show mobile numbers in contact suggestions Automatic emoji @@ -575,6 +578,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 diff --git a/QKSMS/src/main/res/xml/settings_general.xml b/QKSMS/src/main/res/xml/settings_general.xml index 8038ad44..f23b33bb 100644 --- a/QKSMS/src/main/res/xml/settings_general.xml +++ b/QKSMS/src/main/res/xml/settings_general.xml @@ -89,7 +89,7 @@ + android:title="@string/pref_category_blocking"> + + +