diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 5e0944535..7da3b5e9e 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -3,5 +3,6 @@
+
\ No newline at end of file
diff --git a/app/src/main/java/com/afkanerd/deku/DefaultSMS/BroadcastReceivers/IncomingTextSMSReplyMuteActionBroadcastReceiver.kt b/app/src/main/java/com/afkanerd/deku/DefaultSMS/BroadcastReceivers/IncomingTextSMSReplyMuteActionBroadcastReceiver.kt
index 401376128..28d364ff5 100644
--- a/app/src/main/java/com/afkanerd/deku/DefaultSMS/BroadcastReceivers/IncomingTextSMSReplyMuteActionBroadcastReceiver.kt
+++ b/app/src/main/java/com/afkanerd/deku/DefaultSMS/BroadcastReceivers/IncomingTextSMSReplyMuteActionBroadcastReceiver.kt
@@ -146,6 +146,6 @@ class IncomingTextSMSReplyMuteActionBroadcastReceiver : BroadcastReceiver() {
var REPLY_SUBSCRIPTION_ID: String = "REPLY_SUBSCRIPTION_ID"
// Key for the string that's delivered in the action's intent.
- const val KEY_TEXT_REPLY: String = "KEY_TEXT_REPLY"
+ const val KEY_TEXT_REPLY: String = "extra_remote_reply"
}
}
diff --git a/app/src/main/java/com/afkanerd/deku/DefaultSMS/Commons/Helpers.java b/app/src/main/java/com/afkanerd/deku/DefaultSMS/Commons/Helpers.java
index 8a64e8378..b2daf84b3 100644
--- a/app/src/main/java/com/afkanerd/deku/DefaultSMS/Commons/Helpers.java
+++ b/app/src/main/java/com/afkanerd/deku/DefaultSMS/Commons/Helpers.java
@@ -52,64 +52,6 @@
public class Helpers {
- public static Spannable highlightSubstringYellow(Context context, String text,
- String searchString, boolean sent) {
- // Find all occurrences of the substring in the text.
- List startIndices = new ArrayList<>();
- int index = text.toLowerCase().indexOf(searchString.toLowerCase());
- while (index >= 0) {
- startIndices.add(index);
- index = text.indexOf(searchString, index + searchString.length());
- }
-
- // Create a SpannableString object.
- SpannableString spannableString = new SpannableString(text);
-
- // Set the foreground color of the substring to yellow.
- BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(
- context.getColor(R.color.md_theme_inversePrimary));
- for (int startIndex : startIndices) {
- spannableString.setSpan(backgroundColorSpan, startIndex, startIndex + searchString.length(),
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
-
- return spannableString;
- }
- public static long generateRandomNumber() {
- Random random = new Random();
- return random.nextInt(Integer.MAX_VALUE);
- }
-
- public static int dpToPixel(float dpValue) {
- float density = Resources.getSystem().getDisplayMetrics().density;
- return (int) (dpValue * density);
- }
-
- public static int getRandomColor() {
- Random random = new Random();
- int r = random.nextInt(256);
- int g = random.nextInt(256);
- int b = random.nextInt(256);
- int color = r << 16 | g << 8 | b;
-
- return generateColor(color);
- }
-
- public static String[] convertSetToStringArray(Set setOfString)
- {
- // Create String[] of size of setOfString
- String[] arrayOfString = new String[setOfString.size()];
-
- // Copy elements from set to string array
- // using advanced for loop
- int index = 0;
- for (String str : setOfString)
- arrayOfString[index++] = str;
-
- // return the formed String[]
- return arrayOfString;
- }
-
public static boolean isShortCode(String address) {
if(address.length() < 4)
return true;
@@ -118,34 +60,13 @@ public static boolean isShortCode(String address) {
return !PhoneNumberUtils.isWellFormedSmsAddress(address) || matcher.find();
}
- public static byte[] generateRandomBytes(int length) {
- SecureRandom random = new SecureRandom();
- byte[] bytes = new
-
- byte[length];
- random.nextBytes(bytes);
- return bytes;
- }
-
- public static String getFormatCompleteNumber(Context context, String address, String defaultRegion) {
- try(Cursor cursor = NativeSMSDB.fetchByAddress(context, address)) {
- if(cursor.moveToFirst()) {
- int recipientIdIndex = cursor.getColumnIndexOrThrow("address");
- address = cursor.getString(recipientIdIndex);
- }
- cursor.close();
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- return address;
- }
-
public static String getFormatCompleteNumber(String data, String defaultRegion) {
data = data.replaceAll("%2B", "+")
.replaceAll("-", "")
.replaceAll("%20", "")
- .replaceAll(" ", "");
+ .replaceAll(" ", "")
+ .replaceFirst("^0+", "");
+
if(data.length() < 5)
return data;
PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
@@ -157,9 +78,10 @@ public static String getFormatCompleteNumber(String data, String defaultRegion)
return "+" + countryCode + nationalNumber;
} catch(NumberParseException e) {
-// e.printStackTrace();
if(e.getErrorType() == NumberParseException.ErrorType.INVALID_COUNTRY_CODE) {
- data = outputNumber.replaceAll("sms[to]*:", "");
+ data = outputNumber
+ .replaceAll("sms[to]*:", "")
+ .replaceFirst("^0+", "");
if (data.startsWith(defaultRegion)) {
outputNumber = "+" + data;
} else {
@@ -228,35 +150,6 @@ public static String getFormatNationalNumber(String data, String defaultRegion)
return data;
}
-// public static String formatDateExtended(Context context, long epochTime) {
-// long currentTime = System.currentTimeMillis();
-// long diff = currentTime - epochTime;
-//
-// Date currentDate = new Date(currentTime);
-// Date targetDate = new Date(epochTime);
-//
-// SimpleDateFormat timeFormat = new SimpleDateFormat("h:mm a", Locale.getDefault());
-// SimpleDateFormat fullDayFormat = new SimpleDateFormat("EEEE", Locale.getDefault());
-// SimpleDateFormat shortDayFormat = new SimpleDateFormat("EEE", Locale.getDefault());
-// SimpleDateFormat shortMonthDayFormat = new SimpleDateFormat("MMM d", Locale.getDefault());
-//
-//// if (diff < DateUtils.HOUR_IN_MILLIS) { // less than 1 hour
-//// return DateUtils.getRelativeTimeSpanString(epochTime, currentTime, DateUtils.MINUTE_IN_MILLIS).toString();
-//// }
-// if (diff < DateUtils.DAY_IN_MILLIS) { // less than 1 day
-// return DateUtils.formatDateTime(context, epochTime, DateUtils.FORMAT_SHOW_TIME);
-// } else if (isSameDay(currentDate, targetDate)) { // today
-// return timeFormat.format(targetDate);
-// } else if (isYesterday(currentDate, targetDate)) { // yesterday
-// return context.getString(R.string.single_message_thread_yesterday) + " • " + timeFormat.format(targetDate);
-// } else if (isSameWeek(currentDate, targetDate)) { // within the same week
-// return fullDayFormat.format(targetDate) + " • " + timeFormat.format(targetDate);
-// } else { // greater than 1 week
-// return shortDayFormat.format(targetDate) + ", " + shortMonthDayFormat.format(targetDate)
-// + " • " + timeFormat.format(targetDate);
-// }
-// }
-
public static String formatDateExtended(Context context, long epochTime) {
long currentTime = System.currentTimeMillis();
long diff = currentTime - epochTime;
@@ -281,13 +174,6 @@ public static String formatDateExtended(Context context, long epochTime) {
}
}
- private static boolean isSameDay(Date date1, Date date2) {
- SimpleDateFormat dayFormat = new SimpleDateFormat("yyyyDDD", Locale.getDefault());
- String day1 = dayFormat.format(date1);
- String day2 = dayFormat.format(date2);
- return day1.equals(day2);
- }
-
private static boolean isYesterday(Date date1, Date date2) {
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyyDDD", Locale.getDefault());
String day1 = dayFormat.format(date1);
@@ -309,21 +195,6 @@ private static boolean isSameWeek(Date date1, Date date2) {
return week1.equals(week2);
}
-// public static String formatDate(Context context, long epochTime) {
-// long currentTime = System.currentTimeMillis();
-// long diff = currentTime - epochTime;
-//
-// if (diff < DateUtils.HOUR_IN_MILLIS) { // less than 1 hour
-// return DateUtils.getRelativeTimeSpanString(epochTime, currentTime, DateUtils.MINUTE_IN_MILLIS).toString();
-// } else if (diff < DateUtils.DAY_IN_MILLIS) { // less than 1 day
-// return DateUtils.formatDateTime(context, epochTime, DateUtils.FORMAT_SHOW_TIME);
-// } else if (diff < DateUtils.WEEK_IN_MILLIS) { // less than 1 week
-// return DateUtils.formatDateTime(context, epochTime, DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY);
-// } else { // greater than 1 week
-// return DateUtils.formatDateTime(context, epochTime, DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_DATE);
-// }
-// }
-
public static String formatDate(Context context, long epochTime) {
long currentTime = System.currentTimeMillis();
long diff = currentTime - epochTime;
@@ -352,17 +223,6 @@ public static String formatDate(Context context, long epochTime) {
return null;
}
- public static String formatLongDate(long epochTime) {
- // Create a date object from the epoch time
- Date date = new Date(epochTime);
-
- // Create a SimpleDateFormat object with the desired format
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd, h:mm a", Locale.getDefault());
-
- // Format the date and return the string
- return formatter.format(date);
- }
-
public static String getUserCountry(Context context) {
String countryCode = null;
@@ -379,57 +239,6 @@ public static String getUserCountry(Context context) {
return String.valueOf(PhoneNumberUtil.getInstance().getCountryCodeForRegion(countryCode));
}
- public static int getColor(Context context, String input) {
- int sDefaultColor = context.getResources().getIntArray(R.array.letter_tile_colors)[0];
-// int sDefaultColor = context.getColor(defaultColor);
- if (TextUtils.isEmpty(input)) {
- return sDefaultColor;
- }
- TypedArray sColors = context.getResources().obtainTypedArray(R.array.letter_tile_colors);
- // String.hashCode() implementation is not supposed to change across java versions, so
- // this should guarantee the same email address always maps to the same color.
- // The email should already have been normalized by the ContactRequest.
- final int color = Math.abs(input.hashCode()) % sColors.length();
- return sColors.getColor(color, sDefaultColor);
- }
-
- public static int generateColor(int input) {
- int hue;
- int saturation = 100;
- int value = 60; // Reduced value component for darker colors
-
- hue = Math.abs(input * 31 % 360);
- // Convert the HSV color to RGB and return the color as an int
- float[] hsv = {hue, saturation, value};
- int color = Color.HSVToColor(hsv);
- return color;
- }
-
- public static int generateColor(String input) {
- int hue;
- int saturation = 100;
- int value = 60; // Reduced value component for darker colors
-
- if (input.length() == 0) {
- // Return a default color if the input is empty
- hue = 0;
- } else if (input.length() == 1) {
- // Use the first character of the input to generate the hue
- char firstChar = input.charAt(0);
- hue = Math.abs(firstChar * 31 % 360);
- } else {
- // Use the first and second characters of the input to generate the hue
- char firstChar = input.charAt(0);
- char secondChar = input.charAt(1);
- hue = Math.abs((firstChar + secondChar) * 31 % 360);
- }
-
- // Convert the HSV color to RGB and return the color as an int
- float[] hsv = {hue, saturation, value};
- int color = Color.HSVToColor(hsv);
- return color;
- }
-
public static boolean isBase64Encoded(String input) {
try {
byte[] decodedBytes = Base64.decode(input, Base64.DEFAULT);
@@ -444,82 +253,6 @@ public static boolean isBase64Encoded(String input) {
}
}
- public static void highlightLinks(TextView textView, String text, int color) {
- if(text == null)
- return;
- // Regular expression to find URLs in the text
-// String urlPattern = "((mailto:)?[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+)" +
-// "|((\\+?[0-9]{1,3}?)[ \\-]?)?([\\(]{1}[0-9]{3}[\\)])?[ \\-]?[0-9]{3}[ \\-]?[0-9]{4}" +
-// "|(https?://)?([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\\.)+[a-zA-Z]{2,}(/[\\w\\.-]+)*" +
-// "|(https?://)?([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\\.)+[a-zA-Z]{2,}(/[\\w\\.-]+)*(/\\S*)*(\\?[^ ]*#[^ ]*)/?";
-
- SpannableString spannableString = new SpannableString(text);
-
- String[] splitString = text.split("\\s");
- for(int i=0, length =0; i,
+ // grantResults: IntArray)
+ // to handle the case where the user grants the permission. See the documentation
+ // for ActivityCompat#requestPermissions for more details.
+
+ return@with
+ }
+ // notificationId is a unique int for each notification that you must define.
+ cancel(notificationId)
+ }
+ }
+
fun notify(
context: Context,
builder: NotificationCompat.Builder,
diff --git a/app/src/main/java/com/afkanerd/deku/DefaultSMS/ui/ConversationsMain.kt b/app/src/main/java/com/afkanerd/deku/DefaultSMS/ui/ConversationsMain.kt
index 48aebf4b3..354c05f21 100644
--- a/app/src/main/java/com/afkanerd/deku/DefaultSMS/ui/ConversationsMain.kt
+++ b/app/src/main/java/com/afkanerd/deku/DefaultSMS/ui/ConversationsMain.kt
@@ -96,6 +96,8 @@ import com.afkanerd.deku.DefaultSMS.MainActivity
import com.afkanerd.deku.DefaultSMS.Models.Contacts
import com.afkanerd.deku.DefaultSMS.Models.Conversations.Conversation
import com.afkanerd.deku.DefaultSMS.Models.E2EEHandler
+import com.afkanerd.deku.DefaultSMS.Models.Notifications
+import com.afkanerd.deku.DefaultSMS.Models.NotificationsHandler
import com.afkanerd.deku.DefaultSMS.Models.SIMHandler
import com.afkanerd.deku.DefaultSMS.Models.SMSHandler.sendTextMessage
import com.afkanerd.deku.DefaultSMS.R
@@ -561,6 +563,7 @@ fun Conversations(
if(searchIndexes.isNotEmpty() && searchIndex == 0)
listState.animateScrollToItem(searchIndexes.first())
+ Notifications.cancel(context, viewModel.threadId.toInt())
}
LaunchedEffect(viewModel.address){
diff --git a/app/src/main/res/drawable/hello_rafiki.xml b/app/src/main/res/drawable/hello_rafiki.xml
deleted file mode 100644
index b576d415c..000000000
--- a/app/src/main/res/drawable/hello_rafiki.xml
+++ /dev/null
@@ -1,194 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-