forked from upstream-mirrors/quik
Remove SharedPreferences object from MessageListFragment
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
package com.moez.QKSMS.common.preferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public class QKPreferences {
|
||||
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
public QKPreferences(Context context) {
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
public boolean getBoolean(QKPreference preference) {
|
||||
return mPrefs.getBoolean(preference.getKey(), (boolean) preference.getDefaultValue());
|
||||
}
|
||||
|
||||
public void setBoolean(QKPreference preference, boolean newValue) {
|
||||
mPrefs.edit().putBoolean(preference.getKey(), newValue).apply();
|
||||
}
|
||||
|
||||
public int getInt(QKPreference preference) {
|
||||
return mPrefs.getInt(preference.getKey(), (int) preference.getDefaultValue());
|
||||
}
|
||||
|
||||
public void setInt(QKPreference preference, int newValue) {
|
||||
mPrefs.edit().putInt(preference.getKey(), newValue).apply();
|
||||
}
|
||||
|
||||
public String getString(QKPreference preference) {
|
||||
return mPrefs.getString(preference.getKey(), (String) preference.getDefaultValue());
|
||||
}
|
||||
|
||||
public void setString(QKPreference preference, String newValue) {
|
||||
mPrefs.edit().putString(preference.getKey(), newValue).apply();
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import android.widget.Toast;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.moez.QKSMS.QKSMSApp;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.view.QKTextView;
|
||||
|
||||
@@ -236,4 +237,28 @@ public abstract class QKActivity extends ActionBarActivity {
|
||||
public RequestQueue getRequestQueue() {
|
||||
return ((QKSMSApp) getApplication()).getRequestQueue();
|
||||
}
|
||||
|
||||
public boolean getBoolean(QKPreference preference) {
|
||||
return getPrefs().getBoolean(preference.getKey(), (boolean) preference.getDefaultValue());
|
||||
}
|
||||
|
||||
public void setBoolean(QKPreference preference, boolean newValue) {
|
||||
getPrefs().edit().putBoolean(preference.getKey(), newValue).apply();
|
||||
}
|
||||
|
||||
public int getInt(QKPreference preference) {
|
||||
return getPrefs().getInt(preference.getKey(), (int) preference.getDefaultValue());
|
||||
}
|
||||
|
||||
public void setInt(QKPreference preference, int newValue) {
|
||||
getPrefs().edit().putInt(preference.getKey(), newValue).apply();
|
||||
}
|
||||
|
||||
public String getString(QKPreference preference) {
|
||||
return getPrefs().getString(preference.getKey(), (String) preference.getDefaultValue());
|
||||
}
|
||||
|
||||
public void setString(QKPreference preference, String newValue) {
|
||||
getPrefs().edit().putString(preference.getKey(), newValue).apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.common.DialogHelper;
|
||||
import com.moez.QKSMS.common.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.DrmUtils;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
import com.moez.QKSMS.common.utils.MessageUtils;
|
||||
@@ -168,7 +169,6 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
private SensorManager mSensorManager;
|
||||
private AsyncDialog mAsyncDialog;
|
||||
private ComposeView mComposeView;
|
||||
private SharedPreferences mPrefs;
|
||||
private ConversationPrefsHelper mConversationPrefs;
|
||||
private ConversationDetailsDialog mConversationDetailsDialog;
|
||||
|
||||
@@ -212,7 +212,6 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
}
|
||||
|
||||
mArgbEvaluator = new ArgbEvaluator();
|
||||
mPrefs = mContext.getPrefs();
|
||||
mConversationPrefs = new ConversationPrefsHelper(mContext, mThreadId);
|
||||
mIsSmsEnabled = MmsConfig.isSmsEnabled(mContext);
|
||||
mConversationDetailsDialog = new ConversationDetailsDialog(mContext, getFragmentManager());
|
||||
@@ -221,7 +220,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
||||
mProxSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
|
||||
if (mPrefs.getBoolean(SettingsFragment.PROXIMITY_CALLING, false)) {
|
||||
if (mContext.getBoolean(QKPreference.PROXIMITY_SENSOR)) {
|
||||
mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
|
||||
@@ -751,7 +750,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
super.onContentOpened();
|
||||
mOpened = true; // The fragment has finished animating in
|
||||
|
||||
if (mPrefs != null && mPrefs.getBoolean(SettingsFragment.PROXIMITY_CALLING, false)) {
|
||||
if (mContext.getBoolean(QKPreference.PROXIMITY_SENSOR)) {
|
||||
mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user