From c2f7850e16de028ed5e3650349c2fb62b9778fce Mon Sep 17 00:00:00 2001 From: aikrq <95296093+aikrq@users.noreply.github.com> Date: Sun, 3 Nov 2024 18:28:29 +0700 Subject: [PATCH] feat: Small improvements & deprecate custom schemes --- app/build.gradle.kts | 27 ---------- .../main/kotlin/org/cosmicide/MainActivity.kt | 18 ------- .../cosmicide/fragment/CompileInfoFragment.kt | 1 - .../org/cosmicide/fragment/EditorFragment.kt | 4 -- .../org/cosmicide/fragment/GitFragment.kt | 1 - .../fragment/InstallResourcesFragment.kt | 1 - .../cosmicide/fragment/NewProjectFragment.kt | 2 - .../org/cosmicide/fragment/ProjectFragment.kt | 4 -- .../fragment/ProjectOutputFragment.kt | 3 -- .../fragment/settings/AboutSettings.kt | 1 - .../settings/PluginSettingsProvider.kt | 2 - .../kotlin/org/cosmicide/util/CommonUtils.kt | 12 ----- app/src/main/res/layout/activity_main.xml | 13 ++--- .../main/res/values-night/themes_custom.xml | 49 ------------------- app/src/main/res/values-v27/themes.xml | 2 - app/src/main/res/values-v31/themes.xml | 8 +-- app/src/main/res/values/styles.xml | 3 -- app/src/main/res/values/themes.xml | 13 ++--- app/src/main/res/values/themes_custom.xml | 49 ------------------- build.gradle.kts | 1 - .../cosmicide/common/BaseBindingFragment.kt | 2 +- .../main/java/org/cosmicide/common/Prefs.kt | 3 -- 22 files changed, 14 insertions(+), 205 deletions(-) delete mode 100644 app/src/main/res/values-night/themes_custom.xml delete mode 100644 app/src/main/res/values/themes_custom.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f099547f5..0a17b753f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -8,7 +8,6 @@ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") - id("dev.rikka.tools.materialthemebuilder") id("com.google.gms.google-services") } @@ -147,32 +146,6 @@ fun getGitCommit(): String { } } -materialThemeBuilder { - themes { - for ((name, color) in listOf( - "Pyro" to "#EF7A35", - "indigo" to "#3F51B5", - "flamingo" to "#E91E63", - "mint" to "#009688", - "emerald" to "#4CAF50", - "azure" to "#2196F3", - )) { - create(name) { - primaryColor = color - lightThemeFormat = "Theme.CosmicIde.%s.Light" - lightThemeParent = "Theme.CosmicIde" - darkThemeFormat = "Theme.CosmicIde.%s.Dark" - darkThemeParent = "Theme.CosmicIde" - - isDynamicColors = false - } - } - } - - generatePaletteAttributes = true - packageName = "org.cosmicide" -} - configurations.all { resolutionStrategy.force("com.squareup.okhttp3:okhttp:4.12.0") resolutionStrategy.force("com.google.guava:guava:33.1.0-android") diff --git a/app/src/main/kotlin/org/cosmicide/MainActivity.kt b/app/src/main/kotlin/org/cosmicide/MainActivity.kt index 0d26efe52..5251660e7 100644 --- a/app/src/main/kotlin/org/cosmicide/MainActivity.kt +++ b/app/src/main/kotlin/org/cosmicide/MainActivity.kt @@ -39,27 +39,9 @@ import rikka.shizuku.ShizukuProvider class MainActivity : AppCompatActivity() { - var themeInt = 0 private lateinit var binding: ActivityMainBinding val shizukuPermissionCode = 1 - override fun onCreateView( - parent: View?, - name: String, - context: Context, - attrs: AttributeSet - ): View? { - val accent = Prefs.appAccent - - themeInt = CommonUtils.getAccent(accent) - setTheme(themeInt) - - if (themeInt == R.style.Theme_CosmicIde) - DynamicColors.applyToActivityIfAvailable(this) - - return super.onCreateView(parent, name, context, attrs) - } - override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() diff --git a/app/src/main/kotlin/org/cosmicide/fragment/CompileInfoFragment.kt b/app/src/main/kotlin/org/cosmicide/fragment/CompileInfoFragment.kt index a623e766d..9e9b3da04 100644 --- a/app/src/main/kotlin/org/cosmicide/fragment/CompileInfoFragment.kt +++ b/app/src/main/kotlin/org/cosmicide/fragment/CompileInfoFragment.kt @@ -92,7 +92,6 @@ class CompileInfoFragment : BaseBindingFragment() { parentFragmentManager.commit { add(R.id.fragment_container, ProjectOutputFragment()) addToBackStack(null) - setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } } } diff --git a/app/src/main/kotlin/org/cosmicide/fragment/EditorFragment.kt b/app/src/main/kotlin/org/cosmicide/fragment/EditorFragment.kt index a8a760268..cc9706067 100644 --- a/app/src/main/kotlin/org/cosmicide/fragment/EditorFragment.kt +++ b/app/src/main/kotlin/org/cosmicide/fragment/EditorFragment.kt @@ -386,7 +386,6 @@ class EditorFragment : BaseBindingFragment() { parentFragmentManager.commit { add(R.id.fragment_container, ChatFragment()) addToBackStack(null) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } true } @@ -395,7 +394,6 @@ class EditorFragment : BaseBindingFragment() { parentFragmentManager.commit { add(R.id.fragment_container, GitFragment()) addToBackStack(null) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } true } @@ -604,7 +602,6 @@ class EditorFragment : BaseBindingFragment() { parentFragmentManager.commit { add(R.id.fragment_container, CompileInfoFragment()) addToBackStack(null) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } } @@ -612,7 +609,6 @@ class EditorFragment : BaseBindingFragment() { parentFragmentManager.commit { add(R.id.fragment_container, SettingsFragment()) addToBackStack(null) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } } diff --git a/app/src/main/kotlin/org/cosmicide/fragment/GitFragment.kt b/app/src/main/kotlin/org/cosmicide/fragment/GitFragment.kt index 02089bb55..2ba96390a 100644 --- a/app/src/main/kotlin/org/cosmicide/fragment/GitFragment.kt +++ b/app/src/main/kotlin/org/cosmicide/fragment/GitFragment.kt @@ -96,7 +96,6 @@ class GitFragment : BaseBindingFragment() { parentFragmentManager.popBackStack() parentFragmentManager.commit { replace(R.id.fragment_container, SettingsFragment()).addToBackStack(null) - setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } }.setNegativeButton("No") { _, _ -> parentFragmentManager.popBackStack() diff --git a/app/src/main/kotlin/org/cosmicide/fragment/InstallResourcesFragment.kt b/app/src/main/kotlin/org/cosmicide/fragment/InstallResourcesFragment.kt index 575794eae..57893281b 100644 --- a/app/src/main/kotlin/org/cosmicide/fragment/InstallResourcesFragment.kt +++ b/app/src/main/kotlin/org/cosmicide/fragment/InstallResourcesFragment.kt @@ -52,7 +52,6 @@ class InstallResourcesFragment : BaseBindingFragment() { if (success) { parentFragmentManager.commit { remove(this@NewProjectFragment) - setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) } } } @@ -104,7 +103,6 @@ class NewProjectFragment : BaseBindingFragment() { parentFragmentManager.commit { add(R.id.fragment_container, EditorFragment.newInstance(project)) addToBackStack(null) - setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } } diff --git a/app/src/main/kotlin/org/cosmicide/fragment/ProjectFragment.kt b/app/src/main/kotlin/org/cosmicide/fragment/ProjectFragment.kt index 237797a88..f95065fc5 100644 --- a/app/src/main/kotlin/org/cosmicide/fragment/ProjectFragment.kt +++ b/app/src/main/kotlin/org/cosmicide/fragment/ProjectFragment.kt @@ -130,7 +130,6 @@ class ProjectFragment : BaseBindingFragment(), parentFragmentManager.commit { replace(R.id.fragment_container, SettingsFragment()) addToBackStack(null) - setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } true } @@ -262,7 +261,6 @@ class ProjectFragment : BaseBindingFragment(), setPositiveButton("Ok") { _, _ -> parentFragmentManager.commit { replace(R.id.fragment_container, SettingsFragment()) - setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } } show() @@ -403,7 +401,6 @@ class ProjectFragment : BaseBindingFragment(), parentFragmentManager.commit { add(R.id.fragment_container, NewProjectFragment()) addToBackStack(null) - setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } } @@ -415,7 +412,6 @@ class ProjectFragment : BaseBindingFragment(), } }) addToBackStack(null) - setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } } } diff --git a/app/src/main/kotlin/org/cosmicide/fragment/ProjectOutputFragment.kt b/app/src/main/kotlin/org/cosmicide/fragment/ProjectOutputFragment.kt index a17c280b5..17982911c 100644 --- a/app/src/main/kotlin/org/cosmicide/fragment/ProjectOutputFragment.kt +++ b/app/src/main/kotlin/org/cosmicide/fragment/ProjectOutputFragment.kt @@ -46,7 +46,6 @@ class ProjectOutputFragment : BaseBindingFragment() if (isRunning) { parentFragmentManager.commit { replace(R.id.fragment_container, ProjectOutputFragment()) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) } } text.insert(text.cursor.rightLine, text.cursor.rightColumn, "--- Stopped ---\n") @@ -57,7 +56,6 @@ class ProjectOutputFragment : BaseBindingFragment() R.id.cancel -> { parentFragmentManager.commit { remove(this@ProjectOutputFragment) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) } true } @@ -74,7 +72,6 @@ class ProjectOutputFragment : BaseBindingFragment() binding.toolbar.setNavigationOnClickListener { parentFragmentManager.commit { remove(this@ProjectOutputFragment) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) } } diff --git a/app/src/main/kotlin/org/cosmicide/fragment/settings/AboutSettings.kt b/app/src/main/kotlin/org/cosmicide/fragment/settings/AboutSettings.kt index ae8c45ad3..136ea18fa 100644 --- a/app/src/main/kotlin/org/cosmicide/fragment/settings/AboutSettings.kt +++ b/app/src/main/kotlin/org/cosmicide/fragment/settings/AboutSettings.kt @@ -238,7 +238,6 @@ class AboutSettings(private val activity: FragmentActivity) : SettingsProvider { activity.supportFragmentManager.commit { replace(R.id.fragment_container, InstallResourcesFragment()) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) } } } diff --git a/app/src/main/kotlin/org/cosmicide/fragment/settings/PluginSettingsProvider.kt b/app/src/main/kotlin/org/cosmicide/fragment/settings/PluginSettingsProvider.kt index fc0737e3f..ae6f975ab 100644 --- a/app/src/main/kotlin/org/cosmicide/fragment/settings/PluginSettingsProvider.kt +++ b/app/src/main/kotlin/org/cosmicide/fragment/settings/PluginSettingsProvider.kt @@ -39,7 +39,6 @@ class PluginSettingsProvider(private val activity: FragmentActivity) : SettingsP activity.supportFragmentManager.commit { add(R.id.fragment_container, PluginListFragment()) addToBackStack(null) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } true } @@ -52,7 +51,6 @@ class PluginSettingsProvider(private val activity: FragmentActivity) : SettingsP activity.supportFragmentManager.commit { add(R.id.fragment_container, PluginsFragment()) addToBackStack(null) - setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) } true } diff --git a/app/src/main/kotlin/org/cosmicide/util/CommonUtils.kt b/app/src/main/kotlin/org/cosmicide/util/CommonUtils.kt index a72714dcf..749ff592b 100644 --- a/app/src/main/kotlin/org/cosmicide/util/CommonUtils.kt +++ b/app/src/main/kotlin/org/cosmicide/util/CommonUtils.kt @@ -66,18 +66,6 @@ object CommonUtils { .usePlugin(HtmlPlugin.create()) .build() - fun getAccent(accent: String): Int { - return when (accent) { - "default" -> R.style.Theme_CosmicIde - "pyro" -> R.style.Theme_CosmicIde_Pyro - "indigo" -> R.style.Theme_CosmicIde_Indigo - "flamingo" -> R.style.Theme_CosmicIde_Flamingo - "mint" -> R.style.Theme_CosmicIde_Mint - "emerald" -> R.style.Theme_CosmicIde_Emerald - else -> R.style.Theme_CosmicIde - } - } - fun Activity.isShizukuGranted(): Boolean { if (Shizuku.pingBinder().not()) { Log.d("Shizuku", "Shizuku not installed") diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 261468cb4..9b641dc8c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,15 +4,8 @@ ~ Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ~ You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see . --> - - - - - + android:background="?colorSurfaceContainerLow" /> diff --git a/app/src/main/res/values-night/themes_custom.xml b/app/src/main/res/values-night/themes_custom.xml deleted file mode 100644 index 006dee5ad..000000000 --- a/app/src/main/res/values-night/themes_custom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app/src/main/res/values-v27/themes.xml b/app/src/main/res/values-v27/themes.xml index a493c29b1..2dda81c74 100644 --- a/app/src/main/res/values-v27/themes.xml +++ b/app/src/main/res/values-v27/themes.xml @@ -4,9 +4,7 @@ ~ Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ~ You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see . --> - - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index a1de986fc..39565f67e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -4,12 +4,9 @@ ~ Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ~ You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see . --> - - - diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index f248b7262..4fc08379a 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -4,20 +4,17 @@ ~ Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ~ You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see . --> - - - - - - - - - - - - diff --git a/build.gradle.kts b/build.gradle.kts index 93c88c125..b04e83107 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,6 @@ plugins { id("com.android.library") version "8.6.0" apply false id("org.jetbrains.kotlin.android") version "2.0.0" apply false id("org.jetbrains.kotlin.jvm") version "2.0.0" apply false - id("dev.rikka.tools.materialthemebuilder") version "1.4.1" apply false } buildscript { diff --git a/common/src/main/java/org/cosmicide/common/BaseBindingFragment.kt b/common/src/main/java/org/cosmicide/common/BaseBindingFragment.kt index 574a91faf..45d8334bf 100644 --- a/common/src/main/java/org/cosmicide/common/BaseBindingFragment.kt +++ b/common/src/main/java/org/cosmicide/common/BaseBindingFragment.kt @@ -30,7 +30,7 @@ abstract class BaseBindingFragment : Fragment() { @CallSuper override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - // applyTransitions() + applyTransitions() if (isBackHandled.not()) { requireActivity().onBackPressedDispatcher.addCallback(this) { diff --git a/common/src/main/java/org/cosmicide/common/Prefs.kt b/common/src/main/java/org/cosmicide/common/Prefs.kt index 2a129ce10..cc3764c79 100644 --- a/common/src/main/java/org/cosmicide/common/Prefs.kt +++ b/common/src/main/java/org/cosmicide/common/Prefs.kt @@ -33,9 +33,6 @@ object Prefs { val appTheme: String get() = prefs.getString("app_theme", "auto") ?: "auto" - val appAccent: String - get() = prefs.getString("app_accent", "default") ?: "default" - val useFastJarFs: Boolean get() = prefs.getBoolean("use_fastjarfs", true)