fixed extensions fragment

removed retweets_of_me
This commit is contained in:
Mariotaku Lee 2016-07-26 14:51:43 +08:00
parent aa3279c5b2
commit 173fe2d462
12 changed files with 27 additions and 153 deletions

View File

@ -14,7 +14,6 @@ import android.support.annotation.StringDef;
CustomTabType.USER_TIMELINE, CustomTabType.USER_TIMELINE,
CustomTabType.SEARCH_STATUSES, CustomTabType.SEARCH_STATUSES,
CustomTabType.LIST_TIMELINE, CustomTabType.LIST_TIMELINE,
CustomTabType.RETWEETS_OF_ME,
}) })
public @interface CustomTabType { public @interface CustomTabType {
String HOME_TIMELINE = "home_timeline"; String HOME_TIMELINE = "home_timeline";
@ -26,5 +25,4 @@ public @interface CustomTabType {
String USER_TIMELINE = "user_timeline"; String USER_TIMELINE = "user_timeline";
String SEARCH_STATUSES = "search_statuses"; String SEARCH_STATUSES = "search_statuses";
String LIST_TIMELINE = "list_timeline"; String LIST_TIMELINE = "list_timeline";
String RETWEETS_OF_ME = "retweets_of_me";
} }

View File

@ -32,6 +32,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.AsyncTaskLoader; import android.support.v4.content.AsyncTaskLoader;
import org.mariotaku.twidere.Constants; import org.mariotaku.twidere.Constants;
@ -115,6 +116,7 @@ public class ExtensionsListLoader extends AsyncTaskLoader<List<ExtensionsListLoa
} }
public static class ExtensionInfo implements Comparable<ExtensionInfo> { public static class ExtensionInfo implements Comparable<ExtensionInfo> {
@Nullable
public final String[] permissions; public final String[] permissions;
public final String label, description; public final String label, description;
public final String pname, settings; public final String pname, settings;

View File

@ -83,7 +83,9 @@ class ParcelableUserLoader(
val values = ParcelableUserValuesCreator.create(user) val values = ParcelableUserValuesCreator.create(user)
resolver.insert(CachedUsers.CONTENT_URI, values) resolver.insert(CachedUsers.CONTENT_URI, values)
ParcelableUserUtils.updateExtraInformation(user, credentials, userColorNameManager) ParcelableUserUtils.updateExtraInformation(user, credentials, userColorNameManager)
return SingleResponse.Companion.getInstance(user) val response = SingleResponse(user)
response.extras.putParcelable(EXTRA_ACCOUNT, credentials)
return response
} }
} }
val twitter = MicroBlogAPIFactory.getInstance(context, credentials, true, true) ?: return SingleResponse() val twitter = MicroBlogAPIFactory.getInstance(context, credentials, true, true) ?: return SingleResponse()
@ -118,7 +120,9 @@ class ParcelableUserLoader(
if (TextUtils.equals(UserKeyUtils.getUserHost(user), user.key.host)) { if (TextUtils.equals(UserKeyUtils.getUserHost(user), user.key.host)) {
user.account_key = accountKey user.account_key = accountKey
user.account_color = credentials.color user.account_color = credentials.color
return SingleResponse.Companion.getInstance(user) val response = SingleResponse(user)
response.extras.putParcelable(EXTRA_ACCOUNT, credentials)
return response
} }
cur.moveToNext() cur.moveToNext()
} }
@ -164,7 +168,7 @@ class ParcelableUserLoader(
if (!omitIntentExtra && extras != null) { if (!omitIntentExtra && extras != null) {
val user = extras.getParcelable<ParcelableUser>(EXTRA_USER) val user = extras.getParcelable<ParcelableUser>(EXTRA_USER)
if (user != null) { if (user != null) {
deliverResult(SingleResponse.Companion.getInstance(user)) // deliverResult(SingleResponse(user))
} }
} }
forceLoad() forceLoad()

View File

@ -1,61 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 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.loader
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.support.annotation.WorkerThread
import org.mariotaku.microblog.library.MicroBlog
import org.mariotaku.microblog.library.MicroBlogException
import org.mariotaku.microblog.library.twitter.model.Paging
import org.mariotaku.microblog.library.twitter.model.ResponseList
import org.mariotaku.microblog.library.twitter.model.Status
import org.mariotaku.twidere.model.ParcelableCredentials
import org.mariotaku.twidere.model.ParcelableStatus
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.util.InternalTwitterContentUtils
class RetweetsOfMeLoader(
context: Context,
accountKey: UserKey?,
sinceId: String?,
maxId: String?,
adapterData: List<ParcelableStatus>?,
savedStatusesArgs: Array<String>?,
tabPosition: Int,
fromUser: Boolean,
loadingMore: Boolean
) : MicroBlogAPIStatusesLoader(context, accountKey, sinceId, maxId, -1, adapterData, savedStatusesArgs,
tabPosition, fromUser, loadingMore) {
@Throws(MicroBlogException::class)
override fun getStatuses(microBlog: MicroBlog, credentials: ParcelableCredentials, paging: Paging): ResponseList<Status> {
return microBlog.getRetweetsOfMe(paging)
}
@WorkerThread
override fun shouldFilterStatus(database: SQLiteDatabase, status: ParcelableStatus): Boolean {
return InternalTwitterContentUtils.isFiltered(database, null, status.text_plain,
status.quoted_text_plain, status.spans, status.quoted_spans, status.source,
status.quoted_source, status.retweeted_by_user_key, status.quoted_user_key)
}
}

View File

@ -45,7 +45,6 @@ import org.mariotaku.twidere.fragment.HomeTimelineFragment;
import org.mariotaku.twidere.fragment.InteractionsTimelineFragment; import org.mariotaku.twidere.fragment.InteractionsTimelineFragment;
import org.mariotaku.twidere.fragment.InvalidTabFragment; import org.mariotaku.twidere.fragment.InvalidTabFragment;
import org.mariotaku.twidere.fragment.MessagesEntriesFragment; import org.mariotaku.twidere.fragment.MessagesEntriesFragment;
import org.mariotaku.twidere.fragment.RetweetsOfMeFragment;
import org.mariotaku.twidere.fragment.StatusesSearchFragment; import org.mariotaku.twidere.fragment.StatusesSearchFragment;
import org.mariotaku.twidere.fragment.TrendsSuggestionsFragment; import org.mariotaku.twidere.fragment.TrendsSuggestionsFragment;
import org.mariotaku.twidere.fragment.UserFavoritesFragment; import org.mariotaku.twidere.fragment.UserFavoritesFragment;
@ -117,10 +116,6 @@ public class CustomTabUtils implements Constants {
UserListTimelineFragment.class, R.string.list_timeline, R.drawable.ic_action_list, UserListTimelineFragment.class, R.string.list_timeline, R.drawable.ic_action_list,
CustomTabConfiguration.ACCOUNT_REQUIRED, CustomTabConfiguration.FIELD_TYPE_USER_LIST, 7)); CustomTabConfiguration.ACCOUNT_REQUIRED, CustomTabConfiguration.FIELD_TYPE_USER_LIST, 7));
CUSTOM_TABS_CONFIGURATION_MAP.put(CustomTabType.RETWEETS_OF_ME, new CustomTabConfiguration(
RetweetsOfMeFragment.class, R.string.retweets_of_me, R.drawable.ic_action_retweet,
CustomTabConfiguration.ACCOUNT_REQUIRED, CustomTabConfiguration.FIELD_TYPE_NONE, 10));
CUSTOM_TABS_ICON_NAME_MAP.put("accounts", R.drawable.ic_action_accounts); CUSTOM_TABS_ICON_NAME_MAP.put("accounts", R.drawable.ic_action_accounts);
CUSTOM_TABS_ICON_NAME_MAP.put("hashtag", R.drawable.ic_action_hashtag); CUSTOM_TABS_ICON_NAME_MAP.put("hashtag", R.drawable.ic_action_hashtag);
CUSTOM_TABS_ICON_NAME_MAP.put("heart", R.drawable.ic_action_heart); CUSTOM_TABS_ICON_NAME_MAP.put("heart", R.drawable.ic_action_heart);
@ -214,8 +209,7 @@ public class CustomTabUtils implements Constants {
switch (type) { switch (type) {
case CustomTabType.HOME_TIMELINE: case CustomTabType.HOME_TIMELINE:
case CustomTabType.NOTIFICATIONS_TIMELINE: case CustomTabType.NOTIFICATIONS_TIMELINE:
case CustomTabType.DIRECT_MESSAGES: case CustomTabType.DIRECT_MESSAGES: {
case CustomTabType.RETWEETS_OF_ME: {
return JsonSerializer.parse(json, TabArguments.class); return JsonSerializer.parse(json, TabArguments.class);
} }
case CustomTabType.USER_TIMELINE: case CustomTabType.USER_TIMELINE:

View File

@ -54,10 +54,11 @@ class ExtensionsAdapter(context: Context) : ArrayAdapter<ExtensionInfo>(context,
} }
val info = getItem(position) val info = getItem(position)
val permissionValid = PermissionsManager.isPermissionValid(*info.permissions) val permissions = info.permissions ?: emptyArray()
val permissionValid = PermissionsManager.isPermissionValid(*permissions)
holder.checkbox.visibility = if (permissionValid) View.VISIBLE else View.GONE holder.checkbox.visibility = if (permissionValid) View.VISIBLE else View.GONE
if (permissionValid) { if (permissionValid) {
holder.checkbox.isChecked = mPermissionsManager.checkPermission(info.pname, *info.permissions) holder.checkbox.isChecked = mPermissionsManager.checkPermission(info.pname, *permissions)
} }
holder.text1.text = info.label holder.text1.text = info.label
holder.text2.visibility = if (TextUtils.isEmpty(info.description)) View.GONE else View.VISIBLE holder.text2.visibility = if (TextUtils.isEmpty(info.description)) View.GONE else View.VISIBLE

View File

@ -747,7 +747,7 @@ class AccountsDashboardFragment : BaseSupportFragment(), LoaderCallbacks<Account
override fun loadInBackground(): AccountsInfo { override fun loadInBackground(): AccountsInfo {
val accounts = ParcelableAccountUtils.getAccounts(context) val accounts = ParcelableAccountUtils.getAccounts(context)
val draftsCount = DataStoreUtils.queryCount(context, Drafts.CONTENT_URI, null, null) val draftsCount = DataStoreUtils.queryCount(context, Drafts.CONTENT_URI_UNSENT, null, null)
return AccountsInfo(accounts, draftsCount) return AccountsInfo(accounts, draftsCount)
} }

View File

@ -56,6 +56,7 @@ class ExtensionsListFragment : BaseListFragment(), LoaderCallbacks<List<Extensio
listAdapter = adapter listAdapter = adapter
listView.setOnCreateContextMenuListener(this) listView.setOnCreateContextMenuListener(this)
loaderManager.initLoader(0, null, this) loaderManager.initLoader(0, null, this)
setEmptyText(getString(R.string.no_extension_installed))
setListShown(false) setListShown(false)
} }
@ -63,7 +64,7 @@ class ExtensionsListFragment : BaseListFragment(), LoaderCallbacks<List<Extensio
super.onStop() super.onStop()
} }
override fun onCreateLoader(id: Int, args: Bundle): Loader<List<ExtensionInfo>> { override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ExtensionInfo>> {
return ExtensionsListLoader(activity, packageManager) return ExtensionsListLoader(activity, packageManager)
} }
@ -123,7 +124,7 @@ class ExtensionsListFragment : BaseListFragment(), LoaderCallbacks<List<Extensio
private fun openSettings(info: ExtensionInfo): Boolean { private fun openSettings(info: ExtensionInfo): Boolean {
val intent = Intent(IntentConstants.INTENT_ACTION_EXTENSION_SETTINGS) val intent = Intent(IntentConstants.INTENT_ACTION_EXTENSION_SETTINGS)
intent.setPackage(info.pname) intent.`package` = info.pname
if (info.settings != null) { if (info.settings != null) {
intent.setClassName(info.pname, info.settings) intent.setClassName(info.pname, info.settings)
} else { } else {

View File

@ -51,7 +51,7 @@ class HomeTimelineFragment : CursorStatusesFragment() {
get() = true get() = true
override fun updateRefreshState() { override fun updateRefreshState() {
val twitter = twitterWrapper ?: return val twitter = twitterWrapper
refreshing = twitter.isHomeTimelineRefreshing refreshing = twitter.isHomeTimelineRefreshing
} }

View File

@ -1,66 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 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.fragment
import android.content.Context
import android.os.Bundle
import android.support.v4.content.Loader
import edu.tsinghua.hotmobi.model.TimelineType
import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.loader.RetweetsOfMeLoader
import org.mariotaku.twidere.model.ParcelableStatus
import org.mariotaku.twidere.util.Utils
import java.util.*
class RetweetsOfMeFragment : ParcelableStatusesFragment() {
override fun onCreateStatusesLoader(context: Context,
args: Bundle,
fromUser: Boolean): Loader<List<ParcelableStatus>?> {
val accountKey = Utils.getAccountKey(context, args)
val maxId = args.getString(EXTRA_MAX_ID)
val sinceId = args.getString(EXTRA_SINCE_ID)
val tabPosition = args.getInt(EXTRA_TAB_POSITION, -1)
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
return RetweetsOfMeLoader(context, accountKey, sinceId, maxId, adapterData,
savedStatusesFileArgs, tabPosition, fromUser, loadingMore)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
// final IStatusesListAdapter<List<ParcelableStatus>> adapter = getAdapter();
// adapter.setIndicateMyStatusDisabled(false);
// adapter.setFiltersEnabled(true);
// adapter.setIgnoredFilterFields(true, false, false, false, false);
}
override val savedStatusesFileArgs: Array<String>?
get() {
val args = arguments!!
val accountKey = Utils.getAccountKey(context, args)!!
val result = ArrayList<String>()
result.add(AUTHORITY_RETWEETS_OF_ME)
result.add("account=$accountKey")
return result.toTypedArray()
}
override val timelineType: String
get() = TimelineType.INTERACTIONS
}

View File

@ -122,7 +122,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
// Data fields // Data fields
var user: ParcelableUser? = null var user: ParcelableUser? = null
private set private set
private var mAccount: ParcelableAccount? = null private var account: ParcelableAccount? = null
private var mRelationship: UserRelationship? = null private var mRelationship: UserRelationship? = null
private var mLocale: Locale? = null private var mLocale: Locale? = null
private var mGetUserInfoLoaderInitialized: Boolean = false private var mGetUserInfoLoaderInitialized: Boolean = false
@ -218,7 +218,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
cardContent!!.visibility = View.VISIBLE cardContent!!.visibility = View.VISIBLE
errorContainer!!.visibility = View.GONE errorContainer!!.visibility = View.GONE
progressContainer!!.visibility = View.GONE progressContainer!!.visibility = View.GONE
displayUser(user, mAccount) displayUser(user, account)
updateOptionsMenuVisibility() updateOptionsMenuVisibility()
} else { } else {
if (data.hasException()) { if (data.hasException()) {
@ -399,7 +399,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
fun displayUser(user: ParcelableUser?, account: ParcelableAccount?) { fun displayUser(user: ParcelableUser?, account: ParcelableAccount?) {
val activity = activity ?: return val activity = activity ?: return
this.user = user this.user = user
mAccount = account this.account = account
if (user == null || user.key == null) { if (user == null || user.key == null) {
profileImage.visibility = View.GONE profileImage.visibility = View.GONE
profileType!!.visibility = View.GONE profileType!!.visibility = View.GONE
@ -552,7 +552,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
val user = user val user = user
// TODO check account status // TODO check account status
if (user == null || user != event.user) return if (user == null || user != event.user) return
displayUser(event.user, mAccount) displayUser(event.user, account)
} }
@Subscribe @Subscribe
@ -748,9 +748,9 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
MenuUtils.setItemAvailability(menu, R.id.mute_user, !isMyself) MenuUtils.setItemAvailability(menu, R.id.mute_user, !isMyself)
MenuUtils.setItemAvailability(menu, R.id.report_spam, !isMyself) MenuUtils.setItemAvailability(menu, R.id.report_spam, !isMyself)
MenuUtils.setItemAvailability(menu, R.id.enable_retweets, !isMyself) MenuUtils.setItemAvailability(menu, R.id.enable_retweets, !isMyself)
if (mAccount != null) { if (account != null) {
MenuUtils.setItemAvailability(menu, R.id.add_to_list, TextUtils.equals(ParcelableAccount.Type.TWITTER, MenuUtils.setItemAvailability(menu, R.id.add_to_list, TextUtils.equals(ParcelableAccount.Type.TWITTER,
ParcelableAccountUtils.getAccountType(mAccount!!))) ParcelableAccountUtils.getAccountType(account!!)))
} else { } else {
MenuUtils.setItemAvailability(menu, R.id.add_to_list, false) MenuUtils.setItemAvailability(menu, R.id.add_to_list, false)
} }
@ -1151,12 +1151,12 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
override fun onUserNicknameChanged(userId: UserKey, nick: String) { override fun onUserNicknameChanged(userId: UserKey, nick: String) {
if (user == null || user!!.key != userId) return if (user == null || user!!.key != userId) return
displayUser(user, mAccount) displayUser(user, account)
} }
override fun onUserColorChanged(userId: UserKey, color: Int) { override fun onUserColorChanged(userId: UserKey, color: Int) {
if (user == null || user!!.key != userId) return if (user == null || user!!.key != userId) return
displayUser(user, mAccount) displayUser(user, account)
} }
override fun onSizeChanged(view: View, w: Int, h: Int, oldw: Int, oldh: Int) { override fun onSizeChanged(view: View, w: Int, h: Int, oldw: Int, oldh: Int) {

View File

@ -810,4 +810,5 @@
<string name="hide_retweets">Hide retweets</string> <string name="hide_retweets">Hide retweets</string>
<string name="hide_quotes">Hide quotes</string> <string name="hide_quotes">Hide quotes</string>
<string name="hide_replies">Hide replies</string> <string name="hide_replies">Hide replies</string>
<string name="no_extension_installed">No extension installed</string>
</resources> </resources>