improved accent color handling

This commit is contained in:
Mariotaku Lee 2016-01-30 01:57:15 +08:00
parent e537ceb805
commit 094cb49d82
2 changed files with 44 additions and 33 deletions

View File

@ -51,6 +51,7 @@ import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.util.MenuUtils;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper;
@ -161,6 +162,13 @@ public final class MediaViewerActivity extends AbsMediaViewerActivity implements
protected Object getDownloadExtra() {
return ((MediaViewerActivity) getActivity()).getDownloadExtra();
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final ProgressWheel progressWheel = (ProgressWheel) view.findViewById(org.mariotaku.mediaviewer.library.R.id.load_progress);
progressWheel.setBarColor(ThemeUtils.getUserAccentColor(getContext()));
}
}
public static class VideoPageFragment extends MediaViewerFragment implements MediaPlayer.OnPreparedListener,
@ -189,7 +197,6 @@ public final class MediaViewerActivity extends AbsMediaViewerActivity implements
private ProgressBar mVideoViewProgress;
private TextView mDurationLabel, mPositionLabel;
private ImageButton mPlayPauseButton, mVolumeButton;
private ProgressWheel mProgressBar;
private View mVideoControl;
private boolean mPlayAudio;
@ -202,21 +209,6 @@ public final class MediaViewerActivity extends AbsMediaViewerActivity implements
}
@Override
protected void showProgress(boolean indeterminate, float progress) {
mProgressBar.setVisibility(View.VISIBLE);
if (indeterminate) {
mProgressBar.spin();
} else {
mProgressBar.setProgress(progress);
}
}
@Override
protected void hideProgress() {
mProgressBar.setVisibility(View.GONE);
}
@Override
protected boolean isAbleToLoad() {
return getDownloadUri() != null;
@ -310,12 +302,14 @@ public final class MediaViewerActivity extends AbsMediaViewerActivity implements
mVideoView = (TextureVideoView) view.findViewById(R.id.video_view);
mVideoViewOverlay = view.findViewById(R.id.video_view_overlay);
mVideoViewProgress = (ProgressBar) view.findViewById(R.id.video_view_progress);
mProgressBar = (ProgressWheel) view.findViewById(R.id.load_progress);
mDurationLabel = (TextView) view.findViewById(R.id.duration_label);
mPositionLabel = (TextView) view.findViewById(R.id.position_label);
mPlayPauseButton = (ImageButton) view.findViewById(R.id.play_pause_button);
mVolumeButton = (ImageButton) view.findViewById(R.id.volume_button);
mVideoControl = view.findViewById(R.id.video_control);
final ProgressWheel progressWheel = (ProgressWheel) view.findViewById(org.mariotaku.mediaviewer.library.R.id.load_progress);
progressWheel.setBarColor(ThemeUtils.getUserAccentColor(getContext()));
}

View File

@ -139,6 +139,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -165,11 +167,13 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
Bus mBus;
@Inject
UserColorNameManager mUserColorNameManager;
private Handler mHandler;
private ContentResolver mContentResolver;
private SQLiteDatabaseWrapper mDatabaseWrapper;
private PermissionsManager mPermissionsManager;
private ImagePreloader mImagePreloader;
private Executor mBackgroundExecutor;
private boolean mHomeActivityInBackground;
private boolean mNameFirst;
private boolean mUseStarForLikes;
@ -561,6 +565,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
mHandler = new Handler(Looper.getMainLooper());
mDatabaseWrapper = new SQLiteDatabaseWrapper(this);
mPreferences.registerOnSharedPreferenceChangeListener(this);
mBackgroundExecutor = Executors.newSingleThreadExecutor();
updatePreferences();
mPermissionsManager = new PermissionsManager(context);
mImagePreloader = new ImagePreloader(context, mMediaLoader);
@ -1186,25 +1191,36 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
if (!uri.getBooleanQueryParameter(QUERY_PARAM_NOTIFY, true)) return;
switch (tableId) {
case TABLE_ID_STATUSES: {
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(context,
DataStoreUtils.getAccountIds(context));
for (final AccountPreferences pref : prefs) {
if (!pref.isHomeTimelineNotificationEnabled()) continue;
showTimelineNotification(pref, getPositionTag(CustomTabType.HOME_TIMELINE, pref.getAccountId()));
}
notifyUnreadCountChanged(NOTIFICATION_ID_HOME_TIMELINE);
mBackgroundExecutor.execute(new Runnable() {
@Override
public void run() {
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(context,
DataStoreUtils.getAccountIds(context));
for (final AccountPreferences pref : prefs) {
if (!pref.isHomeTimelineNotificationEnabled()) continue;
final long positionTag = getPositionTag(CustomTabType.HOME_TIMELINE, pref.getAccountId());
showTimelineNotification(pref, positionTag);
}
notifyUnreadCountChanged(NOTIFICATION_ID_HOME_TIMELINE);
}
});
break;
}
case TABLE_ID_ACTIVITIES_ABOUT_ME: {
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(context,
DataStoreUtils.getAccountIds(context));
final boolean combined = mPreferences.getBoolean(KEY_COMBINED_NOTIFICATIONS);
for (final AccountPreferences pref : prefs) {
if (!pref.isInteractionsNotificationEnabled()) continue;
showInteractionsNotification(pref, getPositionTag(ReadPositionTag.ACTIVITIES_ABOUT_ME,
pref.getAccountId()), combined);
}
notifyUnreadCountChanged(NOTIFICATION_ID_INTERACTIONS_TIMELINE);
mBackgroundExecutor.execute(new Runnable() {
@Override
public void run() {
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(context,
DataStoreUtils.getAccountIds(context));
final boolean combined = mPreferences.getBoolean(KEY_COMBINED_NOTIFICATIONS);
for (final AccountPreferences pref : prefs) {
if (!pref.isInteractionsNotificationEnabled()) continue;
showInteractionsNotification(pref, getPositionTag(ReadPositionTag.ACTIVITIES_ABOUT_ME,
pref.getAccountId()), combined);
}
notifyUnreadCountChanged(NOTIFICATION_ID_INTERACTIONS_TIMELINE);
}
});
break;
}
case TABLE_ID_DIRECT_MESSAGES_INBOX: {
@ -1234,6 +1250,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
private void showTimelineNotification(AccountPreferences pref, long position) {
final long accountId = pref.getAccountId();
final Context context = getContext();
if (context == null) return;
final Resources resources = context.getResources();
final NotificationManagerWrapper nm = mNotificationManager;
final Expression selection = Expression.and(Expression.equals(Statuses.ACCOUNT_ID, accountId),