diff --git a/.gitignore b/.gitignore index 0a68f3c..5d498ee 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ .externalNativeBuild .cxx local.properties +/.idea/ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..eb1a923 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Telegram Monet \ No newline at end of file diff --git a/.idea/appInsightsSettings.xml b/.idea/appInsightsSettings.xml new file mode 100644 index 0000000..371f2e2 --- /dev/null +++ b/.idea/appInsightsSettings.xml @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fcb19bf --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..8ba55ae --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..6806f5a --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,53 @@ + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..6d0ee1c --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..2364a5b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..931b96c --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 6584f51..b324631 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,46 @@ -# Telegram Monet (Android 12 or above) - -

- - - -

- -drawing - - -### Developers and testers: -- [8055](https://t.me/the8055u) -- [TIDI](https://t.me/TIDI286) -- [R4IN80W](https://t.me/TierOhneNation) -- [DPROSAN](https://t.me/dprosan) -- [G_Alex](https://t.me/Mi_G_alex) - - -[If you find bug, please create issues](https://github.com/c3r5b8/Telegram-Monet/issues/new) - - -### Translators -- [Arabic](https://t.me/MMETMA2) -- [Bengali India](https://t.me/pubglover0_01) -- [German](https://t.me/lelehier) -- [Spanish](https://t.me/yoshijulas) -- [Persian](https://t.me/ItsEeleeya_uwu) -- [Filipino](https://t.me/znarfm) -- French - Pierre -- [Hindi](https://t.me/ShivanshVerma) -- [Croatian](https://t.me/Haxyme) -- Indonesian [1](https://t.me/DarmaCahyadi) & [2](https://t.me/ravaeru) -- [Italian](https://t.me/thetruejake) -- [Hebrew](https://t.me/MeniViner) -- [Kabyle](https://t.me/mld9401) -- [Dutch](https://t.me/TheTruePrism) -- [Polish](https://t.me/Lambada10) -- [Europe Portuguese](https://github.com/ReduxFlakes) -- [Brazilian portuguese](https://t.me/Bygrilinho) -- [Romanian](https://t.me/igram96) -- [Tagalog](https://t.me/quantumpi6) -- [Turkish](https://t.me/Teaqaria) -- [Ukrainian](https://t.me/the_dise) -- [Uzbek](https://t.me/FerNikoMF) -- [Vietnamese](https://t.me/masarou) +# Telegram Monet (Android 12 or above) + +

+ + + +

+ +drawing + + +### Developers and testers: +- [8055](https://t.me/the8055u) +- [TIDI](https://t.me/TIDI286) +- [R4IN80W](https://t.me/TierOhneNation) +- [DPROSAN](https://t.me/dprosan) +- [G_Alex](https://t.me/Mi_G_alex) + + +[If you find bug, please create issues](https://github.com/c3r5b8/Telegram-Monet/issues/new) + + +### Translators +- [Arabic](https://t.me/MMETMA2) +- [Bengali India](https://t.me/pubglover0_01) +- [German](https://t.me/lelehier) +- [Spanish](https://t.me/yoshijulas) +- [Persian](https://t.me/ItsEeleeya_uwu) +- [Filipino](https://t.me/znarfm) +- French - Pierre +- [Hindi](https://t.me/ShivanshVerma) +- [Croatian](https://t.me/Haxyme) +- Indonesian [1](https://t.me/DarmaCahyadi) & [2](https://t.me/ravaeru) +- [Italian](https://t.me/thetruejake) +- [Hebrew](https://t.me/MeniViner) +- [Kabyle](https://t.me/mld9401) +- [Dutch](https://t.me/TheTruePrism) +- [Polish](https://t.me/Lambada10) +- [Europe Portuguese](https://github.com/ReduxFlakes) +- [Brazilian portuguese](https://t.me/Bygrilinho) +- [Romanian](https://t.me/igram96) +- [Tagalog](https://t.me/quantumpi6) +- [Turkish](https://t.me/Teaqaria) +- [Ukrainian](https://t.me/the_dise) +- [Uzbek](https://t.me/FerNikoMF) +- [Vietnamese](https://t.me/masarou) diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 04edde5..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,82 +0,0 @@ -import java.nio.file.Paths - -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' -} - -android { - compileSdk 34 - - defaultConfig { - applicationId "com.c3r5b8.telegram_monet" - minSdk 31 - targetSdk 34 - versionCode 23122101 - versionName '10.3.2' - resConfigs 'ar', 'bn_IN', 'de', 'es', 'fa_IR', 'fil', 'fr', 'hi', 'hr', 'in', 'it', 'iw', 'kab', 'ml', 'nl', 'pl', 'pt', 'pt_BR', 'ro', 'ru', 'tl', 'tr_TR', 'uk_UA', 'uz', 'vi', 'zh_CN' - } - - buildTypes { - release { - minifyEnabled true - shrinkResources false - proguardFiles 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - buildFeatures { - viewBinding true - } - - kotlinOptions { - jvmTarget = '1.8' - } - - packagingOptions { - resources { - excludes += "**" - } - } - - dependenciesInfo.includeInApk false -} - -dependencies { - implementation 'androidx.core:core-ktx:1.9.0' - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.google.android.material:material:1.8.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' -} - -def optimizeReleaseRes = task('optimizeReleaseRes').doLast { - def aapt2 = Paths.get(project.android.sdkDirectory.path, 'build-tools', project.android.buildToolsVersion, 'aapt2') - def zip = Paths.get( - project.buildDir.path, - "intermediates", - "optimized_processed_res", - "release", - "resources-release-optimize.ap_" - ) - def optimized = new File("${zip}.opt") - def cmd = exec { - commandLine aapt2, 'optimize', '--collapse-resource-names', - '-o', optimized, zip - ignoreExitValue false - } - if (cmd.exitValue == 0) { - delete(zip) - optimized.renameTo("$zip") - } -} - -tasks.whenTaskAdded { task -> - if (task.name == 'optimizeReleaseResources') { - task.finalizedBy optimizeReleaseRes - } -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..6865dbf --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,81 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) +} + +android { + namespace = "com.c3r5b8.telegram_monet" + compileSdk = 34 + + defaultConfig { + applicationId = "com.c3r5b8.telegram_monet" + minSdk = 31 + targetSdk = 35 + versionCode = 24072101 + versionName = "10.14.0" + + resourceConfigurations.addAll( + arrayOf( + "ar", "bn_IN", "de", "es", "fa_IR", "fil", "fr", "hi", "hr", "in", "it", "iw", + "kab", "ml", "nl", "pl", "pt", "pt_BR", "ro", "ru", "tl", "tr_TR", "uk_UA", "uz", + "vi", "zh_CN" + ) + ) + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_18 + targetCompatibility = JavaVersion.VERSION_18 + } + + kotlinOptions { + jvmTarget = "18" + freeCompilerArgs += arrayOf( + "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api" + ) + } + + buildFeatures { + compose = true + } + + packaging { + resources { + excludes += "**" + } + } + + dependenciesInfo.includeInApk = false + dependenciesInfo.includeInBundle = false + +} + +dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + implementation(libs.androidx.navigation.runtime.ktx) + implementation(libs.androidx.navigation.compose) + implementation(libs.coil.compose) + implementation(libs.coil.gif) + debugImplementation(libs.ui.tooling) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 720d569..481bb43 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,10 +1,21 @@ --assumenosideeffects class kotlin.jvm.internal.Intrinsics { - public static void check*(...); - public static void throw*(...); -} +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html --keepattributes SourceFile,LineNumberTable --renamesourcefileattribute --repackageclasses --allowaccessmodification --overloadaggressively \ No newline at end of file +# 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 \ No newline at end of file diff --git a/app/release/baselineProfiles/0/app-release.dm b/app/release/baselineProfiles/0/app-release.dm new file mode 100644 index 0000000..17d2abe Binary files /dev/null and b/app/release/baselineProfiles/0/app-release.dm differ diff --git a/app/release/baselineProfiles/1/app-release.dm b/app/release/baselineProfiles/1/app-release.dm new file mode 100644 index 0000000..9b318cf Binary files /dev/null and b/app/release/baselineProfiles/1/app-release.dm differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..12cf34a --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,37 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.c3r5b8.telegram_monet", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 24072101, + "versionName": "10.14.0", + "outputFile": "app-release.apk" + } + ], + "elementType": "File", + "baselineProfiles": [ + { + "minApi": 28, + "maxApi": 30, + "baselineProfiles": [ + "baselineProfiles/1/app-release.dm" + ] + }, + { + "minApi": 31, + "maxApi": 2147483647, + "baselineProfiles": [ + "baselineProfiles/0/app-release.dm" + ] + } + ], + "minSdkVersionForDexing": 31 +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e471886..25d0476 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,28 +1,20 @@ - + - - - - - - - + + android:theme="@style/Theme.TelegramMonet"> + android:theme="@style/Theme.TelegramMonet"> @@ -32,7 +24,7 @@ - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - resolveInfos = - packageManager.queryIntentActivities(intent, ResolveInfoFlags.of(flags.toLong())) - } else { - resolveInfos = packageManager.queryIntentActivities(intent, flags) } - if (!resolveInfos.isEmpty()) { - MaterialAlertDialogBuilder(this) - .setTitle(R.string.fast_import_choose_method) - .setMessage(R.string.fast_import_description) - .setPositiveButton(R.string.fast_import_method_fast_import) { dialog, which -> - resolveInfos.forEach { - grantUriPermission( - it.activityInfo.packageName, - uri, - Intent.FLAG_GRANT_READ_URI_PERMISSION - ) - } - - val runIntent = Intent("org.telegram.messenger.IMPORT_THEME") - runIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - runIntent.type = "*/*" - runIntent.putExtra(Intent.EXTRA_STREAM, uri) - runIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - startActivity(Intent.createChooser(runIntent, theme)) - } - .setNegativeButton(R.string.fast_import_method_regular) { dialog, which -> - shareThemeRegular( - theme, - uri - ) - } - .show() - - return - } - - shareThemeRegular(theme, uri) - } - - private fun shareThemeRegular(theme: String, uri: Uri) { - intent = Intent(Intent.ACTION_SEND) - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - intent.type = "*/*" - intent.putExtra(Intent.EXTRA_STREAM, uri) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - startActivity(Intent.createChooser(intent, theme)) - } - - private fun putData() { - val sharedPreferences: SharedPreferences = - getSharedPreferences("switchSettings", MODE_PRIVATE) - val sharedPreferencesEditor: SharedPreferences.Editor = sharedPreferences.edit() - - val useGradient: SwitchCompat = findViewById(R.id.switchGradient) - val useGradientAvatars: SwitchCompat = findViewById(R.id.switchGradientAvatars) - val isAmoledMode: SwitchCompat = findViewById(R.id.switchAmoledPhone) - val useColorNick: SwitchCompat = findViewById(R.id.switchColorsOfNickNames) - - - sharedPreferencesEditor.putBoolean("useGradient", useGradient.isChecked) - sharedPreferencesEditor.putBoolean("useGradientAvatars", useGradientAvatars.isChecked) - sharedPreferencesEditor.putBoolean("isAmoledMode", isAmoledMode.isChecked) - sharedPreferencesEditor.putBoolean("useColorNick", useColorNick.isChecked) - sharedPreferencesEditor.apply() } - - private fun getData() { - val sharedPreferences: SharedPreferences = - getSharedPreferences("switchSettings", MODE_PRIVATE) - - val useGradient: SwitchCompat = findViewById(R.id.switchGradient) - val useGradientAvatars: SwitchCompat = findViewById(R.id.switchGradientAvatars) - val isAmoledMode: SwitchCompat = findViewById(R.id.switchAmoledPhone) - val useColorNick: SwitchCompat = findViewById(R.id.switchColorsOfNickNames) - - useGradient.isChecked = sharedPreferences.getBoolean("useGradient", false) - useGradientAvatars.isChecked = sharedPreferences.getBoolean("useGradientAvatars", false) - isAmoledMode.isChecked = sharedPreferences.getBoolean("isAmoledMode", false) - useColorNick.isChecked = sharedPreferences.getBoolean("useColorNick", true) - } - - override fun onPause() { - super.onPause() - putData() - } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/NavigationScreen.kt b/app/src/main/java/com/c3r5b8/telegram_monet/NavigationScreen.kt new file mode 100644 index 0000000..fbdb86a --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/NavigationScreen.kt @@ -0,0 +1,54 @@ +package com.c3r5b8.telegram_monet + +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.navigation +import androidx.navigation.compose.rememberNavController +import com.c3r5b8.telegram_monet.presentation.how_to_use.HowToUseScreen +import com.c3r5b8.telegram_monet.presentation.main_screen.MainScreen +import com.c3r5b8.telegram_monet.presentation.main_screen.MainScreenViewModel + + +private object Routes { + const val MAIN_ROUTE = "MAIN_ROUTE" + const val MAIN_SCREEN = "MAIN_SCREEN" + const val HOW_USE_SCREEN = "HOW_USE_SCREEN" +} + +@Composable +fun NavigationScreen( + navController: NavHostController = rememberNavController() +) { + + val mainScreenViewModel = MainScreenViewModel(LocalContext.current) + + NavHost( + navController = navController, + startDestination = Routes.MAIN_ROUTE + ) { + + navigation( + route = Routes.MAIN_ROUTE, + startDestination = Routes.MAIN_SCREEN + ) { + composable( + route = Routes.MAIN_SCREEN, + ) { _ -> + MainScreen( + viewModel = mainScreenViewModel + ) { + navController.navigate(Routes.HOW_USE_SCREEN) + } + } + composable( + route = Routes.HOW_USE_SCREEN, + ) { _ -> + HowToUseScreen { navController.navigateUp() } + } + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/TelegramAdapter.kt b/app/src/main/java/com/c3r5b8/telegram_monet/TelegramAdapter.kt deleted file mode 100644 index 5679d58..0000000 --- a/app/src/main/java/com/c3r5b8/telegram_monet/TelegramAdapter.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.c3r5b8.telegram_monet - -import android.content.Context -import androidx.core.content.ContextCompat - -fun changeTextTelegram(file: String, applicationContext : Context): String { - val monetList = mapOf( - "a1_0" to ContextCompat.getColor(applicationContext, R.color.system_accent1_0), - "a1_200" to ContextCompat.getColor(applicationContext, R.color.system_accent1_200), - "a1_300" to ContextCompat.getColor(applicationContext, R.color.system_accent1_300), - "a1_400" to ContextCompat.getColor(applicationContext, R.color.system_accent1_400), - "a1_500" to ContextCompat.getColor(applicationContext, R.color.system_accent1_500), - "a1_600" to ContextCompat.getColor(applicationContext, R.color.system_accent1_600), - "a1_700" to ContextCompat.getColor(applicationContext, R.color.system_accent1_700), - "a1_800" to ContextCompat.getColor(applicationContext, R.color.system_accent1_800), - "a1_900" to ContextCompat.getColor(applicationContext, R.color.system_accent1_900), - "a1_1000" to ContextCompat.getColor(applicationContext, R.color.system_accent1_1000), - "a1_100" to ContextCompat.getColor(applicationContext, R.color.system_accent1_100), - "a1_10" to ContextCompat.getColor(applicationContext, R.color.system_accent1_10), - "a1_50" to ContextCompat.getColor(applicationContext, R.color.system_accent1_50), - "a2_0" to ContextCompat.getColor(applicationContext, R.color.system_accent2_0), - "a2_200" to ContextCompat.getColor(applicationContext, R.color.system_accent2_200), - "a2_300" to ContextCompat.getColor(applicationContext, R.color.system_accent2_300), - "a2_400" to ContextCompat.getColor(applicationContext, R.color.system_accent2_400), - "a2_500" to ContextCompat.getColor(applicationContext, R.color.system_accent2_500), - "a2_600" to ContextCompat.getColor(applicationContext, R.color.system_accent2_600), - "a2_700" to ContextCompat.getColor(applicationContext, R.color.system_accent2_700), - "a2_800" to ContextCompat.getColor(applicationContext, R.color.system_accent2_800), - "a2_900" to ContextCompat.getColor(applicationContext, R.color.system_accent2_900), - "a2_1000" to ContextCompat.getColor(applicationContext, R.color.system_accent2_1000), - "a2_100" to ContextCompat.getColor(applicationContext, R.color.system_accent2_100), - "a2_10" to ContextCompat.getColor(applicationContext, R.color.system_accent2_10), - "a2_50" to ContextCompat.getColor(applicationContext, R.color.system_accent2_50), - "a3_0" to ContextCompat.getColor(applicationContext, R.color.system_accent3_0), - "a3_200" to ContextCompat.getColor(applicationContext, R.color.system_accent3_200), - "a3_300" to ContextCompat.getColor(applicationContext, R.color.system_accent3_300), - "a3_400" to ContextCompat.getColor(applicationContext, R.color.system_accent3_400), - "a3_500" to ContextCompat.getColor(applicationContext, R.color.system_accent3_500), - "a3_600" to ContextCompat.getColor(applicationContext, R.color.system_accent3_600), - "a3_700" to ContextCompat.getColor(applicationContext, R.color.system_accent3_700), - "a3_800" to ContextCompat.getColor(applicationContext, R.color.system_accent3_800), - "a3_900" to ContextCompat.getColor(applicationContext, R.color.system_accent3_900), - "a3_1000" to ContextCompat.getColor(applicationContext, R.color.system_accent3_1000), - "a3_100" to ContextCompat.getColor(applicationContext, R.color.system_accent3_100), - "a3_10" to ContextCompat.getColor(applicationContext, R.color.system_accent3_10), - "a3_50" to ContextCompat.getColor(applicationContext, R.color.system_accent3_50), - "n1_0" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_0), - "n1_200" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_200), - "n1_300" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_300), - "n1_400" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_400), - "n1_500" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_500), - "n1_600" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_600), - "n1_700" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_700), - "n1_800" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_800), - "n1_900" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_900), - "n1_1000" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_1000), - "n1_100" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_100), - "n1_10" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_10), - "n1_50" to ContextCompat.getColor(applicationContext, R.color.system_neutral1_50), - "n2_0" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_0), - "n2_200" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_200), - "n2_300" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_300), - "n2_400" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_400), - "n2_500" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_500), - "n2_600" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_600), - "n2_700" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_700), - "n2_800" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_800), - "n2_900" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_900), - "n2_1000" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_1000), - "n2_100" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_100), - "n2_10" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_10), - "n2_50" to ContextCompat.getColor(applicationContext, R.color.system_neutral2_50), - "monetRedDark" to ContextCompat.getColor(applicationContext, R.color.monetRedDark), - "monetRedLight" to ContextCompat.getColor(applicationContext, R.color.monetRedLight), - "monetRedCall" to ContextCompat.getColor(applicationContext, R.color.colorCallRed), - "monetGreenCall" to ContextCompat.getColor(applicationContext, R.color.colorCallGreen), - ) - var themeText = file.replace("\$", "") - monetList.forEach { - themeText = themeText.replace(it.key, it.value.toString()) - } - return themeText -} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/TelegramXAdapter.kt b/app/src/main/java/com/c3r5b8/telegram_monet/TelegramXAdapter.kt deleted file mode 100644 index 8b9d4df..0000000 --- a/app/src/main/java/com/c3r5b8/telegram_monet/TelegramXAdapter.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.c3r5b8.telegram_monet - -import android.content.Context -import androidx.core.content.ContextCompat - -fun changeTextTelegramX(file: String, applicationContext : Context): String { - val monetList = mapOf( - "a1_0" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_0)), - "a1_200" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_200)), - "a1_300" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_300)), - "a1_400" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_400)), - "a1_500" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_500)), - "a1_600" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_600)), - "a1_700" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_700)), - "a1_800" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_800)), - "a1_900" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_900)), - "a1_1000" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_1000)), - "a1_100" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_100)), - "a1_10" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_10)), - "a1_50" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent1_50)), - "a2_0" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_0)), - "a2_200" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_200)), - "a2_300" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_300)), - "a2_400" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_400)), - "a2_500" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_500)), - "a2_600" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_600)), - "a2_700" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_700)), - "a2_800" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_800)), - "a2_900" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_900)), - "a2_1000" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_1000)), - "a2_100" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_100)), - "a2_10" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_10)), - "a2_50" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent2_50)), - "a3_0" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_0)), - "a3_200" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_200)), - "a3_300" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_300)), - "a3_400" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_400)), - "a3_500" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_500)), - "a3_600" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_600)), - "a3_700" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_700)), - "a3_800" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_800)), - "a3_900" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_900)), - "a3_1000" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_1000)), - "a3_100" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_100)), - "a3_10" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_10)), - "a3_50" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_accent3_50)), - "n1_0" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_0)), - "n1_200" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_200)), - "n1_300" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_300)), - "n1_400" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_400)), - "n1_500" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_500)), - "n1_600" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_600)), - "n1_700" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_700)), - "n1_800" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_800)), - "n1_900" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_900)), - "n1_1000" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_1000)), - "n1_100" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_100)), - "n1_10" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_10)), - "n1_50" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral1_50)), - "n2_0" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_0)), - "n2_200" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_200)), - "n2_300" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_300)), - "n2_400" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_400)), - "n2_500" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_500)), - "n2_600" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_600)), - "n2_700" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_700)), - "n2_800" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_800)), - "n2_900" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_900)), - "n2_1000" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_1000)), - "n2_100" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_100)), - "n2_10" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_10)), - "n2_50" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.system_neutral2_50)), - "monetRedDark" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.monetRedDark)), - "monetRedLight" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.monetRedLight)), - "monetRedCall" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.colorCallRed)), - "monetGreenCall" to Integer.toHexString(ContextCompat.getColor(applicationContext, R.color.colorCallGreen)), - ) - var themeText = file.replace("\$", "") - monetList.forEach { - themeText = themeText.replace(it.key, "#" + it.value.toString().substring(2)) - } - return themeText -} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/adapters/CreateTheme.kt b/app/src/main/java/com/c3r5b8/telegram_monet/adapters/CreateTheme.kt new file mode 100644 index 0000000..57b9260 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/adapters/CreateTheme.kt @@ -0,0 +1,60 @@ +package com.c3r5b8.telegram_monet.adapters + +import android.content.Context +import java.io.BufferedReader +import java.io.File +import java.io.InputStreamReader + +fun createTheme( + context: Context, + isTelegram: Boolean, + isAmoled: Boolean, + isGradient: Boolean, + isAvatarGradient: Boolean, + isNicknameColorful: Boolean, + inputFileName: String, + outputFileName: String, +) { + val reader = BufferedReader(InputStreamReader(context.assets.open(inputFileName))) + var themeImport = "" + reader.readLines().forEach { themeImport += it + "\n" } + reader.close() + + + if (isAmoled) + themeImport = themeImport.replace("n1_900", "n1_1000") + if (isGradient) + themeImport = themeImport.replace("noGradient", "chat_outBubbleGradient") + if (isNicknameColorful) + themeImport = themeImport.replace( + "\nend", + "\navatar_nameInMessageBlue=a1_400\n" + + "avatar_nameInMessageCyan=a1_400\n" + + "avatar_nameInMessageGreen=a1_400\n" + + "avatar_nameInMessageOrange=a1_400\n" + + "avatar_nameInMessagePink=a1_400\n" + + "avatar_nameInMessageRed=a1_400\n" + + "avatar_nameInMessageViolet=a1_400\nend" + ) + if (isAvatarGradient) { + themeImport = themeImport.replace("avatar_backgroundBlue=n2_800", "avatar_backgroundBlue=n2_700") + themeImport = themeImport.replace("avatar_backgroundCyan=n2_800", "avatar_backgroundCyan=n2_700") + themeImport = themeImport.replace("avatar_backgroundGreen=n2_800", "avatar_backgroundGreen=n2_700") + themeImport = themeImport.replace("avatar_backgroundOrange=n2_800", "avatar_backgroundOrange=n2_700") + themeImport = themeImport.replace("avatar_backgroundPink=n2_800", "avatar_backgroundPink=n2_700") + themeImport = themeImport.replace("avatar_backgroundRed=n2_800", "avatar_backgroundRed=n2_700") + themeImport = themeImport.replace("avatar_backgroundSaved=n2_800", "avatar_backgroundSaved=n2_700") + themeImport = themeImport.replace("avatar_backgroundViolet=n2_800", "avatar_backgroundViolet=n2_700") + } + + val generatedTheme = + if (isTelegram) + changeTextTelegram(themeImport, context) + else + changeTextTelegramX(themeImport, context) + + File(context.filesDir, outputFileName).writeText(text = generatedTheme) + + shareTheme(context, outputFileName) + +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/adapters/ShareTheme.kt b/app/src/main/java/com/c3r5b8/telegram_monet/adapters/ShareTheme.kt new file mode 100644 index 0000000..f85d8b4 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/adapters/ShareTheme.kt @@ -0,0 +1,26 @@ +package com.c3r5b8.telegram_monet.adapters + +import android.content.Context +import android.content.Intent +import androidx.core.content.FileProvider +import java.io.File + +fun shareTheme( + context: Context, + fileName: String +) { + val file = File(context.filesDir, fileName) + + val uri = FileProvider.getUriForFile( + context, + "com.c3r5b8.telegram_monet.provider", + file + ) + + val intent = Intent(Intent.ACTION_SEND) + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + intent.type = "document/*" + intent.putExtra(Intent.EXTRA_STREAM, uri) + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + context.startActivity(Intent.createChooser(intent, fileName)) +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/adapters/TelegramAdapter.kt b/app/src/main/java/com/c3r5b8/telegram_monet/adapters/TelegramAdapter.kt new file mode 100644 index 0000000..c389bd2 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/adapters/TelegramAdapter.kt @@ -0,0 +1,84 @@ +package com.c3r5b8.telegram_monet.adapters + +import android.content.Context +import androidx.core.content.ContextCompat.getColor +import com.c3r5b8.telegram_monet.R + +fun changeTextTelegram(file: String, applicationContext : Context): String { + val monetList = mapOf( + "a1_0" to getColor(applicationContext, R.color.system_accent1_0), + "a1_200" to getColor(applicationContext, R.color.system_accent1_200), + "a1_300" to getColor(applicationContext, R.color.system_accent1_300), + "a1_400" to getColor(applicationContext, R.color.system_accent1_400), + "a1_500" to getColor(applicationContext, R.color.system_accent1_500), + "a1_600" to getColor(applicationContext, R.color.system_accent1_600), + "a1_700" to getColor(applicationContext, R.color.system_accent1_700), + "a1_800" to getColor(applicationContext, R.color.system_accent1_800), + "a1_900" to getColor(applicationContext, R.color.system_accent1_900), + "a1_1000" to getColor(applicationContext, R.color.system_accent1_1000), + "a1_100" to getColor(applicationContext, R.color.system_accent1_100), + "a1_10" to getColor(applicationContext, R.color.system_accent1_10), + "a1_50" to getColor(applicationContext, R.color.system_accent1_50), + "a2_0" to getColor(applicationContext, R.color.system_accent2_0), + "a2_200" to getColor(applicationContext, R.color.system_accent2_200), + "a2_300" to getColor(applicationContext, R.color.system_accent2_300), + "a2_400" to getColor(applicationContext, R.color.system_accent2_400), + "a2_500" to getColor(applicationContext, R.color.system_accent2_500), + "a2_600" to getColor(applicationContext, R.color.system_accent2_600), + "a2_700" to getColor(applicationContext, R.color.system_accent2_700), + "a2_800" to getColor(applicationContext, R.color.system_accent2_800), + "a2_900" to getColor(applicationContext, R.color.system_accent2_900), + "a2_1000" to getColor(applicationContext, R.color.system_accent2_1000), + "a2_100" to getColor(applicationContext, R.color.system_accent2_100), + "a2_10" to getColor(applicationContext, R.color.system_accent2_10), + "a2_50" to getColor(applicationContext, R.color.system_accent2_50), + "a3_0" to getColor(applicationContext, R.color.system_accent3_0), + "a3_200" to getColor(applicationContext, R.color.system_accent3_200), + "a3_300" to getColor(applicationContext, R.color.system_accent3_300), + "a3_400" to getColor(applicationContext, R.color.system_accent3_400), + "a3_500" to getColor(applicationContext, R.color.system_accent3_500), + "a3_600" to getColor(applicationContext, R.color.system_accent3_600), + "a3_700" to getColor(applicationContext, R.color.system_accent3_700), + "a3_800" to getColor(applicationContext, R.color.system_accent3_800), + "a3_900" to getColor(applicationContext, R.color.system_accent3_900), + "a3_1000" to getColor(applicationContext, R.color.system_accent3_1000), + "a3_100" to getColor(applicationContext, R.color.system_accent3_100), + "a3_10" to getColor(applicationContext, R.color.system_accent3_10), + "a3_50" to getColor(applicationContext, R.color.system_accent3_50), + "n1_0" to getColor(applicationContext, R.color.system_neutral1_0), + "n1_200" to getColor(applicationContext, R.color.system_neutral1_200), + "n1_300" to getColor(applicationContext, R.color.system_neutral1_300), + "n1_400" to getColor(applicationContext, R.color.system_neutral1_400), + "n1_500" to getColor(applicationContext, R.color.system_neutral1_500), + "n1_600" to getColor(applicationContext, R.color.system_neutral1_600), + "n1_700" to getColor(applicationContext, R.color.system_neutral1_700), + "n1_800" to getColor(applicationContext, R.color.system_neutral1_800), + "n1_900" to getColor(applicationContext, R.color.system_neutral1_900), + "n1_1000" to getColor(applicationContext, R.color.system_neutral1_1000), + "n1_100" to getColor(applicationContext, R.color.system_neutral1_100), + "n1_10" to getColor(applicationContext, R.color.system_neutral1_10), + "n1_50" to getColor(applicationContext, R.color.system_neutral1_50), + "n2_0" to getColor(applicationContext, R.color.system_neutral2_0), + "n2_200" to getColor(applicationContext, R.color.system_neutral2_200), + "n2_300" to getColor(applicationContext, R.color.system_neutral2_300), + "n2_400" to getColor(applicationContext, R.color.system_neutral2_400), + "n2_500" to getColor(applicationContext, R.color.system_neutral2_500), + "n2_600" to getColor(applicationContext, R.color.system_neutral2_600), + "n2_700" to getColor(applicationContext, R.color.system_neutral2_700), + "n2_800" to getColor(applicationContext, R.color.system_neutral2_800), + "n2_900" to getColor(applicationContext, R.color.system_neutral2_900), + "n2_1000" to getColor(applicationContext, R.color.system_neutral2_1000), + "n2_100" to getColor(applicationContext, R.color.system_neutral2_100), + "n2_10" to getColor(applicationContext, R.color.system_neutral2_10), + "n2_50" to getColor(applicationContext, R.color.system_neutral2_50), + "monetRedDark" to getColor(applicationContext, R.color.monetRedDark), + "monetRedLight" to getColor(applicationContext, R.color.monetRedLight), + "monetRedCall" to getColor(applicationContext, R.color.colorCallRed), + "monetGreenCall" to getColor(applicationContext, R.color.colorCallGreen), + ) + var themeText = file.replace("\$", "") + monetList.forEach { + themeText = themeText.replace(it.key, it.value.toString()) + } + return themeText +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/adapters/TelegramXAdapter.kt b/app/src/main/java/com/c3r5b8/telegram_monet/adapters/TelegramXAdapter.kt new file mode 100644 index 0000000..0b71693 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/adapters/TelegramXAdapter.kt @@ -0,0 +1,84 @@ +package com.c3r5b8.telegram_monet.adapters + +import android.content.Context +import androidx.core.content.ContextCompat.getColor +import com.c3r5b8.telegram_monet.R + +fun changeTextTelegramX(file: String, applicationContext : Context): String { + val monetList = mapOf( + "a1_0" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_0)), + "a1_200" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_200)), + "a1_300" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_300)), + "a1_400" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_400)), + "a1_500" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_500)), + "a1_600" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_600)), + "a1_700" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_700)), + "a1_800" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_800)), + "a1_900" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_900)), + "a1_1000" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_1000)), + "a1_100" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_100)), + "a1_10" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_10)), + "a1_50" to Integer.toHexString(getColor(applicationContext, R.color.system_accent1_50)), + "a2_0" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_0)), + "a2_200" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_200)), + "a2_300" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_300)), + "a2_400" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_400)), + "a2_500" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_500)), + "a2_600" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_600)), + "a2_700" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_700)), + "a2_800" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_800)), + "a2_900" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_900)), + "a2_1000" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_1000)), + "a2_100" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_100)), + "a2_10" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_10)), + "a2_50" to Integer.toHexString(getColor(applicationContext, R.color.system_accent2_50)), + "a3_0" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_0)), + "a3_200" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_200)), + "a3_300" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_300)), + "a3_400" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_400)), + "a3_500" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_500)), + "a3_600" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_600)), + "a3_700" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_700)), + "a3_800" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_800)), + "a3_900" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_900)), + "a3_1000" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_1000)), + "a3_100" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_100)), + "a3_10" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_10)), + "a3_50" to Integer.toHexString(getColor(applicationContext, R.color.system_accent3_50)), + "n1_0" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_0)), + "n1_200" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_200)), + "n1_300" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_300)), + "n1_400" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_400)), + "n1_500" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_500)), + "n1_600" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_600)), + "n1_700" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_700)), + "n1_800" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_800)), + "n1_900" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_900)), + "n1_1000" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_1000)), + "n1_100" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_100)), + "n1_10" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_10)), + "n1_50" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral1_50)), + "n2_0" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_0)), + "n2_200" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_200)), + "n2_300" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_300)), + "n2_400" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_400)), + "n2_500" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_500)), + "n2_600" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_600)), + "n2_700" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_700)), + "n2_800" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_800)), + "n2_900" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_900)), + "n2_1000" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_1000)), + "n2_100" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_100)), + "n2_10" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_10)), + "n2_50" to Integer.toHexString(getColor(applicationContext, R.color.system_neutral2_50)), + "monetRedDark" to Integer.toHexString(getColor(applicationContext, R.color.monetRedDark)), + "monetRedLight" to Integer.toHexString(getColor(applicationContext, R.color.monetRedLight)), + "monetRedCall" to Integer.toHexString(getColor(applicationContext, R.color.colorCallRed)), + "monetGreenCall" to Integer.toHexString(getColor(applicationContext, R.color.colorCallGreen)), + ) + var themeText = file.replace("\$", "") + monetList.forEach { + themeText = themeText.replace(it.key, "#" + it.value.toString().substring(2)) + } + return themeText +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/common/Constants.kt b/app/src/main/java/com/c3r5b8/telegram_monet/common/Constants.kt new file mode 100644 index 0000000..2f4b721 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/common/Constants.kt @@ -0,0 +1,28 @@ +package com.c3r5b8.telegram_monet.common +object Constants { + + const val URL_GIF = "https://raw.githubusercontent.com/mi-g-alex/Telegram-Monet/main/screen.gif" + const val URL_TELEGRAM = "https://t.me/tgmonet" + const val URL_GITHUB = "https://github.com/mi-g-alex/Telegram-Monet" + + // Files Names + const val INPUT_FILE_TELEGRAM_LIGHT = "monet_light.attheme" + const val INPUT_FILE_TELEGRAM_DARK = "monet_dark.attheme" + const val INPUT_FILE_TELEGRAM_X_LIGHT = "monet_x_light.tgx-theme" + const val INPUT_FILE_TELEGRAM_X_DARK = "monet_x_dark.tgx-theme" + + const val OUTPUT_FILE_TELEGRAM_LIGHT = "Light Theme.attheme" + const val OUTPUT_FILE_TELEGRAM_DARK = "Dark Theme.attheme" + const val OUTPUT_FILE_TELEGRAM_AMOLED = "Amoled Theme.attheme" + const val OUTPUT_FILE_TELEGRAM_X_LIGHT = "Light Theme.tgx-theme" + const val OUTPUT_FILE_TELEGRAM_X_DARK = "Dark Theme.tgx-theme" + const val OUTPUT_FILE_TELEGRAM_X_AMOLED = "Amoled Theme.tgx-theme" + + + // SharedPrefs + const val SHARED_PREF = "switchSettings" + const val SHARED_IS_AMOLED = "isAmoledMode" + const val SHARED_USE_GRADIENT = "useGradient" + const val SHARED_USE_GRADIENT_AVATARS = "useGradientAvatars" + const val SHARED_USE_COLORFUL_NICKNAME = "useColorNick" +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/components/ButtonAnimation.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/components/ButtonAnimation.kt new file mode 100644 index 0000000..e6509e0 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/components/ButtonAnimation.kt @@ -0,0 +1,78 @@ +package com.c3r5b8.telegram_monet.presentation.components + +import androidx.annotation.FloatRange +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.awaitFirstDown +import androidx.compose.foundation.gestures.waitForUpOrCancellation +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.composed +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.input.pointer.pointerInput + +enum class ButtonState { Pressed, Idle } + +/** + * Bounce animation on click + * Default scale = 0.9f + */ +fun Modifier.bounceClick(onClick: () -> Unit = {}) = bounceClick(0.9f, 0.9f, onClick) + + +/** + * Bounce animation on click + * + * @param scale scale of button on click on X and Y. Min 0.1f. + */ +fun Modifier.bounceClick(@FloatRange(0.1) scale: Float, onClick: () -> Unit = {}) = bounceClick(scale, scale, onClick) + +/** + * Bounce animation on click + * + * @param scaleToX scale of button on click on X. Min 0.1f + * @param scaleToY scale of button on click on Y. Min 0.1f + */ + +fun Modifier.bounceClick( + @FloatRange(0.1) scaleToX: Float, + @FloatRange(0.1) scaleToY: Float, + onClick: () -> Unit = {} +) = + composed { + var buttonState by remember { mutableStateOf(ButtonState.Idle) } + val scaleStateX by animateFloatAsState( + if (buttonState == ButtonState.Pressed) scaleToX else 1f, + label = "" + ) + val scaleStateY by animateFloatAsState( + if (buttonState == ButtonState.Pressed) scaleToY else 1f, + label = "" + ) + + this + .graphicsLayer { + scaleX = scaleStateX + scaleY = scaleStateY + } + .clickable( + interactionSource = remember { MutableInteractionSource() }, + indication = null, + onClick = { onClick() } + ) + .pointerInput(buttonState) { + awaitPointerEventScope { + buttonState = if (buttonState == ButtonState.Pressed) { + waitForUpOrCancellation() + ButtonState.Idle + } else { + awaitFirstDown(false) + ButtonState.Pressed + } + } + } + } \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/how_to_use/HowToUseScreen.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/how_to_use/HowToUseScreen.kt new file mode 100644 index 0000000..157ce6a --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/how_to_use/HowToUseScreen.kt @@ -0,0 +1,80 @@ +package com.c3r5b8.telegram_monet.presentation.how_to_use + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import coil.decode.GifDecoder +import coil.request.ImageRequest +import com.c3r5b8.telegram_monet.R +import com.c3r5b8.telegram_monet.common.Constants + +@Composable +fun HowToUseScreen( + goBack: () -> Unit +) { + var goBackClicked by remember { mutableStateOf(false) } + + var isError by remember { mutableStateOf(false) } + + Scaffold( + topBar = { + TopAppBar( + title = { Text(stringResource(R.string.how_to_use)) }, + navigationIcon = { + IconButton(onClick = { goBackClicked = true; goBack() }, enabled = !goBackClicked) { + Icon( + Icons.AutoMirrored.Filled.ArrowBack, + null + ) + } + } + ) + } + ) { pad -> + Box(Modifier.fillMaxSize().padding(pad).padding(16.dp), contentAlignment = Alignment.Center) { + if(!isError) CircularProgressIndicator() + AsyncImage( + model = ImageRequest.Builder(LocalContext.current) + .data(Constants.URL_GIF) + .decoderFactory(GifDecoder.Factory()) + .build(), + contentDescription = stringResource(R.string.how_to_use), + modifier = Modifier + .fillMaxHeight() + .clip(RoundedCornerShape(20.dp)), + contentScale = ContentScale.FillHeight, + onError = { + isError = true + } + ) + if(isError) { + Text( + stringResource(R.string.something_went_wrong) + ) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/MainScreen.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/MainScreen.kt new file mode 100644 index 0000000..fdbdb8a --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/MainScreen.kt @@ -0,0 +1,144 @@ +package com.c3r5b8.telegram_monet.presentation.main_screen + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.Scaffold +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.rememberTopAppBarState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.tooling.preview.Preview +import com.c3r5b8.telegram_monet.R +import com.c3r5b8.telegram_monet.common.Constants +import com.c3r5b8.telegram_monet.presentation.main_screen.components.AboutCard +import com.c3r5b8.telegram_monet.presentation.main_screen.components.CreateThemeCard +import com.c3r5b8.telegram_monet.presentation.main_screen.components.SettingsCard +import com.c3r5b8.telegram_monet.presentation.main_screen.components.TopAppBar + +@Composable +fun MainScreen( + viewModel: MainScreenViewModel, + goHowUse: () -> Unit +) { + + val isAmoled by remember { viewModel.isAmoled } + val isGradient by remember { viewModel.isGradient } + val isAvatarGradient by remember { viewModel.isAvatarGradient } + val isNicknameColorful by remember { viewModel.isNicknameColorful } + val context = LocalContext.current + + MainScreenComponent( + isAmoled = isAmoled, + isGradient = isGradient, + isAvatarGradient = isAvatarGradient, + isNicknameColorful = isNicknameColorful, + setAmoled = { viewModel.setSettings(Constants.SHARED_IS_AMOLED, it) }, + setGradient = { viewModel.setSettings(Constants.SHARED_USE_GRADIENT, it) }, + setAvatarGradient = { viewModel.setSettings(Constants.SHARED_USE_GRADIENT_AVATARS, it) }, + setNicknameColorful = { viewModel.setSettings(Constants.SHARED_USE_COLORFUL_NICKNAME, it) }, + onShareTheme = { isTg, isLight -> viewModel.onShareTheme(context, isTg, isLight) }, + goHowUse = goHowUse + ) +} + +@Composable +private fun MainScreenComponent( + isAmoled: Boolean, + isGradient: Boolean, + isAvatarGradient: Boolean, + isNicknameColorful: Boolean, + setAmoled: (value: Boolean) -> Unit, + setGradient: (value: Boolean) -> Unit, + setAvatarGradient: (value: Boolean) -> Unit, + setNicknameColorful: (value: Boolean) -> Unit, + onShareTheme: (isTelegram: Boolean, isLight: Boolean) -> Unit, + goHowUse: () -> Unit +) { + + val scrollBehavior = + TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState()) + + Scaffold( + modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), + topBar = { + TopAppBar(scrollBehavior = scrollBehavior, goHowUse = goHowUse) + } + ) { pad -> + + LazyColumn( + modifier = Modifier + .fillMaxSize() + .padding(pad) + ) { + + item { + CreateThemeCard( + title = R.string.light_theme, + description = R.string.light_theme_description, + icon = R.drawable.theme_icon_light, + onTelegramClick = { + onShareTheme(true, true) + }, + onTelegramXClick = { + onShareTheme(false, true) + } + ) + } + + item { + CreateThemeCard( + title = R.string.dark_theme, + description = R.string.dark_theme_description, + icon = R.drawable.theme_icon_dark, + onTelegramClick = { + onShareTheme(true, false) + }, + onTelegramXClick = { + onShareTheme(false, false) + } + ) + } + + item { + SettingsCard( + isAmoled = isAmoled, + isGradient = isGradient, + isAvatarGradient = isAvatarGradient, + isNicknameColorful = isNicknameColorful, + setAmoled = setAmoled, + setGradient = setGradient, + setAvatarGradient = setAvatarGradient, + setNicknameColorful = setNicknameColorful + ) + } + + item { + AboutCard() + } + + } + + } +} + +@Preview +@Composable +private fun MainScreenPreview() { + MainScreenComponent( + isAmoled = true, + isGradient = false, + isAvatarGradient = true, + isNicknameColorful = false, + setAmoled = { }, + setGradient = { }, + setAvatarGradient = { }, + setNicknameColorful = { }, + onShareTheme = {_, _ ->}, + goHowUse = {} + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/MainScreenViewModel.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/MainScreenViewModel.kt new file mode 100644 index 0000000..593f4d6 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/MainScreenViewModel.kt @@ -0,0 +1,98 @@ +package com.c3r5b8.telegram_monet.presentation.main_screen + +import android.content.Context +import android.content.SharedPreferences +import androidx.compose.runtime.mutableStateOf +import androidx.lifecycle.ViewModel +import com.c3r5b8.telegram_monet.adapters.createTheme +import com.c3r5b8.telegram_monet.common.Constants +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch + +class MainScreenViewModel( + contextParam: Context +) : ViewModel() { + + var isAmoled = mutableStateOf(false) + var isGradient = mutableStateOf(false) + var isAvatarGradient = mutableStateOf(false) + var isNicknameColorful = mutableStateOf(false) + + private val sharedPreferences: SharedPreferences = + contextParam.getSharedPreferences(Constants.SHARED_PREF, Context.MODE_PRIVATE) + + fun onShareTheme(context: Context, isTelegram: Boolean, isLight: Boolean) { + + val inputFileName = when { + isTelegram && isLight -> { + Constants.INPUT_FILE_TELEGRAM_LIGHT + } + isTelegram -> { + Constants.INPUT_FILE_TELEGRAM_DARK + } + !isTelegram && isLight -> { + Constants.INPUT_FILE_TELEGRAM_X_LIGHT + } + else -> { + Constants.INPUT_FILE_TELEGRAM_X_DARK + } + } + + val outputFileName = when { + isTelegram && isLight -> { + Constants.OUTPUT_FILE_TELEGRAM_LIGHT + } + isTelegram && !isAmoled.value -> { + Constants.OUTPUT_FILE_TELEGRAM_DARK + } + isTelegram -> { + Constants.OUTPUT_FILE_TELEGRAM_AMOLED + } + !isTelegram && isLight -> { + Constants.OUTPUT_FILE_TELEGRAM_X_LIGHT + } + !isTelegram && !isAmoled.value -> { + Constants.OUTPUT_FILE_TELEGRAM_X_DARK + } + else -> { + Constants.OUTPUT_FILE_TELEGRAM_X_AMOLED + } + } + + CoroutineScope(Dispatchers.IO).launch { + createTheme( + context = context, + isTelegram = isTelegram, + isAmoled = isAmoled.value, + isGradient = isGradient.value, + isAvatarGradient = isAvatarGradient.value, + isNicknameColorful = isNicknameColorful.value, + inputFileName = inputFileName, + outputFileName = outputFileName, + ) + } + } + + init { + getSettings() + } + + fun setSettings(settings: String, value: Boolean) { + when (settings) { + Constants.SHARED_IS_AMOLED -> isAmoled.value = value + Constants.SHARED_USE_GRADIENT -> isGradient.value = value + Constants.SHARED_USE_COLORFUL_NICKNAME -> isNicknameColorful.value = value + Constants.SHARED_USE_GRADIENT_AVATARS -> isAvatarGradient.value = value + } + sharedPreferences.edit().putBoolean(settings, value).apply() + } + + private fun getSettings() { + isAmoled.value = sharedPreferences.getBoolean("isAmoledMode", false) + isGradient.value = sharedPreferences.getBoolean("useGradient", false) + isAvatarGradient.value = sharedPreferences.getBoolean("useGradientAvatars", false) + isNicknameColorful.value = sharedPreferences.getBoolean("useColorNick", true) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/AboutCard.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/AboutCard.kt new file mode 100644 index 0000000..2ac1e6f --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/AboutCard.kt @@ -0,0 +1,89 @@ +package com.c3r5b8.telegram_monet.presentation.main_screen.components + +import android.content.Intent +import android.net.Uri +import androidx.annotation.StringRes +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.Constraints +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.c3r5b8.telegram_monet.R +import com.c3r5b8.telegram_monet.common.Constants + +@Composable +fun AboutCard( + +) { + + val localContext = LocalContext.current + + val openLink: (link: String) -> Unit = { link -> + val i = Intent(Intent.ACTION_VIEW) + i.data = Uri.parse(link) + localContext.startActivity(i) + } + + BasicCard( + title = R.string.about_card_title, + icon = R.drawable.about_icon, + description = R.string.about_card_description + ) { + + Text( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 12.dp), + text = stringResource(R.string.about_card_description), + fontSize = 14.sp + ) + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + ) { + CardButton(R.string.about_card_telegram) { + openLink(Constants.URL_TELEGRAM) + } + CardButton(R.string.about_card_github) { + openLink(Constants.URL_GITHUB) + } + } + + } +} + + +@Composable +private fun CardButton( + @StringRes text: Int, + onClick: () -> Unit, +) { + Button( + modifier = Modifier.padding(end = 8.dp), + onClick = { onClick() } + ) { + Text( + stringResource(text) + ) + } +} + + + +@Preview +@Composable +private fun AboutCardPreview() { + + AboutCard( + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/BasicCard.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/BasicCard.kt new file mode 100644 index 0000000..aa4bf15 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/BasicCard.kt @@ -0,0 +1,56 @@ +package com.c3r5b8.telegram_monet.presentation.main_screen.components + +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Card +import androidx.compose.material3.ElevatedCard +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +@Composable +fun BasicCard( + @StringRes title: Int, + @StringRes description: Int, + @DrawableRes icon: Int, + content: @Composable () -> Unit +) { + ElevatedCard ( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 8.dp, vertical = 8.dp), + shape = RoundedCornerShape(32.dp) + ) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp) + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + Icon( + painter = painterResource(icon), + contentDescription = stringResource(description), + ) + Text( + text = stringResource(title), + modifier = Modifier.padding(start = 8.dp), + fontSize = 18.sp + ) + } + content() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/CreateThemeCard.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/CreateThemeCard.kt new file mode 100644 index 0000000..d9154da --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/CreateThemeCard.kt @@ -0,0 +1,88 @@ +package com.c3r5b8.telegram_monet.presentation.main_screen.components + +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.c3r5b8.telegram_monet.R + +@Composable +fun CreateThemeCard( + @StringRes title: Int, + @StringRes description: Int, + @DrawableRes icon: Int, + onTelegramClick: () -> Unit, + onTelegramXClick: () -> Unit, +) { + BasicCard( + title = title, + icon = icon, + description = description + ) { + Text( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 12.dp), + text = stringResource(description), + fontSize = 14.sp + ) + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + ) { + CardButton(R.string.setup_telegram, onTelegramClick) + CardButton(R.string.setup_telegram_x, onTelegramXClick) + } + } +} + +@Composable +private fun CardButton( + @StringRes text: Int, + onClick: () -> Unit, +) { + Button( + modifier = Modifier.padding(end = 8.dp), + onClick = { onClick() } + ) { + Text( + stringResource(text) + ) + } +} + + +@Preview +@Composable +private fun CreateCardPreview1() { + CreateThemeCard( + title = R.string.light_theme, + description = R.string.light_theme_description, + icon = R.drawable.theme_icon_light, + onTelegramClick = {}, + onTelegramXClick = {}, + ) +} + +@Preview +@Composable +private fun CreateCardPreview2() { + CreateThemeCard( + title = R.string.dark_theme, + description = R.string.dark_theme_description, + icon = R.drawable.theme_icon_dark, + onTelegramClick = {}, + onTelegramXClick = {}, + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/SettingsCard.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/SettingsCard.kt new file mode 100644 index 0000000..9f26916 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/SettingsCard.kt @@ -0,0 +1,110 @@ +package com.c3r5b8.telegram_monet.presentation.main_screen.components + +import androidx.annotation.StringRes +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.Switch +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import com.c3r5b8.telegram_monet.R +import com.c3r5b8.telegram_monet.presentation.components.bounceClick + +@Composable +fun SettingsCard( + isAmoled: Boolean, + isGradient: Boolean, + isAvatarGradient: Boolean, + isNicknameColorful: Boolean, + setAmoled: (value: Boolean) -> Unit, + setGradient: (value: Boolean) -> Unit, + setAvatarGradient: (value: Boolean) -> Unit, + setNicknameColorful: (value: Boolean) -> Unit, +) { + + BasicCard( + title = R.string.settings_card_title, + icon = R.drawable.icon_settings, + description = R.string.settings_card_title + ) { + + SettingItem( + R.string.settings_card_switch_amoled, + isAmoled, + setAmoled + ) + + SettingItem( + R.string.settings_card_use_gradient, + isGradient, + setGradient + ) + + SettingItem( + R.string.settings_card_use_gradient_avatars, + isAvatarGradient, + setAvatarGradient + ) + + SettingItem( + R.string.settings_card_monet_nick, + isNicknameColorful, + setNicknameColorful + ) + } +} + +@Composable +private fun SettingItem( + @StringRes text: Int, + isChecked: Boolean, + onClick: (state: Boolean) -> Unit, +) { + Row( + modifier = Modifier + .fillMaxWidth() + .bounceClick(0.9f) { + onClick(!isChecked) + }, + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + stringResource(text) + ) + + Switch( + checked = isChecked, + onCheckedChange = { state -> onClick(state) } + ) + } +} + +@Preview +@Composable +private fun SettingsPreview() { + + var isAmoled by remember { mutableStateOf(false) } + var isGradient by remember { mutableStateOf(true) } + var isAvatarGradient by remember { mutableStateOf(false) } + var isNicknameColorful by remember { mutableStateOf(true) } + + SettingsCard( + isAmoled = isAmoled, + isGradient = isGradient, + isAvatarGradient = isAvatarGradient, + isNicknameColorful = isNicknameColorful, + setAmoled = { isAmoled = it}, + setGradient = { isGradient = it}, + setAvatarGradient = { isAvatarGradient = it}, + setNicknameColorful = { isNicknameColorful = it} + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/TopAppBar.kt b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/TopAppBar.kt new file mode 100644 index 0000000..7022c7d --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/presentation/main_screen/components/TopAppBar.kt @@ -0,0 +1,48 @@ +package com.c3r5b8.telegram_monet.presentation.main_screen.components + +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LargeTopAppBar +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarScrollBehavior +import androidx.compose.material3.rememberTopAppBarState +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview +import com.c3r5b8.telegram_monet.R + +@Composable +fun TopAppBar( + scrollBehavior: TopAppBarScrollBehavior, + goHowUse: () -> Unit +) { + LargeTopAppBar( + title = { + Text( + text = stringResource(R.string.app_name), + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + }, + actions = { + IconButton(onClick = { goHowUse() }) { + Icon( + painterResource(R.drawable.how_to_use_icon), + stringResource(R.string.how_to_use) + ) + } + }, + scrollBehavior = scrollBehavior + ) +} + +@Preview +@Composable +private fun TopAppBarPreview() { + TopAppBar( + TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState()) + ){} +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Color.kt b/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Color.kt new file mode 100644 index 0000000..a2d4ebf --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package com.c3r5b8.telegram_monet.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Theme.kt b/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Theme.kt new file mode 100644 index 0000000..e140d22 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Theme.kt @@ -0,0 +1,57 @@ +package com.c3r5b8.telegram_monet.ui.theme + +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun TelegramMonetTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Type.kt b/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Type.kt new file mode 100644 index 0000000..ad121c1 --- /dev/null +++ b/app/src/main/java/com/c3r5b8/telegram_monet/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.c3r5b8.telegram_monet.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/app/src/main/res/drawable/round_palette_24.xml b/app/src/main/res/drawable/about_icon.xml similarity index 91% rename from app/src/main/res/drawable/round_palette_24.xml rename to app/src/main/res/drawable/about_icon.xml index 0d97f03..9bc3301 100644 --- a/app/src/main/res/drawable/round_palette_24.xml +++ b/app/src/main/res/drawable/about_icon.xml @@ -2,8 +2,7 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24" - android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + android:viewportHeight="24"> diff --git a/app/src/main/res/drawable/how_to_use_icon.xml b/app/src/main/res/drawable/how_to_use_icon.xml new file mode 100644 index 0000000..9dde6fa --- /dev/null +++ b/app/src/main/res/drawable/how_to_use_icon.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_foreground.xml b/app/src/main/res/drawable/ic_foreground.xml index 9025de2..b086fdd 100644 --- a/app/src/main/res/drawable/ic_foreground.xml +++ b/app/src/main/res/drawable/ic_foreground.xml @@ -1,15 +1,15 @@ - + android:viewportWidth="52" + android:viewportHeight="52"> + diff --git a/app/src/main/res/drawable/ic_foreground_monochrome.xml b/app/src/main/res/drawable/ic_foreground_monochrome.xml index 720245e..7802634 100644 --- a/app/src/main/res/drawable/ic_foreground_monochrome.xml +++ b/app/src/main/res/drawable/ic_foreground_monochrome.xml @@ -1,15 +1,15 @@ - + android:viewportWidth="52" + android:viewportHeight="52"> + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_settings_24.xml b/app/src/main/res/drawable/icon_settings.xml similarity index 93% rename from app/src/main/res/drawable/ic_baseline_settings_24.xml rename to app/src/main/res/drawable/icon_settings.xml index d99a8ae..ea7e236 100644 --- a/app/src/main/res/drawable/ic_baseline_settings_24.xml +++ b/app/src/main/res/drawable/icon_settings.xml @@ -2,8 +2,7 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24" - android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + android:viewportHeight="24"> diff --git a/app/src/main/res/drawable/round_dark_mode_24.xml b/app/src/main/res/drawable/theme_icon_dark.xml similarity index 86% rename from app/src/main/res/drawable/round_dark_mode_24.xml rename to app/src/main/res/drawable/theme_icon_dark.xml index 7c2afbf..72f10fa 100644 --- a/app/src/main/res/drawable/round_dark_mode_24.xml +++ b/app/src/main/res/drawable/theme_icon_dark.xml @@ -2,8 +2,7 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24" - android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + android:viewportHeight="24"> diff --git a/app/src/main/res/drawable/round_light_mode_24.xml b/app/src/main/res/drawable/theme_icon_light.xml similarity index 94% rename from app/src/main/res/drawable/round_light_mode_24.xml rename to app/src/main/res/drawable/theme_icon_light.xml index a826abd..df83e15 100644 --- a/app/src/main/res/drawable/round_light_mode_24.xml +++ b/app/src/main/res/drawable/theme_icon_light.xml @@ -3,8 +3,7 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24" - android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + android:viewportHeight="24"> - - - - - - - - - -