kotlin migration
This commit is contained in:
parent
860ae89454
commit
bd0ea16b97
|
@ -58,7 +58,7 @@ subprojects {
|
|||
MultiValueSwitch : '0.9.8',
|
||||
PickNCrop : '0.9.25',
|
||||
AndroidGIFDrawable : '1.2.6',
|
||||
KPreferences : '0.9.6',
|
||||
KPreferences : '0.9.7',
|
||||
Kovenant : '3.3.0',
|
||||
ParcelablePlease : '1.0.2',
|
||||
Chameleon : '0.9.17',
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.annotation;
|
||||
|
||||
import android.support.annotation.IntDef;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/4/17.
|
||||
*/
|
||||
@IntDef(value = {TabAccountFlags.FLAG_HAS_ACCOUNT, TabAccountFlags.FLAG_ACCOUNT_REQUIRED,
|
||||
TabAccountFlags.FLAG_ACCOUNT_MULTIPLE, TabAccountFlags.FLAG_ACCOUNT_MUTABLE}, flag = true)
|
||||
public @interface TabAccountFlags {
|
||||
|
||||
int FLAG_HAS_ACCOUNT = 1;
|
||||
int FLAG_ACCOUNT_REQUIRED = 2;
|
||||
int FLAG_ACCOUNT_MULTIPLE = 4;
|
||||
int FLAG_ACCOUNT_MUTABLE = 8;
|
||||
}
|
|
@ -4,6 +4,7 @@ import android.accounts.AccountManager;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -41,7 +42,6 @@ import org.mariotaku.twidere.model.account.cred.OAuthCredentials;
|
|||
import org.mariotaku.twidere.model.util.AccountUtils;
|
||||
import org.mariotaku.twidere.util.DataStoreUtils;
|
||||
import org.mariotaku.twidere.util.MicroBlogAPIFactory;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.dagger.DependencyHolder;
|
||||
import org.mariotaku.twidere.util.net.TwidereDns;
|
||||
|
@ -151,10 +151,10 @@ public class NetworkDiagnosticsFragment extends BaseFragment {
|
|||
publishProgress(LogText.LINEBREAK, LogText.LINEBREAK);
|
||||
DependencyHolder holder = DependencyHolder.Companion.get(mContext);
|
||||
final Dns dns = holder.getDns();
|
||||
final SharedPreferencesWrapper prefs = holder.getPreferences();
|
||||
final SharedPreferences prefs = holder.getPreferences();
|
||||
publishProgress(new LogText("Network preferences"), LogText.LINEBREAK);
|
||||
publishProgress(new LogText("using_resolver: " + prefs.getBoolean(KEY_BUILTIN_DNS_RESOLVER)), LogText.LINEBREAK);
|
||||
publishProgress(new LogText("tcp_dns_query: " + prefs.getBoolean(KEY_TCP_DNS_QUERY)), LogText.LINEBREAK);
|
||||
publishProgress(new LogText("using_resolver: " + prefs.getBoolean(KEY_BUILTIN_DNS_RESOLVER, false)), LogText.LINEBREAK);
|
||||
publishProgress(new LogText("tcp_dns_query: " + prefs.getBoolean(KEY_TCP_DNS_QUERY, false)), LogText.LINEBREAK);
|
||||
publishProgress(new LogText("dns_server: " + prefs.getString(KEY_DNS_SERVER, null)), LogText.LINEBREAK);
|
||||
publishProgress(LogText.LINEBREAK);
|
||||
publishProgress(new LogText("System DNS servers"), LogText.LINEBREAK);
|
||||
|
|
|
@ -4,19 +4,22 @@ import android.content.Context;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.BoolRes;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/28.
|
||||
*/
|
||||
|
||||
public abstract class BooleanHolder implements Parcelable {
|
||||
public abstract class BooleanHolder {
|
||||
|
||||
public abstract boolean createBoolean(Context context);
|
||||
|
||||
@NonNull
|
||||
public static BooleanHolder resource(@BoolRes int resourceId) {
|
||||
return new Resource(resourceId);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static BooleanHolder constant(boolean value) {
|
||||
return new Constant(value);
|
||||
}
|
||||
|
|
|
@ -7,21 +7,20 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.mariotaku.kpreferences.SharedPreferencesExtensionsKt;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.constant.PreferenceKeysKt;
|
||||
import org.mariotaku.twidere.util.dagger.DependencyHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_I_WANT_MY_STARS_BACK;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public abstract class DrawableHolder {
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
@Nullable
|
||||
|
@ -148,23 +147,41 @@ public abstract class DrawableHolder {
|
|||
}
|
||||
|
||||
public static class Builtin extends DrawableHolder {
|
||||
@NonNull
|
||||
public static final DrawableHolder HOME = new Builtin("home", R.drawable.ic_action_home);
|
||||
@NonNull
|
||||
public static final DrawableHolder HEART = new Builtin("heart", R.drawable.ic_action_heart);
|
||||
@NonNull
|
||||
public static final DrawableHolder HASHTAG = new Builtin("hashtag", R.drawable.ic_action_hashtag);
|
||||
@NonNull
|
||||
public static final DrawableHolder ACCOUNTS = new Builtin("accounts", R.drawable.ic_action_accounts);
|
||||
@NonNull
|
||||
public static final DrawableHolder LIST = new Builtin("list", R.drawable.ic_action_list);
|
||||
@NonNull
|
||||
public static final DrawableHolder MENTION = new Builtin("mention", R.drawable.ic_action_at);
|
||||
@NonNull
|
||||
public static final DrawableHolder NOTIFICATIONS = new Builtin("notifications", R.drawable.ic_action_notification);
|
||||
@NonNull
|
||||
public static final DrawableHolder GALLERY = new Builtin("gallery", R.drawable.ic_action_gallery);
|
||||
@NonNull
|
||||
public static final DrawableHolder MESSAGE = new Builtin("message", R.drawable.ic_action_message);
|
||||
@NonNull
|
||||
public static final DrawableHolder QUOTE = new Builtin("quote", R.drawable.ic_action_quote);
|
||||
@NonNull
|
||||
public static final DrawableHolder SEARCH = new Builtin("search", R.drawable.ic_action_search);
|
||||
@NonNull
|
||||
public static final DrawableHolder STAGGERED = new Builtin("staggered", R.drawable.ic_action_view_quilt);
|
||||
@NonNull
|
||||
public static final DrawableHolder STAR = new Builtin("star", R.drawable.ic_action_star);
|
||||
@NonNull
|
||||
public static final DrawableHolder TRENDS = new Builtin("trends", R.drawable.ic_action_trends);
|
||||
@NonNull
|
||||
public static final DrawableHolder TWIDERE = new Builtin("twidere", R.drawable.ic_action_twidere);
|
||||
@NonNull
|
||||
public static final DrawableHolder TWITTER = new Builtin("twitter", R.drawable.ic_action_twitter);
|
||||
@NonNull
|
||||
public static final DrawableHolder USER = new Builtin("user", R.drawable.ic_action_user);
|
||||
@NonNull
|
||||
public static final DrawableHolder FAVORITE = new DrawableHolder() {
|
||||
@NonNull
|
||||
@Override
|
||||
|
@ -181,7 +198,8 @@ public abstract class DrawableHolder {
|
|||
@NonNull
|
||||
@Override
|
||||
public Drawable createDrawable(Context context) {
|
||||
if (DependencyHolder.Companion.get(context).preferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
|
||||
final DependencyHolder holder = DependencyHolder.Companion.get(context);
|
||||
if (SharedPreferencesExtensionsKt.get(holder.preferences, PreferenceKeysKt.getIWantMyStarsBackKey())) {
|
||||
return ContextCompat.getDrawable(context, R.drawable.ic_action_star);
|
||||
}
|
||||
return ContextCompat.getDrawable(context, R.drawable.ic_action_heart);
|
||||
|
|
|
@ -3,16 +3,18 @@ package org.mariotaku.twidere.model.tab;
|
|||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/28.
|
||||
*/
|
||||
|
||||
public abstract class StringHolder implements Parcelable {
|
||||
public abstract class StringHolder {
|
||||
|
||||
public abstract String createString(Context context);
|
||||
|
||||
@NonNull
|
||||
public static StringHolder resource(@StringRes int resourceId) {
|
||||
return new Resource(resourceId);
|
||||
}
|
||||
|
|
|
@ -1,264 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.mariotaku.twidere.annotation.CustomTabType;
|
||||
import org.mariotaku.twidere.fragment.CustomTabsFragment.TabEditorDialogFragment;
|
||||
import org.mariotaku.twidere.model.AccountDetails;
|
||||
import org.mariotaku.twidere.model.Tab;
|
||||
import org.mariotaku.twidere.model.tab.impl.FavoriteTimelineTabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.impl.HomeTabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.impl.InteractionsTabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.impl.MessagesTabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.impl.PublicTimelineTabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.impl.SearchTabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.impl.TrendsTabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.impl.UserListTimelineTabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.impl.UserTimelineTabConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import kotlin.Pair;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public abstract class TabConfiguration {
|
||||
|
||||
public static final int FLAG_HAS_ACCOUNT = 0b0001;
|
||||
public static final int FLAG_ACCOUNT_REQUIRED = 0b0010;
|
||||
public static final int FLAG_ACCOUNT_MULTIPLE = 0b0100;
|
||||
public static final int FLAG_ACCOUNT_MUTABLE = 0b1000;
|
||||
|
||||
@NonNull
|
||||
public abstract StringHolder getName();
|
||||
|
||||
@NonNull
|
||||
public abstract DrawableHolder getIcon();
|
||||
|
||||
@AccountFlags
|
||||
public abstract int getAccountFlags();
|
||||
|
||||
@NonNull
|
||||
public abstract Class<? extends Fragment> getFragmentClass();
|
||||
|
||||
public boolean isSingleTab() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getSortPosition() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ExtraConfiguration[] getExtraConfigurations(Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean applyExtraConfigurationTo(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean readExtraConfigurationFrom(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkAccountAvailability(@NonNull AccountDetails details) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static List<Pair<String, TabConfiguration>> all() {
|
||||
List<Pair<String, TabConfiguration>> all = new ArrayList<>();
|
||||
for (String type : allTypes()) {
|
||||
all.add(new Pair<>(type, ofType(type)));
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String[] allTypes() {
|
||||
return new String[]{
|
||||
CustomTabType.HOME_TIMELINE,
|
||||
CustomTabType.NOTIFICATIONS_TIMELINE,
|
||||
CustomTabType.TRENDS_SUGGESTIONS,
|
||||
CustomTabType.DIRECT_MESSAGES,
|
||||
CustomTabType.FAVORITES,
|
||||
CustomTabType.USER_TIMELINE,
|
||||
CustomTabType.SEARCH_STATUSES,
|
||||
CustomTabType.LIST_TIMELINE,
|
||||
CustomTabType.PUBLIC_TIMELINE,
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static TabConfiguration ofType(@CustomTabType String type) {
|
||||
switch (type) {
|
||||
case CustomTabType.HOME_TIMELINE:
|
||||
return new HomeTabConfiguration();
|
||||
case CustomTabType.NOTIFICATIONS_TIMELINE:
|
||||
return new InteractionsTabConfiguration();
|
||||
case CustomTabType.DIRECT_MESSAGES:
|
||||
return new MessagesTabConfiguration();
|
||||
case CustomTabType.LIST_TIMELINE:
|
||||
return new UserListTimelineTabConfiguration();
|
||||
case CustomTabType.FAVORITES:
|
||||
return new FavoriteTimelineTabConfiguration();
|
||||
case CustomTabType.USER_TIMELINE:
|
||||
return new UserTimelineTabConfiguration();
|
||||
case CustomTabType.TRENDS_SUGGESTIONS:
|
||||
return new TrendsTabConfiguration();
|
||||
case CustomTabType.SEARCH_STATUSES:
|
||||
return new SearchTabConfiguration();
|
||||
case CustomTabType.PUBLIC_TIMELINE:
|
||||
return new PublicTimelineTabConfiguration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@IntDef(value = {FLAG_HAS_ACCOUNT, FLAG_ACCOUNT_REQUIRED, FLAG_ACCOUNT_MULTIPLE,
|
||||
FLAG_ACCOUNT_MUTABLE}, flag = true)
|
||||
protected @interface AccountFlags {
|
||||
|
||||
}
|
||||
|
||||
public static abstract class ExtraConfiguration {
|
||||
private final String key;
|
||||
private StringHolder title;
|
||||
@Nullable
|
||||
private StringHolder summary;
|
||||
@Nullable
|
||||
private StringHolder headerTitle;
|
||||
private int position;
|
||||
private boolean mutable;
|
||||
|
||||
private Context context;
|
||||
private View view;
|
||||
|
||||
protected ExtraConfiguration(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public StringHolder getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(StringHolder title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public StringHolder getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
public void setSummary(@Nullable StringHolder summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public ExtraConfiguration title(StringHolder title) {
|
||||
setTitle(title);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExtraConfiguration summary(StringHolder summary) {
|
||||
setSummary(summary);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExtraConfiguration title(@StringRes int titleRes) {
|
||||
setTitle(StringHolder.resource(titleRes));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExtraConfiguration summary(@StringRes int summaryRes) {
|
||||
setSummary(StringHolder.resource(summaryRes));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public StringHolder getHeaderTitle() {
|
||||
return headerTitle;
|
||||
}
|
||||
|
||||
public void setHeaderTitle(@Nullable StringHolder headerTitle) {
|
||||
this.headerTitle = headerTitle;
|
||||
}
|
||||
|
||||
public ExtraConfiguration headerTitle(@Nullable StringHolder title) {
|
||||
setHeaderTitle(title);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExtraConfiguration headerTitle(@StringRes int titleRes) {
|
||||
setHeaderTitle(StringHolder.resource(titleRes));
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return mutable;
|
||||
}
|
||||
|
||||
public void setMutable(boolean mutable) {
|
||||
this.mutable = mutable;
|
||||
}
|
||||
|
||||
public ExtraConfiguration mutable(boolean mutable) {
|
||||
setMutable(mutable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract View onCreateView(Context context, ViewGroup parent);
|
||||
|
||||
@CallSuper
|
||||
public void onCreate(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public final Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
public void onViewCreated(@NonNull Context context, @NonNull View view, @NonNull TabEditorDialogFragment fragment) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public void onActivityResult(@NonNull final TabEditorDialogFragment fragment, int requestCode, int resultCode, @Nullable Intent data) {
|
||||
|
||||
}
|
||||
|
||||
public void onAccountSelectionChanged(@Nullable AccountDetails account) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.fragment.UserFavoritesFragment;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.Tab;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.argument.UserArguments;
|
||||
import org.mariotaku.twidere.model.tab.conf.UserExtraConfiguration;
|
||||
import org.mariotaku.twidere.util.dagger.DependencyHolder;
|
||||
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_I_WANT_MY_STARS_BACK;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class FavoriteTimelineTabConfiguration extends TabConfiguration {
|
||||
final static StringHolder TAB_NAME = new StringHolder() {
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createString(Context context) {
|
||||
if (DependencyHolder.Companion.get(context).preferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
|
||||
return context.getString(R.string.title_favorites);
|
||||
}
|
||||
return context.getString(R.string.title_likes);
|
||||
}
|
||||
};
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return TAB_NAME;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.FAVORITE;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_REQUIRED;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ExtraConfiguration[] getExtraConfigurations(Context context) {
|
||||
return new ExtraConfiguration[]{
|
||||
new UserExtraConfiguration(EXTRA_USER).title(R.string.title_user).headerTitle(R.string.title_user)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyExtraConfigurationTo(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
UserArguments arguments = (UserArguments) tab.getArguments();
|
||||
assert arguments != null;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_USER: {
|
||||
final ParcelableUser user = ((UserExtraConfiguration) extraConf).getValue();
|
||||
if (user == null) return false;
|
||||
arguments.setUserKey(user.key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return UserFavoritesFragment.class;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.fragment.HomeTimelineFragment;
|
||||
import org.mariotaku.twidere.model.Tab;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.conf.BooleanExtraConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.extra.HomeTabExtras;
|
||||
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_HIDE_QUOTES;
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_HIDE_REPLIES;
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_HIDE_RETWEETS;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class HomeTabConfiguration extends TabConfiguration {
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return StringHolder.resource(R.string.title_home);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.HOME;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_MULTIPLE | FLAG_ACCOUNT_MUTABLE;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ExtraConfiguration[] getExtraConfigurations(Context context) {
|
||||
return new ExtraConfiguration[]{
|
||||
new BooleanExtraConfiguration(EXTRA_HIDE_RETWEETS, false).title(R.string.hide_retweets).mutable(true),
|
||||
new BooleanExtraConfiguration(EXTRA_HIDE_QUOTES, false).title(R.string.hide_quotes).mutable(true),
|
||||
new BooleanExtraConfiguration(EXTRA_HIDE_REPLIES, false).title(R.string.hide_replies).mutable(true),
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyExtraConfigurationTo(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
final HomeTabExtras extras = (HomeTabExtras) tab.getExtras();
|
||||
assert extras != null;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_HIDE_RETWEETS: {
|
||||
extras.setHideRetweets(((BooleanExtraConfiguration) extraConf).getValue());
|
||||
break;
|
||||
}
|
||||
case EXTRA_HIDE_QUOTES: {
|
||||
extras.setHideQuotes(((BooleanExtraConfiguration) extraConf).getValue());
|
||||
break;
|
||||
}
|
||||
case EXTRA_HIDE_REPLIES: {
|
||||
extras.setHideReplies(((BooleanExtraConfiguration) extraConf).getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readExtraConfigurationFrom(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
final HomeTabExtras extras = (HomeTabExtras) tab.getExtras();
|
||||
if (extras == null) return false;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_HIDE_RETWEETS: {
|
||||
((BooleanExtraConfiguration) extraConf).setValue(extras.isHideRetweets());
|
||||
break;
|
||||
}
|
||||
case EXTRA_HIDE_QUOTES: {
|
||||
((BooleanExtraConfiguration) extraConf).setValue(extras.isHideQuotes());
|
||||
break;
|
||||
}
|
||||
case EXTRA_HIDE_REPLIES: {
|
||||
((BooleanExtraConfiguration) extraConf).setValue(extras.isHideReplies());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return HomeTimelineFragment.class;
|
||||
}
|
||||
}
|
|
@ -1,177 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.extension.model.AccountDetailsExtensionsKt;
|
||||
import org.mariotaku.twidere.fragment.InteractionsTimelineFragment;
|
||||
import org.mariotaku.twidere.model.AccountDetails;
|
||||
import org.mariotaku.twidere.model.Tab;
|
||||
import org.mariotaku.twidere.model.tab.BooleanHolder;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.conf.BooleanExtraConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.extra.InteractionsTabExtras;
|
||||
import org.mariotaku.twidere.model.util.AccountUtils;
|
||||
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_MENTIONS_ONLY;
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_MY_FOLLOWING_ONLY;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class InteractionsTabConfiguration extends TabConfiguration {
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return StringHolder.resource(R.string.interactions);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.NOTIFICATIONS;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_MULTIPLE | FLAG_ACCOUNT_MUTABLE;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ExtraConfiguration[] getExtraConfigurations(Context context) {
|
||||
return new ExtraConfiguration[]{
|
||||
new BooleanExtraConfiguration(EXTRA_MY_FOLLOWING_ONLY, false).title(R.string.following_only).mutable(true),
|
||||
new MentionsOnlyExtraConfiguration(EXTRA_MENTIONS_ONLY).title(R.string.mentions_only).mutable(true),
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyExtraConfigurationTo(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
final InteractionsTabExtras extras = (InteractionsTabExtras) tab.getExtras();
|
||||
assert extras != null;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_MY_FOLLOWING_ONLY: {
|
||||
extras.setMyFollowingOnly(((BooleanExtraConfiguration) extraConf).getValue());
|
||||
break;
|
||||
}
|
||||
case EXTRA_MENTIONS_ONLY: {
|
||||
extras.setMentionsOnly(((BooleanExtraConfiguration) extraConf).getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readExtraConfigurationFrom(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
final InteractionsTabExtras extras = (InteractionsTabExtras) tab.getExtras();
|
||||
if (extras == null) return false;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_MY_FOLLOWING_ONLY: {
|
||||
((BooleanExtraConfiguration) extraConf).setValue(extras.isMyFollowingOnly());
|
||||
break;
|
||||
}
|
||||
case EXTRA_MENTIONS_ONLY: {
|
||||
((BooleanExtraConfiguration) extraConf).setValue(extras.isMentionsOnly());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return InteractionsTimelineFragment.class;
|
||||
}
|
||||
|
||||
private static class MentionsOnlyExtraConfiguration extends BooleanExtraConfiguration {
|
||||
|
||||
private boolean valueBackup;
|
||||
|
||||
MentionsOnlyExtraConfiguration(@NonNull String key) {
|
||||
super(key, new HasOfficialBooleanHolder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountSelectionChanged(@Nullable AccountDetails account) {
|
||||
final boolean hasOfficial;
|
||||
if (account == null || account.dummy) {
|
||||
hasOfficial = AccountUtils.hasOfficialKeyAccount(getContext());
|
||||
} else {
|
||||
hasOfficial = AccountDetailsExtensionsKt.isOfficial(account, getContext());
|
||||
}
|
||||
((HasOfficialBooleanHolder) getDefaultValue()).hasOfficial = hasOfficial;
|
||||
final View view = getView();
|
||||
final CheckBox checkBox = (CheckBox) view.findViewById(android.R.id.checkbox);
|
||||
final TextView titleView = (TextView) view.findViewById(android.R.id.title);
|
||||
final TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
|
||||
view.setEnabled(hasOfficial);
|
||||
titleView.setEnabled(hasOfficial);
|
||||
summaryView.setEnabled(hasOfficial);
|
||||
checkBox.setEnabled(hasOfficial);
|
||||
if (hasOfficial) {
|
||||
checkBox.setChecked(valueBackup);
|
||||
summaryView.setVisibility(View.GONE);
|
||||
} else {
|
||||
valueBackup = checkBox.isChecked();
|
||||
checkBox.setChecked(true);
|
||||
summaryView.setText(R.string.summary_interactions_not_available);
|
||||
summaryView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getValue() {
|
||||
if (((HasOfficialBooleanHolder) getDefaultValue()).hasOfficial) {
|
||||
return super.getValue();
|
||||
}
|
||||
return valueBackup;
|
||||
}
|
||||
|
||||
private static class HasOfficialBooleanHolder extends BooleanHolder implements Parcelable {
|
||||
|
||||
private boolean hasOfficial;
|
||||
|
||||
@Override
|
||||
public boolean createBoolean(Context context) {
|
||||
return hasOfficial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
}
|
||||
|
||||
public static final Creator<HasOfficialBooleanHolder> CREATOR = new Creator<HasOfficialBooleanHolder>() {
|
||||
@Override
|
||||
public HasOfficialBooleanHolder createFromParcel(Parcel in) {
|
||||
return new HasOfficialBooleanHolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HasOfficialBooleanHolder[] newArray(int size) {
|
||||
return new HasOfficialBooleanHolder[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.fragment.message.MessagesEntriesFragment;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class MessagesTabConfiguration extends TabConfiguration {
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return StringHolder.resource(R.string.title_direct_messages);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.MESSAGE;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_MULTIPLE | FLAG_ACCOUNT_MUTABLE;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return MessagesEntriesFragment.class;
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.annotation.AccountType;
|
||||
import org.mariotaku.twidere.fragment.PublicTimelineFragment;
|
||||
import org.mariotaku.twidere.model.AccountDetails;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class PublicTimelineTabConfiguration extends TabConfiguration {
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return StringHolder.resource(R.string.title_public_timeline);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.QUOTE;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_REQUIRED | FLAG_ACCOUNT_MUTABLE;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return PublicTimelineFragment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAccountAvailability(@NonNull final AccountDetails details) {
|
||||
return AccountType.FANFOU.equals(details.type)
|
||||
|| AccountType.STATUSNET.equals(details.type);
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.fragment.StatusesSearchFragment;
|
||||
import org.mariotaku.twidere.model.Tab;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.argument.TextQueryArguments;
|
||||
import org.mariotaku.twidere.model.tab.conf.StringExtraConfiguration;
|
||||
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_QUERY;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class SearchTabConfiguration extends TabConfiguration {
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return StringHolder.resource(R.string.action_search);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.SEARCH;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_REQUIRED;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ExtraConfiguration[] getExtraConfigurations(Context context) {
|
||||
return new ExtraConfiguration[]{
|
||||
new StringExtraConfiguration(EXTRA_QUERY, null).maxLines(1).title(R.string.search_statuses).headerTitle(R.string.query)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyExtraConfigurationTo(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
final TextQueryArguments arguments = (TextQueryArguments) tab.getArguments();
|
||||
assert arguments != null;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_QUERY: {
|
||||
final String query = ((StringExtraConfiguration) extraConf).getValue();
|
||||
if (query == null) return false;
|
||||
arguments.setQuery(query);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readExtraConfigurationFrom(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
final TextQueryArguments arguments = (TextQueryArguments) tab.getArguments();
|
||||
if (arguments == null) return false;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_QUERY: {
|
||||
((StringExtraConfiguration) extraConf).setValue(arguments.getQuery());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return StatusesSearchFragment.class;
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.fragment.TrendsSuggestionsFragment;
|
||||
import org.mariotaku.twidere.model.Tab;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.conf.TrendsLocationExtraConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.extra.TrendsTabExtras;
|
||||
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_PLACE;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class TrendsTabConfiguration extends TabConfiguration {
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return StringHolder.resource(R.string.trends);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.HASHTAG;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_REQUIRED | FLAG_ACCOUNT_MUTABLE;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ExtraConfiguration[] getExtraConfigurations(Context context) {
|
||||
return new ExtraConfiguration[]{
|
||||
new TrendsLocationExtraConfiguration(EXTRA_PLACE).title(R.string.trends_location).mutable(true),
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyExtraConfigurationTo(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
final TrendsTabExtras extras = (TrendsTabExtras) tab.getExtras();
|
||||
assert extras != null;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_PLACE: {
|
||||
TrendsLocationExtraConfiguration conf = (TrendsLocationExtraConfiguration) extraConf;
|
||||
TrendsLocationExtraConfiguration.Place place = conf.getValue();
|
||||
if (place != null) {
|
||||
extras.setWoeId(place.getWoeId());
|
||||
extras.setPlaceName(place.getName());
|
||||
} else {
|
||||
extras.setWoeId(0);
|
||||
extras.setPlaceName(null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readExtraConfigurationFrom(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
final TrendsTabExtras extras = (TrendsTabExtras) tab.getExtras();
|
||||
if (extras == null) return false;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_PLACE: {
|
||||
final int woeId = extras.getWoeId();
|
||||
final String name = extras.getPlaceName();
|
||||
if (name != null) {
|
||||
TrendsLocationExtraConfiguration.Place place = new TrendsLocationExtraConfiguration.Place(woeId, name);
|
||||
((TrendsLocationExtraConfiguration) extraConf).setValue(place);
|
||||
} else {
|
||||
((TrendsLocationExtraConfiguration) extraConf).setValue(null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return TrendsSuggestionsFragment.class;
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.fragment.UserListTimelineFragment;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
import org.mariotaku.twidere.model.Tab;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.argument.UserListArguments;
|
||||
import org.mariotaku.twidere.model.tab.conf.UserListExtraConfiguration;
|
||||
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER_LIST;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class UserListTimelineTabConfiguration extends TabConfiguration {
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return StringHolder.resource(R.string.list_timeline);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.LIST;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_REQUIRED;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ExtraConfiguration[] getExtraConfigurations(Context context) {
|
||||
return new ExtraConfiguration[]{
|
||||
new UserListExtraConfiguration(EXTRA_USER_LIST).title(R.string.user_list).headerTitle(R.string.user_list)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyExtraConfigurationTo(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
UserListArguments arguments = (UserListArguments) tab.getArguments();
|
||||
assert arguments != null;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_USER_LIST: {
|
||||
final ParcelableUserList userList = ((UserListExtraConfiguration) extraConf).getValue();
|
||||
if (userList == null) return false;
|
||||
arguments.setListId(userList.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return UserListTimelineFragment.class;
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package org.mariotaku.twidere.model.tab.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.fragment.UserTimelineFragment;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.Tab;
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder;
|
||||
import org.mariotaku.twidere.model.tab.StringHolder;
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration;
|
||||
import org.mariotaku.twidere.model.tab.argument.UserArguments;
|
||||
import org.mariotaku.twidere.model.tab.conf.UserExtraConfiguration;
|
||||
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
public class UserTimelineTabConfiguration extends TabConfiguration {
|
||||
@NonNull
|
||||
@Override
|
||||
public StringHolder getName() {
|
||||
return StringHolder.resource(R.string.users_statuses);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DrawableHolder getIcon() {
|
||||
return DrawableHolder.Builtin.USER;
|
||||
}
|
||||
|
||||
@AccountFlags
|
||||
@Override
|
||||
public int getAccountFlags() {
|
||||
return FLAG_HAS_ACCOUNT | FLAG_ACCOUNT_REQUIRED;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ExtraConfiguration[] getExtraConfigurations(Context context) {
|
||||
return new ExtraConfiguration[]{
|
||||
new UserExtraConfiguration(EXTRA_USER).title(R.string.title_user).headerTitle(R.string.title_user)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyExtraConfigurationTo(@NonNull Tab tab, @NonNull ExtraConfiguration extraConf) {
|
||||
UserArguments arguments = (UserArguments) tab.getArguments();
|
||||
assert arguments != null;
|
||||
switch (extraConf.getKey()) {
|
||||
case EXTRA_USER: {
|
||||
final ParcelableUser user = ((UserExtraConfiguration) extraConf).getValue();
|
||||
if (user == null) return false;
|
||||
arguments.setUserKey(user.key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends Fragment> getFragmentClass() {
|
||||
return UserTimelineFragment.class;
|
||||
}
|
||||
}
|
|
@ -103,7 +103,7 @@ public class CustomTabUtils implements Constants {
|
|||
if (tabExtras != null) {
|
||||
args.putParcelable(EXTRA_EXTRAS, tabExtras);
|
||||
}
|
||||
final TabConfiguration conf = TabConfiguration.ofType(type);
|
||||
final TabConfiguration conf = TabConfiguration.Companion.ofType(type);
|
||||
final Class<? extends Fragment> cls = conf != null ? conf.getFragmentClass() : InvalidTabFragment.class;
|
||||
final String tabTypeName = getTabTypeName(context, type);
|
||||
final DrawableHolder icon = DrawableHolder.parse(iconType);
|
||||
|
@ -188,7 +188,7 @@ public class CustomTabUtils implements Constants {
|
|||
|
||||
public static String getTabTypeName(final Context context, @CustomTabType final String type) {
|
||||
if (context == null) return null;
|
||||
final TabConfiguration conf = TabConfiguration.ofType(type);
|
||||
final TabConfiguration conf = TabConfiguration.Companion.ofType(type);
|
||||
if (conf == null) return null;
|
||||
return conf.getName().createString(context);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class CustomTabUtils implements Constants {
|
|||
}
|
||||
|
||||
public static boolean isTabTypeValid(@NonNull final String tabType) {
|
||||
return TabConfiguration.ofType(Tab.getTypeAlias(tabType)) != null;
|
||||
return TabConfiguration.Companion.ofType(Tab.getTypeAlias(tabType)) != null;
|
||||
}
|
||||
|
||||
public static boolean hasAccountKey(final Context context, @NonNull final Bundle args,
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.mariotaku.twidere.util;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -64,11 +65,10 @@ public class KeyboardShortcutsHandler implements KeyboardShortcutConstants {
|
|||
sMetaNameMap.put(KeyEvent.META_SHIFT_ON, "shift");
|
||||
}
|
||||
|
||||
private final SharedPreferencesWrapper mPreferences;
|
||||
private final SharedPreferences mPreferences;
|
||||
|
||||
public KeyboardShortcutsHandler(final Context context) {
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(context,
|
||||
KEYBOARD_SHORTCUTS_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mPreferences = context.getSharedPreferences(KEYBOARD_SHORTCUTS_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public String findAction(@NonNull KeyboardShortcutSpec spec) {
|
||||
|
|
|
@ -39,19 +39,19 @@ public class PermissionsManager implements Constants {
|
|||
|
||||
private static final String[] PERMISSIONS_DENIED = {PERMISSION_DENIED};
|
||||
|
||||
private final SharedPreferencesWrapper mPreferences;
|
||||
private final PackageManager mPackageManager;
|
||||
private final SharedPreferences preferences;
|
||||
private final PackageManager packageManager;
|
||||
private final Context mContext;
|
||||
|
||||
public PermissionsManager(final Context context) {
|
||||
mContext = context;
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(context, PERMISSION_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mPackageManager = context.getPackageManager();
|
||||
preferences = context.getSharedPreferences(PERMISSION_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
packageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
public boolean accept(final String packageName, final String[] permissions) {
|
||||
if (packageName == null || permissions == null) return false;
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
final SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putString(packageName, TwidereArrayUtils.toString(permissions, '|', false));
|
||||
return editor.commit();
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ public class PermissionsManager implements Constants {
|
|||
public boolean checkSignature(final String pname) {
|
||||
if (mContext.getPackageName().equals(pname)) return true;
|
||||
if (BuildConfig.DEBUG) return false;
|
||||
return mPackageManager.checkSignatures(pname, mContext.getPackageName()) == PackageManager.SIGNATURE_MATCH;
|
||||
return packageManager.checkSignatures(pname, mContext.getPackageName()) == PackageManager.SIGNATURE_MATCH;
|
||||
}
|
||||
|
||||
public boolean deny(final String packageName) {
|
||||
if (packageName == null) return false;
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
final SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putString(packageName, PERMISSION_DENIED);
|
||||
return editor.commit();
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class PermissionsManager implements Constants {
|
|||
|
||||
public Map<String, String> getAll() {
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
for (final Map.Entry<String, ?> entry : mPreferences.getAll().entrySet()) {
|
||||
for (final Map.Entry<String, ?> entry : preferences.getAll().entrySet()) {
|
||||
if (entry.getValue() instanceof String) {
|
||||
map.put(entry.getKey(), (String) entry.getValue());
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class PermissionsManager implements Constants {
|
|||
}
|
||||
|
||||
public String getPackageNameByUid(final int uid) {
|
||||
final String[] pkgs = mPackageManager.getPackagesForUid(uid);
|
||||
final String[] pkgs = packageManager.getPackagesForUid(uid);
|
||||
if (pkgs != null && pkgs.length > 0) return pkgs[0];
|
||||
return null;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class PermissionsManager implements Constants {
|
|||
|
||||
public String[] getPermissions(final String packageName) {
|
||||
if (isEmpty(packageName)) return new String[0];
|
||||
final String permissionsString = mPreferences.getString(packageName, null);
|
||||
final String permissionsString = preferences.getString(packageName, null);
|
||||
if (isEmpty(permissionsString)) return new String[0];
|
||||
if (permissionsString.contains(PERMISSION_DENIED)) return PERMISSIONS_DENIED;
|
||||
return permissionsString.split("\\|");
|
||||
|
@ -125,7 +125,7 @@ public class PermissionsManager implements Constants {
|
|||
|
||||
public boolean revoke(final String packageName) {
|
||||
if (packageName == null) return false;
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
final SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.remove(packageName);
|
||||
return editor.commit();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ import android.widget.Toast;
|
|||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.json.JSONException;
|
||||
import org.mariotaku.kpreferences.SharedPreferencesExtensionsKt;
|
||||
import org.mariotaku.microblog.library.MicroBlogException;
|
||||
import org.mariotaku.microblog.library.twitter.model.RateLimitStatus;
|
||||
import org.mariotaku.pickncrop.library.PNCUtils;
|
||||
|
@ -78,10 +79,10 @@ import org.mariotaku.sqliteqb.library.Columns;
|
|||
import org.mariotaku.sqliteqb.library.Columns.Column;
|
||||
import org.mariotaku.sqliteqb.library.Expression;
|
||||
import org.mariotaku.sqliteqb.library.Selectable;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.annotation.CustomTabType;
|
||||
import org.mariotaku.twidere.annotation.ProfileImageSize;
|
||||
import org.mariotaku.twidere.constant.PreferenceKeysKt;
|
||||
import org.mariotaku.twidere.model.AccountDetails;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.ParcelableUserMention;
|
||||
|
@ -102,9 +103,35 @@ import java.util.Map.Entry;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.mariotaku.twidere.TwidereConstants.DEFAULT_SHARE_FORMAT;
|
||||
import static org.mariotaku.twidere.TwidereConstants.FORMAT_PATTERN_TITLE;
|
||||
import static org.mariotaku.twidere.TwidereConstants.KEY_SHARE_FORMAT;
|
||||
import static org.mariotaku.twidere.TwidereConstants.KEY_TAB_DISPLAY_OPTION;
|
||||
import static org.mariotaku.twidere.TwidereConstants.LOGTAG;
|
||||
import static org.mariotaku.twidere.TwidereConstants.METADATA_KEY_EXTENSION_USE_JSON;
|
||||
import static org.mariotaku.twidere.TwidereConstants.QUERY_PARAM_USER_KEY;
|
||||
import static org.mariotaku.twidere.TwidereConstants.SHARED_PREFERENCES_NAME;
|
||||
import static org.mariotaku.twidere.TwidereConstants.TAB_CODE_DIRECT_MESSAGES;
|
||||
import static org.mariotaku.twidere.TwidereConstants.TAB_CODE_HOME_TIMELINE;
|
||||
import static org.mariotaku.twidere.TwidereConstants.TAB_CODE_NOTIFICATIONS_TIMELINE;
|
||||
import static org.mariotaku.twidere.TwidereConstants.VALUE_TAB_DISPLAY_OPTION_ICON;
|
||||
import static org.mariotaku.twidere.TwidereConstants.VALUE_TAB_DISPLAY_OPTION_LABEL;
|
||||
import static org.mariotaku.twidere.constant.CompatibilityConstants.EXTRA_ACCOUNT_ID;
|
||||
import static org.mariotaku.twidere.constant.CompatibilityConstants.QUERY_PARAM_USER_ID;
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT_KEY;
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT_KEYS;
|
||||
import static org.mariotaku.twidere.constant.IntentConstants.INTENT_ACTION_PEBBLE_NOTIFICATION;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.DEFAULT_QUOTE_FORMAT;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.FORMAT_PATTERN_LINK;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.FORMAT_PATTERN_NAME;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.FORMAT_PATTERN_TEXT;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_BANDWIDTH_SAVING_MODE;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_DEFAULT_ACCOUNT_KEY;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_PEBBLE_NOTIFICATIONS;
|
||||
import static org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_QUOTE_FORMAT;
|
||||
import static org.mariotaku.twidere.util.TwidereLinkify.PATTERN_TWITTER_PROFILE_IMAGES;
|
||||
|
||||
public final class Utils implements Constants {
|
||||
public final class Utils {
|
||||
|
||||
public static final Pattern PATTERN_XML_RESOURCE_IDENTIFIER = Pattern.compile("res/xml/([\\w_]+)\\.xml");
|
||||
public static final Pattern PATTERN_RESOURCE_IDENTIFIER = Pattern.compile("@([\\w_]+)/([\\w_]+)");
|
||||
|
@ -855,10 +882,11 @@ public final class Utils implements Constants {
|
|||
|| plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||
}
|
||||
|
||||
public static boolean isMediaPreviewEnabled(Context context, SharedPreferencesWrapper preferences) {
|
||||
if (!preferences.getBoolean(KEY_MEDIA_PREVIEW)) return false;
|
||||
public static boolean isMediaPreviewEnabled(Context context, SharedPreferences preferences) {
|
||||
if (!SharedPreferencesExtensionsKt.get(preferences, PreferenceKeysKt.getMediaPreviewKey()))
|
||||
return false;
|
||||
final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
return !ConnectivityManagerCompat.isActiveNetworkMetered(cm) || !preferences.getBoolean(KEY_BANDWIDTH_SAVING_MODE);
|
||||
return !ConnectivityManagerCompat.isActiveNetworkMetered(cm) || !preferences.getBoolean(KEY_BANDWIDTH_SAVING_MODE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.ktextension
|
||||
|
||||
import android.os.Parcel
|
||||
|
||||
private const val byteTrue: Byte = 1
|
||||
private const val byteFalse: Byte = 0
|
||||
|
||||
fun Parcel.readBoolean(): Boolean {
|
||||
return readByte() == byteTrue
|
||||
}
|
||||
|
||||
fun Parcel.writeBoolean(bool: Boolean) {
|
||||
writeByte(if (bool) byteTrue else byteFalse)
|
||||
}
|
|
@ -4,26 +4,20 @@ import android.app.Activity
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import org.mariotaku.twidere.Constants
|
||||
import org.mariotaku.twidere.TwidereConstants.SHARED_PREFERENCES_NAME
|
||||
import org.mariotaku.twidere.constant.IntentConstants.*
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.*
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
|
||||
class AssistLauncherActivity : Activity(), Constants {
|
||||
class AssistLauncherActivity : Activity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val prefs = SharedPreferencesWrapper.getInstance(this, SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE)
|
||||
val prefs = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
val composeNowAction = prefs.getString(KEY_COMPOSE_NOW_ACTION, VALUE_COMPOSE_NOW_ACTION_COMPOSE)
|
||||
val action: String
|
||||
if (VALUE_COMPOSE_NOW_ACTION_TAKE_PHOTO == composeNowAction) {
|
||||
action = INTENT_ACTION_COMPOSE_TAKE_PHOTO
|
||||
} else if (VALUE_COMPOSE_NOW_ACTION_PICK_IMAGE == composeNowAction) {
|
||||
action = INTENT_ACTION_COMPOSE_PICK_IMAGE
|
||||
} else {
|
||||
action = INTENT_ACTION_COMPOSE
|
||||
val action = when (composeNowAction) {
|
||||
VALUE_COMPOSE_NOW_ACTION_TAKE_PHOTO -> INTENT_ACTION_COMPOSE_TAKE_PHOTO
|
||||
VALUE_COMPOSE_NOW_ACTION_PICK_IMAGE -> INTENT_ACTION_COMPOSE_PICK_IMAGE
|
||||
else -> INTENT_ACTION_COMPOSE
|
||||
}
|
||||
val intent = Intent(action)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||
|
|
|
@ -89,7 +89,7 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
|||
@Inject
|
||||
lateinit var bus: Bus
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var kPreferences: KPreferences
|
||||
@Inject
|
||||
|
|
|
@ -1567,7 +1567,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
}
|
||||
|
||||
private fun setupEditText() {
|
||||
val sendByEnter = preferences.getBoolean(KEY_QUICK_SEND)
|
||||
val sendByEnter = preferences[quickSendKey]
|
||||
EditTextEnterHandler.attach(editText, ComposeEnterListener(this), sendByEnter)
|
||||
editText.addTextChangedListener(object : TextWatcher {
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ import org.mariotaku.twidere.model.UserKey
|
|||
import org.mariotaku.twidere.model.analyzer.PurchaseFinished
|
||||
import org.mariotaku.twidere.util.*
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback
|
||||
import org.mariotaku.twidere.util.Utils.LINK_ID_FILTERS_IMPORT_BLOCKS
|
||||
import org.mariotaku.twidere.util.linkhandler.TwidereLinkMatcher
|
||||
import org.mariotaku.twidere.util.theme.getCurrentThemeResource
|
||||
|
||||
|
@ -356,7 +355,7 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
|||
setTitle(R.string.title_statuses)
|
||||
}
|
||||
LINK_ID_USER_FAVORITES -> {
|
||||
if (preferences.getBoolean(SharedPreferenceConstants.KEY_I_WANT_MY_STARS_BACK)) {
|
||||
if (preferences[iWantMyStarsBackKey]) {
|
||||
setTitle(R.string.title_favorites)
|
||||
} else {
|
||||
setTitle(R.string.title_likes)
|
||||
|
@ -375,7 +374,7 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
|||
setTitle(R.string.action_twitter_muted_users)
|
||||
}
|
||||
LINK_ID_USER_LIST -> {
|
||||
setTitle(R.string.user_list)
|
||||
setTitle(R.string.title_user_list)
|
||||
}
|
||||
LINK_ID_GROUP -> {
|
||||
setTitle(R.string.group)
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.mariotaku.twidere.activity
|
|||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.NavUtils
|
||||
|
@ -28,7 +29,6 @@ import org.mariotaku.twidere.adapter.BaseRecyclerViewAdapter
|
|||
import org.mariotaku.twidere.fragment.ProgressDialogFragment
|
||||
import org.mariotaku.twidere.model.analyzer.PurchaseFinished
|
||||
import org.mariotaku.twidere.util.Analyzer
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
import org.mariotaku.twidere.util.schedule.StatusScheduleProvider
|
||||
|
@ -166,7 +166,7 @@ class PremiumDashboardActivity : BaseActivity() {
|
|||
protected lateinit var extraFeaturesService: ExtraFeaturesService
|
||||
|
||||
@Inject
|
||||
protected lateinit var preferences: SharedPreferencesWrapper
|
||||
protected lateinit var preferences: SharedPreferences
|
||||
|
||||
@Inject
|
||||
protected lateinit var mScheduleProviderFactory: StatusScheduleProvider.Factory
|
||||
|
|
|
@ -21,18 +21,19 @@ package org.mariotaku.twidere.activity
|
|||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import org.mariotaku.twidere.Constants.KEY_USAGE_STATISTICS
|
||||
import org.mariotaku.kpreferences.contains
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.kpreferences.set
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_RESID
|
||||
import org.mariotaku.twidere.constant.usageStatisticsKey
|
||||
import org.mariotaku.twidere.fragment.SettingsDetailsFragment
|
||||
|
||||
class UsageStatisticsActivity : BaseActivity() {
|
||||
|
||||
override fun onDestroy() {
|
||||
if (!preferences.contains(KEY_USAGE_STATISTICS)) {
|
||||
val editor = preferences.edit()
|
||||
editor.putBoolean(KEY_USAGE_STATISTICS, preferences.getBoolean(KEY_USAGE_STATISTICS))
|
||||
editor.apply()
|
||||
if (isFinishing && usageStatisticsKey !in preferences) {
|
||||
preferences[usageStatisticsKey] = preferences[usageStatisticsKey]
|
||||
}
|
||||
super.onDestroy()
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v4.text.BidiFormatter
|
||||
import com.bumptech.glide.RequestManager
|
||||
import org.mariotaku.kpreferences.get
|
||||
|
@ -51,7 +52,7 @@ open class BaseArrayAdapter<T>(
|
|||
@Inject
|
||||
lateinit var multiSelectManager: MultiSelectManager
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var permissionsManager: PermissionsManager
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v4.text.BidiFormatter
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import com.bumptech.glide.RequestManager
|
||||
|
@ -51,7 +52,7 @@ abstract class BaseRecyclerViewAdapter<VH : RecyclerView.ViewHolder>(
|
|||
@Inject
|
||||
override final lateinit var bidiFormatter: BidiFormatter
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var readStateManager: ReadStateManager
|
||||
@Inject
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.database.Cursor
|
||||
import android.graphics.PorterDuff.Mode
|
||||
import android.support.v4.widget.SimpleCursorAdapter
|
||||
|
@ -35,7 +36,6 @@ import org.mariotaku.twidere.extension.loadProfileImage
|
|||
import org.mariotaku.twidere.model.SuggestionItem
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Suggestions
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.view.ProfileImageView
|
||||
|
@ -45,7 +45,7 @@ class ComposeAutoCompleteAdapter(context: Context, val requestManager: RequestMa
|
|||
R.layout.list_item_auto_complete, null, emptyArray(), intArrayOf(), 0) {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var userColorNameManager: UserColorNameManager
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.database.Cursor
|
||||
import android.support.v4.widget.SimpleCursorAdapter
|
||||
import android.support.v7.widget.RecyclerViewAccessor
|
||||
|
@ -30,7 +31,6 @@ import org.mariotaku.kpreferences.get
|
|||
import org.mariotaku.library.objectcursor.ObjectCursor
|
||||
import org.mariotaku.twidere.constant.mediaPreviewStyleKey
|
||||
import org.mariotaku.twidere.model.Draft
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.view.holder.DraftViewHolder
|
||||
import javax.inject.Inject
|
||||
|
@ -41,7 +41,7 @@ class DraftsAdapter(
|
|||
) : SimpleCursorAdapter(context, DraftViewHolder.layoutResource, null, emptyArray(), intArrayOf(), 0) {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
|
||||
private val mediaPreviewStyle: Int
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.mariotaku.twidere.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v4.text.BidiFormatter
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import com.bumptech.glide.RequestManager
|
||||
|
@ -14,7 +15,6 @@ import org.mariotaku.twidere.constant.*
|
|||
import org.mariotaku.twidere.model.*
|
||||
import org.mariotaku.twidere.model.util.getActivityStatus
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.TwidereLinkify
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
|
@ -32,7 +32,7 @@ class DummyItemAdapter(
|
|||
) : IStatusesAdapter<Any>, IUsersAdapter<Any>, IUserListsAdapter<Any> {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
override lateinit var twitterWrapper: AsyncTwitterWrapper
|
||||
@Inject
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.adapter
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.support.v4.widget.SimpleCursorAdapter
|
||||
|
@ -40,7 +41,6 @@ import org.mariotaku.twidere.extension.loadProfileImage
|
|||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedUsers
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.Utils
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
|
@ -54,7 +54,7 @@ class UserAutoCompleteAdapter(
|
|||
) : SimpleCursorAdapter(context, R.layout.list_item_auto_complete, null, emptyArray(), intArrayOf(), 0) {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var userColorNameManager: UserColorNameManager
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.mariotaku.twidere.TwidereConstants.KEY_MEDIA_PRELOAD
|
|||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.annotation.ImageShapeStyle
|
||||
import org.mariotaku.twidere.annotation.PreviewStyle
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.*
|
||||
import org.mariotaku.twidere.extension.getNonEmptyString
|
||||
import org.mariotaku.twidere.model.CustomAPIConfig
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
@ -76,6 +75,22 @@ val multiColumnWidthKey = KStringKey("multi_column_tab_width", "normal")
|
|||
val streamingEnabledKey = KBooleanKey("streaming_enabled", false)
|
||||
val streamingNonMeteredNetworkKey = KBooleanKey("streaming_non_metered_network", true)
|
||||
val streamingPowerSavingKey = KBooleanKey("streaming_power_saving", true)
|
||||
val quickSendKey = KBooleanKey(KEY_QUICK_SEND, false)
|
||||
val refreshAfterTweetKey = KBooleanKey(KEY_REFRESH_AFTER_TWEET, false)
|
||||
val homeRefreshMentionsKey = KBooleanKey(KEY_HOME_REFRESH_MENTIONS, true)
|
||||
val homeRefreshDirectMessagesKey = KBooleanKey(KEY_HOME_REFRESH_DIRECT_MESSAGES, true)
|
||||
val homeRefreshSavedSearchesKey = KBooleanKey(KEY_HOME_REFRESH_SAVED_SEARCHES, true)
|
||||
|
||||
object cacheSizeLimitKey : KSimpleKey<Int>(KEY_CACHE_SIZE_LIMIT, 300) {
|
||||
override fun read(preferences: SharedPreferences) = preferences.getInt(key, def).coerceIn(100,
|
||||
500)
|
||||
|
||||
override fun write(editor: SharedPreferences.Editor, value: Int): Boolean {
|
||||
editor.putInt(key, value)
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
object overrideLanguageKey : KSimpleKey<Locale?>("override_language", null) {
|
||||
override fun read(preferences: SharedPreferences): Locale? {
|
||||
|
|
|
@ -74,6 +74,7 @@ import org.mariotaku.twidere.annotation.ProfileImageSize
|
|||
import org.mariotaku.twidere.annotation.Referral
|
||||
import org.mariotaku.twidere.constant.KeyboardShortcutConstants.*
|
||||
import org.mariotaku.twidere.constant.extraFeaturesNoticeVersionKey
|
||||
import org.mariotaku.twidere.constant.iWantMyStarsBackKey
|
||||
import org.mariotaku.twidere.constant.newDocumentApiKey
|
||||
import org.mariotaku.twidere.constant.profileImageStyleKey
|
||||
import org.mariotaku.twidere.extension.loadProfileBanner
|
||||
|
@ -301,7 +302,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
|||
noAccountContainer.visibility = View.VISIBLE
|
||||
profileContainer.visibility = View.INVISIBLE
|
||||
}
|
||||
useStarsForLikes = preferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)
|
||||
useStarsForLikes = preferences[iWantMyStarsBackKey]
|
||||
accountsAdapter.accounts = accounts
|
||||
val defaultKey = preferences.getString(KEY_DEFAULT_ACCOUNT_KEY, null)?.let(UserKey::valueOf)
|
||||
?: accounts.firstOrNull { it.activated }?.key
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo
|
|||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.layout_draggable_list_with_empty_view.*
|
||||
import nl.komponents.kovenant.task
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.Bundle
|
||||
import org.mariotaku.ktextension.set
|
||||
import org.mariotaku.sqliteqb.library.Expression
|
||||
|
@ -31,7 +32,7 @@ import org.mariotaku.twidere.activity.ColorPickerDialogActivity
|
|||
import org.mariotaku.twidere.adapter.AccountDetailsAdapter
|
||||
import org.mariotaku.twidere.annotation.Referral
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT_KEY
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NEW_DOCUMENT_API
|
||||
import org.mariotaku.twidere.constant.newDocumentApiKey
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.extension.model.getAccountKey
|
||||
import org.mariotaku.twidere.extension.model.setActivated
|
||||
|
@ -151,8 +152,8 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
|||
|
||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||
val account = adapter.getItem(position)
|
||||
IntentUtils.openUserProfile(context, account.user, preferences.getBoolean(KEY_NEW_DOCUMENT_API), Referral.SELF_PROFILE,
|
||||
null)
|
||||
IntentUtils.openUserProfile(context, account.user, preferences[newDocumentApiKey],
|
||||
Referral.SELF_PROFILE, null)
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<AccountDetails>> {
|
||||
|
|
|
@ -25,9 +25,10 @@ import android.os.Bundle
|
|||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.app.AlertDialog
|
||||
import com.twitter.Extractor
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_STATUS
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NAME_FIRST
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.model.ParcelableStatus
|
||||
import org.mariotaku.twidere.model.ParcelableUserMention
|
||||
|
@ -49,7 +50,7 @@ class AddStatusFilterDialogFragment : BaseDialogFragment() {
|
|||
val builder = AlertDialog.Builder(context)
|
||||
filterItems = filterItemsInfo
|
||||
val entries = arrayOfNulls<String>(filterItems!!.size)
|
||||
val nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
|
||||
val nameFirst = preferences[nameFirstKey]
|
||||
for (i in 0 until entries.size) {
|
||||
val info = filterItems!![i]
|
||||
when (info.type) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v4.app.DialogFragment
|
||||
import com.squareup.otto.Bus
|
||||
import com.twitter.Validator
|
||||
|
@ -37,7 +38,7 @@ open class BaseDialogFragment : DialogFragment() {
|
|||
@Inject
|
||||
lateinit var userColorNameManager: UserColorNameManager
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var kPreferences: KPreferences
|
||||
@Inject
|
||||
|
|
|
@ -20,12 +20,14 @@
|
|||
package org.mariotaku.twidere.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.text.BidiFormatter
|
||||
import com.squareup.otto.Bus
|
||||
import com.twitter.Validator
|
||||
import nl.komponents.kovenant.Promise
|
||||
import okhttp3.Dns
|
||||
import org.mariotaku.restfu.http.RestHttpClient
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment
|
||||
import org.mariotaku.twidere.model.DefaultFeatures
|
||||
|
@ -52,7 +54,7 @@ open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
|||
@Inject
|
||||
lateinit var userColorNameManager: UserColorNameManager
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var notificationManager: NotificationManagerWrapper
|
||||
@Inject
|
||||
|
@ -73,6 +75,8 @@ open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
|||
lateinit var timelineSyncManagerFactory: TimelineSyncManager.Factory
|
||||
@Inject
|
||||
lateinit var restHttpClient: RestHttpClient
|
||||
@Inject
|
||||
lateinit var dns: Dns
|
||||
|
||||
protected val statusScheduleProvider: StatusScheduleProvider?
|
||||
get() = statusScheduleProviderFactory.newInstance(context)
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.mariotaku.twidere.activity.SettingsActivity
|
|||
import org.mariotaku.twidere.adapter.AccountsSpinnerAdapter
|
||||
import org.mariotaku.twidere.adapter.ArrayAdapter
|
||||
import org.mariotaku.twidere.annotation.CustomTabType
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.extension.model.isOfficial
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
|
@ -142,7 +143,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
|
|||
val subMenu = itemAdd.subMenu
|
||||
subMenu.clear()
|
||||
for ((type, conf) in TabConfiguration.all()) {
|
||||
val accountRequired = TabConfiguration.FLAG_ACCOUNT_REQUIRED in conf.accountFlags
|
||||
val accountRequired = TabAccountFlags.FLAG_ACCOUNT_REQUIRED in conf.accountFlags
|
||||
val subItem = subMenu.add(0, 0, conf.sortPosition, conf.name.createString(context))
|
||||
val disabledByNoAccount = accountRequired && accounts.none(conf::checkAccountAvailability)
|
||||
val disabledByDuplicateTab = conf.isSingleTab && CustomTabUtils.isTabAdded(context, type)
|
||||
|
@ -282,11 +283,11 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
|
|||
|
||||
val editMode = tag == TAG_EDIT_TAB
|
||||
|
||||
val hasAccount = TabConfiguration.FLAG_HAS_ACCOUNT in conf.accountFlags
|
||||
val accountMutable = TabConfiguration.FLAG_ACCOUNT_MUTABLE in conf.accountFlags
|
||||
val hasAccount = TabAccountFlags.FLAG_HAS_ACCOUNT in conf.accountFlags
|
||||
val accountMutable = TabAccountFlags.FLAG_ACCOUNT_MUTABLE in conf.accountFlags
|
||||
if (hasAccount && (accountMutable || !editMode)) {
|
||||
accountContainer.visibility = View.VISIBLE
|
||||
val accountRequired = TabConfiguration.FLAG_ACCOUNT_REQUIRED in conf.accountFlags
|
||||
val accountRequired = TabAccountFlags.FLAG_ACCOUNT_REQUIRED in conf.accountFlags
|
||||
accountsAdapter.clear()
|
||||
if (!accountRequired) {
|
||||
accountsAdapter.add(AccountDetails.dummy())
|
||||
|
@ -358,7 +359,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
|
|||
if (tab.extras == null) {
|
||||
tab.extras = CustomTabUtils.newTabExtras(tabType)
|
||||
}
|
||||
if (hasAccount && (!editMode || TabConfiguration.FLAG_ACCOUNT_MUTABLE in conf.accountFlags)) {
|
||||
if (hasAccount && (!editMode || TabAccountFlags.FLAG_ACCOUNT_MUTABLE in conf.accountFlags)) {
|
||||
val account = accountSpinner.selectedItem as? AccountDetails ?: return@setOnClickListener
|
||||
if (!account.dummy) {
|
||||
tab.arguments?.accountKeys = arrayOf(account.key)
|
||||
|
|
|
@ -24,11 +24,12 @@ import android.content.DialogInterface
|
|||
import android.os.Bundle
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.app.AlertDialog
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.toTypedArray
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USERS
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER_LIST
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NAME_FIRST
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.ParcelableUserList
|
||||
|
@ -54,7 +55,7 @@ class DeleteUserListMembersDialogFragment : BaseDialogFragment(), DialogInterfac
|
|||
if (users == null || userList == null) throw NullPointerException()
|
||||
if (users.size == 1) {
|
||||
val user = users[0]
|
||||
val nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
|
||||
val nameFirst = preferences[nameFirstKey]
|
||||
val displayName = userColorNameManager.getDisplayName(user, nameFirst)
|
||||
builder.setTitle(getString(R.string.delete_user, displayName))
|
||||
builder.setMessage(getString(R.string.delete_user_from_list_confirm, displayName, userList.name))
|
||||
|
|
|
@ -24,11 +24,12 @@ import android.content.DialogInterface
|
|||
import android.os.Bundle
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.app.AlertDialog
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.Bundle
|
||||
import org.mariotaku.ktextension.set
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NAME_FIRST
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
|
||||
|
@ -46,7 +47,7 @@ class DestroyFriendshipDialogFragment : BaseDialogFragment(), DialogInterface.On
|
|||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
val nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
|
||||
val nameFirst = preferences[nameFirstKey]
|
||||
val displayName = userColorNameManager.getDisplayName(user, nameFirst)
|
||||
builder.setTitle(getString(R.string.unfollow_user, displayName))
|
||||
builder.setMessage(getString(R.string.unfollow_user_confirm_message, displayName))
|
||||
|
|
|
@ -71,7 +71,7 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks<SingleRespon
|
|||
if (group != null) {
|
||||
activity.title = group.fullname
|
||||
} else {
|
||||
activity.setTitle(R.string.user_list)
|
||||
activity.setTitle(R.string.title_user_list)
|
||||
}
|
||||
activity.invalidateOptionsMenu()
|
||||
}
|
||||
|
|
|
@ -46,13 +46,12 @@ import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
|||
class HostMappingsListFragment : AbsContentListViewFragment<HostMappingsListFragment.HostMappingAdapter>(),
|
||||
AdapterView.OnItemClickListener, MultiChoiceModeListener, OnSharedPreferenceChangeListener {
|
||||
|
||||
private lateinit var hostMapping: SharedPreferencesWrapper
|
||||
private lateinit var hostMapping: SharedPreferences
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
hostMapping = SharedPreferencesWrapper.getInstance(activity,
|
||||
Constants.HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
hostMapping = activity.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
hostMapping.registerOnSharedPreferenceChangeListener(this)
|
||||
listView.choiceMode = ListView.CHOICE_MODE_MULTIPLE_MODAL
|
||||
listView.setMultiChoiceModeListener(this)
|
||||
|
|
|
@ -24,9 +24,10 @@ import android.content.DialogInterface
|
|||
import android.os.Bundle
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.app.AlertDialog
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NAME_FIRST
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
|
||||
|
@ -47,7 +48,7 @@ class ReportSpamDialogFragment : BaseDialogFragment(), DialogInterface.OnClickLi
|
|||
val builder = AlertDialog.Builder(context)
|
||||
val user = user
|
||||
if (user != null) {
|
||||
val nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
|
||||
val nameFirst = preferences[nameFirstKey]
|
||||
val displayName = userColorNameManager.getDisplayName(user, nameFirst)
|
||||
builder.setTitle(getString(R.string.report_user, displayName))
|
||||
builder.setMessage(getString(R.string.report_user_confirm_message, displayName))
|
||||
|
|
|
@ -654,7 +654,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
val activity = activity
|
||||
nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
|
||||
nameFirst = preferences[nameFirstKey]
|
||||
cardBackgroundColor = ThemeUtils.getCardBackgroundColor(activity,
|
||||
preferences[themeBackgroundOptionKey], preferences[themeBackgroundAlphaKey])
|
||||
actionBarShadowColor = 0xA0000000.toInt()
|
||||
|
@ -1136,7 +1136,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
}
|
||||
}
|
||||
TAB_TYPE_FAVORITES -> {
|
||||
if (preferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
|
||||
if (preferences[iWantMyStarsBackKey]) {
|
||||
actionBar.subtitle = resources.getQuantityString(R.plurals.N_favorites,
|
||||
user.favorites_count.toInt(), user.favorites_count)
|
||||
} else {
|
||||
|
@ -1458,7 +1458,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
position = TAB_POSITION_STATUSES)
|
||||
pagerAdapter.add(cls = UserMediaTimelineFragment::class.java, args = tabArgs,
|
||||
name = getString(R.string.media), type = TAB_TYPE_MEDIA, position = TAB_POSITION_MEDIA)
|
||||
if (preferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
|
||||
if (preferences[iWantMyStarsBackKey]) {
|
||||
pagerAdapter.add(cls = UserFavoritesFragment::class.java, args = tabArgs,
|
||||
name = getString(R.string.title_favorites), type = TAB_TYPE_FAVORITES,
|
||||
position = TAB_POSITION_FAVORITES)
|
||||
|
|
|
@ -84,7 +84,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
|
|||
if (userList != null) {
|
||||
activity.title = userList.name
|
||||
} else {
|
||||
activity.setTitle(R.string.user_list)
|
||||
activity.setTitle(R.string.title_user_list)
|
||||
}
|
||||
activity.invalidateOptionsMenu()
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
|
|||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setView(R.layout.dialog_user_list_detail_editor)
|
||||
builder.setTitle(R.string.user_list)
|
||||
builder.setTitle(R.string.title_user_list)
|
||||
builder.setPositiveButton(android.R.string.ok, this)
|
||||
builder.setNegativeButton(android.R.string.cancel, this)
|
||||
val dialog = builder.create()
|
||||
|
|
|
@ -39,6 +39,7 @@ import android.widget.Toast
|
|||
import com.twitter.Validator
|
||||
import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.task
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.*
|
||||
import org.mariotaku.library.objectcursor.ObjectCursor
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
|
@ -46,7 +47,7 @@ import org.mariotaku.twidere.R
|
|||
import org.mariotaku.twidere.activity.content.RetweetQuoteDialogActivity
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.constant.IntentConstants.*
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_QUICK_SEND
|
||||
import org.mariotaku.twidere.constant.quickSendKey
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
|
||||
import org.mariotaku.twidere.extension.model.textLimit
|
||||
|
@ -115,7 +116,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
|
|||
}
|
||||
return false
|
||||
}
|
||||
}, preferences.getBoolean(KEY_QUICK_SEND))
|
||||
}, preferences[quickSendKey])
|
||||
enterHandler.addTextChangedListener(object : SimpleTextWatcher {
|
||||
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.loader
|
|||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v4.content.FixedAsyncTaskLoader
|
||||
import android.util.Log
|
||||
import org.mariotaku.kpreferences.get
|
||||
|
@ -39,7 +40,6 @@ import org.mariotaku.twidere.model.ParcelableUserList
|
|||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.util.AccountUtils
|
||||
import org.mariotaku.twidere.model.util.ParcelableUserListUtils
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.collection.NoDuplicatesArrayList
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import java.util.*
|
||||
|
@ -53,7 +53,7 @@ abstract class BaseUserListsLoader(
|
|||
data: List<ParcelableUserList>?
|
||||
) : FixedAsyncTaskLoader<List<ParcelableUserList>>(context), ICursorSupportLoader {
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
|
||||
protected val data = NoDuplicatesArrayList<ParcelableUserList>()
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.loader
|
|||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.support.annotation.WorkerThread
|
||||
import org.mariotaku.kpreferences.get
|
||||
|
@ -41,7 +42,6 @@ import org.mariotaku.twidere.model.util.AccountUtils
|
|||
import org.mariotaku.twidere.model.util.ParcelableStatusUtils
|
||||
import org.mariotaku.twidere.task.twitter.GetStatusesTask
|
||||
import org.mariotaku.twidere.util.DebugLog
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.cache.JsonCache
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
|
@ -76,7 +76,7 @@ abstract class MicroBlogAPIStatusesLoader(
|
|||
@Inject
|
||||
lateinit var jsonCache: JsonCache
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var userColorNameManager: UserColorNameManager
|
||||
|
||||
|
|
|
@ -21,18 +21,26 @@ package org.mariotaku.twidere.model
|
|||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.text.TextUtils
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.contains
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants.ACCOUNT_PREFERENCES_NAME_PREFIX
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.*
|
||||
import org.mariotaku.twidere.constant.defaultAutoRefreshKey
|
||||
import org.mariotaku.twidere.model.util.AccountUtils
|
||||
|
||||
class AccountPreferences(private val context: Context, val accountKey: UserKey) {
|
||||
private val preferences = context.getSharedPreferences("$ACCOUNT_PREFERENCES_NAME_PREFIX$accountKey", Context.MODE_PRIVATE)
|
||||
class AccountPreferences(
|
||||
private val context: Context,
|
||||
private val preferences: SharedPreferences,
|
||||
val accountKey: UserKey
|
||||
) {
|
||||
private val accountPreferences = context.getSharedPreferences(
|
||||
"$ACCOUNT_PREFERENCES_NAME_PREFIX$accountKey", Context.MODE_PRIVATE)
|
||||
|
||||
val defaultNotificationLightColor: Int
|
||||
get() {
|
||||
|
@ -45,20 +53,24 @@ class AccountPreferences(private val context: Context, val accountKey: UserKey)
|
|||
}
|
||||
|
||||
val directMessagesNotificationType: Int
|
||||
get() = preferences.getInt(KEY_NOTIFICATION_TYPE_DIRECT_MESSAGES, DEFAULT_NOTIFICATION_TYPE_DIRECT_MESSAGES)
|
||||
get() = accountPreferences.getInt(KEY_NOTIFICATION_TYPE_DIRECT_MESSAGES,
|
||||
DEFAULT_NOTIFICATION_TYPE_DIRECT_MESSAGES)
|
||||
|
||||
val homeTimelineNotificationType: Int
|
||||
get() = preferences.getInt(KEY_NOTIFICATION_TYPE_HOME, DEFAULT_NOTIFICATION_TYPE_HOME)
|
||||
get() = accountPreferences.getInt(KEY_NOTIFICATION_TYPE_HOME,
|
||||
DEFAULT_NOTIFICATION_TYPE_HOME)
|
||||
|
||||
val mentionsNotificationType: Int
|
||||
get() = preferences.getInt(KEY_NOTIFICATION_TYPE_MENTIONS, DEFAULT_NOTIFICATION_TYPE_MENTIONS)
|
||||
get() = accountPreferences.getInt(KEY_NOTIFICATION_TYPE_MENTIONS,
|
||||
DEFAULT_NOTIFICATION_TYPE_MENTIONS)
|
||||
|
||||
val notificationLightColor: Int
|
||||
get() = preferences.getInt(KEY_NOTIFICATION_LIGHT_COLOR, defaultNotificationLightColor)
|
||||
get() = accountPreferences.getInt(KEY_NOTIFICATION_LIGHT_COLOR,
|
||||
defaultNotificationLightColor)
|
||||
|
||||
val notificationRingtone: Uri
|
||||
get() {
|
||||
val ringtone = preferences.getString(KEY_NOTIFICATION_RINGTONE, null)
|
||||
val ringtone = accountPreferences.getString(KEY_NOTIFICATION_RINGTONE, null)
|
||||
if (TextUtils.isEmpty(ringtone)) {
|
||||
return RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
|
||||
} else {
|
||||
|
@ -67,57 +79,66 @@ class AccountPreferences(private val context: Context, val accountKey: UserKey)
|
|||
}
|
||||
|
||||
val isAutoRefreshEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_AUTO_REFRESH, preferences.getBoolean(KEY_DEFAULT_AUTO_REFRESH, false))
|
||||
get() = accountPreferences.getBoolean(KEY_AUTO_REFRESH, preferences[defaultAutoRefreshKey])
|
||||
|
||||
val isAutoRefreshHomeTimelineEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_AUTO_REFRESH_HOME_TIMELINE, DEFAULT_AUTO_REFRESH_HOME_TIMELINE)
|
||||
get() = accountPreferences.getBoolean(KEY_AUTO_REFRESH_HOME_TIMELINE,
|
||||
DEFAULT_AUTO_REFRESH_HOME_TIMELINE)
|
||||
|
||||
val isAutoRefreshMentionsEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_AUTO_REFRESH_MENTIONS, DEFAULT_AUTO_REFRESH_MENTIONS)
|
||||
get() = accountPreferences.getBoolean(KEY_AUTO_REFRESH_MENTIONS,
|
||||
DEFAULT_AUTO_REFRESH_MENTIONS)
|
||||
|
||||
val isAutoRefreshDirectMessagesEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_AUTO_REFRESH_DIRECT_MESSAGES, DEFAULT_AUTO_REFRESH_DIRECT_MESSAGES)
|
||||
get() = accountPreferences.getBoolean(KEY_AUTO_REFRESH_DIRECT_MESSAGES,
|
||||
DEFAULT_AUTO_REFRESH_DIRECT_MESSAGES)
|
||||
|
||||
val isAutoRefreshTrendsEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_AUTO_REFRESH_TRENDS, DEFAULT_AUTO_REFRESH_TRENDS)
|
||||
get() = accountPreferences.getBoolean(KEY_AUTO_REFRESH_TRENDS, DEFAULT_AUTO_REFRESH_TRENDS)
|
||||
|
||||
val isStreamingEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_ENABLE_STREAMING, false)
|
||||
get() = accountPreferences.getBoolean(KEY_ENABLE_STREAMING, false)
|
||||
|
||||
val isStreamHomeTimelineEnabled: Boolean
|
||||
get() = preferences.getBoolean("stream_home_timeline", true)
|
||||
get() = accountPreferences.getBoolean("stream_home_timeline", true)
|
||||
|
||||
val isStreamInteractionsEnabled: Boolean
|
||||
get() = preferences.getBoolean("stream_interactions", true)
|
||||
get() = accountPreferences.getBoolean("stream_interactions", true)
|
||||
|
||||
val isStreamDirectMessagesEnabled: Boolean
|
||||
get() = preferences.getBoolean("stream_direct_messages", true)
|
||||
get() = accountPreferences.getBoolean("stream_direct_messages", true)
|
||||
|
||||
val isStreamNotificationUsersEnabled: Boolean
|
||||
get() = preferences.getBoolean("stream_notification_users", true)
|
||||
get() = accountPreferences.getBoolean("stream_notification_users", true)
|
||||
|
||||
val isDirectMessagesNotificationEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_DIRECT_MESSAGES_NOTIFICATION, DEFAULT_DIRECT_MESSAGES_NOTIFICATION)
|
||||
get() = accountPreferences.getBoolean(KEY_DIRECT_MESSAGES_NOTIFICATION,
|
||||
DEFAULT_DIRECT_MESSAGES_NOTIFICATION)
|
||||
|
||||
val isHomeTimelineNotificationEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_HOME_TIMELINE_NOTIFICATION, DEFAULT_HOME_TIMELINE_NOTIFICATION)
|
||||
get() = accountPreferences.getBoolean(KEY_HOME_TIMELINE_NOTIFICATION,
|
||||
DEFAULT_HOME_TIMELINE_NOTIFICATION)
|
||||
|
||||
val isInteractionsNotificationEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_MENTIONS_NOTIFICATION, DEFAULT_MENTIONS_NOTIFICATION)
|
||||
get() = accountPreferences.getBoolean(KEY_MENTIONS_NOTIFICATION,
|
||||
DEFAULT_MENTIONS_NOTIFICATION)
|
||||
|
||||
val isNotificationFollowingOnly: Boolean
|
||||
get() = preferences.getBoolean(KEY_NOTIFICATION_FOLLOWING_ONLY, false)
|
||||
get() = accountPreferences.getBoolean(KEY_NOTIFICATION_FOLLOWING_ONLY, false)
|
||||
|
||||
val isNotificationMentionsOnly: Boolean
|
||||
get() = preferences.getBoolean(KEY_NOTIFICATION_MENTIONS_ONLY, false)
|
||||
get() = accountPreferences.getBoolean(KEY_NOTIFICATION_MENTIONS_ONLY, false)
|
||||
|
||||
val isNotificationEnabled: Boolean
|
||||
get() = preferences.getBoolean(KEY_NOTIFICATION, DEFAULT_NOTIFICATION)
|
||||
get() = accountPreferences.getBoolean(KEY_NOTIFICATION, DEFAULT_NOTIFICATION)
|
||||
|
||||
companion object {
|
||||
|
||||
fun getAccountPreferences(context: Context, accountKeys: Array<UserKey>): Array<AccountPreferences> {
|
||||
return Array(accountKeys.size) { AccountPreferences(context, accountKeys[it]) }
|
||||
fun getAccountPreferences(context: Context, preferences: SharedPreferences,
|
||||
accountKeys: Array<UserKey>): Array<AccountPreferences> {
|
||||
return Array(accountKeys.size) {
|
||||
AccountPreferences(context, preferences, accountKeys[it])
|
||||
}
|
||||
}
|
||||
|
||||
fun isNotificationHasLight(flags: Int): Boolean {
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.support.annotation.CallSuper
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v4.app.Fragment
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import org.mariotaku.twidere.annotation.CustomTabType
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.fragment.CustomTabsFragment.TabEditorDialogFragment
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.Tab
|
||||
import org.mariotaku.twidere.model.tab.impl.*
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
abstract class TabConfiguration {
|
||||
|
||||
abstract val name: StringHolder
|
||||
|
||||
abstract val icon: DrawableHolder
|
||||
|
||||
@get:TabAccountFlags
|
||||
abstract val accountFlags: Int
|
||||
|
||||
abstract val fragmentClass: Class<out Fragment>
|
||||
|
||||
open val isSingleTab: Boolean
|
||||
get() = false
|
||||
|
||||
open val sortPosition: Int
|
||||
get() = 0
|
||||
|
||||
open fun getExtraConfigurations(context: Context): Array<ExtraConfiguration>? {
|
||||
return null
|
||||
}
|
||||
|
||||
open fun applyExtraConfigurationTo(tab: Tab, extraConf: ExtraConfiguration): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
open fun readExtraConfigurationFrom(tab: Tab, extraConf: ExtraConfiguration): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
open fun checkAccountAvailability(details: AccountDetails): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
abstract class ExtraConfiguration {
|
||||
val key: String
|
||||
val title: StringHolder
|
||||
|
||||
var summary: StringHolder? = null
|
||||
var headerTitle: StringHolder? = null
|
||||
|
||||
var position: Int = 0
|
||||
var isMutable: Boolean = false
|
||||
|
||||
lateinit var context: Context
|
||||
private set
|
||||
|
||||
lateinit var view: View
|
||||
private set
|
||||
|
||||
protected constructor(key: String, title: StringHolder) {
|
||||
this.key = key
|
||||
this.title = title
|
||||
}
|
||||
|
||||
protected constructor(key: String, titleRes: Int) :this(key, StringHolder.resource(titleRes))
|
||||
|
||||
fun summary(summary: StringHolder): ExtraConfiguration {
|
||||
this.summary = summary
|
||||
return this
|
||||
}
|
||||
|
||||
fun summary(@StringRes summaryRes: Int): ExtraConfiguration {
|
||||
summary = StringHolder.resource(summaryRes)
|
||||
return this
|
||||
}
|
||||
|
||||
fun headerTitle(title: StringHolder?): ExtraConfiguration {
|
||||
headerTitle = title
|
||||
return this
|
||||
}
|
||||
|
||||
fun headerTitle(@StringRes titleRes: Int): ExtraConfiguration {
|
||||
headerTitle = StringHolder.resource(titleRes)
|
||||
return this
|
||||
}
|
||||
|
||||
fun mutable(mutable: Boolean): ExtraConfiguration {
|
||||
isMutable = mutable
|
||||
return this
|
||||
}
|
||||
|
||||
abstract fun onCreateView(context: Context, parent: ViewGroup): View
|
||||
|
||||
@CallSuper
|
||||
open fun onCreate(context: Context) {
|
||||
this.context = context
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
open fun onViewCreated(context: Context, view: View, fragment: TabEditorDialogFragment) {
|
||||
this.view = view
|
||||
}
|
||||
|
||||
open fun onActivityResult(fragment: TabEditorDialogFragment, requestCode: Int,
|
||||
resultCode: Int, data: Intent?) {
|
||||
|
||||
}
|
||||
|
||||
open fun onAccountSelectionChanged(account: AccountDetails?) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun all(): List<Pair<String, TabConfiguration>> {
|
||||
return allTypes().mapNotNull {
|
||||
val conf = ofType(it) ?: return@mapNotNull null
|
||||
return@mapNotNull Pair(it, conf)
|
||||
}
|
||||
}
|
||||
|
||||
fun allTypes(): Array<String> {
|
||||
return arrayOf(CustomTabType.HOME_TIMELINE, CustomTabType.NOTIFICATIONS_TIMELINE,
|
||||
CustomTabType.TRENDS_SUGGESTIONS, CustomTabType.DIRECT_MESSAGES,
|
||||
CustomTabType.FAVORITES, CustomTabType.USER_TIMELINE,
|
||||
CustomTabType.SEARCH_STATUSES, CustomTabType.LIST_TIMELINE,
|
||||
CustomTabType.PUBLIC_TIMELINE)
|
||||
}
|
||||
|
||||
fun ofType(@CustomTabType type: String): TabConfiguration? {
|
||||
when (type) {
|
||||
CustomTabType.HOME_TIMELINE -> return HomeTabConfiguration()
|
||||
CustomTabType.NOTIFICATIONS_TIMELINE -> return InteractionsTabConfiguration()
|
||||
CustomTabType.DIRECT_MESSAGES -> return MessagesTabConfiguration()
|
||||
CustomTabType.LIST_TIMELINE -> return UserListTimelineTabConfiguration()
|
||||
CustomTabType.FAVORITES -> return FavoriteTimelineTabConfiguration()
|
||||
CustomTabType.USER_TIMELINE -> return UserTimelineTabConfiguration()
|
||||
CustomTabType.TRENDS_SUGGESTIONS -> return TrendsTabConfiguration()
|
||||
CustomTabType.SEARCH_STATUSES -> return SearchTabConfiguration()
|
||||
CustomTabType.PUBLIC_TIMELINE -> return PublicTimelineTabConfiguration()
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import android.widget.TextView
|
|||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.fragment.CustomTabsFragment
|
||||
import org.mariotaku.twidere.model.tab.BooleanHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
|
||||
/**
|
||||
|
@ -17,8 +18,9 @@ import org.mariotaku.twidere.model.tab.TabConfiguration
|
|||
*/
|
||||
open class BooleanExtraConfiguration(
|
||||
key: String,
|
||||
title: StringHolder,
|
||||
val defaultValue: BooleanHolder
|
||||
) : TabConfiguration.ExtraConfiguration(key) {
|
||||
) : TabConfiguration.ExtraConfiguration(key, title) {
|
||||
|
||||
open var value: Boolean
|
||||
get() = checkBox.isChecked
|
||||
|
@ -28,7 +30,11 @@ open class BooleanExtraConfiguration(
|
|||
|
||||
private lateinit var checkBox: CheckBox
|
||||
|
||||
constructor(key: String, def: Boolean) : this(key, BooleanHolder.constant(def))
|
||||
constructor(key: String, title: StringHolder, def: Boolean) : this(key, title,
|
||||
BooleanHolder.constant(def))
|
||||
|
||||
constructor(key: String, title: Int, def: Boolean) : this(key, StringHolder.resource(title),
|
||||
BooleanHolder.constant(def))
|
||||
|
||||
override fun onCreateView(context: Context, parent: ViewGroup): View {
|
||||
return LayoutInflater.from(context).inflate(R.layout.layout_extra_config_checkbox, parent, false)
|
||||
|
|
|
@ -8,12 +8,14 @@ import android.widget.EditText
|
|||
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.fragment.CustomTabsFragment
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/12/5.
|
||||
*/
|
||||
class StringExtraConfiguration(key: String, private val def: String?) : TabConfiguration.ExtraConfiguration(key) {
|
||||
class StringExtraConfiguration(key: String, title: StringHolder, private val def: String?) :
|
||||
TabConfiguration.ExtraConfiguration(key, title) {
|
||||
var maxLines: Int = 0
|
||||
|
||||
var value: String?
|
||||
|
@ -22,6 +24,9 @@ class StringExtraConfiguration(key: String, private val def: String?) : TabConfi
|
|||
|
||||
private lateinit var editText: EditText
|
||||
|
||||
constructor(key: String, titleRes: Int, def: String?) : this(key,
|
||||
StringHolder.resource(titleRes), def)
|
||||
|
||||
override fun onCreateView(context: Context, parent: ViewGroup): View {
|
||||
return LayoutInflater.from(context).inflate(R.layout.layout_extra_config_text, parent, false)
|
||||
}
|
||||
|
|
|
@ -15,14 +15,16 @@ import org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT_KEY
|
|||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_LOCATION
|
||||
import org.mariotaku.twidere.fragment.CustomTabsFragment.TabEditorDialogFragment
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/12/5.
|
||||
*/
|
||||
open class TrendsLocationExtraConfiguration(
|
||||
key: String
|
||||
) : TabConfiguration.ExtraConfiguration(key) {
|
||||
key: String,
|
||||
title: StringHolder
|
||||
) : TabConfiguration.ExtraConfiguration(key, title) {
|
||||
|
||||
open var value: Place? = null
|
||||
set(value) {
|
||||
|
@ -37,6 +39,8 @@ open class TrendsLocationExtraConfiguration(
|
|||
|
||||
private lateinit var summaryView: TextView
|
||||
|
||||
constructor(key: String, titleRes: Int) : this(key, StringHolder.resource(titleRes))
|
||||
|
||||
override fun onCreateView(context: Context, parent: ViewGroup): View {
|
||||
return LayoutInflater.from(context).inflate(R.layout.layout_extra_config_checkbox, parent, false)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ import org.mariotaku.twidere.view.holder.SimpleUserViewHolder
|
|||
* Created by mariotaku on 2016/11/28.
|
||||
*/
|
||||
|
||||
class UserExtraConfiguration(key: String) : TabConfiguration.ExtraConfiguration(key) {
|
||||
class UserExtraConfiguration(key: String) : TabConfiguration.ExtraConfiguration(key,
|
||||
R.string.title_user) {
|
||||
var value: ParcelableUser? = null
|
||||
private set
|
||||
|
||||
|
@ -61,8 +62,8 @@ class UserExtraConfiguration(key: String) : TabConfiguration.ExtraConfiguration(
|
|||
override fun onActivityResult(fragment: TabEditorDialogFragment, requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
when (requestCode) {
|
||||
1 -> {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
val user: ParcelableUser = data!!.getParcelableExtra(EXTRA_USER)
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
val user: ParcelableUser = data.getParcelableExtra(EXTRA_USER)
|
||||
viewHolder.displayUser(user)
|
||||
viewHolder.itemView.visibility = View.VISIBLE
|
||||
hintView.visibility = View.GONE
|
||||
|
|
|
@ -23,7 +23,8 @@ import org.mariotaku.twidere.view.holder.SimpleUserListViewHolder
|
|||
* Created by mariotaku on 2016/11/28.
|
||||
*/
|
||||
|
||||
class UserListExtraConfiguration(key: String) : TabConfiguration.ExtraConfiguration(key) {
|
||||
class UserListExtraConfiguration(key: String) : TabConfiguration.ExtraConfiguration(key,
|
||||
R.string.title_user_list) {
|
||||
var value: ParcelableUserList? = null
|
||||
private set
|
||||
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import android.content.Context
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER
|
||||
import org.mariotaku.twidere.constant.iWantMyStarsBackKey
|
||||
import org.mariotaku.twidere.fragment.UserFavoritesFragment
|
||||
import org.mariotaku.twidere.model.Tab
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
import org.mariotaku.twidere.model.tab.argument.UserArguments
|
||||
import org.mariotaku.twidere.model.tab.conf.UserExtraConfiguration
|
||||
import org.mariotaku.twidere.util.dagger.DependencyHolder
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class FavoriteTimelineTabConfiguration : TabConfiguration() {
|
||||
|
||||
override val name = FavoriteStringHolder
|
||||
|
||||
override val icon = DrawableHolder.Builtin.FAVORITE
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or
|
||||
TabAccountFlags.FLAG_ACCOUNT_REQUIRED
|
||||
|
||||
override val fragmentClass = UserFavoritesFragment::class.java
|
||||
|
||||
override fun getExtraConfigurations(context: Context) = arrayOf(
|
||||
UserExtraConfiguration(EXTRA_USER).headerTitle(R.string.title_user)
|
||||
)
|
||||
|
||||
override fun applyExtraConfigurationTo(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val arguments = tab.arguments as UserArguments
|
||||
when (extraConf.key) {
|
||||
EXTRA_USER -> {
|
||||
val user = (extraConf as UserExtraConfiguration).value ?: return false
|
||||
arguments.setUserKey(user.key)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
object FavoriteStringHolder : StringHolder() {
|
||||
|
||||
override fun createString(context: Context): String {
|
||||
if (DependencyHolder.get(context).preferences[iWantMyStarsBackKey]) {
|
||||
return context.getString(R.string.title_favorites)
|
||||
}
|
||||
return context.getString(R.string.title_likes)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import android.content.Context
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.constant.IntentConstants.*
|
||||
import org.mariotaku.twidere.fragment.HomeTimelineFragment
|
||||
import org.mariotaku.twidere.model.Tab
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
import org.mariotaku.twidere.model.tab.conf.BooleanExtraConfiguration
|
||||
import org.mariotaku.twidere.model.tab.extra.HomeTabExtras
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class HomeTabConfiguration : TabConfiguration() {
|
||||
|
||||
override val name = StringHolder.resource(R.string.title_home)
|
||||
|
||||
override val icon = DrawableHolder.Builtin.HOME
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or
|
||||
TabAccountFlags.FLAG_ACCOUNT_MULTIPLE or TabAccountFlags.FLAG_ACCOUNT_MUTABLE
|
||||
|
||||
override val fragmentClass = HomeTimelineFragment::class.java
|
||||
|
||||
override fun getExtraConfigurations(context: Context) = arrayOf(
|
||||
BooleanExtraConfiguration(EXTRA_HIDE_RETWEETS, R.string.hide_retweets, false).mutable(true),
|
||||
BooleanExtraConfiguration(EXTRA_HIDE_QUOTES, R.string.hide_quotes, false).mutable(true),
|
||||
BooleanExtraConfiguration(EXTRA_HIDE_REPLIES, R.string.hide_replies, false).mutable(true)
|
||||
)
|
||||
|
||||
override fun applyExtraConfigurationTo(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val extras = tab.extras as HomeTabExtras
|
||||
when (extraConf.key) {
|
||||
EXTRA_HIDE_RETWEETS -> {
|
||||
extras.isHideRetweets = (extraConf as BooleanExtraConfiguration).value
|
||||
}
|
||||
EXTRA_HIDE_QUOTES -> {
|
||||
extras.isHideQuotes = (extraConf as BooleanExtraConfiguration).value
|
||||
}
|
||||
EXTRA_HIDE_REPLIES -> {
|
||||
extras.isHideReplies = (extraConf as BooleanExtraConfiguration).value
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun readExtraConfigurationFrom(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val extras = tab.extras as? HomeTabExtras ?: return false
|
||||
when (extraConf.key) {
|
||||
EXTRA_HIDE_RETWEETS -> {
|
||||
(extraConf as BooleanExtraConfiguration).value = extras.isHideRetweets
|
||||
}
|
||||
EXTRA_HIDE_QUOTES -> {
|
||||
(extraConf as BooleanExtraConfiguration).value = extras.isHideQuotes
|
||||
}
|
||||
EXTRA_HIDE_REPLIES -> {
|
||||
(extraConf as BooleanExtraConfiguration).value = extras.isHideReplies
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
import android.widget.TextView
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_MENTIONS_ONLY
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_MY_FOLLOWING_ONLY
|
||||
import org.mariotaku.twidere.extension.model.isOfficial
|
||||
import org.mariotaku.twidere.fragment.InteractionsTimelineFragment
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.Tab
|
||||
import org.mariotaku.twidere.model.tab.BooleanHolder
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
import org.mariotaku.twidere.model.tab.conf.BooleanExtraConfiguration
|
||||
import org.mariotaku.twidere.model.tab.extra.InteractionsTabExtras
|
||||
import org.mariotaku.twidere.model.util.AccountUtils
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class InteractionsTabConfiguration : TabConfiguration() {
|
||||
|
||||
override val name = StringHolder.resource(R.string.interactions)
|
||||
|
||||
override val icon = DrawableHolder.Builtin.NOTIFICATIONS
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or
|
||||
TabAccountFlags.FLAG_ACCOUNT_MULTIPLE or TabAccountFlags.FLAG_ACCOUNT_MUTABLE
|
||||
|
||||
override val fragmentClass = InteractionsTimelineFragment::class.java
|
||||
|
||||
override fun getExtraConfigurations(context: Context) = arrayOf(
|
||||
BooleanExtraConfiguration(EXTRA_MY_FOLLOWING_ONLY, R.string.following_only, false).mutable(true),
|
||||
MentionsOnlyExtraConfiguration(EXTRA_MENTIONS_ONLY).mutable(true)
|
||||
)
|
||||
|
||||
override fun applyExtraConfigurationTo(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val extras = tab.extras as InteractionsTabExtras
|
||||
when (extraConf.key) {
|
||||
EXTRA_MY_FOLLOWING_ONLY -> {
|
||||
extras.isMyFollowingOnly = (extraConf as BooleanExtraConfiguration).value
|
||||
}
|
||||
EXTRA_MENTIONS_ONLY -> {
|
||||
extras.isMentionsOnly = (extraConf as BooleanExtraConfiguration).value
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun readExtraConfigurationFrom(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val extras = tab.extras as? InteractionsTabExtras ?: return false
|
||||
when (extraConf.key) {
|
||||
EXTRA_MY_FOLLOWING_ONLY -> {
|
||||
(extraConf as BooleanExtraConfiguration).value = extras.isMyFollowingOnly
|
||||
}
|
||||
EXTRA_MENTIONS_ONLY -> {
|
||||
(extraConf as BooleanExtraConfiguration).value = extras.isMentionsOnly
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private class MentionsOnlyExtraConfiguration(key: String) : BooleanExtraConfiguration(key,
|
||||
StringHolder.resource(R.string.mentions_only),
|
||||
MentionsOnlyExtraConfiguration.HasOfficialBooleanHolder()) {
|
||||
|
||||
private var valueBackup: Boolean = false
|
||||
|
||||
override fun onAccountSelectionChanged(account: AccountDetails?) {
|
||||
val hasOfficial: Boolean
|
||||
if (account == null || account.dummy) {
|
||||
hasOfficial = AccountUtils.hasOfficialKeyAccount(context)
|
||||
} else {
|
||||
hasOfficial = account.isOfficial(context)
|
||||
}
|
||||
(defaultValue as HasOfficialBooleanHolder).hasOfficial = hasOfficial
|
||||
val checkBox = view.findViewById(android.R.id.checkbox) as CheckBox
|
||||
val titleView = view.findViewById(android.R.id.title) as TextView
|
||||
val summaryView = view.findViewById(android.R.id.summary) as TextView
|
||||
view.isEnabled = hasOfficial
|
||||
titleView.isEnabled = hasOfficial
|
||||
summaryView.isEnabled = hasOfficial
|
||||
checkBox.isEnabled = hasOfficial
|
||||
if (hasOfficial) {
|
||||
checkBox.isChecked = valueBackup
|
||||
summaryView.visibility = View.GONE
|
||||
} else {
|
||||
valueBackup = checkBox.isChecked
|
||||
checkBox.isChecked = true
|
||||
summaryView.setText(R.string.summary_interactions_not_available)
|
||||
summaryView.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
override var value: Boolean
|
||||
get() {
|
||||
if ((defaultValue as HasOfficialBooleanHolder).hasOfficial) {
|
||||
return super.value
|
||||
}
|
||||
return valueBackup
|
||||
}
|
||||
set(value) {
|
||||
super.value = value
|
||||
}
|
||||
|
||||
private class HasOfficialBooleanHolder : BooleanHolder() {
|
||||
|
||||
var hasOfficial: Boolean = false
|
||||
|
||||
override fun createBoolean(context: Context): Boolean {
|
||||
return hasOfficial
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.fragment.message.MessagesEntriesFragment
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class MessagesTabConfiguration : TabConfiguration() {
|
||||
override val name = StringHolder.resource(R.string.title_direct_messages)
|
||||
|
||||
override val icon = DrawableHolder.Builtin.MESSAGE
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or
|
||||
TabAccountFlags.FLAG_ACCOUNT_MULTIPLE or TabAccountFlags.FLAG_ACCOUNT_MUTABLE
|
||||
|
||||
override val fragmentClass = MessagesEntriesFragment::class.java
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.fragment.PublicTimelineFragment
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class PublicTimelineTabConfiguration : TabConfiguration() {
|
||||
|
||||
override val name = StringHolder.resource(R.string.title_public_timeline)
|
||||
|
||||
override val icon = DrawableHolder.Builtin.QUOTE
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or
|
||||
TabAccountFlags.FLAG_ACCOUNT_REQUIRED or TabAccountFlags.FLAG_ACCOUNT_MUTABLE
|
||||
|
||||
override val fragmentClass = PublicTimelineFragment::class.java
|
||||
|
||||
override fun checkAccountAvailability(details: AccountDetails): Boolean {
|
||||
return AccountType.FANFOU == details.type || AccountType.STATUSNET == details.type
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import android.content.Context
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_QUERY
|
||||
import org.mariotaku.twidere.fragment.StatusesSearchFragment
|
||||
import org.mariotaku.twidere.model.Tab
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
import org.mariotaku.twidere.model.tab.argument.TextQueryArguments
|
||||
import org.mariotaku.twidere.model.tab.conf.StringExtraConfiguration
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class SearchTabConfiguration : TabConfiguration() {
|
||||
|
||||
override val name = StringHolder.resource(R.string.action_search)
|
||||
|
||||
override val icon = DrawableHolder.Builtin.SEARCH
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or TabAccountFlags.FLAG_ACCOUNT_REQUIRED
|
||||
|
||||
override val fragmentClass = StatusesSearchFragment::class.java
|
||||
|
||||
override fun getExtraConfigurations(context: Context) = arrayOf(
|
||||
StringExtraConfiguration(EXTRA_QUERY, R.string.search_statuses, null).maxLines(1).headerTitle(R.string.query)
|
||||
)
|
||||
|
||||
override fun applyExtraConfigurationTo(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val arguments = tab.arguments as TextQueryArguments
|
||||
when (extraConf.key) {
|
||||
EXTRA_QUERY -> {
|
||||
val query = (extraConf as StringExtraConfiguration).value ?: return false
|
||||
arguments.query = query
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun readExtraConfigurationFrom(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val arguments = tab.arguments as? TextQueryArguments ?: return false
|
||||
when (extraConf.key) {
|
||||
EXTRA_QUERY -> {
|
||||
(extraConf as StringExtraConfiguration).value = arguments.query
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import android.content.Context
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_PLACE
|
||||
import org.mariotaku.twidere.fragment.TrendsSuggestionsFragment
|
||||
import org.mariotaku.twidere.model.Tab
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
import org.mariotaku.twidere.model.tab.conf.TrendsLocationExtraConfiguration
|
||||
import org.mariotaku.twidere.model.tab.extra.TrendsTabExtras
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class TrendsTabConfiguration : TabConfiguration() {
|
||||
|
||||
override val name = StringHolder.resource(R.string.trends)
|
||||
|
||||
override val icon = DrawableHolder.Builtin.HASHTAG
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or
|
||||
TabAccountFlags.FLAG_ACCOUNT_REQUIRED or TabAccountFlags.FLAG_ACCOUNT_MUTABLE
|
||||
|
||||
override val fragmentClass = TrendsSuggestionsFragment::class.java
|
||||
|
||||
override fun getExtraConfigurations(context: Context) = arrayOf(
|
||||
TrendsLocationExtraConfiguration(EXTRA_PLACE, R.string.trends_location).mutable(true)
|
||||
)
|
||||
|
||||
override fun applyExtraConfigurationTo(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val extras = tab.extras as TrendsTabExtras
|
||||
when (extraConf.key) {
|
||||
EXTRA_PLACE -> {
|
||||
val conf = extraConf as TrendsLocationExtraConfiguration
|
||||
val place = conf.value
|
||||
if (place != null) {
|
||||
extras.woeId = place.woeId
|
||||
extras.placeName = place.name
|
||||
} else {
|
||||
extras.woeId = 0
|
||||
extras.placeName = null
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun readExtraConfigurationFrom(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val extras = tab.extras as? TrendsTabExtras ?: return false
|
||||
when (extraConf.key) {
|
||||
EXTRA_PLACE -> {
|
||||
val woeId = extras.woeId
|
||||
val name = extras.placeName
|
||||
if (name != null) {
|
||||
val place = TrendsLocationExtraConfiguration.Place(woeId, name)
|
||||
(extraConf as TrendsLocationExtraConfiguration).value = place
|
||||
} else {
|
||||
(extraConf as TrendsLocationExtraConfiguration).value = null
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import android.content.Context
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER_LIST
|
||||
import org.mariotaku.twidere.fragment.UserListTimelineFragment
|
||||
import org.mariotaku.twidere.model.Tab
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
import org.mariotaku.twidere.model.tab.argument.UserListArguments
|
||||
import org.mariotaku.twidere.model.tab.conf.UserListExtraConfiguration
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class UserListTimelineTabConfiguration : TabConfiguration() {
|
||||
|
||||
override val name = StringHolder.resource(R.string.list_timeline)
|
||||
|
||||
override val icon = DrawableHolder.Builtin.LIST
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or
|
||||
TabAccountFlags.FLAG_ACCOUNT_REQUIRED
|
||||
|
||||
override val fragmentClass = UserListTimelineFragment::class.java
|
||||
|
||||
override fun getExtraConfigurations(context: Context) = arrayOf(
|
||||
UserListExtraConfiguration(EXTRA_USER_LIST).headerTitle(R.string.title_user_list)
|
||||
)
|
||||
|
||||
override fun applyExtraConfigurationTo(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val arguments = tab.arguments as UserListArguments
|
||||
when (extraConf.key) {
|
||||
EXTRA_USER_LIST -> {
|
||||
val userList = (extraConf as UserListExtraConfiguration).value ?: return false
|
||||
arguments.listId = userList.id
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.tab.impl
|
||||
|
||||
import android.content.Context
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.TabAccountFlags
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER
|
||||
import org.mariotaku.twidere.fragment.UserTimelineFragment
|
||||
import org.mariotaku.twidere.model.Tab
|
||||
import org.mariotaku.twidere.model.tab.DrawableHolder
|
||||
import org.mariotaku.twidere.model.tab.StringHolder
|
||||
import org.mariotaku.twidere.model.tab.TabConfiguration
|
||||
import org.mariotaku.twidere.model.tab.argument.UserArguments
|
||||
import org.mariotaku.twidere.model.tab.conf.UserExtraConfiguration
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/11/27.
|
||||
*/
|
||||
|
||||
class UserTimelineTabConfiguration : TabConfiguration() {
|
||||
|
||||
override val name = StringHolder.resource(R.string.users_statuses)
|
||||
|
||||
override val icon = DrawableHolder.Builtin.USER
|
||||
|
||||
override val accountFlags = TabAccountFlags.FLAG_HAS_ACCOUNT or TabAccountFlags.FLAG_ACCOUNT_REQUIRED
|
||||
|
||||
override val fragmentClass = UserTimelineFragment::class.java
|
||||
|
||||
override fun getExtraConfigurations(context: Context) = arrayOf(
|
||||
UserExtraConfiguration(EXTRA_USER).headerTitle(R.string.title_user)
|
||||
)
|
||||
|
||||
override fun applyExtraConfigurationTo(tab: Tab, extraConf: TabConfiguration.ExtraConfiguration): Boolean {
|
||||
val arguments = tab.arguments as UserArguments
|
||||
when (extraConf.key) {
|
||||
EXTRA_USER -> {
|
||||
val user = (extraConf as UserExtraConfiguration).value ?: return false
|
||||
arguments.setUserKey(user.key)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.provider
|
|||
|
||||
import android.content.ContentProvider
|
||||
import android.content.ContentValues
|
||||
import android.content.SharedPreferences
|
||||
import android.database.Cursor
|
||||
import android.database.MatrixCursor
|
||||
import android.database.SQLException
|
||||
|
@ -65,7 +66,7 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
|
|||
@Inject
|
||||
lateinit internal var notificationManager: NotificationManagerWrapper
|
||||
@Inject
|
||||
lateinit internal var preferences: SharedPreferencesWrapper
|
||||
lateinit internal var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit internal var dns: Dns
|
||||
@Inject
|
||||
|
@ -461,7 +462,8 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
|
|||
TABLE_ID_STATUSES -> {
|
||||
if (!uri.getBooleanQueryParameter(QUERY_PARAM_SHOW_NOTIFICATION, true)) return
|
||||
backgroundExecutor.execute {
|
||||
val prefs = AccountPreferences.getAccountPreferences(context, DataStoreUtils.getAccountKeys(context))
|
||||
val prefs = AccountPreferences.getAccountPreferences(context, preferences,
|
||||
DataStoreUtils.getAccountKeys(context))
|
||||
prefs.filter { it.isNotificationEnabled && it.isHomeTimelineNotificationEnabled }.forEach {
|
||||
val positionTag = getPositionTag(CustomTabType.HOME_TIMELINE, it.accountKey)
|
||||
contentNotificationManager.showTimeline(it, positionTag)
|
||||
|
@ -472,7 +474,8 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
|
|||
TABLE_ID_ACTIVITIES_ABOUT_ME -> {
|
||||
if (!uri.getBooleanQueryParameter(QUERY_PARAM_SHOW_NOTIFICATION, true)) return
|
||||
backgroundExecutor.execute {
|
||||
val prefs = AccountPreferences.getAccountPreferences(context, DataStoreUtils.getAccountKeys(context))
|
||||
val prefs = AccountPreferences.getAccountPreferences(context, preferences,
|
||||
DataStoreUtils.getAccountKeys(context))
|
||||
prefs.filter { it.isNotificationEnabled && it.isInteractionsNotificationEnabled }.forEach {
|
||||
val positionTag = getPositionTag(ReadPositionTag.ACTIVITIES_ABOUT_ME, it.accountKey)
|
||||
contentNotificationManager.showInteractions(it, positionTag)
|
||||
|
@ -483,7 +486,8 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
|
|||
TABLE_ID_MESSAGES_CONVERSATIONS -> {
|
||||
if (!uri.getBooleanQueryParameter(QUERY_PARAM_SHOW_NOTIFICATION, true)) return
|
||||
backgroundExecutor.execute {
|
||||
val prefs = AccountPreferences.getAccountPreferences(context, DataStoreUtils.getAccountKeys(context))
|
||||
val prefs = AccountPreferences.getAccountPreferences(context, preferences,
|
||||
DataStoreUtils.getAccountKeys(context))
|
||||
prefs.filter { it.isNotificationEnabled && it.isDirectMessagesNotificationEnabled }.forEach {
|
||||
contentNotificationManager.showMessages(it)
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.mariotaku.twidere.service
|
||||
|
||||
import android.app.IntentService
|
||||
import android.content.SharedPreferences
|
||||
import com.twitter.Extractor
|
||||
import com.twitter.Validator
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper
|
||||
import org.mariotaku.twidere.util.NotificationManagerWrapper
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import javax.inject.Inject
|
||||
|
@ -13,7 +13,7 @@ import javax.inject.Inject
|
|||
abstract class BaseIntentService(tag: String) : IntentService(tag) {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var twitterWrapper: AsyncTwitterWrapper
|
||||
@Inject
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.service
|
||||
|
||||
import android.app.Service
|
||||
import android.content.SharedPreferences
|
||||
import android.net.ConnectivityManager
|
||||
import com.twitter.Extractor
|
||||
import com.twitter.Validator
|
||||
|
@ -30,7 +31,7 @@ import javax.inject.Inject
|
|||
abstract class BaseService : Service() {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var twitterWrapper: AsyncTwitterWrapper
|
||||
@Inject
|
||||
|
|
|
@ -40,6 +40,7 @@ import nl.komponents.kovenant.task
|
|||
import nl.komponents.kovenant.ui.successUi
|
||||
import org.mariotaku.abstask.library.AbstractTask
|
||||
import org.mariotaku.abstask.library.ManualTaskStarter
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.configure
|
||||
import org.mariotaku.ktextension.toLongOr
|
||||
import org.mariotaku.ktextension.toTypedArray
|
||||
|
@ -55,6 +56,7 @@ import org.mariotaku.restfu.http.mime.SimpleBody
|
|||
import org.mariotaku.sqliteqb.library.Expression
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.constant.refreshAfterTweetKey
|
||||
import org.mariotaku.twidere.model.*
|
||||
import org.mariotaku.twidere.model.draft.SendDirectMessageActionExtras
|
||||
import org.mariotaku.twidere.model.draft.StatusObjectActionExtras
|
||||
|
@ -318,7 +320,7 @@ class LengthyOperationsService : BaseIntentService("lengthy_operations") {
|
|||
})
|
||||
}
|
||||
}
|
||||
if (preferences.getBoolean(KEY_REFRESH_AFTER_TWEET)) {
|
||||
if (preferences[refreshAfterTweetKey]) {
|
||||
handler.post { twitterWrapper.refreshAll() }
|
||||
}
|
||||
stopForeground(false)
|
||||
|
|
|
@ -133,7 +133,7 @@ class StreamingService : BaseService() {
|
|||
private fun updateStreamingInstances(): Boolean {
|
||||
val am = AccountManager.get(this)
|
||||
val supportedAccounts = AccountUtils.getAllAccountDetails(am, true).filter { it.isStreamingSupported }
|
||||
val supportedPrefs = supportedAccounts.map { AccountPreferences(this, it.key) }
|
||||
val supportedPrefs = supportedAccounts.map { AccountPreferences(this, preferences, it.key) }
|
||||
val enabledAccounts = supportedAccounts.filter { account ->
|
||||
return@filter supportedPrefs.any {
|
||||
account.key == it.accountKey && it.isStreamingEnabled
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package org.mariotaku.twidere.task
|
||||
|
||||
import android.content.Context
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.mapToArray
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NAME_FIRST
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.ParcelableUserList
|
||||
import org.mariotaku.twidere.model.SingleResponse
|
||||
|
@ -43,7 +44,7 @@ class AddUserListMembersTask(
|
|||
val message: String
|
||||
if (users.size == 1) {
|
||||
val user = users.first()
|
||||
val nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
|
||||
val nameFirst = preferences[nameFirstKey]
|
||||
val displayName = userColorNameManager.getDisplayName(user.key, user.name,
|
||||
user.screen_name, nameFirst)
|
||||
message = context.getString(R.string.message_toast_added_user_to_list, displayName, result.data.name)
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package org.mariotaku.twidere.task
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.squareup.otto.Bus
|
||||
import com.twitter.Extractor
|
||||
import org.mariotaku.abstask.library.AbstractTask
|
||||
import org.mariotaku.kpreferences.KPreferences
|
||||
import org.mariotaku.twidere.model.DefaultFeatures
|
||||
import org.mariotaku.twidere.util.*
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper
|
||||
import org.mariotaku.twidere.util.ErrorInfoStore
|
||||
import org.mariotaku.twidere.util.ReadStateManager
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.util.media.MediaPreloader
|
||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
|
@ -27,7 +31,7 @@ abstract class BaseAbstractTask<Params, Result, Callback>(val context: Context)
|
|||
@Inject
|
||||
lateinit var mediaPreloader: MediaPreloader
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var kPreferences: KPreferences
|
||||
@Inject
|
||||
|
|
|
@ -20,17 +20,14 @@
|
|||
package org.mariotaku.twidere.task
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.AsyncTask
|
||||
|
||||
import com.squareup.otto.Bus
|
||||
|
||||
import org.mariotaku.twidere.model.event.TaskStateChangedEvent
|
||||
import org.mariotaku.twidere.util.AsyncTaskManager
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class ManagedAsyncTask<Params, Progress, Result> @JvmOverloads constructor(
|
||||
|
@ -45,7 +42,7 @@ abstract class ManagedAsyncTask<Params, Progress, Result> @JvmOverloads construc
|
|||
@Inject
|
||||
lateinit var userColorNameManager: UserColorNameManager
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
@Inject
|
||||
lateinit var asyncTwitterWrapper: AsyncTwitterWrapper
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.util
|
|||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import com.squareup.otto.Bus
|
||||
import com.squareup.otto.Subscribe
|
||||
|
@ -36,7 +37,9 @@ import org.mariotaku.microblog.library.twitter.model.*
|
|||
import org.mariotaku.sqliteqb.library.Expression
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants
|
||||
import org.mariotaku.twidere.constant.homeRefreshDirectMessagesKey
|
||||
import org.mariotaku.twidere.constant.homeRefreshMentionsKey
|
||||
import org.mariotaku.twidere.constant.homeRefreshSavedSearchesKey
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
import org.mariotaku.twidere.model.*
|
||||
import org.mariotaku.twidere.model.event.*
|
||||
|
@ -56,7 +59,7 @@ import java.util.*
|
|||
class AsyncTwitterWrapper(
|
||||
val context: Context,
|
||||
private val bus: Bus,
|
||||
private val preferences: SharedPreferencesWrapper,
|
||||
private val preferences: SharedPreferences,
|
||||
private val asyncTaskManager: AsyncTaskManager,
|
||||
private val notificationManager: NotificationManagerWrapper
|
||||
) {
|
||||
|
@ -280,7 +283,7 @@ class AsyncTwitterWrapper(
|
|||
accountKeys.toNulls())
|
||||
}
|
||||
})
|
||||
if (preferences.getBoolean(SharedPreferenceConstants.KEY_HOME_REFRESH_MENTIONS)) {
|
||||
if (preferences[homeRefreshMentionsKey]) {
|
||||
getActivitiesAboutMeAsync(object : SimpleRefreshTaskParam() {
|
||||
override val accountKeys: Array<UserKey> by lazy { action() }
|
||||
|
||||
|
@ -290,12 +293,12 @@ class AsyncTwitterWrapper(
|
|||
}
|
||||
})
|
||||
}
|
||||
if (preferences.getBoolean(SharedPreferenceConstants.KEY_HOME_REFRESH_DIRECT_MESSAGES)) {
|
||||
if (preferences[homeRefreshDirectMessagesKey]) {
|
||||
getMessagesAsync(object : GetMessagesTask.RefreshMessagesTaskParam(context) {
|
||||
override val accountKeys: Array<UserKey> by lazy { action() }
|
||||
})
|
||||
}
|
||||
if (preferences.getBoolean(SharedPreferenceConstants.KEY_HOME_REFRESH_SAVED_SEARCHES)) {
|
||||
if (preferences[homeRefreshSavedSearchesKey]) {
|
||||
getSavedSearchesAsync(action())
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package org.mariotaku.twidere.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.util.Base64
|
||||
import okhttp3.*
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.toIntOr
|
||||
import org.mariotaku.restfu.http.RestHttpClient
|
||||
import org.mariotaku.restfu.okhttp3.OkHttpRestClient
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.*
|
||||
import org.mariotaku.twidere.constant.cacheSizeLimitKey
|
||||
import org.mariotaku.twidere.util.dagger.DependencyHolder
|
||||
import java.io.IOException
|
||||
import java.net.InetSocketAddress
|
||||
|
@ -41,12 +44,12 @@ object HttpClientFactory {
|
|||
builder.cache(cache)
|
||||
}
|
||||
|
||||
class HttpClientConfiguration(val prefs: SharedPreferencesWrapper) {
|
||||
class HttpClientConfiguration(val prefs: SharedPreferences) {
|
||||
|
||||
var readTimeoutSecs: Long = -1
|
||||
var writeTimeoutSecs: Long = -1
|
||||
var connectionTimeoutSecs: Long = prefs.getInt(KEY_CONNECTION_TIMEOUT, 10).toLong()
|
||||
var cacheSize: Int = prefs.getInt(KEY_CACHE_SIZE_LIMIT, 300).coerceIn(100..500)
|
||||
var cacheSize: Int = prefs[cacheSizeLimitKey]
|
||||
|
||||
internal fun applyTo(builder: OkHttpClient.Builder) {
|
||||
if (connectionTimeoutSecs >= 0) {
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.mariotaku.twidere.annotation.ReadPositionTag
|
|||
|
||||
class ReadStateManager(context: Context) {
|
||||
|
||||
private val preferences = SharedPreferencesWrapper.getInstance(context,
|
||||
TIMELINE_POSITIONS_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
private val preferences = context.getSharedPreferences(TIMELINE_POSITIONS_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE)
|
||||
|
||||
fun getPosition(key: String): Long {
|
||||
if (TextUtils.isEmpty(key)) return -1
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.Constants
|
||||
|
@ -32,7 +33,8 @@ import org.mariotaku.twidere.model.util.ParcelableMediaUtils
|
|||
/**
|
||||
* Created by mariotaku on 15/4/6.
|
||||
*/
|
||||
class StatusAdapterLinkClickHandler<D>(context: Context, preferences: SharedPreferencesWrapper) : OnLinkClickHandler(context, null, preferences), Constants {
|
||||
class StatusAdapterLinkClickHandler<D>(context: Context, preferences: SharedPreferences) :
|
||||
OnLinkClickHandler(context, null, preferences), Constants {
|
||||
|
||||
private var adapter: IStatusesAdapter<D>? = null
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package org.mariotaku.twidere.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.support.annotation.StringDef
|
||||
import android.util.Log
|
||||
import com.squareup.otto.Bus
|
||||
import org.mariotaku.abstask.library.AbstractTask
|
||||
import org.mariotaku.abstask.library.TaskStarter
|
||||
import org.mariotaku.kpreferences.KPreferences
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.mapToArray
|
||||
import org.mariotaku.ktextension.toNulls
|
||||
import org.mariotaku.twidere.TwidereConstants.LOGTAG
|
||||
|
@ -29,7 +30,7 @@ import org.mariotaku.twidere.task.twitter.message.GetMessagesTask
|
|||
|
||||
class TaskServiceRunner(
|
||||
val context: Context,
|
||||
val preferences: KPreferences,
|
||||
val preferences: SharedPreferences,
|
||||
val bus: Bus
|
||||
) {
|
||||
|
||||
|
@ -59,14 +60,16 @@ class TaskServiceRunner(
|
|||
when (action) {
|
||||
ACTION_REFRESH_HOME_TIMELINE -> {
|
||||
val task = GetHomeTimelineTask(context)
|
||||
task.params = AutoRefreshTaskParam(context, AccountPreferences::isAutoRefreshHomeTimelineEnabled) { accountKeys ->
|
||||
task.params = AutoRefreshTaskParam(context, preferences,
|
||||
AccountPreferences::isAutoRefreshHomeTimelineEnabled) { accountKeys ->
|
||||
DataStoreUtils.getNewestStatusIds(context, Statuses.CONTENT_URI, accountKeys.toNulls())
|
||||
}
|
||||
return task
|
||||
}
|
||||
ACTION_REFRESH_NOTIFICATIONS -> {
|
||||
val task = GetActivitiesAboutMeTask(context)
|
||||
task.params = AutoRefreshTaskParam(context, AccountPreferences::isAutoRefreshMentionsEnabled) { accountKeys ->
|
||||
task.params = AutoRefreshTaskParam(context, preferences,
|
||||
AccountPreferences::isAutoRefreshMentionsEnabled) { accountKeys ->
|
||||
DataStoreUtils.getRefreshNewestActivityMaxPositions(context,
|
||||
Activities.AboutMe.CONTENT_URI, accountKeys.toNulls())
|
||||
}
|
||||
|
@ -76,7 +79,8 @@ class TaskServiceRunner(
|
|||
val task = GetMessagesTask(context)
|
||||
task.params = object : GetMessagesTask.RefreshNewTaskParam(context) {
|
||||
override val accountKeys: Array<UserKey> by lazy {
|
||||
AccountPreferences.getAccountPreferences(context, DataStoreUtils.getAccountKeys(context)).filter {
|
||||
AccountPreferences.getAccountPreferences(context, preferences,
|
||||
DataStoreUtils.getAccountKeys(context)).filter {
|
||||
it.isAutoRefreshEnabled && it.isAutoRefreshDirectMessagesEnabled
|
||||
}.mapToArray(AccountPreferences::accountKey)
|
||||
}
|
||||
|
@ -98,11 +102,13 @@ class TaskServiceRunner(
|
|||
|
||||
class AutoRefreshTaskParam(
|
||||
val context: Context,
|
||||
val preferences: SharedPreferences,
|
||||
val refreshable: (AccountPreferences) -> Boolean,
|
||||
val getSinceIds: (Array<UserKey>) -> Array<String?>?
|
||||
) : SimpleRefreshTaskParam() {
|
||||
override val accountKeys: Array<UserKey> by lazy {
|
||||
return@lazy AccountPreferences.getAccountPreferences(context, DataStoreUtils.getAccountKeys(context)).filter {
|
||||
return@lazy AccountPreferences.getAccountPreferences(context, preferences,
|
||||
DataStoreUtils.getAccountKeys(context)).filter {
|
||||
it.isAutoRefreshEnabled && refreshable(it)
|
||||
}.mapToArray(AccountPreferences::accountKey)
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.util.dagger
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.location.LocationManager
|
||||
import android.net.ConnectivityManager
|
||||
import android.os.Build
|
||||
|
@ -45,7 +46,6 @@ import org.mariotaku.mediaviewer.library.FileCache
|
|||
import org.mariotaku.mediaviewer.library.MediaDownloader
|
||||
import org.mariotaku.restfu.http.RestHttpClient
|
||||
import org.mariotaku.twidere.Constants
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_CACHE_SIZE_LIMIT
|
||||
import org.mariotaku.twidere.constant.autoRefreshCompatibilityModeKey
|
||||
import org.mariotaku.twidere.model.DefaultFeatures
|
||||
|
@ -86,7 +86,7 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun externalThemeManager(preferences: SharedPreferencesWrapper): ExternalThemeManager {
|
||||
fun externalThemeManager(preferences: SharedPreferences): ExternalThemeManager {
|
||||
return ExternalThemeManager(context, preferences)
|
||||
}
|
||||
|
||||
|
@ -98,14 +98,13 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun sharedPreferences(): SharedPreferencesWrapper {
|
||||
return SharedPreferencesWrapper.getInstance(context, Constants.SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE, SharedPreferenceConstants::class.java)
|
||||
fun sharedPreferences(): SharedPreferences {
|
||||
return context.getSharedPreferences(Constants.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun kPreferences(sharedPreferences: SharedPreferencesWrapper): KPreferences {
|
||||
fun kPreferences(sharedPreferences: SharedPreferences): KPreferences {
|
||||
return KPreferences(sharedPreferences)
|
||||
}
|
||||
|
||||
|
@ -129,7 +128,7 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun restHttpClient(prefs: SharedPreferencesWrapper, dns: Dns,
|
||||
fun restHttpClient(prefs: SharedPreferences, dns: Dns,
|
||||
connectionPool: ConnectionPool, cache: Cache): RestHttpClient {
|
||||
val conf = HttpClientFactory.HttpClientConfiguration(prefs)
|
||||
return HttpClientFactory.createRestHttpClient(conf, dns, connectionPool, cache)
|
||||
|
@ -161,7 +160,7 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun asyncTwitterWrapper(bus: Bus, preferences: SharedPreferencesWrapper,
|
||||
fun asyncTwitterWrapper(bus: Bus, preferences: SharedPreferences,
|
||||
asyncTaskManager: AsyncTaskManager, notificationManagerWrapper: NotificationManagerWrapper): AsyncTwitterWrapper {
|
||||
return AsyncTwitterWrapper(context, bus, preferences, asyncTaskManager, notificationManagerWrapper)
|
||||
}
|
||||
|
@ -175,13 +174,14 @@ class ApplicationModule(private val context: Context) {
|
|||
@Provides
|
||||
@Singleton
|
||||
fun contentNotificationManager(activityTracker: ActivityTracker, userColorNameManager: UserColorNameManager,
|
||||
notificationManagerWrapper: NotificationManagerWrapper, preferences: SharedPreferencesWrapper): ContentNotificationManager {
|
||||
notificationManagerWrapper: NotificationManagerWrapper,
|
||||
preferences: SharedPreferences): ContentNotificationManager {
|
||||
return ContentNotificationManager(context, activityTracker, userColorNameManager, notificationManagerWrapper, preferences)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun mediaLoaderWrapper(preferences: SharedPreferencesWrapper): MediaPreloader {
|
||||
fun mediaLoaderWrapper(preferences: SharedPreferences): MediaPreloader {
|
||||
val preloader = MediaPreloader(context)
|
||||
preloader.reloadOptions(preferences)
|
||||
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
|
@ -191,13 +191,13 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun dns(preferences: SharedPreferencesWrapper): Dns {
|
||||
fun dns(preferences: SharedPreferences): Dns {
|
||||
return TwidereDns(context, preferences)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun mediaDownloader(preferences: SharedPreferencesWrapper, client: RestHttpClient,
|
||||
fun mediaDownloader(preferences: SharedPreferences, client: RestHttpClient,
|
||||
thumbor: ThumborWrapper): MediaDownloader {
|
||||
return TwidereMediaDownloader(context, client, thumbor)
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun thumborWrapper(preferences: SharedPreferencesWrapper): ThumborWrapper {
|
||||
fun thumborWrapper(preferences: SharedPreferences): ThumborWrapper {
|
||||
val thumbor = ThumborWrapper()
|
||||
thumbor.reloadSettings(preferences)
|
||||
return thumbor
|
||||
|
@ -259,13 +259,13 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun taskCreator(kPreferences: KPreferences, bus: Bus): TaskServiceRunner {
|
||||
return TaskServiceRunner(context, kPreferences, bus)
|
||||
fun taskCreator(preferences: SharedPreferences, bus: Bus): TaskServiceRunner {
|
||||
return TaskServiceRunner(context, preferences, bus)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun defaultFeatures(preferences: SharedPreferencesWrapper): DefaultFeatures {
|
||||
fun defaultFeatures(preferences: SharedPreferences): DefaultFeatures {
|
||||
val features = DefaultFeatures()
|
||||
features.load(preferences)
|
||||
return features
|
||||
|
@ -294,7 +294,7 @@ class ApplicationModule(private val context: Context) {
|
|||
}
|
||||
|
||||
@Provides
|
||||
fun okHttpClient(preferences: SharedPreferencesWrapper, dns: Dns, connectionPool: ConnectionPool,
|
||||
fun okHttpClient(preferences: SharedPreferences, dns: Dns, connectionPool: ConnectionPool,
|
||||
cache: Cache): OkHttpClient {
|
||||
val conf = HttpClientFactory.HttpClientConfiguration(preferences)
|
||||
val builder = OkHttpClient.Builder()
|
||||
|
@ -304,7 +304,7 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun dataSourceFactory(preferences: SharedPreferencesWrapper, dns: Dns, connectionPool: ConnectionPool,
|
||||
fun dataSourceFactory(preferences: SharedPreferences, dns: Dns, connectionPool: ConnectionPool,
|
||||
cache: Cache): DataSource.Factory {
|
||||
val conf = HttpClientFactory.HttpClientConfiguration(preferences)
|
||||
val builder = OkHttpClient.Builder()
|
||||
|
@ -315,7 +315,7 @@ class ApplicationModule(private val context: Context) {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun cache(preferences: SharedPreferencesWrapper): Cache {
|
||||
fun cache(preferences: SharedPreferences): Cache {
|
||||
val cacheSizeMB = preferences.getInt(KEY_CACHE_SIZE_LIMIT, 300).coerceIn(100..500)
|
||||
// Convert to bytes
|
||||
return Cache(getCacheDir("network", cacheSizeMB * 1048576L), cacheSizeMB * 1048576L)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.mariotaku.twidere.util.dagger
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.twitter.Validator
|
||||
import okhttp3.Cache
|
||||
import okhttp3.ConnectionPool
|
||||
|
@ -27,7 +28,10 @@ import okhttp3.Dns
|
|||
import org.mariotaku.kpreferences.KPreferences
|
||||
import org.mariotaku.restfu.http.RestHttpClient
|
||||
import org.mariotaku.twidere.model.DefaultFeatures
|
||||
import org.mariotaku.twidere.util.*
|
||||
import org.mariotaku.twidere.util.ActivityTracker
|
||||
import org.mariotaku.twidere.util.ExternalThemeManager
|
||||
import org.mariotaku.twidere.util.ReadStateManager
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.media.MediaPreloader
|
||||
import org.mariotaku.twidere.util.media.ThumborWrapper
|
||||
import org.mariotaku.twidere.util.sync.TimelineSyncManager
|
||||
|
@ -56,7 +60,7 @@ class DependencyHolder internal constructor(context: Context) {
|
|||
lateinit var validator: Validator
|
||||
internal set
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferencesWrapper
|
||||
lateinit var preferences: SharedPreferences
|
||||
internal set
|
||||
@Inject
|
||||
lateinit var connectionPool: ConnectionPool
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.mariotaku.ktextension.toIntOr
|
|||
import org.mariotaku.twidere.BuildConfig
|
||||
import org.mariotaku.twidere.TwidereConstants.HOST_MAPPING_PREFERENCES_NAME
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.*
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.xbill.DNS.*
|
||||
import java.io.IOException
|
||||
import java.net.InetAddress
|
||||
|
@ -39,15 +38,14 @@ import javax.inject.Singleton
|
|||
@Singleton
|
||||
class TwidereDns(context: Context, private val preferences: SharedPreferences) : Dns {
|
||||
|
||||
private val hostMapping: SharedPreferences
|
||||
private val systemHosts: SystemHosts
|
||||
private val hostMapping = context.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE)
|
||||
private val systemHosts = SystemHosts()
|
||||
|
||||
private var resolver: Resolver? = null
|
||||
private var useResolver: Boolean = false
|
||||
|
||||
init {
|
||||
hostMapping = SharedPreferencesWrapper.getInstance(context, HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
systemHosts = SystemHosts()
|
||||
reloadDnsSettings()
|
||||
}
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@
|
|||
<string name="usage_statistics_notification_summary">ساعدنا كي نحسن تويدر!</string>
|
||||
<string name="user_blocked">تم حظر هذا المستخدم.</string>
|
||||
<string name="user_filter_name">المستخدم : <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">لائحة</string>
|
||||
<string name="title_user_list">لائحة</string>
|
||||
<string name="user_list_details">تفاصيل القائمة</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">الوصف</string>
|
||||
|
|
|
@ -1029,7 +1029,7 @@ Convertilu a un tuit normal amiesta una caráuter estra.</string>
|
|||
<string name="usage_statistics_notification_summary">¡Ayúdamos a ameyorar Twidere!</string>
|
||||
<string name="user_blocked">Bloquióse a esti usuariu.</string>
|
||||
<string name="user_filter_name">Usuariu: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Llistáu</string>
|
||||
<string name="title_user_list">Llistáu</string>
|
||||
<string name="user_list_details">Detalles del llistáu</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Descripción</string>
|
||||
|
|
|
@ -750,7 +750,7 @@
|
|||
<string name="usage_statistics_notification_summary">Ajuda\'ns a millorar Twidere!</string>
|
||||
<string name="user_blocked">S\'ha bloquejat aquest usuari.</string>
|
||||
<string name="user_filter_name">Usuari: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Llista</string>
|
||||
<string name="title_user_list">Llista</string>
|
||||
<string name="user_list_details">Detalls de la llista</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Descripció</string>
|
||||
|
|
|
@ -410,7 +410,7 @@
|
|||
<string name="usage_statistics">Statistiky využití</string>
|
||||
<string name="user_blocked">Blokovat tohoto uživatele.</string>
|
||||
<string name="user_filter_name">Uživatel: <xliff:g id="name">%s </xliff:g></string>
|
||||
<string name="user_list">Seznam</string>
|
||||
<string name="title_user_list">Seznam</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Popis</string>
|
||||
<!-- User list is public -->
|
||||
|
|
|
@ -297,7 +297,7 @@
|
|||
<string name="type_to_compose">Tryk for at komponere</string>
|
||||
<string name="uninstall">Afinstallér</string>
|
||||
<string name="user_blocked">Bloker denne bruger.</string>
|
||||
<string name="user_list">Liste</string>
|
||||
<string name="title_user_list">Liste</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Beskrivelse</string>
|
||||
<!-- User list is public -->
|
||||
|
|
|
@ -1034,7 +1034,7 @@
|
|||
<string name="usage_statistics_notification_summary">Hilf uns Twidere zu verbessern!</string>
|
||||
<string name="user_blocked">Dieser Benutzer wurde blockiert.</string>
|
||||
<string name="user_filter_name">Benutzer: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Liste</string>
|
||||
<string name="title_user_list">Liste</string>
|
||||
<string name="user_list_details">Listendetails</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Beschreibung</string>
|
||||
|
|
|
@ -1049,7 +1049,7 @@
|
|||
<string name="usage_statistics_notification_summary">Ayúdanos a mejorar Twidere!</string>
|
||||
<string name="user_blocked">Bloquear a este usuario.</string>
|
||||
<string name="user_filter_name">Usuario: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Lista</string>
|
||||
<string name="title_user_list">Lista</string>
|
||||
<string name="user_list_details">Detalles de la lista</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Descripción</string>
|
||||
|
|
|
@ -905,7 +905,7 @@
|
|||
<string name="usage_statistics_notification_summary">کمک کنید تویدر را بهتر کنیم!</string>
|
||||
<string name="user_blocked">این کاربر مسدود شده است.</string>
|
||||
<string name="user_filter_name">کاربر: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">فهرست</string>
|
||||
<string name="title_user_list">فهرست</string>
|
||||
<string name="user_list_details">فهرست کردن جزییات</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">توصیف</string>
|
||||
|
|
|
@ -736,7 +736,7 @@
|
|||
<string name="usage_statistics_notification_summary">Auta meitä kehittämään Twidereä!</string>
|
||||
<string name="user_blocked">Käyttäjä on estetty.</string>
|
||||
<string name="user_filter_name">Käyttäjä: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Lista</string>
|
||||
<string name="title_user_list">Lista</string>
|
||||
<string name="user_list_details">Listaa lisätiedot</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Kuvaus</string>
|
||||
|
|
|
@ -1028,7 +1028,7 @@
|
|||
<string name="usage_statistics_notification_summary">Aidez-nous à améliorer Twidere !</string>
|
||||
<string name="user_blocked">Utilisateur bloqué.</string>
|
||||
<string name="user_filter_name">Utilisateur : <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Liste</string>
|
||||
<string name="title_user_list">Liste</string>
|
||||
<string name="user_list_details">Détails de la liste</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Description</string>
|
||||
|
|
|
@ -1051,7 +1051,7 @@
|
|||
<string name="usage_statistics_notification_summary">Axúdanos a mellorar Twidere!</string>
|
||||
<string name="user_blocked">Este usuario foi bloqueado.</string>
|
||||
<string name="user_filter_name">Usuario: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Lista</string>
|
||||
<string name="title_user_list">Lista</string>
|
||||
<string name="user_list_details">Detalles da lista</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Descrición</string>
|
||||
|
|
|
@ -645,7 +645,7 @@
|
|||
<string name="usage_statistics_notification_summary">Pomozite nam poboljšati Twidere!</string>
|
||||
<string name="user_blocked">Ovaj korisnik je blokiran.</string>
|
||||
<string name="user_filter_name">Korisnik: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Lista</string>
|
||||
<string name="title_user_list">Lista</string>
|
||||
<string name="user_list_details">Detalji o listi</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Opis</string>
|
||||
|
|
|
@ -756,7 +756,7 @@
|
|||
<string name="usage_statistics_notification_summary">Segíts fejleszteni a Twidere-t!</string>
|
||||
<string name="user_blocked">Felhasználó blokkolva.</string>
|
||||
<string name="user_filter_name">Felhasználó: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Lista</string>
|
||||
<string name="title_user_list">Lista</string>
|
||||
<string name="user_list_details">Részletek listázása</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Leírás</string>
|
||||
|
|
|
@ -816,7 +816,7 @@
|
|||
<string name="usage_statistics_notification_summary">Bantu kami memperbaiki Twidere!</string>
|
||||
<string name="user_blocked">Unlock pengguna ini.</string>
|
||||
<string name="user_filter_name">Pengguna: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Daftar</string>
|
||||
<string name="title_user_list">Daftar</string>
|
||||
<string name="user_list_details">Daftar rincian</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Deskripsi</string>
|
||||
|
|
|
@ -733,7 +733,7 @@
|
|||
<string name="usage_statistics_notification_summary">Aiutaci a migliorare Twidere!</string>
|
||||
<string name="user_blocked">Blocca questo utente.</string>
|
||||
<string name="user_filter_name">Utente: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">Lista</string>
|
||||
<string name="title_user_list">Lista</string>
|
||||
<string name="user_list_details">Dettagli della lista</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">Descrizione</string>
|
||||
|
|
|
@ -443,7 +443,7 @@
|
|||
<string name="usage_statistics">סטטיסטיקות שימוש</string>
|
||||
<string name="user_blocked">משתמש זה נחסם.</string>
|
||||
<string name="user_filter_name">משתמש: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">רשימה</string>
|
||||
<string name="title_user_list">רשימה</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">תיאור</string>
|
||||
<!-- User list is public -->
|
||||
|
|
|
@ -1060,7 +1060,7 @@
|
|||
<string name="usage_statistics_notification_summary">Twidereの機能向上にご協力ください</string>
|
||||
<string name="user_blocked">このユーザーをブロックしました。</string>
|
||||
<string name="user_filter_name">ユーザー: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">リスト</string>
|
||||
<string name="title_user_list">リスト</string>
|
||||
<string name="user_list_details">リストの詳細</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">リストの説明</string>
|
||||
|
|
|
@ -937,7 +937,7 @@
|
|||
<string name="usage_statistics_notification_summary">Twidere를 보완하는데 도와주세요!</string>
|
||||
<string name="user_blocked">사용자 차단</string>
|
||||
<string name="user_filter_name">사용자: <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="user_list">리스트</string>
|
||||
<string name="title_user_list">리스트</string>
|
||||
<string name="user_list_details">리스트 상세 정보</string>
|
||||
<!-- User list description -->
|
||||
<string name="user_list_details_description">설명</string>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue