Skip to content

Commit

Permalink
feat: Small improvements & deprecate custom schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq committed Nov 3, 2024
1 parent 539bb4a commit 7b289b6
Show file tree
Hide file tree
Showing 23 changed files with 15 additions and 206 deletions.
27 changes: 0 additions & 27 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CosmicIde.Flamingo.Light"
android:theme="@style/Theme.CosmicIde"
tools:targetApi="34">

<provider
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/kotlin/org/cosmicide/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class CompileInfoFragment : BaseBindingFragment<FragmentCompileInfoBinding>() {
parentFragmentManager.commit {
add(R.id.fragment_container, ProjectOutputFragment())
addToBackStack(null)
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}
}
4 changes: 0 additions & 4 deletions app/src/main/kotlin/org/cosmicide/fragment/EditorFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ class EditorFragment : BaseBindingFragment<FragmentEditorBinding>() {
parentFragmentManager.commit {
add(R.id.fragment_container, ChatFragment())
addToBackStack(null)
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
true
}
Expand All @@ -395,7 +394,6 @@ class EditorFragment : BaseBindingFragment<FragmentEditorBinding>() {
parentFragmentManager.commit {
add(R.id.fragment_container, GitFragment())
addToBackStack(null)
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
true
}
Expand Down Expand Up @@ -604,15 +602,13 @@ class EditorFragment : BaseBindingFragment<FragmentEditorBinding>() {
parentFragmentManager.commit {
add(R.id.fragment_container, CompileInfoFragment())
addToBackStack(null)
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}

private fun navigateToSettingsFragment() {
parentFragmentManager.commit {
add(R.id.fragment_container, SettingsFragment())
addToBackStack(null)
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}

Expand Down
1 change: 0 additions & 1 deletion app/src/main/kotlin/org/cosmicide/fragment/GitFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class GitFragment : BaseBindingFragment<FragmentGitBinding>() {
parentFragmentManager.popBackStack()
parentFragmentManager.commit {
replace(R.id.fragment_container, SettingsFragment()).addToBackStack(null)
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}.setNegativeButton("No") { _, _ ->
parentFragmentManager.popBackStack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class InstallResourcesFragment : BaseBindingFragment<InstallResourcesFragmentBin
withContext(Dispatchers.Main) {
parentFragmentManager.commit {
replace(R.id.fragment_container, ProjectFragment())
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class NewProjectFragment : BaseBindingFragment<FragmentNewProjectBinding>() {
if (success) {
parentFragmentManager.commit {
remove(this@NewProjectFragment)
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
}
}
}
Expand Down Expand Up @@ -104,7 +103,6 @@ class NewProjectFragment : BaseBindingFragment<FragmentNewProjectBinding>() {
parentFragmentManager.commit {
add(R.id.fragment_container, EditorFragment.newInstance(project))
addToBackStack(null)
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}

Expand Down
4 changes: 0 additions & 4 deletions app/src/main/kotlin/org/cosmicide/fragment/ProjectFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class ProjectFragment : BaseBindingFragment<FragmentProjectBinding>(),
parentFragmentManager.commit {
replace(R.id.fragment_container, SettingsFragment())
addToBackStack(null)
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
true
}
Expand Down Expand Up @@ -262,7 +261,6 @@ class ProjectFragment : BaseBindingFragment<FragmentProjectBinding>(),
setPositiveButton("Ok") { _, _ ->
parentFragmentManager.commit {
replace(R.id.fragment_container, SettingsFragment())
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}
show()
Expand Down Expand Up @@ -403,7 +401,6 @@ class ProjectFragment : BaseBindingFragment<FragmentProjectBinding>(),
parentFragmentManager.commit {
add(R.id.fragment_container, NewProjectFragment())
addToBackStack(null)
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}

Expand All @@ -415,7 +412,6 @@ class ProjectFragment : BaseBindingFragment<FragmentProjectBinding>(),
}
})
addToBackStack(null)
setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ProjectOutputFragment : BaseBindingFragment<FragmentCompileInfoBinding>()
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")
Expand All @@ -57,7 +56,6 @@ class ProjectOutputFragment : BaseBindingFragment<FragmentCompileInfoBinding>()
R.id.cancel -> {
parentFragmentManager.commit {
remove(this@ProjectOutputFragment)
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
}
true
}
Expand All @@ -74,7 +72,6 @@ class ProjectOutputFragment : BaseBindingFragment<FragmentCompileInfoBinding>()
binding.toolbar.setNavigationOnClickListener {
parentFragmentManager.commit {
remove(this@ProjectOutputFragment)
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/kotlin/org/cosmicide/util/CommonUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 3 additions & 10 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.gnu.org/licenses/>.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorSurfaceContainerLow"
android:orientation="vertical">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
android:background="?colorSurfaceContainerLow" />
49 changes: 0 additions & 49 deletions app/src/main/res/values-night/themes_custom.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values-v27/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.gnu.org/licenses/>.
-->

<resources xmlns:tools="http://schemas.android.com/tools">

<style name="Theme.CosmicIde.BaseV27" parent="Theme.CosmicIde.Base">
<item name="android:enforceNavigationBarContrast" tools:targetApi="q">false</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/values-v31/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
<style name="Theme.CosmicIde" parent="Theme.CosmicIde.BaseV31" />

<style name="Theme.CosmicIde.Start" parent="Theme.SplashScreen">
<!-- Android framework -->
<item name="android:navigationBarColor">@color/logo_background</item>
<item name="android:statusBarColor">@color/logo_background</item>

<item name="windowSplashScreenBackground">@color/logo_background</item>
<item name="android:splashScreenTheme">@style/Theme.CosmicIde.Flamingo</item>
<item name="windowSplashScreenIconBackgroundColor">?attr/colorSurface</item>
<item name="postSplashScreenTheme">@style/Theme.CosmicIde.Pyro</item>
<item name="postSplashScreenTheme">@style/Theme.CosmicIde</item>
</style>
</resources>
3 changes: 0 additions & 3 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.gnu.org/licenses/>.
-->

<resources>

<style name="Widget.CosmicIde.ListItemCard" parent="Widget.Material3.CardView.Filled">
<item name="android:layout_marginHorizontal">16dp</item>
<item name="android:layout_marginVertical">8dp</item>
</style>

</resources>
13 changes: 5 additions & 8 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.gnu.org/licenses/>.
-->

<resources>

<style name="Theme.CosmicIde.Base" parent="Theme.Material3.DayNight.NoActionBar">
<item name="android:fontFamily">@font/inter</item>
<style name="Theme.CosmicIde.Base" parent="Theme.Material3.DynamicColors.DayNight.NoActionBar">
<!-- Android framework -->
<item name="android:overScrollMode">never</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>

<item name="android:navigationBarColor">
@android:color/transparent
</item>
<!-- Font -->
<item name="android:fontFamily">@font/inter</item>
<item name="fontFamily">@font/inter</item>
</style>

<style name="Theme.CosmicIde" parent="Theme.CosmicIde.Base" />

</resources>
Loading

0 comments on commit 7b289b6

Please sign in to comment.