mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 03:28:52 +01:00
Minor package reorganization
This commit is contained in:
@@ -3,7 +3,7 @@ package com.moez.QKSMS.common;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.interfaces.LiveView;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -1070,92 +1070,6 @@ public class MessageUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CharSequence styleText(CharSequence text) {
|
||||
if (text == null || text.toString().isEmpty() || (!text.toString().contains("*") && !text.toString().contains("_")))
|
||||
return text; // Do nothing if there's nothing to be styled
|
||||
|
||||
boolean bool;
|
||||
|
||||
text = Html.toHtml(new SpannedString(text));
|
||||
|
||||
// bold text
|
||||
if (text.toString().contains("*")) {
|
||||
int doubleStars = 0;
|
||||
bool = true;
|
||||
for (int i = 0; i < text.length() - 1; i++) {
|
||||
if (text.subSequence(i, i + 2).equals("**")) {
|
||||
doubleStars++;
|
||||
}
|
||||
}
|
||||
if (doubleStars >= 2) {
|
||||
if (doubleStars % 2 != 0) {
|
||||
doubleStars--;
|
||||
}
|
||||
for (int i = 0; i < doubleStars; i++) {
|
||||
text = text.toString().replaceFirst(Pattern.quote("**"), bool ? "<b>" : "</b>");
|
||||
bool = !bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// italic text
|
||||
if (text.toString().contains("*")) {
|
||||
int singleStars = 0;
|
||||
bool = true;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.subSequence(i, i + 1).equals("*")) {
|
||||
singleStars++;
|
||||
}
|
||||
}
|
||||
if (singleStars >= 2) {
|
||||
if (singleStars % 2 != 0) {
|
||||
singleStars--;
|
||||
}
|
||||
for (int i = 0; i < singleStars; i++) {
|
||||
text = text.toString().replaceFirst(Pattern.quote("*"), bool ? "<i>" : "</i>");
|
||||
bool = !bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// underlined text
|
||||
if (text.toString().contains("_")) {
|
||||
int underscores = 0;
|
||||
bool = true;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.subSequence(i, i + 1).equals("_")) {
|
||||
underscores++;
|
||||
}
|
||||
}
|
||||
if (underscores >= 2) {
|
||||
if (underscores % 2 != 0) {
|
||||
underscores--;
|
||||
}
|
||||
for (int i = 0; i < underscores; i++) {
|
||||
text = text.toString().replaceFirst(Pattern.quote("_"), bool ? "<u>" : "</u>");
|
||||
bool = !bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text = text.toString().replaceAll(Pattern.quote("<p dir=\"ltr\">"), "").replaceAll(Pattern.quote("</p>"), "");
|
||||
|
||||
return Html.fromHtml(text.toString());
|
||||
}
|
||||
|
||||
public static String getInitial(String name) {
|
||||
char initial;
|
||||
if (name.length() == 1) {
|
||||
initial = name.toUpperCase().charAt(0);
|
||||
} else if (android.text.TextUtils.isEmpty(name) || PhoneNumberUtils.isReallyWellFormedSmsAddress(PhoneNumberUtils.stripSeparators(name))) {
|
||||
initial = '#';
|
||||
} else {
|
||||
initial = name.toUpperCase().charAt(0);
|
||||
}
|
||||
|
||||
return Character.toString(initial);
|
||||
}
|
||||
|
||||
private static void log(String msg) {
|
||||
Log.d(TAG, "[MsgUtils] " + msg);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.moez.QKSMS.common.utils;
|
||||
|
||||
import android.text.Html;
|
||||
import android.text.SpannedString;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TextUtils {
|
||||
public static CharSequence styleText(CharSequence text) {
|
||||
if (text == null || text.toString().isEmpty() || (!text.toString().contains("*") && !text.toString().contains("_")))
|
||||
return text; // Do nothing if there's nothing to be styled
|
||||
|
||||
boolean bool;
|
||||
|
||||
text = Html.toHtml(new SpannedString(text));
|
||||
|
||||
// bold text
|
||||
if (text.toString().contains("*")) {
|
||||
int doubleStars = 0;
|
||||
bool = true;
|
||||
for (int i = 0; i < text.length() - 1; i++) {
|
||||
if (text.subSequence(i, i + 2).equals("**")) {
|
||||
doubleStars++;
|
||||
}
|
||||
}
|
||||
if (doubleStars >= 2) {
|
||||
if (doubleStars % 2 != 0) {
|
||||
doubleStars--;
|
||||
}
|
||||
for (int i = 0; i < doubleStars; i++) {
|
||||
text = text.toString().replaceFirst(Pattern.quote("**"), bool ? "<b>" : "</b>");
|
||||
bool = !bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// italic text
|
||||
if (text.toString().contains("*")) {
|
||||
int singleStars = 0;
|
||||
bool = true;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.subSequence(i, i + 1).equals("*")) {
|
||||
singleStars++;
|
||||
}
|
||||
}
|
||||
if (singleStars >= 2) {
|
||||
if (singleStars % 2 != 0) {
|
||||
singleStars--;
|
||||
}
|
||||
for (int i = 0; i < singleStars; i++) {
|
||||
text = text.toString().replaceFirst(Pattern.quote("*"), bool ? "<i>" : "</i>");
|
||||
bool = !bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// underlined text
|
||||
if (text.toString().contains("_")) {
|
||||
int underscores = 0;
|
||||
bool = true;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.subSequence(i, i + 1).equals("_")) {
|
||||
underscores++;
|
||||
}
|
||||
}
|
||||
if (underscores >= 2) {
|
||||
if (underscores % 2 != 0) {
|
||||
underscores--;
|
||||
}
|
||||
for (int i = 0; i < underscores; i++) {
|
||||
text = text.toString().replaceFirst(Pattern.quote("_"), bool ? "<u>" : "</u>");
|
||||
bool = !bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text = text.toString().replaceAll(Pattern.quote("<p dir=\"ltr\">"), "").replaceAll(Pattern.quote("</p>"), "");
|
||||
|
||||
return Html.fromHtml(text.toString());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.moez.QKSMS.common.preferences;
|
||||
package com.moez.QKSMS.enums;
|
||||
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.moez.QKSMS.common.conversationdetails;
|
||||
package com.moez.QKSMS.interfaces;
|
||||
|
||||
import com.moez.QKSMS.data.Conversation;
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.moez.QKSMS.common.DonationManager;
|
||||
import com.moez.QKSMS.common.QKRateSnack;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.google.DraftCache;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
import com.moez.QKSMS.common.utils.MessageUtils;
|
||||
import com.moez.QKSMS.common.utils.Units;
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.moez.QKSMS.common.AnalyticsManager;
|
||||
import com.moez.QKSMS.common.CIELChEvaluator;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.ColorUtils;
|
||||
import com.moez.QKSMS.receiver.IconColorReceiver;
|
||||
import com.moez.QKSMS.ui.base.QKActivity;
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.android.volley.RequestQueue;
|
||||
import com.moez.QKSMS.QKSMSApp;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.ColorUtils;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.view.QKTextView;
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import com.moez.QKSMS.QKSMSApp;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.squareup.leakcanary.RefWatcher;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.emoji.EmojiRegistry;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.DateFormatter;
|
||||
import com.moez.QKSMS.data.Contact;
|
||||
import com.moez.QKSMS.data.Conversation;
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.BlockedConversationHelper;
|
||||
import com.moez.QKSMS.common.DialogHelper;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.ColorUtils;
|
||||
import com.moez.QKSMS.data.Conversation;
|
||||
import com.moez.QKSMS.data.ConversationLegacy;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.moez.QKSMS.common.conversationdetails;
|
||||
package com.moez.QKSMS.ui.dialog.conversationdetails;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package com.moez.QKSMS.common.conversationdetails;
|
||||
package com.moez.QKSMS.ui.dialog.conversationdetails;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.view.View;
|
||||
@@ -8,6 +8,7 @@ import android.widget.ListView;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.utils.DateFormatter;
|
||||
import com.moez.QKSMS.data.Conversation;
|
||||
import com.moez.QKSMS.interfaces.ConversationDetails;
|
||||
import com.moez.QKSMS.ui.base.QKActivity;
|
||||
import com.moez.QKSMS.ui.dialog.QKDialog;
|
||||
import com.moez.QKSMS.ui.view.QKTextView;
|
||||
@@ -55,8 +55,8 @@ import com.moez.QKSMS.common.CIELChEvaluator;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.common.DialogHelper;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.DrmUtils;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
import com.moez.QKSMS.common.utils.MessageUtils;
|
||||
@@ -67,7 +67,6 @@ import com.moez.QKSMS.data.Conversation;
|
||||
import com.moez.QKSMS.data.ConversationLegacy;
|
||||
import com.moez.QKSMS.data.Message;
|
||||
import com.moez.QKSMS.interfaces.ActivityLauncher;
|
||||
import com.moez.QKSMS.interfaces.LiveView;
|
||||
import com.moez.QKSMS.model.SlideshowModel;
|
||||
import com.moez.QKSMS.transaction.NotificationManager;
|
||||
import com.moez.QKSMS.transaction.SmsHelper;
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.google.ItemLoadedCallback;
|
||||
import com.moez.QKSMS.common.google.ThumbnailManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.interfaces.SlideViewInterface;
|
||||
import com.moez.QKSMS.interfaces.LiveView;
|
||||
import com.moez.QKSMS.ui.base.ClickyViewHolder;
|
||||
|
||||
@@ -35,7 +35,7 @@ import com.moez.QKSMS.common.DialogHelper;
|
||||
import com.moez.QKSMS.common.DonationManager;
|
||||
import com.moez.QKSMS.common.ListviewHelper;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.DateFormatter;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
import com.moez.QKSMS.common.utils.PackageUtils;
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.android.ex.chips.RecipientEditTextView;
|
||||
import com.moez.QKSMS.common.FontManager;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.TypefaceManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.base.QKActivity;
|
||||
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
||||
|
||||
@@ -25,7 +25,7 @@ import android.widget.ImageView;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.TypefaceManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.ImageUtils;
|
||||
import com.moez.QKSMS.common.utils.Units;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
|
||||
@@ -37,7 +37,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
import com.github.lzyzsd.circleprogress.DonutProgress;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.mmssms.Transaction;
|
||||
import com.moez.QKSMS.mmssms.Utils;
|
||||
import com.moez.QKSMS.R;
|
||||
|
||||
@@ -11,7 +11,7 @@ import android.util.TypedValue;
|
||||
import com.moez.QKSMS.common.FontManager;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.TypefaceManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
|
||||
public class QKEditText extends android.widget.EditText {
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
|
||||
public class QKImageView extends ImageView {
|
||||
|
||||
@@ -9,7 +9,7 @@ import android.support.v7.widget.SwitchCompat;
|
||||
import android.util.AttributeSet;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
|
||||
public class QKSwitch extends SwitchCompat {
|
||||
|
||||
@@ -14,8 +14,8 @@ import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.FontManager;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.TypefaceManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.MessageUtils;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.TextUtils;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
||||
|
||||
@@ -145,7 +145,7 @@ public class QKTextView extends TextView {
|
||||
}
|
||||
|
||||
if (prefs.getBoolean(SettingsFragment.MARKDOWN_ENABLED, false)) {
|
||||
text = MessageUtils.styleText(text);
|
||||
text = TextUtils.styleText(text);
|
||||
if (text == null || text.length() <= 0 || Build.VERSION.SDK_INT >= 19) {
|
||||
super.setText(text, BufferType.EDITABLE);
|
||||
return;
|
||||
|
||||
@@ -16,7 +16,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.data.Contact;
|
||||
import com.moez.QKSMS.data.ContactHelper;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
|
||||
@@ -10,7 +10,7 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.base.QKActivity;
|
||||
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
||||
|
||||
Reference in New Issue
Block a user