From 3c8f7d007fac6284392777a3a76214a446785acd Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sun, 26 Apr 2015 18:55:41 +0800 Subject: [PATCH] added restart confirm --- twidere/src/main/AndroidManifest.xml | 2 +- .../activity/BasePreferenceActivity.java | 3 +- .../twidere/activity/SettingsActivity.java | 90 +++++-- .../support/BaseDialogWhenLargeActivity.java | 3 +- .../activity/support/LinkHandlerActivity.java | 3 +- .../twidere/fragment/BaseFiltersFragment.java | 70 ++--- .../support/AbsActivitiesFragment.java | 2 +- .../support/AbsContentListViewFragment.java | 253 ++++++++++++++++++ ...va => AbsContentRecyclerViewFragment.java} | 4 +- .../fragment/support/AbsStatusesFragment.java | 2 +- .../fragment/support/AbsUsersFragment.java | 2 +- .../support/DirectMessagesFragment.java | 2 +- .../support/UserMediaTimelineFragment.java | 2 +- .../util/ContentListScrollListener.java | 13 +- .../mariotaku/twidere/util/ThemeUtils.java | 39 ++- .../main/res-localized/values-ar/strings.xml | 2 +- .../main/res-localized/values-ca/strings.xml | 2 +- .../main/res-localized/values-cs/strings.xml | 2 +- .../main/res-localized/values-de/strings.xml | 2 +- .../main/res-localized/values-es/strings.xml | 2 +- .../main/res-localized/values-fi/strings.xml | 2 +- .../main/res-localized/values-fr/strings.xml | 2 +- .../main/res-localized/values-hi/strings.xml | 2 +- .../main/res-localized/values-hu/strings.xml | 2 +- .../main/res-localized/values-in/strings.xml | 2 +- .../main/res-localized/values-it/strings.xml | 2 +- .../main/res-localized/values-iw/strings.xml | 2 +- .../main/res-localized/values-ja/strings.xml | 2 +- .../main/res-localized/values-ko/strings.xml | 2 +- .../main/res-localized/values-nl/strings.xml | 2 +- .../main/res-localized/values-no/strings.xml | 2 +- .../main/res-localized/values-pl/strings.xml | 2 +- .../main/res-localized/values-pt/strings.xml | 2 +- .../main/res-localized/values-ru/strings.xml | 2 +- .../main/res-localized/values-th/strings.xml | 2 +- .../main/res-localized/values-tr/strings.xml | 2 +- .../main/res-localized/values-uk/strings.xml | 2 +- .../res-localized/values-zh-rCN/strings.xml | 2 +- .../main/res-localized/values-zh/strings.xml | 2 +- .../ic_action_inverse_selection.png | Bin 151 -> 0 bytes .../ic_action_inverse_selection.png | Bin 132 -> 0 bytes .../ic_action_inverse_selection.png | Bin 161 -> 0 bytes .../ic_action_inverse_selection.png | Bin 186 -> 0 bytes ...list.xml => fragment_content_listview.xml} | 17 +- ....xml => fragment_content_recyclerview.xml} | 2 +- .../res/menu/action_multi_select_items.xml | 9 +- twidere/src/main/res/values/strings.xml | 5 +- .../src/main/res/xml/preferences_cards.xml | 5 - 48 files changed, 451 insertions(+), 125 deletions(-) create mode 100644 twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentListViewFragment.java rename twidere/src/main/java/org/mariotaku/twidere/fragment/support/{AbsContentListFragment.java => AbsContentRecyclerViewFragment.java} (98%) delete mode 100644 twidere/src/main/res/drawable-hdpi/ic_action_inverse_selection.png delete mode 100644 twidere/src/main/res/drawable-mdpi/ic_action_inverse_selection.png delete mode 100644 twidere/src/main/res/drawable-xhdpi/ic_action_inverse_selection.png delete mode 100644 twidere/src/main/res/drawable-xxhdpi/ic_action_inverse_selection.png rename twidere/src/main/res/layout/{fragment_content_list.xml => fragment_content_listview.xml} (81%) rename twidere/src/main/res/layout/{fragment_recycler_view.xml => fragment_content_recyclerview.xml} (95%) diff --git a/twidere/src/main/AndroidManifest.xml b/twidere/src/main/AndroidManifest.xml index 54cbb7793..fe19f5c79 100644 --- a/twidere/src/main/AndroidManifest.xml +++ b/twidere/src/main/AndroidManifest.xml @@ -652,7 +652,7 @@ android:authorities="twidere" android:exported="true" android:grantUriPermissions="true" - android:label="@string/label_tweetstore_provider" + android:label="@string/label_data_provider" tools:ignore="ExportedContentProvider"/> , +public abstract class BaseFiltersFragment extends AbsContentListViewFragment implements LoaderManager.LoaderCallbacks, MultiChoiceModeListener { private static final String EXTRA_AUTO_COMPLETE_TYPE = "auto_complete_type"; @@ -91,8 +91,6 @@ public abstract class BaseFiltersFragment extends BaseSupportListFragment implem } }; - private ListView mListView; - private SimpleCursorAdapter mAdapter; private ContentResolver mResolver; private ActionMode mActionMode; @@ -103,26 +101,23 @@ public abstract class BaseFiltersFragment extends BaseSupportListFragment implem super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true); mResolver = getContentResolver(); - mAdapter = createListAdapter(); - setListAdapter(mAdapter); - mListView = getListView(); - mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - mListView.setMultiChoiceModeListener(this); - setEmptyText(getString(R.string.no_rule)); + final ListView listView = getListView(); + listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); + listView.setMultiChoiceModeListener(this); getLoaderManager().initLoader(0, null, this); - setListShown(false); + setRefreshEnabled(false); + showProgress(); } @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = super.onCreateView(inflater, container, savedInstanceState); assert view != null; - final View lv = view.findViewById(android.R.id.list); + final ListView listView = (ListView) view.findViewById(R.id.list_view); final Resources res = getResources(); final float density = res.getDisplayMetrics().density; final int padding = (int) density * 16; - lv.setId(android.R.id.list); - lv.setPadding(padding, 0, padding, 0); + listView.setPadding(padding, 0, padding, 0); return view; } @@ -162,16 +157,17 @@ public abstract class BaseFiltersFragment extends BaseSupportListFragment implem @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { + final ListView listView = getListView(); switch (item.getItemId()) { case MENU_DELETE: { - final Expression where = Expression.in(new Column(Filters._ID), new RawItemArray(mListView.getCheckedItemIds())); + final Expression where = Expression.in(new Column(Filters._ID), new RawItemArray(listView.getCheckedItemIds())); mResolver.delete(getContentUri(), where.getSQL(), null); break; } case MENU_INVERSE_SELECTION: { - final SparseBooleanArray positions = mListView.getCheckedItemPositions(); - for (int i = 0, j = mListView.getCount(); i < j; i++) { - mListView.setItemChecked(i, !positions.get(i)); + final SparseBooleanArray positions = listView.getCheckedItemPositions(); + for (int i = 0, j = listView.getCount(); i < j; i++) { + listView.setItemChecked(i, !positions.get(i)); } return true; } @@ -195,13 +191,19 @@ public abstract class BaseFiltersFragment extends BaseSupportListFragment implem @Override public void onLoadFinished(final Loader loader, final Cursor data) { - mAdapter.swapCursor(data); - setListShown(true); + final SimpleCursorAdapter adapter = getAdapter(); + adapter.swapCursor(data); + if (data != null && data.getCount() > 0) { + showContent(); + } else { + showError(R.drawable.ic_info_error_generic, getString(R.string.no_rule)); + } } @Override public void onLoaderReset(final Loader loader) { - mAdapter.swapCursor(null); + final SimpleCursorAdapter adapter = getAdapter(); + adapter.swapCursor(null); } @Override @@ -230,15 +232,23 @@ public abstract class BaseFiltersFragment extends BaseSupportListFragment implem updateTitle(mode); } - protected SimpleCursorAdapter createListAdapter() { - return new FilterListAdapter(getActivity()); + @Override + public boolean isRefreshing() { + return false; + } + + @NonNull + @Override + protected SimpleCursorAdapter onCreateAdapter(Context context, boolean compact) { + return new FilterListAdapter(context); } protected abstract String[] getContentColumns(); private void updateTitle(final ActionMode mode) { - if (mListView == null || mode == null || getActivity() == null) return; - final int count = mListView.getCheckedItemCount(); + final ListView listView = getListView(); + if (listView == null || mode == null || getActivity() == null) return; + final int count = listView.getCheckedItemCount(); mode.setTitle(getResources().getQuantityString(R.plurals.Nitems_selected, count, count)); } @@ -441,11 +451,6 @@ public abstract class BaseFiltersFragment extends BaseSupportListFragment implem return Filters.Users.CONTENT_URI; } - @Override - protected SimpleCursorAdapter createListAdapter() { - return new FilterUsersListAdapter(getActivity()); - } - @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -460,6 +465,11 @@ public abstract class BaseFiltersFragment extends BaseSupportListFragment implem return super.onOptionsItemSelected(item); } + @NonNull + @Override + protected SimpleCursorAdapter onCreateAdapter(Context context, boolean isCompact) { + return new FilterUsersListAdapter(getActivity()); + } } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsActivitiesFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsActivitiesFragment.java index 9c2c132b9..f87635a81 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsActivitiesFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsActivitiesFragment.java @@ -157,7 +157,7 @@ public abstract class AbsActivitiesFragment extends BaseSupportFragment im @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_recycler_view, container, false); + return inflater.inflate(R.layout.fragment_content_recyclerview, container, false); } @Override diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentListViewFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentListViewFragment.java new file mode 100644 index 000000000..ba3434857 --- /dev/null +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentListViewFragment.java @@ -0,0 +1,253 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.fragment.support; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Rect; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.FragmentActivity; +import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.TextView; + +import org.mariotaku.twidere.R; +import org.mariotaku.twidere.activity.iface.IControlBarActivity; +import org.mariotaku.twidere.activity.iface.IControlBarActivity.ControlBarOffsetListener; +import org.mariotaku.twidere.activity.support.BaseAppCompatActivity; +import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface; +import org.mariotaku.twidere.util.ContentListScrollListener.ContentListSupport; +import org.mariotaku.twidere.util.ThemeUtils; +import org.mariotaku.twidere.util.TwidereColorUtils; +import org.mariotaku.twidere.util.Utils; + +/** + * Created by mariotaku on 15/4/16. + */ +public abstract class AbsContentListViewFragment extends BaseSupportFragment + implements OnRefreshListener, RefreshScrollTopInterface, ControlBarOffsetListener, + ContentListSupport { + + private View mProgressContainer; + private SwipeRefreshLayout mSwipeRefreshLayout; + private ListView mListView; + private View mErrorContainer; + private ImageView mErrorIconView; + private TextView mErrorTextView; + + private A mAdapter; + + // Data fields + private Rect mSystemWindowsInsets = new Rect(); + + @Override + public void onControlBarOffsetChanged(IControlBarActivity activity, float offset) { + updateRefreshProgressOffset(); + } + + @Override + public void onRefresh() { + triggerRefresh(); + } + + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + updateRefreshProgressOffset(); + } + + @Override + public boolean scrollToStart() { + mListView.setSelectionFromTop(0, 0); +// mListView.stopScroll(); + setControlVisible(true); + return true; + } + + @Override + public void setControlVisible(boolean visible) { + final FragmentActivity activity = getActivity(); + if (activity instanceof BaseAppCompatActivity) { + ((BaseAppCompatActivity) activity).setControlBarVisibleAnimate(visible); + } + } + + @Override + public A getAdapter() { + return mAdapter; + } + + @Override + public abstract boolean isRefreshing(); + + public void setRefreshing(final boolean refreshing) { + final boolean currentRefreshing = mSwipeRefreshLayout.isRefreshing(); + if (!currentRefreshing) { + updateRefreshProgressOffset(); + } + if (refreshing == currentRefreshing) return; + mSwipeRefreshLayout.setRefreshing(refreshing); + } + + @Override + public void onLoadMoreContents() { + setRefreshEnabled(false); + } + + public final ListView getListView() { + return mListView; + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + if (activity instanceof IControlBarActivity) { + ((IControlBarActivity) activity).registerControlBarOffsetListener(this); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_content_listview, container, false); + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + final View view = getView(); + if (view == null) throw new AssertionError(); + final Context context = view.getContext(); + final boolean compact = Utils.isCompactCards(context); + final int backgroundColor = ThemeUtils.getThemeBackgroundColor(context); + final int colorRes = TwidereColorUtils.getContrastYIQ(backgroundColor, + R.color.bg_refresh_progress_color_light, R.color.bg_refresh_progress_color_dark); + mSwipeRefreshLayout.setOnRefreshListener(this); + mSwipeRefreshLayout.setColorSchemeColors(ThemeUtils.getUserAccentColor(context)); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(colorRes); + mAdapter = onCreateAdapter(context, compact); + mListView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { + updateRefreshProgressOffset(); + } + return false; + } + }); + mListView.setAdapter((ListAdapter) mAdapter); + + } + + @Override + public void onBaseViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onBaseViewCreated(view, savedInstanceState); + mProgressContainer = view.findViewById(R.id.progress_container); + mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_layout); + mListView = (ListView) view.findViewById(R.id.list_view); + mErrorContainer = view.findViewById(R.id.error_container); + mErrorIconView = (ImageView) view.findViewById(R.id.error_icon); + mErrorTextView = (TextView) view.findViewById(R.id.error_text); + } + + @Override + public void onDetach() { + final FragmentActivity activity = getActivity(); + if (activity instanceof IControlBarActivity) { + ((IControlBarActivity) activity).unregisterControlBarOffsetListener(this); + } + super.onDetach(); + } + + @Override + protected void fitSystemWindows(Rect insets) { + super.fitSystemWindows(insets); + mListView.setPadding(insets.left, insets.top, insets.right, insets.bottom); + mErrorContainer.setPadding(insets.left, insets.top, insets.right, insets.bottom); + mProgressContainer.setPadding(insets.left, insets.top, insets.right, insets.bottom); + mSystemWindowsInsets.set(insets); + updateRefreshProgressOffset(); + } + + public void setRefreshEnabled(boolean enabled) { + mSwipeRefreshLayout.setEnabled(enabled); + } + + @Override + public boolean triggerRefresh() { + return false; + } + + @NonNull + protected abstract A onCreateAdapter(Context context, boolean compact); + + protected final void showContent() { + mErrorContainer.setVisibility(View.GONE); + mProgressContainer.setVisibility(View.GONE); + mSwipeRefreshLayout.setVisibility(View.VISIBLE); + } + + protected final void showProgress() { + mErrorContainer.setVisibility(View.GONE); + mProgressContainer.setVisibility(View.VISIBLE); + mSwipeRefreshLayout.setVisibility(View.GONE); + } + + protected final void showError(int icon, CharSequence text) { + mErrorContainer.setVisibility(View.VISIBLE); + mProgressContainer.setVisibility(View.GONE); + mSwipeRefreshLayout.setVisibility(View.GONE); + mErrorIconView.setImageResource(icon); + mErrorTextView.setText(text); + } + + protected final void showEmpty(int icon, CharSequence text) { + mErrorContainer.setVisibility(View.VISIBLE); + mProgressContainer.setVisibility(View.GONE); + mSwipeRefreshLayout.setVisibility(View.VISIBLE); + mErrorIconView.setImageResource(icon); + mErrorTextView.setText(text); + } + + protected void updateRefreshProgressOffset() { + final FragmentActivity activity = getActivity(); + if (!(activity instanceof IControlBarActivity) || mSystemWindowsInsets.top == 0 || mSwipeRefreshLayout == null + || isRefreshing()) { + return; + } + final float density = getResources().getDisplayMetrics().density; + final int progressCircleDiameter = mSwipeRefreshLayout.getProgressCircleDiameter(); + final IControlBarActivity control = (IControlBarActivity) activity; + final int controlBarOffsetPixels = Math.round(control.getControlBarHeight() * (1 - control.getControlBarOffset())); + final int swipeStart = (mSystemWindowsInsets.top - controlBarOffsetPixels) - progressCircleDiameter; + // 64: SwipeRefreshLayout.DEFAULT_CIRCLE_TARGET + final int swipeDistance = Math.round(64 * density); + mSwipeRefreshLayout.setProgressViewOffset(false, swipeStart, swipeStart + swipeDistance); + } +} diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentRecyclerViewFragment.java similarity index 98% rename from twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentListFragment.java rename to twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentRecyclerViewFragment.java index 742ea1b63..e3112db34 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsContentRecyclerViewFragment.java @@ -57,7 +57,7 @@ import org.mariotaku.twidere.view.HeaderDrawerLayout.DrawerCallback; /** * Created by mariotaku on 15/4/16. */ -public abstract class AbsContentListFragment extends BaseSupportFragment +public abstract class AbsContentRecyclerViewFragment extends BaseSupportFragment implements OnRefreshListener, DrawerCallback, RefreshScrollTopInterface, ControlBarOffsetListener, ContentListSupport { @@ -187,7 +187,7 @@ public abstract class AbsContentListFragment exte @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_recycler_view, container, false); + return inflater.inflate(R.layout.fragment_content_recyclerview, container, false); } @Override diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsStatusesFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsStatusesFragment.java index 33fdb2dbd..6ea5e2f06 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsStatusesFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsStatusesFragment.java @@ -49,7 +49,7 @@ import static org.mariotaku.twidere.util.Utils.setMenuForStatus; /** * Created by mariotaku on 14/11/5. */ -public abstract class AbsStatusesFragment extends AbsContentListFragment> +public abstract class AbsStatusesFragment extends AbsContentRecyclerViewFragment> implements LoaderCallbacks, StatusAdapterListener, KeyboardShortcutCallback { private final Object mStatusesBusCallback; diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java index f1f1403fe..5c2cc10d3 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java @@ -42,7 +42,7 @@ import org.mariotaku.twidere.util.RecyclerViewNavigationHelper; import org.mariotaku.twidere.util.Utils; import org.mariotaku.twidere.view.holder.UserViewHolder; -abstract class AbsUsersFragment extends AbsContentListFragment> +abstract class AbsUsersFragment extends AbsContentRecyclerViewFragment> implements LoaderCallbacks, UserAdapterListener, KeyboardShortcutCallback { private RecyclerViewNavigationHelper mRecyclerViewNavigationHelper; diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/DirectMessagesFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/DirectMessagesFragment.java index 523a246cd..b9471b8a0 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/DirectMessagesFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/DirectMessagesFragment.java @@ -72,7 +72,7 @@ import java.util.Set; import static org.mariotaku.twidere.util.Utils.openMessageConversation; -public class DirectMessagesFragment extends AbsContentListFragment +public class DirectMessagesFragment extends AbsContentRecyclerViewFragment implements LoaderCallbacks, MessageEntriesAdapterListener, KeyboardShortcutCallback { // Listeners diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserMediaTimelineFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserMediaTimelineFragment.java index 691d3e3c5..f6daf22f3 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserMediaTimelineFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserMediaTimelineFragment.java @@ -131,7 +131,7 @@ public class UserMediaTimelineFragment extends BaseSupportFragment @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_recycler_view, container, false); + return inflater.inflate(R.layout.fragment_content_recyclerview, container, false); } @Override diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ContentListScrollListener.java b/twidere/src/main/java/org/mariotaku/twidere/util/ContentListScrollListener.java index cbc5abafd..f7b89a5db 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ContentListScrollListener.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ContentListScrollListener.java @@ -24,7 +24,7 @@ import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.OnScrollListener; -import org.mariotaku.twidere.adapter.iface.IContentCardAdapter; +import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter; /** * Created by mariotaku on 15/3/15. @@ -70,17 +70,20 @@ public class ContentListScrollListener extends OnScrollListener { } private void notifyScrollStateChanged(RecyclerView recyclerView) { - final IContentCardAdapter adapter = mContentListSupport.getAdapter(); + final Object adapter = mContentListSupport.getAdapter(); + if (!(adapter instanceof ILoadMoreSupportAdapter)) return; + final ILoadMoreSupportAdapter loadMoreAdapter = (ILoadMoreSupportAdapter) adapter; final LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); - if (!mContentListSupport.isRefreshing() && adapter.isLoadMoreSupported() && !adapter.isLoadMoreIndicatorVisible() - && layoutManager.findLastVisibleItemPosition() == adapter.getItemCount() - 1) { + if (!mContentListSupport.isRefreshing() && loadMoreAdapter.isLoadMoreSupported() + && !loadMoreAdapter.isLoadMoreIndicatorVisible() + && layoutManager.findLastVisibleItemPosition() == layoutManager.getItemCount() - 1) { mContentListSupport.onLoadMoreContents(); } } public static interface ContentListSupport { - IContentCardAdapter getAdapter(); + Object getAdapter(); boolean isRefreshing(); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java index 10f013cc1..5ee17075f 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java @@ -80,6 +80,8 @@ public class ThemeUtils implements Constants { android.R.attr.activityOpenExitAnimation}; private static final int[] ANIM_CLOSE_STYLE_ATTRS = {android.R.attr.activityCloseEnterAnimation, android.R.attr.activityCloseExitAnimation}; + public static final int[] ATTRS_TEXT_COLOR_PRIMARY = {android.R.attr.textColorPrimary}; + public static final int[] ATTRS_TEXT_COLOR_PRIMARY_INVERSE = {android.R.attr.textColorPrimaryInverse}; private ThemeUtils() { throw new AssertionError(); @@ -196,6 +198,8 @@ public class ThemeUtils implements Constants { boolean outlineEnabled) { // Very dirty implementation if (!(modeCompat instanceof ActionModeImpl)) return; + // This call ensures TitleView created + modeCompat.setTitle(null); try { WindowDecorActionBar actionBar = null; final Field[] fields = ActionModeImpl.class.getDeclaredFields(); @@ -212,7 +216,6 @@ public class ThemeUtils implements Constants { contextViewField.setAccessible(true); final View contextView = (View) contextViewField.get(actionBar); if (!(contextView instanceof ActionBarContextView)) return; - final ActionBarContextView actionBarContextView = (ActionBarContextView) contextView; final TextView actionBarTitleView = (TextView) contextView.findViewById(android.support.v7.appcompat.R.id.action_bar_title); final TextView actionBarSubtitleView = (TextView) contextView.findViewById(android.support.v7.appcompat.R.id.action_bar_subtitle); final ImageView actionModeCloseButton = (ImageView) contextView.findViewById(android.support.v7.appcompat.R.id.action_mode_close_button); @@ -398,19 +401,23 @@ public class ThemeUtils implements Constants { public static int getContrastActionBarItemColor(Context context, int theme, int color) { if (isDarkTheme(theme) || TwidereColorUtils.getYIQLuminance(color) < 192) { //return light text color - return Color.WHITE; + return context.getResources().getColor(R.color.action_icon_light); } //return dark text color - return Color.BLACK; + return context.getResources().getColor(R.color.action_icon_dark); } public static int getContrastActionBarTitleColor(Context context, int theme, int color) { - if (isDarkTheme(theme) || TwidereColorUtils.getYIQLuminance(color) < 192) { + if (isDarkTheme(theme)) { //return light text color - return Color.WHITE; + return getTextColorPrimary(context); + } else if (TwidereColorUtils.getYIQLuminance(color) < 192) { + //return light text color + return getTextColorPrimaryInverse(context); + } else { + //return dark text color + return getTextColorPrimary(context); } - //return dark text color - return Color.BLACK; } public static int getDialogThemeResource(final Context context) { @@ -528,7 +535,16 @@ public class ThemeUtils implements Constants { } public static int getTextColorPrimary(final Context context) { - final TypedArray a = context.obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary}); + final TypedArray a = context.obtainStyledAttributes(ATTRS_TEXT_COLOR_PRIMARY); + try { + return a.getColor(0, Color.TRANSPARENT); + } finally { + a.recycle(); + } + } + + public static int getTextColorPrimaryInverse(final Context context) { + final TypedArray a = context.obtainStyledAttributes(ATTRS_TEXT_COLOR_PRIMARY_INVERSE); try { return a.getColor(0, Color.TRANSPARENT); } finally { @@ -874,14 +890,15 @@ public class ThemeUtils implements Constants { } } - public static void setActionBarItemsColor(Window window, android.support.v7.app.ActionBar actionBar, int itemColor) { + public static void setActionBarColor(Window window, android.support.v7.app.ActionBar actionBar, + int titleColor, int itemColor) { final Drawable drawable = getActionBarHomeAsUpIndicator(actionBar); if (drawable != null) { drawable.setColorFilter(itemColor, Mode.SRC_ATOP); } actionBar.setHomeAsUpIndicator(drawable); - setActionBarTitleTextColor(window, itemColor); - setActionBarSubtitleTextColor(window, itemColor); + setActionBarTitleTextColor(window, titleColor); + setActionBarSubtitleTextColor(window, titleColor); } public static void setActionBarOverflowColor(Toolbar toolbar, int itemColor) { diff --git a/twidere/src/main/res-localized/values-ar/strings.xml b/twidere/src/main/res-localized/values-ar/strings.xml index 723eff1a7..15ad93535 100755 --- a/twidere/src/main/res-localized/values-ar/strings.xml +++ b/twidere/src/main/res-localized/values-ar/strings.xml @@ -41,7 +41,7 @@ اختيار حساب اسم المستخدم كلمة المرور - مزود قاعدة بيانات Twidere + مزود قاعدة بيانات Twidere تحديث الخدمة خدمة التشغيل في الخلفية فتح بالمستعرض diff --git a/twidere/src/main/res-localized/values-ca/strings.xml b/twidere/src/main/res-localized/values-ca/strings.xml index efccc4f3c..e131eab21 100755 --- a/twidere/src/main/res-localized/values-ca/strings.xml +++ b/twidere/src/main/res-localized/values-ca/strings.xml @@ -43,7 +43,7 @@ Tria un compte Nom d\'usuari Contrasenya - Proveïdor de la base de dades de Twidere + Proveïdor de la base de dades de Twidere Actualitza el servei Servei d\'execució en rerefons Obrir al navegador diff --git a/twidere/src/main/res-localized/values-cs/strings.xml b/twidere/src/main/res-localized/values-cs/strings.xml index fdd3a2317..300f83461 100755 --- a/twidere/src/main/res-localized/values-cs/strings.xml +++ b/twidere/src/main/res-localized/values-cs/strings.xml @@ -40,7 +40,7 @@ Vyberte účet Uživatelské jméno Heslo - Poskytovatel databáze pro twidere + Poskytovatel databáze pro twidere Obnovit službu Služba na pozadí Otevřít v prohlížeči diff --git a/twidere/src/main/res-localized/values-de/strings.xml b/twidere/src/main/res-localized/values-de/strings.xml index ca5a2fc53..3e18d1759 100755 --- a/twidere/src/main/res-localized/values-de/strings.xml +++ b/twidere/src/main/res-localized/values-de/strings.xml @@ -43,7 +43,7 @@ Account auswählen Benutzername Passwort - Twidere Datenbank Anbieter + Twidere Datenbank Anbieter Dienst aktualisieren Hintergrunddienste Im Browser öffnen diff --git a/twidere/src/main/res-localized/values-es/strings.xml b/twidere/src/main/res-localized/values-es/strings.xml index 847142fe7..2cf094aaa 100755 --- a/twidere/src/main/res-localized/values-es/strings.xml +++ b/twidere/src/main/res-localized/values-es/strings.xml @@ -43,7 +43,7 @@ Seleccione la cuenta Nombre de usuario Contraseña - Proveedor de base de datos de Twidere + Proveedor de base de datos de Twidere Recargar servicio Servicio en segundo plano Abrir en el navegador diff --git a/twidere/src/main/res-localized/values-fi/strings.xml b/twidere/src/main/res-localized/values-fi/strings.xml index 8fbcac67c..d8848064f 100755 --- a/twidere/src/main/res-localized/values-fi/strings.xml +++ b/twidere/src/main/res-localized/values-fi/strings.xml @@ -42,7 +42,7 @@ Valitse tili Käyttäjätunnus Salasana - Twideren tietokannan tarjoaja + Twideren tietokannan tarjoaja Päivitä palvelu Taustatoimintojen palvelu Avaa selaimessa diff --git a/twidere/src/main/res-localized/values-fr/strings.xml b/twidere/src/main/res-localized/values-fr/strings.xml index c30df439f..5a2bdb1a4 100755 --- a/twidere/src/main/res-localized/values-fr/strings.xml +++ b/twidere/src/main/res-localized/values-fr/strings.xml @@ -43,7 +43,7 @@ Sélectionner un compte Nom d\'utilisateur Mot de passe - Fournisseur de base de données de Twidere + Fournisseur de base de données de Twidere Refraîcher le service Service en arrière-plan Ouvrir dans un navigateur diff --git a/twidere/src/main/res-localized/values-hi/strings.xml b/twidere/src/main/res-localized/values-hi/strings.xml index 0e5e00c14..5e35ccd13 100755 --- a/twidere/src/main/res-localized/values-hi/strings.xml +++ b/twidere/src/main/res-localized/values-hi/strings.xml @@ -37,7 +37,7 @@ खाता चुने यूज़रनेम पासवर्ड - ट्विदेर डेटाबेस प्रदाता + ट्विदेर डेटाबेस प्रदाता ब्राउज़र में खोलें छुए अधिक लोड करने के लिए। मिटायें diff --git a/twidere/src/main/res-localized/values-hu/strings.xml b/twidere/src/main/res-localized/values-hu/strings.xml index 826d11c14..e2128c78a 100755 --- a/twidere/src/main/res-localized/values-hu/strings.xml +++ b/twidere/src/main/res-localized/values-hu/strings.xml @@ -43,7 +43,7 @@ Válasszon fiókot Felhasználónév Jelszó - Twidere adatbázis szolgáltató + Twidere adatbázis szolgáltató Frissítő szolgáltatás Háttér szolgáltatás Megnyitás böngészőben diff --git a/twidere/src/main/res-localized/values-in/strings.xml b/twidere/src/main/res-localized/values-in/strings.xml index 0cd636f57..69c912b59 100755 --- a/twidere/src/main/res-localized/values-in/strings.xml +++ b/twidere/src/main/res-localized/values-in/strings.xml @@ -43,7 +43,7 @@ Pilih akun Nama pengguna Kata Sandi - Penyedia database Twidere + Penyedia database Twidere Segarkan layanan Latar Belakang layanan operasi Buka di Browser diff --git a/twidere/src/main/res-localized/values-it/strings.xml b/twidere/src/main/res-localized/values-it/strings.xml index 975b78e81..b6cb020e1 100755 --- a/twidere/src/main/res-localized/values-it/strings.xml +++ b/twidere/src/main/res-localized/values-it/strings.xml @@ -43,7 +43,7 @@ Seleziona account Username Password - Provider database Twidere + Provider database Twidere Aggiorna servizio Background operation service Apri nel browser diff --git a/twidere/src/main/res-localized/values-iw/strings.xml b/twidere/src/main/res-localized/values-iw/strings.xml index 3c2ddf17c..82d8519ce 100755 --- a/twidere/src/main/res-localized/values-iw/strings.xml +++ b/twidere/src/main/res-localized/values-iw/strings.xml @@ -30,7 +30,7 @@ בחר חשבון שם משתמש סיסמה - ספק מסד הנתונים של Twidere + ספק מסד הנתונים של Twidere רענן שירות שירות פעולה ברקע פתח בדפדפן diff --git a/twidere/src/main/res-localized/values-ja/strings.xml b/twidere/src/main/res-localized/values-ja/strings.xml index 26dd9deea..049080774 100755 --- a/twidere/src/main/res-localized/values-ja/strings.xml +++ b/twidere/src/main/res-localized/values-ja/strings.xml @@ -43,7 +43,7 @@ アカウントを選択 ユーザー名かメールアドレス パスワード - Twidereのデータベースストレージ + Twidereのデータベースストレージ サービスをリフレッシュ バックグラウンド操作サービス ブラウザで開く diff --git a/twidere/src/main/res-localized/values-ko/strings.xml b/twidere/src/main/res-localized/values-ko/strings.xml index 72ccae725..05552791f 100755 --- a/twidere/src/main/res-localized/values-ko/strings.xml +++ b/twidere/src/main/res-localized/values-ko/strings.xml @@ -42,7 +42,7 @@ 계정 선택 사용자명 패스워드 - Twidere 데이터베이스 공급자 + Twidere 데이터베이스 공급자 서비스 새로고침 백그라운드 동작 서비스 브라우저에서 열기 diff --git a/twidere/src/main/res-localized/values-nl/strings.xml b/twidere/src/main/res-localized/values-nl/strings.xml index 6cc671576..7ea6f34ce 100755 --- a/twidere/src/main/res-localized/values-nl/strings.xml +++ b/twidere/src/main/res-localized/values-nl/strings.xml @@ -40,7 +40,7 @@ Selecteer account Gebruikersnaam Wachtwoord - Citeer + Citeer Vernieuw dienst Achtergrond activiteiten service. In browser openen diff --git a/twidere/src/main/res-localized/values-no/strings.xml b/twidere/src/main/res-localized/values-no/strings.xml index ae528eae8..62323572a 100755 --- a/twidere/src/main/res-localized/values-no/strings.xml +++ b/twidere/src/main/res-localized/values-no/strings.xml @@ -34,7 +34,7 @@ Velg konto Brukernavn Passord - Twidere database leverandør + Twidere database leverandør Oppdaterings service Åpne i nettleser Trykk for å laste inn mer diff --git a/twidere/src/main/res-localized/values-pl/strings.xml b/twidere/src/main/res-localized/values-pl/strings.xml index 8245adae4..bce731436 100755 --- a/twidere/src/main/res-localized/values-pl/strings.xml +++ b/twidere/src/main/res-localized/values-pl/strings.xml @@ -43,7 +43,7 @@ Wybierz konto Nazwa użytkownika Hasło - Dostawca bazy Twidere + Dostawca bazy Twidere Odświeżanie Usługa operacji w tle Otwórz w przeglądarce diff --git a/twidere/src/main/res-localized/values-pt/strings.xml b/twidere/src/main/res-localized/values-pt/strings.xml index 63a95ece4..0e0fb6b45 100755 --- a/twidere/src/main/res-localized/values-pt/strings.xml +++ b/twidere/src/main/res-localized/values-pt/strings.xml @@ -42,7 +42,7 @@ Selecione a conta Nome de Usuário Senha - Provedor de banco de dados do Twidere + Provedor de banco de dados do Twidere Atualizar serviço Serviço de operação em segundo plano Abrir no navegador diff --git a/twidere/src/main/res-localized/values-ru/strings.xml b/twidere/src/main/res-localized/values-ru/strings.xml index 6bec5884e..8f42a15bc 100755 --- a/twidere/src/main/res-localized/values-ru/strings.xml +++ b/twidere/src/main/res-localized/values-ru/strings.xml @@ -43,7 +43,7 @@ Выберите учетную запись Имя пользователя Пароль - Провайдер базы данных Twitter + Провайдер базы данных Twitter Обновить сервис Справочная служба Открыть в браузере diff --git a/twidere/src/main/res-localized/values-th/strings.xml b/twidere/src/main/res-localized/values-th/strings.xml index dc7f26f2d..96cecfa6b 100755 --- a/twidere/src/main/res-localized/values-th/strings.xml +++ b/twidere/src/main/res-localized/values-th/strings.xml @@ -40,7 +40,7 @@ เลือกบัญชี ชื่อผู้ใช้ รหัสผ่าน - ผู้ให้บริการญานข้อมูล Twidere + ผู้ให้บริการญานข้อมูล Twidere เรียกบริการอีกครั้ง เซอร์วิสที่ทำงานเบื้องหลัง เปิดในเบราเซอร์ diff --git a/twidere/src/main/res-localized/values-tr/strings.xml b/twidere/src/main/res-localized/values-tr/strings.xml index 8c41d5793..430ac9c41 100755 --- a/twidere/src/main/res-localized/values-tr/strings.xml +++ b/twidere/src/main/res-localized/values-tr/strings.xml @@ -43,7 +43,7 @@ Hesap seç Kullanıcı adı Şifre - Twidere veritabanı sağlayıcı + Twidere veritabanı sağlayıcı Servisi yenile Arkaplan çalışma servisi Tarayıcıda aç diff --git a/twidere/src/main/res-localized/values-uk/strings.xml b/twidere/src/main/res-localized/values-uk/strings.xml index b4c558235..b2c5438f5 100755 --- a/twidere/src/main/res-localized/values-uk/strings.xml +++ b/twidere/src/main/res-localized/values-uk/strings.xml @@ -40,7 +40,7 @@ Виберіть обліковий запис Ім\'я користувача Пароль - Постачальник бази даних Твіттера + Постачальник бази даних Твіттера Оновити послугу Послуга фонових операцій Відкрити у браузері diff --git a/twidere/src/main/res-localized/values-zh-rCN/strings.xml b/twidere/src/main/res-localized/values-zh-rCN/strings.xml index c184c40b7..d0883291c 100755 --- a/twidere/src/main/res-localized/values-zh-rCN/strings.xml +++ b/twidere/src/main/res-localized/values-zh-rCN/strings.xml @@ -43,7 +43,7 @@ 选择帐号 用户名 密码 - Twidere 数据库存储 + Twidere 数据库存储 刷新服务 后台操作服务 在浏览器中打开 diff --git a/twidere/src/main/res-localized/values-zh/strings.xml b/twidere/src/main/res-localized/values-zh/strings.xml index 407c92c32..37a863ecc 100755 --- a/twidere/src/main/res-localized/values-zh/strings.xml +++ b/twidere/src/main/res-localized/values-zh/strings.xml @@ -43,7 +43,7 @@ 選擇帳號 用戶名 密碼 - Twidere 資料庫存儲 + Twidere 資料庫存儲 刷新服務 後台操作服務 在瀏覽器中打開 diff --git a/twidere/src/main/res/drawable-hdpi/ic_action_inverse_selection.png b/twidere/src/main/res/drawable-hdpi/ic_action_inverse_selection.png deleted file mode 100644 index a852d34b132b110178b7d6d590672e20d18f322b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DI8PVHkch)?r)}h9P!wR{6?tv6 zz2p6HqnzXO&b_JF;r-81VD8O=CPqO+7KVoX9utqRS+%xL_db(vTV(ic+1nff3L9b- zyv)3_CMQ46UH|fx@}pTo3I#3+UypM$JUGkpk4U-kvUwAs)w*6C_v<^Z%Lt_k9D) z)B{Og8cCae@OJ#IXXAX~)y|qxV!9c+E;EXc~ z8rp3|6IS*yy?7b0VutY09FN<=fxxY|uUT - + + - + android:listSelector="?selectableItemBackground" /> - - \ No newline at end of file diff --git a/twidere/src/main/res/layout/fragment_recycler_view.xml b/twidere/src/main/res/layout/fragment_content_recyclerview.xml similarity index 95% rename from twidere/src/main/res/layout/fragment_recycler_view.xml rename to twidere/src/main/res/layout/fragment_content_recyclerview.xml index 4fbd7d1c4..4dcb38fdb 100644 --- a/twidere/src/main/res/layout/fragment_recycler_view.xml +++ b/twidere/src/main/res/layout/fragment_content_recyclerview.xml @@ -1,7 +1,7 @@