(receiver) create package for receiver
This commit is contained in:
parent
1815d574c8
commit
ed5564d4d5
6 changed files with 8 additions and 6 deletions
|
@ -1,31 +0,0 @@
|
|||
/* Copyright 2017 Andrew Dawson
|
||||
*
|
||||
* This file is a part of Tusky.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Tusky 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 Tusky; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
package com.keylesspalace.tusky.util;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class NotificationClearBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
SharedPreferences notificationPreferences = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = notificationPreferences.edit();
|
||||
editor.putString("current", "[]");
|
||||
editor.apply();
|
||||
}
|
||||
}
|
|
@ -32,6 +32,8 @@ import android.support.v4.app.TaskStackBuilder;
|
|||
import com.keylesspalace.tusky.MainActivity;
|
||||
import com.keylesspalace.tusky.R;
|
||||
import com.keylesspalace.tusky.entity.Notification;
|
||||
import com.keylesspalace.tusky.receiver.NotificationClearBroadcastReceiver;
|
||||
import com.keylesspalace.tusky.view.RoundedTransformation;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Target;
|
||||
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package com.keylesspalace.tusky.util;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import com.keylesspalace.tusky.adapter.TimelineAdapter;
|
||||
import com.keylesspalace.tusky.fragment.TimelineFragment;
|
||||
|
||||
public class TimelineReceiver extends BroadcastReceiver {
|
||||
public static final class Types {
|
||||
public static final String UNFOLLOW_ACCOUNT = "UNFOLLOW_ACCOUNT";
|
||||
public static final String BLOCK_ACCOUNT = "BLOCK_ACCOUNT";
|
||||
public static final String MUTE_ACCOUNT = "MUTE_ACCOUNT";
|
||||
}
|
||||
|
||||
TimelineAdapter adapter;
|
||||
|
||||
public TimelineReceiver(TimelineAdapter adapter) {
|
||||
super();
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, final Intent intent) {
|
||||
String id = intent.getStringExtra("id");
|
||||
adapter.removeAllByAccountId(id);
|
||||
}
|
||||
|
||||
public static IntentFilter getFilter(TimelineFragment.Kind kind) {
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
if (kind == TimelineFragment.Kind.HOME) {
|
||||
intentFilter.addAction(Types.UNFOLLOW_ACCOUNT);
|
||||
}
|
||||
intentFilter.addAction(Types.BLOCK_ACCOUNT);
|
||||
intentFilter.addAction(Types.MUTE_ACCOUNT);
|
||||
|
||||
return intentFilter;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue