mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-13 02:00:39 +01:00
improved account selection
This commit is contained in:
parent
8c6802a9b2
commit
582a9e221f
@ -108,6 +108,7 @@ public interface Constants extends TwidereConstants {
|
||||
public static final int MENU_PROGRESS = R.id.progress;
|
||||
public static final int MENU_OPEN_WITH_ACCOUNT = R.id.open_with_account;
|
||||
public static final int MENU_ACCOUNTS = R.id.accounts;
|
||||
public static final int MENU_INVERSE_SELECTION = R.id.inverse_selection;
|
||||
|
||||
public static final int LINK_ID_STATUS = 1;
|
||||
public static final int LINK_ID_USER = 2;
|
||||
|
@ -5,6 +5,7 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -22,13 +23,16 @@ import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
||||
public abstract class MenuDialogFragment extends BaseSupportDialogFragment implements OnItemClickListener {
|
||||
|
||||
private MenuAdapter mAdapter;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
final Context context = getThemedContext();
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
final MenuAdapter adapter = new MenuAdapter(context);
|
||||
mAdapter = new MenuAdapter(context);
|
||||
final ListView listView = new ListView(context);
|
||||
listView.setAdapter(adapter);
|
||||
listView.setAdapter(mAdapter);
|
||||
listView.setOnItemClickListener(this);
|
||||
builder.setView(listView);
|
||||
final Menu menu = MenuUtils.createMenu(context);
|
||||
@ -36,7 +40,7 @@ public abstract class MenuDialogFragment extends BaseSupportDialogFragment imple
|
||||
final int itemColor = ThemeUtils.getThemeForegroundColor(context);
|
||||
final int highlightColor = ThemeUtils.getUserAccentColor(context);
|
||||
ThemeUtils.applyColorFilterToMenuIcon(menu, itemColor, highlightColor, Mode.SRC_ATOP);
|
||||
adapter.setMenu(menu);
|
||||
mAdapter.setMenu(menu);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@ -49,7 +53,7 @@ public abstract class MenuDialogFragment extends BaseSupportDialogFragment imple
|
||||
final Fragment parentFragment = getParentFragment();
|
||||
final MenuItem item = (MenuItem) parent.getItemAtPosition(position);
|
||||
if (item.hasSubMenu()) {
|
||||
|
||||
mAdapter.setMenu(item.getSubMenu());
|
||||
} else if (parentFragment instanceof OnMenuItemClickListener) {
|
||||
((OnMenuItemClickListener) parentFragment).onMenuItemClick(item);
|
||||
dismiss();
|
||||
|
@ -30,12 +30,13 @@ import com.mobeta.android.dslv.SimpleDragSortCursorAdapter;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.iface.IBaseAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Accounts;
|
||||
import org.mariotaku.twidere.util.ImageLoaderWrapper;
|
||||
import org.mariotaku.twidere.view.holder.AccountViewHolder;
|
||||
|
||||
public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Constants {
|
||||
public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Constants, IBaseAdapter {
|
||||
|
||||
private final ImageLoaderWrapper mImageLoader;
|
||||
private final SharedPreferences mPreferences;
|
||||
@ -94,23 +95,94 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageLoaderWrapper getImageLoader() {
|
||||
return mImageLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLinkHighlightColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLinkHighlightOption() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplayNameFirst() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplayProfileImage() {
|
||||
return mDisplayProfileImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNicknameOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowAccountColor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDataSetChanged() {
|
||||
mDefaultAccountId = mPreferences.getLong(KEY_DEFAULT_ACCOUNT_ID, -1);
|
||||
super.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayNameFirst(boolean nameFirst) {
|
||||
|
||||
}
|
||||
|
||||
public void setChoiceMode(final int mode) {
|
||||
if (mChoiceMode == mode) return;
|
||||
mChoiceMode = mode;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayProfileImage(final boolean display) {
|
||||
mDisplayProfileImage = display;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLinkHighlightColor(int color) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLinkHighlightOption(String option) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNicknameOnly(boolean nicknameOnly) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowAccountColor(boolean show) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(float textSize) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor swapCursor(final Cursor cursor) {
|
||||
if (cursor != null) {
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package org.mariotaku.twidere.adapter;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getLinkHighlightOptionInt;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
@ -33,6 +31,8 @@ import org.mariotaku.twidere.util.TwidereLinkify;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getLinkHighlightOptionInt;
|
||||
|
||||
public class BaseArrayAdapter<T> extends ArrayAdapter<T> implements IBaseAdapter, OnSharedPreferenceChangeListener {
|
||||
|
||||
private final TwidereLinkify mLinkify;
|
||||
@ -105,9 +105,12 @@ public class BaseArrayAdapter<T> extends ArrayAdapter<T> implements IBaseAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) {
|
||||
public void onSharedPreferenceChanged(final SharedPreferences preferences, final String key) {
|
||||
if (KEY_NICKNAME_ONLY.equals(key) || KEY_DISPLAY_PROFILE_IMAGE.equals(key)
|
||||
|| KEY_DISPLAY_IMAGE_PREVIEW.equals(key) || KEY_DISPLAY_SENSITIVE_CONTENTS.equals(key)) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setDisplayNameFirst(final boolean nameFirst) {
|
||||
@ -134,8 +137,8 @@ public class BaseArrayAdapter<T> extends ArrayAdapter<T> implements IBaseAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setNicknameOnly(final boolean nickname_only) {
|
||||
mNicknameOnly = nickname_only;
|
||||
public final void setNicknameOnly(final boolean nicknameOnly) {
|
||||
mNicknameOnly = nicknameOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,9 +144,9 @@ public class BaseCursorAdapter extends SimpleCursorAdapter implements IBaseAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setNicknameOnly(final boolean nickname_only) {
|
||||
if (mNicknameOnly == nickname_only) return;
|
||||
mNicknameOnly = nickname_only;
|
||||
public final void setNicknameOnly(final boolean nicknameOnly) {
|
||||
if (mNicknameOnly == nicknameOnly) return;
|
||||
mNicknameOnly = nicknameOnly;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -158,9 +158,9 @@ public class BaseCursorAdapter extends SimpleCursorAdapter implements IBaseAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setTextSize(final float text_size) {
|
||||
if (text_size == mTextSize) return;
|
||||
mTextSize = text_size;
|
||||
public final void setTextSize(final float textSize) {
|
||||
if (textSize == mTextSize) return;
|
||||
mTextSize = textSize;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,9 @@ public interface IBaseAdapter extends Constants, ListAdapter {
|
||||
|
||||
public void setLinkHighlightOption(String option);
|
||||
|
||||
public void setNicknameOnly(boolean nickname_only);
|
||||
public void setNicknameOnly(boolean nicknameOnly);
|
||||
|
||||
public void setShowAccountColor(boolean show);
|
||||
|
||||
public void setTextSize(float text_size);
|
||||
public void setTextSize(float textSize);
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package org.mariotaku.twidere.fragment;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getDisplayName;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@ -34,6 +32,7 @@ import android.os.Bundle;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.ActionMode;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
@ -52,6 +51,8 @@ import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.fragment.support.BaseSupportListFragment;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Filters;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getDisplayName;
|
||||
|
||||
public abstract class BaseFiltersFragment extends BaseSupportListFragment implements LoaderManager.LoaderCallbacks<Cursor>,
|
||||
MultiChoiceModeListener {
|
||||
|
||||
@ -86,6 +87,13 @@ public abstract class BaseFiltersFragment extends BaseSupportListFragment implem
|
||||
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));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
@ -14,16 +15,20 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.mobeta.android.dslv.DragSortListView;
|
||||
import com.mobeta.android.dslv.DragSortListView.DropListener;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.support.SignInActivity;
|
||||
import org.mariotaku.twidere.adapter.AccountsAdapter;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Accounts;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14/10/26.
|
||||
*/
|
||||
public class AccountsManagerFragment extends BaseSupportListFragment implements LoaderCallbacks<Cursor> {
|
||||
public class AccountsManagerFragment extends BaseSupportListFragment implements LoaderCallbacks<Cursor>, DropListener {
|
||||
|
||||
private AccountsAdapter mAdapter;
|
||||
|
||||
@ -49,8 +54,12 @@ public class AccountsManagerFragment extends BaseSupportListFragment implements
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
mAdapter = new AccountsAdapter(getActivity());
|
||||
final FragmentActivity activity = getActivity();
|
||||
mAdapter = new AccountsAdapter(activity);
|
||||
Utils.configBaseAdapter(activity, mAdapter);
|
||||
setListAdapter(mAdapter);
|
||||
final DragSortListView listView = (DragSortListView) getListView();
|
||||
listView.setDropListener(this);
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
@ -79,4 +88,10 @@ public class AccountsManagerFragment extends BaseSupportListFragment implements
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
mAdapter.changeCursor(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drop(int from, int to) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ public class UserListMenuDialogFragment extends MenuDialogFragment {
|
||||
extensionsExtras.putParcelable(EXTRA_USER_LIST, user);
|
||||
extensionsIntent.putExtras(extensionsExtras);
|
||||
addIntentToMenu(getThemedContext(), menu, extensionsIntent);
|
||||
final boolean longclickToOpenMenu = prefs.getBoolean(KEY_LONG_CLICK_TO_OPEN_MENU, false);
|
||||
Utils.setMenuItemAvailability(menu, MENU_MULTI_SELECT, longclickToOpenMenu);
|
||||
final boolean longClickToOpenMenu = prefs.getBoolean(KEY_LONG_CLICK_TO_OPEN_MENU, false);
|
||||
Utils.setMenuItemAvailability(menu, MENU_MULTI_SELECT, longClickToOpenMenu);
|
||||
}
|
||||
|
||||
protected void onPrepareItemMenu(final Menu menu, final ParcelableUserList userList) {
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 173 B |
Binary file not shown.
After Width: | Height: | Size: 149 B |
Binary file not shown.
After Width: | Height: | Size: 190 B |
Binary file not shown.
After Width: | Height: | Size: 243 B |
@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<org.mariotaku.twidere.view.MainFrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.FiltersActivity">
|
||||
|
||||
<org.mariotaku.twidere.view.ExtendedViewPager
|
||||
@ -8,4 +11,4 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</merge>
|
||||
</org.mariotaku.twidere.view.MainFrameLayout>
|
@ -31,10 +31,9 @@
|
||||
android:id="@+id/drag_handle"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_weight="0"
|
||||
android:background="@drawable/list_drag_handle"/>
|
||||
|
||||
<ImageView
|
||||
@ -56,13 +55,28 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/default_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/default_account"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/text2"
|
||||
android:layout_width="match_parent"
|
||||
@ -80,16 +94,4 @@
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/default_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@android:id/icon"
|
||||
android:layout_alignLeft="@android:id/icon"
|
||||
android:background="#80000000"
|
||||
android:singleLine="true"
|
||||
android:text="@string/default_account"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
</org.mariotaku.twidere.view.ColorLabelRelativeLayout>
|
@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@id/inverse_selection"
|
||||
android:icon="@drawable/ic_action_inverse_selection"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
android:title="@string/inverse_selection"/>
|
||||
<item
|
||||
android:id="@id/delete"
|
||||
android:icon="@drawable/ic_action_delete"
|
||||
|
@ -68,12 +68,10 @@
|
||||
<item>iAtYJ4HpUVfIUoNnif1DA;172fOpzuZoYzNYaU3mMYvE8m8MEyLbztOdbrUolU</item>
|
||||
</string-array>
|
||||
<string-array name="entries_theme">
|
||||
<item>@string/theme_twidere</item>
|
||||
<item>@string/theme_light</item>
|
||||
<item>@string/theme_dark</item>
|
||||
</string-array>
|
||||
<string-array name="values_theme">
|
||||
<item>twidere</item>
|
||||
<item>light</item>
|
||||
<item>dark</item>
|
||||
</string-array>
|
||||
|
@ -75,4 +75,5 @@
|
||||
<item name="progress" type="id"/>
|
||||
<item name="open_with_account" type="id"/>
|
||||
<item name="accounts" type="id"/>
|
||||
<item name="inverse_selection" type="id"/>
|
||||
</resources>
|
@ -646,5 +646,6 @@
|
||||
<string name="exclude_this_host">Exclude this host</string>
|
||||
<string name="api_url_format_help">[DOMAIN]: Twitter API domain.\nExample: https://[DOMAIN].twitter.com/ will be replaced to https://api.twitter.com/.</string>
|
||||
<string name="no_version_suffix">No version suffix</string>
|
||||
<string name="inverse_selection">Inverse selection</string>
|
||||
|
||||
</resources>
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/theme">
|
||||
|
||||
@ -10,21 +11,19 @@
|
||||
<org.mariotaku.twidere.preference.ThemePreviewPreference android:key="theme_preview"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<org.mariotaku.twidere.preference.AutoInvalidateListPreference
|
||||
<org.mariotaku.twidere.preference.SummaryListPreference
|
||||
android:defaultValue="twidere"
|
||||
android:entries="@array/entries_theme"
|
||||
android:entryValues="@array/values_theme"
|
||||
android:key="theme"
|
||||
android:order="21"
|
||||
android:summary="%s"
|
||||
android:title="@string/theme"/>
|
||||
<org.mariotaku.twidere.preference.AutoInvalidateListPreference
|
||||
<org.mariotaku.twidere.preference.SummaryListPreference
|
||||
android:defaultValue="default"
|
||||
android:entries="@array/entries_theme_background"
|
||||
android:entryValues="@array/values_theme_background"
|
||||
android:key="theme_background"
|
||||
android:order="22"
|
||||
android:summary="%s"
|
||||
android:title="@string/theme_background"/>
|
||||
|
||||
<org.mariotaku.twidere.preference.ValueDependencySeekBarDialogPreference
|
||||
@ -38,15 +37,6 @@
|
||||
app:max="255"
|
||||
app:min="0"/>
|
||||
|
||||
<org.mariotaku.twidere.preference.ValueDependencyCheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="theme_dark_actionbar"
|
||||
android:order="24"
|
||||
android:title="@string/theme_dark_actionbar"
|
||||
app:dependencyKey="theme"
|
||||
app:dependencyValueDefault="twidere"
|
||||
app:dependencyValues="@array/dependency_values_actionbar_theme"/>
|
||||
|
||||
<org.mariotaku.twidere.preference.ColorPickerPreference
|
||||
android:defaultValue="@android:color/holo_blue_light"
|
||||
android:key="theme_color"
|
||||
|
Loading…
x
Reference in New Issue
Block a user