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" /> + + + + + + { + 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/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 166af425..35d16d88 100644 --- a/QKSMS/src/main/res/xml/settings_general.xml +++ b/QKSMS/src/main/res/xml/settings_general.xml @@ -88,7 +88,7 @@ + android:title="@string/pref_category_blocking"> + + +