forked from upstream-mirrors/quik
Removed static Resources and SharedPreferences
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
@@ -210,7 +210,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, ""));
|
||||
|
||||
@@ -13,7 +13,6 @@ 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;
|
||||
@@ -88,8 +87,6 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
|
||||
public static boolean sIsShowing = false;
|
||||
public static boolean sIsContentHidden = true;
|
||||
private static Resources sRes;
|
||||
private static SharedPreferences sPrefs;
|
||||
|
||||
private SlidingMenu mSlidingMenu;
|
||||
private ConversationListFragment mConversationList;
|
||||
@@ -106,9 +103,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);
|
||||
@@ -208,7 +202,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
}
|
||||
|
||||
private void launchWelcomeActivity() {
|
||||
if (sPrefs.getBoolean(SettingsFragment.WELCOME_SEEN, false)) {
|
||||
if (mPrefs.getBoolean(SettingsFragment.WELCOME_SEEN, false)) {
|
||||
// User has already seen the welcome screen
|
||||
return;
|
||||
}
|
||||
@@ -226,7 +220,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
}
|
||||
|
||||
private void setupSlidingMenu() {
|
||||
setSlidingTabEnabled(sPrefs.getBoolean(SettingsFragment.SLIDING_TAB, false));
|
||||
setSlidingTabEnabled(mPrefs.getBoolean(SettingsFragment.SLIDING_TAB, false));
|
||||
mSlidingMenu.setBehindScrollScale(0.5f);
|
||||
mSlidingMenu.setFadeDegree(0.5f);
|
||||
mSlidingMenu.setOnOpenListener(this);
|
||||
@@ -281,7 +275,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
setTitle(getString(R.string.title_settings));
|
||||
inflater.inflate(R.menu.settings, menu);
|
||||
MenuItem simplePrefs = menu.findItem(R.id.simple_settings);
|
||||
if (sPrefs.getBoolean(SettingsFragment.SIMPLE_PREFS, true)) {
|
||||
if (mPrefs.getBoolean(SettingsFragment.SIMPLE_PREFS, true)) {
|
||||
simplePrefs.setTitle(R.string.menu_show_all_prefs);
|
||||
} else {
|
||||
simplePrefs.setTitle(R.string.menu_show_fewer_prefs);
|
||||
@@ -315,8 +309,8 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
onKeyUp(KeyEvent.KEYCODE_BACK, null);
|
||||
break;
|
||||
case R.id.simple_settings:
|
||||
sPrefs.edit().putBoolean(SettingsFragment.SIMPLE_PREFS,
|
||||
!sPrefs.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;
|
||||
@@ -496,10 +490,10 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
}
|
||||
|
||||
private void beginMmsSetup() {
|
||||
if (!sPrefs.getBoolean(MMS_SETUP_DONT_ASK_AGAIN, false) &&
|
||||
TextUtils.isEmpty(sPrefs.getString(SettingsFragment.MMSC_URL, "")) &&
|
||||
TextUtils.isEmpty(sPrefs.getString(SettingsFragment.MMS_PROXY, "")) &&
|
||||
TextUtils.isEmpty(sPrefs.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.
|
||||
@@ -682,20 +676,6 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
.show();
|
||||
}
|
||||
|
||||
public static SharedPreferences getPrefs(Context context) {
|
||||
if (sPrefs == null) {
|
||||
sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
return sPrefs;
|
||||
}
|
||||
|
||||
public static Resources getRes(Context context) {
|
||||
if (sRes == null) {
|
||||
sRes = context.getResources();
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
|
||||
public static class DeleteThreadListener implements DialogInterface.OnClickListener {
|
||||
private final Collection<Long> mThreadIds;
|
||||
private final Conversation.ConversationQueryHandler mHandler;
|
||||
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,6 +64,10 @@ public class QKActivity extends ActionBarActivity {
|
||||
ThemeManager.loadThemeProperties(this);
|
||||
}
|
||||
|
||||
public SharedPreferences getPrefs() {
|
||||
return mPrefs;
|
||||
}
|
||||
|
||||
public void colorMenuIcons(Menu menu, int color) {
|
||||
|
||||
// Toolbar navigation icon
|
||||
|
||||
@@ -3,9 +3,8 @@ 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.ThemeManager;
|
||||
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
||||
|
||||
@@ -37,8 +36,6 @@ public class QKContentFragment extends QKFragment implements LiveView {
|
||||
public static final int STATE_CLOSING = 2;
|
||||
public static final int STATE_CLOSED = 3;
|
||||
|
||||
protected MainActivity mContext;
|
||||
|
||||
/**
|
||||
* It's not strictly necessary, but subclasses should call through to super() in their
|
||||
* constructor.
|
||||
@@ -78,7 +75,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
package com.moez.QKSMS.ui.base;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import com.moez.QKSMS.QKSMSApp;
|
||||
import com.moez.QKSMS.ui.MainActivity;
|
||||
import com.squareup.leakcanary.RefWatcher;
|
||||
|
||||
public class QKFragment extends Fragment {
|
||||
|
||||
protected MainActivity mContext;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mContext = (MainActivity) getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -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;
|
||||
|
||||
+8
-10
@@ -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,7 +31,6 @@ import com.moez.QKSMS.interfaces.LiveView;
|
||||
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.QKFragment;
|
||||
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
|
||||
import com.moez.QKSMS.ui.compose.ComposeFragment;
|
||||
@@ -60,7 +59,6 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
private ConversationListAdapter mAdapter;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private ConversationDetailsDialog mConversationDetailsDialog;
|
||||
private QKActivity mContext;
|
||||
|
||||
// This does not hold the current position of the list, rather the position the list is pending being set to
|
||||
private int mPosition;
|
||||
@@ -69,7 +67,6 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mContext = (QKActivity) getActivity();
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
mAdapter = new ConversationListAdapter(mContext);
|
||||
|
||||
+16
-15
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.moez.QKSMS.ui.search;
|
||||
|
||||
import android.content.AsyncQueryHandler;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
@@ -15,13 +14,13 @@ 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.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 +33,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 +46,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()) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -21,6 +21,7 @@ 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;
|
||||
@@ -201,8 +202,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) {
|
||||
@@ -655,7 +656,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();
|
||||
}
|
||||
@@ -667,7 +668,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();
|
||||
}
|
||||
@@ -738,7 +739,7 @@ public class SettingsFragment extends PreferenceFragment implements
|
||||
return null;
|
||||
}
|
||||
|
||||
mPrefs = MainActivity.getPrefs(getActivity());
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user