improved media viewer
moved some call into separate thread
This commit is contained in:
parent
458c50a820
commit
3b0899ddd4
|
@ -59,6 +59,8 @@ import android.widget.TextView;
|
|||
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource;
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
|
||||
import com.desmond.asyncmanager.AsyncManager;
|
||||
import com.desmond.asyncmanager.TaskRunnable;
|
||||
import com.pnikosis.materialishprogress.ProgressWheel;
|
||||
import com.sprylab.android.widget.TextureVideoView;
|
||||
|
||||
|
@ -83,7 +85,6 @@ import org.mariotaku.twidere.util.ThemeUtils;
|
|||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.VideoLoader;
|
||||
import org.mariotaku.twidere.util.VideoLoader.VideoLoadingListener;
|
||||
import org.mariotaku.twidere.view.LinePageIndicator;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -99,7 +100,6 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
private ViewPager mViewPager;
|
||||
private MediaPagerAdapter mPagerAdapter;
|
||||
private View mMediaStatusContainer;
|
||||
private LinePageIndicator mIndicator;
|
||||
|
||||
@Override
|
||||
public int getThemeColor() {
|
||||
|
@ -134,15 +134,11 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
mViewPager.setAdapter(mPagerAdapter);
|
||||
mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.element_spacing_normal));
|
||||
mViewPager.setOnPageChangeListener(this);
|
||||
mIndicator.setSelectedColor(getCurrentThemeColor());
|
||||
mIndicator.setViewPager(mViewPager);
|
||||
final Intent intent = getIntent();
|
||||
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
|
||||
final ParcelableMedia[] media = Utils.newParcelableArray(intent.getParcelableArrayExtra(EXTRA_MEDIA), ParcelableMedia.CREATOR);
|
||||
final ParcelableMedia currentMedia = intent.getParcelableExtra(EXTRA_CURRENT_MEDIA);
|
||||
mPagerAdapter.setMedia(accountId, media);
|
||||
mIndicator.notifyDataSetChanged();
|
||||
mIndicator.setVisibility(mPagerAdapter.getCount() > 1 ? View.VISIBLE : View.GONE);
|
||||
final int currentIndex = ArrayUtils.indexOf(media, currentMedia);
|
||||
if (currentIndex != -1) {
|
||||
mViewPager.setCurrentItem(currentIndex, false);
|
||||
|
@ -161,6 +157,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
} else {
|
||||
mMediaStatusContainer.setVisibility(View.GONE);
|
||||
}
|
||||
updatePositionTitle();
|
||||
}
|
||||
|
||||
public boolean hasStatus() {
|
||||
|
@ -171,7 +168,6 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
public void onContentChanged() {
|
||||
super.onContentChanged();
|
||||
mViewPager = (ViewPager) findViewById(R.id.view_pager);
|
||||
mIndicator = (LinePageIndicator) findViewById(R.id.pager_indicator);
|
||||
mMediaStatusContainer = findViewById(R.id.media_status_container);
|
||||
}
|
||||
|
||||
|
@ -182,6 +178,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
updatePositionTitle();
|
||||
setBarVisibility(true);
|
||||
}
|
||||
|
||||
|
@ -236,7 +233,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
}
|
||||
|
||||
private boolean isMediaStatusEnabled() {
|
||||
return false;
|
||||
return Boolean.parseBoolean("false");
|
||||
}
|
||||
|
||||
private void setBarVisibility(boolean visible) {
|
||||
|
@ -248,7 +245,6 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
actionBar.hide();
|
||||
}
|
||||
|
||||
mIndicator.setVisibility(visible && mPagerAdapter.getCount() > 1 ? View.VISIBLE : View.GONE);
|
||||
mMediaStatusContainer.setVisibility(isMediaStatusEnabled() && visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
|
@ -256,6 +252,10 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
setBarVisibility(!isBarShowing());
|
||||
}
|
||||
|
||||
private void updatePositionTitle() {
|
||||
setTitle(String.format("%d / %d", mViewPager.getCurrentItem() + 1, mPagerAdapter.getCount()));
|
||||
}
|
||||
|
||||
public static class BaseImagePageFragment extends BaseSupportFragment
|
||||
implements DownloadListener, LoaderCallbacks<Result>, OnClickListener {
|
||||
|
||||
|
@ -401,32 +401,51 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
|
|||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
final File file = mImageFile;
|
||||
final boolean isLoading = getLoaderManager().hasRunningLoaders();
|
||||
final boolean hasImage = file != null && file.exists();
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.refresh, !hasImage && !isLoading);
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.share, hasImage && !isLoading);
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.save, hasImage && !isLoading);
|
||||
if (!hasImage) return;
|
||||
final MenuItem shareItem = menu.findItem(R.id.share);
|
||||
final ShareActionProvider shareProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
|
||||
final Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
final Uri fileUri = Uri.fromFile(file);
|
||||
intent.setDataAndType(fileUri, Utils.getImageMimeType(file));
|
||||
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
||||
final MediaViewerActivity activity = (MediaViewerActivity) getActivity();
|
||||
if (activity.hasStatus()) {
|
||||
final ParcelableStatus status = activity.getStatus();
|
||||
intent.putExtra(Intent.EXTRA_TEXT, Utils.getStatusShareText(activity, status));
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, Utils.getStatusShareSubject(activity, status));
|
||||
}
|
||||
shareProvider.setShareIntent(intent);
|
||||
final TaskRunnable<File, Pair<Boolean, Intent>, Menu> checkState = new TaskRunnable<File, Pair<Boolean, Intent>, Menu>() {
|
||||
@Override
|
||||
public Pair<Boolean, Intent> doLongOperation(File file) throws InterruptedException {
|
||||
final boolean hasImage = file != null && file.exists();
|
||||
if (!hasImage) {
|
||||
return Pair.create(false, null);
|
||||
}
|
||||
final Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
final Uri fileUri = Uri.fromFile(file);
|
||||
intent.setDataAndType(fileUri, Utils.getImageMimeType(file));
|
||||
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
||||
final MediaViewerActivity activity = (MediaViewerActivity) getActivity();
|
||||
if (activity.hasStatus()) {
|
||||
final ParcelableStatus status = activity.getStatus();
|
||||
intent.putExtra(Intent.EXTRA_TEXT, Utils.getStatusShareText(activity, status));
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, Utils.getStatusShareSubject(activity, status));
|
||||
}
|
||||
return Pair.create(true, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callback(Menu menu, Pair<Boolean, Intent> result) {
|
||||
final boolean hasImage = result.first;
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.refresh, !hasImage && !isLoading);
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.share, hasImage && !isLoading);
|
||||
MenuUtils.setMenuItemAvailability(menu, R.id.save, hasImage && !isLoading);
|
||||
if (!hasImage) return;
|
||||
final MenuItem shareItem = menu.findItem(R.id.share);
|
||||
final ShareActionProvider shareProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
|
||||
shareProvider.setShareIntent(result.second);
|
||||
}
|
||||
};
|
||||
checkState.setParams(mImageFile);
|
||||
checkState.setResultHandler(menu);
|
||||
AsyncManager.runBackgroundTask(checkState);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_media_viewer_image_page, menu);
|
||||
final MenuItem shareItem = menu.findItem(R.id.share);
|
||||
final ShareActionProvider shareProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
|
||||
shareProvider.setShareHistoryFileName(null);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
|||
pm.setComponentEnabledSetting(main2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
if (!Utils.isComposeNowSupported()) {
|
||||
if (!Utils.isComposeNowSupported(this)) {
|
||||
final ComponentName assist = new ComponentName(this, AssistLauncherActivity.class);
|
||||
pm.setComponentEnabledSetting(assist, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
|
|
|
@ -62,7 +62,6 @@ import org.mariotaku.querybuilder.RawItemArray;
|
|||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.BasePreferenceActivity;
|
||||
import org.mariotaku.twidere.activity.SettingsActivity;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.CustomTabEditorActivity;
|
||||
import org.mariotaku.twidere.model.CustomTabConfiguration;
|
||||
import org.mariotaku.twidere.model.CustomTabConfiguration.CustomTabConfigurationComparator;
|
||||
|
@ -314,11 +313,10 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
|
|||
final Activity activity = getActivity();
|
||||
if (activity instanceof BasePreferenceActivity) {
|
||||
final ActionBar actionBar = ((BasePreferenceActivity) activity).getSupportActionBar();
|
||||
final int themeResId = ((IThemedActivity) activity).getThemeResourceId();
|
||||
final int themeColor = ((IThemedActivity) activity).getCurrentThemeColor();
|
||||
final int themeResourceId = ((BasePreferenceActivity) activity).getCurrentThemeResourceId();
|
||||
final int itemColor = ThemeUtils.getContrastActionBarItemColor(actionBar.getThemedContext());
|
||||
final int popupTheme = ThemeUtils.getActionBarPopupThemeRes(actionBar.getThemedContext());
|
||||
final int popupColor = ThemeUtils.getContrastActionBarItemColor(activity);
|
||||
final int popupTheme = ThemeUtils.getActionBarPopupThemeRes(actionBar.getThemedContext(), themeResourceId);
|
||||
final int popupColor = ThemeUtils.getColorFromAttribute(activity, popupTheme, android.R.attr.colorForeground, 0);
|
||||
ThemeUtils.applyColorFilterToMenuIcon(menu, itemColor, popupColor, 0, Mode.SRC_ATOP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,9 +260,16 @@ public abstract class AbsContentRecyclerViewFragment<A extends IContentCardAdapt
|
|||
super.onDetach();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected Rect getExtraContentPadding() {
|
||||
return new Rect();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fitSystemWindows(Rect insets) {
|
||||
mRecyclerView.setPadding(insets.left, insets.top, insets.right, insets.bottom);
|
||||
final Rect extraPadding = getExtraContentPadding();
|
||||
mRecyclerView.setPadding(insets.left + extraPadding.left, insets.top + extraPadding.top,
|
||||
insets.right + extraPadding.right, insets.bottom + extraPadding.bottom);
|
||||
mErrorContainer.setPadding(insets.left, insets.top, insets.right, insets.bottom);
|
||||
mProgressContainer.setPadding(insets.left, insets.top, insets.right, insets.bottom);
|
||||
mSystemWindowsInsets.set(insets);
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.mariotaku.twidere.fragment.support;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -414,6 +415,13 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentRecyclerViewFr
|
|||
mReadStateManager.setPosition(getCurrentReadPositionTag(), status.id, true);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Rect getExtraContentPadding() {
|
||||
final int paddingVertical = getResources().getDimensionPixelSize(R.dimen.element_spacing_small);
|
||||
return new Rect(0, paddingVertical, 0, paddingVertical);
|
||||
}
|
||||
|
||||
private String getCurrentReadPositionTag() {
|
||||
final String tag = getReadPositionTagWithAccounts();
|
||||
if (tag == null) return null;
|
||||
|
|
|
@ -25,13 +25,14 @@ import android.content.SharedPreferences;
|
|||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.content.Loader;
|
||||
|
||||
import com.desmond.asyncmanager.AsyncManager;
|
||||
import com.desmond.asyncmanager.TaskRunnable;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.mariotaku.querybuilder.Columns.Column;
|
||||
|
@ -45,7 +46,6 @@ import org.mariotaku.twidere.loader.support.ExtendedCursorLoader;
|
|||
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Filters;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
|
||||
import org.mariotaku.twidere.util.AsyncTaskUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.message.AccountChangedEvent;
|
||||
import org.mariotaku.twidere.util.message.FavoriteCreatedEvent;
|
||||
|
@ -215,10 +215,9 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<Cursor>
|
|||
@Override
|
||||
public void onLoadMoreContents() {
|
||||
super.onLoadMoreContents();
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Object, Object, long[][]>() {
|
||||
|
||||
AsyncManager.runBackgroundTask(new TaskRunnable<Object, long[][], CursorStatusesFragment>() {
|
||||
@Override
|
||||
protected long[][] doInBackground(final Object... params) {
|
||||
public long[][] doLongOperation(Object o) throws InterruptedException {
|
||||
final long[][] result = new long[3][];
|
||||
result[0] = getAccountIds();
|
||||
result[1] = getOldestStatusIds(result[0]);
|
||||
|
@ -226,20 +225,18 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<Cursor>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final long[][] result) {
|
||||
getStatuses(result[0], result[1], result[2]);
|
||||
public void callback(CursorStatusesFragment fragment, long[][] result) {
|
||||
fragment.getStatuses(result[0], result[1], result[2]);
|
||||
}
|
||||
|
||||
});
|
||||
}.setResultHandler(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
super.triggerRefresh();
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Object, Object, long[][]>() {
|
||||
|
||||
AsyncManager.runBackgroundTask(new TaskRunnable<Object, long[][], CursorStatusesFragment>() {
|
||||
@Override
|
||||
protected long[][] doInBackground(final Object... params) {
|
||||
public long[][] doLongOperation(Object o) throws InterruptedException {
|
||||
final long[][] result = new long[3][];
|
||||
result[0] = getAccountIds();
|
||||
result[2] = getNewestStatusIds(result[0]);
|
||||
|
@ -247,11 +244,10 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<Cursor>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final long[][] result) {
|
||||
getStatuses(result[0], result[1], result[2]);
|
||||
public void callback(CursorStatusesFragment fragment, long[][] result) {
|
||||
fragment.getStatuses(result[0], result[1], result[2]);
|
||||
}
|
||||
|
||||
});
|
||||
}.setResultHandler(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,12 +124,14 @@ public class TrendsSuggestionsFragment extends AbsContentListViewFragment<Trends
|
|||
super.onStart();
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
final Bus bus = TwidereApplication.getInstance(getActivity()).getMessageBus();
|
||||
assert bus != null;
|
||||
bus.unregister(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ComposeNowPreference extends ComponentStatePreference {
|
|||
|
||||
@Override
|
||||
protected boolean isComponentAvailable() {
|
||||
return Utils.isComposeNowSupported();
|
||||
return Utils.isComposeNowSupported(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -238,13 +238,12 @@ public class ThemeUtils implements Constants {
|
|||
return ActionBarColorDrawable.create(actionBarColor, outlineEnabled);
|
||||
}
|
||||
|
||||
public static int getActionBarPopupThemeRes(final Context context) {
|
||||
final TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.actionBarPopupTheme});
|
||||
try {
|
||||
return a.getResourceId(0, 0);
|
||||
} finally {
|
||||
a.recycle();
|
||||
public static int getActionBarPopupThemeRes(final Context context, int def) {
|
||||
final TypedValue outValue = new TypedValue();
|
||||
if (context.getTheme().resolveAttribute(R.attr.actionBarPopupTheme, outValue, true)) {
|
||||
return outValue.resourceId;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static Drawable getActionBarSplitBackground(final Context context, final int themeRes) {
|
||||
|
@ -425,6 +424,18 @@ public class ThemeUtils implements Constants {
|
|||
return outValue.data;
|
||||
}
|
||||
|
||||
|
||||
public static int getColorFromAttribute(Context context, int themeId, int attr, int def) {
|
||||
final TypedValue outValue = new TypedValue();
|
||||
final Resources.Theme theme = context.getResources().newTheme();
|
||||
theme.applyStyle(themeId, true);
|
||||
if (!theme.resolveAttribute(attr, outValue, true))
|
||||
return def;
|
||||
if (outValue.type == TypedValue.TYPE_REFERENCE)
|
||||
return context.getResources().getColor(attr);
|
||||
return outValue.data;
|
||||
}
|
||||
|
||||
public static int getTextColorPrimary(final Context context) {
|
||||
final TypedArray a = context.obtainStyledAttributes(ATTRS_TEXT_COLOR_PRIMARY);
|
||||
try {
|
||||
|
|
|
@ -602,17 +602,17 @@ public final class Utils implements Constants {
|
|||
final int itemLimit = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).getInt(
|
||||
KEY_DATABASE_ITEM_LIMIT, DEFAULT_DATABASE_ITEM_LIMIT);
|
||||
|
||||
for (final long account_id : getAccountIds(context)) {
|
||||
for (final long accountId : getAccountIds(context)) {
|
||||
// Clean statuses.
|
||||
for (final Uri uri : STATUSES_URIS) {
|
||||
if (CachedStatuses.CONTENT_URI.equals(uri)) {
|
||||
continue;
|
||||
}
|
||||
final String table = getTableNameByUri(uri);
|
||||
final Expression account_where = new Expression(Statuses.ACCOUNT_ID + " = " + account_id);
|
||||
final Expression account_where = new Expression(Statuses.ACCOUNT_ID + " = " + accountId);
|
||||
final SQLSelectQuery.Builder qb = new SQLSelectQuery.Builder();
|
||||
qb.select(new Column(Statuses._ID)).from(new Tables(table));
|
||||
qb.where(Expression.equals(Statuses.ACCOUNT_ID, account_id));
|
||||
qb.where(Expression.equals(Statuses.ACCOUNT_ID, accountId));
|
||||
qb.orderBy(new OrderBy(Statuses.STATUS_ID, false));
|
||||
qb.limit(itemLimit);
|
||||
final Expression where = Expression.and(Expression.notIn(new Column(Statuses._ID), qb.build()), account_where);
|
||||
|
@ -620,12 +620,12 @@ public final class Utils implements Constants {
|
|||
}
|
||||
for (final Uri uri : DIRECT_MESSAGES_URIS) {
|
||||
final String table = getTableNameByUri(uri);
|
||||
final Expression account_where = new Expression(DirectMessages.ACCOUNT_ID + " = " + account_id);
|
||||
final Expression account_where = new Expression(DirectMessages.ACCOUNT_ID + " = " + accountId);
|
||||
final SQLSelectQuery.Builder qb = new SQLSelectQuery.Builder();
|
||||
qb.select(new Column(DirectMessages._ID)).from(new Tables(table));
|
||||
qb.where(Expression.equals(DirectMessages.ACCOUNT_ID, account_id));
|
||||
qb.where(Expression.equals(DirectMessages.ACCOUNT_ID, accountId));
|
||||
qb.orderBy(new OrderBy(DirectMessages.MESSAGE_ID, false));
|
||||
qb.limit(itemLimit);
|
||||
qb.limit(itemLimit * 10);
|
||||
final Expression where = Expression.and(Expression.notIn(new Column(DirectMessages._ID), qb.build()), account_where);
|
||||
resolver.delete(uri, where.getSQL(), null);
|
||||
}
|
||||
|
@ -1528,9 +1528,9 @@ public final class Utils implements Constants {
|
|||
return ids;
|
||||
}
|
||||
|
||||
public static boolean isComposeNowSupported() {
|
||||
public static boolean isComposeNowSupported(Context context) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return false;
|
||||
return !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
|
||||
return hasNavBar(context);
|
||||
}
|
||||
|
||||
public static boolean isOfficialCredentials(final Context context, final ParcelableCredentials account) {
|
||||
|
@ -2253,6 +2253,17 @@ public final class Utils implements Constants {
|
|||
return date.getTime();
|
||||
}
|
||||
|
||||
public static boolean hasNavBar(Context context) {
|
||||
final Resources resources = context.getResources();
|
||||
int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
|
||||
if (id > 0) {
|
||||
return resources.getBoolean(id);
|
||||
} else {
|
||||
// Check for keys
|
||||
return !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK)
|
||||
&& !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTwitterErrorMessage(final Context context, final CharSequence action,
|
||||
final TwitterException te) {
|
||||
|
|
|
@ -211,8 +211,8 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
typeIconRes = 0;
|
||||
}
|
||||
|
||||
final int userColor = manager.getUserColor(status.quoted_by_user_id, false);
|
||||
itemContent.drawStart(userColor);
|
||||
itemContent.drawStart(manager.getUserColor(status.quoted_by_user_id, false),
|
||||
manager.getUserColor(status.user_id, false));
|
||||
} else {
|
||||
primaryNameView.setText(manager.getUserNickname(status.user_id, status.user_name, false));
|
||||
secondaryNameView.setText("@" + status.user_screen_name);
|
||||
|
@ -239,8 +239,12 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
|
||||
typeIconRes = 0;
|
||||
}
|
||||
final int userColor = manager.getUserColor(status.user_id, false);
|
||||
itemContent.drawStart(userColor);
|
||||
if (status.is_retweet) {
|
||||
itemContent.drawStart(manager.getUserColor(status.retweeted_by_user_id, false),
|
||||
manager.getUserColor(status.user_id, false));
|
||||
} else {
|
||||
itemContent.drawStart(manager.getUserColor(status.user_id, false));
|
||||
}
|
||||
}
|
||||
|
||||
if (typeIconRes != 0) {
|
||||
|
@ -346,6 +350,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
final long my_retweet_id = cursor.getLong(indices.my_retweet_id);
|
||||
final long in_reply_to_status_id = cursor.getLong(indices.in_reply_to_status_id);
|
||||
final long in_reply_to_user_id = cursor.getLong(indices.in_reply_to_user_id);
|
||||
final long retweeted_by_id = cursor.getLong(indices.retweeted_by_user_id);
|
||||
|
||||
final String user_name = cursor.getString(indices.user_name);
|
||||
final String user_screen_name = cursor.getString(indices.user_screen_name);
|
||||
|
@ -358,7 +363,6 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
final ParcelableLocation location = ParcelableLocation.fromString(cursor.getString(indices.location));
|
||||
|
||||
if (retweet_id > 0) {
|
||||
final long retweeted_by_id = cursor.getLong(indices.retweeted_by_user_id);
|
||||
final String retweeted_by_name = cursor.getString(indices.retweeted_by_user_name);
|
||||
final String retweeted_by_screen_name = cursor.getString(indices.retweeted_by_user_screen_name);
|
||||
final String retweetedBy = manager.getDisplayName(retweeted_by_id, retweeted_by_name,
|
||||
|
@ -422,8 +426,8 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
typeIconRes = 0;
|
||||
}
|
||||
|
||||
final int userColor = manager.getUserColor(cursor.getLong(indices.quoted_by_user_id), false);
|
||||
itemContent.drawStart(userColor);
|
||||
itemContent.drawStart(manager.getUserColor(cursor.getLong(indices.quoted_by_user_id), false),
|
||||
manager.getUserColor(cursor.getLong(indices.user_id), false));
|
||||
|
||||
} else {
|
||||
primaryNameView.setText(user_name);
|
||||
|
@ -452,8 +456,11 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
|
||||
typeIconRes = 0;
|
||||
}
|
||||
final int userColor = manager.getUserColor(user_id, false);
|
||||
itemContent.drawStart(userColor);
|
||||
if (retweet_id > 0) {
|
||||
itemContent.drawStart(manager.getUserColor(retweeted_by_id, false), manager.getUserColor(user_id, false));
|
||||
} else {
|
||||
itemContent.drawStart(manager.getUserColor(user_id, false));
|
||||
}
|
||||
}
|
||||
|
||||
if (typeIconRes != 0) {
|
||||
|
@ -503,7 +510,6 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
|
|||
retweet_count = Math.max(0, cursor.getLong(indices.retweet_count) - 1);
|
||||
} else {
|
||||
final boolean creatingRetweet = twitter.isCreatingRetweet(account_id, status_id);
|
||||
final long retweeted_by_id = cursor.getLong(indices.retweeted_by_user_id);
|
||||
retweetCountView.setActivated(creatingRetweet || Utils.isMyRetweet(account_id,
|
||||
retweeted_by_id, my_retweet_id));
|
||||
retweet_count = cursor.getLong(indices.retweet_count) + (creatingRetweet ? 1 : 0);
|
||||
|
|
|
@ -66,7 +66,8 @@
|
|||
android:layout_toEndOf="@+id/account_selector_button"
|
||||
android:layout_toLeftOf="@+id/send"
|
||||
android:layout_toRightOf="@+id/account_selector_button"
|
||||
android:layout_toStartOf="@+id/send">
|
||||
android:layout_toStartOf="@+id/send"
|
||||
android:scrollbars="none">
|
||||
|
||||
<android.support.v7.widget.ActionMenuView
|
||||
android:id="@+id/menu_bar"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
|
@ -18,9 +17,7 @@
|
|||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -30,7 +27,7 @@
|
|||
<org.mariotaku.twidere.view.MediaViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/media_status_container"
|
||||
|
@ -43,22 +40,13 @@
|
|||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/element_spacing_small"
|
||||
android:background="@drawable/shadow_top"/>
|
||||
android:background="@drawable/shadow_top" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/media_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#80000000"/>
|
||||
android:background="#80000000" />
|
||||
</LinearLayout>
|
||||
|
||||
<org.mariotaku.twidere.view.LinePageIndicator
|
||||
android:id="@+id/pager_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:padding="@dimen/element_spacing_normal"
|
||||
app:lineWidth="@dimen/line_indicator_line_width_wizard"
|
||||
app:selectedColor="?android:colorActivatedHighlight"
|
||||
app:strokeWidth="@dimen/line_indicator_stroke_width_wizard"/>
|
||||
</merge>
|
|
@ -266,7 +266,7 @@
|
|||
android:layout_alignLeft="@id/status_content"
|
||||
android:layout_alignStart="@id/status_content"
|
||||
android:layout_below="@+id/status_content"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_normal"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_mlarge"
|
||||
android:layout_toLeftOf="@+id/item_menu"
|
||||
android:layout_toStartOf="@+id/item_menu"
|
||||
android:gravity="center_vertical|start"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<dimen name="element_spacing_minus_small">-4dp</dimen>
|
||||
<dimen name="element_spacing_minus_msmall">-6dp</dimen>
|
||||
<dimen name="element_spacing_minus_normal">-8dp</dimen>
|
||||
<dimen name="element_spacing_minus_mlarge">-12dp</dimen>
|
||||
<dimen name="element_spacing_minus_large">-16dp</dimen>
|
||||
<dimen name="element_spacing_minus_xlarge">-24dp</dimen>
|
||||
<dimen name="icon_size_list_item">56dp</dimen>
|
||||
|
|
Loading…
Reference in New Issue