now delete notification can also mark read.
fixed crashes in notification settings due to non exists key "stream_notification"
This commit is contained in:
parent
8f645d3112
commit
31171ad05e
|
@ -88,6 +88,7 @@ dependencies {
|
|||
compile 'com.github.uucky:ColorPicker-Android:0.9.1'
|
||||
compile 'com.sprylab.android.texturevideoview:texturevideoview:1.0.0'
|
||||
compile 'com.squareup:pollexor:2.0.2'
|
||||
compile 'org.apache.commons:commons-lang3:3.4'
|
||||
googleCompile 'com.google.android.gms:play-services-maps:7.0.0'
|
||||
googleCompile 'com.google.maps.android:android-maps-utils:0.3.4'
|
||||
fdroidCompile 'org.osmdroid:osmdroid-android:4.3'
|
||||
|
|
|
@ -216,13 +216,13 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
@Override
|
||||
public void onPrepared(MediaPlayer mp) {
|
||||
if (getUserVisibleHint()) {
|
||||
mp.start();
|
||||
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||
if (mPlayAudio) {
|
||||
mp.setVolume(1, 1);
|
||||
} else {
|
||||
mp.setVolume(0, 0);
|
||||
}
|
||||
mp.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.mariotaku.twidere.provider;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
|
@ -522,46 +521,6 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
}
|
||||
}
|
||||
|
||||
private void buildNotification(final NotificationCompat.Builder builder, final AccountPreferences accountPrefs,
|
||||
final int notificationType, final String ticker, final String title, final String message, final long when,
|
||||
final int icon, final Bitmap largeIcon, final Intent contentIntent, final Intent deleteIntent) {
|
||||
final Context context = getContext();
|
||||
builder.setTicker(ticker);
|
||||
builder.setContentTitle(title);
|
||||
builder.setContentText(message);
|
||||
builder.setAutoCancel(true);
|
||||
builder.setWhen(System.currentTimeMillis());
|
||||
builder.setSmallIcon(icon);
|
||||
if (largeIcon != null) {
|
||||
builder.setLargeIcon(largeIcon);
|
||||
}
|
||||
if (deleteIntent != null) {
|
||||
builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT));
|
||||
}
|
||||
if (contentIntent != null) {
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, contentIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT));
|
||||
}
|
||||
int defaults = 0;
|
||||
if (isNotificationAudible()) {
|
||||
if (AccountPreferences.isNotificationHasRingtone(notificationType)) {
|
||||
final Uri ringtone = accountPrefs.getNotificationRingtone();
|
||||
builder.setSound(ringtone, Notification.STREAM_DEFAULT);
|
||||
}
|
||||
if (AccountPreferences.isNotificationHasVibration(notificationType)) {
|
||||
defaults |= Notification.DEFAULT_VIBRATE;
|
||||
} else {
|
||||
defaults &= ~Notification.DEFAULT_VIBRATE;
|
||||
}
|
||||
}
|
||||
if (AccountPreferences.isNotificationHasLight(notificationType)) {
|
||||
final int color = accountPrefs.getNotificationLightColor();
|
||||
builder.setLights(color, 1000, 2000);
|
||||
}
|
||||
builder.setDefaults(defaults);
|
||||
}
|
||||
|
||||
private boolean checkPermission(final String... permissions) {
|
||||
return mPermissionsManager.checkCallingPermission(permissions);
|
||||
}
|
||||
|
@ -1039,6 +998,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
private static PendingIntent getDeleteIntent(Context context, String type, long accountId, long position) {
|
||||
// Setup delete intent
|
||||
final Intent recvIntent = new Intent(context, NotificationReceiver.class);
|
||||
recvIntent.setAction(BROADCAST_NOTIFICATION_DELETED);
|
||||
final Uri.Builder recvLinkBuilder = new Uri.Builder();
|
||||
recvLinkBuilder.scheme(SCHEME_TWIDERE);
|
||||
recvLinkBuilder.authority(AUTHORITY_NOTIFICATIONS);
|
||||
|
@ -1067,12 +1027,18 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
if (AccountPreferences.isNotificationHasLight(defaultFlags)) {
|
||||
notificationDefaults |= NotificationCompat.DEFAULT_LIGHTS;
|
||||
}
|
||||
if (AccountPreferences.isNotificationHasVibration(defaultFlags)) {
|
||||
notificationDefaults |= NotificationCompat.DEFAULT_VIBRATE;
|
||||
}
|
||||
if (AccountPreferences.isNotificationHasRingtone(defaultFlags)) {
|
||||
notificationDefaults |= NotificationCompat.DEFAULT_SOUND;
|
||||
builder.setSound(pref.getNotificationRingtone(), AudioManager.STREAM_NOTIFICATION);
|
||||
if (isNotificationAudible()) {
|
||||
if (AccountPreferences.isNotificationHasVibration(defaultFlags)) {
|
||||
notificationDefaults |= NotificationCompat.DEFAULT_VIBRATE;
|
||||
} else {
|
||||
notificationDefaults &= ~NotificationCompat.DEFAULT_VIBRATE;
|
||||
}
|
||||
if (AccountPreferences.isNotificationHasRingtone(defaultFlags)) {
|
||||
notificationDefaults |= NotificationCompat.DEFAULT_SOUND;
|
||||
builder.setSound(pref.getNotificationRingtone(), AudioManager.STREAM_NOTIFICATION);
|
||||
}
|
||||
} else {
|
||||
notificationDefaults &= ~(NotificationCompat.DEFAULT_VIBRATE | NotificationCompat.DEFAULT_SOUND);
|
||||
}
|
||||
builder.setDefaults(notificationDefaults);
|
||||
}
|
||||
|
@ -1281,10 +1247,6 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
return count;
|
||||
}
|
||||
|
||||
private static <T> T safeGet(final List<T> list, final int index) {
|
||||
return index >= 0 && index < list.size() ? list.get(index) : null;
|
||||
}
|
||||
|
||||
private static boolean shouldReplaceOnConflict(final int table_id) {
|
||||
switch (table_id) {
|
||||
case TABLE_ID_CACHED_HASHTAGS:
|
||||
|
|
|
@ -39,7 +39,9 @@ import org.mariotaku.twidere.util.Utils;
|
|||
public class NotificationReceiver extends BroadcastReceiver implements Constants {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
final String action = intent.getAction();
|
||||
if (action == null) return;
|
||||
switch (action) {
|
||||
case BROADCAST_NOTIFICATION_DELETED: {
|
||||
final Uri uri = intent.getData();
|
||||
final String tag = getPositionTag(uri.getLastPathSegment());
|
||||
|
|
|
@ -217,7 +217,7 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
}
|
||||
|
||||
private Notification buildNotification(final String title, final String message, final int icon,
|
||||
final Intent content_intent, final Intent delete_intent) {
|
||||
final Intent content_intent, final Intent deleteIntent) {
|
||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
|
||||
builder.setTicker(message);
|
||||
builder.setContentTitle(title);
|
||||
|
@ -225,8 +225,8 @@ public class BackgroundOperationService extends IntentService implements Constan
|
|||
builder.setAutoCancel(true);
|
||||
builder.setWhen(System.currentTimeMillis());
|
||||
builder.setSmallIcon(icon);
|
||||
if (delete_intent != null) {
|
||||
builder.setDeleteIntent(PendingIntent.getBroadcast(this, 0, delete_intent,
|
||||
if (deleteIntent != null) {
|
||||
builder.setDeleteIntent(PendingIntent.getBroadcast(this, 0, deleteIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT));
|
||||
}
|
||||
if (content_intent != null) {
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_notifications"
|
||||
android:dependency="stream_notifications"
|
||||
android:summary="@string/pebble_notifications_summary"
|
||||
android:title="@string/pebble_notifications"/>
|
||||
</PreferenceCategory>
|
||||
|
|
Loading…
Reference in New Issue