mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
removing some settings
improving L compatibility
This commit is contained in:
parent
22cce2c10f
commit
e377f58c4e
@ -1 +1 @@
|
||||
Subproject commit 67c6b1600c27ea38c4b7e601e69ccfbdb6a3cfbf
|
||||
Subproject commit ac2a08c10b37162c730f44acab67b284bcd0a52d
|
@ -1 +1 @@
|
||||
Subproject commit e29a94571fc82349d46b2911729a55e7ab9e34c4
|
||||
Subproject commit 72c6fc5c5ffa2b0dd882fc9f929ad39a7ca26c9b
|
@ -1 +1 @@
|
||||
Subproject commit 92cc3efc8aa4a842b8601a918a33d4d1fe78d8dc
|
||||
Subproject commit 48af37e2d62bd86366eebc58eba5cf4e79555b4c
|
@ -1 +1 @@
|
||||
Subproject commit f5078e9266d2f5222bef3493bf50e3e0aebcf69e
|
||||
Subproject commit 040037fc11af14f85994791d5619542261df1513
|
@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 20
|
||||
buildToolsVersion "21.0.2"
|
||||
buildToolsVersion "21.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.mariotaku.twidere"
|
||||
|
@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion '21.0.2'
|
||||
buildToolsVersion '21.1'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.mariotaku.twidere"
|
||||
@ -10,6 +10,7 @@ android {
|
||||
targetSdkVersion 21
|
||||
versionCode 96
|
||||
versionName "0.3.0-dev"
|
||||
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
@ -67,8 +68,12 @@ android {
|
||||
abortOnError false
|
||||
}
|
||||
productFlavors {
|
||||
google {}
|
||||
fdroid {}
|
||||
google {
|
||||
versionName = android.defaultConfig.versionName + '-google'
|
||||
}
|
||||
fdroid {
|
||||
versionName = android.defaultConfig.versionName + '-fdroid'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,14 +84,16 @@ dependencies {
|
||||
compile 'com.android.support:recyclerview-v7:21.0.0'
|
||||
compile 'com.etsy.android.grid:library:1.0.5'
|
||||
compile 'com.sothree.slidinguppanel:library:2.0.0'
|
||||
compile 'it.sephiroth.android.library.imagezoom:imagezoom:+'
|
||||
compile 'it.sephiroth.android.library.imagezoom:imagezoom:1.0.5'
|
||||
compile 'com.twitter:twitter-text:1.9.9'
|
||||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
|
||||
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
|
||||
compile 'org.apache.httpcomponents:httpmime:4.3.5'
|
||||
compile 'ch.acra:acra:4.5.0'
|
||||
compile 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
|
||||
googleCompile 'com.google.android.gms:play-services:6.1.11'
|
||||
compile 'me.grantland:autofittextview:0.2.0'
|
||||
compile 'com.pkmmte.view:circularimageview:1.1'
|
||||
googleCompile 'com.google.android.gms:play-services:6.1.71'
|
||||
fdroidCompile 'org.osmdroid:osmdroid-android:4.2'
|
||||
fdroidCompile 'org.slf4j:slf4j-simple:1.6.1'
|
||||
compile project(':SlidingMenu')
|
||||
|
@ -48,19 +48,19 @@ public class Where implements SQLLang {
|
||||
}
|
||||
|
||||
public static Where equals(final Column l, final Column r) {
|
||||
return new Where(String.format(Locale.US, "%s = %s", l.getSQL(), r.getSQL()));
|
||||
return new Where(String.format(Locale.ROOT, "%s = %s", l.getSQL(), r.getSQL()));
|
||||
}
|
||||
|
||||
public static Where equals(final Column l, final long r) {
|
||||
return new Where(String.format(Locale.US, "%s = %d", l.getSQL(), r));
|
||||
return new Where(String.format(Locale.ROOT, "%s = %d", l.getSQL(), r));
|
||||
}
|
||||
|
||||
public static Where equals(final Column l, final String r) {
|
||||
return new Where(String.format(Locale.US, "%s = '%s'", l.getSQL(), r));
|
||||
return new Where(String.format(Locale.ROOT, "%s = '%s'", l.getSQL(), r));
|
||||
}
|
||||
|
||||
public static Where equals(final String l, final long r) {
|
||||
return new Where(String.format(Locale.US, "%s = %d", l, r));
|
||||
return new Where(String.format(Locale.ROOT, "%s = %d", l, r));
|
||||
}
|
||||
|
||||
public static Where in(final Column column, final Selectable in) {
|
||||
@ -68,7 +68,7 @@ public class Where implements SQLLang {
|
||||
}
|
||||
|
||||
public static Where notEquals(final String l, final long r) {
|
||||
return new Where(String.format(Locale.US, "%s != %d", l, r));
|
||||
return new Where(String.format(Locale.ROOT, "%s != %d", l, r));
|
||||
}
|
||||
|
||||
public static Where notEquals(final String l, final String r) {
|
||||
|
@ -65,7 +65,6 @@ import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.StackView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
@ -178,9 +177,8 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
|
||||
private IColorLabelView mColorIndicator;
|
||||
private EditText mEditText;
|
||||
private ProgressBar mProgress;
|
||||
private StackView mAccountStack;
|
||||
private View mSendView, mBottomSendView;
|
||||
private StatusTextCountView mSendTextCountView, mBottomSendTextCountView;
|
||||
private View mSendView;
|
||||
private StatusTextCountView mSendTextCountView;
|
||||
private View mSelectAccount;
|
||||
|
||||
private MediaPreviewAdapter mMediaPreviewAdapter;
|
||||
@ -199,8 +197,6 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
|
||||
private long mInReplyToStatusId;
|
||||
private String mOriginalText;
|
||||
|
||||
private boolean mBottomSendButton;
|
||||
|
||||
private final Rect mWindowDecorHitRect = new Rect();
|
||||
|
||||
@Override
|
||||
@ -437,13 +433,10 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
|
||||
mMediasPreviewGrid = (GridView) findViewById(R.id.medias_thumbnail_preview);
|
||||
mMenuBar = (MenuBar) findViewById(R.id.menu_bar);
|
||||
mProgress = (ProgressBar) findViewById(R.id.actionbar_progress_indeterminate);
|
||||
mAccountStack = (StackView) findViewById(R.id.accounts_stack);
|
||||
final View composeActionBar = findViewById(R.id.compose_actionbar);
|
||||
final View composeBottomBar = findViewById(R.id.compose_bottombar);
|
||||
mSendView = composeActionBar.findViewById(R.id.send);
|
||||
mBottomSendView = composeBottomBar.findViewById(R.id.send);
|
||||
mSendView = composeBottomBar.findViewById(R.id.send);
|
||||
mSendTextCountView = (StatusTextCountView) mSendView.findViewById(R.id.status_text_count);
|
||||
mBottomSendTextCountView = (StatusTextCountView) mBottomSendView.findViewById(R.id.status_text_count);
|
||||
mSelectAccount = composeActionBar.findViewById(R.id.select_account);
|
||||
ViewAccessor.setBackground(findViewById(R.id.compose_content), getWindowContentOverlayForCompose(this));
|
||||
ViewAccessor.setBackground(composeActionBar, getActionBarBackground(this, getCurrentThemeResourceId()));
|
||||
@ -491,7 +484,7 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
|
||||
public boolean onLongClick(final View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.send: {
|
||||
showMenuItemToast(v, getString(R.string.send), mBottomSendButton);
|
||||
showMenuItemToast(v, getString(R.string.send), true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -579,7 +572,6 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
|
||||
super.onCreate(savedInstanceState);
|
||||
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(this, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mBottomSendButton = mPreferences.getBoolean(KEY_BOTTOM_SEND_BUTTON, false);
|
||||
mTwitterWrapper = getTwidereApplication().getTwitterWrapper();
|
||||
mResolver = getContentResolver();
|
||||
mValidator = new TwidereValidator(this);
|
||||
@ -599,7 +591,6 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
|
||||
mEditText.setOnEditorActionListener(mPreferences.getBoolean(KEY_QUICK_SEND, false) ? this : null);
|
||||
mEditText.addTextChangedListener(this);
|
||||
mAccountSelectorAdapter = new AccountSelectorAdapter(this);
|
||||
mAccountStack.setAdapter(mAccountSelectorAdapter);
|
||||
mAccountSelectorAdapter.addAll(Account.getAccountsList(this, false));
|
||||
mSelectAccount.setOnClickListener(this);
|
||||
// mAccountSelector.setOnItemClickListener(this);
|
||||
@ -648,12 +639,8 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
|
||||
}
|
||||
|
||||
mMenuBar.inflate(R.menu.menu_compose);
|
||||
mSendView.setVisibility(mBottomSendButton ? View.GONE : View.VISIBLE);
|
||||
mBottomSendView.setVisibility(mBottomSendButton ? View.VISIBLE : View.GONE);
|
||||
mSendView.setOnClickListener(this);
|
||||
mBottomSendView.setOnClickListener(this);
|
||||
mSendView.setOnLongClickListener(this);
|
||||
mBottomSendView.setOnLongClickListener(this);
|
||||
final Menu menu = mMenuBar.getMenu();
|
||||
final Intent composeExtensionsIntent = new Intent(INTENT_ACTION_EXTENSION_COMPOSE);
|
||||
addIntentToMenu(this, menu, composeExtensionsIntent, MENU_GROUP_COMPOSE_EXTENSION);
|
||||
@ -1128,14 +1115,12 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
|
||||
}
|
||||
|
||||
private void updateTextCount() {
|
||||
final StatusTextCountView textCountView = mBottomSendButton ? mBottomSendTextCountView : mSendTextCountView;
|
||||
if (textCountView != null && mEditText != null) {
|
||||
if (mSendTextCountView == null || mEditText == null) return;
|
||||
final String textOrig = parseString(mEditText.getText());
|
||||
final String text = hasMedia() && textOrig != null ? mImageUploaderUsed ? getImageUploadStatus(this,
|
||||
new String[]{FAKE_IMAGE_LINK}, textOrig) : textOrig + " " + FAKE_IMAGE_LINK : textOrig;
|
||||
final int validatedCount = text != null ? mValidator.getTweetLength(text) : 0;
|
||||
textCountView.setTextCount(validatedCount);
|
||||
}
|
||||
mSendTextCountView.setTextCount(validatedCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +76,6 @@ public interface IntentConstants {
|
||||
public static final String BROADCAST_TASK_STATE_CHANGED = INTENT_PACKAGE_PREFIX + "TASK_STATE_CHANGED";
|
||||
public static final String BROADCAST_NOTIFICATION_DELETED = INTENT_PACKAGE_PREFIX + "NOTIFICATION_DELETED";
|
||||
public static final String BROADCAST_FRIENDSHIP_CHANGED = INTENT_PACKAGE_PREFIX + "FRIENDSHIP_CHANGED";
|
||||
public static final String BROADCAST_BLOCKSTATE_CHANGED = INTENT_PACKAGE_PREFIX + "BLOCKSTATE_CHANGED";
|
||||
public static final String BROADCAST_PROFILE_UPDATED = INTENT_PACKAGE_PREFIX + "PROFILE_UPDATED";
|
||||
public static final String BROADCAST_PROFILE_IMAGE_UPDATED = INTENT_PACKAGE_PREFIX + "PROFILE_IMAGE_UPDATED";
|
||||
public static final String BROADCAST_PROFILE_BANNER_UPDATED = INTENT_PACKAGE_PREFIX + "PROFILE_BANNER_UPDATED";
|
||||
@ -147,7 +146,7 @@ public interface IntentConstants {
|
||||
public static final String EXTRA_TEXT = "text";
|
||||
public static final String EXTRA_TITLE = "title";
|
||||
public static final String EXTRA_TYPE = "type";
|
||||
public static final String EXTRA_SUCCEED = "succeed";
|
||||
// public static final String EXTRA_SUCCEED = "succeed";
|
||||
public static final String EXTRA_IDS = "ids";
|
||||
public static final String EXTRA_IS_SHARE = "is_share";
|
||||
public static final String EXTRA_STATUS = "status";
|
||||
|
@ -141,12 +141,8 @@ public interface SharedPreferenceConstants {
|
||||
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = false)
|
||||
public static final String KEY_DISPLAY_IMAGE_PREVIEW = "display_image_preview";
|
||||
@Preference(type = BOOLEAN)
|
||||
public static final String KEY_BOTTOM_COMPOSE_BUTTON = "bottom_compose_button";
|
||||
@Preference(type = BOOLEAN)
|
||||
public static final String KEY_LEFTSIDE_COMPOSE_BUTTON = "leftside_compose_button";
|
||||
@Preference(type = BOOLEAN)
|
||||
public static final String KEY_BOTTOM_SEND_BUTTON = "bottom_send_button";
|
||||
@Preference(type = BOOLEAN)
|
||||
public static final String KEY_ATTACH_LOCATION = "attach_location";
|
||||
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = true)
|
||||
public static final String KEY_GZIP_COMPRESSING = "gzip_compressing";
|
||||
|
@ -175,7 +175,7 @@ public class AccountsDrawerFragment extends BaseSupportListFragment implements L
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
|
||||
return new CursorLoader(getActivity(), Accounts.CONTENT_URI, Accounts.COLUMNS, null, null, null);
|
||||
return new CursorLoader(getActivity(), Accounts.CONTENT_URI, Accounts.COLUMNS, null, null, Accounts.SORT_POSITION);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -426,7 +426,7 @@ public class AccountsDrawerFragment extends BaseSupportListFragment implements L
|
||||
private static final ArrayList<OptionItem> sOptionsDefault = new ArrayList<>();
|
||||
|
||||
static {
|
||||
sOptions.add(new OptionItem(R.string.view_user_profile, R.drawable.ic_action_user, MENU_VIEW_PROFILE));
|
||||
sOptions.add(new OptionItem(R.string.view_user_profile, R.drawable.ic_action_profile, MENU_VIEW_PROFILE));
|
||||
sOptions.add(new OptionItem(android.R.string.search_go, R.drawable.ic_action_search, MENU_SEARCH));
|
||||
sOptions.add(new OptionItem(R.string.statuses, R.drawable.ic_action_quote, MENU_STATUSES));
|
||||
sOptions.add(new OptionItem(R.string.favorites, R.drawable.ic_action_star, MENU_FAVORITES));
|
||||
@ -437,7 +437,7 @@ public class AccountsDrawerFragment extends BaseSupportListFragment implements L
|
||||
sOptions.add(new OptionItem(R.string.set_as_default, R.drawable.ic_action_ok, MENU_SET_AS_DEFAULT));
|
||||
sOptions.add(new OptionItem(R.string.delete, R.drawable.ic_action_delete, MENU_DELETE));
|
||||
|
||||
sOptionsDefault.add(new OptionItem(R.string.view_user_profile, R.drawable.ic_action_user,
|
||||
sOptionsDefault.add(new OptionItem(R.string.view_user_profile, R.drawable.ic_action_profile,
|
||||
MENU_VIEW_PROFILE));
|
||||
sOptionsDefault.add(new OptionItem(android.R.string.search_go, R.drawable.ic_action_search,
|
||||
MENU_SEARCH));
|
||||
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.support;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
public class CreateUserMuteDialogFragment extends BaseSupportDialogFragment implements DialogInterface.OnClickListener {
|
||||
|
||||
public static final String FRAGMENT_TAG = "create_user_mute";
|
||||
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
final ParcelableUser user = getUser();
|
||||
final AsyncTwitterWrapper twitter = getTwitterWrapper();
|
||||
if (user == null || twitter == null) return;
|
||||
twitter.createMuteAsync(user.account_id, user.id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
|
||||
final ParcelableUser user = getUser();
|
||||
if (user != null) {
|
||||
final String displayName = Utils.getDisplayName(wrapped, user.id, user.name, user.screen_name);
|
||||
builder.setTitle(getString(R.string.mute_user, displayName));
|
||||
builder.setMessage(getString(R.string.mute_user_confirm_message, displayName));
|
||||
}
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
private ParcelableUser getUser() {
|
||||
final Bundle args = getArguments();
|
||||
if (!args.containsKey(EXTRA_USER)) return null;
|
||||
return args.getParcelable(EXTRA_USER);
|
||||
}
|
||||
|
||||
public static CreateUserMuteDialogFragment show(final FragmentManager fm, final ParcelableUser user) {
|
||||
final Bundle args = new Bundle();
|
||||
args.putParcelable(EXTRA_USER, user);
|
||||
final CreateUserMuteDialogFragment f = new CreateUserMuteDialogFragment();
|
||||
f.setArguments(args);
|
||||
f.show(fm, FRAGMENT_TAG);
|
||||
return f;
|
||||
}
|
||||
}
|
@ -19,8 +19,6 @@
|
||||
|
||||
package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.encodeQueryParams;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -40,6 +38,8 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.encodeQueryParams;
|
||||
|
||||
public abstract class ParcelableStatusesListFragment extends BaseStatusesListFragment<List<ParcelableStatus>> {
|
||||
|
||||
protected SharedPreferences mPreferences;
|
||||
@ -54,10 +54,9 @@ public abstract class ParcelableStatusesListFragment extends BaseStatusesListFra
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_STATUS_DESTROYED.equals(action)) {
|
||||
final long status_id = intent.getLongExtra(EXTRA_STATUS_ID, -1);
|
||||
final boolean succeed = intent.getBooleanExtra(EXTRA_SUCCEED, false);
|
||||
if (status_id > 0 && succeed) {
|
||||
deleteStatus(status_id);
|
||||
final long statusId = intent.getLongExtra(EXTRA_STATUS_ID, -1);
|
||||
if (statusId > 0) {
|
||||
deleteStatus(statusId);
|
||||
}
|
||||
} else if (BROADCAST_RETWEET_CHANGED.equals(action)) {
|
||||
final long status_id = intent.getLongExtra(EXTRA_STATUS_ID, -1);
|
||||
|
@ -188,22 +188,28 @@ public class StatusFragment extends ParcelableStatusesListFragment implements On
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_FRIENDSHIP_CHANGED.equals(action)) {
|
||||
if (mStatus != null && mStatus.user_id == intent.getLongExtra(EXTRA_USER_ID, -1)
|
||||
&& intent.getBooleanExtra(EXTRA_SUCCEED, false)) {
|
||||
switch (action) {
|
||||
case BROADCAST_FRIENDSHIP_CHANGED: {
|
||||
if (mStatus != null && mStatus.user_id == intent.getLongExtra(EXTRA_USER_ID, -1)) {
|
||||
showFollowInfo(true);
|
||||
}
|
||||
} else if (BROADCAST_FAVORITE_CHANGED.equals(action)) {
|
||||
break;
|
||||
}
|
||||
case BROADCAST_FAVORITE_CHANGED: {
|
||||
final ParcelableStatus status = intent.getParcelableExtra(EXTRA_STATUS);
|
||||
if (mStatus != null && status != null && isSameAccount(context, status.account_id, mStatus.account_id)
|
||||
&& status.id == getStatusId()) {
|
||||
getStatus(true);
|
||||
}
|
||||
} else if (BROADCAST_RETWEET_CHANGED.equals(action)) {
|
||||
break;
|
||||
}
|
||||
case BROADCAST_RETWEET_CHANGED: {
|
||||
final long status_id = intent.getLongExtra(EXTRA_STATUS_ID, -1);
|
||||
if (status_id > 0 && status_id == getStatusId()) {
|
||||
getStatus(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -54,8 +54,6 @@ import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.menucomponent.widget.MenuBar;
|
||||
import org.mariotaku.menucomponent.widget.MenuBar.MenuBarListener;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.support.UserListSelectorActivity;
|
||||
import org.mariotaku.twidere.adapter.ListActionAdapter;
|
||||
@ -121,15 +119,15 @@ public class UserListDetailsFragment extends BaseSupportListFragment implements
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
final ParcelableUserList user_list = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (user_list == null || mUserList == null || !intent.getBooleanExtra(EXTRA_SUCCEED, false))
|
||||
final ParcelableUserList userList = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (userList == null || mUserList == null)
|
||||
return;
|
||||
if (BROADCAST_USER_LIST_DETAILS_UPDATED.equals(action)) {
|
||||
if (user_list.id == mUserList.id) {
|
||||
if (userList.id == mUserList.id) {
|
||||
getUserListInfo(true);
|
||||
}
|
||||
} else if (BROADCAST_USER_LIST_SUBSCRIBED.equals(action) || BROADCAST_USER_LIST_UNSUBSCRIBED.equals(action)) {
|
||||
if (user_list.id == mUserList.id) {
|
||||
if (userList.id == mUserList.id) {
|
||||
getUserListInfo(true);
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getTwitterInstance;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -40,6 +38,8 @@ import twitter4j.Twitter;
|
||||
import twitter4j.TwitterException;
|
||||
import twitter4j.UserList;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getTwitterInstance;
|
||||
|
||||
public class UserListMembersFragment extends CursorSupportUsersListFragment implements OnMenuItemClickListener {
|
||||
|
||||
private ParcelableUserList mUserList;
|
||||
@ -51,7 +51,6 @@ public class UserListMembersFragment extends CursorSupportUsersListFragment impl
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_USER_LIST_MEMBERS_DELETED.equals(action)) {
|
||||
if (!intent.getBooleanExtra(EXTRA_SUCCEED, false)) return;
|
||||
final ParcelableUserList list = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (mUserList != null && list != null && list.id == mUserList.id) {
|
||||
removeUsers(intent.getLongArrayExtra(EXTRA_USER_IDS));
|
||||
|
@ -49,7 +49,7 @@ public class UserListsListFragment extends BaseUserListsListFragment {
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_USER_LIST_DELETED.equals(action)) {
|
||||
final ParcelableUserList list = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (list != null && intent.getBooleanExtra(EXTRA_SUCCEED, false)) {
|
||||
if (list != null) {
|
||||
removeUserList(list.id);
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
@ -64,6 +62,7 @@ import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.menucomponent.internal.menu.MenuUtils;
|
||||
import org.mariotaku.querybuilder.Where;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.support.AccountSelectorActivity;
|
||||
@ -89,6 +88,8 @@ import org.mariotaku.twidere.util.ParseUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify.OnLinkClickListener;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
||||
import org.mariotaku.twidere.view.ColorLabelLinearLayout;
|
||||
import org.mariotaku.twidere.view.ExtendedFrameLayout;
|
||||
import org.mariotaku.twidere.view.ProfileImageView;
|
||||
@ -180,20 +181,22 @@ public class UserProfileFragment extends BaseSupportListFragment implements OnCl
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
if (mUser == null) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_FRIENDSHIP_CHANGED.equals(action)) {
|
||||
if (intent.getLongExtra(EXTRA_USER_ID, -1) == mUser.id && intent.getBooleanExtra(EXTRA_SUCCEED, false)) {
|
||||
switch (action) {
|
||||
case BROADCAST_FRIENDSHIP_CHANGED: {
|
||||
if (intent.getLongExtra(EXTRA_USER_ID, -1) == mUser.id) {
|
||||
getFriendship();
|
||||
}
|
||||
} else if (BROADCAST_BLOCKSTATE_CHANGED.equals(action)) {
|
||||
if (intent.getLongExtra(EXTRA_USER_ID, -1) == mUser.id && intent.getBooleanExtra(EXTRA_SUCCEED, false)) {
|
||||
getFriendship();
|
||||
break;
|
||||
}
|
||||
} else if (BROADCAST_PROFILE_UPDATED.equals(action) || BROADCAST_PROFILE_IMAGE_UPDATED.equals(action)
|
||||
|| BROADCAST_PROFILE_BANNER_UPDATED.equals(action)) {
|
||||
if (intent.getLongExtra(EXTRA_USER_ID, -1) == mUser.id && intent.getBooleanExtra(EXTRA_SUCCEED, false)) {
|
||||
case BROADCAST_PROFILE_UPDATED:
|
||||
case BROADCAST_PROFILE_IMAGE_UPDATED:
|
||||
case BROADCAST_PROFILE_BANNER_UPDATED: {
|
||||
if (intent.getLongExtra(EXTRA_USER_ID, -1) == mUser.id) {
|
||||
getUserInfo(true);
|
||||
}
|
||||
} else if (BROADCAST_TASK_STATE_CHANGED.equals(action)) {
|
||||
break;
|
||||
}
|
||||
case BROADCAST_TASK_STATE_CHANGED: {
|
||||
final AsyncTwitterWrapper twitter = getTwitterWrapper();
|
||||
final boolean is_creating_friendship = twitter != null
|
||||
&& twitter.isCreatingFriendship(mUser.account_id, mUser.id);
|
||||
@ -201,6 +204,8 @@ public class UserProfileFragment extends BaseSupportListFragment implements OnCl
|
||||
&& twitter.isDestroyingFriendship(mUser.account_id, mUser.id);
|
||||
setProgressBarIndeterminateVisibility(is_creating_friendship || is_destroying_friendship);
|
||||
invalidateOptionsMenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -697,7 +702,6 @@ public class UserProfileFragment extends BaseSupportListFragment implements OnCl
|
||||
super.onStart();
|
||||
final IntentFilter filter = new IntentFilter(BROADCAST_TASK_STATE_CHANGED);
|
||||
filter.addAction(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
filter.addAction(BROADCAST_BLOCKSTATE_CHANGED);
|
||||
filter.addAction(BROADCAST_PROFILE_UPDATED);
|
||||
filter.addAction(BROADCAST_PROFILE_IMAGE_UPDATED);
|
||||
filter.addAction(BROADCAST_PROFILE_BANNER_UPDATED);
|
||||
@ -791,10 +795,27 @@ public class UserProfileFragment extends BaseSupportListFragment implements OnCl
|
||||
break;
|
||||
}
|
||||
case MENU_ADD_TO_FILTER: {
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
resolver.delete(Filters.Users.CONTENT_URI, Where.equals(Filters.Users.USER_ID, user.id).getSQL(), null);
|
||||
resolver.insert(Filters.Users.CONTENT_URI, ContentValuesCreator.makeFilteredUserContentValues(user));
|
||||
final boolean filtering = Utils.isFilteringUser(getActivity(), user.id);
|
||||
final ContentResolver cr = getContentResolver();
|
||||
if (filtering) {
|
||||
final Where where = Where.equals(Filters.Users.USER_ID, user.id);
|
||||
cr.delete(Filters.Users.CONTENT_URI, where.getSQL(), null);
|
||||
showInfoMessage(getActivity(), R.string.message_user_unmuted, false);
|
||||
} else {
|
||||
cr.insert(Filters.Users.CONTENT_URI, ContentValuesCreator.makeFilteredUserContentValues(user));
|
||||
showInfoMessage(getActivity(), R.string.message_user_muted, false);
|
||||
}
|
||||
setMenu(mMenuBar.getMenu());
|
||||
break;
|
||||
}
|
||||
case MENU_MUTE_USER: {
|
||||
if (mRelationship != null) {
|
||||
if (mRelationship.isSourceMutingTarget()) {
|
||||
twitter.destroyMuteAsync(user.account_id, user.id);
|
||||
} else {
|
||||
CreateUserMuteDialogFragment.show(getFragmentManager(), user);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MENU_MENTION: {
|
||||
@ -889,7 +910,6 @@ public class UserProfileFragment extends BaseSupportListFragment implements OnCl
|
||||
final ParcelableUser user = mUser;
|
||||
final Relationship relationship = mRelationship;
|
||||
if (twitter == null || user == null) return;
|
||||
final int activatedColor = ThemeUtils.getUserAccentColor(getActivity());
|
||||
final boolean isMyself = user.account_id == user.id;
|
||||
final boolean isFollowing = relationship != null && relationship.isSourceFollowingTarget();
|
||||
final boolean isProtected = user.is_protected;
|
||||
@ -912,17 +932,24 @@ public class UserProfileFragment extends BaseSupportListFragment implements OnCl
|
||||
if (user.id != user.account_id && relationship != null) {
|
||||
setMenuItemAvailability(menu, MENU_SEND_DIRECT_MESSAGE, relationship.canSourceDMTarget());
|
||||
setMenuItemAvailability(menu, MENU_BLOCK, true);
|
||||
setMenuItemAvailability(menu, MENU_MUTE_USER, true);
|
||||
final MenuItem blockItem = menu.findItem(MENU_BLOCK);
|
||||
if (blockItem != null) {
|
||||
final Drawable blockIcon = blockItem.getIcon();
|
||||
if (relationship.isSourceBlockingTarget()) {
|
||||
blockItem.setTitle(R.string.unblock);
|
||||
blockIcon.mutate();
|
||||
blockIcon.setColorFilter(activatedColor, PorterDuff.Mode.SRC_ATOP);
|
||||
} else {
|
||||
blockItem.setTitle(R.string.block);
|
||||
blockIcon.clearColorFilter();
|
||||
final boolean blocking = relationship.isSourceBlockingTarget();
|
||||
MenuUtils.setMenuInfo(blockItem, new TwidereMenuInfo(blocking));
|
||||
blockItem.setTitle(blocking ? R.string.unblock : R.string.block);
|
||||
}
|
||||
final MenuItem muteItem = menu.findItem(MENU_MUTE_USER);
|
||||
if (muteItem != null) {
|
||||
final boolean muting = relationship.isSourceMutingTarget();
|
||||
MenuUtils.setMenuInfo(muteItem, new TwidereMenuInfo(muting));
|
||||
muteItem.setTitle(muting ? R.string.unmute : R.string.mute);
|
||||
}
|
||||
final MenuItem filterItem = menu.findItem(MENU_ADD_TO_FILTER);
|
||||
if (filterItem != null) {
|
||||
final boolean filtering = Utils.isFilteringUser(getActivity(), user.id);
|
||||
MenuUtils.setMenuInfo(filterItem, new TwidereMenuInfo(filtering));
|
||||
filterItem.setTitle(filtering ? R.string.remove_from_filter : R.string.add_to_filter);
|
||||
}
|
||||
} else {
|
||||
setMenuItemAvailability(menu, MENU_SEND_DIRECT_MESSAGE, false);
|
||||
|
@ -19,24 +19,6 @@
|
||||
|
||||
package org.mariotaku.twidere.util;
|
||||
|
||||
import static org.mariotaku.twidere.provider.TweetStore.STATUSES_URIS;
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.makeDirectMessageContentValues;
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.makeStatusContentValues;
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.makeTrendsContentValues;
|
||||
import static org.mariotaku.twidere.util.Utils.appendQueryParameters;
|
||||
import static org.mariotaku.twidere.util.Utils.getActivatedAccountIds;
|
||||
import static org.mariotaku.twidere.util.Utils.getAllStatusesIds;
|
||||
import static org.mariotaku.twidere.util.Utils.getDefaultAccountId;
|
||||
import static org.mariotaku.twidere.util.Utils.getNewestMessageIdsFromDatabase;
|
||||
import static org.mariotaku.twidere.util.Utils.getNewestStatusIdsFromDatabase;
|
||||
import static org.mariotaku.twidere.util.Utils.getStatusIdsInDatabase;
|
||||
import static org.mariotaku.twidere.util.Utils.getTwitterInstance;
|
||||
import static org.mariotaku.twidere.util.Utils.getUserName;
|
||||
import static org.mariotaku.twidere.util.Utils.truncateMessages;
|
||||
import static org.mariotaku.twidere.util.Utils.truncateStatuses;
|
||||
import static org.mariotaku.twidere.util.content.ContentResolverUtils.bulkDelete;
|
||||
import static org.mariotaku.twidere.util.content.ContentResolverUtils.bulkInsert;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
@ -46,8 +28,6 @@ import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import edu.ucdavis.earlybird.ProfilingUtil;
|
||||
|
||||
import org.mariotaku.querybuilder.Columns.Column;
|
||||
import org.mariotaku.querybuilder.RawItemArray;
|
||||
import org.mariotaku.querybuilder.Where;
|
||||
@ -75,6 +55,14 @@ import org.mariotaku.twidere.task.AsyncTask;
|
||||
import org.mariotaku.twidere.task.CacheUsersStatusesTask;
|
||||
import org.mariotaku.twidere.task.ManagedAsyncTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.ucdavis.earlybird.ProfilingUtil;
|
||||
import twitter4j.DirectMessage;
|
||||
import twitter4j.Paging;
|
||||
import twitter4j.ResponseList;
|
||||
@ -86,11 +74,22 @@ import twitter4j.User;
|
||||
import twitter4j.UserList;
|
||||
import twitter4j.http.HttpResponseCode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import static org.mariotaku.twidere.provider.TweetStore.STATUSES_URIS;
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.makeDirectMessageContentValues;
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.makeStatusContentValues;
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.makeTrendsContentValues;
|
||||
import static org.mariotaku.twidere.util.Utils.appendQueryParameters;
|
||||
import static org.mariotaku.twidere.util.Utils.getActivatedAccountIds;
|
||||
import static org.mariotaku.twidere.util.Utils.getDefaultAccountId;
|
||||
import static org.mariotaku.twidere.util.Utils.getNewestMessageIdsFromDatabase;
|
||||
import static org.mariotaku.twidere.util.Utils.getNewestStatusIdsFromDatabase;
|
||||
import static org.mariotaku.twidere.util.Utils.getStatusIdsInDatabase;
|
||||
import static org.mariotaku.twidere.util.Utils.getTwitterInstance;
|
||||
import static org.mariotaku.twidere.util.Utils.getUserName;
|
||||
import static org.mariotaku.twidere.util.Utils.truncateMessages;
|
||||
import static org.mariotaku.twidere.util.Utils.truncateStatuses;
|
||||
import static org.mariotaku.twidere.util.content.ContentResolverUtils.bulkDelete;
|
||||
import static org.mariotaku.twidere.util.content.ContentResolverUtils.bulkInsert;
|
||||
|
||||
public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@ -144,6 +143,11 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
}
|
||||
|
||||
public int createMuteAsync(final long accountId, final long user_id) {
|
||||
final CreateMuteTask task = new CreateMuteTask(accountId, user_id);
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
}
|
||||
|
||||
public int createFavoriteAsync(final long accountId, final long status_id) {
|
||||
final CreateFavoriteTask task = new CreateFavoriteTask(accountId, status_id);
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
@ -190,6 +194,11 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
}
|
||||
|
||||
public int destroyMuteAsync(final long accountId, final long user_id) {
|
||||
final DestroyMuteTask task = new DestroyMuteTask(accountId, user_id);
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
}
|
||||
|
||||
public int destroyDirectMessageAsync(final long accountId, final long message_id) {
|
||||
final DestroyDirectMessageTask task = new DestroyDirectMessageTask(accountId, message_id);
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
@ -440,7 +449,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<Boolean> result) {
|
||||
if (result.hasData() && result.getData()) {
|
||||
if (Boolean.TRUE.equals(result.getData())) {
|
||||
Utils.showOkMessage(mContext, R.string.profile_banner_image_updated, false);
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_updating_profile_banner_image, result.getException(),
|
||||
@ -448,7 +457,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_PROFILE_BANNER_UPDATED);
|
||||
intent.putExtra(EXTRA_USER_ID, mAccountId);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
@ -485,7 +493,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_PROFILE_UPDATED);
|
||||
intent.putExtra(EXTRA_USER_ID, account_id);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
context.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
@ -524,7 +531,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_PROFILE_IMAGE_UPDATED);
|
||||
intent.putExtra(EXTRA_USER_ID, account_id);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
context.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
@ -576,7 +582,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_ACCEPTED);
|
||||
intent.putExtra(EXTRA_USER_ID, mUserId);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
@ -634,7 +639,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_MEMBERS_ADDED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
intent.putExtra(EXTRA_USERS, users);
|
||||
intent.putExtra(EXTRA_SUCCEED, succeed);
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
@ -688,16 +692,16 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
try {
|
||||
final User user = twitter.createBlock(user_id);
|
||||
for (final Uri uri : STATUSES_URIS) {
|
||||
final String where = Statuses.ACCOUNT_ID + " = " + account_id + " AND " + Statuses.USER_ID + " = "
|
||||
+ user_id;
|
||||
mResolver.delete(uri, where, null);
|
||||
final Where where = Where.and(Where.equals(Statuses.ACCOUNT_ID, account_id),
|
||||
Where.equals(Statuses.USER_ID, user_id));
|
||||
mResolver.delete(uri, where.getSQL(), null);
|
||||
|
||||
}
|
||||
// I bet you don't want to see this user in your auto
|
||||
// complete
|
||||
// list.
|
||||
final String where = CachedUsers.USER_ID + " = " + user_id;
|
||||
mResolver.delete(CachedUsers.CONTENT_URI, where, null);
|
||||
final Where where = Where.equals(CachedUsers.USER_ID, user_id);
|
||||
mResolver.delete(CachedUsers.CONTENT_URI, where.getSQL(), null);
|
||||
return SingleResponse.getInstance(user, null);
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(null, e);
|
||||
@ -710,13 +714,55 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final String message = mContext.getString(R.string.blocked_user,
|
||||
getUserName(mContext, result.getData()));
|
||||
mMessagesManager.showInfoMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, user_id);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_blocking, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_BLOCKSTATE_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, user_id);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CreateMuteTask extends ManagedAsyncTask<Void, Void, SingleResponse<User>> {
|
||||
|
||||
private final long mAccountId, mUserId;
|
||||
|
||||
public CreateMuteTask(final long accountId, final long userId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
this.mAccountId = accountId;
|
||||
this.mUserId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<User> doInBackground(final Void... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
final User user = twitter.createMute(mUserId);
|
||||
final Where where = Where.and(Where.equals(Statuses.ACCOUNT_ID, mAccountId),
|
||||
Where.equals(Statuses.USER_ID, mUserId));
|
||||
mResolver.delete(Statuses.CONTENT_URI, where.getSQL(), null);
|
||||
|
||||
return SingleResponse.getInstance(user, null);
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(null, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<User> result) {
|
||||
if (result.hasData() && result.getData().getId() > 0) {
|
||||
final String message = mContext.getString(R.string.muted_user,
|
||||
getUserName(mContext, result.getData()));
|
||||
mMessagesManager.showInfoMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, mUserId);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_muting, result.getException(), true);
|
||||
}
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -741,16 +787,11 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final twitter4j.Status status = twitter.createFavorite(status_id);
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(Statuses.IS_FAVORITE, true);
|
||||
final StringBuilder where = new StringBuilder();
|
||||
where.append(Statuses.ACCOUNT_ID + " = " + account_id);
|
||||
where.append(" AND ");
|
||||
where.append("(");
|
||||
where.append(Statuses.STATUS_ID + " = " + status_id);
|
||||
where.append(" OR ");
|
||||
where.append(Statuses.RETWEET_ID + " = " + status_id);
|
||||
where.append(")");
|
||||
final Where where = Where.and(Where.equals(Statuses.ACCOUNT_ID, account_id),
|
||||
Where.or(Where.equals(Statuses.STATUS_ID, status_id),
|
||||
Where.equals(Statuses.RETWEET_ID, status_id)));
|
||||
for (final Uri uri : TweetStore.STATUSES_URIS) {
|
||||
mResolver.update(uri, values, where.toString(), null);
|
||||
mResolver.update(uri, values, where.getSQL(), null);
|
||||
}
|
||||
return SingleResponse.getInstance(new ParcelableStatus(status, account_id, false));
|
||||
} catch (final TwitterException e) {
|
||||
@ -822,7 +863,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, user_id);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
@ -842,7 +882,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected ListResponse<Long> doInBackground(final Void... params) {
|
||||
final List<Long> blocked_users = new ArrayList<Long>();
|
||||
final List<Long> blocked_users = new ArrayList<>();
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, false);
|
||||
if (twitter != null) {
|
||||
for (final long user_id : user_ids) {
|
||||
@ -854,12 +894,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
blocked_users.add(user.getId());
|
||||
} catch (final TwitterException e) {
|
||||
deleteCaches(blocked_users);
|
||||
return new ListResponse<Long>(null, e, null);
|
||||
return new ListResponse<>(null, e, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
deleteCaches(blocked_users);
|
||||
return new ListResponse<Long>(blocked_users, null, null);
|
||||
return new ListResponse<>(blocked_users, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -871,7 +911,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_MULTI_BLOCKSTATE_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, user_ids);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.list != null);
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
@ -940,7 +979,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
try {
|
||||
final ParcelableUserList list = new ParcelableUserList(twitter.createUserListSubscription(listId),
|
||||
accountId);
|
||||
return new SingleResponse<ParcelableUserList>(list, null);
|
||||
return SingleResponse.getInstance(list);
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(e);
|
||||
}
|
||||
@ -952,13 +991,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (succeed) {
|
||||
final String message = mContext.getString(R.string.subscribed_to_list, result.getData().name);
|
||||
mMessagesManager.showOkMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_SUBSCRIBED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_subscribing_to_list, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_SUBSCRIBED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
intent.putExtra(EXTRA_SUCCEED, succeed);
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -993,16 +1031,16 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<UserList> result) {
|
||||
final boolean succeed = result.hasData() && result.getData().getId() > 0;
|
||||
if (succeed) {
|
||||
final String message = mContext.getString(R.string.created_list, result.getData().getName());
|
||||
if (result.hasData()) {
|
||||
final UserList userList = result.getData();
|
||||
final String message = mContext.getString(R.string.created_list, userList.getName());
|
||||
mMessagesManager.showOkMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_CREATED);
|
||||
intent.putExtra(EXTRA_USER_LIST, new ParcelableUserList(userList, account_id));
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_creating_list, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_CREATED);
|
||||
intent.putExtra(EXTRA_SUCCEED, succeed);
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1053,14 +1091,13 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
result.getData().name);
|
||||
}
|
||||
mMessagesManager.showInfoMessage(message, false);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_deleting, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_MEMBERS_DELETED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
intent.putExtra(EXTRA_USERS, users);
|
||||
intent.putExtra(EXTRA_SUCCEED, succeed);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_deleting, result.getException(), true);
|
||||
}
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1110,7 +1147,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_DENIED);
|
||||
intent.putExtra(EXTRA_USER_ID, mUserId);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
@ -1147,13 +1183,53 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final String message = mContext.getString(R.string.unblocked_user,
|
||||
getUserName(mContext, result.getData()));
|
||||
mMessagesManager.showInfoMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, mUserId);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_unblocking, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_BLOCKSTATE_CHANGED);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DestroyMuteTask extends ManagedAsyncTask<Void, Void, SingleResponse<User>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long mUserId;
|
||||
|
||||
public DestroyMuteTask(final long accountId, final long userId) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
mAccountId = accountId;
|
||||
mUserId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<User> doInBackground(final Void... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
final User user = twitter.destroyMute(mUserId);
|
||||
return SingleResponse.getInstance(user, null);
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(null, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<User> result) {
|
||||
if (result.hasData()) {
|
||||
final String message = mContext.getString(R.string.unmuted_user,
|
||||
getUserName(mContext, result.getData()));
|
||||
mMessagesManager.showInfoMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, mUserId);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_unmuting, result.getException(), true);
|
||||
}
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1233,18 +1309,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final twitter4j.Status status = twitter.destroyFavorite(status_id);
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(Statuses.IS_FAVORITE, 0);
|
||||
final StringBuilder where = new StringBuilder();
|
||||
where.append(Statuses.ACCOUNT_ID + " = " + account_id);
|
||||
where.append(" AND ");
|
||||
where.append("(");
|
||||
where.append(Statuses.STATUS_ID + " = " + status_id);
|
||||
where.append(" OR ");
|
||||
where.append(Statuses.RETWEET_ID + " = " + status_id);
|
||||
where.append(")");
|
||||
final Where where = Where.and(Where.equals(Statuses.ACCOUNT_ID, account_id),
|
||||
Where.or(Where.equals(Statuses.STATUS_ID, status_id), Where.equals(Statuses.RETWEET_ID, status_id)));
|
||||
for (final Uri uri : TweetStore.STATUSES_URIS) {
|
||||
mResolver.update(uri, values, where.toString(), null);
|
||||
mResolver.update(uri, values, where.getSQL(), null);
|
||||
}
|
||||
return new SingleResponse<ParcelableStatus>(new ParcelableStatus(status, account_id, false), null);
|
||||
return SingleResponse.getInstance(new ParcelableStatus(status, account_id, false));
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(e);
|
||||
}
|
||||
@ -1295,12 +1365,10 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
try {
|
||||
final User user = twitter.destroyFriendship(user_id);
|
||||
// remove user tweets and retweets
|
||||
final String where
|
||||
= Statuses.ACCOUNT_ID + " = " + account_id
|
||||
+ " AND (" + Statuses.USER_ID + " = " + user_id
|
||||
+ " OR " + Statuses.RETWEETED_BY_USER_ID + " = " + user_id
|
||||
+ ")";
|
||||
mResolver.delete(Statuses.CONTENT_URI, where, null);
|
||||
final Where where = Where.and(Where.equals(Statuses.ACCOUNT_ID, account_id),
|
||||
Where.or(Where.equals(Statuses.USER_ID, user_id),
|
||||
Where.equals(Statuses.RETWEETED_BY_USER_ID, user_id)));
|
||||
mResolver.delete(Statuses.CONTENT_URI, where.getSQL(), null);
|
||||
return SingleResponse.getInstance(user, null);
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(null, e);
|
||||
@ -1315,13 +1383,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
final String message = mContext.getString(R.string.unfollowed_user,
|
||||
getUserName(mContext, result.getData()));
|
||||
mMessagesManager.showInfoMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, user_id);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_unfollowing, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, user_id);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1394,19 +1461,18 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<twitter4j.Status> result) {
|
||||
final Intent intent = new Intent(BROADCAST_STATUS_DESTROYED);
|
||||
if (result.hasData() && result.getData().getId() > 0) {
|
||||
intent.putExtra(EXTRA_STATUS_ID, status_id);
|
||||
intent.putExtra(EXTRA_SUCCEED, true);
|
||||
if (result.getData().getRetweetedStatus() != null) {
|
||||
mMessagesManager.showInfoMessage(R.string.retweet_cancelled, false);
|
||||
} else {
|
||||
mMessagesManager.showInfoMessage(R.string.status_deleted, false);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_STATUS_DESTROYED);
|
||||
intent.putExtra(EXTRA_STATUS_ID, status_id);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_deleting, result.getException(), true);
|
||||
}
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1445,13 +1511,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (succeed) {
|
||||
final String message = mContext.getString(R.string.unsubscribed_from_list, result.getData().name);
|
||||
mMessagesManager.showOkMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_UNSUBSCRIBED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_unsubscribing_from_list, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_UNSUBSCRIBED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
intent.putExtra(EXTRA_SUCCEED, succeed);
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1477,7 +1542,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (mListId > 0) {
|
||||
final ParcelableUserList list = new ParcelableUserList(twitter.destroyUserList(mListId),
|
||||
mAccountId);
|
||||
return new SingleResponse<ParcelableUserList>(list, null);
|
||||
return SingleResponse.getInstance(list);
|
||||
}
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(e);
|
||||
@ -1492,13 +1557,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (succeed) {
|
||||
final String message = mContext.getString(R.string.deleted_list, result.getData().name);
|
||||
mMessagesManager.showInfoMessage(message, false);
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_DELETED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_deleting, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_DELETED);
|
||||
intent.putExtra(EXTRA_SUCCEED, succeed);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1543,7 +1607,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
since_id = since_ids[idx];
|
||||
paging.setSinceId(since_id - 1);
|
||||
}
|
||||
final List<DirectMessage> messages = new ArrayList<DirectMessage>();
|
||||
final List<DirectMessage> messages = new ArrayList<>();
|
||||
final boolean truncated = truncateMessages(getDirectMessages(twitter, paging), messages,
|
||||
since_id);
|
||||
result.add(new MessageListResponse(account_id, max_id, since_id, load_item_limit, messages,
|
||||
@ -1625,7 +1689,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
public List<Trends> getTrends(final Twitter twitter) throws TwitterException {
|
||||
final ArrayList<Trends> trends_list = new ArrayList<Trends>();
|
||||
final ArrayList<Trends> trends_list = new ArrayList<>();
|
||||
if (twitter != null) {
|
||||
trends_list.add(twitter.getLocationTrends(woeid));
|
||||
}
|
||||
@ -1743,7 +1807,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
@Override
|
||||
protected List<StatusListResponse> doInBackground(final Void... params) {
|
||||
|
||||
final List<StatusListResponse> result = new ArrayList<StatusListResponse>();
|
||||
final List<StatusListResponse> result = new ArrayList<>();
|
||||
|
||||
if (mAccountIds == null) return result;
|
||||
|
||||
@ -1768,7 +1832,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
} else {
|
||||
sinceId = -1;
|
||||
}
|
||||
final List<twitter4j.Status> statuses = new ArrayList<twitter4j.Status>();
|
||||
final List<twitter4j.Status> statuses = new ArrayList<>();
|
||||
final boolean truncated = truncateStatuses(getStatuses(twitter, paging), statuses, sinceId);
|
||||
result.add(new StatusListResponse(account_id, maxId, sinceId, load_item_limit, statuses,
|
||||
truncated));
|
||||
@ -1809,12 +1873,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
extras.putLong(EXTRA_ACCOUNT_ID, account_id);
|
||||
if (twitter != null) {
|
||||
try {
|
||||
return new ListResponse<Trends>(getTrends(twitter), null, extras);
|
||||
return new ListResponse<>(getTrends(twitter), null, extras);
|
||||
} catch (final TwitterException e) {
|
||||
return new ListResponse<Trends>(null, e, extras);
|
||||
return new ListResponse<>(null, e, extras);
|
||||
}
|
||||
}
|
||||
return new ListResponse<Trends>(null, null, extras);
|
||||
return new ListResponse<>(null, null, extras);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1851,7 +1915,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
final Bundle extras = new Bundle();
|
||||
extras.putLong(EXTRA_ACCOUNT_ID, account_id);
|
||||
final List<Long> reported_users = new ArrayList<Long>();
|
||||
final List<Long> reported_users = new ArrayList<>();
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, false);
|
||||
if (twitter != null) {
|
||||
for (final long user_id : user_ids) {
|
||||
@ -1862,11 +1926,11 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
reported_users.add(user.getId());
|
||||
} catch (final TwitterException e) {
|
||||
return new ListResponse<Long>(null, e, extras);
|
||||
return new ListResponse<>(null, e, extras);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ListResponse<Long>(reported_users, null, extras);
|
||||
return new ListResponse<>(reported_users, null, extras);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1874,17 +1938,16 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (result != null) {
|
||||
final String user_id_where = ListUtils.toString(result.list, ',', false);
|
||||
for (final Uri uri : STATUSES_URIS) {
|
||||
final String where = Statuses.ACCOUNT_ID + " = " + account_id + " AND " + Statuses.USER_ID
|
||||
+ " IN (" + user_id_where + ")";
|
||||
mResolver.delete(uri, where, null);
|
||||
final Where where = Where.and(Where.equals(Statuses.ACCOUNT_ID, account_id),
|
||||
new Where(String.format(Locale.ROOT, "%s IN (%s)", Statuses.USER_ID, user_id_where)));
|
||||
mResolver.delete(uri, where.getSQL(), null);
|
||||
}
|
||||
mMessagesManager.showInfoMessage(R.string.reported_users_for_spam, false);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_MULTI_BLOCKSTATE_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_IDS, user_ids);
|
||||
intent.putExtra(EXTRA_ACCOUNT_ID, account_id);
|
||||
intent.putExtra(EXTRA_SUCCEED, result != null);
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1924,13 +1987,12 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
mResolver.delete(uri, where, null);
|
||||
}
|
||||
mMessagesManager.showInfoMessage(R.string.reported_user_for_spam, false);
|
||||
final Intent intent = new Intent(BROADCAST_FRIENDSHIP_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, user_id);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_reporting_for_spam, result.getException(), true);
|
||||
}
|
||||
final Intent intent = new Intent(BROADCAST_BLOCKSTATE_CHANGED);
|
||||
intent.putExtra(EXTRA_USER_ID, user_id);
|
||||
intent.putExtra(EXTRA_SUCCEED, result.hasData());
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@ -1990,55 +2052,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class SendDirectMessageTask extends ManagedAsyncTask<Void, Void, SingleResponse<DirectMessage>> {
|
||||
|
||||
private final long user_id;
|
||||
private final String screen_name;
|
||||
private final String message;
|
||||
private final long account_id;
|
||||
|
||||
public SendDirectMessageTask(final long account_id, final String screen_name, final long user_id,
|
||||
final String message) {
|
||||
super(mContext, mAsyncTaskManager);
|
||||
this.account_id = account_id;
|
||||
this.user_id = user_id;
|
||||
this.screen_name = screen_name;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<DirectMessage> doInBackground(final Void... args) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, true, true);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
if (user_id > 0)
|
||||
return SingleResponse.getInstance(twitter.sendDirectMessage(user_id, message), null);
|
||||
else if (screen_name != null)
|
||||
return SingleResponse.getInstance(twitter.sendDirectMessage(screen_name, message), null);
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(null, e);
|
||||
}
|
||||
return SingleResponse.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<DirectMessage> result) {
|
||||
super.onPostExecute(result);
|
||||
if (result.hasData() && result.getData().getId() > 0) {
|
||||
final ContentValues values = makeDirectMessageContentValues(result.getData(), account_id, true);
|
||||
final String delete_where = DirectMessages.ACCOUNT_ID + " = " + account_id + " AND "
|
||||
+ DirectMessages.MESSAGE_ID + " = " + result.getData().getId();
|
||||
mResolver.delete(DirectMessages.Outbox.CONTENT_URI, delete_where, null);
|
||||
mResolver.insert(DirectMessages.Outbox.CONTENT_URI, values);
|
||||
mMessagesManager.showOkMessage(R.string.direct_message_sent, false);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_sending_direct_message, result.getException(), true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class StoreDirectMessagesTask extends ManagedAsyncTask<Void, Void, SingleResponse<Bundle>> {
|
||||
abstract class StoreDirectMessagesTask extends ManagedAsyncTask<Void, Void, SingleResponse<Boolean>> {
|
||||
|
||||
private final List<MessageListResponse> responses;
|
||||
private final Uri uri;
|
||||
@ -2053,44 +2067,39 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<Bundle> doInBackground(final Void... args) {
|
||||
protected SingleResponse<Boolean> doInBackground(final Void... args) {
|
||||
|
||||
boolean succeed = false;
|
||||
for (final TwitterListResponse<DirectMessage> response : responses) {
|
||||
final long account_id = response.account_id;
|
||||
final long accountId = response.account_id;
|
||||
final List<DirectMessage> messages = response.list;
|
||||
if (messages != null) {
|
||||
final ContentValues[] values_array = new ContentValues[messages.size()];
|
||||
final long[] message_ids = new long[messages.size()];
|
||||
final long[] messageIds = new long[messages.size()];
|
||||
|
||||
for (int i = 0, j = messages.size(); i < j; i++) {
|
||||
final DirectMessage message = messages.get(i);
|
||||
message_ids[i] = message.getId();
|
||||
values_array[i] = makeDirectMessageContentValues(message, account_id, isOutgoing());
|
||||
messageIds[i] = message.getId();
|
||||
values_array[i] = makeDirectMessageContentValues(message, accountId, isOutgoing());
|
||||
}
|
||||
|
||||
// Delete all rows conflicting before new data inserted.
|
||||
{
|
||||
final StringBuilder delete_where = new StringBuilder();
|
||||
delete_where.append(DirectMessages.ACCOUNT_ID + " = " + account_id);
|
||||
delete_where.append(" AND ");
|
||||
delete_where.append(Where.in(new Column(DirectMessages.MESSAGE_ID),
|
||||
new RawItemArray(message_ids)).getSQL());
|
||||
final Uri delete_uri = appendQueryParameters(uri, new NameValuePairImpl(QUERY_PARAM_NOTIFY,
|
||||
final Where deleteWhere = Where.and(Where.equals(DirectMessages.ACCOUNT_ID, accountId),
|
||||
Where.in(new Column(DirectMessages.MESSAGE_ID), new RawItemArray(messageIds)));
|
||||
final Uri deleteUri = appendQueryParameters(uri, new NameValuePairImpl(QUERY_PARAM_NOTIFY,
|
||||
false));
|
||||
mResolver.delete(delete_uri, delete_where.toString(), null);
|
||||
mResolver.delete(deleteUri, deleteWhere.getSQL(), null);
|
||||
}
|
||||
|
||||
// Insert previously fetched items.
|
||||
final Uri insert_uri = appendQueryParameters(uri, new NameValuePairImpl(QUERY_PARAM_NOTIFY, notify));
|
||||
bulkInsert(mResolver, insert_uri, values_array);
|
||||
final Uri insertUri = appendQueryParameters(uri, new NameValuePairImpl(QUERY_PARAM_NOTIFY, notify));
|
||||
bulkInsert(mResolver, insertUri, values_array);
|
||||
|
||||
}
|
||||
succeed = true;
|
||||
}
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(EXTRA_SUCCEED, succeed);
|
||||
return SingleResponse.getInstance(bundle, null);
|
||||
return SingleResponse.getInstance(succeed);
|
||||
}
|
||||
|
||||
abstract boolean isOutgoing();
|
||||
@ -2104,12 +2113,10 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<Bundle> response) {
|
||||
final boolean succeed = response != null && response.hasData()
|
||||
&& response.getData().getBoolean(EXTRA_SUCCEED);
|
||||
final Bundle extras = new Bundle();
|
||||
extras.putBoolean(EXTRA_SUCCEED, succeed);
|
||||
mContext.sendBroadcast(new Intent(BROADCAST_HOME_TIMELINE_REFRESHED).putExtras(extras));
|
||||
protected void onPostExecute(final SingleResponse<Boolean> response) {
|
||||
if (Boolean.TRUE.equals(response.getData())) {
|
||||
mContext.sendBroadcast(new Intent(BROADCAST_HOME_TIMELINE_REFRESHED));
|
||||
}
|
||||
super.onPostExecute(response);
|
||||
}
|
||||
|
||||
@ -2130,12 +2137,10 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<Bundle> response) {
|
||||
final boolean succeed = response != null && response.hasData()
|
||||
&& response.getData().getBoolean(EXTRA_SUCCEED);
|
||||
final Bundle extras = new Bundle();
|
||||
extras.putBoolean(EXTRA_SUCCEED, succeed);
|
||||
mContext.sendBroadcast(new Intent(BROADCAST_MENTIONS_REFRESHED).putExtras(extras));
|
||||
protected void onPostExecute(final SingleResponse<Boolean> response) {
|
||||
if (Boolean.TRUE.equals(response.getData())) {
|
||||
mContext.sendBroadcast(new Intent(BROADCAST_MENTIONS_REFRESHED));
|
||||
}
|
||||
super.onPostExecute(response);
|
||||
}
|
||||
|
||||
@ -2167,11 +2172,11 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
abstract class StoreStatusesTask extends ManagedAsyncTask<Void, Void, SingleResponse<Bundle>> {
|
||||
abstract class StoreStatusesTask extends ManagedAsyncTask<Void, Void, SingleResponse<Boolean>> {
|
||||
|
||||
private final List<StatusListResponse> responses;
|
||||
private final Uri uri;
|
||||
private final ArrayList<ContentValues> all_statuses = new ArrayList<ContentValues>();
|
||||
private final ArrayList<ContentValues> all_statuses = new ArrayList<>();
|
||||
private final boolean notify;
|
||||
|
||||
public StoreStatusesTask(final List<StatusListResponse> result, final Uri uri, final boolean notify,
|
||||
@ -2183,31 +2188,31 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<Bundle> doInBackground(final Void... args) {
|
||||
protected SingleResponse<Boolean> doInBackground(final Void... args) {
|
||||
boolean succeed = false;
|
||||
for (final StatusListResponse response : responses) {
|
||||
final long account_id = response.account_id;
|
||||
final long accountId = response.account_id;
|
||||
final List<twitter4j.Status> statuses = response.list;
|
||||
if (statuses == null || statuses.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
final ArrayList<Long> ids_in_db = getStatusIdsInDatabase(mContext, uri, account_id);
|
||||
final ArrayList<Long> ids_in_db = getStatusIdsInDatabase(mContext, uri, accountId);
|
||||
final boolean noItemsBefore = ids_in_db.isEmpty();
|
||||
final ContentValues[] values = new ContentValues[statuses.size()];
|
||||
final long[] statusIds = new long[statuses.size()];
|
||||
for (int i = 0, j = statuses.size(); i < j; i++) {
|
||||
final twitter4j.Status status = statuses.get(i);
|
||||
values[i] = makeStatusContentValues(status, account_id);
|
||||
values[i] = makeStatusContentValues(status, accountId);
|
||||
statusIds[i] = status.getId();
|
||||
}
|
||||
// Delete all rows conflicting before new data inserted.
|
||||
final Where accountWhere = Where.equals(Statuses.ACCOUNT_ID, account_id);
|
||||
final Where accountWhere = Where.equals(Statuses.ACCOUNT_ID, accountId);
|
||||
final Where statusWhere = Where.in(new Column(Statuses.STATUS_ID), new RawItemArray(statusIds));
|
||||
final String deleteWhere = Where.and(accountWhere, statusWhere).getSQL();
|
||||
final Uri deleteUri = appendQueryParameters(uri, new NameValuePairImpl(QUERY_PARAM_NOTIFY, false));
|
||||
final int rowsDeleted = mResolver.delete(deleteUri, deleteWhere, null);
|
||||
// UCD
|
||||
ProfilingUtil.profile(mContext, account_id,
|
||||
ProfilingUtil.profile(mContext, accountId,
|
||||
"Download tweets, " + ArrayUtils.toString(statusIds, ',', true));
|
||||
all_statuses.addAll(Arrays.asList(values));
|
||||
// Insert previously fetched items.
|
||||
@ -2215,26 +2220,22 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
bulkInsert(mResolver, insertUri, values);
|
||||
|
||||
// Insert a gap.
|
||||
final long min_id = statusIds.length != 0 ? ArrayUtils.min(statusIds) : -1;
|
||||
final long minId = statusIds.length != 0 ? ArrayUtils.min(statusIds) : -1;
|
||||
final boolean deletedOldGap = rowsDeleted > 0 && ArrayUtils.contains(statusIds, response.max_id);
|
||||
final boolean noRowsDeleted = rowsDeleted == 0;
|
||||
final boolean insertGap = min_id > 0 && (noRowsDeleted || deletedOldGap) && !response.truncated
|
||||
final boolean insertGap = minId > 0 && (noRowsDeleted || deletedOldGap) && !response.truncated
|
||||
&& !noItemsBefore && statuses.size() > 1;
|
||||
if (insertGap) {
|
||||
final ContentValues gap_value = new ContentValues();
|
||||
gap_value.put(Statuses.IS_GAP, 1);
|
||||
final StringBuilder where = new StringBuilder();
|
||||
where.append(Statuses.ACCOUNT_ID + " = " + account_id);
|
||||
where.append(" AND " + Statuses.STATUS_ID + " = " + min_id);
|
||||
final Uri update_uri = appendQueryParameters(uri, new NameValuePairImpl(QUERY_PARAM_NOTIFY, true));
|
||||
mResolver.update(update_uri, gap_value, where.toString(), null);
|
||||
final ContentValues gapValue = new ContentValues();
|
||||
gapValue.put(Statuses.IS_GAP, 1);
|
||||
final Where where = Where.and(Where.equals(Statuses.ACCOUNT_ID, accountId),
|
||||
Where.equals(Statuses.STATUS_ID, minId));
|
||||
final Uri updateUri = appendQueryParameters(uri, new NameValuePairImpl(QUERY_PARAM_NOTIFY, true));
|
||||
mResolver.update(updateUri, gapValue, where.getSQL(), null);
|
||||
}
|
||||
succeed = true;
|
||||
}
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(EXTRA_SUCCEED, succeed);
|
||||
getAllStatusesIds(mContext, uri);
|
||||
return SingleResponse.getInstance(bundle, null);
|
||||
return SingleResponse.getInstance(succeed, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2246,7 +2247,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class StoreTrendsTask extends ManagedAsyncTask<Void, Void, SingleResponse<Bundle>> {
|
||||
class StoreTrendsTask extends ManagedAsyncTask<Void, Void, SingleResponse<Boolean>> {
|
||||
|
||||
private final ListResponse<Trends> response;
|
||||
private final Uri uri;
|
||||
@ -2258,38 +2259,34 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<Bundle> doInBackground(final Void... args) {
|
||||
final Bundle bundle = new Bundle();
|
||||
if (response != null) {
|
||||
|
||||
protected SingleResponse<Boolean> doInBackground(final Void... args) {
|
||||
if (response == null) return SingleResponse.getInstance(false);
|
||||
final List<Trends> messages = response.list;
|
||||
final ArrayList<String> hashtags = new ArrayList<String>();
|
||||
final ArrayList<ContentValues> hashtag_values = new ArrayList<ContentValues>();
|
||||
final ArrayList<String> hashtags = new ArrayList<>();
|
||||
final ArrayList<ContentValues> hashtagValues = new ArrayList<>();
|
||||
if (messages != null && messages.size() > 0) {
|
||||
final ContentValues[] values_array = makeTrendsContentValues(messages);
|
||||
for (final ContentValues values : values_array) {
|
||||
final ContentValues[] valuesArray = makeTrendsContentValues(messages);
|
||||
for (final ContentValues values : valuesArray) {
|
||||
final String hashtag = values.getAsString(CachedTrends.NAME).replaceFirst("#", "");
|
||||
if (hashtags.contains(hashtag)) {
|
||||
continue;
|
||||
}
|
||||
hashtags.add(hashtag);
|
||||
final ContentValues hashtag_value = new ContentValues();
|
||||
hashtag_value.put(CachedHashtags.NAME, hashtag);
|
||||
hashtag_values.add(hashtag_value);
|
||||
final ContentValues hashtagValue = new ContentValues();
|
||||
hashtagValue.put(CachedHashtags.NAME, hashtag);
|
||||
hashtagValues.add(hashtagValue);
|
||||
}
|
||||
mResolver.delete(uri, null, null);
|
||||
bulkInsert(mResolver, uri, values_array);
|
||||
bulkInsert(mResolver, uri, valuesArray);
|
||||
bulkDelete(mResolver, CachedHashtags.CONTENT_URI, CachedHashtags.NAME, hashtags, null, true);
|
||||
bulkInsert(mResolver, CachedHashtags.CONTENT_URI,
|
||||
hashtag_values.toArray(new ContentValues[hashtag_values.size()]));
|
||||
bundle.putBoolean(EXTRA_SUCCEED, true);
|
||||
hashtagValues.toArray(new ContentValues[hashtagValues.size()]));
|
||||
}
|
||||
}
|
||||
return new SingleResponse<Bundle>(bundle, null);
|
||||
return SingleResponse.getInstance(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<Bundle> response) {
|
||||
protected void onPostExecute(final SingleResponse<Boolean> response) {
|
||||
// if (response != null && response.data != null &&
|
||||
// response.data.getBoolean(EXTRA_SUCCEED)) {
|
||||
// final Intent intent = new Intent(BROADCAST_TRENDS_UPDATED);
|
||||
@ -2325,7 +2322,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (twitter != null) {
|
||||
try {
|
||||
final UserList list = twitter.updateUserList(listId, name, isPublic, description);
|
||||
return new SingleResponse<ParcelableUserList>(new ParcelableUserList(list, accountId), null);
|
||||
return SingleResponse.getInstance(new ParcelableUserList(list, accountId));
|
||||
} catch (final TwitterException e) {
|
||||
return SingleResponse.getInstance(e);
|
||||
}
|
||||
@ -2335,16 +2332,15 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<ParcelableUserList> result) {
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_DETAILS_UPDATED);
|
||||
intent.putExtra(EXTRA_LIST_ID, listId);
|
||||
if (result.hasData() && result.getData().id > 0) {
|
||||
final String message = mContext.getString(R.string.updated_list_details, result.getData().name);
|
||||
mMessagesManager.showOkMessage(message, false);
|
||||
intent.putExtra(EXTRA_SUCCEED, true);
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_DETAILS_UPDATED);
|
||||
intent.putExtra(EXTRA_LIST_ID, listId);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
mMessagesManager.showErrorMessage(R.string.action_updating_details, result.getException(), true);
|
||||
}
|
||||
mContext.sendBroadcast(intent);
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,8 @@
|
||||
|
||||
package org.mariotaku.twidere.util;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.isOnWifi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.nostra13.universalimageloader.cache.disc.DiskCache;
|
||||
@ -33,6 +30,8 @@ import org.mariotaku.twidere.Constants;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.isOnWifi;
|
||||
|
||||
/**
|
||||
* @author mariotaku
|
||||
*/
|
||||
@ -42,7 +41,6 @@ public class ImagePreloader implements Constants {
|
||||
|
||||
private final Context mContext;
|
||||
private final SharedPreferences mPreferences;
|
||||
private final Handler mHandler;
|
||||
private final DiskCache mDiskCache;
|
||||
private final ImageLoader mImageLoader;
|
||||
|
||||
@ -51,7 +49,6 @@ public class ImagePreloader implements Constants {
|
||||
mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mImageLoader = loader;
|
||||
mDiskCache = loader.getDiskCache();
|
||||
mHandler = new Handler();
|
||||
}
|
||||
|
||||
public File getCachedImageFile(final String url) {
|
||||
@ -68,14 +65,7 @@ public class ImagePreloader implements Constants {
|
||||
public void preloadImage(final String url) {
|
||||
if (TextUtils.isEmpty(url)) return;
|
||||
if (!isOnWifi(mContext) && mPreferences.getBoolean(KEY_PRELOAD_WIFI_ONLY, true)) return;
|
||||
mHandler.post(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mImageLoader.loadImage(url, null);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ import org.mariotaku.refreshnow.widget.RefreshNowProgressIndicator.IndicatorConf
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.util.menu.StatusMenuInfo;
|
||||
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -146,15 +146,15 @@ public class ThemeUtils implements Constants {
|
||||
if (info instanceof MenuBarMenuInfo) {
|
||||
final MenuBarMenuInfo mbInfo = (MenuBarMenuInfo) info;
|
||||
final boolean inPopup = mbInfo.isInPopup();
|
||||
if (mbInfo.getMenuInfo() instanceof StatusMenuInfo) {
|
||||
final StatusMenuInfo sInfo = (StatusMenuInfo) mbInfo.getMenuInfo();
|
||||
if (mbInfo.getMenuInfo() instanceof TwidereMenuInfo) {
|
||||
final TwidereMenuInfo sInfo = (TwidereMenuInfo) mbInfo.getMenuInfo();
|
||||
icon.setColorFilter(sInfo.isHighlight() ? highlightColor
|
||||
: (inPopup ? popupColor : color), mode);
|
||||
} else {
|
||||
icon.setColorFilter(inPopup ? popupColor : color, mode);
|
||||
}
|
||||
} else if (info instanceof StatusMenuInfo) {
|
||||
final StatusMenuInfo sInfo = (StatusMenuInfo) info;
|
||||
} else if (info instanceof TwidereMenuInfo) {
|
||||
final TwidereMenuInfo sInfo = (TwidereMenuInfo) info;
|
||||
icon.setColorFilter(sInfo.isHighlight() ? highlightColor : color, mode);
|
||||
} else {
|
||||
icon.setColorFilter(color, mode);
|
||||
|
@ -163,6 +163,7 @@ import org.mariotaku.twidere.provider.TweetStore.DNS;
|
||||
import org.mariotaku.twidere.provider.TweetStore.DirectMessages;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Drafts;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Filters;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Filters.Users;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Mentions;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Notifications;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Permissions;
|
||||
@ -172,7 +173,7 @@ import org.mariotaku.twidere.provider.TweetStore.Tabs;
|
||||
import org.mariotaku.twidere.provider.TweetStore.UnreadCounts;
|
||||
import org.mariotaku.twidere.service.RefreshService;
|
||||
import org.mariotaku.twidere.util.content.ContentResolverUtils;
|
||||
import org.mariotaku.twidere.util.menu.StatusMenuInfo;
|
||||
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
||||
import org.mariotaku.twidere.util.net.TwidereHostResolverFactory;
|
||||
import org.mariotaku.twidere.util.net.TwidereHttpClientFactory;
|
||||
|
||||
@ -3436,16 +3437,16 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
final MenuItem retweet = menu.findItem(MENU_RETWEET);
|
||||
if (retweet != null) {
|
||||
retweet.setVisible(!status.user_is_protected || isMyRetweet);
|
||||
MenuUtils.setMenuInfo(retweet, new StatusMenuInfo(isMyRetweet));
|
||||
MenuUtils.setMenuInfo(retweet, new TwidereMenuInfo(isMyRetweet));
|
||||
retweet.setTitle(isMyRetweet ? R.string.cancel_retweet : R.string.retweet);
|
||||
}
|
||||
final MenuItem retweetSubItem = menu.findItem(R.id.retweet_submenu);
|
||||
if (retweetSubItem != null) {
|
||||
MenuUtils.setMenuInfo(retweetSubItem, new StatusMenuInfo(isMyRetweet));
|
||||
MenuUtils.setMenuInfo(retweetSubItem, new TwidereMenuInfo(isMyRetweet));
|
||||
}
|
||||
final MenuItem favorite = menu.findItem(MENU_FAVORITE);
|
||||
if (favorite != null) {
|
||||
MenuUtils.setMenuInfo(favorite, new StatusMenuInfo(status.is_favorite));
|
||||
MenuUtils.setMenuInfo(favorite, new TwidereMenuInfo(status.is_favorite));
|
||||
favorite.setTitle(status.is_favorite ? R.string.unfavorite : R.string.favorite);
|
||||
}
|
||||
final MenuItem translate = menu.findItem(MENU_TRANSLATE);
|
||||
@ -3585,16 +3586,16 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
|
||||
public static void showInfoMessage(final Context context, final CharSequence message, final boolean long_message) {
|
||||
if (context == null || isEmpty(message)) return;
|
||||
if (context instanceof Activity) {
|
||||
final Crouton crouton = Crouton.makeText((Activity) context, message, CroutonStyle.INFO);
|
||||
final CroutonConfiguration.Builder cb = new CroutonConfiguration.Builder();
|
||||
cb.setDuration(long_message ? CroutonConfiguration.DURATION_LONG : CroutonConfiguration.DURATION_SHORT);
|
||||
crouton.setConfiguration(cb.build());
|
||||
crouton.show();
|
||||
} else {
|
||||
// if (context instanceof Activity) {
|
||||
// final Crouton crouton = Crouton.makeText((Activity) context, message, CroutonStyle.INFO);
|
||||
// final CroutonConfiguration.Builder cb = new CroutonConfiguration.Builder();
|
||||
// cb.setDuration(long_message ? CroutonConfiguration.DURATION_LONG : CroutonConfiguration.DURATION_SHORT);
|
||||
// crouton.setConfiguration(cb.build());
|
||||
// crouton.show();
|
||||
// } else {
|
||||
final Toast toast = Toast.makeText(context, message, long_message ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
public static void showInfoMessage(final Context context, final int resId, final boolean long_message) {
|
||||
@ -3893,4 +3894,15 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFilteringUser(Context context, long userId) {
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
final Where where = Where.equals(Users.USER_ID, userId);
|
||||
final Cursor c = cr.query(Users.CONTENT_URI, new String[0], where.getSQL(), null, null);
|
||||
try {
|
||||
return c.getCount() > 0;
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import android.view.ContextMenu.ContextMenuInfo;
|
||||
/**
|
||||
* Created by mariotaku on 14/10/27.
|
||||
*/
|
||||
public class StatusMenuInfo implements ContextMenuInfo {
|
||||
public class TwidereMenuInfo implements ContextMenuInfo {
|
||||
private final boolean highlight;
|
||||
|
||||
public StatusMenuInfo(boolean highlight) {
|
||||
public TwidereMenuInfo(boolean highlight) {
|
||||
this.highlight = highlight;
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ package org.mariotaku.twidere.view;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
@ -32,10 +32,12 @@ import android.widget.ProgressBar;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.view.iface.IHomeActionButton;
|
||||
|
||||
public class HomeActionButtonCompat extends FrameLayout implements IHomeActionButton {
|
||||
|
||||
private final ImageView mBackgroundView;
|
||||
private final ImageView mIconView;
|
||||
private final ProgressBar mProgressBar;
|
||||
|
||||
@ -49,19 +51,31 @@ public class HomeActionButtonCompat extends FrameLayout implements IHomeActionBu
|
||||
|
||||
public HomeActionButtonCompat(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
ViewAccessor.setBackground(this, null);
|
||||
inflate(ThemeUtils.getActionBarContext(context), R.layout.action_item_home_actions_compat, this);
|
||||
mBackgroundView = (ImageView) findViewById(R.id.background);
|
||||
mIconView = (ImageView) findViewById(android.R.id.icon);
|
||||
mProgressBar = (ProgressBar) findViewById(android.R.id.progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setButtonColor(int color) {
|
||||
final Drawable drawable = getBackground();
|
||||
if (drawable instanceof LayerDrawable) {
|
||||
final Drawable layer = ((LayerDrawable) drawable).findDrawableByLayerId(R.id.color_layer);
|
||||
if (layer != null) {
|
||||
layer.setColorFilter(color, Mode.SRC_ATOP);
|
||||
mBackgroundView.setImageDrawable(new MyColorDrawable(color));
|
||||
}
|
||||
|
||||
private static class MyColorDrawable extends ColorDrawable {
|
||||
public MyColorDrawable(int color) {
|
||||
super(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1609,9 +1609,9 @@ final class TwitterImpl extends TwitterBaseImpl implements Twitter {
|
||||
ensureAuthorizationEnabled();
|
||||
final String url = conf.getRestBaseURL()
|
||||
+ (status.isWithMedia() ? ENDPOINT_STATUSES_UPDATE_WITH_MEDIA : ENDPOINT_STATUSES_UPDATE);
|
||||
final String sign_url = conf.getSigningRestBaseURL()
|
||||
final String signUrl = conf.getSigningRestBaseURL()
|
||||
+ (status.isWithMedia() ? ENDPOINT_STATUSES_UPDATE_WITH_MEDIA : ENDPOINT_STATUSES_UPDATE);
|
||||
return factory.createStatus(post(url, sign_url, status.asHttpParameterArray(INCLUDE_ENTITIES)));
|
||||
return factory.createStatus(post(url, signUrl, status.asHttpParameterArray(INCLUDE_ENTITIES)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
BIN
twidere/src/main/res/drawable-hdpi/ic_action_add_to_list.png
Normal file
BIN
twidere/src/main/res/drawable-hdpi/ic_action_add_to_list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 268 B |
BIN
twidere/src/main/res/drawable-mdpi/ic_action_add_to_list.png
Normal file
BIN
twidere/src/main/res/drawable-mdpi/ic_action_add_to_list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 172 B |
BIN
twidere/src/main/res/drawable-xhdpi/ic_action_add_to_list.png
Normal file
BIN
twidere/src/main/res/drawable-xhdpi/ic_action_add_to_list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 317 B |
BIN
twidere/src/main/res/drawable-xxhdpi/ic_action_add_to_list.png
Normal file
BIN
twidere/src/main/res/drawable-xxhdpi/ic_action_add_to_list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 540 B |
8
twidere/src/main/res/drawable/bg_unread_indicator.xml
Normal file
8
twidere/src/main/res/drawable/bg_unread_indicator.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@android:color/holo_red_light"/>
|
||||
<size
|
||||
android:width="@dimen/unread_indicator_size"
|
||||
android:height="@dimen/unread_indicator_size"/>
|
||||
</shape>
|
@ -1,15 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<shape
|
||||
android:shape="oval" >
|
||||
<gradient
|
||||
android:endColor="#00000000"
|
||||
android:gradientRadius="50%p"
|
||||
android:startColor="#A0000000"
|
||||
android:type="radial"/>
|
||||
<size
|
||||
android:width="64dp"
|
||||
android:height="64dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
|
@ -4,11 +4,6 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackground">
|
||||
|
||||
<StackView
|
||||
android:id="@+id/accounts_stack"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
style="?android:actionButtonStyle">
|
||||
|
||||
</org.mariotaku.twidere.view.SquareFrameLayout>
|
@ -16,6 +16,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/element_size_small"
|
||||
android:textAppearance="?android:textAppearanceSmall"/>
|
||||
|
||||
<ImageView
|
||||
|
@ -1,5 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.pkmmte.view.CircularImageView
|
||||
android:id="@+id/background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:border="false"
|
||||
app:shadow="true"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@android:id/progress"
|
||||
@ -7,7 +15,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="@dimen/element_spacing_normal"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
|
@ -65,6 +65,4 @@
|
||||
|
||||
<include layout="@layout/action_item_compose_account"/>
|
||||
|
||||
<include layout="@layout/action_item_compose_send"/>
|
||||
|
||||
</LinearLayout>
|
@ -7,5 +7,4 @@
|
||||
android:layout_height="@dimen/float_action_button_size"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_margin="@dimen/element_spacing_large"
|
||||
android:background="@drawable/btn_home_actions_compat"
|
||||
android:visibility="visible"/>
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackground">
|
||||
@ -21,13 +22,16 @@
|
||||
android:layout_centerInParent="true"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<TextView
|
||||
<me.grantland.widget.AutofitTextView
|
||||
android:id="@+id/unread_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/unread_indicator_size"
|
||||
app:sizeToFit="true"
|
||||
android:layout_height="@dimen/unread_indicator_size"
|
||||
android:layout_alignRight="@+id/tab_icon"
|
||||
android:layout_alignTop="@+id/tab_icon"
|
||||
android:singleLine="true"
|
||||
android:layout_marginRight="@dimen/element_spacing_minus_small"
|
||||
android:textSize="8sp"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_small"/>
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
android:visible="false"/>
|
||||
<item
|
||||
android:id="@id/add_to_list"
|
||||
android:icon="@drawable/ic_action_list"
|
||||
android:icon="@drawable/ic_action_add_to_list"
|
||||
android:title="@string/add_to_list"/>
|
||||
<item
|
||||
android:id="@id/set_color"
|
||||
|
@ -69,5 +69,6 @@
|
||||
<!-- Dimensions for buttons -->
|
||||
<dimen name="button_width_content_min">72dp</dimen>
|
||||
<dimen name="action_icon_size">32dp</dimen>
|
||||
<dimen name="unread_indicator_size">16dp</dimen>
|
||||
|
||||
</resources>
|
@ -166,6 +166,7 @@
|
||||
<string name="twitter_muted_users">Muted users</string>
|
||||
<string name="message_user_muted">Added this user to filter list. You will not see tweets from this user in your home timeline/mentions list.</string>
|
||||
<string name="message_users_muted">Added users to filter list. You will not see tweets from these users in your home timeline/mentions list.</string>
|
||||
<string name="message_user_unmuted">Removed this user from filter list.</string>
|
||||
<string name="inbox">Inbox</string>
|
||||
<string name="load_images">Load images</string>
|
||||
<string name="other_settings">Other settings</string>
|
||||
@ -649,5 +650,15 @@
|
||||
<string name="inverse_selection">Inverse selection</string>
|
||||
<string name="edit_medias">Edit medias</string>
|
||||
<string name="medias">Medias</string>
|
||||
<string name="mute_user">Mute <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="muted_user">Muted <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="unmute_user">Unmute <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="unmuted_user">Unmuted <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="mute">Mute</string>
|
||||
<string name="unmute">Unmute</string>
|
||||
<string name="action_muting">muting</string>
|
||||
<string name="action_unmuting">unmuting</string>
|
||||
<string name="mute_user_confirm_message">Mute <xliff:g id="name">%s</xliff:g>? You will no longer see tweets from this user while keep following this user.</string>
|
||||
<string name="remove_from_filter">Remove from filter</string>
|
||||
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user