Skip to content

Commit

Permalink
feat: added cn strings
Browse files Browse the repository at this point in the history
  • Loading branch information
agronick committed Jan 3, 2024
1 parent 4cd53b6 commit 6fa2298
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def ghPackage = "aa-torque"


android {
namespace "com.aatorque.stats"
namespace = "com.aatorque.stats"
compileSdk 34
defaultConfig {
applicationId "com.aatorque.stats"
Expand All @@ -31,7 +31,7 @@ android {
useSupportLibrary true
}
buildConfigField "boolean", "SIMULATE_METRICS", "false"
resourceConfigurations += ['en', 'cs', 'de', 'el', 'es', 'fr', 'fr-rCA', 'it', 'nl', 'pl', 'pt', 'pt-rBR', 'ru', 'sl', 'uk']
resourceConfigurations += ['en', 'cs', 'de', 'el', 'es', 'fr', 'fr-rCA', 'it', 'nl', 'pl', 'pt', 'pt-rBR', 'ru', 'sl', 'uk', 'zh-rHK']
}
applicationVariants.all {
buildConfigField "String", "RELEASE_URL", "\"https://api.github.com/repos/${ghOwner}/${ghPackage}/releases/latest\""
Expand Down
138 changes: 129 additions & 9 deletions app/src/main/java/com/aatorque/stats/DashboardFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ import android.widget.RelativeLayout
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.InputDeviceCompat
import androidx.datastore.core.DataStore
import androidx.fragment.app.FragmentContainerView
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.aatorque.datastore.UserPreference
import com.aatorque.prefs.SettingsViewModel
import com.aatorque.prefs.dataStore
import com.aatorque.stats.databinding.FragmentDashboardBinding
import com.google.android.apps.auto.sdk.StatusBarController
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -62,7 +65,132 @@ open class DashboardFragment : CarFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
settingsViewModel = ViewModelProvider(this)[SettingsViewModel::class.java]
torqueService.startTorque(requireContext())
val context = requireContext()
torqueService.startTorque(context)
val registerWithView = { call: suspend (Flow<UserPreference>) -> Unit ->
lifecycleScope.launch {
viewReady.await()
call(context.dataStore.data)
}
}
registerWithView {
data ->
data.map {
it.selectedBackground
}.distinctUntilChanged().collect {
setupBackground(it)
albumArtReady.countDown()
}
}
registerWithView {
data ->
data.collect {
val screenIndex = abs(it.currentScreen) % it.screensCount
val screens = it.screensList[screenIndex]
val showChartChanged = binding.showChart != it.showChart
binding.title = screens.title
settingsViewModel.chartVisible.value = it.showChart
settingsViewModel.minMaxBelow.value = it.minMaxBelow
shouldDisplayArtwork = it.albumArt

albumArtReady.countDown()

if (it.showChart) {
torqueChart.setupItems(
screens.gaugesList.mapIndexed { index, display ->
torqueRefresher.updateIfNeeded(index, screenIndex, display)
}.toTypedArray()
)
} else {
screens.gaugesList.forEachIndexed { index, display ->
if (showChartChanged || torqueRefresher.hasChanged(index, display)) {
val clock = torqueRefresher.populateQuery(index, screenIndex, display)
guages[index]?.setupClock(clock)
}
}
}
screens.displaysList.forEachIndexed { index, display ->
if (torqueRefresher.hasChanged(index + DISPLAY_OFFSET, display)) {
val td = torqueRefresher.populateQuery(
index + DISPLAY_OFFSET,
screenIndex,
display
)
displays[index]?.setupElement(td)
}
}
torqueRefresher.watchConnection(torqueService) {
binding.status = when (it) {
ConnectStatus.CONNECTING_TORQUE -> R.string.status_connecting_torque
ConnectStatus.CONNECTING_ECU -> R.string.status_connecting_to_ecu
ConnectStatus.SETUP_GAUGE -> R.string.status_setup_gauges
ConnectStatus.CONNECTED -> null
}
}
torqueRefresher.makeExecutors(torqueService)
}
}
registerWithView {
data ->
data.map {
it.opacity
}.distinctUntilChanged().collect {
binding.gaugeAlpha = if (it == 0) 1f else 0.01f * it
}
}
registerWithView {
data ->
data.map {
it.darkenArt
}.distinctUntilChanged().collect {
albumColorFilter = if (it != 0) {
PorterDuffColorFilter(
Color.valueOf(0f, 0f, 0f, it * 0.01f).toArgb(),
PorterDuff.Mode.DARKEN,
)
} else null
}
}
if (Build.VERSION.SDK_INT >= 31) {
registerWithView {
data ->
data.map {
it.blurArt
}.distinctUntilChanged().collect {
albumBlurEffect = if (it != 0) {
val blurFloat = it.toFloat()
RenderEffect.createBlurEffect(
blurFloat, blurFloat,
Shader.TileMode.MIRROR
)
} else null
}
}
}
registerWithView {
data ->
data.map {
it.selectedFont
}.distinctUntilChanged().collect(
this@DashboardFragment::setupTypeface
)
}
registerWithView {
data ->
data.map {
it.rotaryInput
}.distinctUntilChanged().collect(
this@DashboardFragment::configureRotaryInput
)
}
registerWithView {
data ->
data.map {
it.centerGaugeLarge
}.distinctUntilChanged().collect(
this@DashboardFragment::updateScale
)
}
}

override fun onCreateView(
Expand Down Expand Up @@ -250,14 +378,6 @@ open class DashboardFragment : CarFragment() {
Timber.d("onResume")
super.onResume()
torqueRefresher.makeExecutors(torqueService)
torqueRefresher.watchConnection(torqueService) {
binding.status = when (it) {
ConnectStatus.CONNECTING_TORQUE -> R.string.status_connecting_torque
ConnectStatus.CONNECTING_ECU -> R.string.status_connecting_to_ecu
ConnectStatus.SETUP_GAUGE -> R.string.status_setup_gauges
ConnectStatus.CONNECTED -> null
}
}
}

override fun onPause() {
Expand Down
125 changes: 125 additions & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,23 @@
<string name="element_outsideTemperature">Buitentemperatuur</string>
<string name="element_soundVolume">Media volume</string>
<string name="element_wheelAngle">Wielhoek</string>
<string name="element_wheel">Wheel</string>
<string name="element_world">World</string>
<string name="element_yawRate">Gierhoek</string>
<string name="element_cac">Charger Air cooler</string>
<string name="element_distance">Distance</string>
<string name="element_ecoaverage">Eco Average</string>
<string name="element_eco">Eco</string>
<string name="exhaust">Exhaust</string>
<string name="element_fuel_primary">Fuel Primary</string>
<string name="element_fuel_secondary">Fuel Secondary</string>
<string name="element_measurement">Measurement</string>
<string name="element_motherboard">Motherboard</string>
<string name="element_obd2">OBD2</string>
<string name="element_pedal">Pedal</string>
<string name="element_radio">Radio</string>
<string name="element_wrench">Wrench</string>
<string name="element_tire">Tire</string>
<string name="pref_appearance">Weergave</string>
<string name="pref_centerclock">Klok midden</string>
<string name="pref_font">Lettertype</string>
Expand All @@ -44,9 +60,118 @@
<string name="pref_ticks">Waarden op de klok</string>
<string name="pref_ticks_off">Geef geen waarde bij de streepjes</string>
<string name="pref_ticks_on">Geef waarde weer bij de streepjes</string>
<string name="element_torque_fuelpressure">Fuel pressure</string>
<string name="element_torque_engineload">Engine load</string>
<string name="element_torque_timing_advance">Timing advance</string>
<string name="element_torque_throttle_position">Throttle position (Manifold)</string>
<string name="element_torque_turboboost">Turbo boost pressure</string>
<string name="element_torque_phonebatterylevel">Phone battery level</string>
<string name="element_torque_phonebarometer">Phone barometer</string>
<string name="element_torque_intakemanifoldpressure">Intake manifold</string>
<string name="element_torque_catalysttemperature">Catalyst</string>
<string name="element_torque_fuellevel">Fuel level</string>
<string name="element_barometer">Barometer</string>
<string name="bg_vw">Discover Pro Sport</string>
<string name="bg_vw2">Carbon fiber</string>
<string name="bg_vw3">Spotlight</string>
<string name="bg_vwplaid">GTI ruitjespatroon</string>
<string name="bg_gte">GTE ruitjespatroon</string>
<string name="bg_vwgtd">GTD ruitjespatroon</string>
<string name="bg_black">Black</string>
<string name="bg_cloth">Cloth</string>
<string name="bg_rock">Rock</string>
<string name="bg_outrun">Outrun</string>
<string name="bg_plain">Plain</string>
<string name="bg_seat">Lines</string>
<string name="bg_seat2">Dark grid</string>
<string name="bg_skoda">Columbus</string>
<string name="bg_skoda2">Columbus Sport</string>
<string name="bg_skodaone">OneApp</string>
<string name="bg_blackboard">Blackboard</string>
<string name="bg_test">Test</string>
<string name="bg_beetle">Herbie</string>
<string name="pref_background">Achtergrond</string>
<string name="bg_dots">Dots</string>
<string name="bg_aa">Android Auto</string>
<string name="item_details_go_back">Terug</string>
<string name="pid">PID</string>
<string name="pidLabel">Label</string>
<string name="pidShowLabel">Show Label</string>
<string name="icon">Icon</string>
<string name="torque_waiting">Waiting for Torque to become available</string>
<string name="min_value">Minimum Value</string>
<string name="max_value">Maximum Value</string>
<string name="num_screens">Number of dashboards to display</string>
<string name="unit">Unit</string>
<string name="dashboards">Dashboards</string>
<string name="rotary_input">Rotary input</string>
<string name="rotary_desc">Disable buttons and use rotary dial if equipped</string>
<string name="enable_script">Run unit conversion</string>
<string name="enable_script_desc">Run formula on output</string>
<string name="custom_script">Unit conversion</string>
<string name="custom_script_desc">Run an EvalEx expression. Use a to represent the current value</string>
<string name="formulas">Formulas</string>
<string name="custom_expression">Custom expression</string>
<string name="status_connecting_torque">Connecting to Torque…</string>
<string name="status_connecting_to_ecu">Connecting to ECU…</string>
<string name="credits_modifications">Developed by:</string>
<string name="export_dashboards">Export dashboards</string>
<string name="import_dashboards">Import dashboards</string>
<string name="file_exported_successfully">File exported successfully</string>
<string name="export_failed">Export failed</string>
<string name="file_not_available">Export file is not available</string>
<string name="whole_numbers">Whole numbers</string>
<string name="whole_numbers_desc">Display without decimal places</string>
<string name="gauge_settings">Gauge Settings</string>
<string name="show_label_desc">In most cases you want to show an icon, but you can show a label if you cannot find an icon to match the PID.</string>
<string name="show_label_desc_clock">Show label above the gauge</string>
<string name="icon_null_desc">Select an icon to represent the metric</string>
<string name="pref_shrink_gauge">Large center gauge</string>
<string name="pref_shrink_gauge_off">Equal size gauges</string>
<string name="pref_shrink_gauge_on">Emphasise center gauge</string>
<string name="new_version">A new version is available</string>
<string name="download">Download</string>
<string name="download_instructions">Update downloading</string>
<string name="expressionDocumentation">View Documentation</string>
<string name="copy_logs">Copy logs to clipboard</string>
<string name="convert_f_to_c">Fahrenheit to Celsius</string>
<string name="convert_c_to_f">Celsius to Fahrenheit</string>
<string name="convert_bar_psi">Convert BAR to PSI</string>
<string name="convert_psi_bar">Convert PSI to BAR</string>
<string name="convert_km_to_miles">Kilometers to Miles</string>
<string name="boolean_logic">Boolean Logic</string>
<string name="convert_newton_ft_lb">Newton Meters to Foot-pounds</string>
<string name="convert_cc_min_gal_hour">CC per minute to Gallon Hour</string>
<string name="convert_liter_100_km">Liter 100/km to Miles per Gallon</string>
<string name="convert_kpa_psi">Kilopascals (kPa) to (PSI)</string>
<string name="status_setup_gauges">Setup gauges in settings</string>
<string name="element_cylinder">Engine Cylinder</string>
<string name="element_horsepower">Horsepower</string>
<string name="element_transmission">Transmission</string>
<string name="download_complete">Download Complete</string>
<string name="icon_credits">Icon Credits</string>
<string name="action_preview">Preview</string>
<string name="pref_view">View %1$d</string>
<string name="pref_data_element_settings">Data element settings %1$d</string>
<string name="pref_title_performance">Title %1$d</string>
<string name="download_dialog">Try to install this app as the Play Store? If this fails you can try using Kingstaller.</string>
<string name="force_update">Force update</string>
<string name="update_failed">Update check failed</string>
<string name="convert_minutes_seconds">Seconds to Minutes:Seconds</string>
<string name="donate">Please donate!</string>
<string name="translate">Translate</string>
<string name="pref_chart_title">Chart line color</string>
<string name="pref_chart_summary">Color to be used to draw lines on the chart</string>
<string name="bg_ev">Electro Vehicle</string>
<string name="minmax_below">Min/Max below gauge</string>
<string name="minmax_below_desc">Place min/max values below gauge instead of overlapping the bottom of the gauge</string>
<string name="media">Media</string>
<string name="media_background_title">Media Background</string>
<string name="media_background_summary">Use album art as background (beta)</string>
<string name="opacity_title">Gauge Opacity</string>
<string name="opacity_summary">Dim gauges to show more of background</string>
<string name="media_blur_title">Blur artwork</string>
<string name="media_blur_summary">Blur artwork to help improve readability</string>
<string name="media_darken_title">Darken artwork</string>
<string name="media_darken_summary">Darken artwork to help improve readability</string>
</resources>

0 comments on commit 6fa2298

Please sign in to comment.