diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..e94930a509b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space + +[*.{kt,kts}] +ktlint_code_style = android_studio +# Disable wildcard imports +ij_kotlin_name_count_to_use_star_import = 9999 +ij_kotlin_name_count_to_use_star_import_for_members = 9999 +# ktlint overrides +ktlint_function_naming_ignore_when_annotated_with=Composable +max_line_length = off diff --git a/app/src/full/java/io/homeassistant/companion/android/CrashHandling.kt b/app/src/full/java/io/homeassistant/companion/android/CrashHandling.kt index 0753db14023..afcece3ffe9 100644 --- a/app/src/full/java/io/homeassistant/companion/android/CrashHandling.kt +++ b/app/src/full/java/io/homeassistant/companion/android/CrashHandling.kt @@ -4,8 +4,6 @@ import android.content.Context import android.util.Log import io.sentry.SentryOptions import io.sentry.android.core.SentryAndroid -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext import java.io.File import java.io.PrintWriter import java.net.ConnectException @@ -18,6 +16,8 @@ import javax.net.ssl.SSLException import javax.net.ssl.SSLHandshakeException import javax.net.ssl.SSLPeerUnverifiedException import javax.net.ssl.SSLProtocolException +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext private const val FATAL_CRASH_FILE = "/fatalcrash/last_crash" diff --git a/app/src/full/java/io/homeassistant/companion/android/launch/LaunchPresenterImpl.kt b/app/src/full/java/io/homeassistant/companion/android/launch/LaunchPresenterImpl.kt index ba4dbe9a6c0..7d741964f67 100644 --- a/app/src/full/java/io/homeassistant/companion/android/launch/LaunchPresenterImpl.kt +++ b/app/src/full/java/io/homeassistant/companion/android/launch/LaunchPresenterImpl.kt @@ -8,8 +8,8 @@ import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.common.data.integration.DeviceRegistration import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.onboarding.getMessagingToken -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @ActivityScoped class LaunchPresenterImpl @Inject constructor( diff --git a/app/src/full/java/io/homeassistant/companion/android/location/HighAccuracyLocationService.kt b/app/src/full/java/io/homeassistant/companion/android/location/HighAccuracyLocationService.kt index aa499780ec8..06ad47fc25c 100644 --- a/app/src/full/java/io/homeassistant/companion/android/location/HighAccuracyLocationService.kt +++ b/app/src/full/java/io/homeassistant/companion/android/location/HighAccuracyLocationService.kt @@ -19,12 +19,12 @@ import com.google.android.gms.location.FusedLocationProviderClient import com.google.android.gms.location.LocationRequest import com.google.android.gms.location.LocationServices import com.google.android.gms.location.Priority -import io.homeassistant.companion.android.common.util.highAccuracyChannel +import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.util.CHANNEL_HIGH_ACCURACY import io.homeassistant.companion.android.sensors.LocationSensorManager import io.homeassistant.companion.android.util.ForegroundServiceLauncher import kotlin.math.abs import kotlin.math.roundToInt -import io.homeassistant.companion.android.common.R as commonR class HighAccuracyLocationService : Service() { @@ -112,7 +112,7 @@ class HighAccuracyLocationService : Service() { private fun createNotificationBuilder(context: Context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val channel = NotificationChannel(highAccuracyChannel, context.getString(commonR.string.high_accuracy_mode_channel_name), NotificationManager.IMPORTANCE_DEFAULT) + val channel = NotificationChannel(CHANNEL_HIGH_ACCURACY, context.getString(commonR.string.high_accuracy_mode_channel_name), NotificationManager.IMPORTANCE_DEFAULT) notificationManagerCompat.createNotificationChannel(channel) } @@ -123,7 +123,7 @@ class HighAccuracyLocationService : Service() { val disablePendingIntent = PendingIntent.getBroadcast(context, 0, disableIntent, PendingIntent.FLAG_MUTABLE) - notificationBuilder = NotificationCompat.Builder(context, highAccuracyChannel) + notificationBuilder = NotificationCompat.Builder(context, CHANNEL_HIGH_ACCURACY) .setSmallIcon(commonR.drawable.ic_stat_ic_notification) .setColor(Color.GRAY) .setOngoing(true) diff --git a/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningActivity.kt b/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningActivity.kt index a6ed5f5a8d5..0d481b88d24 100644 --- a/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningActivity.kt +++ b/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningActivity.kt @@ -20,8 +20,8 @@ import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.matter.views.MatterCommissioningView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import io.homeassistant.companion.android.webview.WebViewActivity -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @AndroidEntryPoint class MatterCommissioningActivity : AppCompatActivity() { diff --git a/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningService.kt b/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningService.kt index 65eebcd41ea..b8f34d3acf9 100644 --- a/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningService.kt +++ b/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningService.kt @@ -10,12 +10,12 @@ import com.google.android.gms.home.matter.commissioning.CommissioningService import com.google.android.gms.home.matter.commissioning.CommissioningService.CommissioningError import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.data.servers.ServerManager +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class MatterCommissioningService : Service(), CommissioningService.Callback { diff --git a/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningViewModel.kt b/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningViewModel.kt index 6dce4e81b64..b4df665a5f5 100644 --- a/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningViewModel.kt +++ b/app/src/full/java/io/homeassistant/companion/android/matter/MatterCommissioningViewModel.kt @@ -11,8 +11,8 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.thread.ThreadManager -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @HiltViewModel class MatterCommissioningViewModel @Inject constructor( diff --git a/app/src/full/java/io/homeassistant/companion/android/matter/views/MatterCommissioningView.kt b/app/src/full/java/io/homeassistant/companion/android/matter/views/MatterCommissioningView.kt index 08c568ad6fb..06ce9d61497 100644 --- a/app/src/full/java/io/homeassistant/companion/android/matter/views/MatterCommissioningView.kt +++ b/app/src/full/java/io/homeassistant/companion/android/matter/views/MatterCommissioningView.kt @@ -33,6 +33,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.database.server.ServerConnectionInfo import io.homeassistant.companion.android.database.server.ServerSessionInfo @@ -40,7 +41,6 @@ import io.homeassistant.companion.android.database.server.ServerUserInfo import io.homeassistant.companion.android.matter.MatterCommissioningViewModel.CommissioningFlowStep import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import kotlin.math.min -import io.homeassistant.companion.android.common.R as commonR @Composable fun MatterCommissioningView( diff --git a/app/src/full/java/io/homeassistant/companion/android/notifications/FirebaseCloudMessagingService.kt b/app/src/full/java/io/homeassistant/companion/android/notifications/FirebaseCloudMessagingService.kt index 1c01ff42a57..9065d8cf1f8 100644 --- a/app/src/full/java/io/homeassistant/companion/android/notifications/FirebaseCloudMessagingService.kt +++ b/app/src/full/java/io/homeassistant/companion/android/notifications/FirebaseCloudMessagingService.kt @@ -6,11 +6,11 @@ import com.google.firebase.messaging.RemoteMessage import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.data.integration.DeviceRegistration import io.homeassistant.companion.android.common.data.servers.ServerManager +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class FirebaseCloudMessagingService : FirebaseMessagingService() { diff --git a/app/src/full/java/io/homeassistant/companion/android/onboarding/WearOnboardingListener.kt b/app/src/full/java/io/homeassistant/companion/android/onboarding/WearOnboardingListener.kt index 079d2bb66ed..cf1474befd3 100644 --- a/app/src/full/java/io/homeassistant/companion/android/onboarding/WearOnboardingListener.kt +++ b/app/src/full/java/io/homeassistant/companion/android/onboarding/WearOnboardingListener.kt @@ -9,8 +9,8 @@ import com.google.android.gms.wearable.Wearable import com.google.android.gms.wearable.WearableListenerService import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.data.servers.ServerManager -import kotlinx.coroutines.runBlocking import javax.inject.Inject +import kotlinx.coroutines.runBlocking @AndroidEntryPoint @SuppressLint("VisibleForTests") // https://issuetracker.google.com/issues/239451111 diff --git a/app/src/full/java/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt b/app/src/full/java/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt index 43c4846e696..c07094f9a81 100644 --- a/app/src/full/java/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt +++ b/app/src/full/java/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt @@ -15,11 +15,11 @@ import com.google.android.gms.location.SleepClassifyEvent import com.google.android.gms.location.SleepSegmentEvent import com.google.android.gms.location.SleepSegmentRequest import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.sensors.SensorReceiverBase import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import java.util.concurrent.TimeUnit -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ActivitySensorManager : BroadcastReceiver(), SensorManager { @@ -234,11 +234,11 @@ class ActivitySensorManager : BroadcastReceiver(), SensorManager { } } if (( - isEnabled(context, sleepConfidence) || isEnabled( + isEnabled(context, sleepConfidence) || isEnabled( context, sleepSegment ) - ) && !sleepRegistration + ) && !sleepRegistration ) { val pendingIntent = getSleepPendingIntent(context) Log.d(TAG, "Registering for sleep updates") diff --git a/app/src/full/java/io/homeassistant/companion/android/sensors/AndroidAutoSensorManager.kt b/app/src/full/java/io/homeassistant/companion/android/sensors/AndroidAutoSensorManager.kt index 2d899c334bb..f94f3b888e6 100644 --- a/app/src/full/java/io/homeassistant/companion/android/sensors/AndroidAutoSensorManager.kt +++ b/app/src/full/java/io/homeassistant/companion/android/sensors/AndroidAutoSensorManager.kt @@ -5,12 +5,12 @@ import android.os.Build import android.util.Log import androidx.car.app.connection.CarConnection import androidx.lifecycle.Observer +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import io.homeassistant.companion.android.common.R as commonR class AndroidAutoSensorManager : SensorManager, Observer { diff --git a/app/src/full/java/io/homeassistant/companion/android/sensors/GeocodeSensorManager.kt b/app/src/full/java/io/homeassistant/companion/android/sensors/GeocodeSensorManager.kt index fc2b16647ca..a8b63d05985 100644 --- a/app/src/full/java/io/homeassistant/companion/android/sensors/GeocodeSensorManager.kt +++ b/app/src/full/java/io/homeassistant/companion/android/sensors/GeocodeSensorManager.kt @@ -8,19 +8,19 @@ import android.os.Build import android.os.Build.VERSION.SDK_INT import android.util.Log import com.google.android.gms.location.LocationServices +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.sensor.SensorSetting import io.homeassistant.companion.android.database.sensor.SensorSettingType import io.homeassistant.companion.android.location.HighAccuracyLocationService -import kotlinx.coroutines.MainScope -import kotlinx.coroutines.launch -import kotlinx.coroutines.tasks.await import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.tasks.await class GeocodeSensorManager : SensorManager { diff --git a/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt b/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt index d5d016341d4..d4e41f3f28f 100644 --- a/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt +++ b/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt @@ -27,6 +27,7 @@ import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.bluetooth.BluetoothUtils import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.UpdateLocation @@ -47,15 +48,14 @@ import io.homeassistant.companion.android.database.sensor.SensorSettingType import io.homeassistant.companion.android.database.sensor.toSensorWithAttributes import io.homeassistant.companion.android.location.HighAccuracyLocationService import io.homeassistant.companion.android.notifications.MessagingManager +import java.util.concurrent.TimeUnit +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import java.util.concurrent.TimeUnit -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class LocationSensorManager : BroadcastReceiver(), SensorManager { @@ -1125,7 +1125,9 @@ class LocationSensorManager : BroadcastReceiver(), SensorManager { ?.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, "HomeAssistant::AccurateLocation" - )?.apply { acquire(10 * 60 * 1000L /*10 minutes*/) } + )?.apply { + acquire(10 * 60 * 1000L) // 10 minutes + } var numberCalls = 0 override fun onLocationResult(locationResult: LocationResult) { numberCalls++ diff --git a/app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearActivity.kt b/app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearActivity.kt index 4bc961d0b52..d15d42d5564 100644 --- a/app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearActivity.kt +++ b/app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearActivity.kt @@ -19,6 +19,7 @@ import com.google.android.gms.wearable.CapabilityInfo import com.google.android.gms.wearable.Node import com.google.android.gms.wearable.NodeClient import com.google.android.gms.wearable.Wearable +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.databinding.ActivitySettingsWearBinding import io.homeassistant.companion.android.settings.HelpMenuProvider import io.homeassistant.companion.android.settings.wear.views.SettingsWearMainView @@ -28,7 +29,6 @@ import kotlinx.coroutines.guava.await import kotlinx.coroutines.launch import kotlinx.coroutines.tasks.await import kotlinx.coroutines.withContext -import io.homeassistant.companion.android.common.R as commonR class SettingsWearActivity : AppCompatActivity(), CapabilityClient.OnCapabilityChangedListener { diff --git a/app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearViewModel.kt b/app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearViewModel.kt index 2a26f85e37a..5b5217891d0 100644 --- a/app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearViewModel.kt +++ b/app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearViewModel.kt @@ -21,6 +21,7 @@ import com.google.android.gms.wearable.PutDataMapRequest import com.google.android.gms.wearable.Wearable import dagger.hilt.android.lifecycle.HiltViewModel import io.homeassistant.companion.android.HomeAssistantApplication +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.prefs.impl.entities.TemplateTileConfig import io.homeassistant.companion.android.common.data.servers.ServerManager @@ -30,6 +31,8 @@ import io.homeassistant.companion.android.database.server.ServerConnectionInfo import io.homeassistant.companion.android.database.server.ServerSessionInfo import io.homeassistant.companion.android.database.server.ServerType import io.homeassistant.companion.android.database.server.ServerUserInfo +import java.util.UUID +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -40,9 +43,6 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.tasks.await import org.burnoutcrew.reorderable.ItemPosition -import java.util.UUID -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @HiltViewModel @SuppressLint("VisibleForTests") // https://issuetracker.google.com/issues/239451111 diff --git a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearFavoritesView.kt b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearFavoritesView.kt index cb5a8ff8274..de4869fed60 100644 --- a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearFavoritesView.kt +++ b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearFavoritesView.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.friendlyName import io.homeassistant.companion.android.settings.wear.SettingsWearViewModel @@ -30,7 +31,6 @@ import kotlinx.coroutines.withContext import org.burnoutcrew.reorderable.ReorderableItem import org.burnoutcrew.reorderable.rememberReorderableLazyListState import org.burnoutcrew.reorderable.reorderable -import io.homeassistant.companion.android.common.R as commonR @Composable fun LoadWearFavoritesSettings( diff --git a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearHomeView.kt b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearHomeView.kt index a3987a51124..326fb70e24e 100644 --- a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearHomeView.kt +++ b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearHomeView.kt @@ -18,9 +18,9 @@ import androidx.navigation.compose.rememberNavController import androidx.navigation.navArgument import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.wear.SettingsWearViewModel import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR const val WEAR_DOCS_LINK = "https://companion.home-assistant.io/docs/wear-os/" diff --git a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearLandingView.kt b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearLandingView.kt index 6db3cadd6f3..42b4b9d3dfd 100644 --- a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearLandingView.kt +++ b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearLandingView.kt @@ -20,13 +20,13 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.views.SettingsRow import io.homeassistant.companion.android.util.wearDeviceName import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import io.homeassistant.companion.android.common.R as commonR @Composable fun SettingWearLandingView( diff --git a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearMainView.kt b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearMainView.kt index 936b08deada..dea533cc7eb 100644 --- a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearMainView.kt +++ b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearMainView.kt @@ -71,11 +71,12 @@ class SettingsWearMainView : AppCompatActivity() { url = registerUrl, defaultDeviceName = currentNodes.firstOrNull()?.displayName ?: "unknown", locationTrackingPossible = false, + // While notifications are technically possible, the app can't handle this for the Wear device notificationsPossible = false, isWatch = true, discoveryOptions = OnboardApp.DiscoveryOptions.ADD_EXISTING_EXTERNAL, mayRequireTlsClientCertificate = (application as HomeAssistantApplication).keyChainRepository.getPrivateKey() != null - ) // While notifications are technically possible, the app can't handle this for the Wear device + ) ) } diff --git a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTile.kt b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTile.kt index 73542dcfc43..e2a901d635e 100644 --- a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTile.kt +++ b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTile.kt @@ -43,8 +43,8 @@ import androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY import androidx.core.text.HtmlCompat.fromHtml import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial -import io.homeassistant.companion.android.util.intervalToString import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.util.intervalToString @Composable fun SettingsWearTemplateTile( diff --git a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt index 85329f96502..699d2f3c96b 100644 --- a/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt +++ b/app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt @@ -17,9 +17,9 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.impl.entities.TemplateTileConfig import io.homeassistant.companion.android.settings.views.SettingsRow -import io.homeassistant.companion.android.common.R as commonR @Composable fun SettingsWearTemplateTileList( diff --git a/app/src/full/java/io/homeassistant/companion/android/thread/ThreadManagerImpl.kt b/app/src/full/java/io/homeassistant/companion/android/thread/ThreadManagerImpl.kt index 0de92e53343..1dce4401195 100644 --- a/app/src/full/java/io/homeassistant/companion/android/thread/ThreadManagerImpl.kt +++ b/app/src/full/java/io/homeassistant/companion/android/thread/ThreadManagerImpl.kt @@ -16,12 +16,12 @@ import com.google.android.gms.threadnetwork.ThreadNetworkStatusCodes import io.homeassistant.companion.android.common.data.HomeAssistantVersion import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.data.websocket.impl.entities.ThreadDatasetResponse -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.async import javax.inject.Inject import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.async class ThreadManagerImpl @Inject constructor( private val serverManager: ServerManager, diff --git a/app/src/main/java/io/homeassistant/companion/android/HomeAssistantApplication.kt b/app/src/main/java/io/homeassistant/companion/android/HomeAssistantApplication.kt index 622743e2a68..6e3c7dcb4e5 100644 --- a/app/src/main/java/io/homeassistant/companion/android/HomeAssistantApplication.kt +++ b/app/src/main/java/io/homeassistant/companion/android/HomeAssistantApplication.kt @@ -26,12 +26,12 @@ import io.homeassistant.companion.android.widgets.button.ButtonWidget import io.homeassistant.companion.android.widgets.entity.EntityWidget import io.homeassistant.companion.android.widgets.mediaplayer.MediaPlayerControlsWidget import io.homeassistant.companion.android.widgets.template.TemplateWidget +import javax.inject.Inject +import javax.inject.Named import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import javax.inject.Inject -import javax.inject.Named @HiltAndroidApp open class HomeAssistantApplication : Application() { diff --git a/app/src/main/java/io/homeassistant/companion/android/assist/AssistViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/assist/AssistViewModel.kt index 39715e94f08..6918af2a2b7 100644 --- a/app/src/main/java/io/homeassistant/companion/android/assist/AssistViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/assist/AssistViewModel.kt @@ -11,14 +11,14 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import io.homeassistant.companion.android.assist.ui.AssistMessage import io.homeassistant.companion.android.assist.ui.AssistUiPipeline +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.assist.AssistViewModelBase import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.data.websocket.impl.entities.AssistPipelineResponse import io.homeassistant.companion.android.common.util.AudioRecorder import io.homeassistant.companion.android.common.util.AudioUrlPlayer -import kotlinx.coroutines.launch import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @HiltViewModel class AssistViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/assist/ui/AssistSheetView.kt b/app/src/main/java/io/homeassistant/companion/android/assist/ui/AssistSheetView.kt index 5630261b92b..f2ad7bfd721 100644 --- a/app/src/main/java/io/homeassistant/companion/android/assist/ui/AssistSheetView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/assist/ui/AssistSheetView.kt @@ -79,9 +79,9 @@ import androidx.compose.ui.unit.sp import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.assist.AssistViewModelBase import kotlinx.coroutines.launch -import io.homeassistant.companion.android.common.R as commonR @OptIn(ExperimentalMaterialApi::class) @Composable diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/CameraControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/CameraControl.kt index aa1569a294e..9b1bd598cf7 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/CameraControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/CameraControl.kt @@ -12,17 +12,17 @@ import android.service.controls.templates.ThumbnailTemplate import android.util.Log import androidx.annotation.RequiresApi import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse import io.homeassistant.companion.android.common.util.STATE_UNAVAILABLE +import java.net.URL +import java.util.concurrent.TimeUnit import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import kotlinx.coroutines.withTimeoutOrNull -import java.net.URL -import java.util.concurrent.TimeUnit -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.S) object CameraControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/ClimateControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/ClimateControl.kt index 3116f75d617..888da90b9ed 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/ClimateControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/ClimateControl.kt @@ -10,10 +10,10 @@ import android.service.controls.actions.ModeAction import android.service.controls.templates.RangeTemplate import android.service.controls.templates.TemperatureControlTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object ClimateControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/CoverControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/CoverControl.kt index 52ea1289bb2..5f9fda56b12 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/CoverControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/CoverControl.kt @@ -12,12 +12,12 @@ import android.service.controls.templates.RangeTemplate import android.service.controls.templates.ToggleRangeTemplate import android.service.controls.templates.ToggleTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.getCoverPosition import io.homeassistant.companion.android.common.data.integration.isActive import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object CoverControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/DefaultButtonControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/DefaultButtonControl.kt index e2ee174deb9..9c32c34ef73 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/DefaultButtonControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/DefaultButtonControl.kt @@ -7,13 +7,13 @@ import android.service.controls.DeviceTypes import android.service.controls.actions.ControlAction import android.service.controls.templates.StatelessTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.domain import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse import io.homeassistant.companion.android.common.util.capitalize import java.util.Locale -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object DefaultButtonControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/DefaultSliderControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/DefaultSliderControl.kt index f8d859d72ba..6bf65b9607f 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/DefaultSliderControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/DefaultSliderControl.kt @@ -8,11 +8,11 @@ import android.service.controls.actions.ControlAction import android.service.controls.actions.FloatAction import android.service.controls.templates.RangeTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse import kotlinx.coroutines.runBlocking -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object DefaultSliderControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/DefaultSwitchControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/DefaultSwitchControl.kt index a4873828c5d..53925aa38bd 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/DefaultSwitchControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/DefaultSwitchControl.kt @@ -9,6 +9,7 @@ import android.service.controls.actions.ControlAction import android.service.controls.templates.ControlButton import android.service.controls.templates.ToggleTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.domain @@ -16,7 +17,6 @@ import io.homeassistant.companion.android.common.data.integration.isActive import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse import io.homeassistant.companion.android.common.util.capitalize import java.util.Locale -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object DefaultSwitchControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/FanControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/FanControl.kt index a7821a972eb..385f855c239 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/FanControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/FanControl.kt @@ -12,13 +12,13 @@ import android.service.controls.templates.RangeTemplate import android.service.controls.templates.ToggleRangeTemplate import android.service.controls.templates.ToggleTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.getFanSpeed import io.homeassistant.companion.android.common.data.integration.isActive import io.homeassistant.companion.android.common.data.integration.supportsFanSetSpeed import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object FanControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/HaControlsPanelActivity.kt b/app/src/main/java/io/homeassistant/companion/android/controls/HaControlsPanelActivity.kt index f92141efdf9..a0bd550be54 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/HaControlsPanelActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/HaControlsPanelActivity.kt @@ -24,13 +24,13 @@ import androidx.compose.ui.unit.dp import androidx.core.content.getSystemService import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import io.homeassistant.companion.android.webview.WebViewActivity -import kotlinx.coroutines.launch import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @AndroidEntryPoint class HaControlsPanelActivity : AppCompatActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/HaControlsProviderService.kt b/app/src/main/java/io/homeassistant/companion/android/controls/HaControlsProviderService.kt index 9373a660d2c..a3806af2dd5 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/HaControlsProviderService.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/HaControlsProviderService.kt @@ -17,6 +17,10 @@ import io.homeassistant.companion.android.common.data.websocket.impl.entities.Ar import io.homeassistant.companion.android.common.data.websocket.impl.entities.DeviceRegistryResponse import io.homeassistant.companion.android.common.data.websocket.impl.entities.EntityRegistryResponse import io.homeassistant.companion.android.util.RegistriesDataHandler +import java.util.Calendar +import java.util.concurrent.Flow +import java.util.function.Consumer +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async @@ -28,10 +32,6 @@ import okhttp3.ResponseBody import okhttp3.ResponseBody.Companion.toResponseBody import retrofit2.HttpException import retrofit2.Response -import java.util.Calendar -import java.util.concurrent.Flow -import java.util.function.Consumer -import javax.inject.Inject @RequiresApi(Build.VERSION_CODES.R) @AndroidEntryPoint diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/LightControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/LightControl.kt index 9202a5416e6..112fec1a966 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/LightControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/LightControl.kt @@ -12,13 +12,13 @@ import android.service.controls.templates.RangeTemplate import android.service.controls.templates.ToggleRangeTemplate import android.service.controls.templates.ToggleTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.getLightBrightness import io.homeassistant.companion.android.common.data.integration.isActive import io.homeassistant.companion.android.common.data.integration.supportsLightBrightness import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object LightControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/LockControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/LockControl.kt index c33058ad124..ceaf6c9f62e 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/LockControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/LockControl.kt @@ -9,11 +9,11 @@ import android.service.controls.actions.ControlAction import android.service.controls.templates.ControlButton import android.service.controls.templates.ToggleTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.isActive import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object LockControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/controls/VacuumControl.kt b/app/src/main/java/io/homeassistant/companion/android/controls/VacuumControl.kt index 582bb2a5373..e881b22b6b8 100644 --- a/app/src/main/java/io/homeassistant/companion/android/controls/VacuumControl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/controls/VacuumControl.kt @@ -9,11 +9,11 @@ import android.service.controls.actions.ControlAction import android.service.controls.templates.ControlButton import android.service.controls.templates.ToggleTemplate import androidx.annotation.RequiresApi +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.isActive import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) object VacuumControl : HaControl { diff --git a/app/src/main/java/io/homeassistant/companion/android/launch/LaunchActivity.kt b/app/src/main/java/io/homeassistant/companion/android/launch/LaunchActivity.kt index 7268aaa7421..b015b246af5 100644 --- a/app/src/main/java/io/homeassistant/companion/android/launch/LaunchActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/launch/LaunchActivity.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.BuildConfig +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.DeviceRegistration import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.sensor.SensorDao @@ -32,15 +33,14 @@ import io.homeassistant.companion.android.settings.server.ServerChooserFragment import io.homeassistant.companion.android.util.UrlUtil import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import io.homeassistant.companion.android.webview.WebViewActivity +import javax.inject.Inject +import javax.net.ssl.SSLException +import javax.net.ssl.SSLHandshakeException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch import retrofit2.HttpException -import javax.inject.Inject -import javax.net.ssl.SSLException -import javax.net.ssl.SSLHandshakeException -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class LaunchActivity : AppCompatActivity(), LaunchView { diff --git a/app/src/main/java/io/homeassistant/companion/android/nfc/NfcSetupActivity.kt b/app/src/main/java/io/homeassistant/companion/android/nfc/NfcSetupActivity.kt index 0f7faf1eaa9..9bacc1dd7f9 100644 --- a/app/src/main/java/io/homeassistant/companion/android/nfc/NfcSetupActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/nfc/NfcSetupActivity.kt @@ -13,11 +13,11 @@ import androidx.activity.viewModels import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.BaseActivity +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.nfc.views.LoadNfcView import io.homeassistant.companion.android.util.UrlUtil import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import kotlinx.coroutines.launch -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class NfcSetupActivity : BaseActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/nfc/NfcViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/nfc/NfcViewModel.kt index f4983da5301..80073a4ba29 100644 --- a/app/src/main/java/io/homeassistant/companion/android/nfc/NfcViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/nfc/NfcViewModel.kt @@ -9,16 +9,16 @@ import androidx.compose.runtime.setValue import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.util.Navigator +import java.util.UUID +import javax.inject.Inject import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.launch -import java.util.UUID -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @HiltViewModel class NfcViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/nfc/TagReaderActivity.kt b/app/src/main/java/io/homeassistant/companion/android/nfc/TagReaderActivity.kt index 78e4c5b34b0..6326e0e376c 100644 --- a/app/src/main/java/io/homeassistant/companion/android/nfc/TagReaderActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/nfc/TagReaderActivity.kt @@ -10,15 +10,15 @@ import androidx.activity.compose.setContent import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.BaseActivity +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.nfc.views.TagReaderView import io.homeassistant.companion.android.util.UrlUtil import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme +import javax.inject.Inject import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.launch -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class TagReaderActivity : BaseActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/nfc/views/NfcNavigationView.kt b/app/src/main/java/io/homeassistant/companion/android/nfc/views/NfcNavigationView.kt index 9d41ab06adc..3a9c06f997e 100644 --- a/app/src/main/java/io/homeassistant/companion/android/nfc/views/NfcNavigationView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/nfc/views/NfcNavigationView.kt @@ -23,11 +23,11 @@ import androidx.compose.ui.res.stringResource import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.nfc.NfcSetupActivity import io.homeassistant.companion.android.nfc.NfcViewModel import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import io.homeassistant.companion.android.common.R as commonR @Composable fun LoadNfcView( diff --git a/app/src/main/java/io/homeassistant/companion/android/nfc/views/NfcWriteView.kt b/app/src/main/java/io/homeassistant/companion/android/nfc/views/NfcWriteView.kt index 901d4807c63..2197ea426b0 100644 --- a/app/src/main/java/io/homeassistant/companion/android/nfc/views/NfcWriteView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/nfc/views/NfcWriteView.kt @@ -27,8 +27,8 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial -import io.homeassistant.companion.android.util.compose.MdcAlertDialog import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.util.compose.MdcAlertDialog @Composable fun NfcWriteView( diff --git a/app/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt b/app/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt index 3b998a4a73e..ef8bea96696 100644 --- a/app/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt @@ -45,6 +45,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import dagger.hilt.android.qualifiers.ApplicationContext import io.homeassistant.companion.android.R import io.homeassistant.companion.android.authenticator.Authenticator +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.notifications.DeviceCommandData @@ -80,6 +81,11 @@ import io.homeassistant.companion.android.util.UrlUtil import io.homeassistant.companion.android.vehicle.HaCarAppService import io.homeassistant.companion.android.websocket.WebsocketManager import io.homeassistant.companion.android.webview.WebViewActivity +import java.io.File +import java.io.FileOutputStream +import java.net.URL +import java.net.URLDecoder +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers @@ -92,12 +98,6 @@ import kotlinx.coroutines.withContext import okhttp3.OkHttpClient import okhttp3.Request import org.json.JSONObject -import java.io.File -import java.io.FileOutputStream -import java.net.URL -import java.net.URLDecoder -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR class MessagingManager @Inject constructor( @ApplicationContext val context: Context, @@ -728,13 +728,13 @@ class MessagingManager @Inject constructor( PowerManager.ON_AFTER_RELEASE, "HomeAssistant::NotificationScreenOnWakeLock" ) - wakeLock?.acquire(1 * 30 * 1000L /*30 seconds */) + wakeLock?.acquire(1 * 30 * 1000L) // 30 seconds wakeLock?.release() } COMMAND_MEDIA -> { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { if (!NotificationManagerCompat.getEnabledListenerPackages(context) - .contains(context.packageName) + .contains(context.packageName) ) { notifyMissingPermission(message.toString(), serverId) } else { diff --git a/app/src/main/java/io/homeassistant/companion/android/notifications/NotificationActionReceiver.kt b/app/src/main/java/io/homeassistant/companion/android/notifications/NotificationActionReceiver.kt index 04a1b4a0b9d..6e29b8c6a66 100644 --- a/app/src/main/java/io/homeassistant/companion/android/notifications/NotificationActionReceiver.kt +++ b/app/src/main/java/io/homeassistant/companion/android/notifications/NotificationActionReceiver.kt @@ -10,16 +10,16 @@ import android.widget.Toast import androidx.core.app.NotificationManagerCompat import androidx.core.app.RemoteInput import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.util.cancel import io.homeassistant.companion.android.database.notification.NotificationDao import io.homeassistant.companion.android.notifications.MessagingManager.Companion.KEY_TEXT_REPLY +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class NotificationActionReceiver : BroadcastReceiver() { diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/authentication/AuthenticationFragment.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/authentication/AuthenticationFragment.kt index 401c5e1d03d..0260666c928 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/authentication/AuthenticationFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/authentication/AuthenticationFragment.kt @@ -24,6 +24,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.HomeAssistantApis import io.homeassistant.companion.android.common.data.authentication.impl.AuthenticationService import io.homeassistant.companion.android.common.data.keychain.KeyChainRepository @@ -33,11 +34,10 @@ import io.homeassistant.companion.android.themes.ThemesManager import io.homeassistant.companion.android.util.TLSWebViewClient import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import io.homeassistant.companion.android.util.isStarted -import okhttp3.HttpUrl -import okhttp3.HttpUrl.Companion.toHttpUrl import javax.inject.Inject import javax.inject.Named -import io.homeassistant.companion.android.common.R as commonR +import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrl @AndroidEntryPoint class AuthenticationFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/DiscoveryFragment.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/DiscoveryFragment.kt index 5dd3bc2c711..e02744b30d5 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/DiscoveryFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/DiscoveryFragment.kt @@ -16,8 +16,8 @@ import io.homeassistant.companion.android.onboarding.OnboardingViewModel import io.homeassistant.companion.android.onboarding.authentication.AuthenticationFragment import io.homeassistant.companion.android.onboarding.manual.ManualSetupFragment import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @AndroidEntryPoint class DiscoveryFragment @Inject constructor() : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/DiscoveryView.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/DiscoveryView.kt index cc6d82df9a1..2c1d7a94d4f 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/DiscoveryView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/DiscoveryView.kt @@ -26,9 +26,9 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.onboarding.OnboardingHeaderView import io.homeassistant.companion.android.onboarding.OnboardingViewModel -import io.homeassistant.companion.android.common.R as commonR @Composable fun DiscoveryView( diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/HomeAssistantSearcher.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/HomeAssistantSearcher.kt index ab0ef1d5c55..88c7bbd74fb 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/HomeAssistantSearcher.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/discovery/HomeAssistantSearcher.kt @@ -7,10 +7,10 @@ import android.util.Log import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import io.homeassistant.companion.android.common.data.HomeAssistantVersion -import okio.internal.commonToUtf8String import java.net.MalformedURLException import java.net.URL import java.util.concurrent.locks.ReentrantLock +import okio.internal.commonToUtf8String class HomeAssistantSearcher constructor( private val nsdManager: NsdManager, diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationFragment.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationFragment.kt index ac09f2e8d48..4b604420326 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationFragment.kt @@ -22,15 +22,15 @@ import androidx.fragment.app.activityViewModels import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.util.DisabledLocationHandler import io.homeassistant.companion.android.onboarding.OnboardingViewModel import io.homeassistant.companion.android.onboarding.notifications.NotificationPermissionFragment import io.homeassistant.companion.android.sensors.LocationSensorManager import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import kotlinx.coroutines.launch import java.io.IOException import java.security.KeyStore -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @AndroidEntryPoint class MobileAppIntegrationFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationView.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationView.kt index e7d11d13810..88cd678409c 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationView.kt @@ -37,9 +37,9 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.unit.dp import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.onboarding.OnboardingHeaderView import io.homeassistant.companion.android.onboarding.OnboardingViewModel -import io.homeassistant.companion.android.common.R as commonR @OptIn(ExperimentalComposeUiApi::class) @Composable diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupView.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupView.kt index 23e2d414884..663f884e913 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupView.kt @@ -21,9 +21,9 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.onboarding.OnboardingHeaderView import io.homeassistant.companion.android.onboarding.OnboardingViewModel -import io.homeassistant.companion.android.common.R as commonR @OptIn(ExperimentalComposeUiApi::class) @Composable diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/notifications/NotificationPermissionFragment.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/notifications/NotificationPermissionFragment.kt index f5d8f2a9be9..a9093cad89e 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/notifications/NotificationPermissionFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/notifications/NotificationPermissionFragment.kt @@ -14,9 +14,9 @@ import androidx.compose.ui.platform.ComposeView import androidx.core.app.NotificationManagerCompat import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.onboarding.OnboardingViewModel import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR class NotificationPermissionFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/notifications/NotificationPermissionView.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/notifications/NotificationPermissionView.kt index 9d98a1500f3..b590218f205 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/notifications/NotificationPermissionView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/notifications/NotificationPermissionView.kt @@ -23,9 +23,9 @@ import androidx.compose.ui.unit.dp import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.onboarding.OnboardingHeaderView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR @Composable fun NotificationPermissionView( diff --git a/app/src/main/java/io/homeassistant/companion/android/onboarding/welcome/WelcomeView.kt b/app/src/main/java/io/homeassistant/companion/android/onboarding/welcome/WelcomeView.kt index 999fe00b278..62d2d44f7d2 100644 --- a/app/src/main/java/io/homeassistant/companion/android/onboarding/welcome/WelcomeView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/onboarding/welcome/WelcomeView.kt @@ -28,8 +28,8 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import io.homeassistant.companion.android.R -import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme @Composable fun WelcomeView( diff --git a/app/src/main/java/io/homeassistant/companion/android/qs/TileExtensions.kt b/app/src/main/java/io/homeassistant/companion/android/qs/TileExtensions.kt index 658585e1c77..79969d988dd 100755 --- a/app/src/main/java/io/homeassistant/companion/android/qs/TileExtensions.kt +++ b/app/src/main/java/io/homeassistant/companion/android/qs/TileExtensions.kt @@ -21,6 +21,7 @@ import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.EntityExt import io.homeassistant.companion.android.common.data.integration.getIcon @@ -35,6 +36,7 @@ import io.homeassistant.companion.android.database.qs.numberedId import io.homeassistant.companion.android.settings.SettingsActivity import io.homeassistant.companion.android.settings.qs.updateActiveTileServices import io.homeassistant.companion.android.util.icondialog.getIconByMdiName +import javax.inject.Inject import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.MainScope @@ -42,8 +44,6 @@ import kotlinx.coroutines.cancel import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.N) @AndroidEntryPoint diff --git a/app/src/main/java/io/homeassistant/companion/android/sensors/CarSensorManager.kt b/app/src/main/java/io/homeassistant/companion/android/sensors/CarSensorManager.kt index 78a3fcd0e50..4493b79a121 100644 --- a/app/src/main/java/io/homeassistant/companion/android/sensors/CarSensorManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/sensors/CarSensorManager.kt @@ -148,7 +148,11 @@ class CarSensorManager : ) private enum class Listener { - ENERGY, MODEL, MILEAGE, STATUS, PROFILE + ENERGY, + MODEL, + MILEAGE, + STATUS, + PROFILE } private val listenerSensors = mapOf( diff --git a/app/src/main/java/io/homeassistant/companion/android/sensors/DynamicColorSensorManager.kt b/app/src/main/java/io/homeassistant/companion/android/sensors/DynamicColorSensorManager.kt index 9c63da70d3e..fc541211bbd 100755 --- a/app/src/main/java/io/homeassistant/companion/android/sensors/DynamicColorSensorManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/sensors/DynamicColorSensorManager.kt @@ -5,8 +5,8 @@ import androidx.core.graphics.blue import androidx.core.graphics.green import androidx.core.graphics.red import com.google.android.material.color.DynamicColors -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class DynamicColorSensorManager : SensorManager { companion object { @@ -51,7 +51,7 @@ class DynamicColorSensorManager : SensorManager { val dynamicColorContext = DynamicColors.wrapContextIfAvailable(context) val attrsToResolve = intArrayOf( - android.R.attr.colorAccent // 0 + android.R.attr.colorAccent ) val test = dynamicColorContext.obtainStyledAttributes(attrsToResolve) val accent = test.getColor(0, 0) diff --git a/app/src/main/java/io/homeassistant/companion/android/sensors/LastAppSensorManager.kt b/app/src/main/java/io/homeassistant/companion/android/sensors/LastAppSensorManager.kt index 25dc60af22b..5c628a305c2 100755 --- a/app/src/main/java/io/homeassistant/companion/android/sensors/LastAppSensorManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/sensors/LastAppSensorManager.kt @@ -8,9 +8,9 @@ import android.os.Build import android.util.Log import androidx.annotation.RequiresApi import androidx.core.content.getSystemService +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.util.STATE_UNKNOWN -import io.homeassistant.companion.android.common.R as commonR class LastAppSensorManager : SensorManager { companion object { diff --git a/app/src/main/java/io/homeassistant/companion/android/sensors/NotificationSensorManager.kt b/app/src/main/java/io/homeassistant/companion/android/sensors/NotificationSensorManager.kt index 0b1105ff9b5..f45375b7f42 100644 --- a/app/src/main/java/io/homeassistant/companion/android/sensors/NotificationSensorManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/sensors/NotificationSensorManager.kt @@ -16,11 +16,11 @@ import android.service.notification.StatusBarNotification import android.util.Log import androidx.core.app.NotificationManagerCompat import androidx.core.content.getSystemService +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.util.STATE_UNAVAILABLE import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.database.sensor.SensorSettingType -import io.homeassistant.companion.android.common.R as commonR class NotificationSensorManager : NotificationListenerService(), SensorManager { companion object { diff --git a/app/src/main/java/io/homeassistant/companion/android/sensors/QuestSensorManager.kt b/app/src/main/java/io/homeassistant/companion/android/sensors/QuestSensorManager.kt index 11312f047d3..831a457763a 100644 --- a/app/src/main/java/io/homeassistant/companion/android/sensors/QuestSensorManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/sensors/QuestSensorManager.kt @@ -4,8 +4,8 @@ import android.content.Context import android.content.Intent import android.content.IntentFilter import android.os.Build -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class QuestSensorManager : SensorManager { companion object { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/SettingViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/SettingViewModel.kt index 41d1eb2a6cf..bdaf70e85f0 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/SettingViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/SettingViewModel.kt @@ -9,8 +9,8 @@ import io.homeassistant.companion.android.database.settings.Setting import io.homeassistant.companion.android.database.settings.SettingsDao import io.homeassistant.companion.android.database.settings.WebsocketSetting import io.homeassistant.companion.android.websocket.WebsocketManager -import kotlinx.coroutines.flow.Flow import javax.inject.Inject +import kotlinx.coroutines.flow.Flow @HiltViewModel class SettingViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsActivity.kt b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsActivity.kt index 7efd051d4d9..9d25e8c3e60 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsActivity.kt @@ -18,15 +18,15 @@ import eightbitlab.com.blurview.RenderScriptBlur import io.homeassistant.companion.android.BaseActivity import io.homeassistant.companion.android.R import io.homeassistant.companion.android.authenticator.Authenticator +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.settings.notification.NotificationHistoryFragment import io.homeassistant.companion.android.settings.qs.ManageTilesFragment import io.homeassistant.companion.android.settings.sensor.SensorDetailFragment import io.homeassistant.companion.android.settings.server.ServerSettingsFragment import io.homeassistant.companion.android.settings.websocket.WebsocketSettingFragment -import kotlinx.coroutines.runBlocking import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.runBlocking @AndroidEntryPoint class SettingsActivity : BaseActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsFragment.kt index c1ec1bfa0b5..6c39a049b30 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsFragment.kt @@ -30,6 +30,7 @@ import com.google.android.material.snackbar.Snackbar import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.R import io.homeassistant.companion.android.authenticator.Authenticator +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.nfc.NfcSetupActivity import io.homeassistant.companion.android.onboarding.OnboardApp @@ -48,15 +49,14 @@ import io.homeassistant.companion.android.settings.wear.SettingsWearActivity import io.homeassistant.companion.android.settings.wear.SettingsWearDetection import io.homeassistant.companion.android.settings.widgets.ManageWidgetsSettingsFragment import io.homeassistant.companion.android.webview.WebViewActivity -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.sync.Mutex -import kotlinx.coroutines.sync.withLock import java.time.Instant import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.format.FormatStyle -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock class SettingsFragment( private val presenter: SettingsPresenter, @@ -137,7 +137,8 @@ class SettingsFragment( it.setOnPreferenceClickListener { requestOnboardingResult.launch( OnboardApp.Input( - url = "", // Empty url skips the 'Welcome' screen + // Empty url skips the 'Welcome' screen + url = "", discoveryOptions = OnboardApp.DiscoveryOptions.HIDE_EXISTING ) ) diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt index 08a2dc8cccc..26c9e81fff8 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt @@ -10,6 +10,7 @@ import androidx.core.content.getSystemService import androidx.preference.PreferenceDataStore import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.DeviceRegistration import io.homeassistant.companion.android.common.data.integration.impl.entities.RateLimitResponse import io.homeassistant.companion.android.common.data.prefs.PrefsRepository @@ -31,6 +32,7 @@ import io.homeassistant.companion.android.settings.language.LanguagesManager import io.homeassistant.companion.android.themes.ThemesManager import io.homeassistant.companion.android.util.ChangeLog import io.homeassistant.companion.android.util.UrlUtil +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -40,8 +42,6 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR class SettingsPresenterImpl @Inject constructor( private val serverManager: ServerManager, diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/controls/ManageControlsSettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/controls/ManageControlsSettingsFragment.kt index e273299361c..badda352eb5 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/controls/ManageControlsSettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/controls/ManageControlsSettingsFragment.kt @@ -10,13 +10,13 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.ControlsAuthRequiredSetting import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.controls.views.ManageControlsView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.TIRAMISU) @AndroidEntryPoint diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/controls/ManageControlsViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/controls/ManageControlsViewModel.kt index 687ef4ec5d1..8aa5998f74c 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/controls/ManageControlsViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/controls/ManageControlsViewModel.kt @@ -20,10 +20,10 @@ import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.controls.HaControlsPanelActivity import io.homeassistant.companion.android.controls.HaControlsProviderService +import javax.inject.Inject import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.launch -import javax.inject.Inject @RequiresApi(Build.VERSION_CODES.TIRAMISU) @HiltViewModel @@ -54,8 +54,8 @@ class ManageControlsViewModel @Inject constructor( if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { panelEnabled = application.packageManager.getComponentEnabledSetting( - ComponentName(application, HaControlsPanelActivity::class.java) - ) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED + ComponentName(application, HaControlsPanelActivity::class.java) + ) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED val panelServer = prefsRepository.getControlsPanelServer() val panelPath = prefsRepository.getControlsPanelPath() diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt index d7d469ce07b..26b77d85145 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt @@ -51,6 +51,7 @@ import androidx.compose.ui.unit.sp import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import io.homeassistant.companion.android.common.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.ControlsAuthRequiredSetting import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.domain @@ -59,7 +60,6 @@ import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.util.compose.HaAlertWarning import io.homeassistant.companion.android.util.compose.ServerExposedDropdownMenu import io.homeassistant.companion.android.util.compose.getEntityDomainString -import io.homeassistant.companion.android.common.R as commonR @Composable fun ManageControlsView( @@ -275,7 +275,8 @@ fun ManageControlsEntity( Checkbox( checked = selected, modifier = Modifier.padding(end = 16.dp), - onCheckedChange = null // Handled by parent Row clickable modifier + // Handled by parent Row clickable modifier + onCheckedChange = null ) Column( modifier = Modifier.weight(1f) @@ -324,14 +325,16 @@ fun ManageControlsModeButton( modifier = Modifier.fillMaxWidth() ) Text( - text = "${stringResource(if (isPanel) commonR.string.controls_setting_mode_panel_info else commonR.string.controls_setting_mode_builtin_info)}\n", // Newline for spacing + // Add newline at the end for spacing + text = "${stringResource(if (isPanel) commonR.string.controls_setting_mode_panel_info else commonR.string.controls_setting_mode_builtin_info)}\n", fontSize = 14.sp, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth() ) RadioButton( selected = selected, - onClick = null // Handled by parent + // Handled by parent + onClick = null ) } } diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/developer/DeveloperSettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/developer/DeveloperSettingsFragment.kt index 35d279b9616..c582856da6b 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/developer/DeveloperSettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/developer/DeveloperSettingsFragment.kt @@ -11,12 +11,12 @@ import androidx.preference.PreferenceFragmentCompat import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.settings.developer.location.LocationTrackingFragment import io.homeassistant.companion.android.settings.log.LogFragment import io.homeassistant.companion.android.settings.server.ServerChooserFragment import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class DeveloperSettingsFragment : DeveloperSettingsView, PreferenceFragmentCompat() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/developer/DeveloperSettingsPresenterImpl.kt b/app/src/main/java/io/homeassistant/companion/android/settings/developer/DeveloperSettingsPresenterImpl.kt index b0b69d4c2e6..7eae79d1507 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/developer/DeveloperSettingsPresenterImpl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/developer/DeveloperSettingsPresenterImpl.kt @@ -4,9 +4,11 @@ import android.content.Context import android.util.Log import androidx.activity.result.ActivityResult import androidx.preference.PreferenceDataStore +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.thread.ThreadManager +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -14,8 +16,6 @@ import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR class DeveloperSettingsPresenterImpl @Inject constructor( private val prefsRepository: PrefsRepository, diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/LocationTrackingFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/LocationTrackingFragment.kt index 02a653719c4..15913a70ef8 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/LocationTrackingFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/LocationTrackingFragment.kt @@ -17,11 +17,11 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.Lifecycle import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.settings.developer.location.views.LocationTrackingView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class LocationTrackingFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/LocationTrackingViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/LocationTrackingViewModel.kt index bb9bd741859..eed66811ba0 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/LocationTrackingViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/LocationTrackingViewModel.kt @@ -15,11 +15,11 @@ import io.homeassistant.companion.android.R import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.database.location.LocationHistoryDao import io.homeassistant.companion.android.database.location.LocationHistoryItemResult +import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.launch -import javax.inject.Inject @HiltViewModel class LocationTrackingViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/views/LocationTrackingView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/views/LocationTrackingView.kt index ea747601e92..c799ae0cc30 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/views/LocationTrackingView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/developer/location/views/LocationTrackingView.kt @@ -53,15 +53,15 @@ import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.itemKey import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.location.LocationHistoryItem import io.homeassistant.companion.android.database.location.LocationHistoryItemResult import io.homeassistant.companion.android.database.location.LocationHistoryItemTrigger import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.settings.views.EmptyState -import kotlinx.coroutines.flow.Flow import java.text.DateFormat import java.util.TimeZone -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.flow.Flow @Composable fun LocationTrackingView( @@ -91,7 +91,8 @@ fun LocationTrackingView( ) Switch( checked = useHistory, - onCheckedChange = null, // Handled by row + // Handled by row + onCheckedChange = null, modifier = Modifier.padding(start = 16.dp), colors = SwitchDefaults.colors(uncheckedThumbColor = colorResource(commonR.color.colorSwitchUncheckedThumb)) ) diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/language/LanguagesManager.kt b/app/src/main/java/io/homeassistant/companion/android/settings/language/LanguagesManager.kt index e8bbaf67aa4..ab8420126bf 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/language/LanguagesManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/language/LanguagesManager.kt @@ -5,11 +5,11 @@ import android.os.Build import android.util.Log import androidx.appcompat.app.AppCompatDelegate import androidx.core.os.LocaleListCompat +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.PrefsRepository +import javax.inject.Inject import kotlinx.coroutines.runBlocking import org.xmlpull.v1.XmlPullParser -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR class LanguagesManager @Inject constructor( private var prefs: PrefsRepository diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/language/LanguagesProvider.kt b/app/src/main/java/io/homeassistant/companion/android/settings/language/LanguagesProvider.kt index d8005967675..08c083cba57 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/language/LanguagesProvider.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/language/LanguagesProvider.kt @@ -1,10 +1,10 @@ package io.homeassistant.companion.android.settings.language import android.content.Context +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.util.capitalize import java.util.Locale import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR class LanguagesProvider @Inject constructor( private var langManager: LanguagesManager diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/log/LogFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/log/LogFragment.kt index 77d808eeead..270230eaf62 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/log/LogFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/log/LogFragment.kt @@ -29,15 +29,15 @@ import androidx.lifecycle.lifecycleScope import com.google.android.material.tabs.TabLayout import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.getLatestFatalCrash import io.homeassistant.companion.android.util.LogcatReader -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import java.io.File import java.util.Calendar import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch @AndroidEntryPoint class LogFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationChannelFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationChannelFragment.kt index 84e5b67b577..4218e744f1a 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationChannelFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationChannelFragment.kt @@ -10,10 +10,10 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.notification.views.NotificationChannelView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class NotificationChannelFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationDetailFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationDetailFragment.kt index 6804a5eb40a..176dc8b0a15 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationDetailFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationDetailFragment.kt @@ -14,13 +14,13 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.notification.NotificationDao import io.homeassistant.companion.android.database.notification.NotificationItem import io.homeassistant.companion.android.settings.notification.views.LoadNotification import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import kotlinx.coroutines.launch import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @AndroidEntryPoint class NotificationDetailFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationHistoryFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationHistoryFragment.kt index c9c06226547..e060651a544 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationHistoryFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/notification/NotificationHistoryFragment.kt @@ -16,13 +16,13 @@ import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.notification.NotificationDao import io.homeassistant.companion.android.database.notification.NotificationItem -import kotlinx.coroutines.launch import java.util.Calendar import java.util.GregorianCalendar import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @AndroidEntryPoint class NotificationHistoryFragment : PreferenceFragmentCompat() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/notification/views/NotificationDetailView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/notification/views/NotificationDetailView.kt index e5053757ede..a72868609f1 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/notification/views/NotificationDetailView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/notification/views/NotificationDetailView.kt @@ -18,11 +18,11 @@ import androidx.compose.ui.viewinterop.AndroidView import androidx.core.text.HtmlCompat import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.ObjectMapper +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.notification.NotificationItem import io.homeassistant.companion.android.util.notificationItem import java.util.Calendar import java.util.GregorianCalendar -import io.homeassistant.companion.android.common.R as commonR @Composable fun LoadNotification(notification: NotificationItem) { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesFragment.kt index 06faa730de4..10d3a7b3ac5 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesFragment.kt @@ -14,12 +14,12 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import com.mikepenz.iconics.typeface.IIcon import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.EntityExt import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.qs.views.ManageTilesView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import io.homeassistant.companion.android.util.icondialog.IconDialog -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ManageTilesFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesViewModel.kt index 26696969a29..5891104909f 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesViewModel.kt @@ -18,6 +18,7 @@ import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import dagger.hilt.android.lifecycle.HiltViewModel +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.domain import io.homeassistant.companion.android.common.data.integration.getIcon @@ -69,6 +70,8 @@ import io.homeassistant.companion.android.qs.Tile8Service import io.homeassistant.companion.android.qs.Tile9Service import io.homeassistant.companion.android.util.icondialog.getIconByMdiName import io.homeassistant.companion.android.util.icondialog.mdiName +import java.util.concurrent.Executors +import javax.inject.Inject import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll @@ -76,9 +79,6 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import java.util.concurrent.Executors -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @HiltViewModel class ManageTilesViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/qs/TileSlot.kt b/app/src/main/java/io/homeassistant/companion/android/settings/qs/TileSlot.kt index 487ce571c68..dfbc6689ef5 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/qs/TileSlot.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/qs/TileSlot.kt @@ -4,8 +4,8 @@ import android.content.ComponentName import android.content.Context import android.content.pm.PackageManager import android.content.res.Resources -import kotlin.math.min import io.homeassistant.companion.android.R as commonR +import kotlin.math.min data class TileSlot( val id: String, diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorDetailViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorDetailViewModel.kt index 1e1e6a0a0f0..a9e947b6e94 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorDetailViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorDetailViewModel.kt @@ -17,6 +17,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.bluetooth.BluetoothUtils import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.sensors.BluetoothSensorManager @@ -32,6 +33,7 @@ import io.homeassistant.companion.android.database.settings.SensorUpdateFrequenc import io.homeassistant.companion.android.database.settings.SettingsDao import io.homeassistant.companion.android.sensors.LastAppSensorManager import io.homeassistant.companion.android.sensors.SensorReceiver +import javax.inject.Inject import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.flow.Flow @@ -41,8 +43,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @HiltViewModel class SensorDetailViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorSettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorSettingsFragment.kt index 83aaea264d1..54ce284456f 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorSettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorSettingsFragment.kt @@ -19,9 +19,9 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.Lifecycle import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.sensor.views.SensorListView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class SensorSettingsFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorSettingsViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorSettingsViewModel.kt index aa98ebe0cbb..4586a25570f 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorSettingsViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorSettingsViewModel.kt @@ -13,8 +13,8 @@ import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.database.sensor.Sensor import io.homeassistant.companion.android.database.sensor.SensorDao import io.homeassistant.companion.android.sensors.SensorReceiver -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @HiltViewModel class SensorSettingsViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorUpdateFrequencyFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorUpdateFrequencyFragment.kt index 6bfc7b786b5..bfb59afad0a 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorUpdateFrequencyFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/SensorUpdateFrequencyFragment.kt @@ -9,11 +9,11 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.SettingViewModel import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.sensor.views.SensorUpdateFrequencyView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class SensorUpdateFrequencyFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorDetailView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorDetailView.kt index 7c3fd25cc00..af710a18397 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorDetailView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorDetailView.kt @@ -69,6 +69,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.database.sensor.SensorSetting import io.homeassistant.companion.android.database.sensor.SensorSettingType @@ -79,7 +80,6 @@ import io.homeassistant.companion.android.util.compose.MdcAlertDialog import io.homeassistant.companion.android.util.compose.TransparentChip import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import io.homeassistant.companion.android.common.R as commonR @Composable fun SensorDetailView( @@ -281,7 +281,9 @@ fun SensorDetailTopPanel( } val mdiIcon = try { IconicsDrawable(context, "cmd-${iconToUse.split(":")[1]}").icon - } catch (e: Exception) { null } + } catch (e: Exception) { + null + } if (mdiIcon != null) { Image( @@ -536,9 +538,9 @@ fun SensorDetailSettingDialog( } onSubmit(state.copy().apply { setting.value = inputValue.value }) } - } else { + } else { // list is saved when selecting a value null - }, // list is saved when selecting a value + }, contentPadding = if (listSettingDialog) PaddingValues(all = 0.dp) else PaddingValues(horizontal = 24.dp) ) } diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorListView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorListView.kt index 9fa6f2ea259..18f841af5be 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorListView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorListView.kt @@ -20,12 +20,12 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.mikepenz.iconics.IconicsDrawable +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.sensors.id import io.homeassistant.companion.android.database.sensor.Sensor import io.homeassistant.companion.android.settings.sensor.SensorSettingsViewModel import io.homeassistant.companion.android.settings.views.SettingsRow -import io.homeassistant.companion.android.common.R as commonR @OptIn(ExperimentalFoundationApi::class) @Composable @@ -92,7 +92,9 @@ fun SensorRow( } val mdiIcon = try { IconicsDrawable(context, "cmd-${iconToUse.split(":")[1]}").icon - } catch (e: Exception) { null } + } catch (e: Exception) { + null + } SettingsRow( primaryText = stringResource(basicSensor.name), diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorUpdateFrequencyView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorUpdateFrequencyView.kt index 9278aef1eca..e4be101e3ae 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorUpdateFrequencyView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/sensor/views/SensorUpdateFrequencyView.kt @@ -13,7 +13,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import io.homeassistant.companion.android.common.R -import io.homeassistant.companion.android.common.util.sensorWorkerChannel +import io.homeassistant.companion.android.common.util.CHANNEL_SENSOR_WORKER import io.homeassistant.companion.android.database.settings.SensorUpdateFrequencySetting import io.homeassistant.companion.android.util.compose.InfoNotification import io.homeassistant.companion.android.util.compose.RadioButtonRow @@ -50,7 +50,7 @@ fun SensorUpdateFrequencyView( if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { InfoNotification( infoString = R.string.sensor_update_notification, - channelId = sensorWorkerChannel, + channelId = CHANNEL_SENSOR_WORKER, buttonString = R.string.sensor_worker_notification_channel ) } diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerChooserView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerChooserView.kt index a10366e5366..86624e2665e 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerChooserView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerChooserView.kt @@ -14,9 +14,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.util.compose.ModalBottomSheet -import io.homeassistant.companion.android.common.R as commonR @Composable fun ServerChooserView( diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerSettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerSettingsFragment.kt index 9787c09016d..26326aef48e 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerSettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerSettingsFragment.kt @@ -25,6 +25,7 @@ import androidx.preference.SwitchPreference import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R import io.homeassistant.companion.android.authenticator.Authenticator +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.util.DisabledLocationHandler import io.homeassistant.companion.android.common.util.LocationPermissionInfoHandler import io.homeassistant.companion.android.launch.LaunchActivity @@ -33,10 +34,9 @@ import io.homeassistant.companion.android.settings.ssid.SsidFragment import io.homeassistant.companion.android.settings.url.ExternalUrlFragment import io.homeassistant.companion.android.settings.websocket.WebsocketSettingFragment import io.homeassistant.companion.android.webview.WebViewActivity +import javax.inject.Inject import kotlinx.coroutines.launch import okhttp3.HttpUrl.Companion.toHttpUrlOrNull -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ServerSettingsFragment : ServerSettingsView, PreferenceFragmentCompat() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerSettingsPresenterImpl.kt b/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerSettingsPresenterImpl.kt index 50b2818aa6e..459d9930624 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerSettingsPresenterImpl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/server/ServerSettingsPresenterImpl.kt @@ -4,13 +4,13 @@ import android.util.Log import androidx.preference.PreferenceDataStore import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.data.wifi.WifiHelper +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import javax.inject.Inject class ServerSettingsPresenterImpl @Inject constructor( private val serverManager: ServerManager, diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsSettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsSettingsFragment.kt index 49ca2d18c4e..37a98d1a920 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsSettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsSettingsFragment.kt @@ -16,11 +16,11 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import com.mikepenz.iconics.typeface.IIcon import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.shortcuts.views.ManageShortcutsView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import io.homeassistant.companion.android.util.icondialog.IconDialog -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.N_MR1) @AndroidEntryPoint diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsViewModel.kt index 219cc1ce98b..ff1b79a5ace 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsViewModel.kt @@ -36,10 +36,10 @@ import io.homeassistant.companion.android.util.icondialog.getIconByMdiName import io.homeassistant.companion.android.util.icondialog.mdiName import io.homeassistant.companion.android.webview.WebViewActivity import io.homeassistant.companion.android.widgets.assist.AssistShortcutActivity +import javax.inject.Inject import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import javax.inject.Inject @RequiresApi(Build.VERSION_CODES.N_MR1) @HiltViewModel diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/ssid/SsidFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/ssid/SsidFragment.kt index 115bdfaac1f..98d03a94017 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/ssid/SsidFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/ssid/SsidFragment.kt @@ -8,10 +8,10 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.ssid.views.SsidView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class SsidFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/ssid/SsidViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/ssid/SsidViewModel.kt index a9ccfd18288..1f847e597f9 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/ssid/SsidViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/ssid/SsidViewModel.kt @@ -11,8 +11,8 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.data.wifi.WifiHelper -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @HiltViewModel class SsidViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/ssid/views/SsidView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/ssid/views/SsidView.kt index 592f004933d..8b65df89a41 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/ssid/views/SsidView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/ssid/views/SsidView.kt @@ -51,8 +51,8 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import io.homeassistant.companion.android.common.data.wifi.WifiHelper import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.data.wifi.WifiHelper @OptIn( ExperimentalComposeUiApi::class, diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/url/ExternalUrlFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/url/ExternalUrlFragment.kt index eb5dd815bfb..0fc003f1909 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/url/ExternalUrlFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/url/ExternalUrlFragment.kt @@ -8,9 +8,9 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.url.views.ExternalUrlView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ExternalUrlFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/url/ExternalUrlViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/url/ExternalUrlViewModel.kt index b1b5149182b..31ddbfef3ac 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/url/ExternalUrlViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/url/ExternalUrlViewModel.kt @@ -12,8 +12,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel import io.homeassistant.companion.android.common.data.MalformedHttpUrlException import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.util.UrlUtil -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @HiltViewModel class ExternalUrlViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/url/views/ExternalUrlInputView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/url/views/ExternalUrlInputView.kt index 6f89d158d83..a6baff339ec 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/url/views/ExternalUrlInputView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/url/views/ExternalUrlInputView.kt @@ -28,8 +28,8 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.dp -import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import io.homeassistant.companion.android.common.R as commonR +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull @OptIn(ExperimentalComposeUiApi::class) @Composable diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoSettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoSettingsFragment.kt index f0be0e340fd..5bbe2364319 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoSettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoSettingsFragment.kt @@ -11,12 +11,12 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.vehicle.views.AndroidAutoFavoritesSettings import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ManageAndroidAutoSettingsFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt index f2b798d3483..58d99e9880c 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt @@ -15,11 +15,11 @@ import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.util.vehicle.isVehicleDomain +import javax.inject.Inject import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.launch import org.burnoutcrew.reorderable.ItemPosition -import javax.inject.Inject @RequiresApi(Build.VERSION_CODES.O) @HiltViewModel diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/views/AndroidAutoFavoritesView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/views/AndroidAutoFavoritesView.kt index 642b4ce3c1a..c2a07c0d4ab 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/views/AndroidAutoFavoritesView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/vehicle/views/AndroidAutoFavoritesView.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.friendlyName import io.homeassistant.companion.android.database.server.Server @@ -30,7 +31,6 @@ import kotlinx.coroutines.withContext import org.burnoutcrew.reorderable.ReorderableItem import org.burnoutcrew.reorderable.rememberReorderableLazyListState import org.burnoutcrew.reorderable.reorderable -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.O) @Composable diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/websocket/WebsocketSettingFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/websocket/WebsocketSettingFragment.kt index 314573a2996..ae0168e45d0 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/websocket/WebsocketSettingFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/websocket/WebsocketSettingFragment.kt @@ -19,13 +19,13 @@ import androidx.core.content.getSystemService import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.wifi.WifiHelper import io.homeassistant.companion.android.settings.SettingViewModel import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.websocket.views.WebsocketSettingView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class WebsocketSettingFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/websocket/views/WebsocketSettingView.kt b/app/src/main/java/io/homeassistant/companion/android/settings/websocket/views/WebsocketSettingView.kt index e95263fed1e..4e3c030d09a 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/websocket/views/WebsocketSettingView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/websocket/views/WebsocketSettingView.kt @@ -20,7 +20,7 @@ import androidx.compose.ui.unit.dp import androidx.core.content.getSystemService import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.common.R -import io.homeassistant.companion.android.common.util.websocketChannel +import io.homeassistant.companion.android.common.util.CHANNEL_WEBSOCKET import io.homeassistant.companion.android.database.settings.WebsocketSetting import io.homeassistant.companion.android.util.compose.HaAlertWarning import io.homeassistant.companion.android.util.compose.InfoNotification @@ -77,7 +77,7 @@ fun WebsocketSettingView( if (websocketSetting != WebsocketSetting.NEVER && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && uiManager?.currentModeType != Configuration.UI_MODE_TYPE_TELEVISION) { InfoNotification( infoString = R.string.websocket_persistent_notification, - channelId = websocketChannel, + channelId = CHANNEL_WEBSOCKET, buttonString = R.string.websocket_notification_channel ) } diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/widgets/ManageWidgetsSettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/widgets/ManageWidgetsSettingsFragment.kt index f330aed14d9..dd0b1e442f2 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/widgets/ManageWidgetsSettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/widgets/ManageWidgetsSettingsFragment.kt @@ -8,10 +8,10 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.settings.addHelpMenuProvider import io.homeassistant.companion.android.settings.widgets.views.ManageWidgetsView import io.homeassistant.companion.android.util.compose.HomeAssistantAppTheme -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ManageWidgetsSettingsFragment : Fragment() { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/widgets/ManageWidgetsViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/settings/widgets/ManageWidgetsViewModel.kt index 1495af237c6..87917e40d88 100755 --- a/app/src/main/java/io/homeassistant/companion/android/settings/widgets/ManageWidgetsViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/widgets/ManageWidgetsViewModel.kt @@ -16,9 +16,9 @@ import io.homeassistant.companion.android.database.widget.CameraWidgetDao import io.homeassistant.companion.android.database.widget.MediaPlayerControlsWidgetDao import io.homeassistant.companion.android.database.widget.StaticWidgetDao import io.homeassistant.companion.android.database.widget.TemplateWidgetDao +import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch -import javax.inject.Inject @HiltViewModel class ManageWidgetsViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/share/ShareActivity.kt b/app/src/main/java/io/homeassistant/companion/android/share/ShareActivity.kt index 38f97abde79..f2a47b03dda 100644 --- a/app/src/main/java/io/homeassistant/companion/android/share/ShareActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/share/ShareActivity.kt @@ -7,11 +7,11 @@ import android.widget.Toast import androidx.core.app.ActivityCompat import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.BaseActivity +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager +import javax.inject.Inject import kotlinx.coroutines.runBlocking import okhttp3.HttpUrl.Companion.toHttpUrlOrNull -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ShareActivity : BaseActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/themes/ThemesManager.kt b/app/src/main/java/io/homeassistant/companion/android/themes/ThemesManager.kt index 3220caf510f..e616aeb058e 100644 --- a/app/src/main/java/io/homeassistant/companion/android/themes/ThemesManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/themes/ThemesManager.kt @@ -8,8 +8,8 @@ import androidx.appcompat.app.AppCompatDelegate import androidx.webkit.WebSettingsCompat import androidx.webkit.WebViewFeature import io.homeassistant.companion.android.common.data.prefs.PrefsRepository -import kotlinx.coroutines.runBlocking import javax.inject.Inject +import kotlinx.coroutines.runBlocking class ThemesManager @Inject constructor( private val themesUseCase: PrefsRepository diff --git a/app/src/main/java/io/homeassistant/companion/android/util/DataUriDownloadManager.kt b/app/src/main/java/io/homeassistant/companion/android/util/DataUriDownloadManager.kt index df632686399..78253ba65ca 100644 --- a/app/src/main/java/io/homeassistant/companion/android/util/DataUriDownloadManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/util/DataUriDownloadManager.kt @@ -16,9 +16,8 @@ import android.util.Log import android.webkit.MimeTypeMap import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat -import io.homeassistant.companion.android.common.util.downloadsChannel -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext +import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.util.CHANNEL_DOWNLOADS import java.io.File import java.io.FileOutputStream import java.text.SimpleDateFormat @@ -26,7 +25,8 @@ import java.util.Date import java.util.Locale import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext object DataUriDownloadManager { private const val TAG = "DataUriDownloadMgr" @@ -44,7 +44,7 @@ object DataUriDownloadManager { val result = writeDataUriToFile(context, url, mime) createNotificationChannel(context) - val notification = NotificationCompat.Builder(context, downloadsChannel) + val notification = NotificationCompat.Builder(context, CHANNEL_DOWNLOADS) .setContentTitle(context.getString(commonR.string.downloads_unnamed_file)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setAutoCancel(true) @@ -145,7 +145,7 @@ object DataUriDownloadManager { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationManager = NotificationManagerCompat.from(context) val channel = NotificationChannel( - downloadsChannel, + CHANNEL_DOWNLOADS, context.getString(commonR.string.downloads), NotificationManager.IMPORTANCE_DEFAULT ) diff --git a/app/src/main/java/io/homeassistant/companion/android/util/LogcatReader.kt b/app/src/main/java/io/homeassistant/companion/android/util/LogcatReader.kt index a02debb57bf..68c383a8ce4 100644 --- a/app/src/main/java/io/homeassistant/companion/android/util/LogcatReader.kt +++ b/app/src/main/java/io/homeassistant/companion/android/util/LogcatReader.kt @@ -1,10 +1,10 @@ package io.homeassistant.companion.android.util import android.util.Log -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext import java.io.BufferedReader import java.io.InputStreamReader +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext object LogcatReader { const val TAG = "LogcatReader" diff --git a/app/src/main/java/io/homeassistant/companion/android/util/Navigator.kt b/app/src/main/java/io/homeassistant/companion/android/util/Navigator.kt index 0ca08642436..9174c6c5f7a 100644 --- a/app/src/main/java/io/homeassistant/companion/android/util/Navigator.kt +++ b/app/src/main/java/io/homeassistant/companion/android/util/Navigator.kt @@ -4,15 +4,15 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow class Navigator { - private val _sharedFlow = MutableSharedFlow(extraBufferCapacity = 1) - val flow = _sharedFlow.asSharedFlow() + private val mutableFlow = MutableSharedFlow(extraBufferCapacity = 1) + val flow = mutableFlow.asSharedFlow() fun navigateTo(navTarget: String) { - _sharedFlow.tryEmit(NavigatorItem(navTarget)) + mutableFlow.tryEmit(NavigatorItem(navTarget)) } fun navigateTo(navItem: NavigatorItem) { - _sharedFlow.tryEmit(navItem) + mutableFlow.tryEmit(navItem) } data class NavigatorItem( diff --git a/app/src/main/java/io/homeassistant/companion/android/util/OnSwipeListener.kt b/app/src/main/java/io/homeassistant/companion/android/util/OnSwipeListener.kt index bc2e8111276..9e40c6cbb14 100644 --- a/app/src/main/java/io/homeassistant/companion/android/util/OnSwipeListener.kt +++ b/app/src/main/java/io/homeassistant/companion/android/util/OnSwipeListener.kt @@ -157,7 +157,10 @@ abstract class OnSwipeListener(context: Context?) : View.OnTouchListener { ): Boolean enum class SwipeDirection { - UP, DOWN, LEFT, RIGHT; + UP, + DOWN, + LEFT, + RIGHT; companion object { fun fromVelocity(velocityX: Float, velocityY: Float): SwipeDirection { diff --git a/app/src/main/java/io/homeassistant/companion/android/util/TLSWebViewClient.kt b/app/src/main/java/io/homeassistant/companion/android/util/TLSWebViewClient.kt index 706e895b2a2..4e0f3d7cb9e 100644 --- a/app/src/main/java/io/homeassistant/companion/android/util/TLSWebViewClient.kt +++ b/app/src/main/java/io/homeassistant/companion/android/util/TLSWebViewClient.kt @@ -13,13 +13,13 @@ import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope import io.homeassistant.companion.android.common.data.keychain.KeyChainRepository -import kotlinx.coroutines.launch import java.security.Principal import java.security.PrivateKey import java.security.cert.CertificateException import java.security.cert.X509Certificate import javax.inject.Inject import javax.inject.Named +import kotlinx.coroutines.launch open class TLSWebViewClient @Inject constructor(@Named("keyChainRepository") private var keyChainRepository: KeyChainRepository) : WebViewClient() { diff --git a/app/src/main/java/io/homeassistant/companion/android/util/compose/ExposedDropdownMenu.kt b/app/src/main/java/io/homeassistant/companion/android/util/compose/ExposedDropdownMenu.kt index 9c78d5dbb7c..41fa7ddefb6 100644 --- a/app/src/main/java/io/homeassistant/companion/android/util/compose/ExposedDropdownMenu.kt +++ b/app/src/main/java/io/homeassistant/companion/android/util/compose/ExposedDropdownMenu.kt @@ -16,8 +16,8 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.stringResource -import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.database.server.Server @OptIn(ExperimentalMaterialApi::class) @Composable diff --git a/app/src/main/java/io/homeassistant/companion/android/util/compose/SingleEntityPicker.kt b/app/src/main/java/io/homeassistant/companion/android/util/compose/SingleEntityPicker.kt index b0a174532fe..580f449235b 100644 --- a/app/src/main/java/io/homeassistant/companion/android/util/compose/SingleEntityPicker.kt +++ b/app/src/main/java/io/homeassistant/companion/android/util/compose/SingleEntityPicker.kt @@ -31,11 +31,11 @@ import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.friendlyName import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import io.homeassistant.companion.android.common.R as commonR @OptIn(ExperimentalMaterialApi::class) @Composable diff --git a/app/src/main/java/io/homeassistant/companion/android/util/vehicle/GridItems.kt b/app/src/main/java/io/homeassistant/companion/android/util/vehicle/GridItems.kt index d5a9803b979..11286ff94b5 100755 --- a/app/src/main/java/io/homeassistant/companion/android/util/vehicle/GridItems.kt +++ b/app/src/main/java/io/homeassistant/companion/android/util/vehicle/GridItems.kt @@ -28,12 +28,12 @@ import io.homeassistant.companion.android.vehicle.ChangeServerScreen import io.homeassistant.companion.android.vehicle.DomainListScreen import io.homeassistant.companion.android.vehicle.EntityGridVehicleScreen import io.homeassistant.companion.android.vehicle.MapVehicleScreen +import java.util.Calendar +import java.util.Locale import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch -import java.util.Calendar -import java.util.Locale private const val TAG = "GridItems" diff --git a/app/src/main/java/io/homeassistant/companion/android/vehicle/ChangeServerScreen.kt b/app/src/main/java/io/homeassistant/companion/android/vehicle/ChangeServerScreen.kt index 5cb197fb7a9..e450fcf4a8d 100644 --- a/app/src/main/java/io/homeassistant/companion/android/vehicle/ChangeServerScreen.kt +++ b/app/src/main/java/io/homeassistant/companion/android/vehicle/ChangeServerScreen.kt @@ -7,9 +7,9 @@ import androidx.car.app.model.ItemList import androidx.car.app.model.ListTemplate import androidx.car.app.model.Row import androidx.car.app.model.Template +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import kotlinx.coroutines.flow.StateFlow -import io.homeassistant.companion.android.common.R as commonR class ChangeServerScreen( carContext: CarContext, diff --git a/app/src/main/java/io/homeassistant/companion/android/vehicle/HaCarAppService.kt b/app/src/main/java/io/homeassistant/companion/android/vehicle/HaCarAppService.kt index 7c3a5cc24a4..d45eec0af4b 100644 --- a/app/src/main/java/io/homeassistant/companion/android/vehicle/HaCarAppService.kt +++ b/app/src/main/java/io/homeassistant/companion/android/vehicle/HaCarAppService.kt @@ -19,6 +19,7 @@ import io.homeassistant.companion.android.R import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableStateFlow @@ -27,7 +28,6 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.shareIn import kotlinx.coroutines.launch import okhttp3.internal.toImmutableMap -import javax.inject.Inject @RequiresApi(Build.VERSION_CODES.O) @AndroidEntryPoint diff --git a/app/src/main/java/io/homeassistant/companion/android/vehicle/LoginScreen.kt b/app/src/main/java/io/homeassistant/companion/android/vehicle/LoginScreen.kt index 4dd383e53ce..d5c0d39ef3e 100644 --- a/app/src/main/java/io/homeassistant/companion/android/vehicle/LoginScreen.kt +++ b/app/src/main/java/io/homeassistant/companion/android/vehicle/LoginScreen.kt @@ -27,13 +27,13 @@ class LoginScreen(context: CarContext, val serverManager: ServerManager) : Scree lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) { isLoggedIn = serverManager.isRegistered() && serverManager.authenticationRepository() - .getSessionState() == SessionState.CONNECTED + .getSessionState() == SessionState.CONNECTED invalidate() while (isLoggedIn != true) { delay(1000) isLoggedIn = serverManager.isRegistered() && serverManager.authenticationRepository() - .getSessionState() == SessionState.CONNECTED + .getSessionState() == SessionState.CONNECTED } if (isLoggedIn == true) { screenManager.pop() diff --git a/app/src/main/java/io/homeassistant/companion/android/vehicle/MainVehicleScreen.kt b/app/src/main/java/io/homeassistant/companion/android/vehicle/MainVehicleScreen.kt index 760f7910e8e..9ca84ca1289 100644 --- a/app/src/main/java/io/homeassistant/companion/android/vehicle/MainVehicleScreen.kt +++ b/app/src/main/java/io/homeassistant/companion/android/vehicle/MainVehicleScreen.kt @@ -12,6 +12,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import io.homeassistant.companion.android.BuildConfig +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.authentication.SessionState import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.domain @@ -30,7 +31,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.launch -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.O) class MainVehicleScreen( @@ -63,13 +63,13 @@ class MainVehicleScreen( favoritesList = prefsRepository.getAutoFavorites() isLoggedIn = serverManager.isRegistered() && serverManager.authenticationRepository() - .getSessionState() == SessionState.CONNECTED + .getSessionState() == SessionState.CONNECTED invalidate() while (isLoggedIn != true) { delay(1000) isLoggedIn = serverManager.isRegistered() && serverManager.authenticationRepository() - .getSessionState() == SessionState.CONNECTED + .getSessionState() == SessionState.CONNECTED invalidate() } serverId.collect { server -> diff --git a/app/src/main/java/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt b/app/src/main/java/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt index f5f459bea10..c3170df2d08 100644 --- a/app/src/main/java/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt +++ b/app/src/main/java/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt @@ -22,6 +22,7 @@ import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.utils.sizeDp import com.mikepenz.iconics.utils.toAndroidIconCompat import io.homeassistant.companion.android.common.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.EntityExt import io.homeassistant.companion.android.common.data.integration.IntegrationRepository @@ -32,7 +33,6 @@ import io.homeassistant.companion.android.common.data.integration.getIcon import io.homeassistant.companion.android.common.data.integration.isActive import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.O) class MapVehicleScreen( diff --git a/app/src/main/java/io/homeassistant/companion/android/websocket/WebsocketManager.kt b/app/src/main/java/io/homeassistant/companion/android/websocket/WebsocketManager.kt index a8d9008ea9a..a6951d97b33 100644 --- a/app/src/main/java/io/homeassistant/companion/android/websocket/WebsocketManager.kt +++ b/app/src/main/java/io/homeassistant/companion/android/websocket/WebsocketManager.kt @@ -24,14 +24,16 @@ import dagger.hilt.components.SingletonComponent import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.common.R import io.homeassistant.companion.android.common.data.servers.ServerManager -import io.homeassistant.companion.android.common.util.websocketChannel -import io.homeassistant.companion.android.common.util.websocketIssuesChannel +import io.homeassistant.companion.android.common.util.CHANNEL_WEBSOCKET +import io.homeassistant.companion.android.common.util.CHANNEL_WEBSOCKET_ISSUES import io.homeassistant.companion.android.database.settings.SettingsDao import io.homeassistant.companion.android.database.settings.WebsocketSetting import io.homeassistant.companion.android.notifications.MessagingManager import io.homeassistant.companion.android.settings.SettingsActivity import io.homeassistant.companion.android.util.hasActiveConnection import io.homeassistant.companion.android.webview.WebViewActivity +import java.lang.IllegalStateException +import java.util.concurrent.TimeUnit import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -40,8 +42,6 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import java.lang.IllegalStateException -import java.util.concurrent.TimeUnit class WebsocketManager( appContext: Context, @@ -214,10 +214,10 @@ class WebsocketManager( private suspend fun createNotification(): Boolean { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { var notificationChannel = - notificationManager.getNotificationChannel(websocketChannel) + notificationManager.getNotificationChannel(CHANNEL_WEBSOCKET) if (notificationChannel == null) { notificationChannel = NotificationChannel( - websocketChannel, + CHANNEL_WEBSOCKET, applicationContext.getString(R.string.websocket_setting_name), NotificationManager.IMPORTANCE_LOW ) @@ -247,13 +247,13 @@ class WebsocketManager( settingIntent, PendingIntent.FLAG_IMMUTABLE ) - val notification = NotificationCompat.Builder(applicationContext, websocketChannel) + val notification = NotificationCompat.Builder(applicationContext, CHANNEL_WEBSOCKET) .setSmallIcon(R.drawable.ic_stat_ic_notification) .setContentTitle(applicationContext.getString(R.string.websocket_listening)) .setContentIntent(pendingIntent) .setPriority(NotificationCompat.PRIORITY_LOW) .setOngoing(true) - .setGroup(websocketChannel) + .setGroup(CHANNEL_WEBSOCKET) .addAction( io.homeassistant.companion.android.R.drawable.ic_websocket, applicationContext.getString(R.string.settings), @@ -268,16 +268,16 @@ class WebsocketManager( Log.e(TAG, "Unable to setForeground due to restrictions", e) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - if (notificationManager.getNotificationChannel(websocketIssuesChannel) == null) { + if (notificationManager.getNotificationChannel(CHANNEL_WEBSOCKET_ISSUES) == null) { val restrictedNotificationChannel = NotificationChannel( - websocketIssuesChannel, + CHANNEL_WEBSOCKET_ISSUES, applicationContext.getString(R.string.websocket_notification_issues), NotificationManager.IMPORTANCE_DEFAULT ) notificationManager.createNotificationChannel(restrictedNotificationChannel) } } - val restrictedNotification = NotificationCompat.Builder(applicationContext, websocketIssuesChannel) + val restrictedNotification = NotificationCompat.Builder(applicationContext, CHANNEL_WEBSOCKET_ISSUES) .setSmallIcon(R.drawable.ic_stat_ic_notification) .setContentTitle(applicationContext.getString(R.string.websocket_restricted_title)) .setContentText(applicationContext.getString(R.string.websocket_restricted_fix)) diff --git a/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt b/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt index 26b4438f0e3..fbd4e2635e6 100644 --- a/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt @@ -78,6 +78,7 @@ import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.R import io.homeassistant.companion.android.assist.AssistActivity import io.homeassistant.companion.android.authenticator.Authenticator +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.HomeAssistantApis import io.homeassistant.companion.android.common.data.keychain.KeyChainRepository import io.homeassistant.companion.android.common.data.servers.ServerManager @@ -101,6 +102,9 @@ import io.homeassistant.companion.android.util.TLSWebViewClient import io.homeassistant.companion.android.util.isStarted import io.homeassistant.companion.android.websocket.WebsocketManager import io.homeassistant.companion.android.webview.WebView.ErrorType +import java.util.concurrent.Executors +import javax.inject.Inject +import javax.inject.Named import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -113,10 +117,6 @@ import kotlinx.coroutines.withContext import okhttp3.HttpUrl.Companion.toHttpUrl import org.chromium.net.CronetEngine import org.json.JSONObject -import java.util.concurrent.Executors -import javax.inject.Inject -import javax.inject.Named -import io.homeassistant.companion.android.common.R as commonR @OptIn(androidx.media3.common.util.UnstableApi::class) @AndroidEntryPoint @@ -490,9 +490,9 @@ class WebViewActivity : BaseActivity(), io.homeassistant.companion.android.webvi if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q || ActivityCompat.checkSelfPermission( - context, - android.Manifest.permission.WRITE_EXTERNAL_STORAGE - ) == PackageManager.PERMISSION_GRANTED + context, + android.Manifest.permission.WRITE_EXTERNAL_STORAGE + ) == PackageManager.PERMISSION_GRANTED ) { downloadFile(url, contentDisposition, mimetype) } else { diff --git a/app/src/main/java/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt b/app/src/main/java/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt index bff68bef3f7..20eb6212bd5 100644 --- a/app/src/main/java/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt @@ -8,6 +8,7 @@ import android.net.Uri import android.util.Log import androidx.activity.result.ActivityResult import dagger.hilt.android.qualifiers.ActivityContext +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.authentication.SessionState import io.homeassistant.companion.android.common.data.prefs.PrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager @@ -16,6 +17,13 @@ import io.homeassistant.companion.android.matter.MatterManager import io.homeassistant.companion.android.thread.ThreadManager import io.homeassistant.companion.android.util.UrlUtil import io.homeassistant.companion.android.util.UrlUtil.baseIsEqual +import java.net.SocketTimeoutException +import java.net.URL +import java.util.regex.Matcher +import java.util.regex.Pattern +import javax.inject.Inject +import javax.net.ssl.SSLException +import javax.net.ssl.SSLHandshakeException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -27,14 +35,6 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext -import java.net.SocketTimeoutException -import java.net.URL -import java.util.regex.Matcher -import java.util.regex.Pattern -import javax.inject.Inject -import javax.net.ssl.SSLException -import javax.net.ssl.SSLHandshakeException -import io.homeassistant.companion.android.common.R as commonR class WebViewPresenterImpl @Inject constructor( @ActivityContext context: Context, @@ -57,7 +57,7 @@ class WebViewPresenterImpl @Inject constructor( private var url: URL? = null private var urlForServer: Int? = null - private val _matterThreadStep = MutableStateFlow(MatterThreadStep.NOT_STARTED) + private val mutableMatterThreadStep = MutableStateFlow(MatterThreadStep.NOT_STARTED) private var matterThreadIntentSender: IntentSender? = null @@ -342,8 +342,8 @@ class WebViewPresenterImpl @Inject constructor( override fun appCanCommissionMatterDevice(): Boolean = matterUseCase.appSupportsCommissioning() override fun startCommissioningMatterDevice(context: Context) { - if (_matterThreadStep.value != MatterThreadStep.REQUESTED) { - _matterThreadStep.tryEmit(MatterThreadStep.REQUESTED) + if (mutableMatterThreadStep.value != MatterThreadStep.REQUESTED) { + mutableMatterThreadStep.tryEmit(MatterThreadStep.REQUESTED) // The app used to sync Thread credentials here until commit 26a472a, but it was // (temporarily?) removed due to slowing down the Matter commissioning flow for the user @@ -359,11 +359,11 @@ class WebViewPresenterImpl @Inject constructor( { intentSender -> Log.d(TAG, "Matter commissioning is ready") matterThreadIntentSender = intentSender - _matterThreadStep.tryEmit(MatterThreadStep.MATTER_IN_PROGRESS) + mutableMatterThreadStep.tryEmit(MatterThreadStep.MATTER_IN_PROGRESS) }, { e -> Log.e(TAG, "Matter commissioning couldn't be prepared", e) - _matterThreadStep.tryEmit(MatterThreadStep.ERROR_MATTER) + mutableMatterThreadStep.tryEmit(MatterThreadStep.ERROR_MATTER) } ) } @@ -371,8 +371,8 @@ class WebViewPresenterImpl @Inject constructor( override fun appCanExportThreadCredentials(): Boolean = threadUseCase.appSupportsThread() override fun exportThreadCredentials(context: Context) { - if (_matterThreadStep.value != MatterThreadStep.REQUESTED) { - _matterThreadStep.tryEmit(MatterThreadStep.REQUESTED) + if (mutableMatterThreadStep.value != MatterThreadStep.REQUESTED) { + mutableMatterThreadStep.tryEmit(MatterThreadStep.REQUESTED) mainScope.launch { try { @@ -382,29 +382,29 @@ class WebViewPresenterImpl @Inject constructor( when (result) { is ThreadManager.SyncResult.OnlyOnDevice -> { matterThreadIntentSender = result.exportIntent - _matterThreadStep.tryEmit(MatterThreadStep.THREAD_EXPORT_TO_SERVER_ONLY) + mutableMatterThreadStep.tryEmit(MatterThreadStep.THREAD_EXPORT_TO_SERVER_ONLY) } is ThreadManager.SyncResult.NoneHaveCredentials, is ThreadManager.SyncResult.OnlyOnServer -> { - _matterThreadStep.tryEmit(MatterThreadStep.THREAD_NONE) + mutableMatterThreadStep.tryEmit(MatterThreadStep.THREAD_NONE) } is ThreadManager.SyncResult.NotConnected -> { - _matterThreadStep.tryEmit(MatterThreadStep.ERROR_THREAD_LOCAL_NETWORK) + mutableMatterThreadStep.tryEmit(MatterThreadStep.ERROR_THREAD_LOCAL_NETWORK) } else -> { - _matterThreadStep.tryEmit(MatterThreadStep.ERROR_THREAD_OTHER) + mutableMatterThreadStep.tryEmit(MatterThreadStep.ERROR_THREAD_OTHER) } } } catch (e: Exception) { Log.w(TAG, "Unable to export preferred Thread dataset", e) - _matterThreadStep.tryEmit(MatterThreadStep.ERROR_THREAD_OTHER) + mutableMatterThreadStep.tryEmit(MatterThreadStep.ERROR_THREAD_OTHER) } } } // else already waiting for a result, don't send another request } override fun getMatterThreadStepFlow(): Flow = - _matterThreadStep.asStateFlow() + mutableMatterThreadStep.asStateFlow() override fun getMatterThreadIntent(): IntentSender? { val intent = matterThreadIntentSender @@ -413,7 +413,7 @@ class WebViewPresenterImpl @Inject constructor( } override fun onMatterThreadIntentResult(context: Context, result: ActivityResult) { - when (_matterThreadStep.value) { + when (mutableMatterThreadStep.value) { MatterThreadStep.THREAD_EXPORT_TO_SERVER_MATTER -> { mainScope.launch { threadUseCase.sendThreadDatasetExportResult(result, serverId) @@ -425,9 +425,9 @@ class WebViewPresenterImpl @Inject constructor( val sent = threadUseCase.sendThreadDatasetExportResult(result, serverId) Log.d(TAG, "Thread ${if (!sent.isNullOrBlank()) "sent credential for $sent" else "did not send credential"}") if (sent.isNullOrBlank()) { - _matterThreadStep.tryEmit(MatterThreadStep.THREAD_NONE) + mutableMatterThreadStep.tryEmit(MatterThreadStep.THREAD_NONE) } else { - _matterThreadStep.tryEmit(MatterThreadStep.THREAD_SENT) + mutableMatterThreadStep.tryEmit(MatterThreadStep.THREAD_SENT) } } } @@ -443,6 +443,6 @@ class WebViewPresenterImpl @Inject constructor( } override fun finishMatterThreadFlow() { - _matterThreadStep.tryEmit(MatterThreadStep.NOT_STARTED) + mutableMatterThreadStep.tryEmit(MatterThreadStep.NOT_STARTED) } } diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/BaseWidgetConfigureActivity.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/BaseWidgetConfigureActivity.kt index 318f9c0e353..e232ffd653f 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/BaseWidgetConfigureActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/BaseWidgetConfigureActivity.kt @@ -53,7 +53,9 @@ abstract class BaseWidgetConfigureActivity : BaseActivity() { val newId = serverManager.defaultServers.getOrNull(position)?.id val isDifferent = selectedServerId != newId selectedServerId = newId - if (isDifferent && newId != null) { onServerSelected(newId) } + if (isDifferent && newId != null) { + onServerSelected(newId) + } } override fun onNothingSelected(parent: AdapterView<*>?) { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/BaseWidgetProvider.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/BaseWidgetProvider.kt index e193b261ad9..662ca074dc9 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/BaseWidgetProvider.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/BaseWidgetProvider.kt @@ -11,13 +11,13 @@ import android.util.Log import android.widget.RemoteViews import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.servers.ServerManager +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import javax.inject.Inject /** * A widget provider class for widgets that update based on entity state changes. diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/assist/AssistShortcutView.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/assist/AssistShortcutView.kt index 34eb7d0b1e8..bf7e85f72cc 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/assist/AssistShortcutView.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/assist/AssistShortcutView.kt @@ -26,12 +26,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.assist.AssistViewModelBase import io.homeassistant.companion.android.common.data.websocket.impl.entities.AssistPipelineListResponse import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.util.compose.ExposedDropdownMenu import io.homeassistant.companion.android.util.compose.ServerExposedDropdownMenu -import io.homeassistant.companion.android.common.R as commonR @Composable fun AssistShortcutView( diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/assist/AssistShortcutViewModel.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/assist/AssistShortcutViewModel.kt index 8039f392fe0..05331b42012 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/assist/AssistShortcutViewModel.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/assist/AssistShortcutViewModel.kt @@ -9,8 +9,8 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.data.websocket.impl.entities.AssistPipelineListResponse -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @HiltViewModel class AssistShortcutViewModel @Inject constructor( diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/button/ButtonWidget.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/button/ButtonWidget.kt index 4d40cf7b4fa..06f95973aaf 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/button/ButtonWidget.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/button/ButtonWidget.kt @@ -29,6 +29,7 @@ import com.mikepenz.iconics.utils.padding import com.mikepenz.iconics.utils.size import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.widget.ButtonWidgetDao import io.homeassistant.companion.android.database.widget.ButtonWidgetEntity @@ -36,13 +37,12 @@ import io.homeassistant.companion.android.database.widget.WidgetBackgroundType import io.homeassistant.companion.android.util.getAttribute import io.homeassistant.companion.android.util.icondialog.getIconByMdiName import io.homeassistant.companion.android.widgets.common.WidgetAuthenticationActivity +import java.util.regex.Pattern +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import java.util.regex.Pattern -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ButtonWidget : AppWidgetProvider() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/button/ButtonWidgetConfigureActivity.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/button/ButtonWidgetConfigureActivity.kt index 3de9da9ed61..690c8052d26 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/button/ButtonWidgetConfigureActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/button/ButtonWidgetConfigureActivity.kt @@ -34,6 +34,7 @@ import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.Service import io.homeassistant.companion.android.database.widget.ButtonWidgetDao @@ -48,9 +49,8 @@ import io.homeassistant.companion.android.widgets.BaseWidgetConfigureActivity import io.homeassistant.companion.android.widgets.common.ServiceFieldBinder import io.homeassistant.companion.android.widgets.common.SingleItemArrayAdapter import io.homeassistant.companion.android.widgets.common.WidgetDynamicFieldAdapter -import kotlinx.coroutines.launch import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @AndroidEntryPoint class ButtonWidgetConfigureActivity : BaseWidgetConfigureActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/camera/CameraWidget.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/camera/CameraWidget.kt index a0f0cc0eaaf..b67c5d24be5 100755 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/camera/CameraWidget.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/camera/CameraWidget.kt @@ -21,11 +21,11 @@ import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.widget.CameraWidgetDao import io.homeassistant.companion.android.database.widget.CameraWidgetEntity import io.homeassistant.companion.android.util.hasActiveConnection +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class CameraWidget : AppWidgetProvider() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/camera/CameraWidgetConfigureActivity.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/camera/CameraWidgetConfigureActivity.kt index 12a89684ec8..a6f02fdecbb 100755 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/camera/CameraWidgetConfigureActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/camera/CameraWidgetConfigureActivity.kt @@ -15,6 +15,7 @@ import android.widget.Toast import androidx.core.content.getSystemService import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.domain import io.homeassistant.companion.android.database.widget.CameraWidgetDao @@ -22,10 +23,9 @@ import io.homeassistant.companion.android.databinding.WidgetCameraConfigureBindi import io.homeassistant.companion.android.settings.widgets.ManageWidgetsViewModel import io.homeassistant.companion.android.widgets.BaseWidgetConfigureActivity import io.homeassistant.companion.android.widgets.common.SingleItemArrayAdapter +import javax.inject.Inject import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class CameraWidgetConfigureActivity : BaseWidgetConfigureActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/entity/EntityWidget.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/entity/EntityWidget.kt index 7d94668e9f6..49564bc47bb 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/entity/EntityWidget.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/entity/EntityWidget.kt @@ -18,6 +18,7 @@ import androidx.core.graphics.toColorInt import com.google.android.material.color.DynamicColors import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.canSupportPrecision import io.homeassistant.companion.android.common.data.integration.friendlyState @@ -28,9 +29,8 @@ import io.homeassistant.companion.android.database.widget.WidgetBackgroundType import io.homeassistant.companion.android.database.widget.WidgetTapAction import io.homeassistant.companion.android.util.getAttribute import io.homeassistant.companion.android.widgets.BaseWidgetProvider -import kotlinx.coroutines.launch import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @AndroidEntryPoint class EntityWidget : BaseWidgetProvider() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/entity/EntityWidgetConfigureActivity.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/entity/EntityWidgetConfigureActivity.kt index 139cd5c6cda..00bc6c2b025 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/entity/EntityWidgetConfigureActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/entity/EntityWidgetConfigureActivity.kt @@ -22,6 +22,7 @@ import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import com.google.android.material.color.DynamicColors import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.EntityExt import io.homeassistant.companion.android.common.data.integration.domain @@ -34,10 +35,9 @@ import io.homeassistant.companion.android.util.getHexForColor import io.homeassistant.companion.android.widgets.BaseWidgetConfigureActivity import io.homeassistant.companion.android.widgets.BaseWidgetProvider import io.homeassistant.companion.android.widgets.common.SingleItemArrayAdapter +import javax.inject.Inject import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class EntityWidgetConfigureActivity : BaseWidgetConfigureActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/mediaplayer/MediaPlayerControlsWidget.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/mediaplayer/MediaPlayerControlsWidget.kt index 7c9171d57cc..719f8569678 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/mediaplayer/MediaPlayerControlsWidget.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/mediaplayer/MediaPlayerControlsWidget.kt @@ -20,17 +20,17 @@ import com.squareup.picasso.Picasso import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.database.widget.MediaPlayerControlsWidgetDao import io.homeassistant.companion.android.database.widget.MediaPlayerControlsWidgetEntity import io.homeassistant.companion.android.database.widget.WidgetBackgroundType import io.homeassistant.companion.android.util.hasActiveConnection import io.homeassistant.companion.android.widgets.BaseWidgetProvider -import kotlinx.coroutines.launch import java.util.LinkedList import javax.inject.Inject import kotlin.collections.HashMap -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @AndroidEntryPoint class MediaPlayerControlsWidget : BaseWidgetProvider() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/mediaplayer/MediaPlayerControlsWidgetConfigureActivity.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/mediaplayer/MediaPlayerControlsWidgetConfigureActivity.kt index baa318596b1..240afe276f6 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/mediaplayer/MediaPlayerControlsWidgetConfigureActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/mediaplayer/MediaPlayerControlsWidgetConfigureActivity.kt @@ -17,6 +17,7 @@ import androidx.core.content.getSystemService import androidx.lifecycle.lifecycleScope import com.google.android.material.color.DynamicColors import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.domain import io.homeassistant.companion.android.database.widget.MediaPlayerControlsWidgetDao @@ -25,11 +26,10 @@ import io.homeassistant.companion.android.databinding.WidgetMediaControlsConfigu import io.homeassistant.companion.android.settings.widgets.ManageWidgetsViewModel import io.homeassistant.companion.android.widgets.BaseWidgetConfigureActivity import io.homeassistant.companion.android.widgets.common.SingleItemArrayAdapter -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking import java.util.LinkedList import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking @AndroidEntryPoint class MediaPlayerControlsWidgetConfigureActivity : BaseWidgetConfigureActivity() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/template/TemplateWidget.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/template/TemplateWidget.kt index ad68573692d..12881a57115 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/template/TemplateWidget.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/template/TemplateWidget.kt @@ -20,19 +20,19 @@ import androidx.core.text.HtmlCompat import com.google.android.material.color.DynamicColors import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.widget.TemplateWidgetDao import io.homeassistant.companion.android.database.widget.TemplateWidgetEntity import io.homeassistant.companion.android.database.widget.WidgetBackgroundType import io.homeassistant.companion.android.util.getAttribute +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class TemplateWidget : AppWidgetProvider() { diff --git a/app/src/main/java/io/homeassistant/companion/android/widgets/template/TemplateWidgetConfigureActivity.kt b/app/src/main/java/io/homeassistant/companion/android/widgets/template/TemplateWidgetConfigureActivity.kt index 38b5fc2078a..f7b17a518c0 100644 --- a/app/src/main/java/io/homeassistant/companion/android/widgets/template/TemplateWidgetConfigureActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/widgets/template/TemplateWidgetConfigureActivity.kt @@ -21,17 +21,17 @@ import androidx.lifecycle.lifecycleScope import com.fasterxml.jackson.databind.JsonMappingException import com.google.android.material.color.DynamicColors import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.widget.TemplateWidgetDao import io.homeassistant.companion.android.database.widget.WidgetBackgroundType import io.homeassistant.companion.android.databinding.WidgetTemplateConfigureBinding import io.homeassistant.companion.android.settings.widgets.ManageWidgetsViewModel import io.homeassistant.companion.android.util.getHexForColor import io.homeassistant.companion.android.widgets.BaseWidgetConfigureActivity +import javax.inject.Inject import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class TemplateWidgetConfigureActivity : BaseWidgetConfigureActivity() { diff --git a/app/src/minimal/java/io/homeassistant/companion/android/launch/LaunchPresenterImpl.kt b/app/src/minimal/java/io/homeassistant/companion/android/launch/LaunchPresenterImpl.kt index bcfd9b1ca11..698729e5a5d 100644 --- a/app/src/minimal/java/io/homeassistant/companion/android/launch/LaunchPresenterImpl.kt +++ b/app/src/minimal/java/io/homeassistant/companion/android/launch/LaunchPresenterImpl.kt @@ -4,8 +4,8 @@ import android.util.Log import io.homeassistant.companion.android.BuildConfig import io.homeassistant.companion.android.common.data.integration.DeviceRegistration import io.homeassistant.companion.android.common.data.servers.ServerManager -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch class LaunchPresenterImpl @Inject constructor( view: LaunchView, diff --git a/app/src/minimal/java/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt b/app/src/minimal/java/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt index c6828e2c02e..66dd1b26a70 100644 --- a/app/src/minimal/java/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt +++ b/app/src/minimal/java/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt @@ -3,8 +3,8 @@ package io.homeassistant.companion.android.sensors import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class ActivitySensorManager : BroadcastReceiver(), SensorManager { diff --git a/app/src/minimal/java/io/homeassistant/companion/android/sensors/AndroidAutoSensorManager.kt b/app/src/minimal/java/io/homeassistant/companion/android/sensors/AndroidAutoSensorManager.kt index 7e9b64cfd47..0dd600c34a7 100644 --- a/app/src/minimal/java/io/homeassistant/companion/android/sensors/AndroidAutoSensorManager.kt +++ b/app/src/minimal/java/io/homeassistant/companion/android/sensors/AndroidAutoSensorManager.kt @@ -1,8 +1,8 @@ package io.homeassistant.companion.android.sensors import android.content.Context -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class AndroidAutoSensorManager : SensorManager { diff --git a/app/src/minimal/java/io/homeassistant/companion/android/sensors/GeocodeSensorManager.kt b/app/src/minimal/java/io/homeassistant/companion/android/sensors/GeocodeSensorManager.kt index 8147f338e56..1373ce70429 100644 --- a/app/src/minimal/java/io/homeassistant/companion/android/sensors/GeocodeSensorManager.kt +++ b/app/src/minimal/java/io/homeassistant/companion/android/sensors/GeocodeSensorManager.kt @@ -1,8 +1,8 @@ package io.homeassistant.companion.android.sensors import android.content.Context -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class GeocodeSensorManager : SensorManager { diff --git a/app/src/minimal/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt b/app/src/minimal/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt index b94a84e39ff..0b1f48337b9 100644 --- a/app/src/minimal/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt +++ b/app/src/minimal/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt @@ -3,8 +3,8 @@ package io.homeassistant.companion.android.sensors import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class LocationSensorManager : BroadcastReceiver(), SensorManager { diff --git a/app/src/minimal/java/io/homeassistant/companion/android/thread/ThreadManagerImpl.kt b/app/src/minimal/java/io/homeassistant/companion/android/thread/ThreadManagerImpl.kt index e10d7508ff2..25987179c60 100644 --- a/app/src/minimal/java/io/homeassistant/companion/android/thread/ThreadManagerImpl.kt +++ b/app/src/minimal/java/io/homeassistant/companion/android/thread/ThreadManagerImpl.kt @@ -4,8 +4,8 @@ import android.content.Context import android.content.IntentSender import androidx.activity.result.ActivityResult import io.homeassistant.companion.android.common.data.websocket.impl.entities.ThreadDatasetResponse -import kotlinx.coroutines.CoroutineScope import javax.inject.Inject +import kotlinx.coroutines.CoroutineScope class ThreadManagerImpl @Inject constructor() : ThreadManager { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/IBeaconMonitor.kt b/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/IBeaconMonitor.kt index a557d11d295..28b06391d1a 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/IBeaconMonitor.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/IBeaconMonitor.kt @@ -3,9 +3,9 @@ package io.homeassistant.companion.android.common.bluetooth.ble import android.content.Context import io.homeassistant.companion.android.common.sensors.BluetoothSensorManager import io.homeassistant.companion.android.common.sensors.SensorUpdateReceiver -import org.altbeacon.beacon.Beacon import kotlin.math.abs import kotlin.math.round +import org.altbeacon.beacon.Beacon const val MAX_SKIPPED_UPDATED = 10 diff --git a/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/KalmanFilter.kt b/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/KalmanFilter.kt index 27b57b8713e..80a163b7790 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/KalmanFilter.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/KalmanFilter.kt @@ -1,7 +1,7 @@ package io.homeassistant.companion.android.common.bluetooth.ble -import org.altbeacon.beacon.service.RssiFilter import kotlin.math.pow +import org.altbeacon.beacon.service.RssiFilter class KalmanFilter : RssiFilter { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/MonitoringManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/MonitoringManager.kt index ce1fcfaa5bc..0127322227c 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/MonitoringManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/MonitoringManager.kt @@ -12,7 +12,7 @@ import io.homeassistant.companion.android.common.BuildConfig import io.homeassistant.companion.android.common.R import io.homeassistant.companion.android.common.sensors.SensorReceiverBase import io.homeassistant.companion.android.common.sensors.SensorUpdateReceiver -import io.homeassistant.companion.android.common.util.beaconMonitorChannel +import io.homeassistant.companion.android.common.util.CHANNEL_BEACON_MONITOR import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -76,11 +76,11 @@ class MonitoringManager { } } - val builder = NotificationCompat.Builder(context, beaconMonitorChannel) + val builder = NotificationCompat.Builder(context, CHANNEL_BEACON_MONITOR) builder.setSmallIcon(R.drawable.ic_stat_ic_notification) builder.setContentTitle(context.getString(R.string.beacon_scanning)) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val channel = NotificationChannel(beaconMonitorChannel, context.getString(R.string.beacon_scanning), NotificationManager.IMPORTANCE_LOW) + val channel = NotificationChannel(CHANNEL_BEACON_MONITOR, context.getString(R.string.beacon_scanning), NotificationManager.IMPORTANCE_LOW) val notifManager = context.getSystemService()!! notifManager.createNotificationChannel(channel) } diff --git a/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/TransmitterManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/TransmitterManager.kt index 1ccba16cc41..64630c0e75d 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/TransmitterManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/ble/TransmitterManager.kt @@ -6,10 +6,10 @@ import android.bluetooth.le.AdvertiseSettings import android.content.Context import androidx.core.content.getSystemService import io.homeassistant.companion.android.common.sensors.BluetoothSensorManager +import java.util.UUID import org.altbeacon.beacon.Beacon import org.altbeacon.beacon.BeaconParser import org.altbeacon.beacon.BeaconTransmitter -import java.util.UUID object TransmitterManager { private lateinit var physicalTransmitter: BeaconTransmitter diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/DataModule.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/DataModule.kt index f5f813892ca..2514b62a18b 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/DataModule.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/DataModule.kt @@ -27,11 +27,11 @@ import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.data.servers.ServerManagerImpl import io.homeassistant.companion.android.common.data.wifi.WifiHelper import io.homeassistant.companion.android.common.data.wifi.WifiHelperImpl -import kotlinx.coroutines.runBlocking -import okhttp3.OkHttpClient import java.util.UUID import javax.inject.Named import javax.inject.Singleton +import kotlinx.coroutines.runBlocking +import okhttp3.OkHttpClient @Module @InstallIn(SingletonComponent::class) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/HomeAssistantApis.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/HomeAssistantApis.kt index 1eb610db344..8575e4bcd14 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/HomeAssistantApis.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/HomeAssistantApis.kt @@ -10,12 +10,12 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.module.kotlin.registerKotlinModule import dagger.hilt.android.qualifiers.ApplicationContext import io.homeassistant.companion.android.common.BuildConfig +import java.util.concurrent.TimeUnit +import javax.inject.Inject import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit import retrofit2.converter.jackson.JacksonConverterFactory -import java.util.concurrent.TimeUnit -import javax.inject.Inject class HomeAssistantApis @Inject constructor( private val tlsHelper: TLSHelper, diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/TLSHelper.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/TLSHelper.kt index 34ff2588e84..3846dbca0c3 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/TLSHelper.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/TLSHelper.kt @@ -1,8 +1,6 @@ package io.homeassistant.companion.android.common.data import io.homeassistant.companion.android.common.data.keychain.KeyChainRepository -import kotlinx.coroutines.runBlocking -import okhttp3.OkHttpClient import java.net.Socket import java.security.KeyStore import java.security.Principal @@ -14,6 +12,8 @@ import javax.net.ssl.SSLContext import javax.net.ssl.TrustManagerFactory import javax.net.ssl.X509ExtendedKeyManager import javax.net.ssl.X509TrustManager +import kotlinx.coroutines.runBlocking +import okhttp3.OkHttpClient class TLSHelper @Inject constructor( @Named("keyChainRepository") private val keyChainRepository: KeyChainRepository, diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationRepositoryImpl.kt index fa0d301dbe6..0631c06097d 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationRepositoryImpl.kt @@ -10,8 +10,8 @@ import io.homeassistant.companion.android.common.data.authentication.Authorizati import io.homeassistant.companion.android.common.data.authentication.SessionState import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.server.ServerSessionInfo -import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import javax.inject.Named +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull class AuthenticationRepositoryImpl @AssistedInject constructor( private val authenticationService: AuthenticationService, diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt index 42d4e70958a..f9a6d86ee14 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt @@ -8,6 +8,7 @@ import android.util.Log import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.websocket.impl.entities.CompressedStateDiff import io.homeassistant.companion.android.common.data.websocket.impl.entities.EntityRegistryOptions import java.time.ZonedDateTime @@ -16,7 +17,6 @@ import java.time.format.DateTimeParseException import java.util.Calendar import java.util.Locale import kotlin.math.round -import io.homeassistant.companion.android.common.R as commonR data class Entity( val entityId: String, diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt index 0e444884d41..2262564ffea 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt @@ -30,13 +30,13 @@ import io.homeassistant.companion.android.common.data.websocket.impl.entities.As import io.homeassistant.companion.android.common.data.websocket.impl.entities.AssistPipelineEventType import io.homeassistant.companion.android.common.data.websocket.impl.entities.AssistPipelineIntentEnd import io.homeassistant.companion.android.common.data.websocket.impl.entities.GetConfigResponse +import java.util.concurrent.TimeUnit +import javax.inject.Named import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.map import okhttp3.HttpUrl.Companion.toHttpUrlOrNull -import java.util.concurrent.TimeUnit -import javax.inject.Named class IntegrationRepositoryImpl @AssistedInject constructor( private val integrationService: IntegrationService, diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/entities/SensorRequest.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/entities/SensorRequest.kt index e32001c157e..055387f8ac6 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/entities/SensorRequest.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/entities/SensorRequest.kt @@ -11,11 +11,13 @@ data class SensorRegistrationRequest( val icon: String, val attributes: Map, val name: String? = null, - @JsonInclude(JsonInclude.Include.ALWAYS) // Always to override incorrect value from old registration + // Always to override incorrect value from old registration + @JsonInclude(JsonInclude.Include.ALWAYS) val deviceClass: String? = null, val unitOfMeasurement: String? = null, val stateClass: String? = null, - @JsonInclude(JsonInclude.Include.ALWAYS) // Always to override incorrect value from old registration + // Always to override incorrect value from old registration + @JsonInclude(JsonInclude.Include.ALWAYS) val entityCategory: String? = null, val disabled: Boolean? = null ) { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/keychain/KeyChainRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/keychain/KeyChainRepositoryImpl.kt index 8dad643d6dc..29099b64dcc 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/keychain/KeyChainRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/keychain/KeyChainRepositoryImpl.kt @@ -4,12 +4,12 @@ import android.content.Context import android.security.KeyChain import android.util.Log import io.homeassistant.companion.android.common.data.prefs.PrefsRepository -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext import java.lang.UnsupportedOperationException import java.security.PrivateKey import java.security.cert.X509Certificate import javax.inject.Inject +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext class KeyChainRepositoryImpl @Inject constructor( private val prefsRepository: PrefsRepository diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/keychain/KeyStoreRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/keychain/KeyStoreRepositoryImpl.kt index a55f7316f2c..700cf0ef68f 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/keychain/KeyStoreRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/keychain/KeyStoreRepositoryImpl.kt @@ -2,13 +2,13 @@ package io.homeassistant.companion.android.common.data.keychain import android.content.Context import android.util.Log -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext import java.security.KeyStore import java.security.KeyStore.PrivateKeyEntry import java.security.PrivateKey import java.security.cert.X509Certificate import javax.inject.Inject +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext class KeyStoreRepositoryImpl @Inject constructor() : KeyChainRepository { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImpl.kt index e92e3a70be6..002789ac79a 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImpl.kt @@ -2,9 +2,9 @@ package io.homeassistant.companion.android.common.data.prefs import io.homeassistant.companion.android.common.data.LocalStorage import io.homeassistant.companion.android.common.data.integration.ControlsAuthRequiredSetting -import kotlinx.coroutines.runBlocking import javax.inject.Inject import javax.inject.Named +import kotlinx.coroutines.runBlocking class PrefsRepositoryImpl @Inject constructor( @Named("themes") private val localStorage: LocalStorage, diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/prefs/WearPrefsRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/prefs/WearPrefsRepositoryImpl.kt index 1fad324d75f..61cc6343024 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/prefs/WearPrefsRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/prefs/WearPrefsRepositoryImpl.kt @@ -3,11 +3,11 @@ package io.homeassistant.companion.android.common.data.prefs import io.homeassistant.companion.android.common.data.LocalStorage import io.homeassistant.companion.android.common.data.prefs.impl.entities.TemplateTileConfig import io.homeassistant.companion.android.common.util.toStringList +import javax.inject.Inject +import javax.inject.Named import kotlinx.coroutines.runBlocking import org.json.JSONArray import org.json.JSONObject -import javax.inject.Inject -import javax.inject.Named class WearPrefsRepositoryImpl @Inject constructor( @Named("wear") private val localStorage: LocalStorage, @@ -116,7 +116,8 @@ class WearPrefsRepositoryImpl @Inject constructor( val jsonArray = JSONArray(jsonStr) val entities = jsonArray.toStringList() mapOf( - null to entities // the key is null since we don't (yet) have the tileId + // the key is null since we don't (yet) have the tileId + null to entities ) } ) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/servers/ServerManagerImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/servers/ServerManagerImpl.kt index 709575665f0..c3eb8316d5f 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/servers/ServerManagerImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/servers/ServerManagerImpl.kt @@ -15,6 +15,9 @@ import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.database.server.ServerDao import io.homeassistant.companion.android.database.server.ServerType import io.homeassistant.companion.android.database.settings.SettingsDao +import javax.inject.Inject +import javax.inject.Named +import kotlin.math.min import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -23,9 +26,6 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import javax.inject.Inject -import javax.inject.Named -import kotlin.math.min class ServerManagerImpl @Inject constructor( private val authenticationRepositoryFactory: AuthenticationRepositoryFactory, @@ -41,8 +41,8 @@ class ServerManagerImpl @Inject constructor( private val ioScope = CoroutineScope(Dispatchers.IO + Job()) - private val _servers = mutableMapOf() - private val _defaultServersFlow = MutableStateFlow>(emptyList()) + private val mutableServers = mutableMapOf() + private val mutableDefaultServersFlow = MutableStateFlow>(emptyList()) private val authenticationRepos = mutableMapOf() private val integrationRepos = mutableMapOf() @@ -53,22 +53,22 @@ class ServerManagerImpl @Inject constructor( } override val defaultServers: List - get() = _servers.values.filter { it.type == ServerType.DEFAULT }.toList() + get() = mutableServers.values.filter { it.type == ServerType.DEFAULT }.toList() override val defaultServersFlow: StateFlow> - get() = _defaultServersFlow.asStateFlow() + get() = mutableDefaultServersFlow.asStateFlow() init { // Initial (blocking) load serverDao.getAll().forEach { - _servers[it.id] = it.apply { connection.wifiHelper = wifiHelper } + mutableServers[it.id] = it.apply { connection.wifiHelper = wifiHelper } } // Listen for updates and update flow ioScope.launch { - _defaultServersFlow.emit(defaultServers) + mutableDefaultServersFlow.emit(defaultServers) serverDao.getAllFlow().collect { servers -> - _servers + mutableServers .filter { it.value.type == ServerType.DEFAULT && it.key !in servers.map { server -> server.id } @@ -77,27 +77,27 @@ class ServerManagerImpl @Inject constructor( removeServerFromManager(it.key) } servers.forEach { - _servers[it.id] = it.apply { connection.wifiHelper = wifiHelper } + mutableServers[it.id] = it.apply { connection.wifiHelper = wifiHelper } } - _defaultServersFlow.emit(defaultServers) + mutableDefaultServersFlow.emit(defaultServers) } } } override fun isRegistered(): Boolean = - _servers.values.any { it.type == ServerType.DEFAULT && it.connection.isRegistered() } + mutableServers.values.any { it.type == ServerType.DEFAULT && it.connection.isRegistered() } override suspend fun addServer(server: Server): Int { val newServer = server.copy( id = when (server.type) { - ServerType.TEMPORARY -> min(-2, (_servers.keys.minOrNull() ?: 0) - 1) + ServerType.TEMPORARY -> min(-2, (mutableServers.keys.minOrNull() ?: 0) - 1) else -> 0 // Use autogenerated ID } ) return if (server.type == ServerType.DEFAULT) { serverDao.add(newServer).toInt() } else { - _servers[newServer.id] = newServer.apply { connection.wifiHelper = wifiHelper } + mutableServers[newServer.id] = newServer.apply { connection.wifiHelper = wifiHelper } newServer.id } } @@ -105,36 +105,36 @@ class ServerManagerImpl @Inject constructor( private fun activeServerId(): Int? = runBlocking { val pref = localStorage.getInt(PREF_ACTIVE_SERVER) - if (pref != null && _servers[pref] != null) { + if (pref != null && mutableServers[pref] != null) { pref } else { - _servers.keys.maxOfOrNull { it } + mutableServers.keys.maxOfOrNull { it } } } override fun getServer(id: Int): Server? { val serverId = if (id == SERVER_ID_ACTIVE) activeServerId() else id - return serverId?.let { _servers[serverId] ?: serverDao.get(serverId) } + return serverId?.let { mutableServers[serverId] ?: serverDao.get(serverId) } } override fun getServer(webhookId: String): Server? = - _servers.values.firstOrNull { it.connection.webhookId == webhookId } ?: serverDao.get(webhookId) + mutableServers.values.firstOrNull { it.connection.webhookId == webhookId } ?: serverDao.get(webhookId) override fun activateServer(id: Int) { - if (id != SERVER_ID_ACTIVE && _servers[id] != null && _servers[id]?.type == ServerType.DEFAULT) { + if (id != SERVER_ID_ACTIVE && mutableServers[id] != null && mutableServers[id]?.type == ServerType.DEFAULT) { ioScope.launch { localStorage.putInt(PREF_ACTIVE_SERVER, id) } } } override fun updateServer(server: Server) { - _servers[server.id] = server.apply { connection.wifiHelper = wifiHelper } + mutableServers[server.id] = server.apply { connection.wifiHelper = wifiHelper } if (server.type == ServerType.DEFAULT) { ioScope.launch { serverDao.update(server) } } } override suspend fun convertTemporaryServer(id: Int): Int? { - return _servers[id]?.let { server -> + return mutableServers[id]?.let { server -> if (server.type != ServerType.TEMPORARY) return null val newServer = server.copy(id = 0) // Use autogenerated ID @@ -155,7 +155,7 @@ class ServerManagerImpl @Inject constructor( } private suspend fun removeServerFromManager(id: Int) { - if (_servers[id]?.type == ServerType.TEMPORARY) { + if (mutableServers[id]?.type == ServerType.TEMPORARY) { authenticationRepository(id).deletePreferences() integrationRepository(id).deletePreferences() prefsRepository.removeServer(id) @@ -164,13 +164,13 @@ class ServerManagerImpl @Inject constructor( integrationRepos.remove(id) webSocketRepos[id]?.shutdown() webSocketRepos.remove(id) - _servers.remove(id) + mutableServers.remove(id) } override fun authenticationRepository(serverId: Int): AuthenticationRepository { val id = if (serverId == SERVER_ID_ACTIVE) activeServerId() else serverId return authenticationRepos[id] ?: run { - if (id == null || _servers[id] == null) throw IllegalArgumentException("No server for ID") + if (id == null || mutableServers[id] == null) throw IllegalArgumentException("No server for ID") authenticationRepos[id] = authenticationRepositoryFactory.create(id) authenticationRepos[id]!! } @@ -179,7 +179,7 @@ class ServerManagerImpl @Inject constructor( override fun integrationRepository(serverId: Int): IntegrationRepository { val id = if (serverId == SERVER_ID_ACTIVE) activeServerId() else serverId return integrationRepos[id] ?: run { - if (id == null || _servers[id] == null) throw IllegalArgumentException("No server for ID") + if (id == null || mutableServers[id] == null) throw IllegalArgumentException("No server for ID") integrationRepos[id] = integrationRepositoryFactory.create(id) integrationRepos[id]!! } @@ -188,7 +188,7 @@ class ServerManagerImpl @Inject constructor( override fun webSocketRepository(serverId: Int): WebSocketRepository { val id = if (serverId == SERVER_ID_ACTIVE) activeServerId() else serverId return webSocketRepos[id] ?: run { - if (id == null || _servers[id] == null) throw IllegalArgumentException("No server for ID") + if (id == null || mutableServers[id] == null) throw IllegalArgumentException("No server for ID") webSocketRepos[id] = webSocketRepositoryFactory.create(id) webSocketRepos[id]!! } diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/WebSocketState.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/WebSocketState.kt index 1d8c578e45f..f94637467f3 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/WebSocketState.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/WebSocketState.kt @@ -1,5 +1,8 @@ package io.homeassistant.companion.android.common.data.websocket enum class WebSocketState { - AUTHENTICATING, ACTIVE, CLOSED_AUTH, CLOSED_OTHER + AUTHENTICATING, + ACTIVE, + CLOSED_AUTH, + CLOSED_OTHER } diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/WebSocketRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/WebSocketRepositoryImpl.kt index d417c124be9..8221876ce16 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/WebSocketRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/WebSocketRepositoryImpl.kt @@ -52,6 +52,10 @@ import io.homeassistant.companion.android.common.data.websocket.impl.entities.Th import io.homeassistant.companion.android.common.data.websocket.impl.entities.TriggerEvent import io.homeassistant.companion.android.common.util.toHexString import io.homeassistant.companion.android.database.server.ServerUserInfo +import java.io.IOException +import java.util.Collections +import java.util.concurrent.atomic.AtomicLong +import kotlin.coroutines.resumeWithException import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart @@ -80,10 +84,6 @@ import okhttp3.WebSocket import okhttp3.WebSocketListener import okio.ByteString import okio.ByteString.Companion.toByteString -import java.io.IOException -import java.util.Collections -import java.util.concurrent.atomic.AtomicLong -import kotlin.coroutines.resumeWithException class WebSocketRepositoryImpl @AssistedInject constructor( private val okHttpClient: OkHttpClient, @@ -455,7 +455,8 @@ class WebSocketRepositoryImpl @AssistedInject constructor( "type" to "matter/commission", "code" to code ), - timeout = 120000L // Matter commissioning takes at least 60 seconds + interview + // Matter commissioning takes at least 60 seconds + interview + timeout = 120000L ) ) @@ -481,7 +482,8 @@ class WebSocketRepositoryImpl @AssistedInject constructor( val response = sendMessage( WebSocketRequest( message = if (server?.version?.isAtLeast(2024, 1) == true) data.plus("ip_addr" to ip) else data, - timeout = 120000L // Matter commissioning takes at least 60 seconds + interview + // Matter commissioning takes at least 60 seconds + interview + timeout = 120000L ) ) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/entities/GetConfigResponse.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/entities/GetConfigResponse.kt index b638efa7fb2..af691017afd 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/entities/GetConfigResponse.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/entities/GetConfigResponse.kt @@ -12,7 +12,10 @@ data class GetConfigResponse( val timeZone: String, val components: List, val version: String, - val cloudhookUrl: String?, // only when using webhook - val remoteUiUrl: String?, // only when using webhook - val entities: Map>? // only on core >= 2022.6 when using webhook + // only when using webhook + val cloudhookUrl: String?, + // only when using webhook + val remoteUiUrl: String?, + // only on core >= 2022.6 when using webhook + val entities: Map>? ) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/entities/ThreadDatasetResponse.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/entities/ThreadDatasetResponse.kt index 8abc5ea02d0..9d9ee9c57e8 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/entities/ThreadDatasetResponse.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/websocket/impl/entities/ThreadDatasetResponse.kt @@ -9,6 +9,7 @@ data class ThreadDatasetResponse( val networkName: String, val panId: String, val preferred: Boolean, - val preferredBorderAgentId: String?, // only on core >= 2023.9, may still be null + // only on core >= 2023.9, may still be null + val preferredBorderAgentId: String?, val source: String ) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/notifications/DeviceCommands.kt b/common/src/main/java/io/homeassistant/companion/android/common/notifications/DeviceCommands.kt index 864b32435d4..a21dc2505f7 100755 --- a/common/src/main/java/io/homeassistant/companion/android/common/notifications/DeviceCommands.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/notifications/DeviceCommands.kt @@ -5,9 +5,9 @@ import android.util.Log import io.homeassistant.companion.android.common.sensors.BluetoothSensorManager import io.homeassistant.companion.android.common.sensors.SensorUpdateReceiver import io.homeassistant.companion.android.database.sensor.SensorDao +import java.util.UUID import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import java.util.UUID object DeviceCommandData { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/notifications/NotificationDeleteReceiver.kt b/common/src/main/java/io/homeassistant/companion/android/common/notifications/NotificationDeleteReceiver.kt index f27f629bd05..16e54ea6129 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/notifications/NotificationDeleteReceiver.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/notifications/NotificationDeleteReceiver.kt @@ -10,11 +10,11 @@ import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.common.util.cancelGroupIfNeeded import io.homeassistant.companion.android.database.notification.NotificationDao +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class NotificationDeleteReceiver : BroadcastReceiver() { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/notifications/NotificationFunctions.kt b/common/src/main/java/io/homeassistant/companion/android/common/notifications/NotificationFunctions.kt index 4ed54bb1ef5..774f615d5c0 100755 --- a/common/src/main/java/io/homeassistant/companion/android/common/notifications/NotificationFunctions.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/notifications/NotificationFunctions.kt @@ -24,8 +24,8 @@ import com.mikepenz.iconics.utils.colorFilter import com.mikepenz.iconics.utils.toAndroidIconCompat import com.vdurmont.emoji.EmojiParser import io.homeassistant.companion.android.common.R +import io.homeassistant.companion.android.common.util.CHANNEL_GENERAL import io.homeassistant.companion.android.common.util.cancel -import io.homeassistant.companion.android.common.util.generalChannel import java.util.Locale object NotificationData { @@ -74,7 +74,7 @@ fun handleChannel( data: Map ): String { // Define some values for a default channel - var channelID = generalChannel + var channelID = CHANNEL_GENERAL var channelName = "General" if (!data[NotificationData.CHANNEL].isNullOrEmpty()) { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/AndroidOsSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/AndroidOsSensorManager.kt index 98b9b86cc40..7324f08e3a8 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/AndroidOsSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/AndroidOsSensorManager.kt @@ -2,8 +2,8 @@ package io.homeassistant.companion.android.common.sensors import android.content.Context import android.os.Build -import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.util.STATE_UNKNOWN class AndroidOsSensorManager : SensorManager { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/AppSensorManagerBase.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/AppSensorManagerBase.kt index e213fa34c8b..27ff18a70ca 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/AppSensorManagerBase.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/AppSensorManagerBase.kt @@ -9,8 +9,8 @@ import android.os.Process import android.util.Log import androidx.annotation.RequiresApi import androidx.core.content.getSystemService -import java.math.RoundingMode import io.homeassistant.companion.android.common.R as commonR +import java.math.RoundingMode abstract class AppSensorManagerBase : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/AudioSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/AudioSensorManager.kt index 2c88a49639e..14105581817 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/AudioSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/AudioSensorManager.kt @@ -6,8 +6,8 @@ import android.media.AudioManager import android.os.Build import androidx.annotation.RequiresApi import androidx.core.content.getSystemService -import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.util.STATE_UNKNOWN class AudioSensorManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/BatterySensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/BatterySensorManager.kt index aeeda0a78b6..55e24266ccb 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/BatterySensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/BatterySensorManager.kt @@ -4,9 +4,9 @@ import android.content.Context import android.content.Intent import android.content.IntentFilter import android.os.BatteryManager +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import java.math.RoundingMode -import io.homeassistant.companion.android.common.R as commonR class BatterySensorManager : SensorManager { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt index fce017313f0..99dcc200214 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt @@ -4,6 +4,7 @@ import android.Manifest import android.annotation.SuppressLint import android.content.Context import android.os.Build +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.bluetooth.BluetoothDevice import io.homeassistant.companion.android.common.bluetooth.BluetoothUtils import io.homeassistant.companion.android.common.bluetooth.BluetoothUtils.supportsTransmitter @@ -18,11 +19,10 @@ import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.sensor.SensorSetting import io.homeassistant.companion.android.database.sensor.SensorSettingType +import java.util.UUID import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import java.util.UUID -import io.homeassistant.companion.android.common.R as commonR class BluetoothSensorManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/DNDSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/DNDSensorManager.kt index ed18daa7fb6..3685a95cd87 100755 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/DNDSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/DNDSensorManager.kt @@ -7,8 +7,8 @@ import android.os.Build import androidx.annotation.ChecksSdkIntAtLeast import androidx.annotation.RequiresApi import androidx.core.content.getSystemService -import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.util.STATE_UNKNOWN @RequiresApi(Build.VERSION_CODES.M) class DNDSensorManager : SensorManager { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/LastRebootSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/LastRebootSensorManager.kt index d5563d62782..bdcd893cb7c 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/LastRebootSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/LastRebootSensorManager.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import android.os.SystemClock import android.util.Log +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.util.STATE_UNAVAILABLE import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.sensor.SensorSetting @@ -15,7 +16,6 @@ import java.util.Date import java.util.GregorianCalendar import java.util.TimeZone import kotlin.math.absoluteValue -import io.homeassistant.companion.android.common.R as commonR class LastRebootSensorManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/LastUpdateManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/LastUpdateManager.kt index 0cf6fc5b672..fa6dce35a71 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/LastUpdateManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/LastUpdateManager.kt @@ -2,10 +2,10 @@ package io.homeassistant.companion.android.common.sensors import android.content.Context import android.util.Log +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.sensor.SensorSetting import io.homeassistant.companion.android.database.sensor.SensorSettingType -import io.homeassistant.companion.android.common.R as commonR class LastUpdateManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/LightSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/LightSensorManager.kt index 5bfc631b355..4fb4aea6013 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/LightSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/LightSensorManager.kt @@ -8,8 +8,8 @@ import android.hardware.SensorEventListener import android.hardware.SensorManager.SENSOR_DELAY_NORMAL import android.util.Log import androidx.core.content.getSystemService -import kotlin.math.roundToInt import io.homeassistant.companion.android.common.R as commonR +import kotlin.math.roundToInt class LightSensorManager : SensorManager, SensorEventListener { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/NetworkSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/NetworkSensorManager.kt index 4a3aed5a447..c8f1f1bc9ef 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/NetworkSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/NetworkSensorManager.kt @@ -12,11 +12,13 @@ import android.os.Build import android.util.Log import androidx.annotation.RequiresApi import androidx.core.content.getSystemService +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.util.STATE_UNAVAILABLE import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.sensor.SensorSetting import io.homeassistant.companion.android.database.sensor.SensorSettingType +import java.lang.reflect.Method import okhttp3.Call import okhttp3.Callback import okhttp3.OkHttpClient @@ -25,8 +27,6 @@ import okhttp3.Response import okio.IOException import org.json.JSONException import org.json.JSONObject -import java.lang.reflect.Method -import io.homeassistant.companion.android.common.R as commonR class NetworkSensorManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/NextAlarmManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/NextAlarmManager.kt index 48a2edc4f82..584e73131f8 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/NextAlarmManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/NextAlarmManager.kt @@ -6,6 +6,7 @@ import android.content.pm.PackageManager import android.os.Build import android.util.Log import androidx.core.content.getSystemService +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.util.STATE_UNAVAILABLE import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.database.AppDatabase @@ -17,7 +18,6 @@ import java.util.Date import java.util.GregorianCalendar import java.util.Locale import java.util.TimeZone -import io.homeassistant.companion.android.common.R as commonR class NextAlarmManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/PhoneStateSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/PhoneStateSensorManager.kt index 1ef032c9b9e..d064b278b59 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/PhoneStateSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/PhoneStateSensorManager.kt @@ -10,9 +10,9 @@ import android.telephony.SubscriptionManager import android.telephony.TelephonyManager import android.util.Log import androidx.core.content.getSystemService +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.util.STATE_UNAVAILABLE import io.homeassistant.companion.android.common.util.STATE_UNKNOWN -import io.homeassistant.companion.android.common.R as commonR class PhoneStateSensorManager : SensorManager { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/PowerSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/PowerSensorManager.kt index 9f9c0f3951a..fdb995ee0e7 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/PowerSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/PowerSensorManager.kt @@ -10,7 +10,7 @@ import io.homeassistant.companion.android.common.R as commonR class PowerSensorManager : SensorManager { companion object { private const val TAG = "PowerSensors" - private const val packageName = "io.homeassistant.companion.android" + private const val PACKAGE_NAME = "io.homeassistant.companion.android" val interactiveDevice = SensorManager.BasicSensor( "is_interactive", @@ -103,7 +103,7 @@ class PowerSensorManager : SensorManager { icon, mapOf( "ignoring_battery_optimizations" to powerManager.isIgnoringBatteryOptimizations( - packageName + PACKAGE_NAME ) ) ) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/PressureSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/PressureSensorManager.kt index 910f6577e81..ea90761e27e 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/PressureSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/PressureSensorManager.kt @@ -8,8 +8,8 @@ import android.hardware.SensorEventListener import android.hardware.SensorManager.SENSOR_DELAY_NORMAL import android.util.Log import androidx.core.content.getSystemService -import java.math.RoundingMode import io.homeassistant.companion.android.common.R as commonR +import java.math.RoundingMode class PressureSensorManager : SensorManager, SensorEventListener { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/ProximitySensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/ProximitySensorManager.kt index da9ea28c55e..6f374edd79d 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/ProximitySensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/ProximitySensorManager.kt @@ -8,8 +8,8 @@ import android.hardware.SensorEventListener import android.hardware.SensorManager.SENSOR_DELAY_NORMAL import android.util.Log import androidx.core.content.getSystemService -import kotlin.math.roundToInt import io.homeassistant.companion.android.common.R as commonR +import kotlin.math.roundToInt class ProximitySensorManager : SensorManager, SensorEventListener { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorManager.kt index 75eccc2447a..e64edda0bf6 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorManager.kt @@ -13,13 +13,13 @@ import dagger.hilt.EntryPoint import dagger.hilt.InstallIn import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.sensor.Attribute import io.homeassistant.companion.android.database.sensor.SensorSetting import io.homeassistant.companion.android.database.sensor.SensorSettingType import java.util.Locale -import io.homeassistant.companion.android.common.R as commonR interface SensorManager { @@ -49,7 +49,10 @@ interface SensorManager { val enabledByDefault: Boolean = false ) { enum class UpdateType { - INTENT, WORKER, LOCATION, CUSTOM + INTENT, + WORKER, + LOCATION, + CUSTOM } } diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorReceiverBase.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorReceiverBase.kt index 01d81735110..3aeec8be617 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorReceiverBase.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorReceiverBase.kt @@ -16,7 +16,7 @@ import io.homeassistant.companion.android.common.R import io.homeassistant.companion.android.common.data.integration.IntegrationException import io.homeassistant.companion.android.common.data.integration.SensorRegistration import io.homeassistant.companion.android.common.data.servers.ServerManager -import io.homeassistant.companion.android.common.util.sensorCoreSyncChannel +import io.homeassistant.companion.android.common.util.CHANNEL_SENSOR_SYNC import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.sensor.SensorDao import io.homeassistant.companion.android.database.sensor.SensorWithAttributes @@ -24,6 +24,11 @@ import io.homeassistant.companion.android.database.sensor.toSensorWithAttributes import io.homeassistant.companion.android.database.sensor.toSensorsWithAttributes import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.database.settings.SensorUpdateFrequencySetting +import java.io.IOException +import java.net.ConnectException +import java.net.SocketTimeoutException +import java.util.Locale +import javax.inject.Inject import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -32,11 +37,6 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.delay import kotlinx.coroutines.launch -import java.io.IOException -import java.net.ConnectException -import java.net.SocketTimeoutException -import java.util.Locale -import javax.inject.Inject abstract class SensorReceiverBase : BroadcastReceiver() { companion object { @@ -285,9 +285,9 @@ abstract class SensorReceiverBase : BroadcastReceiver() { context.getSystemService()?.let { notificationManager -> createNotificationChannel(context) - val notificationId = "$sensorCoreSyncChannel-${basicSensor.id}".hashCode() + val notificationId = "$CHANNEL_SENSOR_SYNC-${basicSensor.id}".hashCode() val notificationIntent = getSensorSettingsIntent(context, basicSensor.id, manager.id(), notificationId) - val notification = NotificationCompat.Builder(context, sensorCoreSyncChannel) + val notification = NotificationCompat.Builder(context, CHANNEL_SENSOR_SYNC) .setSmallIcon(R.drawable.ic_stat_ic_notification) .setContentTitle(context.getString(basicSensor.name)) .setContentText(context.getString(R.string.sensor_worker_sync_missing_permissions)) @@ -427,11 +427,11 @@ abstract class SensorReceiverBase : BroadcastReceiver() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationManager = context.getSystemService() ?: return var notificationChannel = - notificationManager.getNotificationChannel(sensorCoreSyncChannel) + notificationManager.getNotificationChannel(CHANNEL_SENSOR_SYNC) if (notificationChannel == null) { notificationChannel = NotificationChannel( - sensorCoreSyncChannel, - sensorCoreSyncChannel, + CHANNEL_SENSOR_SYNC, + CHANNEL_SENSOR_SYNC, NotificationManager.IMPORTANCE_DEFAULT ) notificationManager.createNotificationChannel(notificationChannel) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorWorkerBase.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorWorkerBase.kt index 69117eedc5d..0874f9ef7aa 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorWorkerBase.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/SensorWorkerBase.kt @@ -10,13 +10,13 @@ import androidx.core.content.getSystemService import androidx.work.CoroutineWorker import androidx.work.ForegroundInfo import androidx.work.WorkerParameters +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager -import io.homeassistant.companion.android.common.util.sensorWorkerChannel +import io.homeassistant.companion.android.common.util.CHANNEL_SENSOR_WORKER import io.homeassistant.companion.android.database.AppDatabase +import java.lang.IllegalStateException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import java.lang.IllegalStateException -import io.homeassistant.companion.android.common.R as commonR abstract class SensorWorkerBase( val appContext: Context, @@ -43,7 +43,7 @@ abstract class SensorWorkerBase( } ) { createNotificationChannel() - val notification = NotificationCompat.Builder(applicationContext, sensorWorkerChannel) + val notification = NotificationCompat.Builder(applicationContext, CHANNEL_SENSOR_WORKER) .setSmallIcon(commonR.drawable.ic_stat_ic_notification) .setContentTitle(appContext.getString(commonR.string.updating_sensors)) .setPriority(NotificationCompat.PRIORITY_LOW) @@ -72,10 +72,10 @@ abstract class SensorWorkerBase( protected fun createNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { var notificationChannel = - notificationManager.getNotificationChannel(sensorWorkerChannel) + notificationManager.getNotificationChannel(CHANNEL_SENSOR_WORKER) if (notificationChannel == null) { notificationChannel = NotificationChannel( - sensorWorkerChannel, + CHANNEL_SENSOR_WORKER, TAG, NotificationManager.IMPORTANCE_LOW ) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/StepsSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/StepsSensorManager.kt index 68b55f936c9..d4d45e2e9b9 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/StepsSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/StepsSensorManager.kt @@ -10,8 +10,8 @@ import android.hardware.SensorManager.SENSOR_DELAY_NORMAL import android.os.Build import android.util.Log import androidx.core.content.getSystemService -import kotlin.math.roundToInt import io.homeassistant.companion.android.common.R as commonR +import kotlin.math.roundToInt class StepsSensorManager : SensorManager, SensorEventListener { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/StorageSensorManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/StorageSensorManager.kt index fa3979bec08..8b0665ac3b6 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/StorageSensorManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/StorageSensorManager.kt @@ -4,9 +4,9 @@ import android.content.Context import android.os.Environment import android.os.StatFs import android.util.Log +import io.homeassistant.companion.android.common.R as commonR import java.io.File import kotlin.math.roundToInt -import io.homeassistant.companion.android.common.R as commonR class StorageSensorManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/TimeZoneManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/TimeZoneManager.kt index eed641d5024..f3aba6730cb 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/TimeZoneManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/TimeZoneManager.kt @@ -1,10 +1,10 @@ package io.homeassistant.companion.android.common.sensors import android.content.Context +import io.homeassistant.companion.android.common.R as commonR import java.util.Date import java.util.Locale import java.util.TimeZone -import io.homeassistant.companion.android.common.R as commonR class TimeZoneManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/sensors/TrafficStatsManager.kt b/common/src/main/java/io/homeassistant/companion/android/common/sensors/TrafficStatsManager.kt index f127330796b..5b01ad97824 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/sensors/TrafficStatsManager.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/sensors/TrafficStatsManager.kt @@ -6,9 +6,9 @@ import android.net.NetworkCapabilities import android.net.TrafficStats import android.util.Log import androidx.core.content.getSystemService +import io.homeassistant.companion.android.common.R as commonR import java.math.RoundingMode import kotlin.math.absoluteValue -import io.homeassistant.companion.android.common.R as commonR class TrafficStatsManager : SensorManager { companion object { diff --git a/common/src/main/java/io/homeassistant/companion/android/common/util/AppNotifChannels.kt b/common/src/main/java/io/homeassistant/companion/android/common/util/AppNotifChannels.kt index 1120a4b367c..cf37b19830b 100755 --- a/common/src/main/java/io/homeassistant/companion/android/common/util/AppNotifChannels.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/util/AppNotifChannels.kt @@ -1,25 +1,25 @@ package io.homeassistant.companion.android.common.util -const val sensorWorkerChannel = "Sensor Worker" -const val sensorCoreSyncChannel = "Sensor Sync" -const val websocketChannel = "Websocket" -const val websocketIssuesChannel = "Websocket Issues" -const val highAccuracyChannel = "High accuracy location" -const val databaseChannel = "App Database" -const val locationDisabledChannel = "Location disabled" -const val downloadsChannel = "downloads" -const val generalChannel = "general" -const val beaconMonitorChannel = "beacon" +const val CHANNEL_SENSOR_WORKER = "Sensor Worker" +const val CHANNEL_SENSOR_SYNC = "Sensor Sync" +const val CHANNEL_WEBSOCKET = "Websocket" +const val CHANNEL_WEBSOCKET_ISSUES = "Websocket Issues" +const val CHANNEL_HIGH_ACCURACY = "High accuracy location" +const val CHANNEL_DATABASE = "App Database" +const val CHANNEL_LOCATION_DISABLED = "Location disabled" +const val CHANNEL_DOWNLOADS = "downloads" +const val CHANNEL_GENERAL = "general" +const val CHANNEL_BEACON_MONITOR = "beacon" val appCreatedChannels = listOf( - sensorWorkerChannel, - sensorCoreSyncChannel, - websocketChannel, - websocketIssuesChannel, - highAccuracyChannel, - databaseChannel, - locationDisabledChannel, - downloadsChannel, - generalChannel, - beaconMonitorChannel + CHANNEL_SENSOR_WORKER, + CHANNEL_SENSOR_SYNC, + CHANNEL_WEBSOCKET, + CHANNEL_WEBSOCKET_ISSUES, + CHANNEL_HIGH_ACCURACY, + CHANNEL_DATABASE, + CHANNEL_LOCATION_DISABLED, + CHANNEL_DOWNLOADS, + CHANNEL_GENERAL, + CHANNEL_BEACON_MONITOR ) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/util/AudioUrlPlayer.kt b/common/src/main/java/io/homeassistant/companion/android/common/util/AudioUrlPlayer.kt index 9b883b2e1f8..af43fb52449 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/util/AudioUrlPlayer.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/util/AudioUrlPlayer.kt @@ -4,11 +4,11 @@ import android.media.AudioAttributes import android.media.MediaPlayer import android.os.Build import android.util.Log +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.isActive import kotlinx.coroutines.withContext -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine /** * Simple interface for playing short streaming audio (from URLs). diff --git a/common/src/main/java/io/homeassistant/companion/android/common/util/DisabledLocationHandler.kt b/common/src/main/java/io/homeassistant/companion/android/common/util/DisabledLocationHandler.kt index c020ec660ba..47e3b64dc99 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/util/DisabledLocationHandler.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/util/DisabledLocationHandler.kt @@ -86,7 +86,7 @@ object DisabledLocationHandler { val notificationManager = NotificationManagerCompat.from(context) if (notificationManager.getActiveNotification(DISABLED_LOCATION_WARN_ID, DISABLED_LOCATION_WARN_ID.hashCode()) == null) { if (VERSION.SDK_INT >= VERSION_CODES.O) { - val channel = NotificationChannel(locationDisabledChannel, context.applicationContext.getString(commonR.string.location_warn_channel), NotificationManager.IMPORTANCE_DEFAULT) + val channel = NotificationChannel(CHANNEL_LOCATION_DISABLED, context.applicationContext.getString(commonR.string.location_warn_channel), NotificationManager.IMPORTANCE_DEFAULT) notificationManager.createNotificationChannel(channel) } @@ -97,7 +97,7 @@ object DisabledLocationHandler { PendingIntent.FLAG_IMMUTABLE ) - val notificationBuilder = NotificationCompat.Builder(context, locationDisabledChannel) + val notificationBuilder = NotificationCompat.Builder(context, CHANNEL_LOCATION_DISABLED) .setSmallIcon(commonR.drawable.ic_stat_ic_notification) .setColor(Color.RED) .setOngoing(true) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/util/LocationPermissionInfoHandler.kt b/common/src/main/java/io/homeassistant/companion/android/common/util/LocationPermissionInfoHandler.kt index 2a1351a1bcb..2826a5eb099 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/util/LocationPermissionInfoHandler.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/util/LocationPermissionInfoHandler.kt @@ -9,8 +9,8 @@ object LocationPermissionInfoHandler { fun showLocationPermInfoDialogIfNeeded(context: Context, permissions: Array, continueYesCallback: () -> Unit, continueNoCallback: (() -> Unit)? = null) { if (permissions.any { - it == Manifest.permission.ACCESS_FINE_LOCATION || it == Manifest.permission.ACCESS_BACKGROUND_LOCATION - } + it == Manifest.permission.ACCESS_FINE_LOCATION || it == Manifest.permission.ACCESS_BACKGROUND_LOCATION + } ) { AlertDialog.Builder(context) .setTitle(commonR.string.location_perm_info_title) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/util/TextUtil.kt b/common/src/main/java/io/homeassistant/companion/android/common/util/TextUtil.kt index 9fef2a161d8..5d1d5f99800 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/util/TextUtil.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/util/TextUtil.kt @@ -1,7 +1,7 @@ package io.homeassistant.companion.android.common.util -import okhttp3.internal.and import java.util.Locale +import okhttp3.internal.and private val HEX_ARRAY = "0123456789ABCDEF".toCharArray() diff --git a/common/src/main/java/io/homeassistant/companion/android/database/AppDatabase.kt b/common/src/main/java/io/homeassistant/companion/android/database/AppDatabase.kt index 4ce67fdd6ac..5f71eeb8eea 100644 --- a/common/src/main/java/io/homeassistant/companion/android/database/AppDatabase.kt +++ b/common/src/main/java/io/homeassistant/companion/android/database/AppDatabase.kt @@ -30,8 +30,9 @@ import androidx.room.migration.AutoMigrationSpec import androidx.room.migration.Migration import androidx.sqlite.db.SupportSQLiteDatabase import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.IntegrationRepository -import io.homeassistant.companion.android.common.util.databaseChannel +import io.homeassistant.companion.android.common.util.CHANNEL_DATABASE import io.homeassistant.companion.android.database.authentication.Authentication import io.homeassistant.companion.android.database.authentication.AuthenticationDao import io.homeassistant.companion.android.database.location.LocationHistoryDao @@ -72,9 +73,8 @@ import io.homeassistant.companion.android.database.widget.TemplateWidgetDao import io.homeassistant.companion.android.database.widget.TemplateWidgetEntity import io.homeassistant.companion.android.database.widget.WidgetBackgroundTypeConverter import io.homeassistant.companion.android.database.widget.WidgetTapActionConverter -import kotlinx.coroutines.runBlocking import java.util.UUID -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.runBlocking @Database( entities = [ @@ -420,20 +420,14 @@ abstract class AppDatabase : RoomDatabase() { val currentSensorSettingName = cursor.getString(cursor.getColumnIndex("name")) var entries = "" var newSensorSettingName = currentSensorSettingName - // Alarm + if (currentSensorId == "next_alarm" && currentSensorSettingName == "Allow List") { newSensorSettingName = "nextalarm_allow_list" - } - // Notification - else if ((currentSensorId == "last_removed_notification" || currentSensorId == "last_notification") && currentSensorSettingName == "Allow List") { + } else if ((currentSensorId == "last_removed_notification" || currentSensorId == "last_notification") && currentSensorSettingName == "Allow List") { newSensorSettingName = "notification_allow_list" - } - // Geocode - else if (currentSensorId == "geocoded_location" && currentSensorSettingName == "Minimum Accuracy") { + } else if (currentSensorId == "geocoded_location" && currentSensorSettingName == "Minimum Accuracy") { newSensorSettingName = "geocode_minimum_accuracy" - } - // Location - else if ((currentSensorId == "zone_background" || currentSensorId == "accurate_location" || currentSensorId == "location_background") && currentSensorSettingName == "Minimum Accuracy") { + } else if ((currentSensorId == "zone_background" || currentSensorId == "accurate_location" || currentSensorId == "location_background") && currentSensorSettingName == "Minimum Accuracy") { newSensorSettingName = "location_minimum_accuracy" } else if (currentSensorId == "accurate_location" && currentSensorSettingName == "Minimum time between updates") { newSensorSettingName = "location_minimum_time_updates" @@ -449,9 +443,7 @@ abstract class AppDatabase : RoomDatabase() { newSensorSettingName = "location_ham_only_enter_zone" } else if (currentSensorId == "location_background" && currentSensorSettingName == "High accuracy mode trigger range for zone (meters)") { newSensorSettingName = "location_ham_trigger_range" - } - // Bluetooth - else if (currentSensorId == "ble_emitter" && currentSensorSettingName == "UUID") { + } else if (currentSensorId == "ble_emitter" && currentSensorSettingName == "UUID") { newSensorSettingName = "ble_uuid" } else if (currentSensorId == "ble_emitter" && currentSensorSettingName == "Major") { newSensorSettingName = "ble_major" @@ -464,19 +456,13 @@ abstract class AppDatabase : RoomDatabase() { newSensorSettingName = "ble_transmit_enabled" } else if (currentSensorId == "ble_emitter" && currentSensorSettingName == "Include when enabling all sensors") { newSensorSettingName = "ble_enable_toggle_all" - } - // Last reboot - else if (currentSensorId == "last_reboot" && currentSensorSettingName == "deadband") { + } else if (currentSensorId == "last_reboot" && currentSensorSettingName == "deadband") { newSensorSettingName = "lastreboot_deadband" - } - // Last update - else if (currentSensorId == "last_update" && currentSensorSettingName == "Add New Intent") { + } else if (currentSensorId == "last_update" && currentSensorSettingName == "Add New Intent") { newSensorSettingName = "lastupdate_add_new_intent" } else if (currentSensorId == "last_update" && currentSensorSettingName.startsWith("intent")) { newSensorSettingName = "lastupdate_intent_var1:" + currentSensorSettingName.substringAfter("intent") + ":" - } - // Network - else if (currentSensorId == "wifi_bssid" && currentSensorSettingName == "get_current_bssid") { + } else if (currentSensorId == "wifi_bssid" && currentSensorSettingName == "get_current_bssid") { newSensorSettingName = "network_get_current_bssid" } else if (currentSensorId == "wifi_bssid" && currentSensorSettingName.startsWith("replace_")) { newSensorSettingName = "network_replace_mac_var1:" + currentSensorSettingName.substringAfter("replace_") + ":" @@ -911,10 +897,10 @@ abstract class AppDatabase : RoomDatabase() { val notificationManager = appContext.getSystemService()!! var notificationChannel = - notificationManager.getNotificationChannel(databaseChannel) + notificationManager.getNotificationChannel(CHANNEL_DATABASE) if (notificationChannel == null) { notificationChannel = NotificationChannel( - databaseChannel, + CHANNEL_DATABASE, TAG, NotificationManager.IMPORTANCE_HIGH ) @@ -925,7 +911,7 @@ abstract class AppDatabase : RoomDatabase() { private fun notifyMigrationFailed() { createNotificationChannel() - val notification = NotificationCompat.Builder(appContext, databaseChannel) + val notification = NotificationCompat.Builder(appContext, CHANNEL_DATABASE) .setSmallIcon(commonR.drawable.ic_stat_ic_notification) .setContentTitle(appContext.getString(commonR.string.database_migration_failed)) .setPriority(NotificationCompat.PRIORITY_HIGH) diff --git a/common/src/main/java/io/homeassistant/companion/android/database/IconDialogCompat.kt b/common/src/main/java/io/homeassistant/companion/android/database/IconDialogCompat.kt index 87e06fd1abc..b0e85ee2da6 100644 --- a/common/src/main/java/io/homeassistant/companion/android/database/IconDialogCompat.kt +++ b/common/src/main/java/io/homeassistant/companion/android/database/IconDialogCompat.kt @@ -4,11 +4,11 @@ import android.content.res.AssetManager import android.util.JsonReader import android.util.NoSuchPropertyException import androidx.annotation.WorkerThread +import javax.inject.Inject import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.withContext -import javax.inject.Inject /** * Translation layer for IDs used by the old icondialog package to material icon names. diff --git a/common/src/main/java/io/homeassistant/companion/android/database/server/Server.kt b/common/src/main/java/io/homeassistant/companion/android/database/server/Server.kt index 2e4bb2d109c..9014a2b8269 100644 --- a/common/src/main/java/io/homeassistant/companion/android/database/server/Server.kt +++ b/common/src/main/java/io/homeassistant/companion/android/database/server/Server.kt @@ -40,5 +40,6 @@ data class Server( } enum class ServerType { - TEMPORARY, DEFAULT + TEMPORARY, + DEFAULT } diff --git a/common/src/main/java/io/homeassistant/companion/android/database/server/ServerConnectionInfo.kt b/common/src/main/java/io/homeassistant/companion/android/database/server/ServerConnectionInfo.kt index 1db2732c287..83e90ca39fa 100644 --- a/common/src/main/java/io/homeassistant/companion/android/database/server/ServerConnectionInfo.kt +++ b/common/src/main/java/io/homeassistant/companion/android/database/server/ServerConnectionInfo.kt @@ -8,8 +8,8 @@ import com.fasterxml.jackson.core.JsonProcessingException import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.readValue import io.homeassistant.companion.android.common.data.wifi.WifiHelper -import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import java.net.URL +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull data class ServerConnectionInfo( @ColumnInfo(name = "external_url") diff --git a/common/src/main/java/io/homeassistant/companion/android/database/widget/ThemeableWidgetEntity.kt b/common/src/main/java/io/homeassistant/companion/android/database/widget/ThemeableWidgetEntity.kt index d640b2eb89a..d738edec22a 100644 --- a/common/src/main/java/io/homeassistant/companion/android/database/widget/ThemeableWidgetEntity.kt +++ b/common/src/main/java/io/homeassistant/companion/android/database/widget/ThemeableWidgetEntity.kt @@ -8,7 +8,9 @@ interface ThemeableWidgetEntity { } enum class WidgetBackgroundType { - DYNAMICCOLOR, DAYNIGHT, TRANSPARENT + DYNAMICCOLOR, + DAYNIGHT, + TRANSPARENT } class WidgetBackgroundTypeConverter { diff --git a/common/src/main/java/io/homeassistant/companion/android/database/widget/WidgetTapAction.kt b/common/src/main/java/io/homeassistant/companion/android/database/widget/WidgetTapAction.kt index c06aa3a7b87..a5187b764b0 100644 --- a/common/src/main/java/io/homeassistant/companion/android/database/widget/WidgetTapAction.kt +++ b/common/src/main/java/io/homeassistant/companion/android/database/widget/WidgetTapAction.kt @@ -3,7 +3,8 @@ package io.homeassistant.companion.android.database.widget import androidx.room.TypeConverter enum class WidgetTapAction { - REFRESH, TOGGLE + REFRESH, + TOGGLE } class WidgetTapActionConverter { diff --git a/common/src/main/java/io/homeassistant/companion/android/util/UrlUtil.kt b/common/src/main/java/io/homeassistant/companion/android/util/UrlUtil.kt index a2d55519d81..7e4c6bb5e31 100644 --- a/common/src/main/java/io/homeassistant/companion/android/util/UrlUtil.kt +++ b/common/src/main/java/io/homeassistant/companion/android/util/UrlUtil.kt @@ -4,11 +4,11 @@ import android.net.Uri import android.util.Log import io.homeassistant.companion.android.common.data.MalformedHttpUrlException import io.homeassistant.companion.android.common.data.authentication.impl.AuthenticationService +import java.net.URI +import java.net.URL import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.HttpUrl.Companion.toHttpUrlOrNull -import java.net.URI -import java.net.URL object UrlUtil { fun formattedUrlString(url: String): String { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1106bfacda3..8152c1ce6c9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,7 +37,7 @@ javaVersion = "11" kotlinx-coroutines = "1.7.3" kotlin = "1.9.22" ksp = "1.9.22-1.0.17" -ktlint = "11.6.1" +ktlint = "12.1.0" lifecycle = "2.7.0" material = "1.11.0" media3 = "1.2.1" diff --git a/wear/src/main/java/io/homeassistant/companion/android/HomeAssistantApplication.kt b/wear/src/main/java/io/homeassistant/companion/android/HomeAssistantApplication.kt index f587450f7bb..1021c24de3f 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/HomeAssistantApplication.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/HomeAssistantApplication.kt @@ -16,12 +16,12 @@ import io.homeassistant.companion.android.common.data.keychain.KeyStoreRepositor import io.homeassistant.companion.android.common.sensors.AudioSensorManager import io.homeassistant.companion.android.complications.ComplicationReceiver import io.homeassistant.companion.android.sensors.SensorReceiver +import javax.inject.Inject +import javax.inject.Named import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import javax.inject.Inject -import javax.inject.Named @HiltAndroidApp open class HomeAssistantApplication : Application() { diff --git a/wear/src/main/java/io/homeassistant/companion/android/complications/ComplicationConfigViewModel.kt b/wear/src/main/java/io/homeassistant/companion/android/complications/ComplicationConfigViewModel.kt index 621ab488c5c..ae0bcd5980e 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/complications/ComplicationConfigViewModel.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/complications/ComplicationConfigViewModel.kt @@ -23,9 +23,9 @@ import io.homeassistant.companion.android.database.wear.EntityStateComplications import io.homeassistant.companion.android.database.wear.EntityStateComplicationsDao import io.homeassistant.companion.android.database.wear.FavoritesDao import io.homeassistant.companion.android.database.wear.getAllFlow +import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch -import javax.inject.Inject @HiltViewModel class ComplicationConfigViewModel @Inject constructor( @@ -39,7 +39,9 @@ class ComplicationConfigViewModel @Inject constructor( } enum class LoadingState { - LOADING, READY, ERROR + LOADING, + READY, + ERROR } val app = getApplication() diff --git a/wear/src/main/java/io/homeassistant/companion/android/complications/ComplicationReceiver.kt b/wear/src/main/java/io/homeassistant/companion/android/complications/ComplicationReceiver.kt index 8aa137d30a3..69570c2345d 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/complications/ComplicationReceiver.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/complications/ComplicationReceiver.kt @@ -10,11 +10,11 @@ import androidx.wear.watchface.complications.datasource.ComplicationDataSourceUp import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.conversation.ConversationActivity +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class ComplicationReceiver : BroadcastReceiver() { diff --git a/wear/src/main/java/io/homeassistant/companion/android/complications/EntityStateDataSourceService.kt b/wear/src/main/java/io/homeassistant/companion/android/complications/EntityStateDataSourceService.kt index dc7a8b974d3..fdab1cf5209 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/complications/EntityStateDataSourceService.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/complications/EntityStateDataSourceService.kt @@ -22,8 +22,8 @@ import io.homeassistant.companion.android.common.data.integration.friendlyState import io.homeassistant.companion.android.common.data.integration.getIcon import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.wear.EntityStateComplicationsDao -import retrofit2.HttpException import javax.inject.Inject +import retrofit2.HttpException @AndroidEntryPoint class EntityStateDataSourceService : SuspendingComplicationDataSourceService() { @@ -163,7 +163,11 @@ class EntityStateDataSourceService : SuspendingComplicationDataSourceService() { setTapAction: Boolean = false ): ComplicationData { val text = PlainComplicationText.Builder( - if (setTapAction) { "+" } else { getText(textRes) } + if (setTapAction) { + "+" + } else { + getText(textRes) + } ).build() val contentDescription = PlainComplicationText.Builder(getText(R.string.complication_entity_state_content_description)).build() val tapAction = if (setTapAction) { diff --git a/wear/src/main/java/io/homeassistant/companion/android/conversation/ConversationViewModel.kt b/wear/src/main/java/io/homeassistant/companion/android/conversation/ConversationViewModel.kt index ba3dc57b497..d669134a526 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/conversation/ConversationViewModel.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/conversation/ConversationViewModel.kt @@ -9,6 +9,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.assist.AssistViewModelBase import io.homeassistant.companion.android.common.data.prefs.WearPrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager @@ -16,9 +17,8 @@ import io.homeassistant.companion.android.common.data.websocket.impl.entities.As import io.homeassistant.companion.android.common.util.AudioRecorder import io.homeassistant.companion.android.common.util.AudioUrlPlayer import io.homeassistant.companion.android.conversation.views.AssistMessage -import kotlinx.coroutines.launch import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR +import kotlinx.coroutines.launch @HiltViewModel class ConversationViewModel @Inject constructor( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/HomeActivity.kt b/wear/src/main/java/io/homeassistant/companion/android/home/HomeActivity.kt index 70664b404f5..3f823f5b2d5 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/HomeActivity.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/HomeActivity.kt @@ -18,9 +18,9 @@ import io.homeassistant.companion.android.home.views.LoadHomePage import io.homeassistant.companion.android.onboarding.OnboardingActivity import io.homeassistant.companion.android.sensors.SensorReceiver import io.homeassistant.companion.android.sensors.SensorWorker +import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class HomeActivity : ComponentActivity(), HomeView { diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/HomePresenterImpl.kt b/wear/src/main/java/io/homeassistant/companion/android/home/HomePresenterImpl.kt index c91c4849256..8c55b664c56 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/HomePresenterImpl.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/HomePresenterImpl.kt @@ -2,6 +2,7 @@ package io.homeassistant.companion.android.home import android.util.Log import io.homeassistant.companion.android.BuildConfig +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.authentication.SessionState import io.homeassistant.companion.android.common.data.integration.DeviceRegistration import io.homeassistant.companion.android.common.data.integration.Entity @@ -18,14 +19,13 @@ import io.homeassistant.companion.android.common.data.websocket.impl.entities.En import io.homeassistant.companion.android.common.data.websocket.impl.entities.EntityRegistryUpdatedEvent import io.homeassistant.companion.android.data.SimplifiedEntity import io.homeassistant.companion.android.onboarding.getMessagingToken +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR class HomePresenterImpl @Inject constructor( private val serverManager: ServerManager, diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/MainViewModel.kt b/wear/src/main/java/io/homeassistant/companion/android/home/MainViewModel.kt index 8c2bd85c2a9..5b49a7f4d04 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/MainViewModel.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/MainViewModel.kt @@ -37,6 +37,7 @@ import io.homeassistant.companion.android.database.wear.getAllFlow import io.homeassistant.companion.android.sensors.SensorReceiver import io.homeassistant.companion.android.util.RegistriesDataHandler import io.homeassistant.companion.android.util.throttleLatest +import javax.inject.Inject import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.flow.Flow @@ -44,7 +45,6 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import javax.inject.Inject @HiltViewModel class MainViewModel @Inject constructor( @@ -60,7 +60,9 @@ class MainViewModel @Inject constructor( } enum class LoadingState { - LOADING, READY, ERROR + LOADING, + READY, + ERROR } private val app = application diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/EntityListView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/EntityListView.kt index feb09904625..6738b8f58e7 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/EntityListView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/EntityListView.kt @@ -9,6 +9,7 @@ import androidx.wear.compose.foundation.lazy.items import androidx.wear.compose.material3.Button import androidx.wear.compose.material3.Text import androidx.wear.tooling.preview.devices.WearDevices +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.theme.WearAppTheme import io.homeassistant.companion.android.theme.getPrimaryButtonColors @@ -21,7 +22,6 @@ import io.homeassistant.companion.android.views.ExpandableListHeader import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn import io.homeassistant.companion.android.views.rememberExpandedStates -import io.homeassistant.companion.android.common.R as commonR @Composable fun EntityViewList( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/MainView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/MainView.kt index a23345b763f..f8ed4a3dc6b 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/MainView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/MainView.kt @@ -31,6 +31,7 @@ import androidx.wear.compose.material3.MaterialTheme import androidx.wear.compose.material3.Text import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.home.MainViewModel @@ -43,7 +44,6 @@ import io.homeassistant.companion.android.util.onEntityClickedFeedback import io.homeassistant.companion.android.views.ExpandableListHeader import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun MainView( @@ -224,8 +224,8 @@ fun MainView( ) { mainViewModel.getCategoryForEntity(it.entityId) == null && mainViewModel.getHiddenByForEntity( - it.entityId - ) == null + it.entityId + ) == null } }, colors = getPrimaryButtonColors() diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/RefreshIntervalPickerView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/RefreshIntervalPickerView.kt index 991b5650fc8..dfe88f38ef2 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/RefreshIntervalPickerView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/RefreshIntervalPickerView.kt @@ -35,9 +35,9 @@ import com.google.android.horologist.composables.picker.toRotaryScrollAdapter import com.google.android.horologist.compose.rotaryinput.rotaryWithSnap import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as R import io.homeassistant.companion.android.theme.wearColorScheme import io.homeassistant.companion.android.util.intervalToString -import io.homeassistant.companion.android.common.R as R @OptIn(ExperimentalHorologistApi::class) @Composable @@ -76,11 +76,13 @@ fun RefreshIntervalPickerView( style = with(LocalDensity.current) { MaterialTheme.typography.displayMedium.copy( fontWeight = FontWeight.Medium, - fontSize = MaterialTheme.typography.displayMedium.fontSize.value.dp.toSp() // Ignore text scaling + // Ignore text scaling + fontSize = MaterialTheme.typography.displayMedium.fontSize.value.dp.toSp() ) }, color = wearColorScheme.primary, - textAlign = TextAlign.Center, // In case of overflow, minimize weird layout behavior + // In case of overflow, minimize weird layout behavior + textAlign = TextAlign.Center, overflow = TextOverflow.Ellipsis, maxLines = 2 ) diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectCameraTileView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectCameraTileView.kt index d9d3ab6efd2..adf79ba64c5 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectCameraTileView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectCameraTileView.kt @@ -10,12 +10,12 @@ import androidx.wear.compose.foundation.lazy.itemsIndexed import androidx.wear.compose.material3.Button import androidx.wear.compose.material3.Text import androidx.wear.tooling.preview.devices.WearDevices +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.database.wear.CameraTile import io.homeassistant.companion.android.theme.WearAppTheme import io.homeassistant.companion.android.theme.getFilledTonalButtonColors import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun SelectCameraTileView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectShortcutsTileView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectShortcutsTileView.kt index 4026df9e6bd..0ab805524f6 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectShortcutsTileView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectShortcutsTileView.kt @@ -14,6 +14,7 @@ import androidx.wear.compose.material3.ToggleButton import androidx.wear.tooling.preview.devices.WearDevices import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.theme.WearAppTheme import io.homeassistant.companion.android.theme.getFilledTonalButtonColors import io.homeassistant.companion.android.theme.getToggleButtonColors @@ -21,7 +22,6 @@ import io.homeassistant.companion.android.theme.wearColorScheme import io.homeassistant.companion.android.util.ToggleCheckbox import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun SelectShortcutsTileView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectTemplateTileView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectTemplateTileView.kt index 2be0d0b208b..db0d558e9fe 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectTemplateTileView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/SelectTemplateTileView.kt @@ -10,12 +10,12 @@ import androidx.wear.compose.foundation.lazy.itemsIndexed import androidx.wear.compose.material3.Button import androidx.wear.compose.material3.Text import androidx.wear.tooling.preview.devices.WearDevices +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.impl.entities.TemplateTileConfig import io.homeassistant.companion.android.theme.WearAppTheme import io.homeassistant.companion.android.theme.getFilledTonalButtonColors import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun SelectTemplateTileView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/SensorsView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/SensorsView.kt index f3e30d3bfad..be638e115a3 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/SensorsView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/SensorsView.kt @@ -11,13 +11,13 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.wear.compose.material3.Button import androidx.wear.compose.material3.Text import androidx.wear.tooling.preview.devices.WearDevices +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.sensors.SensorReceiver import io.homeassistant.companion.android.theme.WearAppTheme import io.homeassistant.companion.android.theme.getFilledTonalButtonColors import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun SensorsView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/SetCameraTileView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/SetCameraTileView.kt index a69521c1bee..c7e070f8f65 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/SetCameraTileView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/SetCameraTileView.kt @@ -11,6 +11,7 @@ import androidx.wear.compose.material3.Text import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import io.homeassistant.companion.android.common.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.friendlyName import io.homeassistant.companion.android.common.data.integration.getIcon @@ -22,7 +23,6 @@ import io.homeassistant.companion.android.tiles.CameraTile.Companion.DEFAULT_REF import io.homeassistant.companion.android.util.intervalToString import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun SetCameraTileView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/SetFavoriteView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/SetFavoriteView.kt index e307be18313..b634a02c6a2 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/SetFavoriteView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/SetFavoriteView.kt @@ -10,6 +10,7 @@ import androidx.wear.compose.foundation.lazy.items import androidx.wear.compose.material3.Text import androidx.wear.compose.material3.ToggleButton import com.mikepenz.iconics.compose.Image +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.getIcon import io.homeassistant.companion.android.home.MainViewModel @@ -21,7 +22,6 @@ import io.homeassistant.companion.android.views.ExpandableListHeader import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn import io.homeassistant.companion.android.views.rememberExpandedStates -import io.homeassistant.companion.android.common.R as commonR @Composable fun SetFavoritesView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/SetShortcutsTileView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/SetShortcutsTileView.kt index a29ad51525c..bff99ba525b 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/SetShortcutsTileView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/SetShortcutsTileView.kt @@ -22,6 +22,7 @@ import androidx.wear.compose.material3.Text import androidx.wear.compose.material3.touchTargetAwareSize import androidx.wear.tooling.preview.devices.WearDevices import com.mikepenz.iconics.compose.Image +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.data.SimplifiedEntity import io.homeassistant.companion.android.theme.WearAppTheme import io.homeassistant.companion.android.theme.getFilledTonalButtonColors @@ -29,7 +30,6 @@ import io.homeassistant.companion.android.util.getIcon import io.homeassistant.companion.android.util.simplifiedEntity import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun SetShortcutsTileView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/home/views/SettingsView.kt b/wear/src/main/java/io/homeassistant/companion/android/home/views/SettingsView.kt index b412756b1f0..43137e4c5bb 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/home/views/SettingsView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/home/views/SettingsView.kt @@ -18,6 +18,7 @@ import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import io.homeassistant.companion.android.common.BuildConfig +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.home.MainViewModel import io.homeassistant.companion.android.theme.WearAppTheme import io.homeassistant.companion.android.theme.getFilledTonalButtonColors @@ -27,7 +28,6 @@ import io.homeassistant.companion.android.util.ToggleSwitch import io.homeassistant.companion.android.util.previewFavoritesList import io.homeassistant.companion.android.views.ListHeader import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun SecondarySettingsChip( diff --git a/wear/src/main/java/io/homeassistant/companion/android/notifications/FirebaseCloudMessagingService.kt b/wear/src/main/java/io/homeassistant/companion/android/notifications/FirebaseCloudMessagingService.kt index e886caaf3dc..1e4d016af22 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/notifications/FirebaseCloudMessagingService.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/notifications/FirebaseCloudMessagingService.kt @@ -6,11 +6,11 @@ import com.google.firebase.messaging.RemoteMessage import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.data.integration.DeviceRegistration import io.homeassistant.companion.android.common.data.servers.ServerManager +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class FirebaseCloudMessagingService : FirebaseMessagingService() { diff --git a/wear/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt b/wear/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt index 76cd38f90d9..328057a8c7b 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt @@ -26,12 +26,12 @@ import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.notification.NotificationItem import io.homeassistant.companion.android.database.sensor.SensorDao import io.homeassistant.companion.android.sensors.SensorReceiver +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch import org.json.JSONObject -import javax.inject.Inject class MessagingManager @Inject constructor( @ApplicationContext val context: Context, diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/OnboardingActivity.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/OnboardingActivity.kt index e413e1ba895..42a5d6e3982 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/OnboardingActivity.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/OnboardingActivity.kt @@ -21,13 +21,13 @@ import com.google.android.gms.wearable.DataMapItem import com.google.android.gms.wearable.Wearable import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.onboarding.integration.MobileAppIntegrationActivity import io.homeassistant.companion.android.onboarding.phoneinstall.PhoneInstallActivity import io.homeassistant.companion.android.util.LoadingView +import javax.inject.Inject import kotlinx.coroutines.guava.await import kotlinx.coroutines.launch -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint @SuppressLint("VisibleForTests") // https://issuetracker.google.com/issues/239451111 @@ -123,7 +123,8 @@ class OnboardingActivity : AppCompatActivity(), OnboardingView { addCategory(Intent.CATEGORY_BROWSABLE) data = Uri.parse(url) }, - null // a Wear device only has one companion device so this is not needed + // A Wear device only has one companion device so this is not needed + null ).await() showContinueOnPhone() } catch (e: Exception) { diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/OnboardingPresenterImpl.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/OnboardingPresenterImpl.kt index 5294b1a894e..ebd08da47ed 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/OnboardingPresenterImpl.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/OnboardingPresenterImpl.kt @@ -14,6 +14,7 @@ import com.google.android.gms.wearable.DataEventBuffer import com.google.android.gms.wearable.DataMap import com.google.android.gms.wearable.DataMapItem import dagger.hilt.android.qualifiers.ActivityContext +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.database.server.ServerConnectionInfo @@ -21,15 +22,14 @@ import io.homeassistant.companion.android.database.server.ServerSessionInfo import io.homeassistant.companion.android.database.server.ServerType import io.homeassistant.companion.android.database.server.ServerUserInfo import io.homeassistant.companion.android.util.UrlUtil +import java.net.URL +import java.util.concurrent.Executors +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.launch -import java.net.URL -import java.util.concurrent.Executors -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @SuppressLint("VisibleForTests") // https://issuetracker.google.com/issues/239451111 class OnboardingPresenterImpl @Inject constructor( diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/ServerListAdapter.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/ServerListAdapter.kt index 0455bed166b..5ce58aec2ba 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/ServerListAdapter.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/ServerListAdapter.kt @@ -5,12 +5,12 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.ViewHolder import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.viewHolders.HeaderViewHolder import io.homeassistant.companion.android.viewHolders.InstanceViewHolder import io.homeassistant.companion.android.viewHolders.LoadingViewHolder import io.homeassistant.companion.android.viewHolders.ManualSetupViewHolder import kotlin.math.min -import io.homeassistant.companion.android.common.R as commonR class ServerListAdapter( val servers: ArrayList diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationActivity.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationActivity.kt index bcb791c0fcf..3c5a0078f8c 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationActivity.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationActivity.kt @@ -8,11 +8,11 @@ import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.wear.activity.ConfirmationActivity import dagger.hilt.android.AndroidEntryPoint +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.databinding.ActivityIntegrationBinding import io.homeassistant.companion.android.home.HomeActivity import io.homeassistant.companion.android.util.adjustInset import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class MobileAppIntegrationActivity : AppCompatActivity(), MobileAppIntegrationView { diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationPresenterImpl.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationPresenterImpl.kt index bce5de1b1a1..8e1a5cb456e 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationPresenterImpl.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationPresenterImpl.kt @@ -12,12 +12,12 @@ import io.homeassistant.companion.android.tiles.CameraTile import io.homeassistant.companion.android.tiles.ConversationTile import io.homeassistant.companion.android.tiles.ShortcutsTile import io.homeassistant.companion.android.tiles.TemplateTile +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.launch -import javax.inject.Inject class MobileAppIntegrationPresenterImpl @Inject constructor( @ActivityContext context: Context, diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupActivity.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupActivity.kt index 292b76c2439..6dd929addfe 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupActivity.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupActivity.kt @@ -10,11 +10,11 @@ import androidx.appcompat.app.AppCompatActivity import androidx.wear.activity.ConfirmationActivity import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.databinding.ActivityManualSetupBinding import io.homeassistant.companion.android.onboarding.integration.MobileAppIntegrationActivity import io.homeassistant.companion.android.util.adjustInset import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ManualSetupActivity : AppCompatActivity(), ManualSetupView { diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupPresenterImpl.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupPresenterImpl.kt index 6827b7bdfe9..8c858ebea26 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupPresenterImpl.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/manual/ManualSetupPresenterImpl.kt @@ -9,6 +9,7 @@ import androidx.wear.phone.interactions.authentication.OAuthRequest import androidx.wear.phone.interactions.authentication.OAuthResponse import androidx.wear.phone.interactions.authentication.RemoteAuthClient import dagger.hilt.android.qualifiers.ActivityContext +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.server.Server import io.homeassistant.companion.android.database.server.ServerConnectionInfo @@ -16,14 +17,13 @@ import io.homeassistant.companion.android.database.server.ServerSessionInfo import io.homeassistant.companion.android.database.server.ServerType import io.homeassistant.companion.android.database.server.ServerUserInfo import io.homeassistant.companion.android.util.UrlUtil +import java.util.concurrent.Executors +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.launch -import java.util.concurrent.Executors -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR class ManualSetupPresenterImpl @Inject constructor( @ActivityContext context: Context, diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/phoneinstall/PhoneInstallActivity.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/phoneinstall/PhoneInstallActivity.kt index cc61407fd46..b7e18a57efb 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/phoneinstall/PhoneInstallActivity.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/phoneinstall/PhoneInstallActivity.kt @@ -11,11 +11,11 @@ import androidx.lifecycle.lifecycleScope import androidx.wear.activity.ConfirmationActivity import androidx.wear.remote.interactions.RemoteActivityHelper import io.homeassistant.companion.android.BuildConfig +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.onboarding.manual.ManualSetupActivity import io.homeassistant.companion.android.theme.WearAppTheme import kotlinx.coroutines.guava.await import kotlinx.coroutines.launch -import io.homeassistant.companion.android.common.R as commonR class PhoneInstallActivity : AppCompatActivity() { companion object { @@ -59,7 +59,8 @@ class PhoneInstallActivity : AppCompatActivity() { addCategory(Intent.CATEGORY_BROWSABLE) data = Uri.parse("https://play.google.com/store/apps/details?id=${BuildConfig.APPLICATION_ID}") }, - null // a Wear device only has one companion device so this is not needed + // A Wear device only has one companion device so this is not needed + null ).await() } catch (e: Exception) { Log.e(TAG, "Unable to open remote activity", e) @@ -69,14 +70,24 @@ class PhoneInstallActivity : AppCompatActivity() { Intent(this@PhoneInstallActivity, ConfirmationActivity::class.java).apply { putExtra( ConfirmationActivity.EXTRA_ANIMATION_TYPE, - if (success) { ConfirmationActivity.OPEN_ON_PHONE_ANIMATION } else { ConfirmationActivity.FAILURE_ANIMATION } + if (success) { + ConfirmationActivity.OPEN_ON_PHONE_ANIMATION + } else { + ConfirmationActivity.FAILURE_ANIMATION + } ) if (success) { putExtra(ConfirmationActivity.EXTRA_ANIMATION_DURATION_MILLIS, 2000) } putExtra( ConfirmationActivity.EXTRA_MESSAGE, - getString(if (success) { commonR.string.continue_on_phone } else { commonR.string.failed_phone_connection }) + getString( + if (success) { + commonR.string.continue_on_phone + } else { + commonR.string.failed_phone_connection + } + ) ) } startActivity(confirmation) diff --git a/wear/src/main/java/io/homeassistant/companion/android/onboarding/phoneinstall/PhoneInstallView.kt b/wear/src/main/java/io/homeassistant/companion/android/onboarding/phoneinstall/PhoneInstallView.kt index 20b3722285a..0fc317ca89c 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/onboarding/phoneinstall/PhoneInstallView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/onboarding/phoneinstall/PhoneInstallView.kt @@ -16,9 +16,9 @@ import androidx.wear.compose.material3.MaterialTheme import androidx.wear.compose.material3.Text import androidx.wear.tooling.preview.devices.WearDevices import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.theme.getFilledTonalButtonColors import io.homeassistant.companion.android.views.ThemeLazyColumn -import io.homeassistant.companion.android.common.R as commonR @Composable fun PhoneInstallView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/phone/PhoneSettingsListener.kt b/wear/src/main/java/io/homeassistant/companion/android/phone/PhoneSettingsListener.kt index a4b356a39cc..abe9f973e56 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/phone/PhoneSettingsListener.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/phone/PhoneSettingsListener.kt @@ -40,16 +40,16 @@ import io.homeassistant.companion.android.tiles.ConversationTile import io.homeassistant.companion.android.tiles.ShortcutsTile import io.homeassistant.companion.android.tiles.TemplateTile import io.homeassistant.companion.android.util.UrlUtil -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.launch -import kotlinx.coroutines.tasks.await import java.security.KeyStore import java.security.PrivateKey import java.security.cert.X509Certificate import javax.inject.Inject import javax.inject.Named +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.launch +import kotlinx.coroutines.tasks.await @AndroidEntryPoint @SuppressLint("VisibleForTests") // https://issuetracker.google.com/issues/239451111 diff --git a/wear/src/main/java/io/homeassistant/companion/android/sensors/BedtimeModeSensorManager.kt b/wear/src/main/java/io/homeassistant/companion/android/sensors/BedtimeModeSensorManager.kt index b5f9ba9c444..d0a235db99e 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/sensors/BedtimeModeSensorManager.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/sensors/BedtimeModeSensorManager.kt @@ -4,8 +4,8 @@ import android.content.Context import android.os.Build import android.provider.Settings import android.util.Log -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class BedtimeModeSensorManager : SensorManager { companion object { diff --git a/wear/src/main/java/io/homeassistant/companion/android/sensors/HealthServicesSensorManager.kt b/wear/src/main/java/io/homeassistant/companion/android/sensors/HealthServicesSensorManager.kt index ec03ae297c7..64310caca05 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/sensors/HealthServicesSensorManager.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/sensors/HealthServicesSensorManager.kt @@ -19,13 +19,13 @@ import androidx.health.services.client.data.PassiveListenerConfig import androidx.health.services.client.data.PassiveMonitoringCapabilities import androidx.health.services.client.data.UserActivityInfo import androidx.health.services.client.data.UserActivityState +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import io.homeassistant.companion.android.database.AppDatabase +import java.time.Instant import kotlinx.coroutines.guava.await import kotlinx.coroutines.runBlocking -import java.time.Instant -import io.homeassistant.companion.android.common.R as commonR @RequiresApi(Build.VERSION_CODES.R) class HealthServicesSensorManager : SensorManager { diff --git a/wear/src/main/java/io/homeassistant/companion/android/sensors/HeartRateSensorManager.kt b/wear/src/main/java/io/homeassistant/companion/android/sensors/HeartRateSensorManager.kt index feef3b67acc..d8ec4993add 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/sensors/HeartRateSensorManager.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/sensors/HeartRateSensorManager.kt @@ -14,10 +14,10 @@ import android.hardware.SensorManager.SENSOR_STATUS_NO_CONTACT import android.hardware.SensorManager.SENSOR_STATUS_UNRELIABLE import android.util.Log import androidx.core.content.getSystemService +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.util.STATE_UNKNOWN import kotlin.math.roundToInt -import io.homeassistant.companion.android.common.R as commonR class HeartRateSensorManager : SensorManager, SensorEventListener { companion object { diff --git a/wear/src/main/java/io/homeassistant/companion/android/sensors/OnBodySensorManager.kt b/wear/src/main/java/io/homeassistant/companion/android/sensors/OnBodySensorManager.kt index d9a9f4b5cfc..9020605e4a4 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/sensors/OnBodySensorManager.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/sensors/OnBodySensorManager.kt @@ -7,9 +7,9 @@ import android.hardware.SensorEventListener import android.hardware.SensorManager.SENSOR_DELAY_NORMAL import android.util.Log import androidx.core.content.getSystemService +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.sensors.SensorManager import kotlin.math.roundToInt -import io.homeassistant.companion.android.common.R as commonR class OnBodySensorManager : SensorManager, SensorEventListener { companion object { diff --git a/wear/src/main/java/io/homeassistant/companion/android/sensors/TheaterModeSensorManager.kt b/wear/src/main/java/io/homeassistant/companion/android/sensors/TheaterModeSensorManager.kt index 701f0d83849..631e434e4cf 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/sensors/TheaterModeSensorManager.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/sensors/TheaterModeSensorManager.kt @@ -4,8 +4,8 @@ import android.content.Context import android.os.Build import android.provider.Settings import android.util.Log -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class TheaterModeSensorManager : SensorManager { companion object { diff --git a/wear/src/main/java/io/homeassistant/companion/android/sensors/WetModeSensorManager.kt b/wear/src/main/java/io/homeassistant/companion/android/sensors/WetModeSensorManager.kt index 0919e673d94..11560b85f0d 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/sensors/WetModeSensorManager.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/sensors/WetModeSensorManager.kt @@ -2,8 +2,8 @@ package io.homeassistant.companion.android.sensors import android.content.Context import android.content.Intent -import io.homeassistant.companion.android.common.sensors.SensorManager import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.common.sensors.SensorManager class WetModeSensorManager : SensorManager { companion object { diff --git a/wear/src/main/java/io/homeassistant/companion/android/tiles/CameraTile.kt b/wear/src/main/java/io/homeassistant/companion/android/tiles/CameraTile.kt index e6fe401f1e2..f39aedad182 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/tiles/CameraTile.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/tiles/CameraTile.kt @@ -18,11 +18,15 @@ import androidx.wear.tiles.TileService import com.google.common.util.concurrent.ListenableFuture import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.WearPrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.database.AppDatabase import io.homeassistant.companion.android.database.wear.CameraTile import io.homeassistant.companion.android.util.UrlUtil +import java.io.ByteArrayOutputStream +import java.util.concurrent.TimeUnit +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -33,10 +37,6 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import okhttp3.OkHttpClient import okhttp3.Request -import java.io.ByteArrayOutputStream -import java.util.concurrent.TimeUnit -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class CameraTile : TileService() { diff --git a/wear/src/main/java/io/homeassistant/companion/android/tiles/ConversationTile.kt b/wear/src/main/java/io/homeassistant/companion/android/tiles/ConversationTile.kt index 5c5481494b5..01c5eadd5b8 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/tiles/ConversationTile.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/tiles/ConversationTile.kt @@ -19,14 +19,14 @@ import androidx.wear.tiles.TileService import com.google.common.util.concurrent.ListenableFuture import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.conversation.ConversationActivity +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.guava.future -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class ConversationTile : TileService() { diff --git a/wear/src/main/java/io/homeassistant/companion/android/tiles/OpenTileSettingsActivity.kt b/wear/src/main/java/io/homeassistant/companion/android/tiles/OpenTileSettingsActivity.kt index fc7d3ad5ec5..a1259e0c564 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/tiles/OpenTileSettingsActivity.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/tiles/OpenTileSettingsActivity.kt @@ -6,8 +6,8 @@ import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.data.prefs.WearPrefsRepositoryImpl import io.homeassistant.companion.android.home.HomeActivity -import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.launch @AndroidEntryPoint class OpenTileSettingsActivity : AppCompatActivity() { diff --git a/wear/src/main/java/io/homeassistant/companion/android/tiles/ShortcutsTile.kt b/wear/src/main/java/io/homeassistant/companion/android/tiles/ShortcutsTile.kt index c49a0689f4e..65ff998daf8 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/tiles/ShortcutsTile.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/tiles/ShortcutsTile.kt @@ -34,21 +34,21 @@ import com.mikepenz.iconics.utils.colorInt import com.mikepenz.iconics.utils.sizeDp import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.WearPrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager import io.homeassistant.companion.android.data.SimplifiedEntity import io.homeassistant.companion.android.util.getIcon +import java.nio.ByteBuffer +import javax.inject.Inject +import kotlin.math.min +import kotlin.math.roundToInt import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.guava.future import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext -import java.nio.ByteBuffer -import javax.inject.Inject -import kotlin.math.min -import kotlin.math.roundToInt -import io.homeassistant.companion.android.common.R as commonR // Dimensions (dp) private const val CIRCLE_SIZE = 56f diff --git a/wear/src/main/java/io/homeassistant/companion/android/tiles/TemplateTile.kt b/wear/src/main/java/io/homeassistant/companion/android/tiles/TemplateTile.kt index 4387797fcaf..8eabfe27be3 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/tiles/TemplateTile.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/tiles/TemplateTile.kt @@ -28,9 +28,11 @@ import com.fasterxml.jackson.databind.JsonMappingException import com.google.common.util.concurrent.ListenableFuture import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.R +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.prefs.WearPrefsRepository import io.homeassistant.companion.android.common.data.prefs.impl.entities.TemplateTileConfig import io.homeassistant.companion.android.common.data.servers.ServerManager +import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -38,8 +40,6 @@ import kotlinx.coroutines.guava.future import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext -import javax.inject.Inject -import io.homeassistant.companion.android.common.R as commonR @AndroidEntryPoint class TemplateTile : TileService() { diff --git a/wear/src/main/java/io/homeassistant/companion/android/tiles/TileActionReceiver.kt b/wear/src/main/java/io/homeassistant/companion/android/tiles/TileActionReceiver.kt index 30cf8dc63d6..4250f8604fe 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/tiles/TileActionReceiver.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/tiles/TileActionReceiver.kt @@ -8,8 +8,8 @@ import dagger.hilt.android.AndroidEntryPoint import io.homeassistant.companion.android.common.data.integration.onEntityPressedWithoutState import io.homeassistant.companion.android.common.data.prefs.WearPrefsRepository import io.homeassistant.companion.android.common.data.servers.ServerManager -import kotlinx.coroutines.runBlocking import javax.inject.Inject +import kotlinx.coroutines.runBlocking @AndroidEntryPoint class TileActionReceiver : BroadcastReceiver() { diff --git a/wear/src/main/java/io/homeassistant/companion/android/tiles/TileViews.kt b/wear/src/main/java/io/homeassistant/companion/android/tiles/TileViews.kt index b05a8303c2f..b2e264ec117 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/tiles/TileViews.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/tiles/TileViews.kt @@ -22,8 +22,8 @@ import androidx.wear.protolayout.material.Typography import androidx.wear.protolayout.material.layouts.PrimaryLayout import androidx.wear.tiles.RequestBuilders import io.homeassistant.companion.android.R -import io.homeassistant.companion.android.splash.SplashActivity import io.homeassistant.companion.android.common.R as commonR +import io.homeassistant.companion.android.splash.SplashActivity const val RESOURCE_REFRESH = "refresh" const val MODIFIER_CLICK_REFRESH = "refresh" @@ -77,10 +77,12 @@ fun primaryLayoutTimeline( action: ActionBuilders.Action ): Timeline { val theme = Colors( - ContextCompat.getColor(context, commonR.color.colorPrimary), // Primary - ContextCompat.getColor(context, commonR.color.colorOnPrimary), // On primary - ContextCompat.getColor(context, R.color.colorOverlay), // Surface - ContextCompat.getColor(context, android.R.color.white) // On surface + ContextCompat.getColor(context, commonR.color.colorPrimary), + ContextCompat.getColor(context, commonR.color.colorOnPrimary), + // Surface + ContextCompat.getColor(context, R.color.colorOverlay), + // On surface + ContextCompat.getColor(context, android.R.color.white) ) val chipColors = ChipColors.primaryChipColors(theme) val chipAction = ModifiersBuilders.Clickable.Builder() diff --git a/wear/src/main/java/io/homeassistant/companion/android/util/CommonFunctions.kt b/wear/src/main/java/io/homeassistant/companion/android/util/CommonFunctions.kt index ae3ae6174cf..cfbd6f79e7d 100755 --- a/wear/src/main/java/io/homeassistant/companion/android/util/CommonFunctions.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/util/CommonFunctions.kt @@ -5,11 +5,11 @@ import android.widget.Toast import androidx.compose.ui.hapticfeedback.HapticFeedback import androidx.compose.ui.hapticfeedback.HapticFeedbackType import com.mikepenz.iconics.typeface.IIcon +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.getIcon import io.homeassistant.companion.android.home.HomePresenterImpl import java.util.Calendar -import io.homeassistant.companion.android.common.R as commonR fun stringForDomain(domain: String, context: Context): String? = ( diff --git a/wear/src/main/java/io/homeassistant/companion/android/views/ChooseEntityView.kt b/wear/src/main/java/io/homeassistant/companion/android/views/ChooseEntityView.kt index 2a4e9345d61..958555f1c36 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/views/ChooseEntityView.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/views/ChooseEntityView.kt @@ -23,6 +23,7 @@ import androidx.wear.compose.material3.ButtonDefaults import androidx.wear.compose.material3.Text import com.mikepenz.iconics.compose.Image import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import io.homeassistant.companion.android.common.R as commonR import io.homeassistant.companion.android.common.data.integration.Entity import io.homeassistant.companion.android.common.data.integration.getIcon import io.homeassistant.companion.android.common.util.capitalize @@ -31,7 +32,6 @@ import io.homeassistant.companion.android.theme.WearAppTheme import io.homeassistant.companion.android.theme.getFilledTonalButtonColors import io.homeassistant.companion.android.util.stringForDomain import java.util.Locale -import io.homeassistant.companion.android.common.R as commonR @Composable fun ChooseEntityView( diff --git a/wear/src/main/java/io/homeassistant/companion/android/views/ListHeader.kt b/wear/src/main/java/io/homeassistant/companion/android/views/ListHeader.kt index 4c3f2a9296a..2c0d03d916a 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/views/ListHeader.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/views/ListHeader.kt @@ -11,8 +11,8 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.wear.compose.material3.ListHeader import androidx.wear.compose.material3.LocalTextStyle import androidx.wear.compose.material3.Text -import kotlin.math.floor import io.homeassistant.companion.android.common.R as commonR +import kotlin.math.floor @Composable fun ListHeader(@StringRes id: Int, modifier: Modifier = Modifier) {