Merge master into blocksenders`

This commit is contained in:
Moez Bhatti
2015-10-18 22:38:56 -04:00
parent 4f31f33aef
commit 0dac7dbcc0
83 changed files with 891 additions and 760 deletions
+2
View File
@@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
repositories {
mavenCentral()
jcenter()
}
android {
@@ -74,6 +75,7 @@ dependencies {
compile 'com.googlecode.ez-vcard:ez-vcard:0.9.6'
compile 'com.google.code.gson:gson:2.3'
compile 'com.koushikdutta.ion:ion:1.1.7'
compile 'org.ligi:snackengage:0.4'
// Google libraries
compile 'com.android.support:appcompat-v7:22.2.1'
@@ -1,25 +1,22 @@
package com.moez.QKSMS.common.utils;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.test.AndroidTestCase;
import android.util.Log;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.settings.SettingsFragment;
import java.text.SimpleDateFormat;
import java.util.Locale;
public class DateFormatterTest extends AndroidTestCase {
protected void setUp() throws Exception {
super.setUp();
}
public void test24Hours(){
SharedPreferences prefs = MainActivity.getPrefs(getContext());
prefs.edit().putBoolean(SettingsFragment.TIMESTAMPS_24H, true).commit();
public void test24Hours() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs.edit().putBoolean(SettingsFragment.TIMESTAMPS_24H, true).apply();
assertTrue(DateFormatter.accountFor24HourTime(getContext(), new SimpleDateFormat("h:mm a")).equals(new SimpleDateFormat("H:mm")));
prefs.edit().putBoolean(SettingsFragment.TIMESTAMPS_24H, false).commit();
prefs.edit().putBoolean(SettingsFragment.TIMESTAMPS_24H, false).apply();
}
public void testDateSymbolsAPI(){
@@ -29,7 +29,7 @@ import java.lang.annotation.Target;
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.SOURCE)
public @interface SdkConstant {
public static enum SdkConstantType {
public enum SdkConstantType {
ACTIVITY_INTENT_ACTION, BROADCAST_INTENT_ACTION, SERVICE_ACTION, INTENT_CATEGORY, FEATURE
}
@@ -90,7 +90,7 @@ public class CountryDetector {
*/
public CountryDetector(ICountryDetector service) {
mService = service;
mListeners = new HashMap<CountryListener, ListenerTransport>();
mListeners = new HashMap<>();
}
/**
@@ -53,7 +53,7 @@ public class DhcpInfoInternal {
private Collection<RouteInfo> mRoutes;
public DhcpInfoInternal() {
mRoutes = new ArrayList<RouteInfo>();
mRoutes = new ArrayList<>();
}
public void addRoute(RouteInfo routeInfo) {
@@ -1387,7 +1387,7 @@ public interface IConnectivityManager extends android.os.IInterface {
}
}
static final int TRANSACTION_setNetworkPreference = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
static final int TRANSACTION_setNetworkPreference = (android.os.IBinder.FIRST_CALL_TRANSACTION);
static final int TRANSACTION_getNetworkPreference = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
static final int TRANSACTION_getActiveNetworkInfo = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
static final int TRANSACTION_getActiveNetworkInfoForUid = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
@@ -125,7 +125,7 @@ public interface INetworkPolicyListener extends android.os.IInterface {
}
}
static final int TRANSACTION_onUidRulesChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
static final int TRANSACTION_onUidRulesChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION);
static final int TRANSACTION_onMeteredIfacesChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
static final int TRANSACTION_onRestrictBackgroundChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
}
@@ -439,7 +439,7 @@ public interface INetworkPolicyManager extends android.os.IInterface {
}
}
static final int TRANSACTION_setUidPolicy = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
static final int TRANSACTION_setUidPolicy = (android.os.IBinder.FIRST_CALL_TRANSACTION);
static final int TRANSACTION_getUidPolicy = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
static final int TRANSACTION_getUidsWithPolicy = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
static final int TRANSACTION_isUidForeground = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
@@ -199,7 +199,7 @@ public class LinkCapabilities implements Parcelable {
* Constructor
*/
public LinkCapabilities() {
mCapabilities = new HashMap<Integer, String>();
mCapabilities = new HashMap<>();
}
/**
@@ -209,9 +209,9 @@ public class LinkCapabilities implements Parcelable {
*/
public LinkCapabilities(LinkCapabilities source) {
if (source != null) {
mCapabilities = new HashMap<Integer, String>(source.mCapabilities);
mCapabilities = new HashMap<>(source.mCapabilities);
} else {
mCapabilities = new HashMap<Integer, String>();
mCapabilities = new HashMap<>();
}
}
@@ -356,7 +356,7 @@ public class LinkCapabilities implements Parcelable {
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mCapabilities.size());
for (Entry<Integer, String> entry : mCapabilities.entrySet()) {
dest.writeInt(entry.getKey().intValue());
dest.writeInt(entry.getKey());
dest.writeString(entry.getValue());
}
}
@@ -52,14 +52,14 @@ import java.util.Collections;
public class LinkProperties implements Parcelable {
String mIfaceName;
private Collection<LinkAddress> mLinkAddresses = new ArrayList<LinkAddress>();
private Collection<InetAddress> mDnses = new ArrayList<InetAddress>();
private Collection<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
private Collection<LinkAddress> mLinkAddresses = new ArrayList<>();
private Collection<InetAddress> mDnses = new ArrayList<>();
private Collection<RouteInfo> mRoutes = new ArrayList<>();
private ProxyProperties mHttpProxy;
public static class CompareResult<T> {
public Collection<T> removed = new ArrayList<T>();
public Collection<T> added = new ArrayList<T>();
public Collection<T> removed = new ArrayList<>();
public Collection<T> added = new ArrayList<>();
@Override
public String toString() {
@@ -97,7 +97,7 @@ public class LinkProperties implements Parcelable {
}
public Collection<InetAddress> getAddresses() {
Collection<InetAddress> addresses = new ArrayList<InetAddress>();
Collection<InetAddress> addresses = new ArrayList<>();
for (LinkAddress linkAddress : mLinkAddresses) {
addresses.add(linkAddress.getAddress());
}
@@ -192,8 +192,7 @@ public class LinkProperties implements Parcelable {
public boolean isIdenticalAddresses(LinkProperties target) {
Collection<InetAddress> targetAddresses = target.getAddresses();
Collection<InetAddress> sourceAddresses = getAddresses();
return (sourceAddresses.size() == targetAddresses.size()) ?
sourceAddresses.containsAll(targetAddresses) : false;
return (sourceAddresses.size() == targetAddresses.size()) && sourceAddresses.containsAll(targetAddresses);
}
/**
@@ -275,8 +274,8 @@ public class LinkProperties implements Parcelable {
* are in target but not in mLinkAddresses are placed in the
* addedAddresses.
*/
CompareResult<LinkAddress> result = new CompareResult<LinkAddress>();
result.removed = new ArrayList<LinkAddress>(mLinkAddresses);
CompareResult<LinkAddress> result = new CompareResult<>();
result.removed = new ArrayList<>(mLinkAddresses);
result.added.clear();
if (target != null) {
for (LinkAddress newAddress : target.getLinkAddresses()) {
@@ -305,9 +304,9 @@ public class LinkProperties implements Parcelable {
* are in target but not in mDnses are placed in the
* addedAddresses.
*/
CompareResult<InetAddress> result = new CompareResult<InetAddress>();
CompareResult<InetAddress> result = new CompareResult<>();
result.removed = new ArrayList<InetAddress>(mDnses);
result.removed = new ArrayList<>(mDnses);
result.added.clear();
if (target != null) {
for (InetAddress newAddress : target.getDnses()) {
@@ -335,9 +334,9 @@ public class LinkProperties implements Parcelable {
* leaving the routes that are different. And route address which
* are in target but not in mRoutes are placed in added.
*/
CompareResult<RouteInfo> result = new CompareResult<RouteInfo>();
CompareResult<RouteInfo> result = new CompareResult<>();
result.removed = new ArrayList<RouteInfo>(mRoutes);
result.removed = new ArrayList<>(mRoutes);
result.added.clear();
if (target != null) {
for (RouteInfo r : target.getRoutes()) {
@@ -168,17 +168,7 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> {
@Override
public String toString() {
final StringBuilder builder = new StringBuilder("NetworkPolicy");
builder.append("[").append(template).append("]:");
builder.append(" cycleDay=").append(cycleDay);
builder.append(", cycleTimezone=").append(cycleTimezone);
builder.append(", warningBytes=").append(warningBytes);
builder.append(", limitBytes=").append(limitBytes);
builder.append(", lastWarningSnooze=").append(lastWarningSnooze);
builder.append(", lastLimitSnooze=").append(lastLimitSnooze);
builder.append(", metered=").append(metered);
builder.append(", inferred=").append(inferred);
return builder.toString();
return "NetworkPolicy" + "[" + template + "]:" + " cycleDay=" + cycleDay + ", cycleTimezone=" + cycleTimezone + ", warningBytes=" + warningBytes + ", limitBytes=" + limitBytes + ", lastWarningSnooze=" + lastWarningSnooze + ", lastLimitSnooze=" + lastLimitSnooze + ", metered=" + metered + ", inferred=" + inferred;
}
public static final Creator<NetworkPolicy> CREATOR = new Creator<NetworkPolicy>() {
@@ -153,8 +153,7 @@ public class ProxyProperties implements Parcelable {
return false;
}
if (mHost != null && p.mHost == null) return false;
if (mHost == null && p.mHost != null) return false;
return mPort == p.mPort;
return !(mHost == null && p.mHost != null) && mPort == p.mPort;
}
/**
@@ -72,11 +72,11 @@ public abstract class ElementTimeImpl implements ElementTime {
String[] beginTimeStringList = mSmilElement.getAttribute("begin").split(";");
// TODO: Check other constraints on parsed values, e.g., "single, non-negative offset values
ArrayList<Time> beginTimeList = new ArrayList<Time>();
ArrayList<Time> beginTimeList = new ArrayList<>();
// Initialize Time instances and add them to Vector
for (int i = 0; i < beginTimeStringList.length; i++) {
for (String aBeginTimeStringList : beginTimeStringList) {
try {
beginTimeList.add(new TimeImpl(beginTimeStringList[i], getBeginConstraints()));
beginTimeList.add(new TimeImpl(aBeginTimeStringList, getBeginConstraints()));
} catch (IllegalArgumentException e) {
// Ignore badly formatted times
}
@@ -121,15 +121,15 @@ public abstract class ElementTimeImpl implements ElementTime {
}
public TimeList getEnd() {
ArrayList<Time> endTimeList = new ArrayList<Time>();
ArrayList<Time> endTimeList = new ArrayList<>();
String[] endTimeStringList = mSmilElement.getAttribute("end").split(";");
int len = endTimeStringList.length;
if (!((len == 1) && (endTimeStringList[0].length() == 0))) { // Ensure the end field is set.
// Initialize Time instances and add them to Vector
for (int i = 0; i < len; i++) {
for (String anEndTimeStringList : endTimeStringList) {
try {
endTimeList.add(new TimeImpl(endTimeStringList[i],
endTimeList.add(new TimeImpl(anEndTimeStringList,
getEndConstraints()));
} catch (IllegalArgumentException e) {
// Ignore badly formatted times
@@ -245,7 +245,7 @@ public abstract class ElementTimeImpl implements ElementTime {
*/
return FILL_AUTO;
} else {
return ((ElementTimeImpl) parent).getFillDefault();
return parent.getFillDefault();
}
}
}
@@ -156,28 +156,29 @@ public class SmilDocumentImpl extends DocumentImpl implements SMILDocument, Docu
public Element createElement(String tagName) throws DOMException {
// Find the appropriate class for this element
tagName = tagName.toLowerCase();
if (tagName.equals("text") ||
tagName.equals("img") ||
tagName.equals("video")) {
return new SmilRegionMediaElementImpl(this, tagName);
} else if (tagName.equals("audio")) {
return new SmilMediaElementImpl(this, tagName);
} else if (tagName.equals("layout")) {
return new SmilLayoutElementImpl(this, tagName);
} else if (tagName.equals("root-layout")) {
return new SmilRootLayoutElementImpl(this, tagName);
} else if (tagName.equals("region")) {
return new SmilRegionElementImpl(this, tagName);
} else if (tagName.equals("ref")) {
return new SmilRefElementImpl(this, tagName);
} else if (tagName.equals("par")) {
return new SmilParElementImpl(this, tagName);
} else if (tagName.equals("vcard")) {
return new SmilRegionMediaElementImpl(this, tagName);
} else {
// This includes also the structural nodes SMIL,
// HEAD, BODY, for which no specific types are defined.
return new SmilElementImpl(this, tagName);
switch (tagName) {
case "text":
case "img":
case "video":
return new SmilRegionMediaElementImpl(this, tagName);
case "audio":
return new SmilMediaElementImpl(this, tagName);
case "layout":
return new SmilLayoutElementImpl(this, tagName);
case "root-layout":
return new SmilRootLayoutElementImpl(this, tagName);
case "region":
return new SmilRegionElementImpl(this, tagName);
case "ref":
return new SmilRefElementImpl(this, tagName);
case "par":
return new SmilParElementImpl(this, tagName);
case "vcard":
return new SmilRegionMediaElementImpl(this, tagName);
default:
// This includes also the structural nodes SMIL,
// HEAD, BODY, for which no specific types are defined.
return new SmilElementImpl(this, tagName);
}
}
@@ -44,7 +44,7 @@ public class SmilParElementImpl extends SmilElementImpl implements SMILParElemen
*/
TimeList beginTimeList = super.getBegin();
if (beginTimeList.getLength() > 1) {
ArrayList<Time> singleTimeContainer = new ArrayList<Time>();
ArrayList<Time> singleTimeContainer = new ArrayList<>();
singleTimeContainer.add(beginTimeList.item(0));
beginTimeList = new TimeListImpl(singleTimeContainer);
}
@@ -46,7 +46,7 @@ public class SmilPlayer implements Runnable {
private static final boolean LOCAL_LOGV = false;
private static final int TIMESLICE = 200;
private static enum SmilPlayerState {
private enum SmilPlayerState {
INITIALIZED,
PLAYING,
PLAYED,
@@ -54,7 +54,7 @@ public class SmilPlayer implements Runnable {
STOPPED,
}
private static enum SmilPlayerAction {
private enum SmilPlayerAction {
NO_ACTIVE_ACTION,
RELOAD,
STOP,
@@ -88,7 +88,7 @@ public class SmilPlayer implements Runnable {
private static ArrayList<TimelineEntry> getParTimeline(
ElementParallelTimeContainer par, double offset, double maxOffset) {
ArrayList<TimelineEntry> timeline = new ArrayList<TimelineEntry>();
ArrayList<TimelineEntry> timeline = new ArrayList<>();
// Set my begin at first
TimeList myBeginList = par.getBegin();
@@ -145,7 +145,7 @@ public class SmilPlayer implements Runnable {
private static ArrayList<TimelineEntry> getSeqTimeline(
ElementSequentialTimeContainer seq, double offset, double maxOffset) {
ArrayList<TimelineEntry> timeline = new ArrayList<TimelineEntry>();
ArrayList<TimelineEntry> timeline = new ArrayList<>();
double orgOffset = offset;
// Set my begin at first
@@ -211,7 +211,7 @@ public class SmilPlayer implements Runnable {
return getSeqTimeline((ElementSequentialTimeContainer) element, offset, maxOffset);
} else {
// Not ElementTimeContainer here
ArrayList<TimelineEntry> timeline = new ArrayList<TimelineEntry>();
ArrayList<TimelineEntry> timeline = new ArrayList<>();
TimeList beginList = element.getBegin();
for (int i = 0; i < beginList.getLength(); ++i) {
@@ -301,7 +301,7 @@ public class SmilPlayer implements Runnable {
mAllEntries = getTimeline(mRoot, 0, Long.MAX_VALUE);
mMediaTimeUpdatedEvent = ((DocumentEvent) mRoot).createEvent("Event");
mMediaTimeUpdatedEvent.initEvent(MEDIA_TIME_UPDATED_EVENT, false, false);
mActiveElements = new ArrayList<ElementTime>();
mActiveElements = new ArrayList<>();
}
public synchronized void play() {
@@ -529,7 +529,7 @@ public class SmilPlayer implements Runnable {
}
private void stopCurrentSlide() {
HashSet<TimelineEntry> skippedEntries = new HashSet<TimelineEntry>();
HashSet<TimelineEntry> skippedEntries = new HashSet<>();
int totalEntries = mAllEntries.size();
for (int i = mCurrentElement; i < totalEntries; i++) {
// Stop any started entries, and skip the not started entries until
@@ -64,7 +64,7 @@ public class EndlessJabberInterface {
editor.putString("InterfaceClass", concreteImplementation.getName());
editor.putBoolean("SendSMS", sendSMS);
editor.putBoolean("SendMMS", sendMMS);
editor.commit();
editor.apply();
SendInfoToEndlessJabber(context);
}
@@ -74,7 +74,7 @@ public class EndlessJabberInterface {
public static void DisableIntegration(Context context, Class nameOfImplementation) {
SharedPreferences.Editor editor = context.getSharedPreferences("EndlessJabberSDK", Context.MODE_PRIVATE).edit();
editor.clear();
editor.commit();
editor.apply();
SendInfoToEndlessJabber(context);
}
@@ -7,72 +7,73 @@ import android.os.Bundle;
public class EndlessJabberWakefulService extends IntentService {
public EndlessJabberWakefulService() {
super("EndlessJabberWakefulService");
}
public EndlessJabberWakefulService() {
super("EndlessJabberWakefulService");
}
@Override
protected void onHandleIntent(Intent intent) {
Context context = getApplicationContext();
@Override
protected void onHandleIntent(Intent intent) {
Context context = getApplicationContext();
// Get the class to call
String implemenationClass = context.getSharedPreferences("EndlessJabberSDK", Context.MODE_PRIVATE).getString("InterfaceClass", null);
// Get the class to call
String implementationClass = context.getSharedPreferences("EndlessJabberSDK", Context.MODE_PRIVATE).getString("InterfaceClass", null);
if (implemenationClass == null) {
return;
}
if (implementationClass != null) {
IEndlessJabberImplementation instanceOfMyClass;
try {
instanceOfMyClass = (IEndlessJabberImplementation) Class.forName(implementationClass).newInstance();
IEndlessJabberImplementation instanceOfMyClass;
try {
instanceOfMyClass = (IEndlessJabberImplementation) Class.forName(implemenationClass).newInstance();
Bundle extras = intent.getExtras();
Bundle extras = intent.getExtras();
switch (extras.getString("Action")) {
case "UpdateRead": {
long time = extras.getLong("Time");
int conversationID = extras.getInt("ConversationID");
instanceOfMyClass.UpdateReadMessages(context, time, conversationID);
break;
}
case "DeleteThread": {
switch (extras.getString("Action")) {
case "UpdateRead": {
long time = extras.getLong("Time");
int conversationID = extras.getInt("ConversationID");
instanceOfMyClass.UpdateReadMessages(context, time, conversationID);
break;
}
case "DeleteThread": {
int conversationID = extras.getInt("ConversationID");
instanceOfMyClass.DeleteThread(context, conversationID);
break;
}
case "SendMMS": {
int conversationID = extras.getInt("ConversationID");
instanceOfMyClass.DeleteThread(context, conversationID);
break;
}
case "SendMMS": {
boolean save = extras.getBoolean("Save");
boolean send = extras.getBoolean("Send");
String[] Recipients = extras.getStringArray("Recipients");
boolean save = extras.getBoolean("Save");
boolean send = extras.getBoolean("Send");
String[] Recipients = extras.getStringArray("Recipients");
MMSPart[] parts = new MMSPart[extras.getParcelableArray("Parts").length];
MMSPart[] parts = new MMSPart[extras.getParcelableArray("Parts").length];
for (int i = 0; i < parts.length; i++) {
parts[i] = (MMSPart) extras.getParcelableArray("Parts")[i];
}
for (int i = 0; i < parts.length; i++) {
parts[i] = (MMSPart) extras.getParcelableArray("Parts")[i];
}
instanceOfMyClass.SendMMS(context, Recipients, parts, extras.getString("Subject"), save, send);
break;
}
case "SendSMS": {
boolean send = extras.getBoolean("Send");
String[] Recipients = extras.getStringArray("Recipients");
String message = extras.getString("Message");
instanceOfMyClass.SendMMS(context, Recipients, parts, extras.getString("Subject"), save, send);
break;
}
case "SendSMS": {
boolean send = extras.getBoolean("Send");
String[] Recipients = extras.getStringArray("Recipients");
String message = extras.getString("Message");
instanceOfMyClass.SendSMS(context, Recipients, message, send);
break;
}
case "UpdateInfo": {
EndlessJabberInterface.SendInfoToEndlessJabber(context);
break;
}
}
} catch (InstantiationException e) {
instanceOfMyClass.SendSMS(context, Recipients, message, send);
break;
}
case "UpdateInfo": {
EndlessJabberInterface.SendInfoToEndlessJabber(context);
break;
}
}
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
} catch (IllegalAccessException e) {
}
} catch (ClassNotFoundException e) {
EndlessJabberReceiver.completeWakefulIntent(intent);
}
}
}
EndlessJabberReceiver.completeWakefulIntent(intent);
}
}
@@ -61,6 +61,10 @@ public class ConversationPrefsHelper {
return getBoolean(SettingsFragment.NOTIFICATION_CALL_BUTTON, false);
}
public boolean getDimissedReadEnabled() {
return getBoolean(SettingsFragment.DISMISSED_READ, false);
}
public void putString(String key, String value) {
mConversationPrefs.edit().putString(key, value).apply();
}
@@ -3,8 +3,8 @@ package com.moez.QKSMS.common;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.preference.PreferenceManager;
import com.moez.QKSMS.R;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.settings.SettingsFragment;
@@ -26,12 +26,12 @@ public class FontManager {
public static final int TEXT_TYPE_TOOLBAR = 0x8;
public static int getFontFamily(Context context) {
SharedPreferences prefs = MainActivity.getPrefs(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return Integer.parseInt(prefs.getString(SettingsFragment.FONT_FAMILY, "0"));
}
public static int getTextSize(Context context, int type) {
SharedPreferences prefs = MainActivity.getPrefs(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int fontSize = Integer.parseInt(prefs.getString(SettingsFragment.FONT_SIZE, "1"));
switch (type) {
@@ -112,7 +112,7 @@ public class FontManager {
}
public static int getFontWeight(Context context, boolean heavy) {
SharedPreferences prefs = MainActivity.getPrefs(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int fontWeight = Integer.parseInt(prefs.getString(SettingsFragment.FONT_WEIGHT, "0"));
int fontFamily = getFontFamily(context);
@@ -2,10 +2,9 @@ package com.moez.QKSMS.common;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.ui.MainActivity;
import java.util.Collections;
import java.util.HashSet;
@@ -38,7 +37,7 @@ public class LiveViewManager implements SharedPreferences.OnSharedPreferenceChan
}
public static void init(Context context) {
SharedPreferences prefs = MainActivity.getPrefs(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.registerOnSharedPreferenceChangeListener(sInstance);
}
@@ -82,6 +81,8 @@ public class LiveViewManager implements SharedPreferences.OnSharedPreferenceChan
/**
* Register a LiveView to be notified when this preference is updated.
* Note that you must first register the view, otherwise #refresh() will
* not be called on it
*
* @param v
* @param pref
@@ -0,0 +1,24 @@
package com.moez.QKSMS.common;
import com.moez.QKSMS.R;
import org.ligi.snackengage.conditions.AfterNumberOfOpportunities;
import org.ligi.snackengage.conditions.NeverAgainWhenClickedOnce;
import org.ligi.snackengage.snacks.RateSnack;
/* https://github.com/ligi/SnackEngage
* "This shows a snackbar after MainActivity was created *10* times and never again when once clicked on Rate" */
public class QKRateSnack extends RateSnack {
public QKRateSnack() {
withConditions(new NeverAgainWhenClickedOnce(), new AfterNumberOfOpportunities(10));
}
@Override public String getText(){
return getString(R.string.rate_title);
}
@Override public String getActionText(){
return getString(R.string.rate_action);
}
}
@@ -38,28 +38,29 @@ public class EmojiRegistry {
public static String parseEmojis(String body) {
if (TextUtils.isEmpty(body)) {
return body;
} else {
// whitespace and punctuation characters
String ACCEPTED_CHARS = "[\\s.,?:;'\"!]";
// explanation: we want to match:
// 1) either an accepted char or the beginning of the text (i.e. ^)
// 2) the actual emoji code (to be inserted in the loop)
// 3) either an accepted char or the end of the text (i.e. $)
String REGEX_TEMPLATE = String.format("(^|%s)%s(%s|$)", ACCEPTED_CHARS, "%s", ACCEPTED_CHARS);
// iterate over all the entries
for (Map.Entry<String, String> entry : EmojiRegistry.EMOJIS_MAP.entrySet()) {
// quote the emoji code because some characters like ) are protected in regex land
String quoted = Pattern.quote(entry.getKey());
String regex = String.format(REGEX_TEMPLATE, quoted);
// the $1 and $2 represent the character* that came before the emoji and the
// character* that came after the emoji
// * - or beginning / end of text
body = body.replaceAll(regex, "$1:" + entry.getValue() + ":$2");
}
return EmojiParser.parseToUnicode(body);
}
// whitespace and punctuation characters
String ACCEPTED_CHARS = "[\\s.,?:;'\"!]";
// explanation: we want to match:
// 1) either an accepted char or the beginning of the text (i.e. ^)
// 2) the actual emoji code (to be inserted in the loop)
// 3) either an accepted char or the end of the text (i.e. $)
String REGEX_TEMPLATE = String.format("(^|%s)%s(%s|$)", ACCEPTED_CHARS, "%s", ACCEPTED_CHARS);
// iterate over all the entries
for (Map.Entry<String, String> entry : EmojiRegistry.EMOJIS_MAP.entrySet()) {
// quote the emoji code because some characters like ) are protected in regex land
String quoted = Pattern.quote(entry.getKey());
String regex = String.format(REGEX_TEMPLATE, quoted);
// the $1 and $2 represent the character* that came before the emoji and the
// character* that came after the emoji
// * - or beginning / end of text
body = body.replaceAll(regex, "$1:" + entry.getValue() + ":$2");
}
return EmojiParser.parseToUnicode(body);
}
}
@@ -1,5 +1,8 @@
package com.moez.QKSMS.common.emoji;
/**
* Defines all supported emojis
*/
public class Emojis {
public static final String SMILE = "smile";
public static final String SMILEY = "smiley";
@@ -0,0 +1,5 @@
package com.moez.QKSMS.common.formatter;
public interface Formatter {
String format(String text);
}
@@ -0,0 +1,12 @@
package com.moez.QKSMS.common.formatter;
public class FormatterFactory {
private static final Formatter[] FORMATTERS = {new NumberToContactFormatter()};
public static String format(String text) {
for (Formatter formatter : FORMATTERS) {
text = formatter.format(text);
}
return text;
}
}
@@ -0,0 +1,43 @@
package com.moez.QKSMS.common.formatter;
import android.content.Context;
import android.telephony.TelephonyManager;
import com.google.i18n.phonenumbers.PhoneNumberMatch;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
import com.moez.QKSMS.QKSMSAppBase;
import com.moez.QKSMS.data.Contact;
public class NumberToContactFormatter implements Formatter {
String mCountryIso;
@Override
public String format(String text) {
PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
Iterable<PhoneNumberMatch> matches = phoneNumberUtil.findNumbers(text, getCurrentCountryIso());
for (PhoneNumberMatch match : matches) {
Contact contact = Contact.get(match.rawString(), true);
if (contact.isNamed()) {
String nameAndNumber = phoneNumberUtil.format(match.number(), PhoneNumberFormat.NATIONAL)
+ " (" + contact.getName() + ")";
text = text.replace(match.rawString(), nameAndNumber);
} // If the contact doesn't exist yet, leave the number as-is
}
return text;
}
public String getCurrentCountryIso() {
if (mCountryIso == null) {
TelephonyManager tm = (TelephonyManager) QKSMSAppBase.getApplication().getSystemService(Context.TELEPHONY_SERVICE);
mCountryIso = tm.getNetworkCountryIso();
// Just in case the TelephonyManager method failed, fallback to US
if (mCountryIso == null) {
mCountryIso = "US";
}
mCountryIso = mCountryIso.toUpperCase();
}
return mCountryIso;
}
}
@@ -73,7 +73,7 @@ public class CacheManager {
// ignore.
}
if (n != 0) return;
pref.edit().putInt(KEY_CACHE_UP_TO_DATE, 1).commit();
pref.edit().putInt(KEY_CACHE_UP_TO_DATE, 1).apply();
clear(context);
}
@@ -137,8 +137,8 @@ public class ImageCacheService {
public static final long crc64Long(byte[] buffer) {
long crc = INITIALCRC;
for (int k = 0, n = buffer.length; k < n; ++k) {
crc = sCrcTable[(((int) crc) ^ buffer[k]) & 0xff] ^ (crc >> 8);
for (byte aBuffer : buffer) {
crc = sCrcTable[(((int) crc) ^ aBuffer) & 0xff] ^ (crc >> 8);
}
return crc;
}
@@ -81,7 +81,7 @@ public class ThumbnailManager extends BackgroundLoaderManager {
public ThumbnailManager(final Context context) {
super(context);
mThumbnailCache = new SimpleCache<Uri, Bitmap>(8, 16, 0.75f, true);
mThumbnailCache = new SimpleCache<>(8, 16, 0.75f, true);
mContext = context;
mEmptyImageBitmap = BitmapFactory.decodeResource(context.getResources(),
@@ -2,12 +2,11 @@ package com.moez.QKSMS.common.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.format.DateUtils;
import android.preference.PreferenceManager;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import com.moez.QKSMS.QKSMSApp;
import com.moez.QKSMS.R;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.settings.SettingsFragment;
import java.text.ParseException;
@@ -49,7 +48,7 @@ public abstract class DateFormatter {
}
public static SimpleDateFormat accountFor24HourTime(Context context, SimpleDateFormat input) { //pass in 12 hour time. If needed, change to 24 hr.
SharedPreferences prefs = MainActivity.getPrefs(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean isUsing24HourTime = prefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(context));
if (isUsing24HourTime) {
@@ -122,6 +122,7 @@ public class Contact {
mIsStale = true;
mSendToVoicemail = false;
}
@Override
public String toString() {
return String.format("{ number=%s, name=%s, nameAndNumber=%s, label=%s, person_id=%d, hash=%d method_id=%d }",
@@ -260,6 +261,10 @@ public class Contact {
}
}
public synchronized boolean isNamed() {
return !TextUtils.isEmpty(mName);
}
public synchronized String getNameAndNumber() {
return mNameAndNumber;
}
@@ -19,7 +19,6 @@ import android.telephony.PhoneNumberUtils;
import android.util.Log;
import com.moez.QKSMS.common.TypefaceManager;
import com.moez.QKSMS.common.utils.Units;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import java.io.BufferedInputStream;
@@ -162,7 +161,7 @@ public class ContactHelper {
}
public static Drawable getDrawable(Context context, long id) {
return new BitmapDrawable(MainActivity.getRes(context), getBitmap(context, id));
return new BitmapDrawable(context.getResources(), getBitmap(context, id));
}
public static Bitmap getOwnerPhoto(Context context) {
@@ -189,7 +188,6 @@ public class ContactHelper {
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}
@@ -7,7 +7,6 @@ import android.graphics.Bitmap;
import android.net.Uri;
import com.moez.QKSMS.R;
import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.dialog.DefaultSmsHelper;
public class Message {
@@ -82,12 +81,12 @@ public class Message {
}
public boolean isMms() {
boolean bool = false;
boolean isMms = false;
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(MMS_SMS_CONTENT_PROVIDER, new String[]{SmsHelper.COLUMN_MMS}, "_id=" + id, null, null);
cursor.moveToFirst();
bool = "application/vnd.wap.multipart.related".equals(cursor.getString(cursor.getColumnIndex(SmsHelper.COLUMN_MMS)));
isMms = "application/vnd.wap.multipart.related".equals(cursor.getString(cursor.getColumnIndex(SmsHelper.COLUMN_MMS)));
} catch (Exception e) {
e.printStackTrace();
} finally {
@@ -95,7 +94,7 @@ public class Message {
cursor.close();
}
}
return bool;
return isMms;
}
public String getAddress() {
@@ -151,12 +150,6 @@ public class Message {
return photoBitmap;
}
public boolean isVisible() {
return getThreadId() == MainActivity.threadId &&
MainActivity.isShowing &&
!MainActivity.isContentHidden;
}
public void markSeen() {
ContentValues cv = new ContentValues();
cv.put("seen", true);
@@ -1247,7 +1247,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) {
return null;
}
return new Long(l[0]);
return Long.valueOf(l[0]);
}
/**
@@ -1266,7 +1266,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) {
return null;
}
return new Integer(l[0]);
return Integer.valueOf(l[0]);
}
/**
@@ -1285,7 +1285,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) {
return null;
}
return new Byte(l[0]);
return Byte.valueOf(l[0]);
}
/**
@@ -3,8 +3,8 @@ package com.moez.QKSMS.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.preference.PreferenceManager;
import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.settings.SettingsFragment;
public class BootReceiver extends BroadcastReceiver {
@@ -14,6 +14,6 @@ public class BootReceiver extends BroadcastReceiver {
NotificationManager.initQuickCompose(context, false, false);
NotificationManager.create(context);
SettingsFragment.updateAlarmManager(context, MainActivity.getPrefs(context).getBoolean(SettingsFragment.NIGHT_AUTO, false));
SettingsFragment.updateAlarmManager(context, PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.NIGHT_AUTO, false));
}
}
@@ -4,10 +4,9 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.widget.Toast;
import com.moez.QKSMS.R;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.settings.SettingsFragment;
public class DeliveredReceiver extends com.moez.QKSMS.mmssms.DeliveredReceiver {
@@ -19,11 +18,11 @@ public class DeliveredReceiver extends com.moez.QKSMS.mmssms.DeliveredReceiver {
switch (getResultCode()) {
case Activity.RESULT_OK:
if (MainActivity.getPrefs(context).getBoolean(SettingsFragment.DELIVERY_TOAST, true)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.DELIVERY_TOAST, true)) {
Toast.makeText(context, R.string.message_delivered, Toast.LENGTH_LONG).show();
}
if (MainActivity.getPrefs(context).getBoolean(SettingsFragment.DELIVERY_VIBRATE, true)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.DELIVERY_VIBRATE, true)) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(100);
}
@@ -4,8 +4,8 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.settings.SettingsFragment;
@@ -20,7 +20,7 @@ public class NightModeAutoReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ThemeManager.loadThemeProperties(context);
SharedPreferences prefs = MainActivity.getPrefs(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(SettingsFragment.NIGHT_AUTO, false)) {
Calendar calendar = Calendar.getInstance();
@@ -9,6 +9,7 @@ import android.graphics.Bitmap;
import android.net.Uri;
import android.os.IBinder;
import android.preference.PreferenceManager;
import com.moez.QKSMS.data.ContactHelper;
import com.moez.QKSMS.data.Message;
import com.moez.QKSMS.common.ConversationPrefsHelper;
@@ -30,7 +31,7 @@ public class NotificationService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
prefs = MainActivity.getPrefs(context);
prefs = PreferenceManager.getDefaultSharedPreferences(context);
Uri uri = Uri.parse(intent.getStringExtra(EXTRA_URI));
@@ -51,10 +52,9 @@ public class NotificationService extends Service {
conversationPrefs = new ConversationPrefsHelper(context, message.getThreadId());
if (conversationPrefs.getNotificationsEnabled()) {
// Only show QuickReply if we're outside of the app, and they have popups and
// QuickReply enabled.
if (!QKReplyActivity.sIsShowing && !MainActivity.isShowing && intent.getBooleanExtra(EXTRA_POPUP, false) &&
prefs.getBoolean(SettingsFragment.QUICKREPLY, true) && !MainActivity.isShowing) {
// Only show QuickReply if we're outside of the app, and they have popups and QuickReply enabled.
if (!QKReplyActivity.sIsShowing && message.getThreadId() != MainActivity.sThreadShowing &&
intent.getBooleanExtra(EXTRA_POPUP, false) && prefs.getBoolean(SettingsFragment.QUICKREPLY, true)) {
popupIntent = new Intent(context, QKReplyActivity.class);
popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -65,8 +65,7 @@ public class NotificationService extends Service {
// Get the photo for the PushBullet notification.
Bitmap photoBitmap = message.getPhotoBitmap();
if (photoBitmap == null) {
ContactHelper helper = new ContactHelper();
photoBitmap = helper.blankContact(context, message.getName());
photoBitmap = ContactHelper.blankContact(context, message.getName());
}
PushbulletService.mirrorMessage(context, "" + message.getThreadId(),
@@ -83,8 +83,8 @@ public class NotificationManager {
public static void init(final Context context) {
// Initialize the static shared prefs and resources.
sPrefs = MainActivity.getPrefs(context);
sRes = MainActivity.getRes(context);
sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
sRes = context.getResources();
// Listen for MMS events.
IntentFilter filter = new IntentFilter(TransactionService.TRANSACTION_COMPLETED_ACTION);
@@ -156,7 +156,7 @@ public class NotificationManager {
// If this message is in the foreground, mark it as read
Message message = new Message(context, lastMessage.mMsgId);
if (message.isVisible()) {
if (message.getThreadId() ==MainActivity.sThreadShowing) {
message.markRead();
return;
}
@@ -243,7 +243,7 @@ public class NotificationManager {
// If the message is visible (i.e. it is currently showing in the Main Activity),
// don't show a notification; just mark it as read and return.
Message message = new Message(context, lastMessage.mMsgId);
if (message.isVisible()) {
if (message.getThreadId() == MainActivity.sThreadShowing) {
message.markRead();
return;
}
@@ -474,6 +474,7 @@ public class NotificationManager {
.addAction(R.drawable.ic_accept, sRes.getString(R.string.read), readPI)
.extend(WearableIntentReceiver.getSingleConversationExtender(context, message.mContact, message.mAddress, threadId))
.setDeleteIntent(seenPI);
if (conversationPrefs.getDimissedReadEnabled()){builder.setDeleteIntent(readPI);}
if (conversationPrefs.getCallButtonEnabled()) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.provider.Telephony.Sms;
import android.telephony.SmsManager;
@@ -17,14 +18,13 @@ import com.google.android.mms.pdu_alt.CharacterSets;
import com.google.android.mms.pdu_alt.EncodedStringValue;
import com.google.android.mms.pdu_alt.MultimediaMessagePdu;
import com.google.android.mms.pdu_alt.PduPersister;
import com.moez.QKSMS.mmssms.Settings;
import com.moez.QKSMS.MmsConfig;
import com.moez.QKSMS.R;
import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.data.Message;
import com.moez.QKSMS.mmssms.Settings;
import com.moez.QKSMS.model.SlideModel;
import com.moez.QKSMS.model.SlideshowModel;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.messagelist.MessageColumns;
import com.moez.QKSMS.ui.messagelist.MessageItem;
import com.moez.QKSMS.ui.settings.SettingsFragment;
@@ -203,7 +203,7 @@ public class SmsHelper {
public static Settings getSendSettings(Context context) {
if (sendSettings == null) {
SharedPreferences prefs = MainActivity.getPrefs(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
sendSettings = new Settings();
sendSettings.setMmsc(prefs.getString(SettingsFragment.MMSC_URL, ""));
@@ -0,0 +1,39 @@
package com.moez.QKSMS.ui;
import android.content.Context;
import android.view.Menu;
import android.view.MenuInflater;
/**
* This interface is for fragments that must extend something other than a vanilla Fragment. It
* allows the fragment to get content animation callbacks without the developer having to
* rewrite the base class to extend BaseContentFragment.
*/
public interface ContentFragment {
/**
* Called when the content is being opened with an animation.
*/
void onContentOpening();
/**
* Called when the content has been opened, i.e. a opening animation has finished or it had
* been opened immediately.
*/
void onContentOpened();
/**
* Called when the content is being closed with an animation.
*/
void onContentClosing();
/**
* Called when the content has been closed, i.e. a closing animation has finished or it had
* been closed immediately.
*/
void onContentClosed();
/**
* Allows the MainActivity to delegate setting of the Toolbar title and menu
*/
void inflateToolbar(Menu menu, MenuInflater inflater, Context context);
}
@@ -6,14 +6,11 @@ import android.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ComponentInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.ContactsContract;
import android.support.v4.content.ContextCompat;
import android.telephony.PhoneNumberUtils;
@@ -25,22 +22,25 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import com.google.android.mms.pdu_alt.PduHeaders;
import com.moez.QKSMS.R;
import com.moez.QKSMS.common.ConversationPrefsHelper;
import com.moez.QKSMS.common.DonationManager;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.common.QKRateSnack;
import com.moez.QKSMS.common.google.DraftCache;
import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.common.utils.MessageUtils;
import com.moez.QKSMS.common.utils.Units;
import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.mmssms.Utils;
import com.moez.QKSMS.receiver.IconColorReceiver;
import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.base.QKContentFragment;
import com.moez.QKSMS.ui.compose.ComposeFragment;
import com.moez.QKSMS.ui.conversationlist.ConversationListFragment;
import com.moez.QKSMS.ui.dialog.ConversationNotificationSettingsDialog;
@@ -50,22 +50,23 @@ import com.moez.QKSMS.ui.dialog.mms.MMSSetupFragment;
import com.moez.QKSMS.ui.messagelist.MessageListFragment;
import com.moez.QKSMS.ui.search.SearchFragment;
import com.moez.QKSMS.ui.settings.SettingsFragment;
import com.moez.QKSMS.ui.view.QKCheckBox;
import com.moez.QKSMS.ui.view.slidingmenu.SlidingMenu;
import com.moez.QKSMS.ui.welcome.WelcomeActivity;
import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.listeners.ActionClickListener;
import org.ligi.snackengage.SnackEngage;
import org.ligi.snackengage.snacks.BaseSnack;
import java.net.URLDecoder;
import java.util.Collection;
public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListener, SlidingMenu.OnCloseListener,
SlidingMenu.OnOpenedListener, SlidingMenu.OnClosedListener, ActionClickListener {
SlidingMenu.OnOpenedListener, SlidingMenu.OnClosedListener, LiveView {
private final String TAG = "MainActivity";
public final static String EXTRA_THREAD_ID = "thread_id";
public static long sThreadShowing;
private final String KEY_TYPE = "type";
private final String KEY_POSITION = "position";
private final String KEY_THREADID = "thread_id";
@@ -84,16 +85,11 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
public static final String MMS_SETUP_DONT_ASK_AGAIN = "mmsSetupDontAskAgain";
// thread IDs are always nonnegative
public static long threadId = 0;
public static boolean isShowing = false;
public static boolean isContentHidden = true;
private static Resources res;
private static SharedPreferences prefs;
private long mThreadId = 0;
private SlidingMenu mSlidingMenu;
private ConversationListFragment menuFragment;
private Fragment content;
private ConversationListFragment mConversationList;
private ContentFragment mContent;
private long mWaitingForThreadId = -1;
private boolean mIsDestroyed = false;
@@ -106,9 +102,6 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPrefs(this);
getRes(this);
launchWelcomeActivity();
setContentView(R.layout.activity_main);
@@ -121,6 +114,13 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
onNewIntent(getIntent());
showDialogIfNeeded(savedInstanceState);
LiveViewManager.registerView(this);
LiveViewManager.registerPreference(this, SettingsFragment.BACKGROUND);
//Adds a small/non intrusive snackbar that asks the user to rate the app
SnackEngage.from(this).withSnack(new QKRateSnack().withDuration(BaseSnack.DURATION_LONG))
.build().engageWhenAppropriate();
}
/**
@@ -130,39 +130,39 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
private void setupFragments(Bundle savedInstanceState) {
int type = 0;
int position = 0;
threadId = 0;
mThreadId = 0;
if (savedInstanceState != null) {
type = savedInstanceState.getInt(KEY_TYPE, 0);
position = savedInstanceState.getInt(KEY_POSITION, 0);
threadId = savedInstanceState.getLong(KEY_THREADID, 0);
mThreadId = savedInstanceState.getLong(KEY_THREADID, 0);
}
menuFragment = new ConversationListFragment();
menuFragment.setPosition(position);
mConversationList = new ConversationListFragment();
mConversationList.setPosition(position);
getFragmentManager().beginTransaction()
.replace(R.id.menu_frame, menuFragment)
.replace(R.id.menu_frame, mConversationList)
.commit();
switch (type) {
case TYPE_COMPOSE:
content = new ComposeFragment();
mContent = new ComposeFragment();
break;
case TYPE_CONVERSATION:
Bundle args = new Bundle();
args.putLong(MessageListFragment.ARG_THREAD_ID, threadId);
content = MessageListFragment.getInstance(args);
args.putLong(MessageListFragment.ARG_THREAD_ID, mThreadId);
mContent = MessageListFragment.getInstance(args);
break;
case TYPE_SETTINGS:
content = SettingsFragment.newInstance(R.xml.settings_simple);
mContent = SettingsFragment.newInstance(R.xml.settings_simple);
break;
case TYPE_SEARCH:
content = new SearchFragment();
mContent = new SearchFragment();
break;
}
getFragmentManager().beginTransaction()
.replace(R.id.content_frame, content)
.replace(R.id.content_frame, (Fragment) mContent)
.commit();
}
@@ -208,7 +208,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
}
private void launchWelcomeActivity() {
if (prefs.getBoolean(SettingsFragment.WELCOME_SEEN, false)) {
if (mPrefs.getBoolean(SettingsFragment.WELCOME_SEEN, false)) {
// User has already seen the welcome screen
return;
}
@@ -226,7 +226,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
}
private void setupSlidingMenu() {
setSlidingTabEnabled(prefs.getBoolean(SettingsFragment.SLIDING_TAB, false));
setSlidingTabEnabled(mPrefs.getBoolean(SettingsFragment.SLIDING_TAB, false));
mSlidingMenu.setBehindScrollScale(0.5f);
mSlidingMenu.setFadeDegree(0.5f);
mSlidingMenu.setOnOpenListener(this);
@@ -257,55 +257,32 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
public boolean onPrepareOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
menu.clear();
if (mSlidingMenu.isMenuShowing() || content == null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
setTitle(this.menuFragment.getTitleId());
if (mSlidingMenu.isMenuShowing() || mContent == null) {
showBackButton(false);
setTitle(mConversationList.getTitleId());
inflater.inflate(R.menu.coversation_list, menu);
} else {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (content instanceof MessageListFragment) {
inflater.inflate(R.menu.conversation, menu);
((MessageListFragment) content).setTitle();
} else if (content instanceof SearchFragment) {
setTitle(getString(R.string.title_search));
inflater.inflate(R.menu.search, menu);
} else if (content instanceof SettingsFragment) {
setTitle(getString(R.string.title_settings));
inflater.inflate(R.menu.settings, menu);
MenuItem simplePrefs = menu.findItem(R.id.simple_settings);
if (prefs.getBoolean(SettingsFragment.SIMPLE_PREFS, true)) {
simplePrefs.setTitle(R.string.menu_show_all_prefs);
} else {
simplePrefs.setTitle(R.string.menu_show_fewer_prefs);
}
} else if (content instanceof ComposeFragment) {
setTitle(getString(R.string.title_compose));
inflater.inflate(R.menu.compose, menu);
}
showBackButton(true);
mContent.inflateToolbar(menu, inflater, this);
}
return super.onCreateOptionsMenu(menu);
return super.onPrepareOptionsMenu(menu);
}
public Fragment getMenuFragment() {
return menuFragment;
public Fragment getConversationList() {
return mConversationList;
}
public Fragment getContent() {
return content;
return (Fragment) mContent;
}
public long getThreadId() {
return threadId;
return mThreadId;
}
@Override
@@ -315,8 +292,8 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
onKeyUp(KeyEvent.KEYCODE_BACK, null);
break;
case R.id.simple_settings:
prefs.edit().putBoolean(SettingsFragment.SIMPLE_PREFS,
!prefs.getBoolean(SettingsFragment.SIMPLE_PREFS, true)).apply();
mPrefs.edit().putBoolean(SettingsFragment.SIMPLE_PREFS,
!mPrefs.getBoolean(SettingsFragment.SIMPLE_PREFS, true)).apply();
case R.id.menu_settings:
switchContent(SettingsFragment.newInstance(R.xml.settings_simple), true);
break;
@@ -397,8 +374,8 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
}
return true;
} else {
if (menuFragment.isShowingBlocked()) {
menuFragment.setShowingBlocked(false);
if (mConversationList.isShowingBlocked()) {
mConversationList.setShowingBlocked(false);
} else {
finish();
}
@@ -411,9 +388,9 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
@Override
protected void onPause() {
super.onPause();
isShowing = false;
sThreadShowing = 0;
if (!mSlidingMenu.isMenuShowing()) {
QKContentFragment.notifyOnContentClosed(content);
mContent.onContentClosed();
}
}
@@ -433,11 +410,16 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
@Override
protected void onResume() {
super.onResume();
isShowing = true;
ThemeManager.loadThemeProperties(this);
if (!mSlidingMenu.isMenuShowing()) {
QKContentFragment.notifyOnContentOpened(content);
mContent.onContentOpened();
}
if (mContent != null && mContent instanceof MessageListFragment) {
sThreadShowing = ((MessageListFragment) mContent).getThreadId();
} else {
sThreadShowing = 0;
}
NotificationManager.initQuickCompose(this, false, false);
@@ -497,10 +479,10 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
}
private void beginMmsSetup() {
if (!prefs.getBoolean(MMS_SETUP_DONT_ASK_AGAIN, false) &&
TextUtils.isEmpty(prefs.getString(SettingsFragment.MMSC_URL, "")) &&
TextUtils.isEmpty(prefs.getString(SettingsFragment.MMS_PROXY, "")) &&
TextUtils.isEmpty(prefs.getString(SettingsFragment.MMS_PORT, ""))) {
if (!mPrefs.getBoolean(MMS_SETUP_DONT_ASK_AGAIN, false) &&
TextUtils.isEmpty(mPrefs.getString(SettingsFragment.MMSC_URL, "")) &&
TextUtils.isEmpty(mPrefs.getString(SettingsFragment.MMS_PROXY, "")) &&
TextUtils.isEmpty(mPrefs.getString(SettingsFragment.MMS_PORT, ""))) {
// Launch the MMS setup fragment here. This is a series of dialogs that will guide the
// user through the MMS setup process.
@@ -530,26 +512,26 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
outState.putBoolean(KEY_MMS_SETUP_FRAGMENT_DISMISSED, true);
}
outState.putInt(KEY_TYPE, content instanceof MessageListFragment ? TYPE_CONVERSATION :
content instanceof SettingsFragment ? TYPE_SETTINGS :
content instanceof SearchFragment ? TYPE_SEARCH : TYPE_COMPOSE);
outState.putInt(KEY_POSITION, menuFragment.getPosition());
outState.putLong(KEY_THREADID, threadId);
outState.putInt(KEY_TYPE, mContent instanceof MessageListFragment ? TYPE_CONVERSATION :
mContent instanceof SettingsFragment ? TYPE_SETTINGS :
mContent instanceof SearchFragment ? TYPE_SEARCH : TYPE_COMPOSE);
outState.putInt(KEY_POSITION, mConversationList.getPosition());
outState.putLong(KEY_THREADID, mThreadId);
}
public void switchContent(Fragment fragment, boolean animate) {
public void switchContent(ContentFragment fragment, boolean animate) {
// Make sure that the activity isn't destroyed before making fragment transactions.
if (fragment != null && !mIsDestroyed) {
KeyboardUtils.hide(this);
content = fragment;
mContent = fragment;
FragmentManager m = getFragmentManager();
// Only do a replace if it is a different fragment.
if (fragment != m.findFragmentById(R.id.content_frame)) {
getFragmentManager()
.beginTransaction()
.replace(R.id.content_frame, fragment)
.replace(R.id.content_frame, (Fragment) fragment)
.commitAllowingStateLoss();
}
@@ -585,56 +567,58 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
MessageListFragment fragment = MessageListFragment.getInstance(args);
// Save the thread ID here and switch the content
MainActivity.threadId = threadId;
mThreadId = threadId;
sThreadShowing = threadId;
switchContent(fragment, animate);
}
@Override
public void onOpen() {
invalidateOptionsMenu();
isContentHidden = true;
sThreadShowing = 0;
// Notify the content that it is being closed, since the menu (i.e. conversation list) is
// being opened.
QKContentFragment.notifyOnContentClosing(content);
// Notify the content that it is being closed, since the menu (i.e. conversation list) is being opened.
if (mContent != null) mContent.onContentClosing();
// Hide the soft keyboard
KeyboardUtils.hide(this, getCurrentFocus());
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
@Override
public void onActionClicked(Snackbar snackbar) {
showBackButton(false);
}
@Override
public void onClose() {
invalidateOptionsMenu();
isContentHidden = false;
// Notify the content that it is being opened, since the menu (i.e. conversation list) is
// being closed.
QKContentFragment.notifyOnContentOpening(content);
// Notify the content that it is being opened, since the menu (i.e. conversation list) is being closed.
if (mContent != null) {
mContent.onContentOpening();
}
if (mContent != null && mContent instanceof MessageListFragment) {
sThreadShowing = ((MessageListFragment) mContent).getThreadId();
} else {
sThreadShowing = 0;
}
// Hide the soft keyboard
KeyboardUtils.hide(this, getCurrentFocus());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
showBackButton(true);
}
@Override
public void onOpened() {
// When the menu (i.e. the conversation list) has been opened, the content has been opened.
// So notify the content fragment.
QKContentFragment.notifyOnContentClosed(content);
if (mContent != null) mContent.onContentClosed();
}
@Override
public void onClosed() {
// When the menu (i.e. the conversation list) has been closed, the content has been opened.
// So notify the content fragment.
QKContentFragment.notifyOnContentOpened(content);
if (mContent != null) mContent.onContentOpened();
}
/**
@@ -647,7 +631,8 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
* @param hasLockedMessages whether the thread(s) contain locked messages
* @param context used to load the various UI elements
*/
public static void confirmDeleteThreadDialog(final DeleteThreadListener listener, Collection<Long> threadIds, boolean hasLockedMessages, Context context) {
public static void confirmDeleteThreadDialog(final DeleteThreadListener listener, Collection<Long> threadIds,
boolean hasLockedMessages, Context context) {
View contents = View.inflate(context, R.layout.dialog_delete_thread, null);
android.widget.TextView msg = (android.widget.TextView) contents.findViewById(R.id.message);
@@ -660,7 +645,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
R.plurals.confirm_delete_conversation, cnt, cnt));
}
final QKCheckBox checkbox = (QKCheckBox) contents.findViewById(R.id.delete_locked);
final CheckBox checkbox = (CheckBox) contents.findViewById(R.id.delete_locked);
if (!hasLockedMessages) {
checkbox.setVisibility(View.GONE);
} else {
@@ -683,18 +668,13 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
.show();
}
public static SharedPreferences getPrefs(Context context) {
if (prefs == null) {
prefs = PreferenceManager.getDefaultSharedPreferences(context);
}
return prefs;
}
public static Resources getRes(Context context) {
if (res == null) {
res = context.getResources();
}
return res;
@Override
public void refresh() {
// Update the background color. This code is important during the welcome screen setup, when the activity
// in the ThemeManager isn't the MainActivity
findViewById(R.id.menu_frame).getRootView().setBackgroundColor(ThemeManager.getBackgroundColor());
findViewById(R.id.menu_frame).setBackgroundColor(ThemeManager.getBackgroundColor());
findViewById(R.id.content_frame).setBackgroundColor(ThemeManager.getBackgroundColor());
}
public static class DeleteThreadListener implements DialogInterface.OnClickListener {
@@ -14,6 +14,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.Gravity;
@@ -252,8 +253,8 @@ public class ThemeManager {
* of each activity that contains fragments that use ThemeManager
*/
public static void loadThemeProperties(Context context) {
sPrefs = MainActivity.getPrefs(context);
sResources = MainActivity.getRes(context);
sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
sResources = context.getResources();
mContext = context;
@@ -1,30 +1,30 @@
package com.moez.QKSMS.ui.base;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public abstract class ClickyViewHolder<DataType> extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
public RecyclerCursorAdapter.ItemClickListener<DataType> clickListener;
public DataType data;
public Context context;
public RecyclerCursorAdapter.ItemClickListener<DataType> mClickListener;
public DataType mData;
public QKActivity mContext;
public ClickyViewHolder(View itemView) {
public ClickyViewHolder(QKActivity context, View itemView) {
super(itemView);
mContext = context;
}
@Override
public void onClick(View v) {
if (clickListener != null) {
clickListener.onItemClick(data, v);
if (mClickListener != null) {
mClickListener.onItemClick(mData, v);
}
}
@Override
public boolean onLongClick(View v) {
if (clickListener != null) {
clickListener.onItemLongClick(data, v);
if (mClickListener != null) {
mClickListener.onItemLongClick(mData, v);
}
return true;
@@ -1,11 +1,14 @@
package com.moez.QKSMS.ui.base;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
@@ -21,7 +24,7 @@ import com.moez.QKSMS.ui.view.QKTextView;
import java.util.ArrayList;
public class QKActivity extends ActionBarActivity {
public abstract class QKActivity extends ActionBarActivity {
private final String TAG = "QKActivity";
private Toolbar mToolbar;
@@ -29,9 +32,14 @@ public class QKActivity extends ActionBarActivity {
private ImageView mOverflowButton;
private Menu mMenu;
protected Resources mRes;
protected SharedPreferences mPrefs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRes = getResources();
getPrefs(); // set the preferences if they haven't been set. this method takes care of that logic for us
}
/**
@@ -56,6 +64,17 @@ public class QKActivity extends ActionBarActivity {
ThemeManager.loadThemeProperties(this);
}
protected void showBackButton(boolean show) {
getSupportActionBar().setDisplayHomeAsUpEnabled(show);
}
public SharedPreferences getPrefs() {
if (mPrefs == null) {
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
}
return mPrefs;
}
public void colorMenuIcons(Menu menu, int color) {
// Toolbar navigation icon
@@ -132,12 +151,11 @@ public class QKActivity extends ActionBarActivity {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
public boolean onPrepareOptionsMenu(Menu menu) {
// Save a reference to the menu so that we can quickly access menu icons later.
mMenu = menu;
colorMenuIcons(mMenu, ThemeManager.getTextOnColorPrimary());
return super.onCreateOptionsMenu(mMenu);
return true;
}
@Override
@@ -1,11 +1,10 @@
package com.moez.QKSMS.ui.base;
import android.app.Fragment;
import android.os.Bundle;
import android.view.View;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.ui.ContentFragment;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.settings.SettingsFragment;
@@ -23,21 +22,7 @@ import com.moez.QKSMS.ui.settings.SettingsFragment;
* - Manages the current state of the fragment in terms of the animation, i.e. opening, fully
* opened, etc.
*/
public class QKContentFragment extends QKFragment implements LiveView {
private static final boolean LOCAL_LOGV = false;
/**
* Holds the state of the content in the menu.
*/
private int mContentAnimationState = STATE_OPENED;
public static final int STATE_OPENING = 0;
public static final int STATE_OPENED = 1;
public static final int STATE_CLOSING = 2;
public static final int STATE_CLOSED = 3;
protected MainActivity mContext;
public abstract class QKContentFragment extends QKFragment implements LiveView, ContentFragment {
/**
* It's not strictly necessary, but subclasses should call through to super() in their
@@ -78,7 +63,6 @@ public class QKContentFragment extends QKFragment implements LiveView {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = (MainActivity) getActivity();
LiveViewManager.registerPreference(this, SettingsFragment.BACKGROUND);
}
@@ -88,71 +72,30 @@ public class QKContentFragment extends QKFragment implements LiveView {
refresh();
}
/**
* @return The current state of the animation of the content.
*/
public int getContentAnimationState() {
return mContentAnimationState;
}
/**
* Call on a BaseContentFragment to notify it that it is opening.
*/
public final void performOnContentOpening() {
mContentAnimationState = STATE_OPENING;
onContentOpening();
}
/**
* Call on a BaseContentFragment to notify it that it has been opened fully, i.e. an opening
* animation has finished or the Fragment has been opened immediately.
*/
public final void performOnContentOpened() {
mContentAnimationState = STATE_OPENED;
onContentOpened();
}
/**
* Call on a BaseContentFragment to notify it that it is closing.
*/
public final void performOnContentClosing() {
mContentAnimationState = STATE_CLOSING;
onContentClosing();
}
/**
* Call on a BaseContentFragment to notify it that it has been closed fully, i.e. a closing
* animation has finished or the Fragment has been closed immediately.
*/
public final void performOnContentClosed() {
mContentAnimationState = STATE_CLOSED;
onContentClosed();
}
/**
* Called when the content is being opened with an animation.
*/
protected void onContentOpening() {
public void onContentOpening() {
}
/**
* Called when the content has been opened, i.e. a opening animation has finished or it had
* been opened immediately.
*/
protected void onContentOpened() {
public void onContentOpened() {
}
/**
* Called when the content is being closed with an animation.
*/
protected void onContentClosing() {
public void onContentClosing() {
}
/**
* Called when the content has been closed, i.e. a closing animation has finished or it had
* been closed immediately.
*/
protected void onContentClosed() {
public void onContentClosed() {
}
@Override
@@ -162,67 +105,4 @@ public class QKContentFragment extends QKFragment implements LiveView {
view.setBackgroundColor(ThemeManager.getBackgroundColor());
}
}
/**
* This interface is for fragments that must extend something other than a vanilla Fragment. It
* allows the fragment to get content animation callbacks without the developer having to
* rewrite the base class to extend BaseContentFragment.
*/
public interface ContentFragment {
/**
* Called when the content is being opened with an animation.
*/
void onContentOpening();
/**
* Called when the content has been opened, i.e. a opening animation has finished or it had
* been opened immediately.
*/
void onContentOpened();
/**
* Called when the content is being closed with an animation.
*/
void onContentClosing();
/**
* Called when the content has been closed, i.e. a closing animation has finished or it had
* been closed immediately.
*/
void onContentClosed();
}
// The following static methods will notify a Fragment about their content animations if
// appropriate, or do nothing otherwise.
public static void notifyOnContentOpening(Fragment fragment) {
if (fragment instanceof QKContentFragment) {
((QKContentFragment) fragment).performOnContentOpening();
} else if (fragment instanceof ContentFragment) {
((ContentFragment) fragment).onContentOpening();
}
}
public static void notifyOnContentOpened(Fragment fragment) {
if (fragment instanceof QKContentFragment) {
((QKContentFragment) fragment).performOnContentOpened();
} else if (fragment instanceof ContentFragment) {
((ContentFragment) fragment).onContentOpened();
}
}
public static void notifyOnContentClosing(Fragment fragment) {
if (fragment instanceof QKContentFragment) {
((QKContentFragment) fragment).performOnContentClosing();
} else if (fragment instanceof ContentFragment) {
((ContentFragment) fragment).onContentClosing();
}
}
public static void notifyOnContentClosed(Fragment fragment) {
if (fragment instanceof QKContentFragment) {
((QKContentFragment) fragment).performOnContentClosed();
} else if (fragment instanceof ContentFragment) {
((ContentFragment) fragment).onContentClosed();
}
}
}
@@ -1,10 +1,26 @@
package com.moez.QKSMS.ui.base;
import android.app.Fragment;
import android.os.Bundle;
import com.moez.QKSMS.QKSMSApp;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.settings.SettingsFragment;
import com.squareup.leakcanary.RefWatcher;
public class QKFragment extends Fragment {
public class QKFragment extends Fragment implements LiveView {
protected QKActivity mContext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = (QKActivity) getActivity();
LiveViewManager.registerView(this);
LiveViewManager.registerPreference(this, SettingsFragment.BACKGROUND);
}
@Override
public void onDestroy() {
@@ -12,4 +28,11 @@ public class QKFragment extends Fragment {
RefWatcher refWatcher = QKSMSApp.getRefWatcher(getActivity());
refWatcher.watch(this);
}
@Override
public void refresh() {
if (getView() != null) {
getView().setBackgroundColor(ThemeManager.getBackgroundColor());
}
}
}
@@ -1,6 +1,5 @@
package com.moez.QKSMS.ui.base;
import android.content.Context;
import android.database.Cursor;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@@ -21,9 +20,13 @@ public abstract class RecyclerCursorAdapter<VH extends RecyclerView.ViewHolder,
void onMultiSelectStateChanged(boolean enabled);
}
protected Context mContext;
protected QKActivity mContext;
protected Cursor mCursor;
public RecyclerCursorAdapter(QKActivity context) {
mContext = context;
}
protected ArrayList<Long> mSelectedItems = new ArrayList<>();
protected ItemClickListener<DataType> mItemClickListener;
@@ -5,17 +5,18 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import com.android.ex.chips.recipientchip.DrawableRecipientChip;
import com.moez.QKSMS.mmssms.Utils;
import com.moez.QKSMS.R;
import com.moez.QKSMS.interfaces.ActivityLauncher;
import com.moez.QKSMS.interfaces.RecipientProvider;
import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.common.utils.PhoneNumberUtils;
import com.moez.QKSMS.interfaces.ActivityLauncher;
import com.moez.QKSMS.interfaces.RecipientProvider;
import com.moez.QKSMS.mmssms.Utils;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.base.QKContentFragment;
import com.moez.QKSMS.ui.view.AutoCompleteContactView;
@@ -42,8 +43,6 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
public static final String FOCUS_RECIPIENTS = "recipients";
public static final String FOCUS_REPLY = "reply";
private Context mContext;
private AutoCompleteContactView mRecipients;
private ComposeView mComposeView;
private StarredContactsView mStarredContactsView;
@@ -67,8 +66,8 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
* Returns a ComposeFragment, configured with the args. If possible, the given fragment
* is used instead of creating a new ComposeFragment.
*
* @param args A Bundle with options for configuring this fragment. See the ARG_ constants for
* configuration options.
* @param args A Bundle with options for configuring this fragment. See the ARG_ constants for
* configuration options.
* @param reuseFragment A fragment that can be used instead of creating a new one.
* @return the ComposeFragment, which may be recycled
*/
@@ -77,7 +76,7 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
// Check if we can reuse the passed fragment.
if (reuseFragment != null && reuseFragment instanceof ComposeFragment) {
f = (ComposeFragment)reuseFragment;
f = (ComposeFragment) reuseFragment;
} else {
f = new ComposeFragment();
}
@@ -94,12 +93,6 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
mPendingFocus = true;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getActivity();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -142,7 +135,7 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
}
@Override
protected void onContentOpened() {
public void onContentOpened() {
setupInput();
}
@@ -167,13 +160,21 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch
}
@Override
protected void onContentClosing() {
public void onContentClosing() {
// Clear the focus from this fragment.
if (getActivity() != null && getActivity().getCurrentFocus() != null) {
getActivity().getCurrentFocus().clearFocus();
}
}
@Override
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
inflater.inflate(R.menu.compose, menu);
mContext.setTitle(R.string.title_compose);
super.onCreateOptionsMenu(menu, inflater);
}
/**
* @return the addresses of all the contacts in the AutoCompleteContactsView.
*/
@@ -1,8 +1,6 @@
package com.moez.QKSMS.ui.conversationlist;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
@@ -17,8 +15,8 @@ import com.moez.QKSMS.common.utils.DateFormatter;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
import com.moez.QKSMS.ui.settings.SettingsFragment;
@@ -32,9 +30,9 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
private final Drawable mUnread;
private final Drawable mError;
public ConversationListAdapter(Context context) {
mContext = context;
mPrefs = MainActivity.getPrefs(mContext);
public ConversationListAdapter(QKActivity context) {
super(context);
mPrefs = mContext.getPrefs();
mMuted = ContextCompat.getDrawable(context, R.drawable.ic_mute);
mUnread = ContextCompat.getDrawable(context, R.drawable.ic_unread);
@@ -54,16 +52,16 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
public ConversationListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(R.layout.list_item_conversation, null);
return new ConversationListViewHolder(view);
return new ConversationListViewHolder(mContext, view);
}
@Override
public void onBindViewHolder(ConversationListViewHolder holder, int position) {
final Conversation conversation = getItem(position);
holder.data = conversation;
holder.context = mContext;
holder.clickListener = mItemClickListener;
holder.mData = conversation;
holder.mContext = mContext;
holder.mClickListener = mItemClickListener;
holder.root.setOnClickListener(holder);
holder.root.setOnLongClickListener(holder);
@@ -31,9 +31,9 @@ import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.data.ConversationLegacy;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.ui.ContentFragment;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.base.QKFragment;
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
import com.moez.QKSMS.ui.compose.ComposeFragment;
@@ -64,7 +64,6 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
private ConversationListAdapter mAdapter;
private LinearLayoutManager mLayoutManager;
private ConversationDetailsDialog mConversationDetailsDialog;
private QKActivity mContext;
private SharedPreferences mPrefs;
private MenuItem mBlockedItem;
private boolean mShowBlocked = false;
@@ -76,7 +75,6 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = (QKActivity) getActivity();
mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
setHasOptionsMenu(true);
@@ -258,7 +256,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
case MENU_NOTIFICATION_SETTINGS:
ConversationNotificationSettingsDialog.newInstance(threadId, name).setContext(mContext)
.show(mContext.getFragmentManager(), "notification prefs");
.show(getFragmentManager(), "notification prefs");
break;
case MENU_VIEW_DETAILS:
@@ -315,11 +313,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
getLoaderManager().restartLoader(0, null, this);
}
private void switchFragment(Fragment fragment) {
if (getActivity() == null) {
return;
}
// TODO
private void switchFragment(ContentFragment fragment) {
((MainActivity) getActivity()).switchContent(fragment, true);
}
@@ -14,6 +14,7 @@ import com.moez.QKSMS.data.ConversationLegacy;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.base.ClickyViewHolder;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.settings.SettingsFragment;
import com.moez.QKSMS.ui.view.AvatarView;
import com.moez.QKSMS.ui.view.QKTextView;
@@ -32,9 +33,9 @@ public class ConversationListViewHolder extends ClickyViewHolder<Conversation> i
protected AvatarView mAvatarView;
protected ImageView mSelected;
public ConversationListViewHolder(View view) {
super(view);
mPrefs = MainActivity.getPrefs(context);
public ConversationListViewHolder(QKActivity context, View view) {
super(context, view);
mPrefs = mContext.getPrefs();
root = view;
fromView = (QKTextView) view.findViewById(R.id.conversation_list_name);
@@ -53,10 +54,10 @@ public class ConversationListViewHolder extends ClickyViewHolder<Conversation> i
final Drawable drawable;
final String name;
if (data.getRecipients().size() == 1) {
Contact contact = data.getRecipients().get(0);
if (mData.getRecipients().size() == 1) {
Contact contact = mData.getRecipients().get(0);
if (contact.getNumber().equals(updated.getNumber())) {
drawable = contact.getAvatar(context, null);
drawable = contact.getAvatar(mContext, null);
name = contact.getName();
if (contact.existsInDatabase()) {
@@ -71,9 +72,9 @@ public class ConversationListViewHolder extends ClickyViewHolder<Conversation> i
name = "";
shouldUpdate = false;
}
} else if (data.getRecipients().size() > 1) {
} else if (mData.getRecipients().size() > 1) {
drawable = null;
name = "" + data.getRecipients().size();
name = "" + mData.getRecipients().size();
mAvatarView.assignContactUri(null);
} else {
drawable = null;
@@ -81,15 +82,15 @@ public class ConversationListViewHolder extends ClickyViewHolder<Conversation> i
mAvatarView.assignContactUri(null);
}
final ConversationLegacy conversationLegacy = new ConversationLegacy(context, data.getThreadId());
final ConversationLegacy conversationLegacy = new ConversationLegacy(mContext, mData.getThreadId());
if (shouldUpdate) {
((MainActivity) context).runOnUiThread(new Runnable() {
((MainActivity) mContext).runOnUiThread(new Runnable() {
@Override
public void run() {
mAvatarView.setImageDrawable(drawable);
mAvatarView.setContactName(name);
fromView.setText(formatMessage(data, conversationLegacy));
fromView.setText(formatMessage(mData, conversationLegacy));
}
});
}
@@ -102,13 +103,13 @@ public class ConversationListViewHolder extends ClickyViewHolder<Conversation> i
if (conversation.getMessageCount() > 1 && mPrefs.getBoolean(SettingsFragment.MESSAGE_COUNT, false)) {
int before = buf.length();
buf.append(context.getResources().getString(R.string.message_count_format, conversation.getMessageCount()));
buf.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.grey_light)), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
buf.append(mContext.getResources().getString(R.string.message_count_format, conversation.getMessageCount()));
buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.grey_light)), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
if (conversationLegacy.hasDraft()) {
buf.append(context.getResources().getString(R.string.draft_separator));
buf.append(mContext.getResources().getString(R.string.draft_separator));
int before = buf.length();
buf.append(context.getResources().getString(R.string.has_draft));
buf.append(mContext.getResources().getString(R.string.has_draft));
buf.setSpan(new ForegroundColorSpan(ThemeManager.getColor()), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
@@ -33,7 +33,6 @@ import com.moez.QKSMS.transaction.SmsHelper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -95,7 +94,7 @@ public class DeliveryReportHelper {
public List<DeliveryReportItem> getListItems() {
List<DeliveryReportItem> items = getReportItems();
if (items == null) {
items = new ArrayList<DeliveryReportItem>(1);
items = new ArrayList<>(1);
items.add(new DeliveryReportItem("", mContext.getString(R.string.status_none), null));
Log.w(LOG_TAG, "cursor == null");
}
@@ -191,15 +190,12 @@ public class DeliveryReportHelper {
private static MmsReportStatus queryStatusByRecipient(
Map<String, MmsReportStatus> status, String recipient) {
Set<String> recipientSet = status.keySet();
Iterator<String> iterator = recipientSet.iterator();
while (iterator.hasNext()) {
String r = iterator.next();
for (String r : recipientSet) {
if (SmsHelper.isEmailAddress(recipient)) {
if (TextUtils.equals(r, recipient)) {
return status.get(r);
}
}
else if (PhoneNumberUtils.compare(r, recipient)) {
} else if (PhoneNumberUtils.compare(r, recipient)) {
return status.get(r);
}
}
@@ -235,7 +235,7 @@ public class QKDialog extends DialogFragment {
}
public QKDialog buildMenu(final OnItemClickListener onItemClickListener) {
ArrayAdapter adapter = new ArrayAdapter<String>(mContext, R.layout.list_item_simple, mMenuItems);
ArrayAdapter adapter = new ArrayAdapter<>(mContext, R.layout.list_item_simple, mMenuItems);
ListView listView = new ListView(mContext);
listView.setAdapter(adapter);
listView.setDivider(null);
@@ -256,7 +256,7 @@ public class QKDialog extends DialogFragment {
}
public QKDialog setItems(String[] items, final OnItemClickListener onClickListener) {
ArrayAdapter adapter = new ArrayAdapter<String>(mContext, R.layout.list_item_simple, items);
ArrayAdapter adapter = new ArrayAdapter<>(mContext, R.layout.list_item_simple, items);
ListView listView = new ListView(mContext);
listView.setAdapter(adapter);
listView.setDivider(null);
@@ -1,31 +1,35 @@
package com.moez.QKSMS.ui.dialog.mms;
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.moez.QKSMS.mmssms.Settings;
import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.R;
import com.moez.QKSMS.mmssms.Apn;
import com.moez.QKSMS.mmssms.ApnUtils;
import com.moez.QKSMS.R;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.mmssms.Settings;
import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.ui.base.QKFragment;
import java.util.List;
import static com.moez.QKSMS.ui.dialog.mms.QKDialogFragment.*;
import static com.moez.QKSMS.ui.dialog.mms.QKDialogFragment.DISMISS_RESULT;
import static com.moez.QKSMS.ui.dialog.mms.QKDialogFragment.DialogFragmentListener;
import static com.moez.QKSMS.ui.dialog.mms.QKDialogFragment.LIST_ITEM_CLICK_RESULT;
import static com.moez.QKSMS.ui.dialog.mms.QKDialogFragment.NEGATIVE_BUTTON_RESULT;
import static com.moez.QKSMS.ui.dialog.mms.QKDialogFragment.NEUTRAL_BUTTON_RESULT;
import static com.moez.QKSMS.ui.dialog.mms.QKDialogFragment.POSITIVE_BUTTON_RESULT;
/**
* @author Shane Creighton-Young
* @since 2015-02-08
*/
public class MMSSetupFragment extends Fragment implements DialogFragmentListener {
public class MMSSetupFragment extends QKFragment implements DialogFragmentListener {
public static final String TAG = "MMSSetupFragment";
private static final boolean LOCAL_LOGV = true;
@@ -73,7 +77,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
super.onCreate(savedInstanceState);
// Get the APNs, which will be used in MMS setup.
mAPNs = ApnUtils.query(getActivity());
mAPNs = ApnUtils.query(mContext);
// Initialize arguments
initArguments();
@@ -140,7 +144,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
} else if (resultCode == NEGATIVE_BUTTON_RESULT) {
if (mArgDontAskAgainPref != null) {
// Save a "don't ask again" pref (this is the DON'T ASK AGAIN button).
MainActivity.getPrefs(getActivity())
mContext.getPrefs()
.edit()
.putBoolean(mArgDontAskAgainPref, true)
.commit();
@@ -158,7 +162,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
if (mArgDontAskAgainPref != null) {
// Don't annoy them with automatic configuration after we've tried and failed.
MainActivity.getPrefs(getActivity())
PreferenceManager.getDefaultSharedPreferences(mContext)
.edit()
.putBoolean(mArgDontAskAgainPref, true)
.commit();
@@ -167,7 +171,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
if (resultCode == POSITIVE_BUTTON_RESULT) {
// Send an email to the qksms team
contactSupport(getActivity());
contactSupport(mContext);
} else if (resultCode == NEGATIVE_BUTTON_RESULT) {
// Show "Next steps" dialog telling them how to set up MMS in the future.
@@ -180,7 +184,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
// Success! Save the APN settings and show them instructions for how to change
// settings later.
Apn apn = mAPNs.get(0);
ApnUtils.persistApn(getActivity(), apn);
ApnUtils.persistApn(mContext, apn);
launchDialog(SUCCESS);
@@ -249,7 +253,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
if (MULTIPLE_CONFIGURATIONS_FOUND.equals(dialogTag)) {
if (resultCode == LIST_ITEM_CLICK_RESULT) {
Apn apn = mAPNs.get(index);
ApnUtils.persistApn(getActivity(), apn);
ApnUtils.persistApn(mContext, apn);
launchDialog(SUCCESS);
}
@@ -267,7 +271,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
if (SET_UP_MMS.equals(dialogTag)) {
QKDialogFragment f = new QKDialogFragment()
.setContext(getActivity())
.setContext(mContext)
.setTitle(R.string.set_up_mms_title)
.setMessage(R.string.set_up_mms_description)
.setListener(this)
@@ -285,7 +289,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
} else if (NO_CONFIGURATIONS_FOUND.equals(dialogTag)) {
new QKDialogFragment()
.setContext(getActivity())
.setContext(mContext)
.setTitle(R.string.mms_setup_no_configurations_found_title)
.setMessage(R.string.mms_setup_no_configurations_found_body)
.setListener(this)
@@ -299,7 +303,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
carrier);
new QKDialogFragment()
.setContext(getActivity())
.setContext(mContext)
.setTitle(R.string.mms_setup_one_configuration_found_title)
.setMessage(message)
.setListener(this)
@@ -314,7 +318,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
}
new QKDialogFragment()
.setContext(getActivity())
.setContext(mContext)
.setTitle(R.string.mms_setup_multiple_configurations_found_title)
.setMessage(R.string.mms_setup_multiple_configurations_found_body)
.setListener(this)
@@ -324,7 +328,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
} else if (SETTING_UP_MMS_LATER.equals(dialogTag)) {
new QKDialogFragment()
.setContext(getActivity())
.setContext(mContext)
.setTitle(R.string.mms_setup_setting_up_later_title)
.setMessage(R.string.mms_setup_setting_up_later_body)
.setListener(this)
@@ -333,7 +337,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
} else if (NEXT_STEPS.equals(dialogTag)) {
new QKDialogFragment()
.setContext(getActivity())
.setContext(mContext)
.setTitle(R.string.mms_setup_next_steps_title)
.setMessage(R.string.mms_setup_next_steps_body)
.setListener(this)
@@ -342,7 +346,7 @@ public class MMSSetupFragment extends Fragment implements DialogFragmentListener
} else if (SUCCESS.equals(dialogTag)) {
new QKDialogFragment()
.setContext(getActivity())
.setContext(mContext)
.setTitle(R.string.mms_setup_success_title)
.setMessage(R.string.mms_setup_success_body)
.setListener(this)
@@ -301,7 +301,7 @@ public class QKDialogFragment extends DialogFragment {
}
public QKDialogFragment setItems(String[] items) {
ArrayAdapter adapter = new ArrayAdapter<String>(mContext, R.layout.list_item_simple, items);
ArrayAdapter adapter = new ArrayAdapter<>(mContext, R.layout.list_item_simple, items);
ListView listView = new ListView(mContext);
listView.setAdapter(adapter);
listView.setDivider(null);
@@ -36,9 +36,9 @@ import com.google.android.mms.pdu_alt.NotificationInd;
import com.google.android.mms.pdu_alt.PduHeaders;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.RetrieveConf;
import com.google.android.mms.pdu_alt.SendReq;
import com.moez.QKSMS.QKSMSApp;
import com.moez.QKSMS.R;
import com.moez.QKSMS.common.formatter.FormatterFactory;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.model.SlideModel;
import com.moez.QKSMS.model.SlideshowModel;
@@ -152,6 +152,7 @@ public class MessageItem {
mContact = Contact.get(mAddress, canBlock).getName();
}
mBody = cursor.getString(columnsMap.mColumnSmsBody);
mBody = FormatterFactory.format(mBody);
// Unless the message is currently in the progress of being sent, it gets a time stamp.
if (!isOutgoingMessage()) {
@@ -383,7 +384,7 @@ public class MessageItem {
// Use constant string for outgoing messages
mContact = mAddress =
mContext.getString(R.string.messagelist_sender_self);
timestamp = msg == null ? 0 : ((SendReq) msg).getDate() * 1000L;
timestamp = msg == null ? 0 : msg.getDate() * 1000L;
}
SlideModel slide = mSlideshow == null ? null : mSlideshow.get(0);
@@ -1,6 +1,5 @@
package com.moez.QKSMS.ui.messagelist;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
@@ -29,13 +28,13 @@ import com.google.android.mms.ContentType;
import com.google.android.mms.pdu_alt.PduHeaders;
import com.moez.QKSMS.QKSMSApp;
import com.moez.QKSMS.R;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.common.emoji.EmojiRegistry;
import com.moez.QKSMS.common.utils.CursorUtils;
import com.moez.QKSMS.common.utils.MessageUtils;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
import com.moez.QKSMS.ui.mms.MmsThumbnailPresenter;
import com.moez.QKSMS.ui.settings.SettingsFragment;
@@ -57,7 +56,6 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
private ArrayList<Long> mSelectedConversations = new ArrayList<>();
private Context mContext;
private MessageItemCache mMessageItemCache;
private MessageColumns.ColumnsMap mColumnsMap;
@@ -72,10 +70,10 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
private Handler mMessageListItemHandler = null; // TODO this isn't quite the same as the others
private String mSelection = null;
public MessageListAdapter(Context context) {
mContext = context;
mRes = MainActivity.getRes(mContext);
mPrefs = MainActivity.getPrefs(mContext);
public MessageListAdapter(QKActivity context) {
super(context);
mRes = mContext.getResources();
mPrefs = mContext.getPrefs();
}
protected MessageItem getItem(int position) {
@@ -128,7 +126,7 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
}
private MessageListViewHolder setupViewHolder(View view, boolean sent) {
MessageListViewHolder holder = new MessageListViewHolder(view);
MessageListViewHolder holder = new MessageListViewHolder(mContext, view);
if (sent) {
// set up colors
@@ -166,9 +164,9 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
public void onBindViewHolder(MessageListViewHolder holder, int position) {
MessageItem messageItem = getItem(position);
holder.data = messageItem;
holder.context = mContext;
holder.clickListener = mItemClickListener;
holder.mData = messageItem;
holder.mContext = mContext;
holder.mClickListener = mItemClickListener;
holder.mRoot.setOnClickListener(holder);
holder.mRoot.setOnLongClickListener(holder);
holder.mPresenter = null;
@@ -52,6 +52,12 @@ import com.moez.QKSMS.LogTag;
import com.moez.QKSMS.MmsConfig;
import com.moez.QKSMS.QKSMSApp;
import com.moez.QKSMS.R;
import com.moez.QKSMS.common.DialogHelper;
import com.moez.QKSMS.common.conversationdetails.ConversationDetailsDialog;
import com.moez.QKSMS.common.utils.DrmUtils;
import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.common.utils.MessageUtils;
import com.moez.QKSMS.common.vcard.ContactOperations;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.data.ContactList;
import com.moez.QKSMS.data.Conversation;
@@ -59,12 +65,6 @@ import com.moez.QKSMS.data.ConversationLegacy;
import com.moez.QKSMS.data.Message;
import com.moez.QKSMS.interfaces.ActivityLauncher;
import com.moez.QKSMS.model.SlideshowModel;
import com.moez.QKSMS.common.DialogHelper;
import com.moez.QKSMS.common.conversationdetails.ConversationDetailsDialog;
import com.moez.QKSMS.common.utils.DrmUtils;
import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.common.utils.MessageUtils;
import com.moez.QKSMS.common.vcard.ContactOperations;
import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.ui.MainActivity;
@@ -205,7 +205,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
mShowImmediate = savedInstanceState.getBoolean(ARG_SHOW_IMMEDIATE, false);
}
mPrefs = MainActivity.getPrefs(mContext);
mPrefs = mContext.getPrefs();
mIsSmsEnabled = MmsConfig.isSmsEnabled(mContext);
mConversationDetailsDialog = new ConversationDetailsDialog(mContext, getFragmentManager());
setHasOptionsMenu(true);
@@ -291,11 +291,6 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
return view;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public void onResume() {
super.onResume();
@@ -329,7 +324,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
new LoadConversationTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null);
}
public void setTitle() {
private void setTitle() {
if (mContext != null && mConversation != null) {
mContext.setTitle(mConversation.getRecipients().formatNames(", "));
}
@@ -622,7 +617,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
makeCall();
return true;
case R.id.menu_delete_conversation:
DialogHelper.showDeleteConversationDialog(mContext, mThreadId);
DialogHelper.showDeleteConversationDialog((MainActivity) mContext, mThreadId);
return true;
case R.id.menu_details:
mConversationDetailsDialog.showDetails(mConversation);
@@ -724,13 +719,13 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
}
@Override
protected void onContentOpening() {
public void onContentOpening() {
super.onContentOpening();
mOpened = false; // We're animating the fragment in, this flag warns us not to do anything heavy
}
@Override
protected void onContentOpened() {
public void onContentOpened() {
super.onContentOpened();
mOpened = true; // The fragment has finished animating in
@@ -740,11 +735,11 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
}
@Override
protected void onContentClosing() {
public void onContentClosing() {
}
@Override
protected void onContentClosed() {
public void onContentClosed() {
if (mSensorManager != null) {
mSensorManager.unregisterListener(this);
}
@@ -762,6 +757,14 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
}
}
@Override
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
inflater.inflate(R.menu.conversation, menu);
setTitle();
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public void onSensorChanged(SensorEvent event) {
if (event.values[0] == 0) {
@@ -1319,7 +1322,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
}
// The last message in this converation was just deleted. Send the user
// to the conversation list.
mContext.showMenu();
((MainActivity) mContext).showMenu();
}
cursor.close();
}
@@ -1362,7 +1365,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
Conversation.init(mContext);
// Go back to the conversation list
mContext.showMenu();
((MainActivity) mContext).showMenu();
} else if (token == DELETE_MESSAGE_TOKEN) {
// Check to see if we just deleted the last message
startMsgListQuery(MESSAGE_LIST_QUERY_AFTER_DELETE_TOKEN);
@@ -13,6 +13,7 @@ import com.moez.QKSMS.common.google.ItemLoadedCallback;
import com.moez.QKSMS.common.google.ThumbnailManager;
import com.moez.QKSMS.interfaces.SlideViewInterface;
import com.moez.QKSMS.ui.base.ClickyViewHolder;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.mms.Presenter;
import com.moez.QKSMS.ui.view.AvatarView;
import com.moez.QKSMS.ui.view.QKTextView;
@@ -43,8 +44,8 @@ public class MessageListViewHolder extends ClickyViewHolder<MessageItem> impleme
protected ImageLoadedCallback mImageLoadedCallback;
protected Presenter mPresenter;
public MessageListViewHolder(View view) {
super(view);
public MessageListViewHolder(QKActivity context, View view) {
super(context, view);
mRoot = view;
mBodyTextView = (QKTextView) view.findViewById(R.id.text_view);
@@ -215,16 +216,16 @@ public class MessageListViewHolder extends ClickyViewHolder<MessageItem> impleme
public ImageLoadedCallback(MessageListViewHolder listItem) {
mListItem = listItem;
mListItem.setImage(null, null);
mMessageId = listItem.data.getMessageId();
mMessageId = listItem.mData.getMessageId();
}
public void reset(MessageListViewHolder listItem) {
mMessageId = listItem.data.getMessageId();
mMessageId = listItem.mData.getMessageId();
}
public void onItemLoaded(ThumbnailManager.ImageLoaded imageLoaded, Throwable exception) {
// Make sure we're still pointing to the same message. The list item could have // been recycled.
MessageItem msgItem = mListItem.data;
MessageItem msgItem = mListItem.mData;
if (msgItem != null && msgItem.getMessageId() == mMessageId) {
if (imageLoaded.mIsVideo) {
mListItem.setVideoThumbnail(null, imageLoaded.mBitmap);
@@ -150,7 +150,7 @@ public class SlideshowActivity extends QKActivity implements EventListener {
@Override
public void onCreate(Bundle icicle) {
// Play slide-show in full-screen mode.
requestWindowFeature(Window.FEATURE_NO_TITLE);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(icicle);
mHandler = new Handler();
@@ -1,6 +1,5 @@
package com.moez.QKSMS.ui.search;
import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
@@ -11,17 +10,17 @@ import android.view.View;
import android.view.ViewGroup;
import com.moez.QKSMS.R;
import com.moez.QKSMS.common.utils.DateFormatter;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
import java.util.ArrayList;
public class SearchAdapter extends RecyclerCursorAdapter<SearchViewHolder, SearchData> {
private Context mContext;
private String mQuery;
public SearchAdapter(Context context) {
mContext = context;
public SearchAdapter(QKActivity context) {
super(context);
}
public void setQuery(String query) {
@@ -38,15 +37,15 @@ public class SearchAdapter extends RecyclerCursorAdapter<SearchViewHolder, Searc
public SearchViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(R.layout.list_item_search, parent, false);
return new SearchViewHolder(view);
return new SearchViewHolder(mContext, view);
}
@Override
public void onBindViewHolder(SearchViewHolder holder, int position) {
SearchData data = getItem(position);
holder.data = data;
holder.clickListener = mItemClickListener;
holder.mData = data;
holder.mClickListener = mItemClickListener;
holder.root.setOnClickListener(holder);
holder.root.setOnLongClickListener(holder);
@@ -11,17 +11,20 @@ import android.provider.Telephony;
import android.support.v7.widget.LinearLayoutManager;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import com.moez.QKSMS.R;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.common.utils.KeyboardUtils;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.base.QKContentFragment;
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
import com.moez.QKSMS.ui.view.QKEditText;
import com.moez.QKSMS.ui.view.MessageListRecyclerView;
import com.moez.QKSMS.ui.view.QKEditText;
import com.moez.QKSMS.ui.view.QKTextView;
import java.util.HashMap;
@@ -34,7 +37,6 @@ public class SearchFragment extends QKContentFragment implements RecyclerCursorA
// appropriately when the Contact gets fully loaded.
private HashMap<Contact, QKTextView> mContactMap = new HashMap<>();
private Context mContext;
private SharedPreferences mPrefs;
private Resources mRes;
private Cursor mCursor;
@@ -48,9 +50,8 @@ public class SearchFragment extends QKContentFragment implements RecyclerCursorA
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getActivity();
mPrefs = MainActivity.getPrefs(mContext);
mRes = MainActivity.getRes(mContext);
mPrefs = mContext.getPrefs();
mRes = mContext.getResources();
// When the query completes cons up a new adapter and set our list adapter to that.
mQueryHandler = new AsyncQueryHandler(mContext.getContentResolver()) {
@@ -129,11 +130,19 @@ public class SearchFragment extends QKContentFragment implements RecyclerCursorA
}
@Override
protected void onContentOpened() {
public void onContentOpened() {
// Show the keyboard and focus on the query text when the fragment is opened.
KeyboardUtils.showAndFocus(mContext, mQuery);
}
@Override
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
inflater.inflate(R.menu.search, menu);
((QKActivity) context).setTitle(R.string.title_search);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public void onItemClick(SearchData data, View view) {
MainActivity mainActivity = (MainActivity) mContext;
@@ -3,6 +3,7 @@ package com.moez.QKSMS.ui.search;
import android.view.View;
import com.moez.QKSMS.R;
import com.moez.QKSMS.ui.base.ClickyViewHolder;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.view.AvatarView;
import com.moez.QKSMS.ui.view.QKTextView;
@@ -14,8 +15,8 @@ public class SearchViewHolder extends ClickyViewHolder<SearchData> {
protected QKTextView date;
protected QKTextView snippet;
public SearchViewHolder(View view) {
super(view);
public SearchViewHolder(QKActivity context, View view) {
super(context, view);
root = view;
avatar = (AvatarView) view.findViewById(R.id.search_avatar);
@@ -1,11 +1,8 @@
package com.moez.QKSMS.ui.settings;
import android.app.AlarmManager;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.PendingIntent;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -21,39 +18,39 @@ import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TimePicker;
import android.widget.Toast;
import com.mariussoft.endlessjabber.sdk.EndlessJabberInterface;
import com.moez.QKSMS.R;
import com.moez.QKSMS.common.AnalyticsManager;
import com.moez.QKSMS.ui.dialog.BlockedNumberDialog;
import com.moez.QKSMS.ui.dialog.BubblePreferenceDialog;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.receiver.NightModeAutoReceiver;
import com.moez.QKSMS.common.DonationManager;
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.interfaces.LiveView;
import com.moez.QKSMS.receiver.NightModeAutoReceiver;
import com.moez.QKSMS.transaction.EndlessJabber;
import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.transaction.SmsHelper;
import com.moez.QKSMS.ui.ContentFragment;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.dialog.BlockedNumberDialog;
import com.moez.QKSMS.ui.dialog.BubblePreferenceDialog;
import com.moez.QKSMS.ui.dialog.QKDialog;
import com.moez.QKSMS.ui.dialog.mms.MMSSetupFragment;
import com.moez.QKSMS.ui.view.QKTextView;
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerDialog;
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerSwatch;
import com.moez.QKSMS.ui.view.QKTextView;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -61,13 +58,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack;
public class SettingsFragment extends PreferenceFragment implements
Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener, LiveView {
public class SettingsFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener,
Preference.OnPreferenceClickListener, LiveView, ContentFragment {
private final String TAG = "PreferenceFragment";
public static final String CATEGORY_APPEARANCE = "pref_key_category_appearance";
@@ -146,6 +142,7 @@ public class SettingsFragment extends PreferenceFragment implements
public static final String MMS_CONTACT_SUPPORT = "pref_key_mms_contact_support";
public static final String SIMPLE_PREFS = "pref_key_simple";
public static final String DONATE = "pref_key_donate";
public static final String DISMISSED_READ = "pref_key_dismiss_read";
/**
* @deprecated
*/
@@ -168,6 +165,7 @@ public class SettingsFragment extends PreferenceFragment implements
public static final String CATEGORY_TAG = "settings_category_fragment_tag";
private MainActivity mContext;
private PreferenceManager mPreferenceManager;
private SharedPreferences mPrefs;
private Resources mRes;
private ListView mListView;
@@ -205,8 +203,8 @@ public class SettingsFragment extends PreferenceFragment implements
Bundle args = getArguments();
mContext = (MainActivity) getActivity();
mPrefs = MainActivity.getPrefs(mContext);
mRes = MainActivity.getRes(mContext);
mPrefs = mContext.getPrefs();
mRes = mContext.getResources();
mResource = args.getInt("category", R.xml.settings);
if (mResource == R.xml.settings_simple || mResource == R.xml.settings_main) {
@@ -486,7 +484,10 @@ public class SettingsFragment extends PreferenceFragment implements
case DELAY_DURATION:
try {
int duration = Integer.parseInt((String) newValue);
if (duration < 1 || duration > 30) throw new Exception("Duration out of bounds");
if (duration < 1 || duration > 30)
throw new Exception("Duration out of bounds");
} catch (Exception e) {
Toast.makeText(mContext, R.string.delayed_duration_bounds_error, Toast.LENGTH_SHORT).show();
}
@@ -501,11 +502,7 @@ public class SettingsFragment extends PreferenceFragment implements
String key = preference.getKey() != null ? preference.getKey() : "";
AnalyticsManager.getInstance().sendEvent(
AnalyticsManager.CATEGORY_PREFERENCE_CLICK,
key,
null
);
AnalyticsManager.getInstance().sendEvent(AnalyticsManager.CATEGORY_PREFERENCE_CLICK, key, null);
// Categories
int resId = 0;
@@ -662,7 +659,7 @@ public class SettingsFragment extends PreferenceFragment implements
Calendar dayCalendar = Calendar.getInstance();
dayCalendar.setTimeInMillis(System.currentTimeMillis());
try {
calendar.setTime(simpleDateFormat.parse(MainActivity.getPrefs(context).getString(DAY_START, "6:00")));
calendar.setTime(simpleDateFormat.parse(PreferenceManager.getDefaultSharedPreferences(context).getString(DAY_START, "6:00")));
} catch (ParseException e) {
e.printStackTrace();
}
@@ -674,7 +671,7 @@ public class SettingsFragment extends PreferenceFragment implements
Calendar nightCalendar = Calendar.getInstance();
nightCalendar.setTimeInMillis(System.currentTimeMillis());
try {
calendar.setTime(simpleDateFormat.parse(MainActivity.getPrefs(context).getString(NIGHT_START, "21:00")));
calendar.setTime(simpleDateFormat.parse(PreferenceManager.getDefaultSharedPreferences(context).getString(NIGHT_START, "21:00")));
} catch (ParseException e) {
e.printStackTrace();
}
@@ -694,18 +691,6 @@ public class SettingsFragment extends PreferenceFragment implements
}
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
mContext.colorMenuIcons(menu, ThemeManager.getTextOnColorPrimary());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true);
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onDestroy() {
super.onDestroy();
@@ -723,57 +708,41 @@ public class SettingsFragment extends PreferenceFragment implements
}
}
public static class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
private final String TAG = "TimePickerPreference";
@Override
public void onContentOpening() {
private Preference mPreference;
private Preference.OnPreferenceChangeListener mListener;
private SharedPreferences mPrefs;
public void setPreference(Preference preference) {
mPreference = preference;
}
public void setOnPreferenceChangeListener(Preference.OnPreferenceChangeListener l) {
mListener = l;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (mPreference == null) {
Log.w(TAG, "No preference set");
return null;
}
mPrefs = MainActivity.getPrefs(getActivity());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
try {
Date date = simpleDateFormat.parse(mPrefs.getString(mPreference.getKey(), "6:00"));
c.setTime(date);
} catch (ParseException e) {
e.printStackTrace();
}
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
boolean isUsing24HourTime = mPrefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(getActivity()));
return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// Format the minutes with padded zeros so we don't get stuff like "6:2" instead
// of 6:02
String newValue = String.format("%d:%02d", hourOfDay, minute);
mPrefs.edit().putString(mPreference.getKey(), newValue).apply();
mPreference.setSummary(DateFormatter.getSummaryTimestamp(getActivity(), newValue));
mListener.onPreferenceChange(mPreference, newValue);
updateAlarmManager(getActivity(), true);
}
}
@Override
public void onContentOpened() {
}
@Override
public void onContentClosing() {
}
@Override
public void onContentClosed() {
}
@Override
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
if (mContext == null) {
mContext = (MainActivity) context;
mPrefs = mContext.getPrefs();
}
inflater.inflate(R.menu.settings, menu);
mContext.setTitle(R.string.title_settings);
MenuItem simplePrefs = menu.findItem(R.id.simple_settings);
if (mPrefs.getBoolean(SettingsFragment.SIMPLE_PREFS, true)) {
simplePrefs.setTitle(R.string.menu_show_all_prefs);
} else {
simplePrefs.setTitle(R.string.menu_show_fewer_prefs);
}
}
}
@@ -0,0 +1,71 @@
package com.moez.QKSMS.ui.settings;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.TimePickerDialog;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.text.format.DateFormat;
import android.util.Log;
import android.widget.TimePicker;
import com.moez.QKSMS.common.utils.DateFormatter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
private final String TAG = "TimePickerPreference";
private Preference mPreference;
private Preference.OnPreferenceChangeListener mListener;
private SharedPreferences mPrefs;
public void setPreference(Preference preference) {
mPreference = preference;
}
public void setOnPreferenceChangeListener(Preference.OnPreferenceChangeListener l) {
mListener = l;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (mPreference == null) {
Log.w(TAG, "No preference set");
return null;
}
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
try {
Date date = simpleDateFormat.parse(mPrefs.getString(mPreference.getKey(), "6:00"));
c.setTime(date);
} catch (ParseException e) {
e.printStackTrace();
}
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
boolean isUsing24HourTime = mPrefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(getActivity()));
return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// Format the minutes with padded zeros so we don't get stuff like "6:2" instead
// of 6:02
String newValue = String.format("%d:%02d", hourOfDay, minute);
mPrefs.edit().putString(mPreference.getKey(), newValue).apply();
mPreference.setSummary(DateFormatter.getSummaryTimestamp(getActivity(), newValue));
mListener.onPreferenceChange(mPreference, newValue);
SettingsFragment.updateAlarmManager(getActivity(), true);
}
}
@@ -7,18 +7,18 @@ import android.util.TypedValue;
import android.widget.MultiAutoCompleteTextView;
import com.android.ex.chips.BaseRecipientAdapter;
import com.android.ex.chips.RecipientEditTextView;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.common.FontManager;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.common.TypefaceManager;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.settings.SettingsFragment;
public class AutoCompleteContactView extends RecipientEditTextView implements LiveView {
public static final String TAG = "AutoCompleteContactView";
private Context mContext;
private QKActivity mContext;
private BaseRecipientAdapter mAdapter;
public AutoCompleteContactView(Context context) {
@@ -32,8 +32,8 @@ public class AutoCompleteContactView extends RecipientEditTextView implements Li
}
private void init(Context context) {
mContext = context;
SharedPreferences prefs = MainActivity.getPrefs(context);
mContext = (QKActivity) context;
SharedPreferences prefs = mContext.getPrefs();
// Setup text size, typeface, etc.
refresh();
@@ -65,7 +65,7 @@ public class AutoCompleteContactView extends RecipientEditTextView implements Li
setHintTextColor(ThemeManager.getTextOnBackgroundSecondary());
if (mAdapter != null) {
SharedPreferences prefs = MainActivity.getPrefs(mContext);
SharedPreferences prefs = mContext.getPrefs();
mAdapter.setShowMobileOnly(prefs.getBoolean(SettingsFragment.MOBILE_ONLY, false));
}
}
@@ -140,8 +140,8 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
super(context, attrs, defStyle);
mContext = (QKActivity) context;
mPrefs = MainActivity.getPrefs(mContext);
mRes = MainActivity.getRes(mContext);
mPrefs = mContext.getPrefs();
mRes = mContext.getResources();
mDelayedMessagingEnabled = mPrefs.getBoolean(SettingsFragment.DELAYED, false);
try {
@@ -194,18 +194,26 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
switch (Integer.parseInt(mPrefs.getString(SettingsFragment.ENTER_BUTTON, "0"))) {
case 0: // emoji
break;
case 1: // return
case 1: // new line
mReplyText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE |
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE);
mReplyText.setSingleLine(false);
break;
case 2: // send
mReplyText.setInputType(
mReplyText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
mReplyText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
mReplyText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI |
EditorInfo.IME_ACTION_SEND);
mReplyText.setSingleLine(false);
mReplyText.setOnKeyListener(new OnKeyListener() { //Workaround because ACTION_SEND does not support multiline mode
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == 66) {
sendSms();
return true;
}
return false;
}});
break;
}
@@ -228,18 +236,6 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
}
});
mReplyText.setOnEditorActionListener(new android.widget.TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(android.widget.TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
sendSms();
return true;
}
return false;
}
});
mProgressAnimator = new ValueAnimator();
mProgressAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mProgressAnimator.setDuration(mDelayDuration);
@@ -460,7 +456,9 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
}
long threadId = mConversation != null ? mConversation.getThreadId() : 0;
sendTransaction.sendNewMessage(message, threadId);
if (!message.toString().equals("")) {
sendTransaction.sendNewMessage(message, threadId);
}
NotificationManager.update(mContext);
if (mConversationLegacy != null) {
@@ -3,17 +3,17 @@ package com.moez.QKSMS.ui.view;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.TextView;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.common.FontManager;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.common.TypefaceManager;
import com.moez.QKSMS.common.utils.MessageUtils;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.settings.SettingsFragment;
@@ -132,7 +132,7 @@ public class QKTextView extends TextView implements LiveView {
@Override
public void setText(CharSequence text, BufferType type) {
SharedPreferences prefs = MainActivity.getPrefs(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (mType == FontManager.TEXT_TYPE_DIALOG_BUTTON) {
text = text.toString().toUpperCase();
@@ -15,11 +15,10 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.moez.QKSMS.R;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.data.ContactHelper;
import com.moez.QKSMS.interfaces.LiveView;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.settings.SettingsFragment;
@@ -27,7 +26,7 @@ import com.moez.QKSMS.ui.settings.SettingsFragment;
public class StarredContactsView extends LinearLayout implements LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener, LiveView {
private final String TAG = "StarredContactsView";
private Context mContext;
private QKActivity mContext;
private SharedPreferences mPrefs;
private Cursor mCursor;
private LinearLayout mFavoritesBackground;
@@ -50,8 +49,8 @@ public class StarredContactsView extends LinearLayout implements LoaderManager.L
}
private void init(Context context) {
mContext = context;
mPrefs = MainActivity.getPrefs(mContext);
mContext = (QKActivity) context;
mPrefs = mContext.getPrefs();
}
@Override
@@ -178,5 +177,6 @@ public class StarredContactsView extends LinearLayout implements LoaderManager.L
@Override
public void refresh() {
mIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.MULTIPLY);
mFavoritesBackground.setBackgroundColor(ThemeManager.getBackgroundColor());
}
}
@@ -53,7 +53,7 @@ public class DemoConversationCursorLoader extends Loader<Cursor> {
ArrayList<MessageData> candidates = new ArrayList<>();
if (THREAD_ID_WELCOME_SCREEN == mThreadId) {
candidates = new ArrayList<MessageData>();
candidates = new ArrayList<>();
long time = System.currentTimeMillis() - 50000;
candidates.add(new MessageData(
"sms", 0, mThreadId, "QKSMS",
@@ -176,6 +176,6 @@ public class WelcomeActivity extends QKActivity implements ViewPager.OnPageChang
SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
prefs.putBoolean(SettingsFragment.WELCOME_SEEN, true);
prefs.commit();
prefs.apply();
}
}
@@ -92,4 +92,9 @@ public class WelcomeNightFragment extends BaseWelcomeFragment implements BaseWel
.commit();
}
}
@Override
public void refresh() {
// Don't let the super class change the background, since we'll handle animations here
}
}
@@ -16,6 +16,7 @@
package com.moez.QKSMS.ui.widget;
import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
@@ -23,8 +24,10 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.RemoteViews;
import com.moez.QKSMS.R;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
@@ -45,7 +48,7 @@ public class WidgetProvider extends AppWidgetProvider {
ThemeManager.loadThemeProperties(context);
for (int appWidgetId : appWidgetIds) {
updateWidget(context, appWidgetId);
updateWidget(context, appWidgetId, isSmallWidget(appWidgetManager, appWidgetId));
}
}
@@ -69,10 +72,40 @@ public class WidgetProvider extends AppWidgetProvider {
}
}
/**
* Update widget when widget size changes
*/
@Override
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager,
int appWidgetId, Bundle newOptions) {
Log.v("TAG", "Changed widget dimensions");
updateWidget(context, appWidgetId, isSmallWidget(appWidgetManager,appWidgetId));
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
}
/**
* Returns 1 when widget has less than 4 columns, else 0
*/
@TargetApi(16)
private static int isSmallWidget(AppWidgetManager appWidgetManager, int appWidgetId) {
Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
int size = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
int n = 2;
while (70 * n - 30 < size) {
++n;
}
int columns = n - 1;
if (columns < 4) return 1;
else return 0;
}
/**
* Update the widget appWidgetId
*/
private static void updateWidget(Context context, int appWidgetId) {
private static void updateWidget(Context context, int appWidgetId, int smallWidget) {
Log.v(TAG, "updateWidget appWidgetId: " + appWidgetId);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
PendingIntent clickIntent;
@@ -80,8 +113,9 @@ public class WidgetProvider extends AppWidgetProvider {
// Launch an intent to avoid ANRs
final Intent intent = new Intent(context, WidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.putExtra("small_widget", smallWidget);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
remoteViews.setRemoteAdapter(appWidgetId, R.id.conversation_list, intent);
remoteViews.setRemoteAdapter(R.id.conversation_list, intent);
remoteViews.setTextViewText(R.id.widget_label, context.getString(R.string.title_conversation_list));
remoteViews.setTextColor(R.id.widget_label, ThemeManager.getTextOnColorPrimary());
@@ -125,7 +159,7 @@ public class WidgetProvider extends AppWidgetProvider {
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
for (int appWidgetId : appWidgetIds) {
updateWidget(context, appWidgetId);
updateWidget(context, appWidgetId, isSmallWidget(appWidgetManager, appWidgetId));
}
}
@@ -32,12 +32,13 @@ import android.util.Log;
import android.view.View;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import com.moez.QKSMS.R;
import com.moez.QKSMS.data.ContactHelper;
import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.common.ConversationPrefsHelper;
import com.moez.QKSMS.common.utils.ImageUtils;
import com.moez.QKSMS.common.utils.MessageUtils;
import com.moez.QKSMS.data.ContactHelper;
import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.ui.MainActivity;
import com.moez.QKSMS.ui.ThemeManager;
@@ -62,6 +63,7 @@ public class WidgetService extends RemoteViewsService {
private static final int MAX_CONVERSATIONS_COUNT = 25;
private final Context mContext;
private final int mAppWidgetId;
private final int mSmallWidget;
private boolean mShouldShowViewMore;
private Cursor mConversationCursor;
private int mUnreadConvCount;
@@ -70,6 +72,7 @@ public class WidgetService extends RemoteViewsService {
public WidgetFactory(Context context, Intent intent) {
mContext = context;
mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
mSmallWidget = intent.getIntExtra("small_widget", 0);
mAppWidgetManager = AppWidgetManager.getInstance(context);
Log.v(TAG, "WidgetFactory intent: " + intent + "widget id: " + mAppWidgetId);
}
@@ -190,8 +193,11 @@ public class WidgetService extends RemoteViewsService {
Conversation conversation = Conversation.from(mContext, mConversationCursor);
RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.list_item_conversation_widget);
bindAvatar(remoteViews, conversation);
if (mSmallWidget == 0) {
remoteViews.setViewVisibility(R.id.avatar, View.VISIBLE);
bindAvatar(remoteViews, conversation);
}
else remoteViews.setViewVisibility(R.id.avatar, View.GONE);
bindIndicators(remoteViews, conversation);
bindDate(remoteViews, conversation);
bindName(remoteViews, conversation);
+2
View File
@@ -49,6 +49,8 @@
<string name="details_body">Inhalt</string>
<string name="details_date_sent">Gesendet</string>
<string name="details_date_received">Empfangen</string>
<string name="rate_title">Gefällt dir QKSMS?</string>
<string name="rate_action">Bewerten</string>
<string name="pref_category_appearance">Erscheinungsbild</string>
<string name="pref_category_summary_appearance">Themen, Schriften, Farben, Avatare und mehr</string>
<string name="pref_category_general">Allgemein</string>
@@ -30,6 +30,7 @@
<item>Jacob Klinker</item>
<item>Jeff Gilfelt</item>
<item>Melnykov Oleksandr</item>
<item>ligi</item>
</string-array>
<string-array name="contributor_githubs">
@@ -39,6 +40,7 @@
<item>github.com/klinker41</item>
<item>github.com/jgilfelt</item>
<item>github.com/makovkastar</item>
<item>github.com/ligi</item>
</string-array>
<string-array name="contributor_projects">
@@ -48,6 +50,7 @@
<item>android-smsmms\nandroid-chips</item>
<item>SystemBarTint</item>
<item>FloatingActionButton</item>
<item>SnackEngage</item>
</string-array>
<string-array name="changelog_versions">
+6
View File
@@ -101,6 +101,10 @@
<string name="details_date_sent">Date sent</string>
<!--Title for date received of a message in message details popup-->
<string name="details_date_received">Date received</string>
<!--Title for rate snackbar-->
<string name="rate_title">Like QKSMS?</string>
<!--Title for rate button-->
<string name="rate_action">Rate</string>
<string name="pref_category_appearance">Appearance</string>
<string name="pref_category_summary_appearance">Themes, fonts, colors, avatars, and more</string>
@@ -209,6 +213,8 @@
<string name="pref_vibration_summary">Vibrate when new messages are received</string>
<string name="pref_notification_call">Call button</string>
<string name="pref_notification_call_summary">Call the sender of a message right from the notification</string>
<string name="pref_dimiss_read">Mark as read</string>
<string name="pref_dismiss_read_summary">Mark message as read when notification is cleared</string>
<string name="pref_delayed">Delayed messaging</string>
<string name="pref_delayed_summary">Wait before sending your messages, so you have a chance to review them</string>
+3
View File
@@ -117,6 +117,9 @@
<Preference
android:defaultValue="false"
android:key="pref_key_notification_call" />
<Preference
android:defaultValue="false"
android:key="pref_key_dismiss_read" />
<!-- QKSMS+ -->
<Preference
@@ -71,5 +71,13 @@
android:summary="@string/pref_notification_call_summary"
android:title="@string/pref_notification_call"
android:widgetLayout="@layout/view_checkbox" />
<CheckBoxPreference
android:defaultValue="false"
android:dependency="pref_key_notifications"
android:key="pref_key_dismiss_read"
android:layout="@layout/list_item_preference"
android:summary="@string/pref_dismiss_read_summary"
android:title="@string/pref_dimiss_read"
android:widgetLayout="@layout/view_checkbox" />
</PreferenceCategory>
</PreferenceScreen>
+2 -2
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget"
android:minHeight="220dp"
android:minWidth="220dp"
android:minHeight="110dp"
android:minWidth="180dp"
android:previewImage="@mipmap/ic_launcher_teal"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="0"
+11 -11
View File
@@ -1,6 +1,6 @@
# QKSMS
QKSMS is an open source replacement to the [stock messaging app](https://github.com/android/platform_packages_apps_mms) on Android. It is currently available on the Google Play Store
QKSMS is an open source replacement to the [stock messaging app](https://github.com/android/platform_packages_apps_mms) on Android. It is currently available on the Google Play Store.
[![Build Status](https://travis-ci.org/qklabs/qksms.svg?branch=master)](https://travis-ci.org/qklabs/qksms)
@@ -13,31 +13,31 @@ QKSMS is an open source replacement to the [stock messaging app](https://github.
# Contributing to QKSMS
We highly encourage contributions to QKSMS; we want to make it as easy and streamlined as possible. If you have any suggestions on how we can improve our workflow, please feel free to contact me
We highly encourage contributions to QKSMS; we want to make it as easy and streamlined as possible. If you have any suggestions on how we can improve our workflow, please feel free to contact me.
Quite a bit of old code still needs to be cleaned up and refactored, so keep that in mind as you're digging through the source. If you find something that's just really crappy, let me know and I'll put it higher up on my list of stuff to clean up. I'll be focusing on improving code quality of existing code over the next couple weeks
Quite a bit of old code still needs to be cleaned up and refactored, so keep that in mind as you're digging through the source. If you find something that's just really crappy, let me know and I'll put it higher up on my list of stuff to clean up. I'll be focusing on improving code quality of existing code over the next couple weeks.
### Collaboration
We use GitHub issues to keep track of bugs and feature requests, but we communicate using [Slack](https://qklabs.slack.com/). To join the Slack group, send an email to team@qklabs.com with the subject `QK Labs Slack Invite` (no need to enter a body, we'll send an invite to your email address). If you plan on contributing at some point, we highly recommend joining the slack group because it gives you a direct way to communicate with the rest of the contributors
We use GitHub issues to keep track of bugs and feature requests, but we communicate using [Slack](https://qklabs.slack.com/). To join the Slack group, send an email to team@qklabs.com with the subject `QK Labs Slack Invite` (no need to enter a body, we'll send an invite to your email address). If you plan on contributing at some point, we highly recommend joining the slack group because it gives you a direct way to communicate with the rest of the contributors.
### Funds
If you'd like to donate to help support the project, you can donate via [PayPal here](http://bit.ly/QKSMSDonation)
If you'd like to donate to help support the project, you can donate via [PayPal here](http://bit.ly/QKSMSDonation).
### Translations
Please do not perform translations directly on the source files. Pull requests for translations will not be accepted. If you would like to do translations for QKSMS, join the translation project on Crowdin: https://crowdin.com/project/qksms
Please do not perform translations directly on the source files. Pull requests for translations will not be accepted. If you would like to do translations for QKSMS, join the translation project on Crowdin: https://crowdin.com/project/qksms.
### Development
We encourage you to make pull requests. Whenever you make one, we'll review the code and test it to make sure that it fits the code style guidelines, and achieves what the pull request intends. We'll discuss any problems or potential improvements, and we'll merge it when we're both (or any number of willing participants) happy with the code
We encourage you to make pull requests. Whenever you make one, we'll review the code and test it to make sure that it fits the code style guidelines, and achieves what the pull request intends. We'll discuss any problems or potential improvements, and we'll merge it when we're both (or any number of willing participants) happy with the code.
If you're new, we recommend that you look through the issues and try to fix some of the more simple sounding bugs to familiarize yourself with the codebase
If you're new, we recommend that you look through the issues and try to fix some of the more simple sounding bugs to familiarize yourself with the codebase.
If you'd like to work on a new feature, please create an issue so we can discuss the idea together before implementation begins.
To learn about pull requests, please refer to the following guide: https://help.github.com/articles/using-pull-requests/
To learn about pull requests, please refer to the following guide: https://help.github.com/articles/using-pull-requests/.
### Code style
@@ -45,7 +45,7 @@ We follow the code style guidelines set by Google for contributors to AOSP: http
The current codebase is far from being 100% at this standard, but updating existing code to follow the unified guidelines can be a good way to introduce yourself to the codebase and start getting familiar with it.
Any new code written should follow these guidelines
Any new code written should follow these guidelines.
# Bug Reports / Feature Requests
@@ -103,4 +103,4 @@ QKSMS is developed and maintained by [Moez Bhatti](https://github.com/moezbhatti
# License
QKSMS is released under the **The GNU General Public License v3.0 (GPLv3)**, which can be found in the `LICENSE` file in the root of this project
QKSMS is released under the **The GNU General Public License v3.0 (GPLv3)**, which can be found in the `LICENSE` file in the root of this project.