Skip to content

Commit ad1ea46

Browse files
authored
refactor: Fix package and code structure (#2541)
BREAKING CHANGE: Various public APIs have changed names and packages or were removed entirely
1 parent eac46ca commit ad1ea46

File tree

108 files changed

+251
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+251
-299
lines changed

api/revanced-patches.api

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ public final class app/revanced/patches/shared/fingerprints/HomeActivityFingerpr
525525

526526
public abstract class app/revanced/patches/shared/integrations/AbstractIntegrationsPatch : app/revanced/patcher/patch/BytecodePatch {
527527
public fun <init> (Ljava/lang/String;Ljava/util/Set;)V
528+
public fun <init> (Ljava/util/Set;)V
528529
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
529530
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
530531
}
@@ -616,13 +617,6 @@ public abstract class app/revanced/patches/shared/settings/preference/BaseResour
616617
public static synthetic fun serialize$default (Lapp/revanced/patches/shared/settings/preference/BaseResource;Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/w3c/dom/Element;
617618
}
618619

619-
public abstract class app/revanced/patches/shared/settings/preference/DefaultBasePreference : app/revanced/patches/shared/settings/preference/BasePreference {
620-
public fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;Ljava/lang/Object;)V
621-
public synthetic fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;Ljava/lang/Object;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
622-
public final fun getDefault ()Ljava/lang/Object;
623-
public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element;
624-
}
625-
626620
public final class app/revanced/patches/shared/settings/preference/SummaryType : java/lang/Enum {
627621
public static final field DEFAULT Lapp/revanced/patches/shared/settings/preference/SummaryType;
628622
public static final field OFF Lapp/revanced/patches/shared/settings/preference/SummaryType;
@@ -650,11 +644,9 @@ public final class app/revanced/patches/shared/settings/preference/impl/InputTyp
650644
public static fun values ()[Lapp/revanced/patches/shared/settings/preference/impl/InputType;
651645
}
652646

653-
public final class app/revanced/patches/shared/settings/preference/impl/ListPreference : app/revanced/patches/shared/settings/preference/DefaultBasePreference {
654-
public fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;)V
655-
public synthetic fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
656-
public final fun getEntries ()Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;
657-
public final fun getEntryValues ()Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;
647+
public final class app/revanced/patches/shared/settings/preference/impl/ListPreference : app/revanced/patches/shared/settings/preference/BasePreference {
648+
public fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;)V
649+
public synthetic fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
658650
public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element;
659651
}
660652

@@ -700,18 +692,18 @@ public final class app/revanced/patches/shared/settings/preference/impl/StringRe
700692
public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element;
701693
}
702694

703-
public final class app/revanced/patches/shared/settings/preference/impl/SwitchPreference : app/revanced/patches/shared/settings/preference/DefaultBasePreference {
704-
public fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Z)V
705-
public synthetic fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
695+
public final class app/revanced/patches/shared/settings/preference/impl/SwitchPreference : app/revanced/patches/shared/settings/preference/BasePreference {
696+
public fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;)V
697+
public synthetic fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
706698
public final fun getSummaryOff ()Lapp/revanced/patches/shared/settings/preference/impl/StringResource;
707699
public final fun getSummaryOn ()Lapp/revanced/patches/shared/settings/preference/impl/StringResource;
708700
public final fun getUserDialogMessage ()Lapp/revanced/patches/shared/settings/preference/impl/StringResource;
709701
public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element;
710702
}
711703

712-
public final class app/revanced/patches/shared/settings/preference/impl/TextPreference : app/revanced/patches/shared/settings/preference/DefaultBasePreference {
713-
public fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;Ljava/lang/String;)V
714-
public synthetic fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
704+
public final class app/revanced/patches/shared/settings/preference/impl/TextPreference : app/revanced/patches/shared/settings/preference/BasePreference {
705+
public fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;)V
706+
public synthetic fun <init> (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
715707
public final fun getInputType ()Lapp/revanced/patches/shared/settings/preference/impl/InputType;
716708
public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element;
717709
}

src/main/kotlin/app/revanced/patches/all/connectivity/wifi/spoof/SpoofWifiPatch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.Instruction
1818
)
1919
@Suppress("unused")
2020
object SpoofWifiPatch : AbstractTransformInstructionsPatch<Instruction35cInfo>() {
21-
private const val INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX = "Lapp/revanced/all/connectivity/wifi/spoof/SpoofWifiPatch"
21+
private const val INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX = "Lapp/revanced/integrations/all/connectivity/wifi/spoof/SpoofWifiPatch"
2222
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "$INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX;"
2323

2424
override fun filterMap(

src/main/kotlin/app/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.Instruction
2020
@Suppress("unused")
2121
object RemoveCaptureRestrictionPatch : AbstractTransformInstructionsPatch<Instruction35cInfo>() {
2222
private const val INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX =
23-
"Lapp/revanced/all/screencapture/removerestriction/RemoveScreencaptureRestrictionPatch"
23+
"Lapp/revanced/integrations/all/screencapture/removerestriction/RemoveScreencaptureRestrictionPatch"
2424
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "$INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX;"
2525
// Information about method calls we want to replace
2626
enum class MethodCall(

src/main/kotlin/app/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
2424
@Suppress("unused")
2525
object RemoveScreenshotRestrictionPatch : AbstractTransformInstructionsPatch<Instruction35cInfo>() {
2626
private const val INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX =
27-
"Lapp/revanced/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch"
27+
"Lapp/revanced/integrations/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch"
2828
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "$INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX;"
2929

3030
override fun execute(context: BytecodeContext) {

src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
2626
@Suppress("unused")
2727
object HideAdsPatch : BytecodePatch(setOf(AdPostFingerprint, NewAdPostFingerprint)) {
2828
private const val FILTER_METHOD_DESCRIPTOR =
29-
"Lapp/revanced/reddit/patches/FilterPromotedLinksPatch;" +
29+
"Lapp/revanced/integrations/reddit/patches/FilterPromotedLinksPatch;" +
3030
"->filterChildren(Ljava/lang/Iterable;)Ljava/util/List;"
3131

3232
override fun execute(context: BytecodeContext) {

src/main/kotlin/app/revanced/patches/shared/integrations/AbstractIntegrationsPatch.kt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,27 @@ import com.android.tools.smali.dexlib2.iface.ClassDef
1111
import com.android.tools.smali.dexlib2.iface.Method
1212

1313
abstract class AbstractIntegrationsPatch(
14-
private val integrationsDescriptor: String,
1514
private val hooks: Set<IntegrationsFingerprint>
1615
) : BytecodePatch(hooks) {
16+
17+
@Deprecated(
18+
"Use the constructor without the integrationsDescriptor parameter",
19+
ReplaceWith("AbstractIntegrationsPatch(hooks)")
20+
)
21+
@Suppress("UNUSED_PARAMETER")
22+
constructor(
23+
integrationsDescriptor: String,
24+
hooks: Set<IntegrationsFingerprint>
25+
) : this(hooks)
26+
27+
override fun execute(context: BytecodeContext) {
28+
if (context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR) == null) throw PatchException(
29+
"Integrations have not been merged yet. This patch can not succeed without merging the integrations."
30+
)
31+
32+
for (hook in hooks) hook.invoke(INTEGRATIONS_CLASS_DESCRIPTOR)
33+
}
34+
1735
/**
1836
* [MethodFingerprint] for integrations.
1937
*
@@ -53,11 +71,7 @@ abstract class AbstractIntegrationsPatch(
5371
}
5472
}
5573

56-
override fun execute(context: BytecodeContext) {
57-
if (context.findClass(integrationsDescriptor) == null) throw PatchException(
58-
"Integrations have not been merged yet. This patch can not succeed without merging the integrations."
59-
)
60-
61-
for (hook in hooks) hook.invoke(integrationsDescriptor)
74+
private companion object {
75+
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/shared/Utils;"
6276
}
6377
}

src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import app.revanced.patches.shared.settings.preference.impl.ArrayResource
1111
import app.revanced.patches.shared.settings.preference.impl.StringResource
1212
import app.revanced.util.ResourceGroup
1313
import app.revanced.util.copyResources
14+
import app.revanced.util.mergeStrings
1415
import org.w3c.dom.Node
1516
import java.io.Closeable
1617

@@ -37,6 +38,8 @@ abstract class AbstractSettingsResourcePatch(
3738
stringsEditor = context.xmlEditor["res/values/strings.xml"]
3839
arraysEditor = context.xmlEditor["res/values/arrays.xml"]
3940
revancedPreferencesEditor = context.xmlEditor["res/xml/$preferenceFileName.xml"]
41+
42+
context.mergeStrings("settings/host/values/strings.xml")
4043
}
4144

4245
internal companion object {

src/main/kotlin/app/revanced/patches/shared/settings/preference/DefaultBasePreference.kt

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package app.revanced.patches.shared.settings.preference.impl
22

3+
import app.revanced.patches.shared.settings.preference.BasePreference
34
import app.revanced.patches.shared.settings.preference.BaseResource
4-
import app.revanced.patches.shared.settings.preference.DefaultBasePreference
55
import app.revanced.patches.shared.settings.preference.addSummary
66
import org.w3c.dom.Document
77

@@ -13,16 +13,14 @@ import org.w3c.dom.Document
1313
* @param entries The human-readable entries of the list preference.
1414
* @param entryValues The entry values of the list preference.
1515
* @param summary The summary of the list preference.
16-
* @param default The default entry value of the list preference.
1716
*/
1817
class ListPreference(
1918
key: String,
2019
title: StringResource,
21-
val entries: ArrayResource,
22-
val entryValues: ArrayResource,
23-
summary: StringResource? = null,
24-
default: String? = null,
25-
) : DefaultBasePreference<String>(key, title, summary, "ListPreference", default) {
20+
private val entries: ArrayResource,
21+
private val entryValues: ArrayResource,
22+
summary: StringResource? = null
23+
) : BasePreference(key, title, summary, "ListPreference") {
2624
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
2725
super.serialize(ownerDocument, resourceCallback).apply {
2826
setAttribute("android:entries", "@array/${entries.also { resourceCallback.invoke(it) }.name}")

src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package app.revanced.patches.shared.settings.preference.impl
22

3+
import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch.Companion.include
4+
import app.revanced.patches.shared.settings.preference.BasePreference
35
import app.revanced.patches.shared.settings.preference.BaseResource
4-
import app.revanced.patches.shared.settings.preference.DefaultBasePreference
56
import app.revanced.patches.shared.settings.preference.SummaryType
67
import app.revanced.patches.shared.settings.preference.addSummary
7-
import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch.Companion.include
88
import org.w3c.dom.Document
99
import org.w3c.dom.Element
1010

@@ -16,15 +16,13 @@ import org.w3c.dom.Element
1616
* @param summaryOn The summary to show when the preference is enabled.
1717
* @param summaryOff The summary to show when the preference is disabled.
1818
* @param userDialogMessage The message to show in a dialog when the user toggles the preference.
19-
* @param default The default value of the switch.
2019
*/
2120
class SwitchPreference(
2221
key: String, title: StringResource,
2322
val summaryOn: StringResource,
2423
val summaryOff: StringResource,
2524
val userDialogMessage: StringResource? = null,
26-
default: Boolean = false,
27-
) : DefaultBasePreference<Boolean>( key, title, null, "SwitchPreference", default) {
25+
) : BasePreference(key, title, null, "SwitchPreference") {
2826
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element {
2927
userDialogMessage?.include()
3028

0 commit comments

Comments
 (0)