Add Wear OS module for initial support (#1250)

* Add Wear OS module, initial implementation. Currently contains only basic activity with home assistant logo + text.

* Update wearos_app package name

* Also update package name in home.kt

* Update package name/application id to: io.homeassistant.companion.android
Update version code and name to be equal to that of the regular android app
Merge settings.gradle.kts include into one line
Move Home.kt to new path (based on package name)

* Remove redundant /build from .gitignore
This commit is contained in:
leroyboerefijn 2020-12-23 04:58:30 +01:00 committed by GitHub
parent 72d21bafa7
commit dbf87cc509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 462 additions and 5 deletions

1
app/.gitignore vendored
View File

@ -1,2 +1 @@
/build
google-services.json

3
buildSrc/.gitignore vendored
View File

@ -1,2 +1 @@
.gradle
/build
.gradle

View File

@ -11,6 +11,7 @@ object Config {
object Android {
const val compileSdk = 30
const val minSdk = 21
const val minSdkWear = 23
const val targetSdk = 30
const val ndk = "21.3.6528147"
}
@ -34,6 +35,9 @@ object Config {
const val daggerCompiler = "com.google.dagger:dagger-compiler:${daggerVersion}"
const val material = "com.google.android.material:material:1.2.1"
const val wearableSupport = "com.google.android.support:wearable:2.8.1"
const val wearable = "com.google.android.wearable:wearable:2.8.1"
}
object AndroidX {
@ -45,6 +49,8 @@ object Config {
const val constraintlayout = "androidx.constraintlayout:constraintlayout:1.1.3"
const val preference = "androidx.preference:preference-ktx:1.1.1"
const val wear = "androidx.wear:wear:1.1.0"
const val navigationFragment = "androidx.navigation:navigation-fragment-ktx:2.3.0"
const val navigationUi = "androidx.navigation:navigation-ui-ktx:2.3.0"

1
common/.gitignore vendored
View File

@ -1 +0,0 @@
/build

View File

@ -1,6 +1,6 @@
import org.gradle.kotlin.dsl.support.serviceOf
include(":common", ":app")
include(":common", ":app", ":wearos_app")
rootProject.name = "home-assistant-android"

View File

@ -0,0 +1,74 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
id("kotlin-android-extensions")
}
android {
compileSdkVersion(Config.Android.compileSdk)
defaultConfig {
applicationId = "io.homeassistant.companion.android"
minSdkVersion(Config.Android.minSdkWear)
targetSdkVersion(Config.Android.targetSdk)
versionName = System.getenv("VERSION") ?: "LOCAL"
versionCode = System.getenv("VERSION_CODE")?.toIntOrNull() ?: 1
javaCompileOptions {
annotationProcessorOptions {
arguments(mapOf("room.incremental" to "true"))
}
}
}
buildFeatures {
viewBinding = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
signingConfigs {
create("release") {
storeFile = file(System.getenv("KEYSTORE_PATH") ?: "release_keystore.keystore")
storePassword = System.getenv("KEYSTORE_PASSWORD") ?: ""
keyAlias = System.getenv("KEYSTORE_ALIAS") ?: ""
keyPassword = System.getenv("KEYSTORE_ALIAS_PASSWORD") ?: ""
isV1SigningEnabled = true
isV2SigningEnabled = true
}
}
buildTypes {
named("debug").configure {
applicationIdSuffix = ".debug"
}
named("release").configure {
isDebuggable = false
isJniDebuggable = false
isZipAlignEnabled = true
signingConfig = signingConfigs.getByName("release")
}
}
kotlinOptions {
jvmTarget = "1.8"
}
lintOptions {
disable("MissingTranslation")
}
}
dependencies {
implementation(project(":common"))
implementation(Config.Dependency.Google.material)
implementation(Config.Dependency.AndroidX.wear)
implementation(Config.Dependency.Google.wearableSupport)
compileOnly(Config.Dependency.Google.wearable)
}

21
wearos_app/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.homeassistant.companion.android">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.type.watch" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HomeAssistant">
<uses-library
android:name="com.google.android.wearable"
android:required="true" />
<!--
Set to true if your app is Standalone, that is, it does not require the handheld
app to run.
-->
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<activity
android:name=".Home"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,15 @@
package io.homeassistant.companion.android
import android.os.Bundle
import android.support.wearable.activity.WearableActivity
class Home : WearableActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
// Enables Always-on
setAmbientEnabled()
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dark_grey"
android:padding="@dimen/box_inset_layout_padding"
tools:context=".Home"
tools:deviceIds="wear">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/inner_frame_layout_padding"
app:layout_boxedEdges="all">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="@android:color/white"
android:textSize="12sp"
android:layout_marginTop="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:contentDescription="@string/app_name"
android:src="@drawable/app_icon"
app:layout_constraintBottom_toTopOf="@+id/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.wear.widget.BoxInsetLayout>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/colorPrimary" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/colorPrimary" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorDialogBackground">#111111</color>
<color name="colorDialogMessage">@android:color/white</color>
<color name="colorDialogTitle">@android:color/white</color>
<color name="colorActivityBackground">#1c1c1c</color>
<color name="colorPrimary">#03A9F4</color>
<color name="colorPrimaryDark">#111111</color>
<color name="colorAccent">#03A9F4</color>
<color name="colorOnPrimary">@android:color/white</color>
<color name="colorWarning">#D32F2F</color>
<color name="colorHeadline1">@android:color/white</color>
<color name="colorHeadline2">@android:color/white</color>
<color name="colorActionBar">#1c1c1c</color>
<color name="colorIcon">@android:color/white</color>
<color name="colorWidgetButtonBackground">#1c1c1c</color>
<color name="colorWidgetButtonLabel">#E6E6E6</color>
</resources>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorDialogBackground">@android:color/white</color>
<color name="colorDialogMessage">@android:color/black</color>
<color name="colorDialogTitle">@android:color/black</color>
<color name="colorActivityBackground">@android:color/white</color>
<color name="colorPrimary">#03A9F4</color>
<color name="colorPrimaryDark">#0288D1</color>
<color name="colorAccent">#03A9F4</color>
<color name="colorOnPrimary">@android:color/white</color>
<color name="colorWarning">#D32F2F</color>
<color name="colorHeadline1">@android:color/black</color>
<color name="colorHeadline2">@android:color/black</color>
<color name="colorActionBar">#03A9F4</color>
<color name="colorIcon">@android:color/black</color>
<color name="colorWidgetButtonBackground">@android:color/white</color>
<color name="colorWidgetButtonLabel">#3A3A3A</color>
</resources>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Because the window insets on round devices are larger than 15dp, this padding only applies
to square screens.
-->
<dimen name="box_inset_layout_padding">0dp</dimen>
<!--
This padding applies to both square and round screens. The total padding between the buttons
and the window insets is box_inset_layout_padding (above variable) on square screens and
inner_frame_layout_padding (below variable) on round screens.
-->
<dimen name="inner_frame_layout_padding">5dp</dimen>
</resources>

View File

@ -0,0 +1,3 @@
<resources>
<string name="app_name">Home Assistant Wear OS</string>
</resources>

View File

@ -0,0 +1,10 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.HomeAssistant" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorButtonNormal">@color/colorPrimary</item>
<item name="android:colorBackground">@color/colorActivityBackground</item>
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
</style>
</resources>