diff --git a/app/build.gradle b/app/build.gradle index 42576a05a..caa82e49b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,9 +25,9 @@ android { buildTypes { release { - // TODO: Make sure all of JSON parsers work when activating these. - //minifyEnabled true - //proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.debug + proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), 'proguard-rules.pro' + minifyEnabled true resValue "string", "app_name", "@string/app_name_release" } debug { diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 5acc1b972..6c4310697 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -5,33 +5,47 @@ # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile -# For the Secp256k1 library +# preserve the line number information for debugging stack traces. +-dontobfuscate +-keepattributes LocalVariableTable +-keepattributes LocalVariableTypeTable +-keepattributes *Annotation* +-keepattributes SourceFile +-keepattributes LineNumberTable +-keepattributes Signature +-keepattributes Exceptions -keepattributes InnerClasses +-keepattributes EnclosingMethod +-keepattributes MethodParameters +-keepparameternames --keep class fr.acinq.secp256k1.jni.** { *; } -# For the NostrPostr library --keep class nostr.postr.** { *; } +-keepdirectories libs + +# Keep all names +-keepnames class ** { *; } + +# Keep All enums +-keep enum ** { *; } + +# preserve access to native classses +-keep class fr.acinq.secp256k1.** { *; } + +# GSON parsing -keep class com.vitorpamplona.amethyst.service.model.** { *; } -# Json parsing --keep class com.google.gson.reflect.** { *; } --keep class * extends com.google.gson.reflect.TypeToken --keep public class * implements java.lang.reflect.Type - --keep class com.vitorpamplona.amethyst.lnurl.** { *; } -keep class com.vitorpamplona.amethyst.model.** { *; } --keep class com.vitorpamplona.amethyst.service.** { *; } --keep class com.vitorpamplona.amethyst.ui.** { *; } + +# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory, +# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) +-keep class * extends com.google.gson.TypeAdapter +-keep class * implements com.google.gson.TypeAdapterFactory +-keep class * implements com.google.gson.JsonSerializer +-keep class * implements com.google.gson.JsonDeserializer + +# Prevent R8 from leaving Data object members always null +-keepclassmembers,allowobfuscation class * { + @com.google.gson.annotations.SerializedName ; +} + +# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher. +-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken +-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken diff --git a/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index e86695edf..619053310 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -10,7 +10,9 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.ConnectivityType import com.vitorpamplona.amethyst.model.GLOBAL_FOLLOWS import com.vitorpamplona.amethyst.model.KIND3_FOLLOWS +import com.vitorpamplona.amethyst.model.Nip47URI import com.vitorpamplona.amethyst.model.RelaySetupInfo +import com.vitorpamplona.amethyst.model.ServersAvailable import com.vitorpamplona.amethyst.model.Settings import com.vitorpamplona.amethyst.model.hexToByteArray import com.vitorpamplona.amethyst.model.parseConnectivityType @@ -22,8 +24,6 @@ import com.vitorpamplona.amethyst.service.model.Event import com.vitorpamplona.amethyst.service.model.Event.Companion.getRefinedEvent import com.vitorpamplona.amethyst.service.model.LnZapEvent import com.vitorpamplona.amethyst.service.toNpub -import com.vitorpamplona.amethyst.ui.actions.ServersAvailable -import com.vitorpamplona.amethyst.ui.note.Nip47URI import fr.acinq.secp256k1.Hex import java.io.File import java.util.Locale diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 5ec995425..b8414fe03 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -18,9 +18,7 @@ import com.vitorpamplona.amethyst.service.relays.Constants import com.vitorpamplona.amethyst.service.relays.FeedType import com.vitorpamplona.amethyst.service.relays.Relay import com.vitorpamplona.amethyst.service.relays.RelayPool -import com.vitorpamplona.amethyst.ui.actions.ServersAvailable import com.vitorpamplona.amethyst.ui.components.BundledUpdate -import com.vitorpamplona.amethyst.ui.note.Nip47URI import com.vitorpamplona.amethyst.ui.note.combineWith import kotlinx.collections.immutable.ImmutableSet import kotlinx.collections.immutable.persistentSetOf diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/Nip47URI.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/Nip47URI.kt new file mode 100644 index 000000000..3401a255d --- /dev/null +++ b/app/src/main/java/com/vitorpamplona/amethyst/model/Nip47URI.kt @@ -0,0 +1,3 @@ +package com.vitorpamplona.amethyst.model + +data class Nip47URI(val pubKeyHex: HexKey, val relayUri: String?, val secret: HexKey?) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/ServersAvailable.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/ServersAvailable.kt new file mode 100644 index 000000000..ea8035dbd --- /dev/null +++ b/app/src/main/java/com/vitorpamplona/amethyst/model/ServersAvailable.kt @@ -0,0 +1,16 @@ +package com.vitorpamplona.amethyst.model + +enum class ServersAvailable { + // IMGUR, + NOSTR_BUILD, + NOSTRIMG, + NOSTRFILES_DEV, + NOSTRCHECK_ME, + + // IMGUR_NIP_94, + NOSTRIMG_NIP_94, + NOSTR_BUILD_NIP_94, + NOSTRFILES_DEV_NIP_94, + NOSTRCHECK_ME_NIP_94, + NIP95 +} diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/Nip47.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/Nip47.kt index 17c9aa5fc..55160aeda 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/Nip47.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/Nip47.kt @@ -1,12 +1,10 @@ package com.vitorpamplona.amethyst.ui.note import android.net.Uri -import com.vitorpamplona.amethyst.model.HexKey +import com.vitorpamplona.amethyst.model.Nip47URI import com.vitorpamplona.amethyst.model.decodePublicKey import com.vitorpamplona.amethyst.model.toHexKey -data class Nip47URI(val pubKeyHex: HexKey, val relayUri: String?, val secret: HexKey?) - // Rename to the corect nip number when ready. object Nip47 { fun parse(uri: String): Nip47URI { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageUploader.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageUploader.kt index a949d5490..d6aa00661 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageUploader.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageUploader.kt @@ -8,6 +8,7 @@ import androidx.core.net.toFile import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.vitorpamplona.amethyst.BuildConfig import com.vitorpamplona.amethyst.model.Account +import com.vitorpamplona.amethyst.model.ServersAvailable import com.vitorpamplona.amethyst.service.HttpClient import okhttp3.* import okhttp3.MediaType.Companion.toMediaType diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt index b99becd4e..98aba213b 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt @@ -45,6 +45,7 @@ import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties import coil.compose.AsyncImage import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.model.ServersAvailable import com.vitorpamplona.amethyst.ui.components.VideoView import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.TextSpinner diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt index 6aed33483..a1c97a294 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt @@ -1099,21 +1099,6 @@ fun CreateButton(onPost: () -> Unit = {}, isActive: Boolean, modifier: Modifier } } -enum class ServersAvailable { - // IMGUR, - NOSTR_BUILD, - NOSTRIMG, - NOSTRFILES_DEV, - NOSTRCHECK_ME, - - // IMGUR_NIP_94, - NOSTRIMG_NIP_94, - NOSTR_BUILD_NIP_94, - NOSTRFILES_DEV_NIP_94, - NOSTRCHECK_ME_NIP_94, - NIP95 -} - @Composable fun ImageVideoDescription( uri: Uri, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt index c037587aa..ba723e53d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt @@ -67,6 +67,7 @@ import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.model.Account +import com.vitorpamplona.amethyst.model.Nip47URI import com.vitorpamplona.amethyst.model.decodePublicKey import com.vitorpamplona.amethyst.model.toHexKey import com.vitorpamplona.amethyst.service.model.LnZapEvent diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt index 118b438e3..d2294a3f0 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt @@ -85,6 +85,7 @@ import com.vitorpamplona.amethyst.model.LiveActivitiesChannel import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.PublicChatChannel +import com.vitorpamplona.amethyst.model.ServersAvailable import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.service.NostrChannelDataSource import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_LIVE @@ -94,7 +95,6 @@ import com.vitorpamplona.amethyst.ui.actions.NewChannelView import com.vitorpamplona.amethyst.ui.actions.NewMessageTagger import com.vitorpamplona.amethyst.ui.actions.NewPostViewModel import com.vitorpamplona.amethyst.ui.actions.PostButton -import com.vitorpamplona.amethyst.ui.actions.ServersAvailable import com.vitorpamplona.amethyst.ui.actions.UploadFromGallery import com.vitorpamplona.amethyst.ui.actions.toImmutableListOfLists import com.vitorpamplona.amethyst.ui.components.LoadNote