Skip to content

Commit 7b289b6

Browse files
committed
feat: Small improvements & deprecate custom schemes
1 parent 539bb4a commit 7b289b6

23 files changed

+15
-206
lines changed

app/build.gradle.kts

-27
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
plugins {
99
id("com.android.application")
1010
id("org.jetbrains.kotlin.android")
11-
id("dev.rikka.tools.materialthemebuilder")
1211
id("com.google.gms.google-services")
1312
}
1413

@@ -147,32 +146,6 @@ fun getGitCommit(): String {
147146
}
148147
}
149148

150-
materialThemeBuilder {
151-
themes {
152-
for ((name, color) in listOf(
153-
"Pyro" to "#EF7A35",
154-
"indigo" to "#3F51B5",
155-
"flamingo" to "#E91E63",
156-
"mint" to "#009688",
157-
"emerald" to "#4CAF50",
158-
"azure" to "#2196F3",
159-
)) {
160-
create(name) {
161-
primaryColor = color
162-
lightThemeFormat = "Theme.CosmicIde.%s.Light"
163-
lightThemeParent = "Theme.CosmicIde"
164-
darkThemeFormat = "Theme.CosmicIde.%s.Dark"
165-
darkThemeParent = "Theme.CosmicIde"
166-
167-
isDynamicColors = false
168-
}
169-
}
170-
}
171-
172-
generatePaletteAttributes = true
173-
packageName = "org.cosmicide"
174-
}
175-
176149
configurations.all {
177150
resolutionStrategy.force("com.squareup.okhttp3:okhttp:4.12.0")
178151
resolutionStrategy.force("com.google.guava:guava:33.1.0-android")

app/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
android:label="@string/app_name"
3838
android:roundIcon="@mipmap/ic_launcher_round"
3939
android:supportsRtl="true"
40-
android:theme="@style/Theme.CosmicIde.Flamingo.Light"
40+
android:theme="@style/Theme.CosmicIde"
4141
tools:targetApi="34">
4242

4343
<provider

app/src/main/kotlin/org/cosmicide/MainActivity.kt

-18
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,9 @@ import rikka.shizuku.ShizukuProvider
3939

4040
class MainActivity : AppCompatActivity() {
4141

42-
var themeInt = 0
4342
private lateinit var binding: ActivityMainBinding
4443
val shizukuPermissionCode = 1
4544

46-
override fun onCreateView(
47-
parent: View?,
48-
name: String,
49-
context: Context,
50-
attrs: AttributeSet
51-
): View? {
52-
val accent = Prefs.appAccent
53-
54-
themeInt = CommonUtils.getAccent(accent)
55-
setTheme(themeInt)
56-
57-
if (themeInt == R.style.Theme_CosmicIde)
58-
DynamicColors.applyToActivityIfAvailable(this)
59-
60-
return super.onCreateView(parent, name, context, attrs)
61-
}
62-
6345
override fun onCreate(savedInstanceState: Bundle?) {
6446
installSplashScreen()
6547

app/src/main/kotlin/org/cosmicide/fragment/CompileInfoFragment.kt

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class CompileInfoFragment : BaseBindingFragment<FragmentCompileInfoBinding>() {
9292
parentFragmentManager.commit {
9393
add(R.id.fragment_container, ProjectOutputFragment())
9494
addToBackStack(null)
95-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
9695
}
9796
}
9897
}

app/src/main/kotlin/org/cosmicide/fragment/EditorFragment.kt

-4
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ class EditorFragment : BaseBindingFragment<FragmentEditorBinding>() {
386386
parentFragmentManager.commit {
387387
add(R.id.fragment_container, ChatFragment())
388388
addToBackStack(null)
389-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
390389
}
391390
true
392391
}
@@ -395,7 +394,6 @@ class EditorFragment : BaseBindingFragment<FragmentEditorBinding>() {
395394
parentFragmentManager.commit {
396395
add(R.id.fragment_container, GitFragment())
397396
addToBackStack(null)
398-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
399397
}
400398
true
401399
}
@@ -604,15 +602,13 @@ class EditorFragment : BaseBindingFragment<FragmentEditorBinding>() {
604602
parentFragmentManager.commit {
605603
add(R.id.fragment_container, CompileInfoFragment())
606604
addToBackStack(null)
607-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
608605
}
609606
}
610607

611608
private fun navigateToSettingsFragment() {
612609
parentFragmentManager.commit {
613610
add(R.id.fragment_container, SettingsFragment())
614611
addToBackStack(null)
615-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
616612
}
617613
}
618614

app/src/main/kotlin/org/cosmicide/fragment/GitFragment.kt

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class GitFragment : BaseBindingFragment<FragmentGitBinding>() {
9696
parentFragmentManager.popBackStack()
9797
parentFragmentManager.commit {
9898
replace(R.id.fragment_container, SettingsFragment()).addToBackStack(null)
99-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
10099
}
101100
}.setNegativeButton("No") { _, _ ->
102101
parentFragmentManager.popBackStack()

app/src/main/kotlin/org/cosmicide/fragment/InstallResourcesFragment.kt

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class InstallResourcesFragment : BaseBindingFragment<InstallResourcesFragmentBin
5252
withContext(Dispatchers.Main) {
5353
parentFragmentManager.commit {
5454
replace(R.id.fragment_container, ProjectFragment())
55-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
5655
}
5756
}
5857
}

app/src/main/kotlin/org/cosmicide/fragment/NewProjectFragment.kt

-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class NewProjectFragment : BaseBindingFragment<FragmentNewProjectBinding>() {
6868
if (success) {
6969
parentFragmentManager.commit {
7070
remove(this@NewProjectFragment)
71-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
7271
}
7372
}
7473
}
@@ -104,7 +103,6 @@ class NewProjectFragment : BaseBindingFragment<FragmentNewProjectBinding>() {
104103
parentFragmentManager.commit {
105104
add(R.id.fragment_container, EditorFragment.newInstance(project))
106105
addToBackStack(null)
107-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
108106
}
109107
}
110108

app/src/main/kotlin/org/cosmicide/fragment/ProjectFragment.kt

-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ class ProjectFragment : BaseBindingFragment<FragmentProjectBinding>(),
130130
parentFragmentManager.commit {
131131
replace(R.id.fragment_container, SettingsFragment())
132132
addToBackStack(null)
133-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
134133
}
135134
true
136135
}
@@ -262,7 +261,6 @@ class ProjectFragment : BaseBindingFragment<FragmentProjectBinding>(),
262261
setPositiveButton("Ok") { _, _ ->
263262
parentFragmentManager.commit {
264263
replace(R.id.fragment_container, SettingsFragment())
265-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
266264
}
267265
}
268266
show()
@@ -403,7 +401,6 @@ class ProjectFragment : BaseBindingFragment<FragmentProjectBinding>(),
403401
parentFragmentManager.commit {
404402
add(R.id.fragment_container, NewProjectFragment())
405403
addToBackStack(null)
406-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
407404
}
408405
}
409406

@@ -415,7 +412,6 @@ class ProjectFragment : BaseBindingFragment<FragmentProjectBinding>(),
415412
}
416413
})
417414
addToBackStack(null)
418-
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
419415
}
420416
}
421417
}

app/src/main/kotlin/org/cosmicide/fragment/ProjectOutputFragment.kt

-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class ProjectOutputFragment : BaseBindingFragment<FragmentCompileInfoBinding>()
4646
if (isRunning) {
4747
parentFragmentManager.commit {
4848
replace(R.id.fragment_container, ProjectOutputFragment())
49-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
5049
}
5150
}
5251
text.insert(text.cursor.rightLine, text.cursor.rightColumn, "--- Stopped ---\n")
@@ -57,7 +56,6 @@ class ProjectOutputFragment : BaseBindingFragment<FragmentCompileInfoBinding>()
5756
R.id.cancel -> {
5857
parentFragmentManager.commit {
5958
remove(this@ProjectOutputFragment)
60-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
6159
}
6260
true
6361
}
@@ -74,7 +72,6 @@ class ProjectOutputFragment : BaseBindingFragment<FragmentCompileInfoBinding>()
7472
binding.toolbar.setNavigationOnClickListener {
7573
parentFragmentManager.commit {
7674
remove(this@ProjectOutputFragment)
77-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
7875
}
7976
}
8077

app/src/main/kotlin/org/cosmicide/fragment/settings/AboutSettings.kt

-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ class AboutSettings(private val activity: FragmentActivity) : SettingsProvider {
238238

239239
activity.supportFragmentManager.commit {
240240
replace(R.id.fragment_container, InstallResourcesFragment())
241-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
242241
}
243242
}
244243
}

app/src/main/kotlin/org/cosmicide/fragment/settings/PluginSettingsProvider.kt

-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class PluginSettingsProvider(private val activity: FragmentActivity) : SettingsP
3939
activity.supportFragmentManager.commit {
4040
add(R.id.fragment_container, PluginListFragment())
4141
addToBackStack(null)
42-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
4342
}
4443
true
4544
}
@@ -52,7 +51,6 @@ class PluginSettingsProvider(private val activity: FragmentActivity) : SettingsP
5251
activity.supportFragmentManager.commit {
5352
add(R.id.fragment_container, PluginsFragment())
5453
addToBackStack(null)
55-
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
5654
}
5755
true
5856
}

app/src/main/kotlin/org/cosmicide/util/CommonUtils.kt

-12
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,6 @@ object CommonUtils {
6666
.usePlugin(HtmlPlugin.create())
6767
.build()
6868

69-
fun getAccent(accent: String): Int {
70-
return when (accent) {
71-
"default" -> R.style.Theme_CosmicIde
72-
"pyro" -> R.style.Theme_CosmicIde_Pyro
73-
"indigo" -> R.style.Theme_CosmicIde_Indigo
74-
"flamingo" -> R.style.Theme_CosmicIde_Flamingo
75-
"mint" -> R.style.Theme_CosmicIde_Mint
76-
"emerald" -> R.style.Theme_CosmicIde_Emerald
77-
else -> R.style.Theme_CosmicIde
78-
}
79-
}
80-
8169
fun Activity.isShizukuGranted(): Boolean {
8270
if (Shizuku.pingBinder().not()) {
8371
Log.d("Shizuku", "Shizuku not installed")

app/src/main/res/layout/activity_main.xml

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,8 @@
44
~ 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.
55
~ You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
66
-->
7-
8-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
7+
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
8+
android:id="@+id/fragment_container"
99
android:layout_width="match_parent"
1010
android:layout_height="match_parent"
11-
android:background="?colorSurfaceContainerLow"
12-
android:orientation="vertical">
13-
14-
<androidx.fragment.app.FragmentContainerView
15-
android:id="@+id/fragment_container"
16-
android:layout_width="match_parent"
17-
android:layout_height="match_parent" />
18-
</LinearLayout>
11+
android:background="?colorSurfaceContainerLow" />

app/src/main/res/values-night/themes_custom.xml

-49
This file was deleted.

app/src/main/res/values-v27/themes.xml

-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
~ 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.
55
~ You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
66
-->
7-
87
<resources xmlns:tools="http://schemas.android.com/tools">
9-
108
<style name="Theme.CosmicIde.BaseV27" parent="Theme.CosmicIde.Base">
119
<item name="android:enforceNavigationBarContrast" tools:targetApi="q">false</item>
1210
<item name="android:navigationBarColor">@android:color/transparent</item>

app/src/main/res/values-v31/themes.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
<style name="Theme.CosmicIde" parent="Theme.CosmicIde.BaseV31" />
1515

1616
<style name="Theme.CosmicIde.Start" parent="Theme.SplashScreen">
17+
<!-- Android framework -->
18+
<item name="android:navigationBarColor">@color/logo_background</item>
19+
<item name="android:statusBarColor">@color/logo_background</item>
20+
1721
<item name="windowSplashScreenBackground">@color/logo_background</item>
18-
<item name="android:splashScreenTheme">@style/Theme.CosmicIde.Flamingo</item>
19-
<item name="windowSplashScreenIconBackgroundColor">?attr/colorSurface</item>
20-
<item name="postSplashScreenTheme">@style/Theme.CosmicIde.Pyro</item>
22+
<item name="postSplashScreenTheme">@style/Theme.CosmicIde</item>
2123
</style>
2224
</resources>

app/src/main/res/values/styles.xml

-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
~ 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.
55
~ You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
66
-->
7-
87
<resources>
9-
108
<style name="Widget.CosmicIde.ListItemCard" parent="Widget.Material3.CardView.Filled">
119
<item name="android:layout_marginHorizontal">16dp</item>
1210
<item name="android:layout_marginVertical">8dp</item>
1311
</style>
14-
1512
</resources>

app/src/main/res/values/themes.xml

+5-8
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@
44
~ 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.
55
~ You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
66
-->
7-
87
<resources>
9-
10-
<style name="Theme.CosmicIde.Base" parent="Theme.Material3.DayNight.NoActionBar">
11-
<item name="android:fontFamily">@font/inter</item>
8+
<style name="Theme.CosmicIde.Base" parent="Theme.Material3.DynamicColors.DayNight.NoActionBar">
9+
<!-- Android framework -->
1210
<item name="android:overScrollMode">never</item>
11+
<item name="android:navigationBarColor">@android:color/transparent</item>
1312
<item name="android:statusBarColor">@android:color/transparent</item>
1413

15-
<item name="android:navigationBarColor">
16-
@android:color/transparent
17-
</item>
14+
<!-- Font -->
15+
<item name="android:fontFamily">@font/inter</item>
1816
<item name="fontFamily">@font/inter</item>
1917
</style>
2018

2119
<style name="Theme.CosmicIde" parent="Theme.CosmicIde.Base" />
22-
2320
</resources>

0 commit comments

Comments
 (0)