mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-27 10:07:32 +01:00
Updated PullRequest with recommended improvements
This commit is contained in:
parent
51399066a4
commit
86e92130d2
@ -25,12 +25,10 @@ import android.support.v7.widget.SearchView;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.adapter.AppBlacklistAdapter;
|
import nodomain.freeyourgadget.gadgetbridge.adapter.AppBlacklistAdapter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
public class AppBlacklistActivity extends AbstractGBActivity {
|
public class AppBlacklistActivity extends AbstractGBActivity {
|
||||||
|
@ -3,11 +3,9 @@ package nodomain.freeyourgadget.gadgetbridge.activities;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
|
||||||
import de.greenrobot.dao.query.Query;
|
import de.greenrobot.dao.query.Query;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.adapter.AppBlacklistAdapter;
|
import nodomain.freeyourgadget.gadgetbridge.adapter.AppBlacklistAdapter;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||||
@ -15,7 +13,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilter;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterDao;
|
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterDao;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterEntry;
|
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterEntry;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterEntryDao;
|
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterEntryDao;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -25,8 +23,6 @@ import java.util.List;
|
|||||||
|
|
||||||
public class NotificationFilterActivity extends AbstractGBActivity {
|
public class NotificationFilterActivity extends AbstractGBActivity {
|
||||||
|
|
||||||
private static final String TAG = NotificationFilterActivity.class.getName();
|
|
||||||
|
|
||||||
public static final int NOTIFICATION_FILTER_MODE_NONE = 0;
|
public static final int NOTIFICATION_FILTER_MODE_NONE = 0;
|
||||||
public static final int NOTIFICATION_FILTER_MODE_WHITELIST = 1;
|
public static final int NOTIFICATION_FILTER_MODE_WHITELIST = 1;
|
||||||
public static final int NOTIFICATION_FILTER_MODE_BLACKLIST = 2;
|
public static final int NOTIFICATION_FILTER_MODE_BLACKLIST = 2;
|
||||||
@ -38,7 +34,6 @@ public class NotificationFilterActivity extends AbstractGBActivity {
|
|||||||
private Spinner mSpinnerFilterSubMode;
|
private Spinner mSpinnerFilterSubMode;
|
||||||
private NotificationFilter mNotificationFilter;
|
private NotificationFilter mNotificationFilter;
|
||||||
private EditText mEditTextWords;
|
private EditText mEditTextWords;
|
||||||
private DBHandler db = null;
|
|
||||||
private List<String> mWordsList = new ArrayList<>();
|
private List<String> mWordsList = new ArrayList<>();
|
||||||
private List<Long> mFilterEntryIds = new ArrayList<>();
|
private List<Long> mFilterEntryIds = new ArrayList<>();
|
||||||
|
|
||||||
@ -58,49 +53,43 @@ public class NotificationFilterActivity extends AbstractGBActivity {
|
|||||||
|
|
||||||
packageName = packageName.toLowerCase();
|
packageName = packageName.toLowerCase();
|
||||||
|
|
||||||
try {
|
try (DBHandler db = GBApplication.acquireDB()) {
|
||||||
db = GBApplication.acquireDB();
|
|
||||||
} catch (GBException e) {
|
|
||||||
LOG.error("Could not acquire DB.", e);
|
|
||||||
this.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationFilterDao notificationFilterDao = db.getDaoSession().getNotificationFilterDao();
|
NotificationFilterDao notificationFilterDao = db.getDaoSession().getNotificationFilterDao();
|
||||||
NotificationFilterEntryDao notificationFilterEntryDao = db.getDaoSession().getNotificationFilterEntryDao();
|
NotificationFilterEntryDao notificationFilterEntryDao = db.getDaoSession().getNotificationFilterEntryDao();
|
||||||
|
|
||||||
Query<NotificationFilter> query = notificationFilterDao.queryBuilder().where(NotificationFilterDao.Properties.AppIdentifier.eq(packageName)).build();
|
Query<NotificationFilter> query = notificationFilterDao.queryBuilder().where(NotificationFilterDao.Properties.AppIdentifier.eq(packageName)).build();
|
||||||
mNotificationFilter = query.unique();
|
mNotificationFilter = query.unique();
|
||||||
|
|
||||||
if (mNotificationFilter == null) {
|
if (mNotificationFilter == null) {
|
||||||
mNotificationFilter = new NotificationFilter();
|
mNotificationFilter = new NotificationFilter();
|
||||||
mNotificationFilter.setAppIdentifier(packageName);
|
mNotificationFilter.setAppIdentifier(packageName);
|
||||||
LOG.debug("New Notification Filter");
|
LOG.debug("New Notification Filter");
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Loaded existing notification filter");
|
LOG.debug("Loaded existing notification filter");
|
||||||
Query<NotificationFilterEntry> queryEntries = notificationFilterEntryDao.queryBuilder().where(NotificationFilterEntryDao.Properties.NotificationFilterId.eq(mNotificationFilter.getId())).build();
|
Query<NotificationFilterEntry> queryEntries = notificationFilterEntryDao.queryBuilder().where(NotificationFilterEntryDao.Properties.NotificationFilterId.eq(mNotificationFilter.getId())).build();
|
||||||
List<NotificationFilterEntry> filterEntries = queryEntries.list();
|
List<NotificationFilterEntry> filterEntries = queryEntries.list();
|
||||||
if (!filterEntries.isEmpty()) {
|
|
||||||
for (NotificationFilterEntry temp : filterEntries) {
|
for (NotificationFilterEntry temp : filterEntries) {
|
||||||
mWordsList.add(temp.getNotificationFilterContent());
|
mWordsList.add(temp.getNotificationFilterContent());
|
||||||
mFilterEntryIds.add(temp.getId());
|
mFilterEntryIds.add(temp.getId());
|
||||||
LOG.debug("Loaded filter word: " + temp.getNotificationFilterContent());
|
LOG.debug("Loaded filter word: " + temp.getNotificationFilterContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
setupView();
|
setupView(db);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
GB.toast(this, "Error accessing the database: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
|
this.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
if (db != null) {
|
|
||||||
GBApplication.releaseDB();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupView() {
|
private void setupView(DBHandler db) {
|
||||||
|
|
||||||
mSpinnerFilterMode = findViewById(R.id.spinnerFilterMode);
|
mSpinnerFilterMode = findViewById(R.id.spinnerFilterMode);
|
||||||
mSpinnerFilterMode.setSelection(mNotificationFilter.getNotificationFilterMode());
|
mSpinnerFilterMode.setSelection(mNotificationFilter.getNotificationFilterMode());
|
||||||
@ -145,69 +134,76 @@ public class NotificationFilterActivity extends AbstractGBActivity {
|
|||||||
mEditTextWords.setEnabled(mSpinnerFilterMode.getSelectedItemPosition() == NOTIFICATION_FILTER_MODE_NONE);
|
mEditTextWords.setEnabled(mSpinnerFilterMode.getSelectedItemPosition() == NOTIFICATION_FILTER_MODE_NONE);
|
||||||
|
|
||||||
mButtonSave = findViewById(R.id.buttonSaveFilter);
|
mButtonSave = findViewById(R.id.buttonSaveFilter);
|
||||||
|
|
||||||
mButtonSave.setOnClickListener(new View.OnClickListener() {
|
mButtonSave.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
saveFilter();
|
||||||
// TODO: check for modifications, only save if something changed
|
|
||||||
String words = mEditTextWords.getText().toString();
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(words) && mSpinnerFilterMode.getSelectedItemPosition() != NOTIFICATION_FILTER_MODE_NONE) {
|
|
||||||
Toast.makeText(NotificationFilterActivity.this, R.string.toast_notification_filter_words_empty_hint, Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
db = GBApplication.acquireDB();
|
|
||||||
NotificationFilterDao notificationFilterDao = db.getDaoSession().getNotificationFilterDao();
|
|
||||||
NotificationFilterEntryDao notificationFilterEntryDao = db.getDaoSession().getNotificationFilterEntryDao();
|
|
||||||
|
|
||||||
debugOutput(notificationFilterDao);
|
|
||||||
|
|
||||||
mNotificationFilter.setNotificationFilterMode(mSpinnerFilterMode.getSelectedItemPosition());
|
|
||||||
mNotificationFilter.setNotificationFilterSubMode(mSpinnerFilterSubMode.getSelectedItemPosition());
|
|
||||||
|
|
||||||
notificationFilterEntryDao.deleteByKeyInTx(mFilterEntryIds);
|
|
||||||
|
|
||||||
Long filterId = notificationFilterDao.insertOrReplace(mNotificationFilter);
|
|
||||||
|
|
||||||
// only save words if filter mode != none
|
|
||||||
if (mNotificationFilter.getNotificationFilterMode() != NOTIFICATION_FILTER_MODE_NONE) {
|
|
||||||
String[] wordsSplitted = words.split("\n");
|
|
||||||
for (String temp : wordsSplitted) {
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(temp)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = temp.trim();
|
|
||||||
NotificationFilterEntry notificationFilterEntry = new NotificationFilterEntry();
|
|
||||||
notificationFilterEntry.setNotificationFilterContent(temp);
|
|
||||||
notificationFilterEntry.setNotificationFilterId(filterId);
|
|
||||||
notificationFilterEntryDao.insert(notificationFilterEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast.makeText(NotificationFilterActivity.this, R.string.toast_notification_filter_saved_successfully, Toast.LENGTH_SHORT).show();
|
|
||||||
NotificationFilterActivity.this.finish();
|
|
||||||
|
|
||||||
} catch (GBException e) {
|
|
||||||
LOG.error("Could not acquire DB.", e);
|
|
||||||
Toast.makeText(NotificationFilterActivity.this, "Database Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveFilter() {
|
||||||
|
// TODO: check for modifications, only save if something changed
|
||||||
|
String words = mEditTextWords.getText().toString();
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(words) && mSpinnerFilterMode.getSelectedItemPosition() != NOTIFICATION_FILTER_MODE_NONE) {
|
||||||
|
Toast.makeText(NotificationFilterActivity.this, R.string.toast_notification_filter_words_empty_hint, Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try (DBHandler db = GBApplication.acquireDB()) {
|
||||||
|
NotificationFilterDao notificationFilterDao = db.getDaoSession().getNotificationFilterDao();
|
||||||
|
NotificationFilterEntryDao notificationFilterEntryDao = db.getDaoSession().getNotificationFilterEntryDao();
|
||||||
|
|
||||||
|
debugOutput(notificationFilterDao);
|
||||||
|
|
||||||
|
mNotificationFilter.setNotificationFilterMode(mSpinnerFilterMode.getSelectedItemPosition());
|
||||||
|
mNotificationFilter.setNotificationFilterSubMode(mSpinnerFilterSubMode.getSelectedItemPosition());
|
||||||
|
|
||||||
|
notificationFilterEntryDao.deleteByKeyInTx(mFilterEntryIds);
|
||||||
|
|
||||||
|
Long filterId = notificationFilterDao.insertOrReplace(mNotificationFilter);
|
||||||
|
|
||||||
|
// only save words if filter mode != none
|
||||||
|
if (mNotificationFilter.getNotificationFilterMode() != NOTIFICATION_FILTER_MODE_NONE) {
|
||||||
|
String[] wordsSplitted = words.split("\n");
|
||||||
|
for (String temp : wordsSplitted) {
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(temp)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = temp.trim();
|
||||||
|
NotificationFilterEntry notificationFilterEntry = new NotificationFilterEntry();
|
||||||
|
notificationFilterEntry.setNotificationFilterContent(temp);
|
||||||
|
notificationFilterEntry.setNotificationFilterId(filterId);
|
||||||
|
notificationFilterEntryDao.insert(notificationFilterEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.makeText(NotificationFilterActivity.this, R.string.toast_notification_filter_saved_successfully, Toast.LENGTH_SHORT).show();
|
||||||
|
NotificationFilterActivity.this.finish();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
GB.toast(NotificationFilterActivity.this, "Error accessing the database: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only used for debugging purposes
|
||||||
|
*
|
||||||
|
* @param notificationFilterDao {@link NotificationFilterDao}
|
||||||
|
*/
|
||||||
private void debugOutput(NotificationFilterDao notificationFilterDao) {
|
private void debugOutput(NotificationFilterDao notificationFilterDao) {
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
|
|
||||||
List<NotificationFilter> filters = notificationFilterDao.loadAll();
|
List<NotificationFilter> filters = notificationFilterDao.loadAll();
|
||||||
|
|
||||||
LOG.info(TAG, "Saved filters");
|
LOG.info("Saved filters");
|
||||||
|
|
||||||
for (NotificationFilter temp : filters) {
|
for (NotificationFilter temp : filters) {
|
||||||
LOG.info(TAG, "Filter: " + temp.getId() + " " + temp.getAppIdentifier());
|
LOG.info("Filter: " + temp.getId() + " " + temp.getAppIdentifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import java.util.Set;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.NotificationFilterActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.NotificationFilterActivity;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.GBApplication.packageNameToPebbleMsgSender;
|
import static nodomain.freeyourgadget.gadgetbridge.GBApplication.packageNameToPebbleMsgSender;
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ public class AppBlacklistAdapter extends RecyclerView.Adapter<AppBlacklistAdapte
|
|||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
|
||||||
if (holder.blacklist_checkbox.isChecked()) {
|
if (holder.blacklist_checkbox.isChecked()) {
|
||||||
Toast.makeText(mContext, R.string.toast_app_must_not_be_blacklisted, Toast.LENGTH_SHORT).show();
|
GB.toast(mContext, mContext.getString(R.string.toast_app_must_not_be_blacklisted), Toast.LENGTH_SHORT, GB.INFO);
|
||||||
} else {
|
} else {
|
||||||
Intent intentStartNotificationFilterActivity = new Intent(mContext, NotificationFilterActivity.class);
|
Intent intentStartNotificationFilterActivity = new Intent(mContext, NotificationFilterActivity.class);
|
||||||
intentStartNotificationFilterActivity.putExtra(STRING_EXTRA_PACKAGE_NAME, appInfo.packageName);
|
intentStartNotificationFilterActivity.putExtra(STRING_EXTRA_PACKAGE_NAME, appInfo.packageName);
|
||||||
|
@ -364,44 +364,43 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
private boolean checkNotificationContentForWhiteAndBlackList(String packageName, String body) {
|
private boolean checkNotificationContentForWhiteAndBlackList(String packageName, String body) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
DBHandler db;
|
List<String> wordsList = new ArrayList<>();
|
||||||
|
NotificationFilter notificationFilter;
|
||||||
|
|
||||||
try {
|
try (DBHandler db = GBApplication.acquireDB()) {
|
||||||
db = GBApplication.acquireDB();
|
|
||||||
} catch (GBException e) {
|
NotificationFilterDao notificationFilterDao = db.getDaoSession().getNotificationFilterDao();
|
||||||
|
NotificationFilterEntryDao notificationFilterEntryDao = db.getDaoSession().getNotificationFilterEntryDao();
|
||||||
|
|
||||||
|
Query<NotificationFilter> query = notificationFilterDao.queryBuilder().where(NotificationFilterDao.Properties.AppIdentifier.eq(packageName.toLowerCase())).build();
|
||||||
|
notificationFilter = query.unique();
|
||||||
|
|
||||||
|
if (notificationFilter == null) {
|
||||||
|
LOG.debug("No Notification Filter found");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.debug("Loaded notification filter for '{}'", packageName);
|
||||||
|
Query<NotificationFilterEntry> queryEntries = notificationFilterEntryDao.queryBuilder().where(NotificationFilterEntryDao.Properties.NotificationFilterId.eq(notificationFilter.getId())).build();
|
||||||
|
|
||||||
|
List<NotificationFilterEntry> filterEntries = queryEntries.list();
|
||||||
|
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
LOG.info("Database lookup took '{}' ms", System.currentTimeMillis() - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filterEntries.isEmpty()) {
|
||||||
|
for (NotificationFilterEntry temp : filterEntries) {
|
||||||
|
wordsList.add(temp.getNotificationFilterContent());
|
||||||
|
LOG.debug("Loaded filter word: " + temp.getNotificationFilterContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
LOG.error("Could not acquire DB.", e);
|
LOG.error("Could not acquire DB.", e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> wordsList = new ArrayList<>();
|
|
||||||
|
|
||||||
NotificationFilterDao notificationFilterDao = db.getDaoSession().getNotificationFilterDao();
|
|
||||||
NotificationFilterEntryDao notificationFilterEntryDao = db.getDaoSession().getNotificationFilterEntryDao();
|
|
||||||
|
|
||||||
Query<NotificationFilter> query = notificationFilterDao.queryBuilder().where(NotificationFilterDao.Properties.AppIdentifier.eq(packageName.toLowerCase())).build();
|
|
||||||
NotificationFilter notificationFilter = query.unique();
|
|
||||||
|
|
||||||
if (notificationFilter == null) {
|
|
||||||
LOG.debug("No Notification Filter found");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.debug("Loaded notification filter for '{}'", packageName);
|
|
||||||
Query<NotificationFilterEntry> queryEntries = notificationFilterEntryDao.queryBuilder().where(NotificationFilterEntryDao.Properties.NotificationFilterId.eq(notificationFilter.getId())).build();
|
|
||||||
|
|
||||||
List<NotificationFilterEntry> filterEntries = queryEntries.list();
|
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
LOG.info("Database lookup took '{}' ms", System.currentTimeMillis() - start);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!filterEntries.isEmpty()) {
|
|
||||||
for (NotificationFilterEntry temp : filterEntries) {
|
|
||||||
wordsList.add(temp.getNotificationFilterContent());
|
|
||||||
LOG.debug("Loaded filter word: " + temp.getNotificationFilterContent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return shouldContinueAfterFilter(body, wordsList, notificationFilter);
|
return shouldContinueAfterFilter(body, wordsList, notificationFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,13 +422,13 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
LOG.info("Every word was found, blacklist has effect, processing stops.");
|
LOG.info("Every word was found, blacklist has effect, processing stops.");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
boolean notContainsAny = !StringUtils.containsAny(body, wordsList.toArray(new CharSequence[0]));
|
boolean containsAny = StringUtils.containsAny(body, wordsList.toArray(new CharSequence[0]));
|
||||||
if (notContainsAny) {
|
if (!containsAny) {
|
||||||
LOG.info("Not matching word was found, blacklist has no effect, processing continues.");
|
LOG.info("No matching word was found, blacklist has no effect, processing continues.");
|
||||||
} else {
|
} else {
|
||||||
LOG.info("At least one matching word was found, blacklist has effect, processing stops.");
|
LOG.info("At least one matching word was found, blacklist has effect, processing stops.");
|
||||||
}
|
}
|
||||||
return notContainsAny;
|
return !containsAny;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NOTIFICATION_FILTER_MODE_WHITELIST:
|
case NOTIFICATION_FILTER_MODE_WHITELIST:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user