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) {
|
||||
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);
|
||||
}
|
||||
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;
|
||||
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,190 +38,191 @@ 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;
|
||||
protected SharedPreferences mPreferences;
|
||||
|
||||
private boolean mStatusesRestored;
|
||||
private boolean mIsFirstCreated;
|
||||
private boolean mStatusesRestored;
|
||||
private boolean mIsFirstCreated;
|
||||
|
||||
private final BroadcastReceiver mStateReceiver = new BroadcastReceiver() {
|
||||
private final BroadcastReceiver mStateReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
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);
|
||||
}
|
||||
} else if (BROADCAST_RETWEET_CHANGED.equals(action)) {
|
||||
final long status_id = intent.getLongExtra(EXTRA_STATUS_ID, -1);
|
||||
final boolean retweeted = intent.getBooleanExtra(EXTRA_RETWEETED, false);
|
||||
if (status_id > 0 && !retweeted) {
|
||||
deleteStatus(status_id);
|
||||
}
|
||||
} else if (BROADCAST_MULTI_MUTESTATE_CHANGED.equals(action)) {
|
||||
final Bundle args = getArguments();
|
||||
final long account_id = args != null ? args.getLong(EXTRA_ACCOUNT_ID, -1) : -1;
|
||||
if (account_id <= 0) return;
|
||||
getStatuses(new long[] { account_id }, null, null);
|
||||
}
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_STATUS_DESTROYED.equals(action)) {
|
||||
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);
|
||||
final boolean retweeted = intent.getBooleanExtra(EXTRA_RETWEETED, false);
|
||||
if (status_id > 0 && !retweeted) {
|
||||
deleteStatus(status_id);
|
||||
}
|
||||
} else if (BROADCAST_MULTI_MUTESTATE_CHANGED.equals(action)) {
|
||||
final Bundle args = getArguments();
|
||||
final long account_id = args != null ? args.getLong(EXTRA_ACCOUNT_ID, -1) : -1;
|
||||
if (account_id <= 0) return;
|
||||
getStatuses(new long[]{account_id}, null, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
public final void deleteStatus(final long status_id) {
|
||||
final List<ParcelableStatus> data = getData();
|
||||
if (status_id <= 0 || data == null) return;
|
||||
final ArrayList<ParcelableStatus> data_to_remove = new ArrayList<ParcelableStatus>();
|
||||
for (final ParcelableStatus status : data) {
|
||||
if (status.id == status_id || status.retweet_id > 0 && status.retweet_id == status_id) {
|
||||
data_to_remove.add(status);
|
||||
}
|
||||
}
|
||||
data.removeAll(data_to_remove);
|
||||
getListAdapter().setData(data);
|
||||
}
|
||||
public final void deleteStatus(final long status_id) {
|
||||
final List<ParcelableStatus> data = getData();
|
||||
if (status_id <= 0 || data == null) return;
|
||||
final ArrayList<ParcelableStatus> data_to_remove = new ArrayList<ParcelableStatus>();
|
||||
for (final ParcelableStatus status : data) {
|
||||
if (status.id == status_id || status.retweet_id > 0 && status.retweet_id == status_id) {
|
||||
data_to_remove.add(status);
|
||||
}
|
||||
}
|
||||
data.removeAll(data_to_remove);
|
||||
getListAdapter().setData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getStatuses(final long[] account_ids, final long[] max_ids, final long[] since_ids) {
|
||||
mStatusesRestored = true;
|
||||
final long max_id = max_ids != null && max_ids.length == 1 ? max_ids[0] : -1;
|
||||
final long since_id = since_ids != null && since_ids.length == 1 ? since_ids[0] : -1;
|
||||
final Bundle args = new Bundle(getArguments());
|
||||
args.putLong(EXTRA_MAX_ID, max_id);
|
||||
args.putLong(EXTRA_SINCE_ID, since_id);
|
||||
getLoaderManager().restartLoader(0, args, this);
|
||||
return -1;
|
||||
}
|
||||
@Override
|
||||
public final int getStatuses(final long[] account_ids, final long[] max_ids, final long[] since_ids) {
|
||||
mStatusesRestored = true;
|
||||
final long max_id = max_ids != null && max_ids.length == 1 ? max_ids[0] : -1;
|
||||
final long since_id = since_ids != null && since_ids.length == 1 ? since_ids[0] : -1;
|
||||
final Bundle args = new Bundle(getArguments());
|
||||
args.putLong(EXTRA_MAX_ID, max_id);
|
||||
args.putLong(EXTRA_SINCE_ID, since_id);
|
||||
getLoaderManager().restartLoader(0, args, this);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
mStatusesRestored = false;
|
||||
if (savedInstanceState != null) {
|
||||
final List<ParcelableStatus> saved = savedInstanceState.getParcelableArrayList(EXTRA_DATA);
|
||||
if (saved != null) {
|
||||
setData(saved);
|
||||
}
|
||||
}
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mPreferences = getSharedPreferences();
|
||||
mIsFirstCreated = savedInstanceState == null;
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
mStatusesRestored = false;
|
||||
if (savedInstanceState != null) {
|
||||
final List<ParcelableStatus> saved = savedInstanceState.getParcelableArrayList(EXTRA_DATA);
|
||||
if (saved != null) {
|
||||
setData(saved);
|
||||
}
|
||||
}
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mPreferences = getSharedPreferences();
|
||||
mIsFirstCreated = savedInstanceState == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Loader<List<ParcelableStatus>> onCreateLoader(final int id, final Bundle args) {
|
||||
setProgressBarIndeterminateVisibility(true);
|
||||
final List<ParcelableStatus> data = getData();
|
||||
if (isInstanceStateSaved() && data != null && !mStatusesRestored)
|
||||
return new DummyParcelableStatusesLoader(getActivity(), data);
|
||||
final Loader<List<ParcelableStatus>> loader = newLoaderInstance(getActivity(), args);
|
||||
return loader != null ? loader : new DummyParcelableStatusesLoader(getActivity());
|
||||
}
|
||||
@Override
|
||||
public final Loader<List<ParcelableStatus>> onCreateLoader(final int id, final Bundle args) {
|
||||
setProgressBarIndeterminateVisibility(true);
|
||||
final List<ParcelableStatus> data = getData();
|
||||
if (isInstanceStateSaved() && data != null && !mStatusesRestored)
|
||||
return new DummyParcelableStatusesLoader(getActivity(), data);
|
||||
final Loader<List<ParcelableStatus>> loader = newLoaderInstance(getActivity(), args);
|
||||
return loader != null ? loader : new DummyParcelableStatusesLoader(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(final Loader<List<ParcelableStatus>> loader, final List<ParcelableStatus> data) {
|
||||
super.onLoadFinished(loader, data);
|
||||
if (mIsFirstCreated && mPreferences.getBoolean(KEY_REFRESH_ON_START, false)) {
|
||||
onRefreshFromStart();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onLoadFinished(final Loader<List<ParcelableStatus>> loader, final List<ParcelableStatus> data) {
|
||||
super.onLoadFinished(loader, data);
|
||||
if (mIsFirstCreated && mPreferences.getBoolean(KEY_REFRESH_ON_START, false)) {
|
||||
onRefreshFromStart();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFromStart() {
|
||||
if (isRefreshing()) return;
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getListAdapter();
|
||||
final int count = adapter.getCount();
|
||||
final ParcelableStatus status = count > 0 ? adapter.getStatus(0) : null;
|
||||
if (status != null) {
|
||||
getStatuses(new long[] { status.account_id }, null, new long[] { status.id });
|
||||
} else {
|
||||
getStatuses(null, null, null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onRefreshFromStart() {
|
||||
if (isRefreshing()) return;
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getListAdapter();
|
||||
final int count = adapter.getCount();
|
||||
final ParcelableStatus status = count > 0 ? adapter.getStatus(0) : null;
|
||||
if (status != null) {
|
||||
getStatuses(new long[]{status.account_id}, null, new long[]{status.id});
|
||||
} else {
|
||||
getStatuses(null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(final Bundle outState) {
|
||||
final List<ParcelableStatus> data = getData();
|
||||
if (data != null) {
|
||||
outState.putParcelableArrayList(EXTRA_DATA, new ArrayList<ParcelableStatus>(data));
|
||||
}
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
@Override
|
||||
public void onSaveInstanceState(final Bundle outState) {
|
||||
final List<ParcelableStatus> data = getData();
|
||||
if (data != null) {
|
||||
outState.putParcelableArrayList(EXTRA_DATA, new ArrayList<ParcelableStatus>(data));
|
||||
}
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final IntentFilter filter = new IntentFilter(BROADCAST_STATUS_DESTROYED);
|
||||
filter.addAction(BROADCAST_RETWEET_CHANGED);
|
||||
registerReceiver(mStateReceiver, filter);
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final IntentFilter filter = new IntentFilter(BROADCAST_STATUS_DESTROYED);
|
||||
filter.addAction(BROADCAST_RETWEET_CHANGED);
|
||||
registerReceiver(mStateReceiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
unregisterReceiver(mStateReceiver);
|
||||
super.onStop();
|
||||
}
|
||||
@Override
|
||||
public void onStop() {
|
||||
unregisterReceiver(mStateReceiver);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final long[] getNewestStatusIds() {
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getListAdapter();
|
||||
final long last_id = adapter.getCount() > 0 ? adapter.getStatus(0).id : -1;
|
||||
return last_id > 0 ? new long[] { last_id } : null;
|
||||
}
|
||||
@Override
|
||||
protected final long[] getNewestStatusIds() {
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getListAdapter();
|
||||
final long last_id = adapter.getCount() > 0 ? adapter.getStatus(0).id : -1;
|
||||
return last_id > 0 ? new long[]{last_id} : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final long[] getOldestStatusIds() {
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getListAdapter();
|
||||
final ParcelableStatus status = adapter.getLastStatus();
|
||||
final long last_id = status != null ? status.id : -1;
|
||||
return last_id > 0 ? new long[] { last_id } : null;
|
||||
}
|
||||
@Override
|
||||
protected final long[] getOldestStatusIds() {
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getListAdapter();
|
||||
final ParcelableStatus status = adapter.getLastStatus();
|
||||
final long last_id = status != null ? status.id : -1;
|
||||
return last_id > 0 ? new long[]{last_id} : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final String getPositionKey() {
|
||||
final Object[] args = getSavedStatusesFileArgs();
|
||||
if (args == null || args.length <= 0) return null;
|
||||
try {
|
||||
return encodeQueryParams(ArrayUtils.toString(args, '.', false) + "." + getTabPosition());
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected final String getPositionKey() {
|
||||
final Object[] args = getSavedStatusesFileArgs();
|
||||
if (args == null || args.length <= 0) return null;
|
||||
try {
|
||||
return encodeQueryParams(ArrayUtils.toString(args, '.', false) + "." + getTabPosition());
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract Object[] getSavedStatusesFileArgs();
|
||||
protected abstract Object[] getSavedStatusesFileArgs();
|
||||
|
||||
@Override
|
||||
protected void loadMoreStatuses() {
|
||||
if (isRefreshing()) return;
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getListAdapter();
|
||||
final ParcelableStatus status = adapter.getLastStatus();
|
||||
if (status != null) {
|
||||
getStatuses(new long[] { status.account_id }, new long[] { status.id }, null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void loadMoreStatuses() {
|
||||
if (isRefreshing()) return;
|
||||
final IStatusesAdapter<List<ParcelableStatus>> adapter = getListAdapter();
|
||||
final ParcelableStatus status = adapter.getLastStatus();
|
||||
if (status != null) {
|
||||
getStatuses(new long[]{status.account_id}, new long[]{status.id}, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ParcelableStatusesAdapter newAdapterInstance(final boolean compact, final boolean plain) {
|
||||
return new ParcelableStatusesAdapter(getActivity(), compact, plain);
|
||||
}
|
||||
@Override
|
||||
protected ParcelableStatusesAdapter newAdapterInstance(final boolean compact, final boolean plain) {
|
||||
return new ParcelableStatusesAdapter(getActivity(), compact, plain);
|
||||
}
|
||||
|
||||
protected abstract Loader<List<ParcelableStatus>> newLoaderInstance(Context context, Bundle args);
|
||||
protected abstract Loader<List<ParcelableStatus>> newLoaderInstance(Context context, Bundle args);
|
||||
|
||||
@Override
|
||||
protected void updateRefreshState() {
|
||||
if (getActivity() == null || !getUserVisibleHint() || !isVisible()) return;
|
||||
final LoaderManager lm = getLoaderManager();
|
||||
final boolean hasRunningLoaders = lm.hasRunningLoaders();
|
||||
if (!hasRunningLoaders) {
|
||||
setRefreshing(true);
|
||||
}
|
||||
setRefreshing(hasRunningLoaders);
|
||||
}
|
||||
@Override
|
||||
protected void updateRefreshState() {
|
||||
if (getActivity() == null || !getUserVisibleHint() || !isVisible()) return;
|
||||
final LoaderManager lm = getLoaderManager();
|
||||
final boolean hasRunningLoaders = lm.hasRunningLoaders();
|
||||
if (!hasRunningLoaders) {
|
||||
setRefreshing(true);
|
||||
}
|
||||
setRefreshing(hasRunningLoaders);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -188,21 +188,27 @@ 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)) {
|
||||
showFollowInfo(true);
|
||||
switch (action) {
|
||||
case BROADCAST_FRIENDSHIP_CHANGED: {
|
||||
if (mStatus != null && mStatus.user_id == intent.getLongExtra(EXTRA_USER_ID, -1)) {
|
||||
showFollowInfo(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (BROADCAST_FAVORITE_CHANGED.equals(action)) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (BROADCAST_RETWEET_CHANGED.equals(action)) {
|
||||
final long status_id = intent.getLongExtra(EXTRA_STATUS_ID, -1);
|
||||
if (status_id > 0 && status_id == getStatusId()) {
|
||||
getStatus(true);
|
||||
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,137 +38,138 @@ 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;
|
||||
private ParcelableUserList mUserList;
|
||||
|
||||
private final BroadcastReceiver mStatusReceiver = new BroadcastReceiver() {
|
||||
private final BroadcastReceiver mStatusReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_USER_LIST_MEMBERS_DELETED.equals(action)) {
|
||||
final ParcelableUserList list = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (mUserList != null && list != null && list.id == mUserList.id) {
|
||||
removeUsers(intent.getLongArrayExtra(EXTRA_USER_IDS));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public CursorSupportUsersLoader newLoaderInstance(final Context context, final Bundle args) {
|
||||
if (args == null) return null;
|
||||
final int list_id = args.getInt(EXTRA_LIST_ID, -1);
|
||||
final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
final long user_id = args.getLong(EXTRA_USER_ID, -1);
|
||||
final String screen_name = args.getString(EXTRA_SCREEN_NAME);
|
||||
final String list_name = args.getString(EXTRA_LIST_NAME);
|
||||
return new UserListMembersLoader(context, account_id, list_id, user_id, screen_name, list_name,
|
||||
getNextCursor(), getData());
|
||||
}
|
||||
@Override
|
||||
public CursorSupportUsersLoader newLoaderInstance(final Context context, final Bundle args) {
|
||||
if (args == null) return null;
|
||||
final int list_id = args.getInt(EXTRA_LIST_ID, -1);
|
||||
final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
final long user_id = args.getLong(EXTRA_USER_ID, -1);
|
||||
final String screen_name = args.getString(EXTRA_SCREEN_NAME);
|
||||
final String list_name = args.getString(EXTRA_LIST_NAME);
|
||||
return new UserListMembersLoader(context, account_id, list_id, user_id, screen_name, list_name,
|
||||
getNextCursor(), getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
final Bundle args = getArguments();
|
||||
if (savedInstanceState != null) {
|
||||
mUserList = savedInstanceState.getParcelable(EXTRA_USER_LIST);
|
||||
} else if (args != null) {
|
||||
mUserList = args.getParcelable(EXTRA_USER_LIST);
|
||||
}
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if (mUserList == null && args != null) {
|
||||
final int list_id = args.getInt(EXTRA_LIST_ID, -1);
|
||||
final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
final long user_id = args.getLong(EXTRA_USER_ID, -1);
|
||||
final String screen_name = args.getString(EXTRA_SCREEN_NAME);
|
||||
final String list_name = args.getString(EXTRA_LIST_NAME);
|
||||
new GetUserListTask(account_id, list_id, list_name, user_id, screen_name).execute();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
final Bundle args = getArguments();
|
||||
if (savedInstanceState != null) {
|
||||
mUserList = savedInstanceState.getParcelable(EXTRA_USER_LIST);
|
||||
} else if (args != null) {
|
||||
mUserList = args.getParcelable(EXTRA_USER_LIST);
|
||||
}
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if (mUserList == null && args != null) {
|
||||
final int list_id = args.getInt(EXTRA_LIST_ID, -1);
|
||||
final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
final long user_id = args.getLong(EXTRA_USER_ID, -1);
|
||||
final String screen_name = args.getString(EXTRA_SCREEN_NAME);
|
||||
final String list_name = args.getString(EXTRA_LIST_NAME);
|
||||
new GetUserListTask(account_id, list_id, list_name, user_id, screen_name).execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
final ParcelableUser user = getSelectedUser();
|
||||
if (user == null || mUserList == null) return false;
|
||||
switch (item.getItemId()) {
|
||||
case MENU_DELETE_FROM_LIST: {
|
||||
DeleteUserListMembersDialogFragment.show(getFragmentManager(), mUserList, user);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return super.onMenuItemClick(item);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
final ParcelableUser user = getSelectedUser();
|
||||
if (user == null || mUserList == null) return false;
|
||||
switch (item.getItemId()) {
|
||||
case MENU_DELETE_FROM_LIST: {
|
||||
DeleteUserListMembersDialogFragment.show(getFragmentManager(), mUserList, user);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return super.onMenuItemClick(item);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(final Bundle outState) {
|
||||
outState.putParcelable(EXTRA_USER_LIST, mUserList);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
@Override
|
||||
public void onSaveInstanceState(final Bundle outState) {
|
||||
outState.putParcelable(EXTRA_USER_LIST, mUserList);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final IntentFilter filter = new IntentFilter(BROADCAST_USER_LIST_MEMBERS_DELETED);
|
||||
registerReceiver(mStatusReceiver, filter);
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final IntentFilter filter = new IntentFilter(BROADCAST_USER_LIST_MEMBERS_DELETED);
|
||||
registerReceiver(mStatusReceiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
unregisterReceiver(mStatusReceiver);
|
||||
super.onStop();
|
||||
}
|
||||
@Override
|
||||
public void onStop() {
|
||||
unregisterReceiver(mStatusReceiver);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getUserMenuResource() {
|
||||
return R.menu.action_user_list_member;
|
||||
}
|
||||
@Override
|
||||
protected int getUserMenuResource() {
|
||||
return R.menu.action_user_list_member;
|
||||
}
|
||||
|
||||
private class GetUserListTask extends AsyncTask<Void, Void, ParcelableUserList> {
|
||||
private class GetUserListTask extends AsyncTask<Void, Void, ParcelableUserList> {
|
||||
|
||||
private final long account_id, user_id;
|
||||
private final int list_id;
|
||||
private final String screen_name, list_name;
|
||||
private final long account_id, user_id;
|
||||
private final int list_id;
|
||||
private final String screen_name, list_name;
|
||||
|
||||
private GetUserListTask(final long account_id, final int list_id, final String list_name, final long user_id,
|
||||
final String screen_name) {
|
||||
this.account_id = account_id;
|
||||
this.user_id = user_id;
|
||||
this.list_id = list_id;
|
||||
this.screen_name = screen_name;
|
||||
this.list_name = list_name;
|
||||
}
|
||||
private GetUserListTask(final long account_id, final int list_id, final String list_name, final long user_id,
|
||||
final String screen_name) {
|
||||
this.account_id = account_id;
|
||||
this.user_id = user_id;
|
||||
this.list_id = list_id;
|
||||
this.screen_name = screen_name;
|
||||
this.list_name = list_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ParcelableUserList doInBackground(final Void... params) {
|
||||
final Twitter twitter = getTwitterInstance(getActivity(), account_id, true);
|
||||
if (twitter == null) return null;
|
||||
try {
|
||||
final UserList list;
|
||||
if (list_id > 0) {
|
||||
list = twitter.showUserList(list_id);
|
||||
} else if (user_id > 0) {
|
||||
list = twitter.showUserList(list_name, user_id);
|
||||
} else if (screen_name != null) {
|
||||
list = twitter.showUserList(list_name, screen_name);
|
||||
} else
|
||||
return null;
|
||||
return new ParcelableUserList(list, account_id);
|
||||
} catch (final TwitterException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected ParcelableUserList doInBackground(final Void... params) {
|
||||
final Twitter twitter = getTwitterInstance(getActivity(), account_id, true);
|
||||
if (twitter == null) return null;
|
||||
try {
|
||||
final UserList list;
|
||||
if (list_id > 0) {
|
||||
list = twitter.showUserList(list_id);
|
||||
} else if (user_id > 0) {
|
||||
list = twitter.showUserList(list_name, user_id);
|
||||
} else if (screen_name != null) {
|
||||
list = twitter.showUserList(list_name, screen_name);
|
||||
} else
|
||||
return null;
|
||||
return new ParcelableUserList(list, account_id);
|
||||
} catch (final TwitterException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final ParcelableUserList result) {
|
||||
if (mUserList != null) return;
|
||||
mUserList = result;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(final ParcelableUserList result) {
|
||||
if (mUserList != null) return;
|
||||
mUserList = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,27 +181,31 @@ 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)) {
|
||||
getFriendship();
|
||||
switch (action) {
|
||||
case BROADCAST_FRIENDSHIP_CHANGED: {
|
||||
if (intent.getLongExtra(EXTRA_USER_ID, -1) == mUser.id) {
|
||||
getFriendship();
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (BROADCAST_BLOCKSTATE_CHANGED.equals(action)) {
|
||||
if (intent.getLongExtra(EXTRA_USER_ID, -1) == mUser.id && intent.getBooleanExtra(EXTRA_SUCCEED, false)) {
|
||||
getFriendship();
|
||||
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);
|
||||
}
|
||||
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)) {
|
||||
getUserInfo(true);
|
||||
case BROADCAST_TASK_STATE_CHANGED: {
|
||||
final AsyncTwitterWrapper twitter = getTwitterWrapper();
|
||||
final boolean is_creating_friendship = twitter != null
|
||||
&& twitter.isCreatingFriendship(mUser.account_id, mUser.id);
|
||||
final boolean is_destroying_friendship = twitter != null
|
||||
&& twitter.isDestroyingFriendship(mUser.account_id, mUser.id);
|
||||
setProgressBarIndeterminateVisibility(is_creating_friendship || is_destroying_friendship);
|
||||
invalidateOptionsMenu();
|
||||
break;
|
||||
}
|
||||
} else if (BROADCAST_TASK_STATE_CHANGED.equals(action)) {
|
||||
final AsyncTwitterWrapper twitter = getTwitterWrapper();
|
||||
final boolean is_creating_friendship = twitter != null
|
||||
&& twitter.isCreatingFriendship(mUser.account_id, mUser.id);
|
||||
final boolean is_destroying_friendship = twitter != null
|
||||
&& twitter.isDestroyingFriendship(mUser.account_id, mUser.id);
|
||||
setProgressBarIndeterminateVisibility(is_creating_friendship || is_destroying_friendship);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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));
|
||||
showInfoMessage(getActivity(), R.string.message_user_muted, false);
|
||||
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);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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,49 +30,42 @@ import org.mariotaku.twidere.Constants;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.isOnWifi;
|
||||
|
||||
/**
|
||||
* @author mariotaku
|
||||
*/
|
||||
public class ImagePreloader implements Constants {
|
||||
|
||||
public static final String LOGTAG = "ImagePreloader";
|
||||
public static final String LOGTAG = "ImagePreloader";
|
||||
|
||||
private final Context mContext;
|
||||
private final SharedPreferences mPreferences;
|
||||
private final Handler mHandler;
|
||||
private final DiskCache mDiskCache;
|
||||
private final ImageLoader mImageLoader;
|
||||
private final Context mContext;
|
||||
private final SharedPreferences mPreferences;
|
||||
private final DiskCache mDiskCache;
|
||||
private final ImageLoader mImageLoader;
|
||||
|
||||
public ImagePreloader(final Context context, final ImageLoader loader) {
|
||||
mContext = context;
|
||||
mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mImageLoader = loader;
|
||||
mDiskCache = loader.getDiskCache();
|
||||
mHandler = new Handler();
|
||||
}
|
||||
public ImagePreloader(final Context context, final ImageLoader loader) {
|
||||
mContext = context;
|
||||
mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mImageLoader = loader;
|
||||
mDiskCache = loader.getDiskCache();
|
||||
}
|
||||
|
||||
public File getCachedImageFile(final String url) {
|
||||
if (url == null) return null;
|
||||
final File cache = mDiskCache.get(url);
|
||||
if (ImageValidator.checkImageValidity(cache))
|
||||
return cache;
|
||||
else {
|
||||
preloadImage(url);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public File getCachedImageFile(final String url) {
|
||||
if (url == null) return null;
|
||||
final File cache = mDiskCache.get(url);
|
||||
if (ImageValidator.checkImageValidity(cache))
|
||||
return cache;
|
||||
else {
|
||||
preloadImage(url);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
public void preloadImage(final String url) {
|
||||
if (TextUtils.isEmpty(url)) return;
|
||||
if (!isOnWifi(mContext) && mPreferences.getBoolean(KEY_PRELOAD_WIFI_ONLY, true)) return;
|
||||
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 {
|
||||
final Toast toast = Toast.makeText(context, message, long_message ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
// 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
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 268 B |
Binary file not shown.
After Width: | Height: | Size: 172 B |
Binary file not shown.
After Width: | Height: | Size: 317 B |
Binary file not shown.
After Width: | Height: | Size: 540 B |
|
@ -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,22 +1,29 @@
|
|||
<?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">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@android:id/progress"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="@dimen/element_spacing_normal"
|
||||
android:visibility="gone"/>
|
||||
<com.pkmmte.view.CircularImageView
|
||||
android:id="@+id/background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:border="false"
|
||||
app:shadow="true"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
<ProgressBar
|
||||
android:id="@android:id/progress"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="@dimen/element_spacing_normal"
|
||||
android:contentDescription="@string/compose"
|
||||
android:scaleType="centerInside"/>
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="@dimen/element_spacing_normal"
|
||||
android:contentDescription="@string/compose"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
</merge>
|
|
@ -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…
Reference in New Issue