allow to setup a common suffix for canned replies (defaults to " (canned reply)")

here
Andreas Shimokawa 2016-01-11 15:29:12 +01:00
parent 0b53f60b0d
commit de4ffe8fb0
4 changed files with 16 additions and 2 deletions

View File

@ -110,6 +110,7 @@ public class SettingsActivity extends AbstractSettingsActivity {
"pebble_emu_addr",
"pebble_emu_port",
"pebble_reconnect_attempts",
"canned_reply_suffix",
"canned_reply_1",
"canned_reply_2",
"canned_reply_3",

View File

@ -6,9 +6,11 @@ import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.telephony.SmsManager;
@ -20,6 +22,7 @@ import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -243,6 +246,11 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
Intent notificationListenerIntent = new Intent(action);
notificationListenerIntent.putExtra("handle", deviceEvent.handle);
if (deviceEvent.reply != null) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(GBApplication.getContext());
String suffix = sharedPrefs.getString("canned_reply_suffix", null);
if (suffix != null && !Objects.equals(suffix, "")) {
deviceEvent.reply += suffix;
}
notificationListenerIntent.putExtra("reply", deviceEvent.reply);
}
LocalBroadcastManager.getInstance(context).sendBroadcast(notificationListenerIntent);

View File

@ -56,6 +56,7 @@
<string name="pref_blacklist">Blacklist Apps</string>
<string name="pref_title_canned_replies">Canned Replies</string>
<string name="pref_title_canned_reply_suffix">Common suffix</string>
<string name="pref_header_development">Developer Options</string>
<string name="pref_title_development_miaddr">Mi Band address</string>

View File

@ -67,8 +67,12 @@
android:title="@string/pref_blacklist" />
<PreferenceScreen
android:key="pref_key_canned_replies"
android:title="@string/pref_title_canned_replies"
android:dependency="pebble_force_untested" >
android:title="@string/pref_title_canned_replies">
<EditTextPreference
android:defaultValue=" (canned reply)"
android:key="canned_reply_suffix"
android:maxLength="64"
android:title="@string/pref_title_canned_reply_suffix" />
<EditTextPreference
android:key="canned_reply_1"
android:maxLength="64" />