Skip to content

Commit

Permalink
Swap host UI
Browse files Browse the repository at this point in the history
  • Loading branch information
kamgurgul committed Nov 24, 2023
1 parent e6c9ce4 commit 3a27725
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 111 deletions.
37 changes: 7 additions & 30 deletions app/src/main/java/com/kgurgul/cpuinfo/features/HostActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@

package com.kgurgul.cpuinfo.features

import android.os.Build
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import androidx.core.view.WindowCompat
import com.kgurgul.cpuinfo.R
import com.kgurgul.cpuinfo.databinding.ActivityHostLayoutBinding
import com.kgurgul.cpuinfo.utils.setupEdgeToEdge
import com.kgurgul.cpuinfo.ui.theme.CpuInfoTheme
import dagger.hilt.android.AndroidEntryPoint

/**
Expand All @@ -35,33 +32,13 @@ import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class HostActivity : AppCompatActivity() {

private lateinit var navController: NavController
private lateinit var binding: ActivityHostLayoutBinding

override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppThemeBase)
super.onCreate(savedInstanceState)
binding = ActivityHostLayoutBinding.inflate(layoutInflater)
setContentView(binding.root)
setupEdgeToEdge()
setupNavigation()
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
// Processes cannot be listed above M
val menu = binding.bottomNavigation.menu
menu.findItem(R.id.processes).isVisible = false
}
}

override fun onSupportNavigateUp() = navController.navigateUp()

private fun setupNavigation() {
navController =
(supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment)
.navController
binding.bottomNavigation.apply {
setupWithNavController(navController)
setOnItemReselectedListener {
// Do nothing - TODO: scroll to top
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
CpuInfoTheme {
HostScreen()
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/kgurgul/cpuinfo/features/HostScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.kgurgul.cpuinfo.R
import com.kgurgul.cpuinfo.features.applications.ApplicationsScreen
import com.kgurgul.cpuinfo.features.information.hardware.HardwareInfoScreen
import com.kgurgul.cpuinfo.features.information.InfoContainerScreen
import com.kgurgul.cpuinfo.features.processes.ProcessesScreen
import com.kgurgul.cpuinfo.features.settings.SettingsScreen
import com.kgurgul.cpuinfo.features.temperature.TemperatureScreen
Expand Down Expand Up @@ -79,10 +79,10 @@ fun HostScreen(
) { paddingValues ->
NavHost(
navController = navController,
startDestination = HostScreen.Hardware.route,
startDestination = HostScreen.Information.route,
modifier = Modifier.padding(paddingValues = paddingValues),
) {
composable(HostScreen.Hardware.route) { HardwareInfoScreen() }
composable(HostScreen.Information.route) { InfoContainerScreen() }
composable(HostScreen.Applications.route) { ApplicationsScreen() }
composable(HostScreen.Processes.route) { ProcessesScreen() }
composable(HostScreen.Temperatures.route) { TemperatureScreen() }
Expand All @@ -92,7 +92,7 @@ fun HostScreen(
}

sealed class HostScreen(val route: String) {
data object Hardware : HostScreen("hardware_route")
data object Information : HostScreen("information_route")
data object Applications : HostScreen("applications_route")
data object Processes : HostScreen("processes_route")
data object Temperatures : HostScreen("temperatures_route")
Expand All @@ -111,8 +111,8 @@ data class HostNavigationItem(
add(
HostNavigationItem(
labelRes = R.string.hardware,
iconRes = R.drawable.ic_hardware,
route = HostScreen.Hardware.route,
iconRes = R.drawable.ic_cpu,
route = HostScreen.Information.route,
)
)
add(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kgurgul.cpuinfo.features

import android.os.Build
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -9,7 +10,11 @@ import javax.inject.Inject
@HiltViewModel
class HostViewModel @Inject constructor() : ViewModel() {

private val _uiStateFlow = MutableStateFlow(UiState())
private val _uiStateFlow = MutableStateFlow(
UiState(
isProcessSectionVisible = Build.VERSION.SDK_INT <= Build.VERSION_CODES.M
)
)
val uiStateFlow = _uiStateFlow.asStateFlow()

data class UiState(
Expand Down
Binary file removed app/src/main/res/drawable-night/ic_c_plus_plus.png
Binary file not shown.
Binary file removed app/src/main/res/drawable/ic_c_plus_plus.png
Binary file not shown.
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_cpu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="490.08"
android:viewportHeight="490.08">
<path
android:fillColor="#FF000000"
android:pathData="M334.08,0h11a4.34,4.34 0,0 0,-0.11 0.7q0,9.71 0,19.43a6.44,6.44 0,0 0,0.15 0.93h6.94L352.06,64.92h21.89L373.95,20.97h6.93c0,-0.42 0.08,-0.69 0.08,-1q0,-9.59 0,-19.19a5.86,5.86 0,0 0,-0.11 -0.82h11v21h7.09v44c2,0 3.82,-0.14 5.63,0 4.46,0.41 9,-1 13.44,0.85a6.45,6.45 0,0 1,3 1.85,7 7,0 0,0 1.21,1.22 3.8,3.8 0,0 1,1.8 3,1.13 1.13,0 0,0 0.2,0.79c1,0.54 0.69,1.45 0.7,2.24 0,5.88 0,11.76 0,17.63 0,0.46 0,0.93 0,1.51h44.05v6.94L470.76,100.99l19.31,0v11L468.96,111.99v7L425.08,118.99v20h43.93v6.89h21.07v11L468.96,156.88v7.07L425.08,163.95v23h43.93v6.9h21.07v11L468.97,204.85v7.06L425.11,211.91v21h43.92v6.94h21.05v11L468.99,250.85v7L425.11,257.85v23h43.92v6.94h21.05v11L469,298.79v7L425.08,305.79v21h44v7L470.76,333.79l19.31,0v10.8c-0.47,0 -0.95,0.11 -1.42,0.11L468.99,344.7v7h-43.9v24h44v6.93L470.76,382.63l19.31,0v11L468.97,393.63v7h-44c0,0.55 0,1 0,1.42 0,4.36 0,8.71 0,13.07a5,5 0,0 1,-0.29 1.48,10.81 10.81,0 0,1 -0.63,1.31 11.29,11.29 0,0 1,-1.3 2.56,22.73 22.73,0 0,1 -2.77,2.29 14.79,14.79 0,0 1,-4.59 1.81l-15,0h-1.41v44h-7c0,0.69 0,1.21 0,1.73q0,9.65 0,19.31h-10.8c0,-0.47 -0.11,-0.95 -0.11,-1.42q0,-9.06 0,-18.11v-1.55h-7.08L373.99,425.07L351,425.07v44h-7c0,0.69 0,1.21 0,1.73q0,9.65 0,19.31h-10.8c0,-0.47 -0.11,-0.95 -0.11,-1.42q0,-9.05 0,-18.11v-1.55h-7.08L326.01,425.09h-21v43.92h-6.88v21.06h-11L287.13,468.97h-7v-43.9h-22v44h-6.92v21h-11L240.21,468.99h-7L233.21,425.07h-22v44h-7v21h-11L193.21,469h-7v-43.9h-22v44h-6.93c0,0.68 0,1.2 0,1.71q0,9.65 0,19.31h-11L146.28,468.96h-7L139.28,425.11h-22v44h-7c0,0.66 0,1.18 0,1.7q0,9.66 0,19.32L99.12,490.13c0,-0.48 -0.11,-1 -0.11,-1.43q0,-9.06 0,-18.11v-1.55h-7v-44L90.54,425.04c-5.28,0 -10.56,0.07 -15.83,-0.07A16.74,16.74 0,0 1,70.55 423.76a1.15,1.15 0,0 1,-0.34 -0.31c-0.5,-0.47 -1,-1 -1.51,-1.41 -1.37,-1.07 -2.72,-2.14 -2.77,-4.11a0.88,0.88 0,0 0,-0.22 -0.64c-0.84,-0.3 -0.67,-1 -0.68,-1.61 0,-5.08 0,-10.16 0,-15.24 0,-0.43 0,-0.86 0,-1.43h-44v-7L19.43,392.01l-19.43,0v-11a4.34,4.34 0,0 0,0.7 0.11L20.14,381.12a6.23,6.23 0,0 0,0.93 -0.16v-6.95L64.93,374.01L64.93,354.01L20.99,354.01v-7h-21v-11h21v-7h43.9v-23L20.99,306.01v-7h-21v-11h21v-7L64.91,281.01L64.91,259.93L20.98,259.93v-6.93L19.43,253l-19.43,0v-11L21.05,242v-7L64.92,235v-23L20.98,212v-6.94L19.44,205.06l-19.44,0v-11h21v-7L64.92,187.06L64.92,166.02L20.98,166.02v-6.94c-0.42,0 -0.69,-0.08 -1,-0.08L0.82,159a5.86,5.86 0,0 0,-0.82 0.11v-11h21v-7.09L64.93,141.02v-24L20.99,117.02v-7L19.43,110.02l-19.43,0v-11a4.34,4.34 0,0 0,0.7 0.11L20.13,99.13a6.32,6.32 0,0 0,0.93 -0.16L21.06,91.89L65,91.89c0,-0.57 0,-1 0,-1.44q0,-8.1 0,-16.19a3.71,3.71 0,0 1,0.25 -1.24c0.19,-0.51 0.5,-1 0.7,-1.47a3,3 0,0 1,0.29 -1.11c1.08,-0.7 1.43,-2 2.56,-2.75s1.86,-1.78 3.31,-1.77A0.78,0.78 0,0 0,72.71 65.76c0.44,-1.08 1.39,-0.75 2.15,-0.75 5.24,0 10.48,0 15.71,0h1.41v-44h6.94c0,-0.42 0.08,-0.69 0.08,-1q0,-9.6 0,-19.19A5.86,5.86 0,0 0,98.88 0h11v21h7.08L116.96,64.92h23L139.96,20.98h6.93c0,-0.42 0.08,-0.69 0.08,-1q0,-9.6 0,-19.19a5.86,5.86 0,0 0,-0.11 -0.82h11v21h7.16L165.02,64.92h20.93L185.95,20.98h6.94v-21h11v21h7v43.9h22L232.89,20.99h7v-21h11v21h7L257.89,64.91h22L279.89,20.97h6.92c0,-0.6 0,-1.07 0,-1.54q0,-9.71 0,-19.43h11L297.81,21.05h7L304.81,64.93h21.94L326.75,20.99h7.05c0,-0.62 0,-1.09 0,-1.56Q334.06,9.76 334.08,0ZM88.08,244.12h0q0,73 0,146a13.16,13.16 0,0 0,0.66 4.83A9,9 0,0 0,91.27 398.76a8.71,8.71 0,0 0,5.81 2.26c0.64,0 1.28,0 1.92,0q143.88,0 287.75,0c2.73,0 5.46,0.48 8.25,-0.7a9.5,9.5 0,0 0,4.67 -3.88c0.79,-1.36 1.68,-3 1.32,-4.85a7.11,7.11 0,0 1,0 -1.32q0,-142.2 -0.05,-284.39c0,-4 0.88,-8.11 -0.81,-12.09a6.8,6.8 0,0 0,-3.28 -3.8,2.35 2.35,0 0,1 -0.54,-0.23 5.78,5.78 0,0 0,-4 -1.63L120.64,88.13c-8.28,0 -16.56,0 -24.84,0.05a13.89,13.89 0,0 0,-3.63 1,0.5 0.5,0 0,0 -0.14,0.18A7,7 0,0 1,90.76 90.86c-1,0.69 -1.85,1.4 -1.87,2.73a0.39,0.39 0,0 1,-0.16 0.3c-0.91,0.22 -0.66,1 -0.68,1.55 0,1 0,2.08 0,3.12Q88.04,171.34 88.04,244.12Z" />
<path
android:fillColor="#FF000000"
android:pathData="M101.02,244.55q0,-63.78 0,-127.55c0,-1.2 0,-2.4 0.06,-3.6a5.1,5.1 0,0 1,0.63 -1.48,1.1 1.1,0 0,0 0.19,-0.41c-0.15,-2.05 1.08,-3.58 2.24,-4.92a13,13 0,0 1,4.39 -3.72c1,-0.46 2.25,-0.48 3,-1 1.76,-1.36 3.64,-0.77 5.43,-0.77q93.05,-0.07 186.11,0h69.23c1.16,0 2.32,0 3.48,0.06a4.5,4.5 0,0 1,1.37 0.62,1.08 1.08,0 0,0 0.4,0.21c2.06,-0.17 3.41,1.31 5,2.2a7.11,7.11 0,0 1,1.48 1.58c0.34,0.37 0.69,0.73 1,1.13 0.62,0.83 1.21,1.68 1.81,2.52a0.2,0.2 0,0 1,0 0.11c0,1.91 1.27,3.44 1.25,5.43 -0.11,12.52 -0.05,25 0,37.56q0,109.49 0,219c0,1.16 0,2.32 0,3.48 0,0.84 0.19,1.78 -0.73,2.38a1.1,1.1 0,0 0,-0.15 0.56,11 11,0 0,1 -2.94,5.29 30.74,30.74 0,0 0,-2.45 2.41,0.27 0.27,0 0,1 -0.07,0.09l-3.29,1.41c-0.48,0.21 -1,0.45 -1.44,0.63a4.31,4.31 0,0 1,-1.24 0.32c-1.12,0.05 -2.24,0 -3.36,0L116.62,388.09c-0.72,0 -1.44,0 -2.16,0 -1,-0.06 -2,0.26 -2.72,-0.77a0.71,0.71 0,0 0,-0.46 -0.1,7.84 7.84,0 0,1 -4.9,-2.36 13,13 0,0 1,-3.56 -4.41c-0.4,-1 -0.44,-2.16 -1,-2.84 -1.34,-1.63 -0.78,-3.4 -0.78,-5.07Q100.98,308.5 101.02,244.55ZM370.95,365.99c0,-2.46 -2.5,-4.8 -5,-5 -2,-0.15 -5,3 -5,5s3,5 5,5S371.33,368.01 370.95,365.99Z" />
</vector>
25 changes: 0 additions & 25 deletions app/src/main/res/drawable/ic_sort.xml

This file was deleted.

49 changes: 0 additions & 49 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,53 +47,4 @@
<item name="colorPrimary">@color/onBackground</item>
</style>

<!-- Texts -->
<style name="BaseText">
<item name="android:textColor">?attr/colorOnBackground</item>
</style>

<style name="TextH1" parent="BaseText">
<item name="android:textSize">96sp</item>
</style>

<style name="TextH2" parent="BaseText">
<item name="android:textSize">60sp</item>
</style>

<style name="TextH3" parent="BaseText">
<item name="android:textSize">48sp</item>
</style>

<style name="TextH4" parent="BaseText">
<item name="android:textSize">34sp</item>
</style>

<style name="TextH5" parent="BaseText">
<item name="android:textSize">24sp</item>
</style>

<style name="TextH6" parent="BaseText">
<item name="android:textSize">20sp</item>
</style>

<style name="TextH7" parent="BaseText">
<item name="android:textSize">18sp</item>
</style>

<style name="TextBody1" parent="BaseText">
<item name="android:textSize">16sp</item>
</style>

<style name="TextBody2" parent="BaseText">
<item name="android:textSize">14sp</item>
</style>

<style name="TextAnnotation1" parent="BaseText">
<item name="android:textSize">12sp</item>
</style>

<style name="TextAnnotation2" parent="BaseText">
<item name="android:textSize">10sp</item>
</style>

</resources>

0 comments on commit 3a27725

Please sign in to comment.