From 0a672476d9cdb993b7a17b7a4444e16d1505e8ef Mon Sep 17 00:00:00 2001 From: zerrium Date: Thu, 18 Mar 2021 12:40:05 +0700 Subject: [PATCH] Added back-end code to filter out instagram posts with specified keywords --- .../instagrabber/activities/MainActivity.java | 14 ++++++++++++++ .../awais/instagrabber/adapters/FeedAdapterV2.java | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/src/main/java/awais/instagrabber/activities/MainActivity.java b/app/src/main/java/awais/instagrabber/activities/MainActivity.java index 411f6225..86acbf2a 100644 --- a/app/src/main/java/awais/instagrabber/activities/MainActivity.java +++ b/app/src/main/java/awais/instagrabber/activities/MainActivity.java @@ -10,6 +10,7 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.res.TypedArray; import android.database.MatrixCursor; +import android.net.IpSecManager; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; @@ -83,6 +84,7 @@ import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.Utils; import awais.instagrabber.utils.emoji.EmojiParser; import awais.instagrabber.viewmodels.AppStateViewModel; +import zerrium.FilterKeywords; import static awais.instagrabber.utils.NavigationExtensions.setupWithNavController; import static awais.instagrabber.utils.Utils.settingsHelper; @@ -174,6 +176,18 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage }); initEmojiCompat(); // initDmService(); + initZerriumFilter(); //to filter out junk instagram post + } + + private void initZerriumFilter(){ + boolean filter_result = false; + try{ + filter_result = FilterKeywords.insert(getResources().getStringArray(R.array.filter_keyword)); + }catch(Exception e){ + Log.e(TAG, "initZerriumFilter: " + e); + } + if(!filter_result) Log.d(TAG, "ZerriumFilter insert failed"); + else Log.d(TAG, "ZerriumFilter insert success"); } private void initDmService() { diff --git a/app/src/main/java/awais/instagrabber/adapters/FeedAdapterV2.java b/app/src/main/java/awais/instagrabber/adapters/FeedAdapterV2.java index 891d6a00..7d14ddef 100644 --- a/app/src/main/java/awais/instagrabber/adapters/FeedAdapterV2.java +++ b/app/src/main/java/awais/instagrabber/adapters/FeedAdapterV2.java @@ -1,6 +1,7 @@ package awais.instagrabber.adapters; import android.content.Context; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -27,6 +28,7 @@ import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.repositories.responses.Caption; import awais.instagrabber.repositories.responses.Media; +import zerrium.FilterKeywords; public final class FeedAdapterV2 extends ListAdapter { private static final String TAG = "FeedAdapterV2"; @@ -152,6 +154,15 @@ public final class FeedAdapterV2 extends ListAdapter