Skip to content

Commit

Permalink
refactor: Rename vehicle_profile module to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Nov 16, 2023
1 parent 31c605b commit 9dd7d95
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ android {
dimension "version"
resValue "string", "DEFAULT_PROFILE", "profile_8"
applicationId "org.obd.graphs.my.giulia.performance_monitor"
versionCode 33
versionCode 34
}

giulia {
Expand Down Expand Up @@ -134,7 +134,7 @@ dependencies {
implementation project(':screen_renderer')
implementation project(":datalogger")
implementation project(":common")
implementation project(":vehicle_profile")
implementation project(':profile')

debugImplementation project(":automotive")
releaseImplementation project(":automotive")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ import org.junit.runner.RunWith
import org.obd.graphs.activity.MainActivity
import org.obd.graphs.preferences.Prefs
import org.obd.graphs.preferences.updateBoolean
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile

@RunWith(AndroidJUnit4ClassRunner::class)
class VehicleProfileTest {
class ProfileTest {

@Test
fun resetProfileTest() {

launchActivity<MainActivity>().use {

// lets use this profiles as default
vehicleProfile.loadProfile("profile_5")
profile.loadProfile("profile_5")

val propName = "pref.adapter.batch.enabled"
assertEquals(Prefs.getBoolean(propName, true), true)
Expand All @@ -52,7 +52,7 @@ class VehicleProfileTest {
assertEquals(Prefs.getBoolean(propName, false), false)

// resetting profiles
vehicleProfile.reset()
profile.reset()
assertEquals(Prefs.getBoolean(propName, true), true)
}
}
Expand All @@ -72,7 +72,7 @@ class VehicleProfileTest {
assertTrue(Prefs.getBoolean(setupProfilesKey, true))
Prefs.updateBoolean(setupProfilesKey, false)

vehicleProfile.setupProfiles()
profile.setupProfiles()

assertTrue(Prefs.getBoolean(setupProfilesKey, true))

Expand All @@ -85,24 +85,24 @@ class VehicleProfileTest {

launchActivity<MainActivity>().use {
val expected = getExpectedProfileList()
val given = vehicleProfile.getAvailableProfiles()
val given = profile.getAvailableProfiles()

assertTrue("Default profiles does not match", expected == given)
}
}

private fun assertProfilesExists() {
val expected = getExpectedProfileList()
val given = vehicleProfile.getAvailableProfiles()
val given = profile.getAvailableProfiles()
Log.e("assertProfilesExists", "Given profiles: $given")
Log.e("assertProfilesExists", "Expected profiles: $expected")

assertTrue("Default profiles does not match", expected == given)

given.forEach {
vehicleProfile.loadProfile(it.key)
profile.loadProfile(it.key)

assertTrue("Loaded profiles does not match", vehicleProfile.getCurrentProfile() == it.key)
assertTrue("Loaded profiles does not match", profile.getCurrentProfile() == it.key)

val txt = if (it.value!!.startsWith("Profile")) it.value!! else "Profile ${it.value}"

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/obd/graphs/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import org.obd.graphs.*
import org.obd.graphs.preferences.*
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile
import pub.devrel.easypermissions.AppSettingsDialog
import pub.devrel.easypermissions.EasyPermissions

Expand Down Expand Up @@ -201,13 +201,13 @@ class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks {
}

private fun setupVehicleProfiles() {
vehicleProfile.init(
profile.init(
versionCode = BuildConfig.VERSION_CODE,
defaultProfile = resources.getString(R.string.DEFAULT_PROFILE),
versionName = BuildConfig.VERSION_NAME
)

Prefs.registerOnSharedPreferenceChangeListener(vehicleProfile)
vehicleProfile.setupProfiles(forceOverrideRecommendation = false)
Prefs.registerOnSharedPreferenceChangeListener(profile)
profile.setupProfiles(forceOverrideRecommendation = false)
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/org/obd/graphs/activity/StatusPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import android.widget.ImageView
import android.widget.TextView
import org.obd.graphs.R
import org.obd.graphs.bl.datalogger.dataLoggerPreferences
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile
import org.obd.graphs.sendBroadcastEvent
import org.obd.graphs.ui.common.COLOR_PHILIPPINE_GREEN
import org.obd.graphs.ui.common.COLOR_RAINBOW_INDIGO
Expand Down Expand Up @@ -68,7 +68,7 @@ internal fun MainActivity.updateVehicleProfile() {
updateTextField(
R.id.vehicle_profile,
resources.getString(R.string.vehicle_profile),
vehicleProfile.getCurrentProfileName(),
profile.getCurrentProfileName(),
COLOR_RAINBOW_INDIGO,
1.0f
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ package org.obd.graphs.preferences.profile
import android.content.Context
import android.util.AttributeSet
import androidx.preference.Preference
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile

class VehicleProfileExportAction(
class ProfileExportAction(
context: Context,
attrs: AttributeSet?
) : Preference(context, attrs) {

init {
setOnPreferenceClickListener {
vehicleProfile.exportBackup()
profile.exportBackup()
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ package org.obd.graphs.preferences.profile
import android.content.Context
import android.util.AttributeSet
import androidx.preference.Preference
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile

class VehicleProfileImportAction(
class ProfileImportAction(
context: Context,
attrs: AttributeSet?
) : Preference(context, attrs) {

init {
setOnPreferenceClickListener {
vehicleProfile.importBackup()
profile.importBackup()
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ import androidx.preference.ListPreference
import androidx.preference.Preference.OnPreferenceChangeListener
import org.obd.graphs.activity.navigateToPreferencesScreen
import org.obd.graphs.profile.PROFILES_PREF
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile
import org.obd.graphs.ui.common.COLOR_PHILIPPINE_GREEN
import org.obd.graphs.ui.common.colorize

class VehicleProfileListPreference(
class ProfileListPreference(
context: Context,
attrs: AttributeSet?
) : ListPreference(context, attrs) {

init {

vehicleProfile.getAvailableProfiles()
profile.getAvailableProfiles()
.let {
entries = it.values.toTypedArray()
entryValues = it.keys.toTypedArray()
Expand All @@ -47,8 +47,8 @@ class VehicleProfileListPreference(

onPreferenceChangeListener =
OnPreferenceChangeListener { _, newValue ->
vehicleProfile.saveCurrentProfile()
vehicleProfile.loadProfile(newValue.toString())
profile.saveCurrentProfile()
profile.loadProfile(newValue.toString())
navigateToPreferencesScreen(PROFILES_PREF)
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ import androidx.preference.EditTextPreference
import androidx.preference.Preference.OnPreferenceChangeListener
import org.obd.graphs.activity.navigateToPreferencesScreen
import org.obd.graphs.profile.PROFILES_PREF
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile

class VehicleProfileNamePreference(
class ProfileNamePreference(
context: Context,
attrs: AttributeSet?
):
EditTextPreference(context, attrs) {
init {
onPreferenceChangeListener = OnPreferenceChangeListener { _, newValue ->

Log.d("VehicleProfileNamePreference", "Updating profile value: ${vehicleProfile.getCurrentProfile()}=$newValue")
Log.d("VehicleProfileNamePreference", "Updating profile value: ${profile.getCurrentProfile()}=$newValue")

vehicleProfile.updateCurrentProfileName(newName = newValue.toString())
profile.updateCurrentProfileName(newName = newValue.toString())

navigateToPreferencesScreen(PROFILES_PREF)
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import android.content.Context
import android.util.AttributeSet
import androidx.preference.Preference
import org.obd.graphs.activity.navigateToPreferencesScreen
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile

class VehicleProfileResetPreferenceAction(
class ProfileResetPreferenceAction(
context: Context,
attrs: AttributeSet?
) : Preference(context, attrs) {

init {
setOnPreferenceClickListener {
vehicleProfile.reset()
profile.reset()
navigateToPreferencesScreen("pref.profiles")
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ package org.obd.graphs.preferences.profile
import android.content.Context
import android.util.AttributeSet
import androidx.preference.Preference
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile

class VehicleProfileSavePreferenceAction(
class ProfileSavePreferenceAction(
context: Context,
attrs: AttributeSet?
) : Preference(context, attrs) {

init {
setOnPreferenceClickListener {
vehicleProfile.saveCurrentProfile()
profile.saveCurrentProfile()
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import androidx.recyclerview.widget.RecyclerView
import org.obd.graphs.*
import org.obd.graphs.bl.trip.TripFileDesc
import org.obd.graphs.bl.trip.tripManager
import org.obd.graphs.profile.vehicleProfile
import org.obd.graphs.profile.profile
import org.obd.graphs.ui.common.Colors
import org.obd.graphs.ui.common.setText
import java.text.SimpleDateFormat
Expand All @@ -51,7 +51,7 @@ class TripsViewAdapter internal constructor(

private val profileColors = mutableMapOf<String, Int>().apply {
val colors = Colors().generate()
vehicleProfile.getAvailableProfiles().forEach { (s, _) ->
profile.getAvailableProfiles().forEach { (s, _) ->
put(s, colors.nextInt())
}
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,22 @@
android:title="@string/pref.settings"
app:singleLineTitle="false">
<PreferenceCategory android:title="@string/pref.general_settings">
<org.obd.graphs.preferences.profile.VehicleProfileListPreference
<org.obd.graphs.preferences.profile.ProfileListPreference
android:key="pref.profile.id"
android:title="@string/pref.profile.available_list"
app:useSimpleSummaryProvider="true" />

<org.obd.graphs.preferences.profile.VehicleProfileResetPreferenceAction
<org.obd.graphs.preferences.profile.ProfileResetPreferenceAction
android:key="pref.profile.reset"
android:summary="@string/pref.profile.reset_summary"
android:title="@string/pref.profile.reset" />

<org.obd.graphs.preferences.profile.VehicleProfileSavePreferenceAction
<org.obd.graphs.preferences.profile.ProfileSavePreferenceAction
android:key="pref.profile.save_current"
android:summary="@string/pref.profile.save_user_settings_summary"
android:title="@string/pref.profile.save_user_settings" />

<org.obd.graphs.preferences.profile.VehicleProfileNamePreference
<org.obd.graphs.preferences.profile.ProfileNamePreference
android:dialogTitle="@string/pref.profile.update_name"
android:key="pref.profile.current_name"
android:title="@string/pref.profile.update_name"
Expand All @@ -367,13 +367,13 @@
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref.profile.backup.category">
<org.obd.graphs.preferences.profile.VehicleProfileExportAction
<org.obd.graphs.preferences.profile.ProfileExportAction
android:key="pref.profile.export"
android:summary="@string/pref.profile.export_summary"
android:title="@string/pref.profile.export"
app:singleLineTitle="false" />

<org.obd.graphs.preferences.profile.VehicleProfileImportAction
<org.obd.graphs.preferences.profile.ProfileImportAction
android:key="pref.profile.import"
android:summary="@string/pref.profile.import_summary"
android:title="@string/pref.profile.import"
Expand Down
2 changes: 1 addition & 1 deletion automotive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ android {
dependencies {
implementation project(':screen_renderer')
implementation project(":common")
implementation project(":vehicle_profile")
implementation project(':profile')
implementation project(":datalogger")
implementation project(":dragracing")

Expand Down
2 changes: 1 addition & 1 deletion datalogger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {

dependencies {
implementation project(":common")
implementation project(":vehicle_profile")
implementation project(':profile')
implementation project(":dragracing")
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.2.0'
Expand Down
Loading

0 comments on commit 9dd7d95

Please sign in to comment.