sponsorpost stats
This commit is contained in:
@@ -37,6 +37,40 @@ public class SponsorPostFragment extends TrackedMaterialPreferenceToolbarFragmen
|
||||
null
|
||||
);
|
||||
|
||||
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), "Статистика блокировок");
|
||||
|
||||
PreferenceFragmentUtils.addPreference(
|
||||
getPreferenceScreen(),
|
||||
"",
|
||||
"SponsorPost",
|
||||
"Заблокировано " + PostsPreferences.getNumBlockedPosts() + " постов",
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
PreferenceFragmentUtils.addPreference(
|
||||
getPreferenceScreen(),
|
||||
"",
|
||||
"SponsorPost фильтры",
|
||||
"Заблокировано " + FiltersPreferences.getNumBlockedPosts() + " постов",
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
PreferenceFragmentUtils.addPreference(
|
||||
getPreferenceScreen(),
|
||||
"",
|
||||
"Сброс статистики",
|
||||
null,
|
||||
null,
|
||||
preference -> {
|
||||
FiltersPreferences.dropNumBlockedPosts();
|
||||
PostsPreferences.dropNumBlockedPosts();
|
||||
AndroidUtils.sendToast("Статистика сброшена");
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), "Sponsor Post");
|
||||
|
||||
if (Preferences.serverFeaturesDisable()) {
|
||||
|
||||
@@ -213,34 +213,33 @@ public class NewsFeedFiltersUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (adsgroup() && post.optInt("marked_as_ads") == 1 && !post.optBoolean("sponsorpost") && !post.optBoolean("sponsorpost_filters") && !isWhitelistedAd(post)) {
|
||||
if (adsgroup() && post.optInt("marked_as_ads") == 1 && !post.optBoolean("sponsorpost") && !isWhitelistedAd(post)) {
|
||||
logRemovedPost(post, source, "marked_as_ads", needToShowToast);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PostsPreferences.isPostAd(getOwnerId(post), getPostId(post)) && !post.optBoolean("sponsorpost") && !post.optBoolean("sponsorpost_filters") && !isWhitelistedAd(post)) {
|
||||
if (PostsPreferences.isPostAd(getOwnerId(post), getPostId(post)) && !post.optBoolean("sponsorpost") && !isWhitelistedAd(post)) {
|
||||
logRemovedPost(post, source, "sponsorpost", needToShowToast);
|
||||
PostsPreferences.incrementNumBlockedPosts();
|
||||
|
||||
if (PostsPreferences.isEnabledMarking()) {
|
||||
post.putOpt("marked_as_ads", 1);
|
||||
post.putOpt("sponsorpost", true);
|
||||
addSponsorPostMark(post);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (VotesPreferences.isPostAd(getOwnerId(post), getPostId(post)) && !post.optBoolean("sponsorpost") && !post.optBoolean("sponsorpost_filters") && !isWhitelistedAd(post)) {
|
||||
if (VotesPreferences.isPostAd(getOwnerId(post), getPostId(post)) && !post.optBoolean("sponsorpost") && !isWhitelistedAd(post)) {
|
||||
logRemovedPost(post, source, "sponsorpost vote base", needToShowToast);
|
||||
post.putOpt("marked_as_ads", 1);
|
||||
post.putOpt("sponsorpost", true);
|
||||
addSponsorPostMark(post);
|
||||
}
|
||||
|
||||
if (sponsorFilters(post.optString("text")) && !post.optBoolean("sponsorpost") && !post.optBoolean("sponsorpost_filters") && !isWhitelistedFilters(post)) {
|
||||
if (sponsorFilters(post.optString("text")) && !post.optBoolean("sponsorpost") && !isWhitelistedFilters(post)) {
|
||||
logRemovedPost(post, source, "sponsorpost filter", needToShowToast);
|
||||
FiltersPreferences.incrementNumBlockedPosts();
|
||||
|
||||
if (FiltersPreferences.isEnabledMarking()) {
|
||||
post.putOpt("marked_as_ads", 1);
|
||||
post.putOpt("sponsorpost_filters", true);
|
||||
addSponsorPostMark(post);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -248,6 +247,7 @@ public class NewsFeedFiltersUtils {
|
||||
|
||||
if (checkCopyright(post)) {
|
||||
logRemovedPost(post, source, "copyright filters", needToShowToast);
|
||||
FiltersPreferences.incrementNumBlockedPosts();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -269,6 +269,11 @@ public class NewsFeedFiltersUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void addSponsorPostMark(JSONObject post) throws JSONException {
|
||||
post.putOpt("marked_as_ads", 1);
|
||||
post.putOpt("sponsorpost", true);
|
||||
}
|
||||
|
||||
public static JSONArray feedInject(JSONArray items, boolean needToShowToast) {
|
||||
if (items.length() == 0) return items;
|
||||
|
||||
@@ -315,7 +320,6 @@ public class NewsFeedFiltersUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static void parseStoriesItem(JSONObject item) throws JSONException {
|
||||
JSONArray stories = item.optJSONArray("stories");
|
||||
JSONArray newStories = new JSONArray();
|
||||
|
||||
@@ -39,6 +39,18 @@ public class FiltersPreferences {
|
||||
preferences.edit().putBoolean("sponsorpost_filters_marking", status).apply();
|
||||
}
|
||||
|
||||
public static int getNumBlockedPosts() {
|
||||
return preferences.getInt("numBlockedPosts", 0);
|
||||
}
|
||||
|
||||
public static void incrementNumBlockedPosts() {
|
||||
preferences.edit().putInt("numBlockedPosts", getNumBlockedPosts() + 1).apply();
|
||||
}
|
||||
|
||||
public static void dropNumBlockedPosts() {
|
||||
preferences.edit().putInt("numBlockedPosts", 0).apply();
|
||||
}
|
||||
|
||||
public static void clearAllCachedLists() {
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
|
||||
@@ -95,6 +95,18 @@ public class PostsPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNumBlockedPosts() {
|
||||
return preferences.getInt("numBlockedPosts", 0);
|
||||
}
|
||||
|
||||
public static void incrementNumBlockedPosts() {
|
||||
preferences.edit().putInt("numBlockedPosts", getNumBlockedPosts() + 1).apply();
|
||||
}
|
||||
|
||||
public static void dropNumBlockedPosts() {
|
||||
preferences.edit().putInt("numBlockedPosts", 0).apply();
|
||||
}
|
||||
|
||||
public static boolean isPostAd(long ownerId, long postId) {
|
||||
if (isEnabled() && isGroupAd(ownerId)) {
|
||||
Set<String> hasSpecifiedGroupPosts = preferences.getStringSet(ownerId + "_posts", new HashSet<>());
|
||||
|
||||
Reference in New Issue
Block a user