0
0
Fork 0
mirror of https://github.com/YTVanced/Integrations synced 2024-11-23 11:45:12 +00:00
* General improvements

- Fixed preferences not obtained properly.
- Cleaned up libraries and code.
- Update deps.

* Update README.md
This commit is contained in:
Oizaro 2021-06-08 18:25:01 +02:00 committed by GitHub
parent 740b33e6aa
commit f329ac46e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 31 additions and 60 deletions

View file

@ -1,8 +1,10 @@
# SponsorBlock YouTube Vanced Implementation
In order to use this in YouTube/Vanced you must first apply the smali mods applied to vanced (the patching process used for this is currently automated using our closed source tools with no plans to open source it for the time being) (if you mod vanced directly it is not required)
* First make your edits in android studio and then compile the code to a debug apk
* First make your edits in android studio
* Change the string "replaceMeWithsetMillisecondMethod" on PlayerController.java to the method name of YouTube package
* Compile debug apk
* Decompile this apk using apktool https://github.com/iBotPeaches/Apktool
* Take this decompiled folder and look for a folder labeled pl in one of your dex class folders (usually the second one)
* Take this decompiled folder and look for a folder labeled pl in one of your dex class folders
* Decompile YouTube/Vanced using apktool (you only need to decompile the base apk files (for vanced you can get these using vanced manager and looking in android/data/com.vanced.manager for black or dark.apk), if you are decompiling stock youtube you must also merge a dpi split into it (todo))
* Copy the pl folder from earlier into the 4th dex class folder (remove any existing one completely first)
* Copy the pl folder from earlier into the dex class folder (remove any existing one completely first)
* Recompile your modded YouTube/Vanced using apktool and sign it + all splits required for your device using the same key

View file

@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.1"
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "pl.jakubweg"
@ -10,8 +10,7 @@ android {
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled false
}
buildTypes {
@ -20,13 +19,13 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.annotation:annotation:1.2.0'
}

View file

@ -1,12 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="pl.jakubweg">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
tools:ignore="AllowBackup" />
</manifest>

View file

@ -92,7 +92,6 @@ public class InjectedPlugin {
Log.i(TAG, spacesStr + "Normal view: " + view);
}
}
}

View file

@ -2,6 +2,7 @@ package pl.jakubweg;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Handler;
@ -10,6 +11,8 @@ import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@ -59,6 +62,13 @@ public class PlayerController {
VideoInformation.currentVideoId = videoId;
Context context = YouTubeTikTokRoot_Application.getAppContext();
if(context == null){
Log.e(TAG, "context is null");
return;
}
SponsorBlockSettings.update(context);
if (!SponsorBlockSettings.isSponsorBlockEnabled) {
currentVideoId = null;
return;

View file

@ -34,7 +34,6 @@ public class ShieldButton {
}
_youtubeControlsLayout = (RelativeLayout) viewStub;
initButtonVisibilitySettings();
ImageView imageView = (ImageView)_youtubeControlsLayout
.findViewById(getIdentifier("sponsorblock_button", "id"));
@ -107,20 +106,6 @@ public class ShieldButton {
return SponsorBlockSettings.isSponsorBlockEnabled && SponsorBlockSettings.isAddNewSegmentEnabled;
}
private static void initButtonVisibilitySettings() {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if(context == null){
Log.e(TAG, "context is null");
SponsorBlockSettings.isSponsorBlockEnabled = false;
SponsorBlockSettings.isAddNewSegmentEnabled = false;
return;
}
SharedPreferences sharedPreferences = context.getSharedPreferences(SponsorBlockSettings.PREFERENCES_NAME, Context.MODE_PRIVATE);
SponsorBlockSettings.isSponsorBlockEnabled = sharedPreferences.getBoolean(SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
SponsorBlockSettings.isAddNewSegmentEnabled = sharedPreferences.getBoolean(SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED, false);
}
//region Helpers
private static int getIdentifier(String name, String defType) {
Context context = YouTubeTikTokRoot_Application.getAppContext();

View file

@ -36,7 +36,6 @@ import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically
import static pl.jakubweg.SponsorBlockSettings.uuid;
import static pl.jakubweg.StringRef.str;
@SuppressWarnings({"unused", "deprecation"}) // injected
public class SponsorBlockPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -54,6 +53,8 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(context);
setPreferenceScreen(preferenceScreen);
SponsorBlockSettings.update(context);
{
SwitchPreference preference = new SwitchPreference(context);
preferenceScreen.addPreference(preference);

View file

@ -86,7 +86,7 @@ public class SponsorBlockSettings {
SponsorBlockUtils.hideShieldButton();
SponsorBlockUtils.hideVoteButton();
PlayerController.sponsorSegmentsOfCurrentVideo = null;
} else if (/*isAddNewSegmentEnabled*/false) {
} else { /*isAddNewSegmentEnabled*/
SponsorBlockUtils.showShieldButton();
}

View file

@ -602,5 +602,4 @@ public abstract class SponsorBlockUtils {
}
}
}
}

View file

@ -26,5 +26,4 @@ public class SponsorSegment implements Comparable<SponsorSegment> {
public int compareTo(SponsorSegment o) {
return (int) (this.start - o.start);
}
}

View file

@ -34,7 +34,6 @@ public class VotingButton {
}
_youtubeControlsLayout = (RelativeLayout) viewStub;
initButtonVisibilitySettings();
ImageView imageView = (ImageView)_youtubeControlsLayout
.findViewById(getIdentifier("voting_button", "id"));
@ -107,20 +106,6 @@ public class VotingButton {
return SponsorBlockSettings.isVotingEnabled && SponsorBlockSettings.isSponsorBlockEnabled;
}
private static void initButtonVisibilitySettings() {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if(context == null){
Log.e(TAG, "context is null");
SponsorBlockSettings.isSponsorBlockEnabled = false;
SponsorBlockSettings.isVotingEnabled = false;
return;
}
SharedPreferences sharedPreferences = context.getSharedPreferences(SponsorBlockSettings.PREFERENCES_NAME, Context.MODE_PRIVATE);
SponsorBlockSettings.isSponsorBlockEnabled = sharedPreferences.getBoolean(SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
SponsorBlockSettings.isVotingEnabled = sharedPreferences.getBoolean(SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED, false);
}
//region Helpers
private static int getIdentifier(String name, String defType) {
Context context = YouTubeTikTokRoot_Application.getAppContext();

View file

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'com.android.tools.build:gradle:4.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View file

@ -1,6 +1,6 @@
#Tue Aug 18 22:56:28 EEST 2020
#Mon Jun 07 19:51:48 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME