diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java index 2fbdb7f59..19d3ccab3 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java @@ -163,10 +163,10 @@ public interface TwidereDataStore { PROFILE_BANNER_URL, COLOR, IS_ACTIVATED, SORT_POSITION, ACCOUNT_TYPE, ACCOUNT_EXTRAS, ACCOUNT_USER}; - String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, - TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, - TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_BOOLEAN, TYPE_INT, - TYPE_TEXT, TYPE_TEXT, TYPE_TEXT}; + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, + TYPE_TEXT_NOT_NULL_UNIQUE, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, + TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, + TYPE_INT, TYPE_BOOLEAN, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT}; } diff --git a/twidere/src/main/java/org/mariotaku/twidere/Constants.java b/twidere/src/main/java/org/mariotaku/twidere/Constants.java index 467fbe01c..fc95319c0 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/Constants.java +++ b/twidere/src/main/java/org/mariotaku/twidere/Constants.java @@ -34,7 +34,7 @@ import static org.mariotaku.twidere.annotation.PreferenceType.STRING; public interface Constants extends TwidereConstants { String DATABASES_NAME = "twidere.sqlite"; - int DATABASES_VERSION = 137; + int DATABASES_VERSION = 138; int MENU_GROUP_STATUS_EXTENSION = 10; int MENU_GROUP_COMPOSE_EXTENSION = 11; diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/AccountsDashboardFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/AccountsDashboardFragment.java index 9d7c9fd25..58ecb7bf9 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/AccountsDashboardFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/AccountsDashboardFragment.java @@ -276,7 +276,14 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo if (accountKey == null) { accountKey = defaultId; } - mAccountsAdapter.setSelectedAccountKey(accountKey); + ParcelableAccount selectedAccount = null; + for (ParcelableAccount account : accounts) { + if (account.account_key.equals(accountKey)) { + selectedAccount = account; + break; + } + } + mAccountsAdapter.setSelectedAccount(selectedAccount); if (mAccountActionProvider != null) { mAccountActionProvider.setExclusive(false); @@ -563,7 +570,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo final Editor editor = mPreferences.edit(); editor.putString(KEY_DEFAULT_ACCOUNT_KEY, account.account_key.toString()); editor.apply(); - mAccountsAdapter.setSelectedAccountKey(account.account_key); + mAccountsAdapter.setSelectedAccount(account); updateAccountActions(); updateAccountOptionsSeparatorLabel(clickedDrawable); snapshotView.setVisibility(View.INVISIBLE); @@ -759,10 +766,10 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo return selectedAccount.account_key; } - public void setSelectedAccountKey(@Nullable UserKey accountKey) { + public void setSelectedAccount(@Nullable ParcelableAccount account) { final ParcelableAccount selectedAccount = getSelectedAccount(); - if (selectedAccount == null || accountKey == null) return; - swap(accountKey, selectedAccount.account_key); + if (selectedAccount == null || account == null) return; + swap(account, selectedAccount); } @Override @@ -821,14 +828,14 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo return mInternalAccounts; } - private void swap(UserKey fromId, UserKey toId) { + private void swap(@NonNull ParcelableAccount from, @NonNull ParcelableAccount to) { int fromIdx = -1, toIdx = -1; for (int i = 0, j = mInternalAccounts.length; i < j; i++) { final ParcelableAccount account = mInternalAccounts[i]; - if (fromId.equals(account.account_key)) { + if (from.id == account.id) { fromIdx = i; } - if (toId.equals(account.account_key)) { + if (to.id == account.id) { toIdx = i; } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/CursorStatusesFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/CursorStatusesFragment.java index f6569c502..2d85ab2e2 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/CursorStatusesFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/CursorStatusesFragment.java @@ -22,7 +22,6 @@ package org.mariotaku.twidere.fragment; import android.content.ContentResolver; import android.content.Context; import android.database.ContentObserver; -import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.os.Handler; @@ -33,7 +32,6 @@ import android.support.v4.content.Loader; import com.squareup.otto.Subscribe; -import org.mariotaku.library.objectcursor.ObjectCursor; import org.mariotaku.sqliteqb.library.ArgsArray; import org.mariotaku.sqliteqb.library.Columns.Column; import org.mariotaku.sqliteqb.library.Expression; @@ -43,7 +41,6 @@ import org.mariotaku.twidere.adapter.ListParcelableStatusesAdapter; import org.mariotaku.twidere.adapter.ParcelableStatusesAdapter; import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition; import org.mariotaku.twidere.loader.ExtendedObjectCursorLoader; -import org.mariotaku.twidere.model.ParcelableAccount; import org.mariotaku.twidere.model.ParcelableStatus; import org.mariotaku.twidere.model.ParcelableStatusCursorIndices; import org.mariotaku.twidere.model.SimpleRefreshTaskParam; @@ -54,7 +51,6 @@ import org.mariotaku.twidere.model.message.GetStatusesTaskEvent; import org.mariotaku.twidere.model.message.StatusDestroyedEvent; import org.mariotaku.twidere.model.message.StatusListChangedEvent; import org.mariotaku.twidere.model.message.StatusRetweetedEvent; -import org.mariotaku.twidere.model.util.ParcelableAccountUtils; import org.mariotaku.twidere.provider.TwidereDataStore.Accounts; import org.mariotaku.twidere.provider.TwidereDataStore.Filters; import org.mariotaku.twidere.provider.TwidereDataStore.Statuses; @@ -138,7 +134,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment { if (!event.uri.equals(getContentUri())) return; setRefreshing(event.running); if (!event.running) { - setLoadMoreIndicatorPosition(IndicatorPosition.END); + setLoadMoreIndicatorPosition(IndicatorPosition.NONE); setRefreshEnabled(true); onLoadingFinished(); } diff --git a/twidere/src/main/java/org/mariotaku/twidere/preference/EntrySummaryListPreference.java b/twidere/src/main/java/org/mariotaku/twidere/preference/EntrySummaryListPreference.java new file mode 100644 index 000000000..1eee08e91 --- /dev/null +++ b/twidere/src/main/java/org/mariotaku/twidere/preference/EntrySummaryListPreference.java @@ -0,0 +1,30 @@ +package org.mariotaku.twidere.preference; + +import android.content.Context; +import android.util.AttributeSet; + +/** + * Created by mariotaku on 16/3/22. + */ +public class EntrySummaryListPreference extends ThemedListPreference { + public EntrySummaryListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + public EntrySummaryListPreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public EntrySummaryListPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public EntrySummaryListPreference(Context context) { + super(context); + } + + @Override + public CharSequence getSummary() { + return getEntry(); + } +} diff --git a/twidere/src/main/java/org/mariotaku/twidere/preference/LinkHighlightPreference.java b/twidere/src/main/java/org/mariotaku/twidere/preference/LinkHighlightPreference.java index 19392f5b4..21c4b8816 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/preference/LinkHighlightPreference.java +++ b/twidere/src/main/java/org/mariotaku/twidere/preference/LinkHighlightPreference.java @@ -20,7 +20,6 @@ package org.mariotaku.twidere.preference; import android.content.Context; -import android.support.v7.preference.PreferenceViewHolder; import android.text.SpannableString; import android.util.AttributeSet; @@ -28,7 +27,7 @@ import org.mariotaku.twidere.Constants; import org.mariotaku.twidere.R; import org.mariotaku.twidere.text.TwidereHighLightStyle; -public class LinkHighlightPreference extends ThemedListPreference implements Constants { +public class LinkHighlightPreference extends EntrySummaryListPreference implements Constants { private static final int[] ENTRIES_RES = {R.string.none, R.string.highlight, R.string.underline, R.string.highlight_and_underline}; @@ -52,14 +51,6 @@ public class LinkHighlightPreference extends ThemedListPreference implements Con setEntryValues(VALUES); } - @Override - public void onBindViewHolder(PreferenceViewHolder holder) { - super.onBindViewHolder(holder); -// final TextView summary = (TextView) holder.findViewById(android.R.id.summary); -// summary.setVisibility(View.VISIBLE); -// summary.setText(getStyledEntry(Utils.getLinkHighlightingStyleInt(getValue()), getEntry())); - } - private static CharSequence getStyledEntry(final int option, final CharSequence entry) { final SpannableString str = new SpannableString(entry); str.setSpan(new TwidereHighLightStyle(option), 0, str.length(), 0); diff --git a/twidere/src/main/java/org/mariotaku/twidere/preference/ThemeFontFamilyPreference.java b/twidere/src/main/java/org/mariotaku/twidere/preference/ThemeFontFamilyPreference.java index f62300814..ddbc17890 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/preference/ThemeFontFamilyPreference.java +++ b/twidere/src/main/java/org/mariotaku/twidere/preference/ThemeFontFamilyPreference.java @@ -28,7 +28,7 @@ import android.util.AttributeSet; import org.mariotaku.twidere.Constants; import org.mariotaku.twidere.R; -public class ThemeFontFamilyPreference extends ThemedListPreference implements Constants { +public class ThemeFontFamilyPreference extends EntrySummaryListPreference implements Constants { private static final int[] ENTRIES_RES = {R.string.font_family_regular, R.string.font_family_condensed, R.string.font_family_light}; diff --git a/twidere/src/main/java/org/mariotaku/twidere/task/twitter/GetStatusesTask.java b/twidere/src/main/java/org/mariotaku/twidere/task/twitter/GetStatusesTask.java index a43060564..07bdb64ec 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/task/twitter/GetStatusesTask.java +++ b/twidere/src/main/java/org/mariotaku/twidere/task/twitter/GetStatusesTask.java @@ -199,7 +199,7 @@ public abstract class GetStatusesTask extends AbstractTask 0) { + // descent sorted by time + extraValue = count - 1 - position; + } else { + // ascent sorted by time + extraValue = position; + } + return timestamp + (sortId - lastSortId) * (499 - count) / sortDiff + extraValue; } } diff --git a/twidere/src/main/res/xml/preferences_advanced_network.xml b/twidere/src/main/res/xml/preferences_advanced_network.xml index ca5d413c7..637aa36e3 100644 --- a/twidere/src/main/res/xml/preferences_advanced_network.xml +++ b/twidere/src/main/res/xml/preferences_advanced_network.xml @@ -51,7 +51,7 @@ android:summary="@string/proxy_summary" android:title="@string/proxy"/> - - - + . --> + - - - - + - - - +