forked from upstream-mirrors/quik
Migrate settings to separate activity
This commit is contained in:
@@ -98,6 +98,8 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".ui.settings.SettingsActivity" />
|
||||||
|
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".ui.MainActivity-Teal"
|
android:name=".ui.MainActivity-Teal"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import butterknife.ButterKnife;
|
|||||||
import com.google.android.mms.pdu_alt.PduHeaders;
|
import com.google.android.mms.pdu_alt.PduHeaders;
|
||||||
import com.moez.QKSMS.R;
|
import com.moez.QKSMS.R;
|
||||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||||
import com.moez.QKSMS.common.DialogHelper;
|
|
||||||
import com.moez.QKSMS.common.DonationManager;
|
import com.moez.QKSMS.common.DonationManager;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
import com.moez.QKSMS.common.LiveViewManager;
|
||||||
import com.moez.QKSMS.common.QKRateSnack;
|
import com.moez.QKSMS.common.QKRateSnack;
|
||||||
@@ -234,19 +233,10 @@ public class MainActivity extends QKActivity implements SlidingMenu.SlidingMenuL
|
|||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
onKeyUp(KeyEvent.KEYCODE_BACK, null);
|
onKeyUp(KeyEvent.KEYCODE_BACK, null);
|
||||||
break;
|
return true;
|
||||||
case R.id.menu_settings:
|
|
||||||
switchContent(SettingsFragment.newInstance(R.xml.settings_main), true);
|
|
||||||
break;
|
|
||||||
case R.id.menu_search:
|
case R.id.menu_search:
|
||||||
switchContent(new SearchFragment(), true);
|
switchContent(new SearchFragment(), true);
|
||||||
break;
|
return true;
|
||||||
case R.id.menu_changelog:
|
|
||||||
DialogHelper.showChangelog(this);
|
|
||||||
break;
|
|
||||||
case R.id.menu_donate:
|
|
||||||
DonationManager.getInstance(this).showDonateDialog();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
@@ -303,13 +293,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.SlidingMenuL
|
|||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
if (!mSlidingMenu.isMenuShowing()) {
|
if (!mSlidingMenu.isMenuShowing()) {
|
||||||
Fragment category = getFragmentManager().findFragmentByTag(SettingsFragment.CATEGORY_TAG);
|
mSlidingMenu.showMenu();
|
||||||
if (category != null) {
|
|
||||||
getFragmentManager().beginTransaction()
|
|
||||||
.replace(R.id.content_frame, SettingsFragment.newInstance(R.xml.settings_main)).commit();
|
|
||||||
} else {
|
|
||||||
mSlidingMenu.showMenu();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (mConversationList.isShowingBlocked()) {
|
if (mConversationList.isShowingBlocked()) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.moez.QKSMS.ui.base;
|
package com.moez.QKSMS.ui.base;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
@@ -23,10 +24,14 @@ import android.widget.Toast;
|
|||||||
import com.android.volley.RequestQueue;
|
import com.android.volley.RequestQueue;
|
||||||
import com.moez.QKSMS.QKSMSApp;
|
import com.moez.QKSMS.QKSMSApp;
|
||||||
import com.moez.QKSMS.R;
|
import com.moez.QKSMS.R;
|
||||||
|
import com.moez.QKSMS.common.DialogHelper;
|
||||||
|
import com.moez.QKSMS.common.DonationManager;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
import com.moez.QKSMS.common.LiveViewManager;
|
||||||
import com.moez.QKSMS.enums.QKPreference;
|
|
||||||
import com.moez.QKSMS.common.utils.ColorUtils;
|
import com.moez.QKSMS.common.utils.ColorUtils;
|
||||||
|
import com.moez.QKSMS.enums.QKPreference;
|
||||||
import com.moez.QKSMS.ui.ThemeManager;
|
import com.moez.QKSMS.ui.ThemeManager;
|
||||||
|
import com.moez.QKSMS.ui.search.SearchFragment;
|
||||||
|
import com.moez.QKSMS.ui.settings.SettingsActivity;
|
||||||
import com.moez.QKSMS.ui.view.QKTextView;
|
import com.moez.QKSMS.ui.view.QKTextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -241,6 +246,28 @@ public abstract class QKActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_settings:
|
||||||
|
startActivity(SettingsActivity.class);
|
||||||
|
return true;
|
||||||
|
case R.id.menu_changelog:
|
||||||
|
DialogHelper.showChangelog(this);
|
||||||
|
return true;
|
||||||
|
case R.id.menu_donate:
|
||||||
|
DonationManager.getInstance(this).showDonateDialog();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startActivity(Class<?> cls) {
|
||||||
|
Intent intent = new Intent(this, cls);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isScreenOn() {
|
public boolean isScreenOn() {
|
||||||
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.graphics.Color;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import com.moez.QKSMS.R;
|
import com.moez.QKSMS.R;
|
||||||
import com.moez.QKSMS.ui.SwipeBackLayout;
|
import com.moez.QKSMS.ui.SwipeBackLayout;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ public abstract class QKSwipeBackActivity extends QKActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_fragment);
|
||||||
|
|
||||||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
getWindow().getDecorView().setBackgroundDrawable(null);
|
getWindow().getDecorView().setBackgroundDrawable(null);
|
||||||
@@ -21,12 +23,29 @@ public abstract class QKSwipeBackActivity extends QKActivity {
|
|||||||
|
|
||||||
mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
|
mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
|
||||||
mSwipeBackLayout.setEnableGesture(true);
|
mSwipeBackLayout.setEnableGesture(true);
|
||||||
|
|
||||||
|
showBackButton(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
onBackPressed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostCreate(Bundle savedInstanceState) {
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
super.onPostCreate(savedInstanceState);
|
super.onPostCreate(savedInstanceState);
|
||||||
mSwipeBackLayout.attachToActivity(this);
|
mSwipeBackLayout.attachToActivity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
mSwipeBackLayout.scrollToFinishActivity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ public class MessageListActivity extends QKSwipeBackActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_fragment);
|
|
||||||
showBackButton(true);
|
|
||||||
|
|
||||||
onNewIntent(getIntent());
|
onNewIntent(getIntent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,20 +114,11 @@ public class MessageListActivity extends QKSwipeBackActivity {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
|
||||||
onBackPressed();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case R.id.menu_donate:
|
case R.id.menu_donate:
|
||||||
DonationManager.getInstance(this).showDonateDialog();
|
DonationManager.getInstance(this).showDonateDialog();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
mSwipeBackLayout.scrollToFinishActivity();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
|||||||
private String mHighlight;
|
private String mHighlight;
|
||||||
private boolean mShowImmediate;
|
private boolean mShowImmediate;
|
||||||
|
|
||||||
public static MessageListFragment getInstance(long threadId, long rowId, String highlight, boolean showImmediate) {
|
protected static MessageListFragment getInstance(long threadId, long rowId, String highlight, boolean showImmediate) {
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong(ARG_THREAD_ID, threadId);
|
args.putLong(ARG_THREAD_ID, threadId);
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.moez.QKSMS.ui.settings;
|
||||||
|
|
||||||
|
import android.app.FragmentManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import com.moez.QKSMS.R;
|
||||||
|
import com.moez.QKSMS.ui.base.QKSwipeBackActivity;
|
||||||
|
|
||||||
|
public class SettingsActivity extends QKSwipeBackActivity {
|
||||||
|
|
||||||
|
private SettingsFragment mSettingsFragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
FragmentManager fm = getFragmentManager();
|
||||||
|
mSettingsFragment = (SettingsFragment) fm.findFragmentById(R.id.content_frame);
|
||||||
|
if (mSettingsFragment == null) {
|
||||||
|
mSettingsFragment = SettingsFragment.newInstance(R.xml.settings_main);
|
||||||
|
}
|
||||||
|
|
||||||
|
fm.beginTransaction()
|
||||||
|
.replace(R.id.content_frame, mSettingsFragment)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (getFragmentManager().getBackStackEntryCount() > 0) {
|
||||||
|
getFragmentManager().popBackStack();
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,17 +35,16 @@ import com.moez.QKSMS.common.DialogHelper;
|
|||||||
import com.moez.QKSMS.common.DonationManager;
|
import com.moez.QKSMS.common.DonationManager;
|
||||||
import com.moez.QKSMS.common.ListviewHelper;
|
import com.moez.QKSMS.common.ListviewHelper;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
import com.moez.QKSMS.common.LiveViewManager;
|
||||||
import com.moez.QKSMS.enums.QKPreference;
|
|
||||||
import com.moez.QKSMS.common.utils.DateFormatter;
|
import com.moez.QKSMS.common.utils.DateFormatter;
|
||||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||||
import com.moez.QKSMS.common.utils.PackageUtils;
|
import com.moez.QKSMS.common.utils.PackageUtils;
|
||||||
|
import com.moez.QKSMS.enums.QKPreference;
|
||||||
import com.moez.QKSMS.receiver.NightModeAutoReceiver;
|
import com.moez.QKSMS.receiver.NightModeAutoReceiver;
|
||||||
import com.moez.QKSMS.transaction.EndlessJabber;
|
import com.moez.QKSMS.transaction.EndlessJabber;
|
||||||
import com.moez.QKSMS.transaction.NotificationManager;
|
import com.moez.QKSMS.transaction.NotificationManager;
|
||||||
import com.moez.QKSMS.transaction.SmsHelper;
|
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.ThemeManager;
|
||||||
|
import com.moez.QKSMS.ui.base.QKActivity;
|
||||||
import com.moez.QKSMS.ui.dialog.BlockedNumberDialog;
|
import com.moez.QKSMS.ui.dialog.BlockedNumberDialog;
|
||||||
import com.moez.QKSMS.ui.dialog.BubblePreferenceDialog;
|
import com.moez.QKSMS.ui.dialog.BubblePreferenceDialog;
|
||||||
import com.moez.QKSMS.ui.dialog.QKDialog;
|
import com.moez.QKSMS.ui.dialog.QKDialog;
|
||||||
@@ -65,7 +64,7 @@ import java.util.Set;
|
|||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
public class SettingsFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener,
|
public class SettingsFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener,
|
||||||
Preference.OnPreferenceClickListener, ContentFragment {
|
Preference.OnPreferenceClickListener {
|
||||||
private final String TAG = "PreferenceFragment";
|
private final String TAG = "PreferenceFragment";
|
||||||
|
|
||||||
public static final String CATEGORY_APPEARANCE = "pref_key_category_appearance";
|
public static final String CATEGORY_APPEARANCE = "pref_key_category_appearance";
|
||||||
@@ -163,7 +162,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
public static final String GITHUB_URL = "https://github.com/qklabs/qksms";
|
public static final String GITHUB_URL = "https://github.com/qklabs/qksms";
|
||||||
public static final String CROWDIN_URL = "https://crowdin.com/project/qksms";
|
public static final String CROWDIN_URL = "https://crowdin.com/project/qksms";
|
||||||
|
|
||||||
private MainActivity mContext;
|
private QKActivity mContext;
|
||||||
private PreferenceManager mPreferenceManager;
|
private PreferenceManager mPreferenceManager;
|
||||||
private SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
private Resources mRes;
|
private Resources mRes;
|
||||||
@@ -186,7 +185,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
|
|
||||||
private int mResource;
|
private int mResource;
|
||||||
|
|
||||||
public static SettingsFragment newInstance(int category) {
|
protected static SettingsFragment newInstance(int category) {
|
||||||
SettingsFragment fragment = new SettingsFragment();
|
SettingsFragment fragment = new SettingsFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
@@ -200,11 +199,14 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
mContext = (MainActivity) getActivity();
|
mContext = (QKActivity) getActivity();
|
||||||
mPrefs = mContext.getPrefs();
|
mPrefs = mContext.getPrefs();
|
||||||
mRes = mContext.getResources();
|
mRes = mContext.getResources();
|
||||||
|
|
||||||
|
mContext.setTitle(R.string.title_settings);
|
||||||
|
|
||||||
mResource = args.getInt("category", R.xml.settings);
|
mResource = args.getInt("category", R.xml.settings);
|
||||||
addPreferencesFromResource(mResource);
|
addPreferencesFromResource(mResource);
|
||||||
|
|
||||||
@@ -333,6 +335,12 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.settings, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removed top level preferences from the layout
|
* Removed top level preferences from the layout
|
||||||
*/
|
*/
|
||||||
@@ -431,9 +439,6 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
case NIGHT_START:
|
case NIGHT_START:
|
||||||
updateAlarmManager(mContext, true);
|
updateAlarmManager(mContext, true);
|
||||||
break;
|
break;
|
||||||
case SLIDING_TAB:
|
|
||||||
mContext.setSlidingTabEnabled((Boolean) newValue);
|
|
||||||
break;
|
|
||||||
case YAPPY:
|
case YAPPY:
|
||||||
if ((Boolean) newValue) {
|
if ((Boolean) newValue) {
|
||||||
try {
|
try {
|
||||||
@@ -520,6 +525,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
Fragment fragment = SettingsFragment.newInstance(resId);
|
Fragment fragment = SettingsFragment.newInstance(resId);
|
||||||
getFragmentManager()
|
getFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
|
.addToBackStack(null)
|
||||||
.replace(R.id.content_frame, fragment, CATEGORY_TAG)
|
.replace(R.id.content_frame, fragment, CATEGORY_TAG)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
@@ -704,40 +710,4 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
alarmManager.cancel(nightIntent);
|
alarmManager.cancel(nightIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContentOpening() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContentOpened() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContentClosing() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContentClosed() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMenuChanging(float percentOpen) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user