added filter for copyright links
This commit is contained in:
@@ -48,9 +48,11 @@ import java.util.List;
|
||||
|
||||
public class Newsfeed{
|
||||
public static List<String> mFilters;
|
||||
public static List<String> mFiltersLinks;
|
||||
|
||||
public static void setupFilters(){
|
||||
mFilters = new ArrayList();
|
||||
mFiltersLinks = new ArrayList();
|
||||
|
||||
getFilter("refsfilter", "Referals.txt");
|
||||
getFilter("shortlinkfilter", "LinkShorter.txt");
|
||||
@@ -63,6 +65,11 @@ public class Newsfeed{
|
||||
mFilters.addAll(Arrays.asList(customfilters.split(", ")));
|
||||
}
|
||||
|
||||
String linkfilter = getPrefsValue("linkfilter");
|
||||
|
||||
if(!linkfilter.isEmpty()){
|
||||
mFiltersLinks.addAll(Arrays.asList(linkfilter.split(", ")));
|
||||
}
|
||||
}
|
||||
|
||||
public static void getFilter(String boolname, String filename){
|
||||
@@ -108,19 +115,19 @@ public class Newsfeed{
|
||||
}
|
||||
|
||||
private static boolean checkCopyright(JSONObject json) throws JSONException{
|
||||
String linkfilter = getPrefsValue("linkfilter");
|
||||
|
||||
if(json.opt("copyright") != null){
|
||||
JSONObject copyright = json.getJSONObject("copyright");
|
||||
String copyrightlink = copyright.getString("link");
|
||||
|
||||
return copyrightlink.contains("vk.com") || copyright_post(); // fuck you, it doesn't work to detect link value
|
||||
for(String linkfilters : mFiltersLinks) {
|
||||
if(copyrightlink.toLowerCase().contains(linkfilters.toLowerCase())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// example of response
|
||||
//"copyright": {
|
||||
//"id": 251706814,
|
||||
//"link": "https://vk.com/wall251706814_9016",
|
||||
//"type": "owner",
|
||||
//"name": "Маргарита Буруня"
|
||||
//}
|
||||
return copyright_post();
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -21,11 +21,6 @@
|
||||
android:key="adsstories"
|
||||
android:summary="@string/feed_ads_stories_summary"
|
||||
android:title="@string/vtldas" />
|
||||
<com.vtosters.lite.ui.MaterialSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="copyright_post"
|
||||
android:summary="@string/feed_ads_sources_summary"
|
||||
android:title="@string/feed_ads_sources" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/vtlfilters">
|
||||
<Preference
|
||||
@@ -56,6 +51,15 @@
|
||||
android:key="shitposting"
|
||||
android:summary="@string/shitpostingsummary"
|
||||
android:title="@string/shitposting" />
|
||||
<com.vtosters.lite.ui.MaterialSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="copyright_post"
|
||||
android:summary="@string/feed_ads_sources_summary"
|
||||
android:title="@string/feed_ads_sources" />
|
||||
<EditTextPreference
|
||||
android:defaultValue=""
|
||||
android:key="linkfilter"
|
||||
android:title="Фильтр ссылок в источнике" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/vtlrecommend">
|
||||
<com.vtosters.lite.ui.MaterialSwitchPreference
|
||||
|
||||
Reference in New Issue
Block a user