1
mirror of https://github.com/revanced/revanced-integrations synced 2025-11-21 18:35:37 +01:00

Compare commits

..

38 Commits

Author SHA1 Message Date
semantic-release-bot
5c5a42da40 chore(release): 0.94.0 [skip ci]
# [0.94.0](https://github.com/revanced/revanced-integrations/compare/v0.93.1...v0.94.0) (2023-01-28)

### Bug Fixes

* **youtube/return-youtube-dislike:** do not fetch voting stats when watching shorts ([#302](https://github.com/revanced/revanced-integrations/issues/302)) ([7551f01](7551f0104c))
* **youtube/return-youtube-dislike:** gracefully exit if Vanced MicroG is missing or not running ([#303](https://github.com/revanced/revanced-integrations/issues/303)) ([03764bc](03764bcc65))
* **youtube:** save new instead of default value ([#298](https://github.com/revanced/revanced-integrations/issues/298)) ([559bbf9](559bbf9778))

### Features

* **youtube/general-ads:** remove hiding video shelf ([04147c1](04147c17c9))
* **youtube/microg-support:** check if Vanced MicroG is running in the background ([#301](https://github.com/revanced/revanced-integrations/issues/301)) ([6e31b78](6e31b7889a))
* **youtube:** `open-links-externally` patch ([4cbe833](4cbe8338b3))
* **youtube:** show toasts along exceptions ([#293](https://github.com/revanced/revanced-integrations/issues/293)) ([dbf1f3f](dbf1f3f0ce))
2023-01-28 08:05:25 +00:00
oSumAtrIX
bb8cdc494f chore: merge branch dev to main (#299) 2023-01-28 09:02:38 +01:00
semantic-release-bot
42346ee3cf chore(release): 0.94.0-dev.6 [skip ci]
# [0.94.0-dev.6](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.5...v0.94.0-dev.6) (2023-01-28)

### Features

* **youtube:** show toasts along exceptions ([#293](https://github.com/revanced/revanced-integrations/issues/293)) ([dbf1f3f](dbf1f3f0ce))
2023-01-28 07:40:30 +00:00
LisoUseInAIKyrios
dbf1f3f0ce feat(youtube): show toasts along exceptions (#293)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-28 08:38:31 +01:00
semantic-release-bot
a70e80dfa0 chore(release): 0.94.0-dev.5 [skip ci]
# [0.94.0-dev.5](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.4...v0.94.0-dev.5) (2023-01-28)

### Bug Fixes

* **youtube/return-youtube-dislike:** do not fetch voting stats when watching shorts ([#302](https://github.com/revanced/revanced-integrations/issues/302)) ([7551f01](7551f0104c))
2023-01-28 07:31:27 +00:00
LisoUseInAIKyrios
7551f0104c fix(youtube/return-youtube-dislike): do not fetch voting stats when watching shorts (#302)
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-28 08:28:42 +01:00
semantic-release-bot
d8bd27251c chore(release): 0.94.0-dev.4 [skip ci]
# [0.94.0-dev.4](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.3...v0.94.0-dev.4) (2023-01-28)

### Features

* **youtube/general-ads:** remove hiding video shelf ([04147c1](04147c17c9))
2023-01-28 07:08:41 +00:00
oSumAtrIX
04147c17c9 feat(youtube/general-ads): remove hiding video shelf
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-28 06:00:34 +01:00
semantic-release-bot
32dc8a846c chore(release): 0.94.0-dev.3 [skip ci]
# [0.94.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.2...v0.94.0-dev.3) (2023-01-22)

### Bug Fixes

* **youtube/return-youtube-dislike:** gracefully exit if Vanced MicroG is missing or not running ([#303](https://github.com/revanced/revanced-integrations/issues/303)) ([03764bc](03764bcc65))
2023-01-22 19:23:44 +00:00
LisoUseInAIKyrios
03764bcc65 fix(youtube/return-youtube-dislike): gracefully exit if Vanced MicroG is missing or not running (#303)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-22 20:22:02 +01:00
semantic-release-bot
0127e7251c chore(release): 0.94.0-dev.2 [skip ci]
# [0.94.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.1...v0.94.0-dev.2) (2023-01-22)

### Features

* **youtube/microg-support:** check if Vanced MicroG is running in the background ([#301](https://github.com/revanced/revanced-integrations/issues/301)) ([6e31b78](6e31b7889a))
2023-01-22 16:21:15 +00:00
reis
6e31b7889a feat(youtube/microg-support): check if Vanced MicroG is running in the background (#301)
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-22 17:18:55 +01:00
semantic-release-bot
057e599aec chore(release): 0.94.0-dev.1 [skip ci]
# [0.94.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.93.2-dev.1...v0.94.0-dev.1) (2023-01-22)

### Features

* **youtube:** `open-links-externally` patch ([4cbe833](4cbe8338b3))
2023-01-22 14:51:44 +00:00
Rizwan
4cbe8338b3 feat(youtube): open-links-externally patch 2023-01-22 15:49:14 +01:00
semantic-release-bot
d65a107c53 chore(release): 0.93.2-dev.1 [skip ci]
## [0.93.2-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.93.1...v0.93.2-dev.1) (2023-01-21)

### Bug Fixes

* **youtube:** save new instead of default value ([#298](https://github.com/revanced/revanced-integrations/issues/298)) ([559bbf9](559bbf9778))
2023-01-21 22:20:12 +00:00
LisoUseInAIKyrios
559bbf9778 fix(youtube): save new instead of default value (#298) 2023-01-21 23:17:50 +01:00
semantic-release-bot
737246636b chore(release): 0.93.1 [skip ci]
## [0.93.1](https://github.com/revanced/revanced-integrations/compare/v0.93.0...v0.93.1) (2023-01-17)

### Bug Fixes

* **youtube/microg-support:** open download link if Vanced MicroG is missing ([#290](https://github.com/revanced/revanced-integrations/issues/290)) ([0af87e2](0af87e2908))
2023-01-17 23:40:49 +00:00
oSumAtrIX
c2d121f32b chore: merge branch dev to main (#291) 2023-01-18 00:38:50 +01:00
reis
0af87e2908 fix(youtube/microg-support): open download link if Vanced MicroG is missing (#290) 2023-01-16 23:42:37 +01:00
semantic-release-bot
6960b0bda5 chore(release): 0.93.0 [skip ci]
# [0.93.0](https://github.com/revanced/revanced-integrations/compare/v0.92.2...v0.93.0) (2023-01-14)

### Features

* `remove-screenshot-restriction` patch ([#285](https://github.com/revanced/revanced-integrations/issues/285)) ([c3eff91](c3eff913dd))
* **youtube/return-youtube-dislike:** better matching color for separators ([#281](https://github.com/revanced/revanced-integrations/issues/281)) ([2a16da1](2a16da15d9))
* **youtube/return-youtube-dislike:** style for minimum width ([#284](https://github.com/revanced/revanced-integrations/issues/284)) ([a80fab7](a80fab7070))
* **youtube:** `spoof-app-version` patch ([#282](https://github.com/revanced/revanced-integrations/issues/282)) ([fd818a3](fd818a35f5))
2023-01-14 02:26:52 +00:00
oSumAtrIX
5b9a0d3d23 chore: merge branch dev to main (#289) 2023-01-14 03:24:56 +01:00
oSumAtrIX
9480f20d44 ci: fix spelling mistake 2023-01-14 03:20:37 +01:00
oSumAtrIX
557c311825 chore: merge branch dev to main (#288) 2023-01-14 03:16:53 +01:00
oSumAtrIX
62eb76415c ci: fix spelling mistake 2023-01-14 03:15:59 +01:00
oSumAtrIX
5d2cc2ca5d chore: merge branch dev to main (#287) 2023-01-13 22:35:04 +01:00
oSumAtrIX
09afccce27 ci: use PAT in step Release
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-13 22:32:40 +01:00
oSumAtrIX
f393d3790a ci: only fetch latest commit when checking out
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-13 22:32:14 +01:00
oSumAtrIX
d33c69f8c2 chore: merge branch dev to main (#283) 2023-01-13 16:03:26 +01:00
oSumAtrIX
b56f472813 ci: give jobs names
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-13 14:40:44 +01:00
semantic-release-bot
803130a693 chore(release): 0.93.0-dev.1 [skip ci]
# [0.93.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.92.2...v0.93.0-dev.1) (2023-01-10)

### Features

* `remove-screenshot-restriction` patch ([#285](https://github.com/revanced/revanced-integrations/issues/285)) ([c3eff91](c3eff913dd))
* **youtube/return-youtube-dislike:** better matching color for separators ([#281](https://github.com/revanced/revanced-integrations/issues/281)) ([2a16da1](2a16da15d9))
* **youtube/return-youtube-dislike:** style for minimum width ([#284](https://github.com/revanced/revanced-integrations/issues/284)) ([a80fab7](a80fab7070))
* **youtube:** `spoof-app-version` patch ([#282](https://github.com/revanced/revanced-integrations/issues/282)) ([fd818a3](fd818a35f5))
2023-01-10 21:45:18 +00:00
oSumAtrIX
8032a3f46a ci: bypass push permission on protected branches with owner PAT
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-10 22:43:30 +01:00
oSumAtrIX
d72937c2fd ci: downgrade semantic release and plugins to v19
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-10 22:43:30 +01:00
LisoUseInAIKyrios
fd818a35f5 feat(youtube): spoof-app-version patch (#282)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-01-10 19:27:43 +01:00
LisoUseInAIKyrios
a80fab7070 feat(youtube/return-youtube-dislike): style for minimum width (#284) 2023-01-10 19:01:21 +01:00
Linus
c3eff913dd feat: remove-screenshot-restriction patch (#285)
Co-authored-by: Linus789 <Linus789@users.noreply.github.com>
2023-01-08 22:24:31 +01:00
LisoUseInAIKyrios
2a16da15d9 feat(youtube/return-youtube-dislike): better matching color for separators (#281) 2023-01-08 07:31:07 +01:00
semantic-release-bot
d076fe0dce chore(release): 0.92.2 [skip ci]
## [0.92.2](https://github.com/revanced/revanced-integrations/compare/v0.92.1...v0.92.2) (2023-01-07)

### Bug Fixes

* load numeric preferences as type String ([212d3a7](212d3a72d8))
2023-01-07 13:43:20 +00:00
oSumAtrIX
e833d16bb8 chore: merge branch dev to main (#280) 2023-01-07 14:41:14 +01:00
37 changed files with 793 additions and 480 deletions

View File

@@ -11,6 +11,7 @@ env:
jobs:
pull-request:
name: Open pull request
runs-on: ubuntu-latest
steps:
- name: Checkout

View File

@@ -12,13 +12,19 @@ on:
- dev
jobs:
build:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Cancel previou runs
uses: styfle/cancel-workflow-action@0.11.0
- name: Checkout
uses: actions/checkout@v3
with:
# Make sure the release step uses its own credentials:
# https://github.com/cycjimmy/semantic-release-action#private-packages
persist-credentials: false
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
@@ -30,8 +36,8 @@ jobs:
node-version: "latest"
cache: 'npm'
- name: Setup semantic-release
run: npm install semantic-release @saithodev/semantic-release-backmerge @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D
run: npm install semantic-release@19.0.5 @saithodev/semantic-release-backmerge @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin@1.7.4 -D
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }}
run: npx semantic-release

View File

@@ -1,3 +1,103 @@
# [0.94.0](https://github.com/revanced/revanced-integrations/compare/v0.93.1...v0.94.0) (2023-01-28)
### Bug Fixes
* **youtube/return-youtube-dislike:** do not fetch voting stats when watching shorts ([#302](https://github.com/revanced/revanced-integrations/issues/302)) ([7551f01](https://github.com/revanced/revanced-integrations/commit/7551f0104c463714749acc6abedbea5cd7afb52f))
* **youtube/return-youtube-dislike:** gracefully exit if Vanced MicroG is missing or not running ([#303](https://github.com/revanced/revanced-integrations/issues/303)) ([03764bc](https://github.com/revanced/revanced-integrations/commit/03764bcc651c6b723a999a58ed9cc9d253075905))
* **youtube:** save new instead of default value ([#298](https://github.com/revanced/revanced-integrations/issues/298)) ([559bbf9](https://github.com/revanced/revanced-integrations/commit/559bbf9778f20ac0f5ce3af677230a1ec28a55ff))
### Features
* **youtube/general-ads:** remove hiding video shelf ([04147c1](https://github.com/revanced/revanced-integrations/commit/04147c17c98bccea27e0293a71ffccc97f5a155d))
* **youtube/microg-support:** check if Vanced MicroG is running in the background ([#301](https://github.com/revanced/revanced-integrations/issues/301)) ([6e31b78](https://github.com/revanced/revanced-integrations/commit/6e31b7889a2488b3d61042111437a6ed4eec019c))
* **youtube:** `open-links-externally` patch ([4cbe833](https://github.com/revanced/revanced-integrations/commit/4cbe8338b3f4ab49139168d7a3d0c9ebebf68952))
* **youtube:** show toasts along exceptions ([#293](https://github.com/revanced/revanced-integrations/issues/293)) ([dbf1f3f](https://github.com/revanced/revanced-integrations/commit/dbf1f3f0ce0500752e5d6c4ce49d7d2b27cc6dc4))
# [0.94.0-dev.6](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.5...v0.94.0-dev.6) (2023-01-28)
### Features
* **youtube:** show toasts along exceptions ([#293](https://github.com/revanced/revanced-integrations/issues/293)) ([dbf1f3f](https://github.com/revanced/revanced-integrations/commit/dbf1f3f0ce0500752e5d6c4ce49d7d2b27cc6dc4))
# [0.94.0-dev.5](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.4...v0.94.0-dev.5) (2023-01-28)
### Bug Fixes
* **youtube/return-youtube-dislike:** do not fetch voting stats when watching shorts ([#302](https://github.com/revanced/revanced-integrations/issues/302)) ([7551f01](https://github.com/revanced/revanced-integrations/commit/7551f0104c463714749acc6abedbea5cd7afb52f))
# [0.94.0-dev.4](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.3...v0.94.0-dev.4) (2023-01-28)
### Features
* **youtube/general-ads:** remove hiding video shelf ([04147c1](https://github.com/revanced/revanced-integrations/commit/04147c17c98bccea27e0293a71ffccc97f5a155d))
# [0.94.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.2...v0.94.0-dev.3) (2023-01-22)
### Bug Fixes
* **youtube/return-youtube-dislike:** gracefully exit if Vanced MicroG is missing or not running ([#303](https://github.com/revanced/revanced-integrations/issues/303)) ([03764bc](https://github.com/revanced/revanced-integrations/commit/03764bcc651c6b723a999a58ed9cc9d253075905))
# [0.94.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.94.0-dev.1...v0.94.0-dev.2) (2023-01-22)
### Features
* **youtube/microg-support:** check if Vanced MicroG is running in the background ([#301](https://github.com/revanced/revanced-integrations/issues/301)) ([6e31b78](https://github.com/revanced/revanced-integrations/commit/6e31b7889a2488b3d61042111437a6ed4eec019c))
# [0.94.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.93.2-dev.1...v0.94.0-dev.1) (2023-01-22)
### Features
* **youtube:** `open-links-externally` patch ([4cbe833](https://github.com/revanced/revanced-integrations/commit/4cbe8338b3f4ab49139168d7a3d0c9ebebf68952))
## [0.93.2-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.93.1...v0.93.2-dev.1) (2023-01-21)
### Bug Fixes
* **youtube:** save new instead of default value ([#298](https://github.com/revanced/revanced-integrations/issues/298)) ([559bbf9](https://github.com/revanced/revanced-integrations/commit/559bbf9778f20ac0f5ce3af677230a1ec28a55ff))
## [0.93.1](https://github.com/revanced/revanced-integrations/compare/v0.93.0...v0.93.1) (2023-01-17)
### Bug Fixes
* **youtube/microg-support:** open download link if Vanced MicroG is missing ([#290](https://github.com/revanced/revanced-integrations/issues/290)) ([0af87e2](https://github.com/revanced/revanced-integrations/commit/0af87e29085fb5b55cd80ccb61f6e58f72fc5271))
# [0.93.0](https://github.com/revanced/revanced-integrations/compare/v0.92.2...v0.93.0) (2023-01-14)
### Features
* `remove-screenshot-restriction` patch ([#285](https://github.com/revanced/revanced-integrations/issues/285)) ([c3eff91](https://github.com/revanced/revanced-integrations/commit/c3eff913ddb076dc86efd0398e34d04336a655ec))
* **youtube/return-youtube-dislike:** better matching color for separators ([#281](https://github.com/revanced/revanced-integrations/issues/281)) ([2a16da1](https://github.com/revanced/revanced-integrations/commit/2a16da15d9a8d37ca65973671f0b4edff0078b47))
* **youtube/return-youtube-dislike:** style for minimum width ([#284](https://github.com/revanced/revanced-integrations/issues/284)) ([a80fab7](https://github.com/revanced/revanced-integrations/commit/a80fab7070be203aa8aaf4c8422ea8e998843e67))
* **youtube:** `spoof-app-version` patch ([#282](https://github.com/revanced/revanced-integrations/issues/282)) ([fd818a3](https://github.com/revanced/revanced-integrations/commit/fd818a35f5252fc0a37e12b528e020cdfac0ab53))
# [0.93.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.92.2...v0.93.0-dev.1) (2023-01-10)
### Features
* `remove-screenshot-restriction` patch ([#285](https://github.com/revanced/revanced-integrations/issues/285)) ([c3eff91](https://github.com/revanced/revanced-integrations/commit/c3eff913ddb076dc86efd0398e34d04336a655ec))
* **youtube/return-youtube-dislike:** better matching color for separators ([#281](https://github.com/revanced/revanced-integrations/issues/281)) ([2a16da1](https://github.com/revanced/revanced-integrations/commit/2a16da15d9a8d37ca65973671f0b4edff0078b47))
* **youtube/return-youtube-dislike:** style for minimum width ([#284](https://github.com/revanced/revanced-integrations/issues/284)) ([a80fab7](https://github.com/revanced/revanced-integrations/commit/a80fab7070be203aa8aaf4c8422ea8e998843e67))
* **youtube:** `spoof-app-version` patch ([#282](https://github.com/revanced/revanced-integrations/issues/282)) ([fd818a3](https://github.com/revanced/revanced-integrations/commit/fd818a35f5252fc0a37e12b528e020cdfac0ab53))
## [0.92.2](https://github.com/revanced/revanced-integrations/compare/v0.92.1...v0.92.2) (2023-01-07)
### Bug Fixes
* load numeric preferences as type String ([212d3a7](https://github.com/revanced/revanced-integrations/commit/212d3a72d879189c061fb77805cda81ca0519495))
## [0.92.2-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.92.1...v0.92.2-dev.1) (2023-01-07)

View File

@@ -0,0 +1,11 @@
package app.revanced.all.screenshot.removerestriction;
import android.view.Window;
import android.view.WindowManager;
public class RemoveScreenshotRestrictionPatch {
public static void setFlags(Window window, int flags, int mask) {
window.setFlags(flags & ~WindowManager.LayoutParams.FLAG_SECURE, mask & ~WindowManager.LayoutParams.FLAG_SECURE);
}
}

View File

@@ -1,7 +1,6 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
@@ -32,7 +31,6 @@ public final class GeneralAdsPatch extends Filter {
var paidContent = new BlockRule(SettingsEnum.ADREMOVER_PAID_CONTENT_REMOVAL, "paid_content_overlay");
var merchandise = new BlockRule(SettingsEnum.ADREMOVER_MERCHANDISE_REMOVAL, "product_carousel");
var infoPanel = new BlockRule(SettingsEnum.ADREMOVER_INFO_PANEL_REMOVAL, "publisher_transparency_panel", "single_item_information_panel");
var suggestions = new BlockRule(SettingsEnum.ADREMOVER_SUGGESTIONS_REMOVAL, "horizontal_video_shelf");
var latestPosts = new BlockRule(SettingsEnum.ADREMOVER_HIDE_LATEST_POSTS, "post_shelf");
var channelGuidelines = new BlockRule(SettingsEnum.ADREMOVER_HIDE_CHANNEL_GUIDELINES, "channel_guidelines_entry_banner");
var artistCard = new BlockRule(SettingsEnum.HIDE_ARTIST_CARD, "official_card");
@@ -69,7 +67,6 @@ public final class GeneralAdsPatch extends Filter {
buttonedAd,
communityPosts,
paidContent,
suggestions,
latestPosts,
movieAds,
chapterTeaser,
@@ -115,7 +112,7 @@ public final class GeneralAdsPatch extends Filter {
else
result = BlockResult.UNBLOCKED;
log(String.format("%s (ID: %s): %s", result.message, identifier, path));
LogHelper.printDebug(() -> String.format("%s (ID: %s): %s", result.message, identifier, path));
return result.filter;
}
@@ -144,7 +141,7 @@ public final class GeneralAdsPatch extends Filter {
private static void hideView(SettingsEnum condition, View view) {
if (!condition.getBoolean()) return;
log("Hiding view with setting: " + condition);
LogHelper.printDebug(() -> "Hiding view with setting: " + condition);
AdRemoverAPI.HideViewWithLayout1dp(view);
}
@@ -167,7 +164,4 @@ public final class GeneralAdsPatch extends Filter {
hideView(SettingsEnum.ADREMOVER_SHORTS_REMOVAL, view);
}
private static void log(String message) {
LogHelper.printDebug(() -> message);
}
}

View File

@@ -10,8 +10,7 @@ public class HideCreateButtonPatch {
//Used by app.revanced.patches.youtube.layout.createbutton.patch.CreateButtonRemoverPatch
public static void hideCreateButton(View view) {
boolean hidden = SettingsEnum.HIDE_CREATE_BUTTON.getBoolean();
String message = "Create button: " + (hidden ? "hidden" : "shown");
LogHelper.printDebug(() -> message);
LogHelper.printDebug(() -> "Create button: " + (hidden ? "hidden" : "shown"));
view.setVisibility(hidden ? View.GONE : View.VISIBLE);
}
}

View File

@@ -12,10 +12,9 @@ public class HideShortsButtonPatch {
public static void hideShortsButton(View view) {
if (lastPivotTab != null && lastPivotTab.name() == "TAB_SHORTS") {
boolean hide = SettingsEnum.HIDE_SHORTS_BUTTON.getBoolean();
String message = hide ? "Shorts button: hidden" : "Shorts button: shown";
LogHelper.printDebug(() -> message);
LogHelper.printDebug(() -> hide ? "Shorts button: hidden" : "Shorts button: shown");
if (hide) {
view.setVisibility(hide ? View.GONE : View.VISIBLE);
view.setVisibility(View.GONE);
}
}
}

View File

@@ -2,11 +2,14 @@ package app.revanced.integrations.patches;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.widget.Toast;
import java.util.Objects;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
@@ -14,20 +17,35 @@ public class MicroGSupport {
private static final String MICROG_VENDOR = "com.mgoogle";
private static final String MICROG_PACKAGE_NAME = "com.mgoogle.android.gms";
private static final String VANCED_MICROG_DOWNLOAD_LINK = "https://github.com/TeamVanced/VancedMicroG/releases/latest";
private static final String DONT_KILL_MY_APP_LINK = "https://dontkillmyapp.com";
private static final Uri VANCED_MICROG_PROVIDER = Uri.parse("content://com.mgoogle.android.gsf.gservices/prefix");
private static void startIntent(Context context, String uriString, String message) {
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
var intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse(uriString));
context.startActivity(intent);
}
public static void checkAvailability() {
var context = ReVancedUtils.getContext();
assert context != null;
var context = Objects.requireNonNull(ReVancedUtils.getContext());
try {
context.getPackageManager().getPackageInfo(MICROG_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
LogHelper.printDebug(() -> "MicroG is installed on the device");
} catch (PackageManager.NameNotFoundException exception) {
LogHelper.printException(() -> ("MicroG was not found"), exception);
Toast.makeText(context, str("microg_not_installed_warning"), Toast.LENGTH_LONG).show();
LogHelper.printInfo(() -> "Vanced MicroG was not found", exception);
startIntent(context, VANCED_MICROG_DOWNLOAD_LINK, str("microg_not_installed_warning"));
var intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(VANCED_MICROG_DOWNLOAD_LINK));
context.startActivity(intent);
// Gracefully exit the app, so it does not crash.
System.exit(0);
}
try (var client = context.getContentResolver().acquireContentProviderClient(VANCED_MICROG_PROVIDER)) {
if (client != null) return;
LogHelper.printInfo(() -> "Vanced MicroG is not running in the background");
startIntent(context, DONT_KILL_MY_APP_LINK, str("microg_not_running_warning"));
}
}
}

View File

@@ -0,0 +1,19 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class OpenLinksExternallyPatch {
/**
* Override 'android.support.customtabs.action.CustomTabsService',
* in order to open links in the default browser. This is done by returning an empty string,
* for the service that handles custom tabs in the Android support library
* which opens links in the default service instead.
*
* @param original The original custom tabs service.
* @return The new, default service to open links with or the original service.
*/
public static String enableExternalBrowser(String original) {
if (SettingsEnum.ENABLE_EXTERNAL_BROWSER.getBoolean()) original = "";
return original;
}
}

View File

@@ -2,8 +2,8 @@ package app.revanced.integrations.patches;
import androidx.annotation.Nullable;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.shared.PlayerType;
import app.revanced.integrations.utils.LogHelper;
/**
* Hook receiver class for 'player-type-hook' patch
@@ -24,7 +24,9 @@ public class PlayerTypeHookPatch {
// update current player type
final PlayerType newType = PlayerType.safeParseFromString(type.toString());
if (newType != null) {
if (newType == null) {
LogHelper.printException(() -> "Unknown PlayerType encountered: " + type);
} else {
PlayerType.setCurrent(newType);
LogHelper.printDebug(() -> "YouTubePlayerOverlaysLayout player type was updated to " + newType);
}

View File

@@ -0,0 +1,15 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class SpoofAppVersionPatch {
public static String getYouTubeVersionOverride(String version) {
if (SettingsEnum.SPOOF_APP_VERSION.getBoolean()){
// Override with the most recent version that does not show the new UI player layout.
// If the new UI shows up for some users, then change this to an older version (such as 17.29.34).
return "17.30.34";
}
return version;
}
}

View File

@@ -36,7 +36,7 @@ public final class VideoInformation {
seekMethod = thisRef.getClass().getMethod(SEEK_METHOD_NAME, Long.TYPE);
seekMethod.setAccessible(true);
} catch (NoSuchMethodException ex) {
LogHelper.printDebug(() -> "Failed to initialize: " + ex.getMessage());
LogHelper.printException(() -> "Failed to initialize", ex);
}
}
@@ -87,7 +87,7 @@ public final class VideoInformation {
LogHelper.printDebug(() -> "Seeking to " + millisecond);
seekMethod.invoke(playerController.get(), millisecond);
} catch (Exception ex) {
LogHelper.printDebug(() -> "Failed to seek: " + ex.getMessage());
LogHelper.printException(() -> "Failed to seek", ex);
}
});
}

View File

@@ -1,5 +1,6 @@
package app.revanced.integrations.patches.playback.quality;
import android.annotation.SuppressLint;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@@ -26,24 +27,25 @@ public class RememberVideoQualityPatch {
if (isConnectedWifi(context)) {
try {
SharedPrefHelper.saveString(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality + "");
String message = "Changing default Wi-Fi quality to: " + defaultQuality;
LogHelper.printDebug(() -> message);
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
LogHelper.printException(() -> ("Failed to change default WI-FI quality:" + ex));
Toast.makeText(context, "Failed to change default WI-FI quality:", Toast.LENGTH_SHORT).show();
LogHelper.printException(() -> "Failed to change default WI-FI quality", ex);
}
LogHelper.printDebug(() -> "Changing default Wi-Fi quality to: " + defaultQuality);
Toast.makeText(context, "Changing default Wi-Fi quality to: " + defaultQuality, Toast.LENGTH_SHORT).show();
} else if (isConnectedMobile(context)) {
try {
SharedPrefHelper.saveString(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality + "");
String message = "Changing default mobile data quality to:" + defaultQuality;
LogHelper.printDebug(() -> message);
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
LogHelper.printDebug(() -> "Failed to change default mobile data quality" + ex);
Toast.makeText(context, "Failed to change default mobile data quality", Toast.LENGTH_SHORT).show();
LogHelper.printException(() -> "Failed to change default mobile data quality", ex);
}
LogHelper.printDebug(() -> "Changing default mobile data quality to:" + defaultQuality);
Toast.makeText(context, "Changing default mobile data quality to:" + defaultQuality, Toast.LENGTH_SHORT).show();
} else {
LogHelper.printDebug(() -> "No internet connection.");
Toast.makeText(context, "No internet connection.", Toast.LENGTH_SHORT).show();
String message = "No internet connection.";
LogHelper.printDebug(() -> message);
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
userChangedQuality = false;
}
@@ -88,7 +90,7 @@ public class RememberVideoQualityPatch {
LogHelper.printDebug(() -> "Quality: " + qualityToLog);
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException(() -> ("Context is null or settings not initialized, returning quality: " + qualityToLog));
LogHelper.printException(() -> "Context is null or settings not initialized, returning quality: " + qualityToLog);
return quality;
}
if (isConnectedWifi(context)) {
@@ -129,8 +131,7 @@ public class RememberVideoQualityPatch {
LogHelper.printDebug(() -> "Quality changed to: " + qualityIndex);
return qualityIndex;
} catch (Exception ex) {
LogHelper.printException(() -> ("Failed to set quality"), ex);
Toast.makeText(context, "Failed to set quality", Toast.LENGTH_SHORT).show();
LogHelper.printException(() -> "Failed to set quality", ex);
return qualityIndex;
}
}
@@ -147,6 +148,7 @@ public class RememberVideoQualityPatch {
newVideo = true;
}
@SuppressLint("MissingPermission")
private static NetworkInfo getNetworkInfo(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo();

View File

@@ -185,11 +185,15 @@ public class ReturnYouTubeDislikeApi {
lastTimeRateLimitWasHit = System.currentTimeMillis();
LogHelper.printDebug(() -> "API rate limit was hit. Stopping API calls for the next "
+ RATE_LIMIT_BACKOFF_SECONDS + " seconds");
ReVancedUtils.runOnMainThread(() -> { // must show toasts on main thread
Toast.makeText(ReVancedUtils.getContext(), str("revanced_ryd_failure_client_rate_limit_requested"), Toast.LENGTH_LONG).show();
});
return true;
}
return false;
}
@SuppressWarnings("NonAtomicOperationOnVolatileField") // do not want to pay performance cost of full synchronization for debug fields that are only estimates anyways
private static void updateStatistics(long timeNetworkCallStarted, long timeNetworkCallEnded, boolean connectionError, boolean rateLimitHit) {
if (connectionError && rateLimitHit) {
throw new IllegalArgumentException("both connection error and rate limit parameter were true");
@@ -202,11 +206,9 @@ public class ReturnYouTubeDislikeApi {
if (connectionError) {
fetchCallResponseTimeLast = responseTimeOfFetchCall;
fetchCallNumberOfFailures++;
showToast("revanced_ryd_failure_connection_timeout");
} else if (rateLimitHit) {
fetchCallResponseTimeLast = FETCH_CALL_RESPONSE_TIME_VALUE_RATE_LIMIT;
numberOfRateLimitRequestsEncountered++;
showToast("revanced_ryd_failure_client_rate_limit_requested");
} else {
fetchCallResponseTimeLast = responseTimeOfFetchCall;
}
@@ -226,6 +228,7 @@ public class ReturnYouTubeDislikeApi {
LogHelper.printDebug(() -> "Fetching votes for: " + videoId);
final long timeNetworkCallStarted = System.currentTimeMillis();
String connectionErrorMessageStringKey = "revanced_ryd_failure_connection_timeout";
try {
HttpURLConnection connection = getRYDConnectionFromRoute(ReturnYouTubeDislikeRoutes.GET_DISLIKES, videoId);
// request headers, as per https://returnyoutubedislike.com/docs/fetching
@@ -261,12 +264,12 @@ public class ReturnYouTubeDislikeApi {
// fall thru to update statistics
}
} else {
LogHelper.printDebug(() -> "Failed to fetch votes for video: " + videoId
+ " response code was: " + responseCode);
LogHelper.printException(() -> "Failed to fetch votes for video: " + videoId
+ " response code was: " + responseCode, null, str(connectionErrorMessageStringKey));
connection.disconnect(); // something went wrong, might as well disconnect
}
} catch (Exception ex) { // connection timed out, response timeout, or some other network error
LogHelper.printException(() -> "Failed to fetch votes", ex);
LogHelper.printException(() -> "Failed to fetch votes", ex, str(connectionErrorMessageStringKey));
}
updateStatistics(timeNetworkCallStarted, System.currentTimeMillis(), true, false);
@@ -304,13 +307,12 @@ public class ReturnYouTubeDislikeApi {
String solution = solvePuzzle(challenge, difficulty);
return confirmRegistration(userId, solution);
}
LogHelper.printDebug(() -> "Failed to register new user: " + userId
LogHelper.printException(() -> "Failed to register new user: " + userId
+ " response code was: " + responseCode);
connection.disconnect();
} catch (Exception ex) {
LogHelper.printException(() -> "Failed to register user", ex);
}
showToast("revanced_ryd_failure_register_user");
return null;
}
@@ -344,10 +346,10 @@ public class ReturnYouTubeDislikeApi {
LogHelper.printDebug(() -> "Registration confirmation successful for user: " + userId);
return userId;
}
LogHelper.printDebug(() -> "Failed to confirm registration for user: " + userId
LogHelper.printException(() -> "Failed to confirm registration for user: " + userId
+ " solution: " + solution + " response string was: " + result);
} else {
LogHelper.printDebug(() -> "Failed to confirm registration for user: " + userId
LogHelper.printException(() -> "Failed to confirm registration for user: " + userId
+ " solution: " + solution + " response code was: " + responseCode);
}
connection.disconnect(); // something went wrong, might as well disconnect
@@ -355,8 +357,6 @@ public class ReturnYouTubeDislikeApi {
LogHelper.printException(() -> "Failed to confirm registration for user: " + userId
+ "solution: " + solution, ex);
}
showToast("revanced_ryd_failure_confirm_user");
return null;
}
@@ -395,14 +395,13 @@ public class ReturnYouTubeDislikeApi {
String solution = solvePuzzle(challenge, difficulty);
return confirmVote(videoId, userId, solution);
}
LogHelper.printDebug(() -> "Failed to send vote for video: " + videoId
LogHelper.printException(() -> "Failed to send vote for video: " + videoId
+ " userId: " + userId + " vote: " + vote + " response code was: " + responseCode);
connection.disconnect(); // something went wrong, might as well disconnect
} catch (Exception ex) {
LogHelper.printException(() -> "Failed to send vote for video: " + videoId
+ " user: " + userId + " vote: " + vote, ex);
}
showToast("revanced_ryd_failure_send_vote_failed");
return false;
}
@@ -438,10 +437,10 @@ public class ReturnYouTubeDislikeApi {
LogHelper.printDebug(() -> "Vote confirm successful for video: " + videoId);
return true;
}
LogHelper.printDebug(() -> "Failed to confirm vote for video: " + videoId
LogHelper.printException(() -> "Failed to confirm vote for video: " + videoId
+ " user: " + userId + " solution: " + solution + " response string was: " + result);
} else {
LogHelper.printDebug(() -> "Failed to confirm vote for video: " + videoId
LogHelper.printException(() -> "Failed to confirm vote for video: " + videoId
+ " user: " + userId + " solution: " + solution + " response code was: " + responseCode);
}
connection.disconnect(); // something went wrong, might as well disconnect
@@ -449,16 +448,9 @@ public class ReturnYouTubeDislikeApi {
LogHelper.printException(() -> "Failed to confirm vote for video: " + videoId
+ " user: " + userId + " solution: " + solution, ex);
}
showToast("revanced_ryd_failure_confirm_vote_failed");
return false;
}
private static void showToast(String toastTextStringKey) {
ReVancedUtils.runOnMainThread(() -> { // must show toasts on main thread
Toast.makeText(ReVancedUtils.getContext(), str(toastTextStringKey), Toast.LENGTH_LONG).show();
});
}
private static void applyCommonPostRequestSettings(HttpURLConnection connection) throws ProtocolException {
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
@@ -477,7 +469,7 @@ public class ReturnYouTubeDislikeApi {
byte[] decodedChallenge = Base64.decode(challenge, Base64.NO_WRAP);
byte[] buffer = new byte[20];
for (int i = 4; i < 20; i++) {
for (int i = 4; i < 20; i++) { // FIXME replace with System.arrayCopy
buffer[i] = decodedChallenge[i - 4];
}

View File

@@ -1,15 +1,13 @@
package app.revanced.integrations.settings;
import android.content.Context;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
import java.util.ArrayList;
import java.util.List;
public enum SettingsEnum {
//Download Settings
// TODO: DOWNLOAD_PATH("revanced_download_path", Environment.getExternalStorageDirectory().getPath() + "/Download", ReturnType.STRING),
@@ -48,7 +46,6 @@ public enum SettingsEnum {
ADREMOVER_INFO_PANEL_REMOVAL("revanced_adremover_info_panel", true, ReturnType.BOOLEAN),
ADREMOVER_MEDICAL_PANEL_REMOVAL("revanced_adremover_medical_panel", true, ReturnType.BOOLEAN),
ADREMOVER_PAID_CONTENT_REMOVAL("revanced_adremover_paid_content", true, ReturnType.BOOLEAN),
ADREMOVER_SUGGESTIONS_REMOVAL("revanced_adremover_hide_suggestions", true, ReturnType.BOOLEAN),
ADREMOVER_HIDE_LATEST_POSTS("revanced_adremover_hide_latest_posts", true, ReturnType.BOOLEAN),
ADREMOVER_HIDE_CHANNEL_GUIDELINES("revanced_adremover_hide_channel_guidelines", true, ReturnType.BOOLEAN),
ADREMOVER_SELF_SPONSOR_REMOVAL("revanced_adremover_self_sponsor", true, ReturnType.BOOLEAN),
@@ -68,6 +65,7 @@ public enum SettingsEnum {
DISABLE_STARTUP_SHORTS_PLAYER("revanced_startup_shorts_player_enabled", false, ReturnType.BOOLEAN),
PLAYER_POPUP_PANELS("revanced_player_popup_panels_enabled", false, ReturnType.BOOLEAN),
USE_TABLET_MINIPLAYER("revanced_tablet_miniplayer", false, ReturnType.BOOLEAN, true),
SPOOF_APP_VERSION("revanced_spoof_app_version", false, ReturnType.BOOLEAN, true),
WIDE_SEARCHBAR("revanced_wide_searchbar", false, ReturnType.BOOLEAN, true),
HIDE_ALBUM_CARDS("revanced_hide_album_cards", false, ReturnType.BOOLEAN, true),
HIDE_ARTIST_CARD("revanced_hide_artist_card", false, ReturnType.BOOLEAN),
@@ -100,6 +98,7 @@ public enum SettingsEnum {
ENABLE_MINIMIZED_PLAYBACK("revanced_enable_minimized_playback", true, ReturnType.BOOLEAN),
OPEN_LINKS_DIRECTLY("revanced_uri_redirect", true, ReturnType.BOOLEAN, true),
DISABLE_ZOOM_HAPTICS("revanced_disable_zoom_haptics", true, ReturnType.BOOLEAN, false),
ENABLE_EXTERNAL_BROWSER("revanced_enable_external_browser", true, ReturnType.BOOLEAN, true),
// Swipe controls
ENABLE_SWIPE_BRIGHTNESS("revanced_enable_swipe_brightness", true, ReturnType.BOOLEAN),
@@ -116,9 +115,10 @@ public enum SettingsEnum {
PLAYBACK_MAX_BUFFER("revanced_pref_buffer_for_playback_ms", 2500, ReturnType.INTEGER),
MAX_PLAYBACK_BUFFER_AFTER_REBUFFER("revanced_pref_buffer_for_playback_after_rebuffer_ms", 5000, ReturnType.INTEGER),
// ReVanced settings
// Debug settings
DEBUG("revanced_debug_enabled", false, ReturnType.BOOLEAN),
DEBUG_STACKTRACE("revanced_debug_stacktrace_enabled", false, ReturnType.BOOLEAN),
DEBUG_SHOW_TOAST_ON_ERROR("revanced_debug_toast_on_error_enabled", true, ReturnType.BOOLEAN),
USE_DARK_THEME("app_theme_dark", false, ReturnType.BOOLEAN),
@@ -126,6 +126,7 @@ public enum SettingsEnum {
RYD_USER_ID("ryd_userId", null, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.STRING),
RYD_ENABLED("ryd_enabled", true, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN),
RYD_SHOW_DISLIKE_PERCENTAGE("ryd_show_dislike_percentage", false, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN),
RYD_USE_COMPACT_LAYOUT("ryd_use_compact_layout", false, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN),
// SponsorBlock settings
SB_ENABLED("sb-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
@@ -223,7 +224,7 @@ public enum SettingsEnum {
//
// old/new settings where old is default off, and new has inverted value and is default on
SettingsEnum invertedSettingsToMigrate[][] = {
SettingsEnum[][] invertedSettingsToMigrate = {
{DEPRECATED_FULLSCREEN_PANELS_SHOWN, HIDE_FULLSCREEN_PANELS},
{DEPRECATED_CREATE_BUTTON_ENABLED, HIDE_CREATE_BUTTON},
{DEPRECATED_SHORTS_BUTTON_SHOWN, HIDE_SHORTS_BUTTON},
@@ -233,7 +234,7 @@ public enum SettingsEnum {
{DEPRECATED_BRANDING_SHOWN, HIDE_VIDEO_WATERMARK},
{DEPRECATED_REMEMBER_VIDEO_QUALITY, REMEMBER_VIDEO_QUALITY_LAST_SELECTED},
};
for (SettingsEnum oldNewSetting[] : invertedSettingsToMigrate) {
for (SettingsEnum[] oldNewSetting : invertedSettingsToMigrate) {
// by default, old setting was default off
// migrate to new setting of default on
SettingsEnum oldSetting = oldNewSetting[0];
@@ -252,7 +253,7 @@ public enum SettingsEnum {
//
// migrate preference of prior 'default off' settings, into replacement setting with different path name but otherwise is identical
//
SettingsEnum renamedSettings[][] = {
SettingsEnum[][] renamedSettings = {
{DEPRECATED_HIDE_MIX_PLAYLISTS, HIDE_MIX_PLAYLISTS},
{DEPRECATED_HIDE_LIKE_BUTTON, HIDE_LIKE_BUTTON},
{DEPRECATED_HIDE_DISLIKE_BUTTON, HIDE_DISLIKE_BUTTON},
@@ -261,7 +262,7 @@ public enum SettingsEnum {
{DEPRECATED_HIDE_ACTION_BUTTON, HIDE_ACTION_BUTTON},
{DEPRECATED_HIDE_SHARE_BUTTON, HIDE_SHARE_BUTTON},
};
for (SettingsEnum oldNewSetting[] : renamedSettings) {
for (SettingsEnum[] oldNewSetting : renamedSettings) {
SettingsEnum oldSetting = oldNewSetting[0];
SettingsEnum newSetting = oldNewSetting[1];
@@ -303,7 +304,7 @@ public enum SettingsEnum {
defaultValue = SharedPrefHelper.getString(setting.sharedPref, path, (String) defaultValue);
break;
default:
LogHelper.printException(() -> ("Setting does not have a valid Type. Name is: " + setting.name()));
LogHelper.printException(() -> "Setting does not have a valid Type. Name is: " + setting.name());
break;
}
setting.setValue(defaultValue);
@@ -336,28 +337,28 @@ public enum SettingsEnum {
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException(() -> ("Context on SaveValue is null!"));
LogHelper.printException(() -> "Context on SaveValue is null!");
return;
}
switch (getReturnType()) {
case FLOAT:
SharedPrefHelper.saveFloat(sharedPref, path, (float) defaultValue);
SharedPrefHelper.saveFloat(sharedPref, path, (float) newValue);
break;
case LONG:
SharedPrefHelper.saveLong(sharedPref, path, (long) defaultValue);
SharedPrefHelper.saveLong(sharedPref, path, (long) newValue);
break;
case BOOLEAN:
SharedPrefHelper.saveBoolean(sharedPref, path, (boolean) newValue);
break;
case INTEGER:
SharedPrefHelper.saveInt(sharedPref, path, (int) defaultValue);
SharedPrefHelper.saveInt(sharedPref, path, (int) newValue);
break;
case STRING:
SharedPrefHelper.saveString(sharedPref, path, (String) defaultValue);
SharedPrefHelper.saveString(sharedPref, path, (String) newValue);
break;
default:
LogHelper.printException(() -> ("Setting does not have a valid Type. Name is: " + name()));
LogHelper.printException(() -> "Setting does not have a valid Type. Name is: " + name());
break;
}

View File

@@ -7,6 +7,8 @@ import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.google.android.libraries.social.licenses.LicenseActivity;
import app.revanced.integrations.utils.LogHelper;
@@ -44,15 +46,23 @@ public class ReVancedSettingActivity {
}
try {
getTextView((ViewGroup) base.findViewById(getIdentifier("toolbar", "id"))).setText(preferenceIdentifier);
TextView toolbar = getTextView((ViewGroup) base.findViewById(getIdentifier("toolbar", "id")));
if (toolbar == null) {
// FIXME
// https://github.com/revanced/revanced-patches/issues/1384
LogHelper.printDebug(() -> "Could not find toolbar");
} else {
toolbar.setText(preferenceIdentifier);
}
} catch (Exception e) {
LogHelper.printException(() -> ("Couldn't set Toolbar title"), e);
LogHelper.printException(() -> "Could not set Toolbar title", e);
}
base.getFragmentManager().beginTransaction().replace(getIdentifier("revanced_settings_fragments", "id"), preferenceFragment).commit();
}
@Nullable
public static <T extends View> T getView(Class<T> typeClass, ViewGroup viewGroup) {
if (viewGroup == null) {
return null;
@@ -67,10 +77,12 @@ public class ReVancedSettingActivity {
return null;
}
@Nullable
public static ImageButton getImageButton(ViewGroup viewGroup) {
return getView(ImageButton.class, viewGroup);
}
@Nullable
public static TextView getTextView(ViewGroup viewGroup) {
return getView(TextView.class, viewGroup);
}

View File

@@ -66,12 +66,12 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
value = Integer.parseInt(editPref.getText());
break;
default:
LogHelper.printException(() -> ("Setting has no valid return type! " + setting.getReturnType()));
LogHelper.printException(() -> "Setting has no valid return type! " + setting.getReturnType());
break;
}
setting.setValue(value);
} else {
LogHelper.printException(() -> ("Setting cannot be handled! " + pref.toString()));
LogHelper.printException(() -> "Setting cannot be handled: " + pref.getClass() + " " + pref.toString());
}
if (ReVancedUtils.getContext() != null && settingsInitialized && setting.shouldRebootOnChange()) {
@@ -96,7 +96,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
this.settingsInitialized = true;
} catch (Throwable th) {
LogHelper.printException(() -> ("Error during onCreate()"), th);
LogHelper.printException(() -> "Error during onCreate()", th);
}
}
@@ -111,7 +111,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
private Preference findPreferenceOnScreen(CharSequence key) {
if (key == null) {
LogHelper.printException(() -> ("Key cannot be null!"));
LogHelper.printException(() -> "Key cannot be null!");
return null;
}
Preference pref = null;
@@ -144,7 +144,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
private String getPackageName() {
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException(() -> ("Context is null, returning com.google.android.youtube!"));
LogHelper.printException(() -> "Context is null, returning com.google.android.youtube!");
return "com.google.android.youtube";
}
String PACKAGE_NAME = context.getPackageName();
@@ -169,7 +169,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
Resources res = context.getResources();
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
} catch (Throwable exception) {
LogHelper.printException(() -> ("Resource not found."), exception);
LogHelper.printException(() -> "Resource not found.", exception);
return "";
}
}

View File

@@ -29,18 +29,27 @@ public class ReturnYouTubeDislikeSettingsFragment extends PreferenceFragment {
*/
private SwitchPreference percentagePreference;
/**
* If segmented like/dislike button uses smaller compact layout
*/
private SwitchPreference compactLayoutPreference;
private void updateUIState() {
final boolean rydIsEnabled = SettingsEnum.RYD_ENABLED.getBoolean();
final boolean dislikePercentageEnabled = SettingsEnum.RYD_SHOW_DISLIKE_PERCENTAGE.getBoolean();
enabledPreference.setSummary(rydIsEnabled
? str("revanced_ryd_enable_summary_on")
: str("revanced_ryd_enable_summary_off"));
percentagePreference.setSummary(dislikePercentageEnabled
percentagePreference.setSummary(SettingsEnum.RYD_SHOW_DISLIKE_PERCENTAGE.getBoolean()
? str("revanced_ryd_dislike_percentage_summary_on")
: str("revanced_ryd_dislike_percentage_summary_off"));
percentagePreference.setEnabled(rydIsEnabled);
compactLayoutPreference.setSummary(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean()
? str("revanced_ryd_compact_layout_summary_on")
: str("revanced_ryd_compact_layout_summary_off"));
compactLayoutPreference.setEnabled(rydIsEnabled);
}
@Override
@@ -80,6 +89,19 @@ public class ReturnYouTubeDislikeSettingsFragment extends PreferenceFragment {
});
preferenceScreen.addPreference(percentagePreference);
compactLayoutPreference = new SwitchPreference(context);
compactLayoutPreference.setKey(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getPath());
compactLayoutPreference.setDefaultValue(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getDefaultValue());
compactLayoutPreference.setChecked(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean());
compactLayoutPreference.setTitle(str("revanced_ryd_compact_layout_title"));
compactLayoutPreference.setOnPreferenceChangeListener((pref, newValue) -> {
SettingsEnum.RYD_USE_COMPACT_LAYOUT.saveValue((Boolean)newValue);
updateUIState();
return true;
});
preferenceScreen.addPreference(compactLayoutPreference);
updateUIState();

View File

@@ -7,7 +7,7 @@ import app.revanced.integrations.utils.Event
*/
@Suppress("unused")
enum class PlayerType {
NONE,
NONE, // this also includes when shorts are playing
HIDDEN,
WATCH_WHILE_MINIMIZED,
WATCH_WHILE_MAXIMIZED,

View File

@@ -52,7 +52,7 @@ public class ShieldButton {
isShowing = true;
changeVisibilityImmediate(false);
} catch (Exception ex) {
LogHelper.printException(() -> ("Unable to set RelativeLayout"), ex);
LogHelper.printException(() -> "Unable to set RelativeLayout", ex);
}
}
@@ -69,29 +69,33 @@ public class ShieldButton {
}
public static void changeVisibility(boolean visible, boolean immediate) {
if (isShowing == visible) return;
isShowing = visible;
try {
if (isShowing == visible) return;
isShowing = visible;
ImageView iView = _shieldBtn.get();
if (_youtubeControlsLayout == null || iView == null) return;
ImageView iView = _shieldBtn.get();
if (_youtubeControlsLayout == null || iView == null) return;
if (visible && shouldBeShown()) {
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
if (visible && shouldBeShown()) {
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
return;
}
LogHelper.printDebug(() -> "Fading in");
iView.setVisibility(View.VISIBLE);
if (!immediate)
iView.startAnimation(fadeIn);
return;
}
LogHelper.printDebug(() -> "Fading in");
iView.setVisibility(View.VISIBLE);
if (!immediate)
iView.startAnimation(fadeIn);
return;
}
if (iView.getVisibility() == View.VISIBLE) {
LogHelper.printDebug(() -> "Fading out");
if (!immediate)
iView.startAnimation(fadeOut);
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
if (iView.getVisibility() == View.VISIBLE) {
LogHelper.printDebug(() -> "Fading out");
if (!immediate)
iView.startAnimation(fadeOut);
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
}
} catch (Exception ex) {
LogHelper.printException(() -> "changeVisibility failure", ex);
}
}

View File

@@ -13,7 +13,7 @@ import app.revanced.integrations.utils.ReVancedUtils;
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.hideSkipButton;
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.showSkipButton;
@SuppressLint({"RtlHardcoded", "SetTextI18n", "LongLogTag", "AppCompatCustomView"})
@SuppressLint({"RtlHardcoded", "SetTextI18n", "AppCompatCustomView"})
public class SkipSegmentView {
private static SponsorSegment lastNotifiedSegment;

View File

@@ -51,7 +51,6 @@ import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
import app.revanced.integrations.sponsorblock.objects.UserStats;
import app.revanced.integrations.sponsorblock.requests.SBRequester;
@SuppressWarnings({"LongLogTag"})
public abstract class SponsorBlockUtils {
public static final String DATE_FORMAT = "HH:mm:ss.SSS";
@SuppressLint("SimpleDateFormat")
@@ -154,7 +153,7 @@ public abstract class SponsorBlockUtils {
Toast.makeText(context, str("submit_started"), Toast.LENGTH_SHORT).show();
appContext = new WeakReference<>(context);
new Thread(submitRunnable).start();
new Thread(submitRunnable).start(); // fixme: use ReVancedUtils#runOnBackgroundThread
}
};
public static String messageToToast = "";
@@ -233,13 +232,13 @@ public abstract class SponsorBlockUtils {
final SponsorBlockSettings.SegmentInfo segmentType = SponsorBlockUtils.newSponsorBlockSegmentType;
try {
if (start < 0 || end < 0 || start >= end || segmentType == null || videoId == null || uuid == null) {
LogHelper.printException(() -> ("Unable to submit times, invalid parameters"));
LogHelper.printException(() -> "Unable to submit times, invalid parameters");
return;
}
SBRequester.submitSegments(videoId, uuid, ((float) start) / 1000f, ((float) end) / 1000f, segmentType.key, toastRunnable);
newSponsorSegmentEndMillis = newSponsorSegmentStartMillis = -1;
} catch (Exception e) {
LogHelper.printException(() -> ("Unable to submit segment"), e);
LogHelper.printException(() -> "Unable to submit segment", e);
}
if (videoId != null)
@@ -403,11 +402,15 @@ public abstract class SponsorBlockUtils {
}
public static String appendTimeWithoutSegments(String totalTime) {
if (videoHasSegments && (SettingsEnum.SB_ENABLED.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean()) && !TextUtils.isEmpty(totalTime) && getCurrentVideoLength() > 1) {
if (timeWithoutSegments.isEmpty()) {
timeWithoutSegments = getTimeWithoutSegments(sponsorSegmentsOfCurrentVideo);
try {
if (videoHasSegments && (SettingsEnum.SB_ENABLED.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean()) && !TextUtils.isEmpty(totalTime) && getCurrentVideoLength() > 1) {
if (timeWithoutSegments.isEmpty()) {
timeWithoutSegments = getTimeWithoutSegments(sponsorSegmentsOfCurrentVideo);
}
return totalTime + timeWithoutSegments;
}
return totalTime + timeWithoutSegments;
} catch (Exception ex) {
LogHelper.printException(() -> "appendTimeWithoutSegments failure", ex);
}
return totalTime;
@@ -436,7 +439,7 @@ public abstract class SponsorBlockUtils {
PlayerController.setCurrentVideoId(null);
}
} catch (Exception ex) {
LogHelper.printException(() -> ("Player type changed caused a crash."), ex);
LogHelper.printException(() -> "Player type changed caused a crash.", ex);
}
}
@@ -558,8 +561,8 @@ public abstract class SponsorBlockUtils {
Toast.makeText(context, str("settings_import_successful"), Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
LogHelper.printInfo(() -> "failed to import settings", ex); // use info level, as we are showing our own toast
Toast.makeText(context, str("settings_import_failed"), Toast.LENGTH_SHORT).show();
ex.printStackTrace();
}
}
@@ -598,8 +601,8 @@ public abstract class SponsorBlockUtils {
return json.toString();
} catch (Exception ex) {
LogHelper.printInfo(() -> "failed to export settings", ex); // use info level, as we are showing our own toast
Toast.makeText(context, str("settings_export_failed"), Toast.LENGTH_SHORT).show();
ex.printStackTrace();
return "";
}
}

View File

@@ -103,11 +103,11 @@ public class StringRef {
if (resources != null) {
final int identifier = resources.getIdentifier(value, "string", packageName);
if (identifier == 0)
LogHelper.printException(() -> ("Resource not found: " + value));
LogHelper.printException(() -> "Resource not found: " + value);
else
value = resources.getString(identifier);
} else {
LogHelper.printException(() -> ("Could not resolve resources!"));
LogHelper.printException(() -> "Could not resolve resources!");
}
}
return value;

View File

@@ -25,7 +25,7 @@ public class SwipeHelper {
isTabletMode = true;
}
} catch (Exception e) {
LogHelper.printException(() -> ("Unable to set FrameLayout"), e);
LogHelper.printException(() -> "Unable to set FrameLayout", e);
}
}
@@ -33,7 +33,7 @@ public class SwipeHelper {
try {
nextGenWatchLayout = (ViewGroup) obj;
} catch (Exception e) {
LogHelper.printException(() -> ("Unable to set _nextGenWatchLayout"), e);
LogHelper.printException(() -> "Unable to set _nextGenWatchLayout", e);
}
}
@@ -44,7 +44,7 @@ public class SwipeHelper {
}
try {
} catch (Exception e) {
LogHelper.printException(() -> ("Unable to get related_endscreen_results visibility"), e);
LogHelper.printException(() -> "Unable to get related_endscreen_results visibility", e);
}
if (_frameLayout.getChildCount() > 0) {
return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
@@ -61,7 +61,7 @@ public class SwipeHelper {
LogHelper.printDebug(() -> "related_endscreen_results refreshed");
}
} catch (Exception e) {
LogHelper.printException(() -> ("Unable to refresh related_endscreen_results layout"), e);
LogHelper.printException(() -> "Unable to refresh related_endscreen_results layout", e);
}
}

View File

@@ -51,7 +51,7 @@ public class VotingButton {
isShowing = true;
changeVisibilityImmediate(false);
} catch (Exception ex) {
LogHelper.printException(() -> ("Unable to set RelativeLayout"), ex);
LogHelper.printException(() -> "Unable to set RelativeLayout", ex);
}
}
@@ -68,28 +68,32 @@ public class VotingButton {
}
public static void changeVisibility(boolean visible, boolean immediate) {
if (isShowing == visible) return;
isShowing = visible;
try {
if (isShowing == visible) return;
isShowing = visible;
ImageView iView = _votingButton.get();
if (_youtubeControlsLayout == null || iView == null) return;
ImageView iView = _votingButton.get();
if (_youtubeControlsLayout == null || iView == null) return;
if (visible && shouldBeShown()) {
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
if (visible && shouldBeShown()) {
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
return;
}
LogHelper.printDebug(() -> "Fading in");
iView.setVisibility(View.VISIBLE);
if (!immediate)
iView.startAnimation(fadeIn);
return;
}
LogHelper.printDebug(() -> "Fading in");
iView.setVisibility(View.VISIBLE);
if (!immediate)
iView.startAnimation(fadeIn);
return;
}
if (iView.getVisibility() == View.VISIBLE) {
LogHelper.printDebug(() -> "Fading out");
if (!immediate)
iView.startAnimation(fadeOut);
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
if (iView.getVisibility() == View.VISIBLE) {
LogHelper.printDebug(() -> "Fading out");
if (!immediate)
iView.startAnimation(fadeOut);
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
}
} catch (Exception ex) {
LogHelper.printException(() -> "changeVisibility failure", ex);
}
}

View File

@@ -48,7 +48,7 @@ public abstract class SlimButton implements View.OnClickListener {
}
setContainerVisibility();
} catch (Exception ex) {
LogHelper.printException(() -> ("Error while changing button visibility"), ex);
LogHelper.printException(() -> "Error while changing button visibility", ex);
}
}

View File

@@ -29,7 +29,7 @@ public class SponsorBlockView {
addView();
} catch (Exception ex) {
LogHelper.printException(() -> ("Unable to set ViewGroup"), ex);
LogHelper.printException(() -> "Unable to set ViewGroup", ex);
}
}
@@ -62,7 +62,7 @@ public class SponsorBlockView {
setSkipBtnMargins(false);
setNewSegmentLayoutMargins(false);
} catch (Exception ex) {
LogHelper.printException(() -> ("Player type changed caused a crash."), ex);
LogHelper.printException(() -> "Player type changed caused a crash.", ex);
}
}
@@ -87,13 +87,13 @@ public class SponsorBlockView {
private static void setSkipBtnMargins(boolean fullScreen) {
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
if (skipSponsorButton == null) {
LogHelper.printException(() -> ("Unable to setSkipBtnMargins"));
LogHelper.printException(() -> "Unable to setSkipBtnMargins");
return;
}
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) skipSponsorButton.getLayoutParams();
if (params == null) {
LogHelper.printException(() -> ("Unable to setSkipBtnMargins"));
LogHelper.printException(() -> "Unable to setSkipBtnMargins");
return;
}
params.bottomMargin = fullScreen ? skipSponsorButton.ctaBottomMargin : skipSponsorButton.defaultBottomMargin;
@@ -103,7 +103,7 @@ public class SponsorBlockView {
private static void skipSponsorButtonVisibility(boolean visible) {
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
if (skipSponsorButton == null) {
LogHelper.printException(() -> ("Unable to skipSponsorButtonVisibility"));
LogHelper.printException(() -> "Unable to skipSponsorButtonVisibility");
return;
}
@@ -116,13 +116,13 @@ public class SponsorBlockView {
private static void setNewSegmentLayoutMargins(boolean fullScreen) {
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
if (newSegmentLayout == null) {
LogHelper.printException(() -> ("Unable to setNewSegmentLayoutMargins"));
LogHelper.printException(() -> "Unable to setNewSegmentLayoutMargins");
return;
}
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) newSegmentLayout.getLayoutParams();
if (params == null) {
LogHelper.printException(() -> ("Unable to setNewSegmentLayoutMargins"));
LogHelper.printException(() -> "Unable to setNewSegmentLayoutMargins");
return;
}
params.bottomMargin = fullScreen ? newSegmentLayout.ctaBottomMargin : newSegmentLayout.defaultBottomMargin;
@@ -132,7 +132,7 @@ public class SponsorBlockView {
private static void newSegmentLayoutVisibility(boolean visible) {
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
if (newSegmentLayout == null) {
LogHelper.printException(() -> ("Unable to newSegmentLayoutVisibility"));
LogHelper.printException(() -> "Unable to newSegmentLayoutVisibility");
return;
}

View File

@@ -31,6 +31,7 @@ import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils.VoteOption;
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
import app.revanced.integrations.sponsorblock.objects.UserStats;
import app.revanced.integrations.utils.LogHelper;
public class SBRequester {
private static final String TIME_TEMPLATE = "%.3f";
@@ -79,7 +80,7 @@ public class SBRequester {
}
connection.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
LogHelper.printException(() -> "failed to get segments", ex);
}
return segments.toArray(new SponsorSegment[0]);
}
@@ -115,7 +116,7 @@ public class SBRequester {
runOnMainThread(toastRunnable);
connection.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
LogHelper.printException(() -> "failed to submit segments", ex);
}
}
@@ -124,12 +125,12 @@ public class SBRequester {
HttpURLConnection connection = getConnectionFromRoute(SBRoutes.VIEWED_SEGMENT, segment.UUID);
connection.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
LogHelper.printException(() -> "failed to send view count request", ex);
}
}
public static void voteForSegment(SponsorSegment segment, VoteOption voteOption, Context context, String... args) {
new Thread(() -> {
new Thread(() -> { // fixme: use ReVancedUtils#runOnBackgroundThread
try {
String segmentUuid = segment.UUID;
String uuid = SettingsEnum.SB_UUID.getString();
@@ -156,7 +157,7 @@ public class SBRequester {
runOnMainThread(() -> Toast.makeText(context, SponsorBlockUtils.messageToToast, Toast.LENGTH_LONG).show());
connection.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
LogHelper.printException(() -> "failed to vote for segment", ex);
}
}).start();
}
@@ -167,20 +168,20 @@ public class SBRequester {
return;
}
new Thread(() -> {
new Thread(() -> { // fixme: use ReVancedUtils#runOnBackgroundThread
try {
JSONObject json = getJSONObject(SBRoutes.GET_USER_STATS, SettingsEnum.SB_UUID.getString());
UserStats stats = new UserStats(json.getString("userName"), json.getDouble("minutesSaved"), json.getInt("segmentCount"),
json.getInt("viewCount"));
SponsorBlockUtils.addUserStats(category, loadingPreference, stats);
} catch (Exception ex) {
ex.printStackTrace();
LogHelper.printException(() -> "failed to retrieve user stats", ex);
}
}).start();
}
public static void setUsername(String username, EditTextPreference preference, Runnable toastRunnable) {
new Thread(() -> {
new Thread(() -> { // fixme: use ReVancedUtils#runOnBackgroundThread
try {
HttpURLConnection connection = getConnectionFromRoute(SBRoutes.CHANGE_USERNAME, SettingsEnum.SB_UUID.getString(), username);
int responseCode = connection.getResponseCode();
@@ -197,7 +198,7 @@ public class SBRequester {
runOnMainThread(toastRunnable);
connection.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
LogHelper.printException(() -> "failed to set username", ex);
}
}).start();
}
@@ -213,7 +214,7 @@ public class SBRequester {
SettingsEnum.SB_IS_VIP.saveValue(vip);
SettingsEnum.SB_LAST_VIP_CHECK.saveValue(now);
} catch (Exception ex) {
ex.printStackTrace();
LogHelper.printException(() -> "failed to check VIP", ex);
}
}

View File

@@ -4,7 +4,7 @@ import android.content.Context
import android.media.AudioManager
import android.os.Build
import app.revanced.integrations.swipecontrols.misc.clamp
import app.revanced.integrations.utils.LogHelper.printDebug
import app.revanced.integrations.utils.LogHelper.printException
import kotlin.properties.Delegates
/**
@@ -29,7 +29,7 @@ class AudioVolumeController(
// bind audio service
val mgr = context.getSystemService(Context.AUDIO_SERVICE) as? AudioManager
if (mgr == null) {
printDebug { "failed to acquire AUDIO_SERVICE" }
printException { "failed to acquire AUDIO_SERVICE" }
} else {
audioManager = mgr
maximumVolumeIndex = audioManager.getStreamMaxVolume(targetStream)

View File

@@ -1,6 +1,11 @@
package app.revanced.integrations.utils;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -13,16 +18,19 @@ public class LogHelper {
* Log messages using lambdas.
*/
public interface LogMessage {
@NonNull
String buildMessageString();
/**
* @return For non inner classes, this returns {@link Class#getSimpleName()}.
* For inner classes (static and anonymous), this returns the enclosing class simple name.<br>
* @return For outer classes, this returns {@link Class#getSimpleName()}.
* For inner, static, or anonymous classes, this returns the simple name of the enclosing class.<br>
* <br>
* For example, each of these classes return 'SomethingView':<br>
* com.company.SomethingView<br>
* com.company.SomethingView$StaticClass<br>
* com.company.SomethingView$1<br>
* For example, each of these classes return 'SomethingView':
* <code>
* com.company.SomethingView
* com.company.SomethingView$StaticClass
* com.company.SomethingView$1
* </code>
*/
private String findOuterClassSimpleName() {
var selfClass = this.getClass();
@@ -32,8 +40,8 @@ public class LogHelper {
if (dollarSignIndex == -1) {
return selfClass.getSimpleName(); // already an outer class
}
// else, class is inner class (static or anonymous)
// class is inner, static, or anonymous
// parse the simple name full name
// a class with no package returns index of -1, but incrementing gives index zero which is correct
final int simpleClassNameStartIndex = fullClassName.lastIndexOf('.') + 1;
@@ -41,17 +49,14 @@ public class LogHelper {
}
}
/**
* Logs information messages with the most outer class name of the code that is calling this method.
*/
public static void printInfo(LogMessage message) {
Log.i("revanced: " + message.findOuterClassSimpleName(), message.buildMessageString());
}
private static final String REVANCED_LOG_PREFIX = "revanced: ";
/**
* Logs debug messages with the most outer class name of the code that is calling this method.
* Logs debug messages under the outer class name of the code calling this method.
* Whenever possible, the log string should be constructed entirely inside {@link LogMessage#buildMessageString()}
* so the performance cost of building strings is paid only if {@link SettingsEnum#DEBUG} is enabled.
*/
public static void printDebug(LogMessage message) {
public static void printDebug(@NonNull LogMessage message) {
if (SettingsEnum.DEBUG.getBoolean()) {
var messageString = message.buildMessageString();
@@ -60,62 +65,79 @@ public class LogHelper {
var sw = new StringWriter();
new Throwable().printStackTrace(new PrintWriter(sw));
builder.append(String.format("\n%s", sw));
builder.append('\n').append(sw);
messageString = builder.toString();
}
Log.d("revanced: " + message.findOuterClassSimpleName(), messageString);
Log.d(REVANCED_LOG_PREFIX + message.findOuterClassSimpleName(), messageString);
}
}
/**
* Logs messages with the most outer class name of the code that is calling this method.
* Logs information messages using the outer class name of the code calling this method.
*/
public static void printException(LogMessage message) {
Log.e("revanced: " + message.findOuterClassSimpleName(), message.buildMessageString());
public static void printInfo(@NonNull LogMessage message) {
printInfo(message, null);
}
/**
* Logs exceptions with the most outer class name of the code that is calling this method.
* Logs information messages using the outer class name of the code calling this method.
*/
public static void printException(LogMessage message, Throwable ex) {
Log.e("revanced: " + message.findOuterClassSimpleName(), message.buildMessageString(), ex);
public static void printInfo(@NonNull LogMessage message, @Nullable Exception ex) {
String logTag = REVANCED_LOG_PREFIX + message.findOuterClassSimpleName();
String logMessage = message.buildMessageString();
if (ex == null) {
Log.i(logTag, logMessage);
} else {
Log.i(logTag, logMessage, ex);
}
}
/**
* Deprecated. Instead call {@link #printDebug(LogMessage)},
* which does not cause log messages to be constructed unless logging is enabled.
* Logs exceptions under the outer class name of the code calling this method.
*/
@Deprecated
public static void debug(Class _clazz, String message) {
printDebug(() -> message); // this fails to show the correct calling class name, but it's deprecated who cares
public static void printException(@NonNull LogMessage message) {
printException(message, null, null);
}
/**
* Deprecated. Instead call {@link #printException(LogMessage, Throwable)}
* or {@link #printException(LogMessage)}
* which does not cause log messages to be constructed unless logging is enabled.
* Logs exceptions under the outer class name of the code calling this method.
*/
@Deprecated
public static void printException(Class _clazz, String message, Throwable ex) {
printException(() -> message, ex);
public static void printException(@NonNull LogMessage message, @Nullable Throwable ex) {
printException(message, ex, null);
}
/**
* Deprecated. Instead call {@link #printException(LogMessage)},
* which does not cause log messages to be constructed unless logging is enabled.
* Logs exceptions under the outer class name of the code calling this method.
* <p>
* If the calling code is showing it's own error toast,
* instead use {@link #printInfo(LogMessage, Exception)}
*
* @param message log message
* @param ex exception (optional)
* @param userToastMessage user specific toast message to show instead of the log message (optional)
*/
@Deprecated
public static void printException(Class _clazz, String message) {
printException(() -> message);
public static void printException(@NonNull LogMessage message, @Nullable Throwable ex,
@Nullable String userToastMessage) {
String messageString = message.buildMessageString();
String outerClassSimpleName = message.findOuterClassSimpleName();
String logMessage = REVANCED_LOG_PREFIX + outerClassSimpleName;
if (ex == null) {
Log.e(logMessage, messageString);
} else {
Log.e(logMessage, messageString, ex);
}
if (SettingsEnum.DEBUG_SHOW_TOAST_ON_ERROR.getBoolean()) {
String toastMessageToDisplay = (userToastMessage != null)
? userToastMessage
: outerClassSimpleName + ": " + messageString;
ReVancedUtils.runOnMainThread(() -> {
Context context = ReVancedUtils.getContext();
if (context != null) {
Toast.makeText(context, toastMessageToDisplay, Toast.LENGTH_LONG).show();
}
});
}
}
/**
* Deprecated. Instead call {@link #printInfo(LogMessage)},
* which does not cause log messages to be constructed unless logging is enabled.
*/
@Deprecated
public static void info(Class _clazz, String message) {
printInfo(() -> message);
}
}

Some files were not shown because too many files have changed in this diff Show More