Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Tiktok - Feed filter): Add more filters (#445)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
28 changed files
with
769 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/src/main/java/app/revanced/tiktok/feedfilter/AdsFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.tiktok.feedfilter; | ||
|
||
import app.revanced.tiktok.settings.SettingsEnum; | ||
import com.ss.android.ugc.aweme.feed.model.Aweme; | ||
|
||
public class AdsFilter implements IFilter { | ||
@Override | ||
public boolean getEnabled() { | ||
return SettingsEnum.REMOVE_ADS.getBoolean(); | ||
} | ||
|
||
@Override | ||
public boolean getFiltered(Aweme item) { | ||
return item.isAd() || item.isWithPromotionalMusic(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/java/app/revanced/tiktok/feedfilter/IFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package app.revanced.tiktok.feedfilter; | ||
|
||
import com.ss.android.ugc.aweme.feed.model.Aweme; | ||
|
||
public interface IFilter { | ||
boolean getEnabled(); | ||
|
||
boolean getFiltered(Aweme item); | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/app/revanced/tiktok/feedfilter/ImageVideoFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.tiktok.feedfilter; | ||
|
||
import app.revanced.tiktok.settings.SettingsEnum; | ||
import com.ss.android.ugc.aweme.feed.model.Aweme; | ||
|
||
public class ImageVideoFilter implements IFilter { | ||
@Override | ||
public boolean getEnabled() { | ||
return SettingsEnum.HIDE_IMAGE.getBoolean(); | ||
} | ||
|
||
@Override | ||
public boolean getFiltered(Aweme item) { | ||
return item.isImage() || item.isPhotoMode(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/app/revanced/tiktok/feedfilter/LikeCountFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package app.revanced.tiktok.feedfilter; | ||
|
||
import app.revanced.tiktok.settings.SettingsEnum; | ||
import com.ss.android.ugc.aweme.feed.model.Aweme; | ||
import com.ss.android.ugc.aweme.feed.model.AwemeStatistics; | ||
|
||
import static app.revanced.tiktok.utils.ReVancedUtils.parseMinMax; | ||
|
||
public final class LikeCountFilter implements IFilter { | ||
final long minLike; | ||
final long maxLike; | ||
|
||
LikeCountFilter() { | ||
long[] minMax = parseMinMax(SettingsEnum.MIN_MAX_LIKES); | ||
minLike = minMax[0]; | ||
maxLike = minMax[1]; | ||
} | ||
|
||
@Override | ||
public boolean getEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean getFiltered(Aweme item) { | ||
AwemeStatistics statistics = item.getStatistics(); | ||
if (statistics == null) return false; | ||
|
||
long likeCount = statistics.getDiggCount(); | ||
return likeCount < minLike || likeCount > maxLike; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/app/revanced/tiktok/feedfilter/LiveFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.tiktok.feedfilter; | ||
|
||
import app.revanced.tiktok.settings.SettingsEnum; | ||
import com.ss.android.ugc.aweme.feed.model.Aweme; | ||
|
||
public class LiveFilter implements IFilter { | ||
@Override | ||
public boolean getEnabled() { | ||
return SettingsEnum.HIDE_LIVE.getBoolean(); | ||
} | ||
|
||
@Override | ||
public boolean getFiltered(Aweme item) { | ||
return item.isLive() || item.isLiveReplay(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/app/revanced/tiktok/feedfilter/StoryFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.tiktok.feedfilter; | ||
|
||
import app.revanced.tiktok.settings.SettingsEnum; | ||
import com.ss.android.ugc.aweme.feed.model.Aweme; | ||
|
||
public class StoryFilter implements IFilter { | ||
@Override | ||
public boolean getEnabled() { | ||
return SettingsEnum.HIDE_STORY.getBoolean(); | ||
} | ||
|
||
@Override | ||
public boolean getFiltered(Aweme item) { | ||
return item.getIsTikTokStory(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/app/revanced/tiktok/feedfilter/ViewCountFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package app.revanced.tiktok.feedfilter; | ||
|
||
import app.revanced.tiktok.settings.SettingsEnum; | ||
import com.ss.android.ugc.aweme.feed.model.Aweme; | ||
import com.ss.android.ugc.aweme.feed.model.AwemeStatistics; | ||
|
||
import static app.revanced.tiktok.utils.ReVancedUtils.parseMinMax; | ||
|
||
public class ViewCountFilter implements IFilter { | ||
final long minView; | ||
final long maxView; | ||
|
||
ViewCountFilter() { | ||
long[] minMax = parseMinMax(SettingsEnum.MIN_MAX_VIEWS); | ||
minView = minMax[0]; | ||
maxView = minMax[1]; | ||
} | ||
|
||
@Override | ||
public boolean getEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean getFiltered(Aweme item) { | ||
AwemeStatistics statistics = item.getStatistics(); | ||
if (statistics == null) return false; | ||
|
||
long playCount = statistics.getPlayCount(); | ||
return playCount < minView || playCount > maxView; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.