fixed settings wizard
This commit is contained in:
parent
78bc7e6d55
commit
444588af19
|
@ -30,9 +30,10 @@ public class ErrorInfo {
|
||||||
|
|
||||||
public static final int PAGE_NOT_FOUND = 34;
|
public static final int PAGE_NOT_FOUND = 34;
|
||||||
public static final int RATE_LIMIT_EXCEEDED = 88;
|
public static final int RATE_LIMIT_EXCEEDED = 88;
|
||||||
|
public static final int NO_DIRECT_MESSAGE_PERMISSION = 93;
|
||||||
public static final int NOT_AUTHORIZED = 179;
|
public static final int NOT_AUTHORIZED = 179;
|
||||||
public static final int STATUS_IS_DUPLICATE = 187;
|
public static final int STATUS_IS_DUPLICATE = 187;
|
||||||
public static final int NO_DIRECT_MESSAGE_PERMISSION = 93;
|
public static final int STATUS_NOT_FOUND = 144;
|
||||||
|
|
||||||
@JsonField(name = "code")
|
@JsonField(name = "code")
|
||||||
int code;
|
int code;
|
||||||
|
|
|
@ -195,7 +195,6 @@ public interface IntentConstants {
|
||||||
String EXTRA_CHANGED = "changed";
|
String EXTRA_CHANGED = "changed";
|
||||||
String EXTRA_NOTIFY_CHANGE = "notify_change";
|
String EXTRA_NOTIFY_CHANGE = "notify_change";
|
||||||
String EXTRA_RESTART_ACTIVITY = "restart_activity";
|
String EXTRA_RESTART_ACTIVITY = "restart_activity";
|
||||||
String EXTRA_RECREATE_ACTIVITY = "recreate_activity";
|
|
||||||
String EXTRA_FROM_USER = "from_user";
|
String EXTRA_FROM_USER = "from_user";
|
||||||
String EXTRA_SHOW_MEDIA_PREVIEW = "show_media_preview";
|
String EXTRA_SHOW_MEDIA_PREVIEW = "show_media_preview";
|
||||||
String EXTRA_SHOW_EXTRA_TYPE = "show_extra_type";
|
String EXTRA_SHOW_EXTRA_TYPE = "show_extra_type";
|
||||||
|
|
|
@ -37,6 +37,7 @@ import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||||
import android.support.v7.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback;
|
import android.support.v7.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -64,6 +65,8 @@ import java.util.List;
|
||||||
public class SettingsActivity extends BaseActivity implements OnItemClickListener,
|
public class SettingsActivity extends BaseActivity implements OnItemClickListener,
|
||||||
OnPreferenceStartFragmentCallback {
|
OnPreferenceStartFragmentCallback {
|
||||||
|
|
||||||
|
public static final String EXTRA_INITIAL_TAG = "initial_tag";
|
||||||
|
|
||||||
private static final int RESULT_SETTINGS_CHANGED = 10;
|
private static final int RESULT_SETTINGS_CHANGED = 10;
|
||||||
|
|
||||||
private ListView mEntriesListView;
|
private ListView mEntriesListView;
|
||||||
|
@ -106,49 +109,63 @@ public class SettingsActivity extends BaseActivity implements OnItemClickListene
|
||||||
mEntriesListView.setOnItemClickListener(this);
|
mEntriesListView.setOnItemClickListener(this);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
String initialTag = getIntent().getStringExtra(EXTRA_INITIAL_TAG);
|
||||||
|
int initialItem = -1, firstEntry = -1;
|
||||||
for (int i = 0, j = mEntriesAdapter.getCount(); i < j; i++) {
|
for (int i = 0, j = mEntriesAdapter.getCount(); i < j; i++) {
|
||||||
if (mEntriesAdapter.getItemViewType(i) == EntriesAdapter.VIEW_TYPE_PREFERENCE_ENTRY) {
|
Entry entry = mEntriesAdapter.getItem(i);
|
||||||
openDetails(i);
|
if (entry instanceof PreferenceEntry) {
|
||||||
mEntriesListView.setItemChecked(i, true);
|
if (firstEntry == -1) {
|
||||||
break;
|
firstEntry = i;
|
||||||
|
}
|
||||||
|
if (TextUtils.equals(initialTag, ((PreferenceEntry) entry).tag)) {
|
||||||
|
initialItem = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (initialItem == -1) {
|
||||||
|
initialItem = firstEntry;
|
||||||
|
}
|
||||||
|
if (initialItem != -1) {
|
||||||
|
openDetails(initialItem);
|
||||||
|
mEntriesListView.setItemChecked(initialItem, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initEntries() {
|
private void initEntries() {
|
||||||
mEntriesAdapter.addHeader(getString(R.string.appearance));
|
mEntriesAdapter.addHeader(getString(R.string.appearance));
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_color_palette, getString(R.string.theme),
|
mEntriesAdapter.addPreference("theme", R.drawable.ic_action_color_palette, getString(R.string.theme),
|
||||||
R.xml.preferences_theme);
|
R.xml.preferences_theme);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_card, getString(R.string.cards),
|
mEntriesAdapter.addPreference("cards", R.drawable.ic_action_card, getString(R.string.cards),
|
||||||
R.xml.preferences_cards);
|
R.xml.preferences_cards);
|
||||||
|
|
||||||
mEntriesAdapter.addHeader(getString(R.string.function));
|
mEntriesAdapter.addHeader(getString(R.string.function));
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_tab, getString(R.string.tabs),
|
mEntriesAdapter.addPreference("tabs", R.drawable.ic_action_tab, getString(R.string.tabs),
|
||||||
CustomTabsFragment.class);
|
CustomTabsFragment.class);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_extension, getString(R.string.extensions),
|
mEntriesAdapter.addPreference("extension", R.drawable.ic_action_extension, getString(R.string.extensions),
|
||||||
ExtensionsListFragment.class);
|
ExtensionsListFragment.class);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_refresh, getString(R.string.refresh),
|
mEntriesAdapter.addPreference("refresh", R.drawable.ic_action_refresh, getString(R.string.refresh),
|
||||||
R.xml.preferences_refresh);
|
R.xml.preferences_refresh);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_notification, getString(R.string.notifications),
|
mEntriesAdapter.addPreference("notifications", R.drawable.ic_action_notification, getString(R.string.notifications),
|
||||||
R.xml.preferences_notifications);
|
R.xml.preferences_notifications);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_web, getString(R.string.network),
|
mEntriesAdapter.addPreference("network", R.drawable.ic_action_web, getString(R.string.network),
|
||||||
R.xml.preferences_network);
|
R.xml.preferences_network);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_status_compose, getString(R.string.compose),
|
mEntriesAdapter.addPreference("compose", R.drawable.ic_action_status_compose, getString(R.string.compose),
|
||||||
R.xml.preferences_compose);
|
R.xml.preferences_compose);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_twidere_square, getString(R.string.content),
|
mEntriesAdapter.addPreference("content", R.drawable.ic_action_twidere_square, getString(R.string.content),
|
||||||
R.xml.preferences_content);
|
R.xml.preferences_content);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_storage, getString(R.string.storage),
|
mEntriesAdapter.addPreference("storage", R.drawable.ic_action_storage, getString(R.string.storage),
|
||||||
R.xml.preferences_storage);
|
R.xml.preferences_storage);
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_more_horizontal, getString(R.string.other_settings),
|
mEntriesAdapter.addPreference("other", R.drawable.ic_action_more_horizontal, getString(R.string.other_settings),
|
||||||
R.xml.preferences_other);
|
R.xml.preferences_other);
|
||||||
|
|
||||||
mEntriesAdapter.addHeader(getString(R.string.about));
|
mEntriesAdapter.addHeader(getString(R.string.about));
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_info, getString(R.string.about),
|
mEntriesAdapter.addPreference("about", R.drawable.ic_action_info, getString(R.string.about),
|
||||||
R.xml.preferences_about);
|
R.xml.preferences_about);
|
||||||
final Bundle browserArgs = new Bundle();
|
final Bundle browserArgs = new Bundle();
|
||||||
browserArgs.putString(EXTRA_URI, "file:///android_asset/gpl-3.0-standalone.html");
|
browserArgs.putString(EXTRA_URI, "file:///android_asset/gpl-3.0-standalone.html");
|
||||||
mEntriesAdapter.addPreference(R.drawable.ic_action_open_source, getString(R.string.open_source_license),
|
mEntriesAdapter.addPreference("license", R.drawable.ic_action_open_source, getString(R.string.open_source_license),
|
||||||
SupportBrowserFragment.class, browserArgs);
|
SupportBrowserFragment.class, browserArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,19 +292,19 @@ public class SettingsActivity extends BaseActivity implements OnItemClickListene
|
||||||
mEntries = new ArrayList<>();
|
mEntries = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPreference(@DrawableRes int icon, String title, @XmlRes int preference) {
|
public void addPreference(String tag, @DrawableRes int icon, String title, @XmlRes int preference) {
|
||||||
mEntries.add(new PreferenceEntry(icon, title, preference, null, null));
|
mEntries.add(new PreferenceEntry(tag, icon, title, preference, null, null));
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPreference(@DrawableRes int icon, String title, Class<? extends Fragment> cls) {
|
public void addPreference(String tag, @DrawableRes int icon, String title, Class<? extends Fragment> cls) {
|
||||||
addPreference(icon, title, cls, null);
|
addPreference(tag, icon, title, cls, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addPreference(@DrawableRes int icon, String title, Class<? extends Fragment> cls,
|
public void addPreference(String tag, @DrawableRes int icon, String title, Class<? extends Fragment> cls,
|
||||||
@Nullable Bundle args) {
|
@Nullable Bundle args) {
|
||||||
mEntries.add(new PreferenceEntry(icon, title, 0, cls.getName(), args));
|
mEntries.add(new PreferenceEntry(tag, icon, title, 0, cls.getName(), args));
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +382,8 @@ public class SettingsActivity extends BaseActivity implements OnItemClickListene
|
||||||
}
|
}
|
||||||
|
|
||||||
static class PreferenceEntry extends Entry {
|
static class PreferenceEntry extends Entry {
|
||||||
|
@NonNull
|
||||||
|
private final String tag;
|
||||||
private final int icon;
|
private final int icon;
|
||||||
private final String title;
|
private final String title;
|
||||||
private final int preference;
|
private final int preference;
|
||||||
|
@ -372,7 +391,8 @@ public class SettingsActivity extends BaseActivity implements OnItemClickListene
|
||||||
|
|
||||||
private final Bundle args;
|
private final Bundle args;
|
||||||
|
|
||||||
public PreferenceEntry(int icon, String title, int preference, String fragment, Bundle args) {
|
public PreferenceEntry(@NonNull String tag, int icon, String title, int preference, String fragment, Bundle args) {
|
||||||
|
this.tag = tag;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.preference = preference;
|
this.preference = preference;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -36,6 +37,7 @@ import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.support.v7.preference.PreferenceManager;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -43,6 +45,7 @@ import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.afollestad.appthemeengine.Config;
|
import com.afollestad.appthemeengine.Config;
|
||||||
|
import com.afollestad.appthemeengine.util.ATEUtil;
|
||||||
import com.afollestad.materialdialogs.AlertDialogWrapper;
|
import com.afollestad.materialdialogs.AlertDialogWrapper;
|
||||||
|
|
||||||
import org.mariotaku.twidere.Constants;
|
import org.mariotaku.twidere.Constants;
|
||||||
|
@ -142,6 +145,12 @@ public class SettingsWizardActivity extends BaseActivity implements Constants {
|
||||||
mIndicator = (LinePageIndicator) findViewById(R.id.indicator);
|
mIndicator = (LinePageIndicator) findViewById(R.id.indicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatusBarColor() {
|
||||||
|
if (VALUE_THEME_NAME_DARK.equals(getATEKey())) return Color.BLACK;
|
||||||
|
return ATEUtil.darkenColor(ThemeUtils.getColorBackground(this));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
|
@ -222,6 +231,8 @@ public class SettingsWizardActivity extends BaseActivity implements Constants {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
|
final PreferenceManager preferenceManager = getPreferenceManager();
|
||||||
|
preferenceManager.setSharedPreferencesName(SHARED_PREFERENCES_NAME);
|
||||||
addPreferencesFromResource(getPreferenceResource());
|
addPreferencesFromResource(getPreferenceResource());
|
||||||
|
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
|
@ -259,13 +270,6 @@ public class SettingsWizardActivity extends BaseActivity implements Constants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(final Preference preference) {
|
public boolean onPreferenceClick(final Preference preference) {
|
||||||
if (WIZARD_PREFERENCE_KEY_NEXT_PAGE.equals(preference.getKey())) {
|
if (WIZARD_PREFERENCE_KEY_NEXT_PAGE.equals(preference.getKey())) {
|
||||||
|
@ -435,10 +439,9 @@ public class SettingsWizardActivity extends BaseActivity implements Constants {
|
||||||
public boolean onPreferenceClick(final Preference preference) {
|
public boolean onPreferenceClick(final Preference preference) {
|
||||||
final String key = preference.getKey();
|
final String key = preference.getKey();
|
||||||
if (WIZARD_PREFERENCE_KEY_EDIT_CUSTOM_TABS.equals(key)) {
|
if (WIZARD_PREFERENCE_KEY_EDIT_CUSTOM_TABS.equals(key)) {
|
||||||
// final Intent intent = new Intent(getActivity(), SettingsActivity.class);
|
final Intent intent = new Intent(getActivity(), SettingsActivity.class);
|
||||||
// intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, CustomTabsFragment.class.getName());
|
intent.putExtra(SettingsActivity.EXTRA_INITIAL_TAG, "tabs");
|
||||||
// intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, R.string.tabs);
|
startActivityForResult(intent, REQUEST_CUSTOM_TABS);
|
||||||
// startActivityForResult(intent, REQUEST_CUSTOM_TABS);
|
|
||||||
} else if (WIZARD_PREFERENCE_KEY_USE_DEFAULTS.equals(key)) {
|
} else if (WIZARD_PREFERENCE_KEY_USE_DEFAULTS.equals(key)) {
|
||||||
applyInitialTabSettings();
|
applyInitialTabSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.mariotaku.twidere.api.twitter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mariotaku on 16/2/13.
|
|
||||||
*/
|
|
||||||
public interface TwitterErrorCode {
|
|
||||||
int NO_DM_PERMISSION = 93;
|
|
||||||
}
|
|
|
@ -178,14 +178,14 @@ public class TwidereApplication extends Application implements Constants,
|
||||||
//noinspection WrongConstant
|
//noinspection WrongConstant
|
||||||
ATE.config(this, VALUE_THEME_NAME_LIGHT)
|
ATE.config(this, VALUE_THEME_NAME_LIGHT)
|
||||||
.primaryColor(themeColor)
|
.primaryColor(themeColor)
|
||||||
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor))
|
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.BLACK))
|
||||||
.coloredActionBar(true)
|
.coloredActionBar(true)
|
||||||
.coloredStatusBar(true)
|
.coloredStatusBar(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
if (!ATE.config(this, VALUE_THEME_NAME_DARK).isConfigured()) {
|
if (!ATE.config(this, VALUE_THEME_NAME_DARK).isConfigured()) {
|
||||||
ATE.config(this, VALUE_THEME_NAME_DARK)
|
ATE.config(this, VALUE_THEME_NAME_DARK)
|
||||||
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor))
|
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE))
|
||||||
.coloredActionBar(false)
|
.coloredActionBar(false)
|
||||||
.coloredStatusBar(true)
|
.coloredStatusBar(true)
|
||||||
.statusBarColor(Color.BLACK)
|
.statusBarColor(Color.BLACK)
|
||||||
|
@ -193,7 +193,7 @@ public class TwidereApplication extends Application implements Constants,
|
||||||
}
|
}
|
||||||
if (!ATE.config(this, null).isConfigured()) {
|
if (!ATE.config(this, null).isConfigured()) {
|
||||||
ATE.config(this, null)
|
ATE.config(this, null)
|
||||||
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor))
|
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE))
|
||||||
.coloredActionBar(false)
|
.coloredActionBar(false)
|
||||||
.coloredStatusBar(false)
|
.coloredStatusBar(false)
|
||||||
.commit();
|
.commit();
|
||||||
|
@ -360,18 +360,18 @@ public class TwidereApplication extends Application implements Constants,
|
||||||
//noinspection WrongConstant
|
//noinspection WrongConstant
|
||||||
ATE.config(this, VALUE_THEME_NAME_LIGHT)
|
ATE.config(this, VALUE_THEME_NAME_LIGHT)
|
||||||
.primaryColor(themeColor)
|
.primaryColor(themeColor)
|
||||||
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor))
|
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.BLACK))
|
||||||
.coloredActionBar(true)
|
.coloredActionBar(true)
|
||||||
.coloredStatusBar(true)
|
.coloredStatusBar(true)
|
||||||
.commit();
|
.commit();
|
||||||
ATE.config(this, VALUE_THEME_NAME_DARK)
|
ATE.config(this, VALUE_THEME_NAME_DARK)
|
||||||
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor))
|
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE))
|
||||||
.coloredActionBar(false)
|
.coloredActionBar(false)
|
||||||
.coloredStatusBar(true)
|
.coloredStatusBar(true)
|
||||||
.statusBarColor(Color.BLACK)
|
.statusBarColor(Color.BLACK)
|
||||||
.commit();
|
.commit();
|
||||||
ATE.config(this, null)
|
ATE.config(this, null)
|
||||||
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor))
|
.accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.BLACK))
|
||||||
.coloredActionBar(false)
|
.coloredActionBar(false)
|
||||||
.coloredStatusBar(false)
|
.coloredStatusBar(false)
|
||||||
.commit();
|
.commit();
|
||||||
|
|
|
@ -24,7 +24,6 @@ import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
|
||||||
import android.support.v7.preference.PreferenceManager;
|
import android.support.v7.preference.PreferenceManager;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ import org.mariotaku.twidere.Constants;
|
||||||
import org.mariotaku.twidere.activity.SettingsActivity;
|
import org.mariotaku.twidere.activity.SettingsActivity;
|
||||||
import org.mariotaku.twidere.util.Utils;
|
import org.mariotaku.twidere.util.Utils;
|
||||||
|
|
||||||
public class SettingsDetailsFragment extends PreferenceFragmentCompat implements Constants,
|
public class SettingsDetailsFragment extends BasePreferenceFragment implements Constants,
|
||||||
OnSharedPreferenceChangeListener {
|
OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,8 +109,6 @@ public class SettingsDetailsFragment extends PreferenceFragmentCompat implements
|
||||||
}
|
}
|
||||||
if (extras.containsKey(EXTRA_RESTART_ACTIVITY)) {
|
if (extras.containsKey(EXTRA_RESTART_ACTIVITY)) {
|
||||||
activity.recreate();
|
activity.recreate();
|
||||||
} else if (extras.containsKey(EXTRA_RECREATE_ACTIVITY)) {
|
|
||||||
activity.recreate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.os.Bundle;
|
||||||
import android.support.v4.content.AsyncTaskLoader;
|
import android.support.v4.content.AsyncTaskLoader;
|
||||||
|
|
||||||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||||
|
import org.mariotaku.twidere.api.twitter.model.ErrorInfo;
|
||||||
import org.mariotaku.twidere.constant.IntentConstants;
|
import org.mariotaku.twidere.constant.IntentConstants;
|
||||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||||
|
@ -31,13 +32,13 @@ import org.mariotaku.twidere.model.SingleResponse;
|
||||||
import org.mariotaku.twidere.model.UserKey;
|
import org.mariotaku.twidere.model.UserKey;
|
||||||
import org.mariotaku.twidere.model.util.ParcelableCredentialsUtils;
|
import org.mariotaku.twidere.model.util.ParcelableCredentialsUtils;
|
||||||
import org.mariotaku.twidere.model.util.ParcelableStatusUtils;
|
import org.mariotaku.twidere.model.util.ParcelableStatusUtils;
|
||||||
|
import org.mariotaku.twidere.util.DataStoreUtils;
|
||||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||||
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper;
|
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT;
|
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT;
|
||||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_STATUS;
|
|
||||||
import static org.mariotaku.twidere.util.Utils.findStatus;
|
import static org.mariotaku.twidere.util.Utils.findStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,6 +85,11 @@ public class ParcelableStatusLoader extends AsyncTaskLoader<SingleResponse<Parce
|
||||||
extras.putParcelable(EXTRA_ACCOUNT, credentials);
|
extras.putParcelable(EXTRA_ACCOUNT, credentials);
|
||||||
return response;
|
return response;
|
||||||
} catch (final TwitterException e) {
|
} catch (final TwitterException e) {
|
||||||
|
if (e.getErrorCode() == ErrorInfo.STATUS_NOT_FOUND) {
|
||||||
|
// Delete all deleted status
|
||||||
|
DataStoreUtils.deleteStatus(getContext().getContentResolver(), mAccountId,
|
||||||
|
mStatusId, null);
|
||||||
|
}
|
||||||
return SingleResponse.getInstance(e);
|
return SingleResponse.getInstance(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class ColorPickerPreference extends DialogPreference implements Constants
|
||||||
if (preference.isPersistent()) {
|
if (preference.isPersistent()) {
|
||||||
preference.persistInt(color);
|
preference.persistInt(color);
|
||||||
}
|
}
|
||||||
|
preference.callChangeListener(color);
|
||||||
preference.notifyChanged();
|
preference.notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class NotificationTypePreference extends DialogPreference implements Cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preference.persistInt(value);
|
preference.persistInt(value);
|
||||||
|
preference.callChangeListener(value);
|
||||||
preference.notifyChanged();
|
preference.notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ public class SeekBarDialogPreference extends DialogPreference implements IDialog
|
||||||
if (progress != mProgress) {
|
if (progress != mProgress) {
|
||||||
mProgress = progress;
|
mProgress = progress;
|
||||||
persistInt(progress);
|
persistInt(progress);
|
||||||
|
callChangeListener(progress);
|
||||||
notifyChanged();
|
notifyChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ public class ThemeBackgroundPreference extends DialogPreference implements Const
|
||||||
// Always persist/notify the first time.
|
// Always persist/notify the first time.
|
||||||
if (!TextUtils.equals(getPersistedString(null), value)) {
|
if (!TextUtils.equals(getPersistedString(null), value)) {
|
||||||
persistString(value);
|
persistString(value);
|
||||||
|
callChangeListener(value);
|
||||||
notifyChanged();
|
notifyChanged();
|
||||||
}
|
}
|
||||||
updateSummary();
|
updateSummary();
|
||||||
|
@ -142,7 +143,6 @@ public class ThemeBackgroundPreference extends DialogPreference implements Const
|
||||||
editor.putInt(KEY_THEME_BACKGROUND_ALPHA, getSliderAlpha());
|
editor.putInt(KEY_THEME_BACKGROUND_ALPHA, getSliderAlpha());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
preference.saveValue();
|
preference.saveValue();
|
||||||
preference.notifyChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAlphaVisibility() {
|
private void updateAlphaVisibility() {
|
||||||
|
|
|
@ -13,9 +13,9 @@ import org.mariotaku.twidere.BuildConfig;
|
||||||
import org.mariotaku.twidere.Constants;
|
import org.mariotaku.twidere.Constants;
|
||||||
import org.mariotaku.twidere.TwidereConstants;
|
import org.mariotaku.twidere.TwidereConstants;
|
||||||
import org.mariotaku.twidere.api.twitter.Twitter;
|
import org.mariotaku.twidere.api.twitter.Twitter;
|
||||||
import org.mariotaku.twidere.api.twitter.TwitterErrorCode;
|
|
||||||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||||
import org.mariotaku.twidere.api.twitter.model.DirectMessage;
|
import org.mariotaku.twidere.api.twitter.model.DirectMessage;
|
||||||
|
import org.mariotaku.twidere.api.twitter.model.ErrorInfo;
|
||||||
import org.mariotaku.twidere.api.twitter.model.Paging;
|
import org.mariotaku.twidere.api.twitter.model.Paging;
|
||||||
import org.mariotaku.twidere.api.twitter.model.ResponseList;
|
import org.mariotaku.twidere.api.twitter.model.ResponseList;
|
||||||
import org.mariotaku.twidere.model.RefreshTaskParam;
|
import org.mariotaku.twidere.model.RefreshTaskParam;
|
||||||
|
@ -98,7 +98,7 @@ public abstract class GetDirectMessagesTask extends AbstractTask<RefreshTaskPara
|
||||||
storeMessages(accountKey, messages, isOutgoing(), true);
|
storeMessages(accountKey, messages, isOutgoing(), true);
|
||||||
errorInfoStore.remove(ErrorInfoStore.KEY_DIRECT_MESSAGES, accountKey);
|
errorInfoStore.remove(ErrorInfoStore.KEY_DIRECT_MESSAGES, accountKey);
|
||||||
} catch (final TwitterException e) {
|
} catch (final TwitterException e) {
|
||||||
if (e.getErrorCode() == TwitterErrorCode.NO_DM_PERMISSION) {
|
if (e.getErrorCode() == ErrorInfo.NO_DIRECT_MESSAGE_PERMISSION) {
|
||||||
errorInfoStore.put(ErrorInfoStore.KEY_DIRECT_MESSAGES, accountKey,
|
errorInfoStore.put(ErrorInfoStore.KEY_DIRECT_MESSAGES, accountKey,
|
||||||
ErrorInfoStore.CODE_NO_DM_PERMISSION);
|
ErrorInfoStore.CODE_NO_DM_PERMISSION);
|
||||||
} else if (e.isCausedByNetworkIssue()) {
|
} else if (e.isCausedByNetworkIssue()) {
|
||||||
|
|
|
@ -577,7 +577,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SingleResponse<ParcelableUser> doLongOperation(final Object params) {
|
protected SingleResponse<ParcelableUser> doLongOperation(final Object params) {
|
||||||
try {
|
try {
|
||||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(mContext, mAccountKey, true);
|
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(mContext, mAccountKey, true);
|
||||||
TwitterWrapper.updateProfileImage(mContext, twitter, mImageUri, mDeleteImage);
|
TwitterWrapper.updateProfileImage(mContext, twitter, mImageUri, mDeleteImage);
|
||||||
|
@ -1304,16 +1304,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||||
} catch (final TwitterException e) {
|
} catch (final TwitterException e) {
|
||||||
exception = e;
|
exception = e;
|
||||||
}
|
}
|
||||||
if (status != null || (exception != null && exception.getErrorCode() == HttpResponseCode.NOT_FOUND)) {
|
if (status != null || (exception != null && exception.getErrorCode() == ErrorInfo.STATUS_NOT_FOUND)) {
|
||||||
final ContentValues values = new ContentValues();
|
DataStoreUtils.deleteStatus(mResolver, mAccountKey, mStatusId, status);
|
||||||
values.put(Statuses.MY_RETWEET_ID, -1);
|
|
||||||
if (status != null) {
|
|
||||||
values.put(Statuses.RETWEET_COUNT, status.retweet_count - 1);
|
|
||||||
}
|
|
||||||
for (final Uri uri : TwidereDataStore.STATUSES_URIS) {
|
|
||||||
mResolver.delete(uri, Expression.equalsArgs(Statuses.STATUS_ID).getSQL(), new String[]{mStatusId});
|
|
||||||
mResolver.update(uri, values, Expression.equalsArgs(Statuses.MY_RETWEET_ID).getSQL(), new String[]{mStatusId});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return SingleResponse.getInstance(status, exception);
|
return SingleResponse.getInstance(status, exception);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.mariotaku.twidere.util;
|
package org.mariotaku.twidere.util;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.UriMatcher;
|
import android.content.UriMatcher;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
@ -50,6 +51,7 @@ import org.mariotaku.twidere.api.twitter.model.Activity;
|
||||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||||
import org.mariotaku.twidere.model.ParcelableCredentialsCursorIndices;
|
import org.mariotaku.twidere.model.ParcelableCredentialsCursorIndices;
|
||||||
|
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||||
import org.mariotaku.twidere.model.UserFollowState;
|
import org.mariotaku.twidere.model.UserFollowState;
|
||||||
import org.mariotaku.twidere.model.UserKey;
|
import org.mariotaku.twidere.model.UserKey;
|
||||||
import org.mariotaku.twidere.model.tab.extra.InteractionsTabExtras;
|
import org.mariotaku.twidere.model.tab.extra.InteractionsTabExtras;
|
||||||
|
@ -905,6 +907,48 @@ public class DataStoreUtils implements Constants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void deleteStatus(@NonNull ContentResolver cr, @NonNull UserKey accountKey,
|
||||||
|
@NonNull String statusId, @Nullable ParcelableStatus status) {
|
||||||
|
|
||||||
|
final String host = accountKey.getHost();
|
||||||
|
if (host != null) {
|
||||||
|
for (final Uri uri : STATUSES_URIS) {
|
||||||
|
final String deleteWhere = Expression.and(
|
||||||
|
Expression.likeRaw(new Column(Statuses.ACCOUNT_KEY), "%@?"),
|
||||||
|
Expression.or(
|
||||||
|
Expression.equalsArgs(Statuses.STATUS_ID),
|
||||||
|
Expression.equalsArgs(Statuses.RETWEET_ID)
|
||||||
|
)).getSQL();
|
||||||
|
cr.delete(uri, deleteWhere, new String[]{host, statusId, statusId});
|
||||||
|
final String updateWhere = Expression.and(
|
||||||
|
Expression.likeRaw(new Column(Statuses.ACCOUNT_KEY), "%@?"),
|
||||||
|
Expression.equalsArgs(Statuses.MY_RETWEET_ID)
|
||||||
|
).getSQL();
|
||||||
|
if (status != null) {
|
||||||
|
final ContentValues values = new ContentValues();
|
||||||
|
values.put(Statuses.MY_RETWEET_ID, -1);
|
||||||
|
values.put(Statuses.RETWEET_COUNT, status.retweet_count - 1);
|
||||||
|
cr.update(uri, values, updateWhere, new String[]{host, statusId});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (final Uri uri : STATUSES_URIS) {
|
||||||
|
final String deleteWhere = Expression.or(
|
||||||
|
Expression.equalsArgs(Statuses.STATUS_ID),
|
||||||
|
Expression.equalsArgs(Statuses.RETWEET_ID)
|
||||||
|
).getSQL();
|
||||||
|
cr.delete(uri, deleteWhere, new String[]{statusId, statusId});
|
||||||
|
final String updateWhere = Expression.equalsArgs(Statuses.MY_RETWEET_ID).getSQL();
|
||||||
|
if (status != null) {
|
||||||
|
final ContentValues values = new ContentValues();
|
||||||
|
values.put(Statuses.MY_RETWEET_ID, -1);
|
||||||
|
values.put(Statuses.RETWEET_COUNT, status.retweet_count - 1);
|
||||||
|
cr.update(uri, values, updateWhere, new String[]{statusId});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface FieldArrayCreator<T> {
|
interface FieldArrayCreator<T> {
|
||||||
T newArray(int size);
|
T newArray(int size);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?selectableItemBackground"
|
||||||
android:padding="@dimen/element_spacing_large">
|
android:padding="@dimen/element_spacing_large">
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.WizardHighlightTextView
|
<org.mariotaku.twidere.view.WizardHighlightTextView
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
android:order="21"
|
android:order="21"
|
||||||
android:title="@string/theme">
|
android:title="@string/theme">
|
||||||
<extra
|
<extra
|
||||||
android:name="recreate_activity"
|
android:name="restart_activity"
|
||||||
android:value="true"/>
|
android:value="true"/>
|
||||||
</org.mariotaku.twidere.preference.EntrySummaryListPreference>
|
</org.mariotaku.twidere.preference.EntrySummaryListPreference>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue