merged #125 #126 manually

theme improvements
This commit is contained in:
Mariotaku Lee 2015-04-17 22:36:04 +08:00
parent 6a1c8ae176
commit bf42c3d792
39 changed files with 326 additions and 264 deletions

View File

@ -220,5 +220,6 @@ public interface IntentConstants {
public static final String EXTRA_BITMAP = "bitmap";
public static final String EXTRA_SOURCE = "source";
public static final String EXTRA_DESTINATION = "destination";
public static final String EXTRA_ACTIVITY_OPTIONS = "activity_options";
}

View File

@ -134,20 +134,6 @@ import java.util.Collections;
import java.util.List;
import java.util.TreeSet;
import static android.text.TextUtils.isEmpty;
import static org.mariotaku.twidere.util.ParseUtils.parseString;
import static org.mariotaku.twidere.util.ThemeUtils.getComposeThemeResource;
import static org.mariotaku.twidere.util.Utils.addIntentToMenu;
import static org.mariotaku.twidere.util.Utils.copyStream;
import static org.mariotaku.twidere.util.Utils.getAccountIds;
import static org.mariotaku.twidere.util.Utils.getAccountName;
import static org.mariotaku.twidere.util.Utils.getAccountScreenName;
import static org.mariotaku.twidere.util.Utils.getDefaultTextSize;
import static org.mariotaku.twidere.util.Utils.getImageUploadStatus;
import static org.mariotaku.twidere.util.Utils.getQuoteStatus;
import static org.mariotaku.twidere.util.Utils.getShareStatus;
import static org.mariotaku.twidere.util.Utils.showMenuItemToast;
public class ComposeActivity extends ThemedFragmentActivity implements TextWatcher, LocationListener,
OnMenuItemClickListener, OnClickListener, OnEditorActionListener, OnLongClickListener, Callback {
@ -247,7 +233,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
@Override
public int getThemeResourceId() {
return getComposeThemeResource(this);
return ThemeUtils.getComposeThemeResource(this);
}
@Override
@ -435,7 +421,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
public boolean onLongClick(final View v) {
switch (v.getId()) {
case R.id.send: {
showMenuItemToast(v, getString(R.string.send), true);
Utils.showMenuItemToast(v, getString(R.string.send), true);
return true;
}
}
@ -500,8 +486,8 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
intent.putExtra(EXTRA_ACCOUNT_IDS, accountIds);
if (accountIds.length > 0) {
final long account_id = accountIds[0];
intent.putExtra(EXTRA_NAME, getAccountName(this, account_id));
intent.putExtra(EXTRA_SCREEN_NAME, getAccountScreenName(this, account_id));
intent.putExtra(EXTRA_NAME, Utils.getAccountName(this, account_id));
intent.putExtra(EXTRA_SCREEN_NAME, Utils.getAccountScreenName(this, account_id));
}
if (mInReplyToStatusId > 0) {
intent.putExtra(EXTRA_IN_REPLY_TO_ID, mInReplyToStatusId);
@ -608,7 +594,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
setContentView(R.layout.activity_compose);
// setSupportProgressBarIndeterminateVisibility(false);
setFinishOnTouchOutside(false);
final long[] defaultAccountIds = getAccountIds(this);
final long[] defaultAccountIds = Utils.getAccountIds(this);
if (defaultAccountIds.length <= 0) {
final Intent intent = new Intent(INTENT_ACTION_TWITTER_LOGIN);
intent.setClass(this, SignInActivity.class);
@ -684,11 +670,11 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
mSendView.setOnClickListener(this);
mSendView.setOnLongClickListener(this);
final Intent composeExtensionsIntent = new Intent(INTENT_ACTION_EXTENSION_COMPOSE);
addIntentToMenu(this, menu, composeExtensionsIntent, MENU_GROUP_COMPOSE_EXTENSION);
Utils.addIntentToMenu(this, menu, composeExtensionsIntent, MENU_GROUP_COMPOSE_EXTENSION);
final Intent imageExtensionsIntent = new Intent(INTENT_ACTION_EXTENSION_EDIT_IMAGE);
final MenuItem mediaMenuItem = menu.findItem(R.id.media_menu);
if (mediaMenuItem != null && mediaMenuItem.hasSubMenu()) {
addIntentToMenu(this, mediaMenuItem.getSubMenu(), imageExtensionsIntent, MENU_GROUP_IMAGE_EXTENSION);
Utils.addIntentToMenu(this, mediaMenuItem.getSubMenu(), imageExtensionsIntent, MENU_GROUP_IMAGE_EXTENSION);
}
setMenu();
updateLocationState();
@ -718,7 +704,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
startLocationUpdateIfEnabled();
setMenu();
updateTextCount();
final int text_size = mPreferences.getInt(KEY_TEXT_SIZE, getDefaultTextSize(this));
final int text_size = mPreferences.getInt(KEY_TEXT_SIZE, Utils.getDefaultTextSize(this));
mEditText.setTextSize(text_size * 1.25f);
}
@ -847,7 +833,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
}
}
}
mEditText.setText(getShareStatus(this, extraSubject, extraText));
mEditText.setText(Utils.getShareStatus(this, extraSubject, extraText));
final int selection_end = mEditText.length();
mEditText.setSelection(selection_end);
return true;
@ -906,8 +892,8 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
private boolean handleMentionIntent(final ParcelableUser user) {
if (user == null || user.id <= 0) return false;
final String my_screen_name = getAccountScreenName(this, user.account_id);
if (isEmpty(my_screen_name)) return false;
final String my_screen_name = Utils.getAccountScreenName(this, user.account_id);
if (TextUtils.isEmpty(my_screen_name)) return false;
mEditText.setText("@" + user.screen_name + " ");
final int selection_end = mEditText.length();
mEditText.setSelection(selection_end);
@ -917,7 +903,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
private boolean handleQuoteIntent(final ParcelableStatus status) {
if (status == null || status.id <= 0) return false;
mEditText.setText(getQuoteStatus(this, status.user_screen_name, status.text_plain));
mEditText.setText(Utils.getQuoteStatus(this, status.id, status.user_screen_name, status.text_plain));
mEditText.setSelection(0);
mAccountsAdapter.setSelectedAccountIds(status.account_id);
return true;
@ -925,11 +911,11 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
private boolean handleReplyIntent(final ParcelableStatus status) {
if (status == null || status.id <= 0) return false;
final String myScreenName = getAccountScreenName(this, status.account_id);
if (isEmpty(myScreenName)) return false;
final String myScreenName = Utils.getAccountScreenName(this, status.account_id);
if (TextUtils.isEmpty(myScreenName)) return false;
mEditText.append("@" + status.user_screen_name + " ");
final int selectionStart = mEditText.length();
if (!isEmpty(status.retweeted_by_screen_name)) {
if (!TextUtils.isEmpty(status.retweeted_by_screen_name)) {
mEditText.append("@" + status.retweeted_by_screen_name + " ");
}
final Collection<String> mentions = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
@ -950,8 +936,8 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
private boolean handleReplyMultipleIntent(final String[] screenNames, final long accountId,
final long inReplyToStatusId) {
if (screenNames == null || screenNames.length == 0 || accountId <= 0) return false;
final String myScreenName = getAccountScreenName(this, accountId);
if (isEmpty(myScreenName)) return false;
final String myScreenName = Utils.getAccountScreenName(this, accountId);
if (TextUtils.isEmpty(myScreenName)) return false;
for (final String screenName : screenNames) {
if (screenName.equalsIgnoreCase(myScreenName)) {
continue;
@ -1097,7 +1083,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
final int textLength = mEditText.length();
mEditText.setSelection(textLength - (tweetLength - maxLength), textLength);
return;
} else if (!hasMedia && (isEmpty(text) || noReplyContent(text))) {
} else if (!hasMedia && (TextUtils.isEmpty(text) || noReplyContent(text))) {
mEditText.setError(getString(R.string.error_message_no_content));
return;
} else if (mAccountsAdapter.isSelectionEmpty()) {
@ -1154,8 +1140,8 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
private void updateTextCount() {
if (mSendTextCountView == null || mEditText == null) return;
final String textOrig = parseString(mEditText.getText());
final String text = hasMedia() && textOrig != null ? mImageUploaderUsed ? getImageUploadStatus(this,
final String textOrig = ParseUtils.parseString(mEditText.getText());
final String text = hasMedia() && textOrig != null ? mImageUploaderUsed ? Utils.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);
@ -1341,7 +1327,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
final ContentResolver resolver = activity.getContentResolver();
final InputStream is = resolver.openInputStream(src);
final OutputStream os = resolver.openOutputStream(dst);
copyStream(is, os);
Utils.copyStream(is, os);
os.close();
if (ContentResolver.SCHEME_FILE.equals(src.getScheme()) && delete_src) {
final File file = new File(src.getPath());

View File

@ -21,9 +21,11 @@ package org.mariotaku.twidere.activity.support;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.AsyncTask.Status;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.DialogFragment;
@ -31,11 +33,16 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.support.v7.widget.Toolbar;
import android.support.v4.view.WindowCompat;
import android.support.v7.app.ActionBar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
@ -43,7 +50,6 @@ import android.widget.Toast;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.fragment.support.SupportProgressDialogFragment;
import org.mariotaku.twidere.graphic.EmptyDrawable;
import org.mariotaku.twidere.loader.support.ParcelableUserLoader;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.SingleResponse;
@ -55,8 +61,8 @@ import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.TwitterWrapper;
import org.mariotaku.twidere.util.ViewUtils;
import org.mariotaku.twidere.view.ForegroundColorView;
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
import org.mariotaku.twidere.view.iface.IExtendedView.OnSizeChangedListener;
import twitter4j.Twitter;
@ -77,28 +83,21 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
private static final int REQUEST_UPLOAD_PROFILE_BANNER_IMAGE = 2;
private static final int REQUEST_PICK_LINK_COLOR = 3;
private static final int REQUEST_PICK_BACKGROUND_COLOR = 4;
private MediaLoaderWrapper mLazyImageLoader;
private AsyncTaskManager mAsyncTaskManager;
private AsyncTask<Object, Object, ?> mTask;
private TintedStatusFrameLayout mMainContent;
private ImageView mProfileImageView;
private ImageView mProfileBannerView;
private EditText mEditName, mEditDescription, mEditLocation, mEditUrl;
private View mProgressContainer, mEditProfileContent;
private View mProfileImageCamera, mProfileImageGallery;
private View mProfileBannerGallery, mProfileBannerRemove;
private View mActionBarOverlay;
private View mCancelButton, mDoneButton;
private View mSetLinkColor, mSetBackgroundColor;
private ForegroundColorView mLinkColor, mBackgroundColor;
private Toolbar mToolbar;
private long mAccountId;
private ParcelableUser mUser;
private boolean mUserInfoLoaderInitialized;
private boolean mGetUserInfoCalled;
@Override
@ -116,29 +115,70 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
@Override
public int getThemeResourceId() {
return ThemeUtils.getThemeResource(this);
return ThemeUtils.getDialogWhenLargeThemeResource(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_HOME: {
finish();
return true;
}
case MENU_SAVE: {
final String name = ParseUtils.parseString(mEditName.getText());
final String url = ParseUtils.parseString(mEditUrl.getText());
final String location = ParseUtils.parseString(mEditLocation.getText());
final String description = ParseUtils.parseString(mEditDescription.getText());
final int linkColor = mLinkColor.getColor();
final int backgroundColor = mBackgroundColor.getColor();
mTask = new UpdateProfileTaskInternal(this, mAccountId, mUser, name, url, location,
description, linkColor, backgroundColor);
AsyncTaskUtils.executeTask(mTask);
return true;
}
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
final Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
window.addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
mAsyncTaskManager = TwidereApplication.getInstance(this).getAsyncTaskManager();
mLazyImageLoader = TwidereApplication.getInstance(this).getMediaLoaderWrapper();
final Intent intent = getIntent();
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
mAccountId = accountId;
if (!isMyAccount(this, accountId)) {
finish();
return;
}
mAsyncTaskManager = TwidereApplication.getInstance(this).getAsyncTaskManager();
mLazyImageLoader = TwidereApplication.getInstance(this).getMediaLoaderWrapper();
mAccountId = accountId;
final ActionBar actionBar = getSupportActionBar();
final int themeColor = getCurrentThemeColor();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
final int themeId = getCurrentThemeResourceId();
final String option = getThemeBackgroundOption();
final int actionBarItemsColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor);
ThemeUtils.applyActionBarBackground(actionBar, this, themeId, themeColor, option, true);
ThemeUtils.setActionBarItemsColor(getWindow(), actionBar, actionBarItemsColor);
}
setContentView(R.layout.activity_user_profile_editor);
setSupportActionBar(mToolbar);
ViewUtils.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
ViewUtils.setBackground(mToolbar, ThemeUtils.getSupportActionBarBackground(mToolbar.getContext(),
getCurrentThemeResourceId()));
ThemeUtils.setCompatToolbarOverlay(this, new EmptyDrawable());
mMainContent.setOnFitSystemWindowsListener(this);
if (ThemeUtils.isDarkTheme(getCurrentThemeResourceId())) {
mMainContent.setColor(getResources().getColor(R.color.background_color_action_bar_dark));
} else {
mMainContent.setColor(themeColor);
}
mMainContent.setDrawColor(true);
// setOverrideExitAniamtion(false);
mEditName.addTextChangedListener(this);
mEditDescription.addTextChangedListener(this);
@ -150,8 +190,6 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
mProfileImageGallery.setOnClickListener(this);
mProfileBannerGallery.setOnClickListener(this);
mProfileBannerRemove.setOnClickListener(this);
mCancelButton.setOnClickListener(this);
mDoneButton.setOnClickListener(this);
mSetLinkColor.setOnClickListener(this);
mSetBackgroundColor.setOnClickListener(this);
@ -167,6 +205,17 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
}
}
@Override
public void onFitSystemWindows(Rect insets) {
mMainContent.setPadding(insets.left, insets.top, insets.right, insets.bottom);
super.onFitSystemWindows(insets);
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
@ -177,11 +226,6 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
outState.putString(EXTRA_URL, ParseUtils.parseString(mEditUrl.getText()));
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
super.onStop();
@ -222,22 +266,6 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
AsyncTaskUtils.executeTask(mTask);
break;
}
case R.id.actionbar_cancel: {
finish();
break;
}
case R.id.actionbar_done: {
final String name = ParseUtils.parseString(mEditName.getText());
final String url = ParseUtils.parseString(mEditUrl.getText());
final String location = ParseUtils.parseString(mEditLocation.getText());
final String description = ParseUtils.parseString(mEditDescription.getText());
final int linkColor = mLinkColor.getColor();
final int backgroundColor = mBackgroundColor.getColor();
mTask = new UpdateProfileTaskInternal(this, mAccountId, mUser, name, url, location,
description, linkColor, backgroundColor);
AsyncTaskUtils.executeTask(mTask);
break;
}
case R.id.set_link_color: {
final Intent intent = new Intent(this, ColorPickerDialogActivity.class);
intent.putExtra(EXTRA_COLOR, user.link_color);
@ -269,7 +297,6 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
if (data.getData() != null && data.getData().id > 0) {
displayUser(data.getData());
} else if (mUser == null) {
finish();
}
}
@ -278,6 +305,12 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_profile_editor, menu);
return true;
}
@Override
public void onSizeChanged(final View view, final int w, final int h, final int oldw, final int oldh) {
}
@ -285,7 +318,7 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
@Override
public void onSupportContentChanged() {
super.onSupportContentChanged();
mToolbar = (Toolbar) findViewById(R.id.done_bar);
mMainContent = (TintedStatusFrameLayout) findViewById(R.id.main_content);
mProgressContainer = findViewById(R.id.progress_container);
mEditProfileContent = findViewById(R.id.edit_profile_content);
mProfileBannerView = (ImageView) findViewById(R.id.profile_banner);
@ -294,15 +327,12 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
mEditDescription = (EditText) findViewById(R.id.description);
mEditLocation = (EditText) findViewById(R.id.location);
mEditUrl = (EditText) findViewById(R.id.url);
mActionBarOverlay = findViewById(R.id.actionbar_overlay);
mProfileImageCamera = findViewById(R.id.profile_image_camera);
mProfileImageGallery = findViewById(R.id.profile_image_gallery);
mProfileBannerGallery = findViewById(R.id.profile_banner_gallery);
mProfileBannerRemove = findViewById(R.id.profile_banner_remove);
mLinkColor = (ForegroundColorView) findViewById(R.id.link_color);
mBackgroundColor = (ForegroundColorView) findViewById(R.id.background_color);
mCancelButton = findViewById(R.id.actionbar_cancel);
mDoneButton = findViewById(R.id.actionbar_done);
mSetLinkColor = findViewById(R.id.set_link_color);
mSetBackgroundColor = findViewById(R.id.set_background_color);
}
@ -411,7 +441,7 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
}
private void updateDoneButton() {
mDoneButton.setEnabled(isProfileChanged());
}
static class UpdateProfileTaskInternal extends AsyncTask<Object, Object, SingleResponse<ParcelableUser>> {

View File

@ -41,8 +41,8 @@ import org.mariotaku.twidere.model.ParcelableActivity;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.MediaLoadingHandler;
import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.MediaLoadingHandler;
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.TwidereLinkify;
@ -88,7 +88,7 @@ public abstract class AbsActivitiesAdapter<Data> extends Adapter<ViewHolder> imp
protected AbsActivitiesAdapter(final Context context, boolean compact) {
mContext = context;
final TwidereApplication app = TwidereApplication.getInstance(context);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
mInflater = LayoutInflater.from(context);
mImageLoader = app.getMediaLoaderWrapper();
mLoadingHandler = new MediaLoadingHandler(R.id.media_preview_progress);

View File

@ -72,7 +72,7 @@ public abstract class AbsStatusesAdapter<D> extends LoadMoreSupportAdapter<ViewH
public AbsStatusesAdapter(Context context, boolean compact) {
mContext = context;
final TwidereApplication app = TwidereApplication.getInstance(context);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
mInflater = LayoutInflater.from(context);
mMediaLoader = app.getMediaLoaderWrapper();
mLoadingHandler = new MediaLoadingHandler(R.id.media_preview_progress);

View File

@ -58,7 +58,7 @@ public abstract class AbsUsersAdapter<D> extends LoadMoreSupportAdapter<ViewHold
public AbsUsersAdapter(final Context context, final boolean compact) {
final TwidereApplication app = TwidereApplication.getInstance(context);
mContext = context;
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
mInflater = LayoutInflater.from(context);
mMediaLoader = app.getMediaLoaderWrapper();
mTwitterWrapper = app.getTwitterWrapper();

View File

@ -21,6 +21,7 @@ package org.mariotaku.twidere.adapter;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
@ -36,8 +37,8 @@ import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.model.ParcelableDirectMessage;
import org.mariotaku.twidere.model.ParcelableDirectMessage.CursorIndices;
import org.mariotaku.twidere.util.DirectMessageOnLinkClickHandler;
import org.mariotaku.twidere.util.MediaLoadingHandler;
import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.MediaLoadingHandler;
import org.mariotaku.twidere.util.MultiSelectManager;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.TwidereLinkify;
@ -76,7 +77,7 @@ public class MessageConversationAdapter extends Adapter<ViewHolder>
mImageLoader = app.getMediaLoaderWrapper();
mMediaLoadingHandler = new MediaLoadingHandler(R.id.media_preview_progress);
mIncomingMessageColor = ThemeUtils.getUserAccentColor(context);
mOutgoingMessageColor = ThemeUtils.getCardBackgroundColor(context);
mOutgoingMessageColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
}
@ -172,7 +173,9 @@ public class MessageConversationAdapter extends Adapter<ViewHolder>
case R.id.media_preview: {
final ParcelableDirectMessage message = getDirectMessage(position);
if (message == null || message.media == null) return;
openMedia(mContext, message, null);
//TODO open media animation
Bundle options = null;
openMedia(mContext, message, null, options);
}
}
}

View File

@ -246,7 +246,9 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListFragment<A
final AbsStatusesAdapter<Data> adapter = getAdapter();
final ParcelableStatus status = adapter.getStatus(position);
if (status == null) return;
Utils.openMedia(getActivity(), status, media);
//TODO open media animation
Bundle options = null;
Utils.openMedia(getActivity(), status, media, options);
//spice
SpiceProfilingUtil.log(getActivity(),
status.id + ",Clicked," + status.account_id + "," + status.user_id + "," + status.text_plain.length()

View File

@ -47,9 +47,10 @@ public class SensitiveContentWarningDialogFragment extends BaseSupportDialogFrag
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
final ParcelableMedia current = args.getParcelable(EXTRA_CURRENT_MEDIA);
final ParcelableStatus status = args.getParcelable(EXTRA_STATUS);
final Bundle option = args.getBundle(EXTRA_ACTIVITY_OPTIONS);
final ParcelableMedia[] media = Utils.newParcelableArray(args.getParcelableArray(EXTRA_MEDIA),
ParcelableMedia.CREATOR);
openMediaDirectly(context, accountId, status, current, media);
openMediaDirectly(context, accountId, status, current, media, option);
break;
}
}

View File

@ -75,7 +75,6 @@ import android.widget.Space;
import android.widget.TextView;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.iface.IThemedActivity;
import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity;
import org.mariotaku.twidere.adapter.AbsStatusesAdapter.StatusAdapterListener;
import org.mariotaku.twidere.adapter.decorator.DividerItemDecoration;
@ -108,7 +107,7 @@ import org.mariotaku.twidere.util.TwidereLinkify;
import org.mariotaku.twidere.util.TwitterCardUtils;
import org.mariotaku.twidere.util.UserColorNameUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener;
import org.mariotaku.twidere.view.CardMediaContainer;
import org.mariotaku.twidere.view.ColorLabelRelativeLayout;
import org.mariotaku.twidere.view.ForegroundColorView;
@ -296,14 +295,16 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
final ParcelableStatus status = mStatusAdapter.getStatus(position);
if (status == null) return;
Utils.openMedia(getActivity(), status, media);
//TODO open media animation
Bundle options = null;
Utils.openMedia(getActivity(), status, media, options);
SpiceProfilingUtil.log(getActivity(),
status.id + ",Clicked," + status.account_id + "," + status.user_id + "," + status.text_plain.length()
+ "," + media.media_url + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + media.preview_url + "," + media.media_url + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + mStatusAdapter.isMediaPreviewEnabled() + "," + status.timestamp);
SpiceProfilingUtil.profile(getActivity(), status.account_id,
status.id + ",Clicked," + status.account_id + "," + status.user_id + "," + status.text_plain.length()
+ "," + media.media_url + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + media.preview_url + "," + media.media_url + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + mStatusAdapter.isMediaPreviewEnabled() + "," + status.timestamp);
}
@ -379,15 +380,17 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
public void onMediaClick(View view, ParcelableMedia media, long accountId) {
final ParcelableStatus status = mStatusAdapter.getStatus();
if (status == null) return;
Utils.openMediaDirectly(getActivity(), accountId, status, media, status.media);
//TODO open media animation
Bundle options = null;
Utils.openMediaDirectly(getActivity(), accountId, status, media, status.media, options);
//spice
SpiceProfilingUtil.log(getActivity(),
status.id + ",Clicked," + status.account_id + "," + status.user_id + "," + status.text_plain.length()
+ "," + media.media_url + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + media.preview_url + "," + media.media_url + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + mStatusAdapter.isMediaPreviewEnabled() + "," + status.timestamp);
SpiceProfilingUtil.profile(getActivity(), status.account_id,
status.id + ",Clicked," + status.account_id + "," + status.user_id + "," + status.text_plain.length()
+ "," + media.media_url + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + media.preview_url + "," + media.media_url + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + mStatusAdapter.isMediaPreviewEnabled() + "," + status.timestamp);
//end
}
@ -444,31 +447,31 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
+ "," + status.reply_count + "," + status.retweet_count + "," + status.favorite_count
+ "," + status.text_plain.length() + "," + status.timestamp);
} else {
for (final ParcelableMedia spiceMedia : status.media) {
if (spiceMedia.type == ParcelableMedia.TYPE_IMAGE) {
for (final ParcelableMedia media : status.media) {
if (media.type == ParcelableMedia.TYPE_IMAGE) {
SpiceProfilingUtil.profile(getActivity(), status.account_id,
status.id + ",PreviewM," + status.account_id + "," + status.user_id
+ "," + status.reply_count + "," + status.retweet_count + "," + status.favorite_count
+ "," + status.text_plain.length() + "," + TypeMappingUtil.getMediaType(spiceMedia.type)
+ "," + spiceMedia.media_url + "," + spiceMedia.width + "x" + spiceMedia.height
+ "," + status.text_plain.length() + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + media.media_url + "," + media.width + "x" + media.height
+ "," + status.timestamp);
SpiceProfilingUtil.log(getActivity(),
status.id + ",PreviewM," + status.account_id + "," + status.user_id
+ "," + status.reply_count + "," + status.retweet_count + "," + status.favorite_count
+ "," + status.text_plain.length() + "," + TypeMappingUtil.getMediaType(spiceMedia.type)
+ "," + spiceMedia.media_url + "," + spiceMedia.width + "x" + spiceMedia.height
+ "," + status.text_plain.length() + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + media.media_url + "," + media.width + "x" + media.height
+ "," + status.timestamp);
} else {
SpiceProfilingUtil.profile(getActivity(), status.account_id,
status.id + ",PreviewO," + status.account_id + "," + status.user_id
+ "," + status.reply_count + "," + status.retweet_count + "," + status.favorite_count
+ "," + status.text_plain.length() + "," + TypeMappingUtil.getMediaType(spiceMedia.type)
+ "," + spiceMedia.media_url + "," + status.timestamp);
+ "," + status.text_plain.length() + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + media.preview_url + "," + media.media_url + "," + status.timestamp);
SpiceProfilingUtil.log(getActivity(),
status.id + ",PreviewO," + status.account_id + "," + status.user_id
+ "," + status.reply_count + "," + status.retweet_count + "," + status.favorite_count
+ "," + status.text_plain.length() + "," + TypeMappingUtil.getMediaType(spiceMedia.type)
+ "," + spiceMedia.media_url + "," + status.timestamp);
+ "," + status.text_plain.length() + "," + TypeMappingUtil.getMediaType(media.type)
+ "," + media.preview_url + "," + media.media_url + "," + status.timestamp);
}
}
}
@ -1057,7 +1060,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
mInflater = LayoutInflater.from(context);
mImageLoader = TwidereApplication.getInstance(context).getMediaLoaderWrapper();
mMediaLoadingHandler = new MediaLoadingHandler(R.id.media_preview_progress);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
mNameFirst = preferences.getBoolean(KEY_NAME_FIRST, true);
mTextSize = preferences.getInt(KEY_TEXT_SIZE, res.getInteger(R.integer.default_text_size));
mProfileImageStyle = Utils.getProfileImageStyle(preferences.getString(KEY_PROFILE_IMAGE_STYLE, null));

View File

@ -680,7 +680,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
getSharedPreferences(USER_NICKNAME_PREFERENCES_NAME, Context.MODE_PRIVATE)
.registerOnSharedPreferenceChangeListener(this);
mLocale = getResources().getConfiguration().locale;
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(activity);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(activity, ThemeUtils.getThemeBackgroundOption(activity), ThemeUtils.getUserThemeBackgroundAlpha(activity));
mActionBarShadowColor = 0xA0000000;
mProfileImageLoader = getApplication().getMediaLoaderWrapper();
final Bundle args = getArguments();
@ -1113,14 +1113,18 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
case R.id.profile_image: {
final String url = Utils.getOriginalTwitterProfileImage(user.profile_image_url);
final ParcelableMedia[] media = {ParcelableMedia.newImage(url, url)};
Utils.openMedia(activity, user.account_id, false, null, media);
//TODO open media animation
Bundle options = null;
Utils.openMedia(activity, user.account_id, false, null, media, options);
break;
}
case R.id.profile_banner: {
if (user.profile_banner_url == null) return;
final String url = user.profile_banner_url + "/ipad_retina";
final ParcelableMedia[] media = {ParcelableMedia.newImage(url, url)};
Utils.openMedia(activity, user.account_id, false, null, media);
//TODO open media animation
Bundle options = null;
Utils.openMedia(activity, user.account_id, false, null, media, options);
break;
}
case R.id.listed_container: {

View File

@ -105,7 +105,7 @@ public class ThemePreviewPreference extends Preference implements Constants, OnS
final CardView cardView = (CardView) view.findViewById(R.id.card);
final int defaultTextSize = getDefaultTextSize(context);
final int cardBackgroundColor = ThemeUtils.getCardBackgroundColor(context);
final int cardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
final int accentColor = ThemeUtils.getUserAccentColor(context);
final int themeId = ThemeUtils.getThemeResource(context);

View File

@ -2389,14 +2389,14 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
+ "," + spiceMedia.media_url + "," + TypeMappingUtil.getMediaType(spiceMedia.type) + "," + spiceMedia.width + "x" + spiceMedia.height);
SpiceProfilingUtil.profile(getContext(), account_id, status.id + ",RetweetM," + account_id + ","
+ status.user_id + "," + status.reply_count + "," + status.retweet_count + "," + status.favorite_count
+ "," + spiceMedia.media_url + "," + TypeMappingUtil.getMediaType(spiceMedia.type) + "," + spiceMedia.width + "x" + spiceMedia.height);
+ "," + spiceMedia.preview_url + "," + spiceMedia.media_url + "," + TypeMappingUtil.getMediaType(spiceMedia.type) + "," + spiceMedia.width + "x" + spiceMedia.height);
} else {
SpiceProfilingUtil.log(getContext(), status.id + ",RetweetO," + account_id + ","
+ status.user_id + "," + status.reply_count + "," + status.retweet_count + "," + status.favorite_count
+ "," + spiceMedia.media_url + "," + TypeMappingUtil.getMediaType(spiceMedia.type));
SpiceProfilingUtil.profile(getContext(), account_id, status.id + ",RetweetO," + account_id + ","
+ status.user_id + "," + status.reply_count + "," + status.retweet_count + "," + status.favorite_count
+ "," + spiceMedia.media_url + "," + TypeMappingUtil.getMediaType(spiceMedia.type));
+ "," + spiceMedia.preview_url + "," + spiceMedia.media_url + "," + TypeMappingUtil.getMediaType(spiceMedia.type));
}
}
}

View File

@ -23,6 +23,7 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -109,7 +110,9 @@ public class OnLinkClickHandler implements OnLinkClickListener, Constants {
protected void openMedia(long accountId, long extraId, boolean sensitive, String link, int start, int end) {
final ParcelableMedia[] media = {ParcelableMedia.newImage(link, link)};
Utils.openMedia(context, accountId, sensitive, null, media);
//TODO open media animation
Bundle options = null;
Utils.openMedia(context, accountId, sensitive, null, media, options);
}
protected void openLink(final String link) {

View File

@ -19,6 +19,7 @@
package org.mariotaku.twidere.util;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
@ -42,7 +43,9 @@ public class StatusAdapterLinkClickHandler<D> extends OnLinkClickHandler {
if (extraId == RecyclerView.NO_POSITION) return;
final ParcelableStatus status = adapter.getStatus((int) extraId);
final ParcelableMedia current = StatusLinkClickHandler.findByLink(status.media, link);
Utils.openMedia(context, status, current);
//TODO open media animation
Bundle options = null;
Utils.openMedia(context, status, current, options);
}
}

View File

@ -20,6 +20,7 @@
package org.mariotaku.twidere.util;
import android.content.Context;
import android.os.Bundle;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
@ -35,7 +36,9 @@ public class StatusLinkClickHandler extends OnLinkClickHandler {
protected void openMedia(long accountId, long extraId, boolean sensitive, String link, int start, int end) {
final ParcelableStatus status = mStatus;
final ParcelableMedia current = findByLink(status.media, link);
Utils.openMedia(context, status, current);
//TODO open media animation
Bundle options = null;
Utils.openMedia(context, status, current, options);
}
public static ParcelableMedia findByLink(ParcelableMedia[] media, String link) {

View File

@ -308,20 +308,6 @@ public class ThemeUtils implements Constants {
}
}
@Deprecated
@NonNull
public static Drawable getActionBarBackground(final Context context, final int themeRes,
final int accentColor, boolean outlineEnabled) {
final int actionBarColor;
if (isDarkTheme(themeRes)) {
actionBarColor = context.getResources().getColor(R.color.background_color_action_bar_dark);
} else {
actionBarColor = accentColor;
}
final ColorDrawable d = ActionBarColorDrawable.create(actionBarColor, outlineEnabled);
return applyActionBarDrawable(context, d, isTransparentBackground(context));
}
@NonNull
public static Drawable getActionBarBackground(final Context context, final int themeRes,
final int accentColor, final String backgroundOption,
@ -332,8 +318,7 @@ public class ThemeUtils implements Constants {
} else {
actionBarColor = accentColor;
}
final ColorDrawable d = ActionBarColorDrawable.create(actionBarColor, outlineEnabled);
return applyActionBarDrawable(context, d, isTransparentBackground(backgroundOption));
return ActionBarColorDrawable.create(actionBarColor, outlineEnabled);
}
public static Context getActionBarContext(final Context context) {
@ -391,9 +376,11 @@ public class ThemeUtils implements Constants {
@SuppressWarnings("ConstantConditions")
final TypedArray a = context.obtainStyledAttributes(null, new int[]{android.R.attr.backgroundSplit},
android.R.attr.actionBarStyle, themeRes);
final Drawable d = a.getDrawable(0);
a.recycle();
return applyActionBarDrawable(context, d, isTransparentBackground(context));
try {
return a.getDrawable(0);
} finally {
a.recycle();
}
}
@NonNull
@ -405,16 +392,20 @@ public class ThemeUtils implements Constants {
} else {
actionBarColor = accentColor;
}
final ColorDrawable d = ActionBarColorDrawable.create(actionBarColor, outlineEnabled);
return applyActionBarDrawable(context, d, isTransparentBackground(context));
return ActionBarColorDrawable.create(actionBarColor, outlineEnabled);
}
public static int getCardBackgroundColor(final Context context) {
public static int getCardBackgroundColor(final Context context, String backgroundOption, int themeAlpha) {
final TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.cardItemBackgroundColor});
final int color = a.getColor(0, Color.TRANSPARENT);
a.recycle();
final int themeAlpha = getThemeAlpha(context);
return themeAlpha << 24 | (0x00FFFFFF & color);
if (isTransparentBackground(backgroundOption)) {
return themeAlpha << 24 | (0x00FFFFFF & color);
} else if (isSolidBackground(backgroundOption)) {
return ColorUtils.getContrastYIQ(color, Color.WHITE, Color.BLACK);
} else {
return color;
}
}
public static Drawable getCompatToolbarOverlay(Activity activity) {
@ -608,14 +599,6 @@ public class ThemeUtils implements Constants {
}
}
public static int getThemeAlpha(final Context context) {
return getThemeAlpha(getThemeResource(context));
}
public static int getThemeAlpha(final int themeRes) {
return 0xff;
}
public static int getThemeBackgroundColor(final Context context) {
final TypedArray a = context.obtainStyledAttributes(new int[]{android.R.attr.colorBackground});
try {
@ -865,6 +848,10 @@ public class ThemeUtils implements Constants {
return VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option);
}
public static boolean isSolidBackground(final String option) {
return VALUE_THEME_BACKGROUND_SOLID.equals(option);
}
public static boolean isWindowFloating(Context context, int theme) {
final TypedArray a;
if (theme != 0) {
@ -1125,16 +1112,6 @@ public class ThemeUtils implements Constants {
}
}
private static Drawable applyActionBarDrawable(final Context context, final Drawable d, final boolean applyAlpha) {
if (d == null) return null;
d.mutate();
// DrawableCompat.setTint(d, getUserAccentColor(context));
if (applyAlpha) {
d.setAlpha(getThemeAlpha(context));
}
return d;
}
private static void applyColorTintForView(View view, int tintColor) {
if (view instanceof IThemedView) {
final ColorStateList tintList = ColorStateList.valueOf(tintColor);

View File

@ -211,6 +211,7 @@ import org.mariotaku.twidere.util.content.ContentResolverUtils;
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
import org.mariotaku.twidere.util.net.OkHttpClientFactory;
import org.mariotaku.twidere.util.net.TwidereHostResolverFactory;
import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener;
import org.mariotaku.twidere.view.CardMediaContainer.PreviewStyle;
import org.mariotaku.twidere.view.ShapedImageView;
import org.mariotaku.twidere.view.ShapedImageView.ShapeStyle;
@ -2084,14 +2085,17 @@ public final class Utils implements Constants, TwitterConstants {
return Proxy.NO_PROXY;
}
public static String getQuoteStatus(final Context context, final String screen_name, final String text) {
public static String getQuoteStatus(final Context context, long statusId, final String screen_name, final String text) {
if (context == null) return null;
String quote_format = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).getString(
String quoteFormat = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).getString(
KEY_QUOTE_FORMAT, DEFAULT_QUOTE_FORMAT);
if (isEmpty(quote_format)) {
quote_format = DEFAULT_QUOTE_FORMAT;
if (isEmpty(quoteFormat)) {
quoteFormat = DEFAULT_QUOTE_FORMAT;
}
return quote_format.replace(FORMAT_PATTERN_NAME, screen_name).replace(FORMAT_PATTERN_TEXT, text);
String result = quoteFormat.replace(FORMAT_PATTERN_LINK, LinkCreator.getTwitterStatusLink(screen_name, statusId).toString());
result = result.replace(FORMAT_PATTERN_NAME, screen_name);
result = result.replace(FORMAT_PATTERN_TEXT, text);
return result;
}
public static String getReasonablySmallTwitterProfileImage(final String url) {
@ -2890,22 +2894,22 @@ public final class Utils implements Constants, TwitterConstants {
context.startActivity(intent);
}
public static void openMedia(final Context context, final ParcelableDirectMessage message, final ParcelableMedia current) {
openMedia(context, message.account_id, false, null, message, current, message.media);
public static void openMedia(final Context context, final ParcelableDirectMessage message, final ParcelableMedia current, Bundle options) {
openMedia(context, message.account_id, false, null, message, current, message.media, options);
}
public static void openMedia(final Context context, final ParcelableStatus status, final ParcelableMedia current) {
openMedia(context, status.account_id, status.is_possibly_sensitive, status, null, current, status.media);
public static void openMedia(final Context context, final ParcelableStatus status, final ParcelableMedia current, Bundle options) {
openMedia(context, status.account_id, status.is_possibly_sensitive, status, null, current, status.media, options);
}
public static void openMedia(final Context context, final long accountId, final boolean isPossiblySensitive,
final ParcelableMedia current, final ParcelableMedia[] media) {
openMedia(context, accountId, isPossiblySensitive, null, null, current, media);
final ParcelableMedia current, final ParcelableMedia[] media, Bundle options) {
openMedia(context, accountId, isPossiblySensitive, null, null, current, media, options);
}
public static void openMedia(final Context context, final long accountId, final boolean isPossiblySensitive,
final ParcelableStatus status, final ParcelableDirectMessage message,
final ParcelableMedia current, final ParcelableMedia[] media) {
final ParcelableMedia current, final ParcelableMedia[] media, Bundle options) {
if (context == null || media == null) return;
final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
if (context instanceof FragmentActivity && isPossiblySensitive
@ -2923,10 +2927,11 @@ public final class Utils implements Constants, TwitterConstants {
args.putParcelable(EXTRA_MESSAGE, message);
}
args.putParcelableArray(EXTRA_MEDIA, media);
args.putBundle(EXTRA_ACTIVITY_OPTIONS, options);
fragment.setArguments(args);
fragment.show(fm, "sensitive_content_warning");
} else {
openMediaDirectly(context, accountId, status, message, current, media);
openMediaDirectly(context, accountId, status, message, current, media, options);
}
}
@ -2942,19 +2947,19 @@ public final class Utils implements Constants, TwitterConstants {
public static void openMediaDirectly(final Context context, final long accountId,
final ParcelableStatus status, final ParcelableMedia current,
final ParcelableMedia[] media) {
openMediaDirectly(context, accountId, status, null, current, media);
final ParcelableMedia[] media, Bundle options) {
openMediaDirectly(context, accountId, status, null, current, media, options);
}
public static void openMediaDirectly(final Context context, final long accountId,
final ParcelableDirectMessage message, final ParcelableMedia current,
final ParcelableMedia[] media) {
openMediaDirectly(context, accountId, null, message, current, media);
final ParcelableMedia[] media, Bundle options) {
openMediaDirectly(context, accountId, null, message, current, media, options);
}
public static void openMediaDirectly(final Context context, final long accountId,
final ParcelableStatus status, final ParcelableDirectMessage message,
final ParcelableMedia current, final ParcelableMedia[] media) {
final ParcelableMedia current, final ParcelableMedia[] media, Bundle options) {
if (context == null || media == null) return;
final Intent intent = new Intent(INTENT_ACTION_VIEW_MEDIA);
intent.putExtra(EXTRA_ACCOUNT_ID, accountId);
@ -2967,7 +2972,11 @@ public final class Utils implements Constants, TwitterConstants {
intent.putExtra(EXTRA_MESSAGE, message);
}
intent.setClass(context, MediaViewerActivity.class);
context.startActivity(intent);
if (context instanceof Activity) {
ActivityCompat.startActivity((Activity) context, intent, options);
} else {
context.startActivity(intent);
}
}
public static void openIncomingFriendships(final Context context, final long accountId) {
@ -4096,10 +4105,6 @@ public final class Utils implements Constants, TwitterConstants {
UtilsL.setSharedElementTransition(context, window, transitionRes);
}
public interface OnMediaClickListener {
void onMediaClick(View view, ParcelableMedia media, long accountId);
}
static class UtilsL {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)

View File

@ -10,13 +10,22 @@ import android.view.Window;
public class WindowAccessor {
public static void setStatusBarColor(Window window, int color) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
WindowAccessorL.setStatusBarColor(window, color);
WindowAccessorLollipop.setStatusBarColor(window, color);
}
public static void setSharedElementsUseOverlay(Window window, boolean sharedElementsUseOverlay) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
WindowAccessorLollipop.setSharedElementsUseOverlay(window, sharedElementsUseOverlay);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static class WindowAccessorL {
private static class WindowAccessorLollipop {
public static void setStatusBarColor(Window window, int color) {
window.setStatusBarColor(color);
}
public static void setSharedElementsUseOverlay(Window window, boolean sharedElementsUseOverlay) {
window.setSharedElementsUseOverlay(sharedElementsUseOverlay);
}
}
}

View File

@ -19,13 +19,11 @@
package org.mariotaku.twidere.view;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import org.mariotaku.twidere.R;
@ -36,6 +34,7 @@ import org.mariotaku.twidere.view.themed.ThemedTextView;
*/
public class ActionIconThemedTextView extends ThemedTextView {
private final int mIconWidth, mIconHeight;
private int mColor, mDisabledColor, mActivatedColor;
public ActionIconThemedTextView(Context context) {
@ -52,6 +51,8 @@ public class ActionIconThemedTextView extends ThemedTextView {
mColor = a.getColor(R.styleable.IconActionButton_iabColor, 0);
mDisabledColor = a.getColor(R.styleable.IconActionButton_iabDisabledColor, 0);
mActivatedColor = a.getColor(R.styleable.IconActionButton_iabActivatedColor, 0);
mIconWidth = a.getDimensionPixelSize(R.styleable.IconActionButton_iabIconWidth, 0);
mIconHeight = a.getDimensionPixelSize(R.styleable.IconActionButton_iabIconHeight, 0);
a.recycle();
}
@ -62,6 +63,30 @@ public class ActionIconThemedTextView extends ThemedTextView {
return getCurrentTextColor();
}
@Override
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
updateCompoundDrawables();
}
@Override
public void setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom) {
super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
updateCompoundDrawables();
}
@Override
public void setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable start, Drawable top, Drawable end, Drawable bottom) {
super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
updateCompoundDrawables();
}
@Override
public void setCompoundDrawablesRelativeWithIntrinsicBounds(int start, int top, int end, int bottom) {
super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
updateCompoundDrawables();
}
public int getColor() {
if (mColor != 0) return mColor;
final ColorStateList colors = getTextColors();
@ -81,33 +106,28 @@ public class ActionIconThemedTextView extends ThemedTextView {
super.setActivated(activated);
}
@Override
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) {
super.setCompoundDrawables(left, top, right, bottom);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public void setCompoundDrawablesRelative(Drawable start, Drawable top, Drawable end, Drawable bottom) {
super.setCompoundDrawablesRelative(start, top, end, bottom);
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
updateCompoundDrawables();
}
private void updateCompoundDrawables() {
for (Drawable d : getCompoundDrawables()) {
if (d != null) {
d.mutate();
final int color;
if (isActivated()) {
color = getActivatedColor();
} else if (isEnabled()) {
color = getColor();
} else {
color = getDisabledColor();
}
d.setColorFilter(color, Mode.SRC_ATOP);
if (d == null) continue;
d.mutate();
final int color;
if (isActivated()) {
color = getActivatedColor();
} else if (isEnabled()) {
color = getColor();
} else {
color = getDisabledColor();
}
if (mIconWidth > 0 && mIconHeight > 0) {
d.setBounds(0, 0, mIconWidth, mIconHeight);
}
d.setColorFilter(color, Mode.SRC_ATOP);
}
}

View File

@ -37,7 +37,6 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.util.MediaLoadingHandler;
import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -281,6 +280,10 @@ public class CardMediaContainer extends ViewGroup implements Constants {
return indicesCount;
}
public interface OnMediaClickListener {
void onMediaClick(View view, ParcelableMedia media, long accountId);
}
private static class ImageGridClickListener implements View.OnClickListener {
private final OnMediaClickListener mListener;
private final long mAccountId;

View File

@ -284,7 +284,7 @@ public class HeaderDrawerLayout extends ViewGroup {
}
private boolean shouldLayoutHeaderBottomCallback() {
if (mDragCallback == null) return false;
if (mDragCallback == null || isInEditMode()) return false;
return mDrawerCallback.shouldLayoutHeaderBottom();
}

View File

@ -57,6 +57,7 @@ public class TintedStatusFrameLayout extends ExtendedFrameLayout {
mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
setWillNotDraw(false);
setFactor(1);
}

View File

@ -23,6 +23,7 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.Html;
import android.view.View;
@ -38,7 +39,7 @@ import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.SimpleValueSerializer;
import org.mariotaku.twidere.util.TwidereLinkify;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener;
import org.mariotaku.twidere.view.CardMediaContainer;
public class MessageConversationViewHolder extends ViewHolder implements OnMediaClickListener {
@ -89,7 +90,9 @@ public class MessageConversationViewHolder extends ViewHolder implements OnMedia
@Override
public void onMediaClick(View view, ParcelableMedia media, long accountId) {
Utils.openMedia(adapter.getContext(), adapter.getDirectMessage(getAdapterPosition()), media);
//TODO open media animation
Bundle options = null;
Utils.openMedia(adapter.getContext(), adapter.getDirectMessage(getAdapterPosition()), media, options);
}
public void setMessageColor(int color) {

View File

@ -25,15 +25,15 @@ import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableStatus.CursorIndices;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.MediaLoadingHandler;
import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.MediaLoadingHandler;
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
import org.mariotaku.twidere.util.SimpleValueSerializer;
import org.mariotaku.twidere.util.TwidereLinkify;
import org.mariotaku.twidere.util.TwitterCardUtils;
import org.mariotaku.twidere.util.UserColorNameUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener;
import org.mariotaku.twidere.view.CardMediaContainer;
import org.mariotaku.twidere.view.ForegroundColorView;
import org.mariotaku.twidere.view.ShapedImageView;
@ -210,7 +210,11 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
} else {
nameView.setText(getUserNickname(context, status.user_id, status.user_name, true));
screenNameView.setText("@" + status.user_screen_name);
timeView.setTime(status.timestamp);
if (status.is_retweet) {
timeView.setTime(status.retweet_timestamp);
} else {
timeView.setTime(status.timestamp);
}
quotedNameContainer.setVisibility(View.GONE);
quoteTextView.setVisibility(View.GONE);
@ -417,7 +421,11 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
} else {
nameView.setText(user_name);
screenNameView.setText("@" + user_screen_name);
timeView.setTime(cursor.getLong(indices.status_timestamp));
if (retweet_id > 0) {
timeView.setTime(cursor.getLong(indices.retweet_timestamp));
} else {
timeView.setTime(cursor.getLong(indices.status_timestamp));
}
quotedNameContainer.setVisibility(View.GONE);
quoteTextView.setVisibility(View.GONE);

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

After

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 528 B

After

Width:  |  Height:  |  Size: 845 B

View File

@ -18,11 +18,12 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout
<org.mariotaku.twidere.view.TintedStatusFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/main_content"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">
@ -355,34 +356,4 @@
android:layout_gravity="center"/>
</FrameLayout>
<org.mariotaku.twidere.view.TwidereToolbar
android:id="@+id/done_bar"
style="?actionBarStyle"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="?android:attr/dividerVertical"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="middle">
<include layout="@layout/include_cancel_button"/>
<include layout="@layout/include_done_button"/>
</LinearLayout>
</org.mariotaku.twidere.view.TwidereToolbar>
<View
android:id="@+id/actionbar_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/done_bar"/>
</RelativeLayout>
</org.mariotaku.twidere.view.TintedStatusFrameLayout>

View File

@ -77,7 +77,7 @@
tools:ignore="ContentDescription"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/profile_image"
@ -106,12 +106,6 @@
</LinearLayout>
</RelativeLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="0.2dp"
android:background="#40808080"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/description"
android:layout_width="match_parent"
@ -120,7 +114,7 @@
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
<org.mariotaku.twidere.view.ActionIconThemedTextView
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -130,11 +124,11 @@
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
<org.mariotaku.twidere.view.ActionIconThemedTextView
android:id="@+id/url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_indicator_web"
android:drawableLeft="@drawable/ic_indicator_link"
android:drawablePadding="4dp"
android:padding="8dp"
android:singleLine="true"

View File

@ -24,7 +24,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
tools:showIn="@layout/fragment_user">
<org.mariotaku.twidere.view.ProfileBannerSpace
android:id="@+id/profile_banner_space"

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 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/>.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@id/save"
app:showAsAction="always"
android:title="@string/save"
android:icon="@drawable/ic_action_ok"/>
</menu>

View File

@ -73,6 +73,8 @@
<attr name="iabColor" format="color"/>
<attr name="iabActivatedColor" format="color"/>
<attr name="iabDisabledColor" format="color"/>
<attr name="iabIconWidth" format="dimension"/>
<attr name="iabIconHeight" format="dimension"/>
</declare-styleable>
<declare-styleable name="ShapedImageView">
<attr name="sivBorder" format="boolean"/>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="element_size_xsmall">16dp</dimen>
<dimen name="element_size_small">24dp</dimen>
<dimen name="element_size_normal">48dp</dimen>
<dimen name="element_size_mlarge">64dp</dimen>