Skip to content

Commit

Permalink
Added "Back to Watch Face" Button/App
Browse files Browse the repository at this point in the history
Implemented a clock button/app within the launcher that, when clicked, simulates a home button press, bringing the user back to the watch face. This is intended to be similar to how the Apple Watch's launcher functions. Overall, it functions as it should, but I may add a few bug fixes to it.
  • Loading branch information
JesusC0der committed May 7, 2024
1 parent 7c307ef commit a4f3d1a
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 11 deletions.
25 changes: 25 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ android {
targetSdkVersion 34
versionCode versionMajor * 100 + versionMinor * 10 + versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
vectorDrawables {
useSupportLibrary true
}
}

buildTypes {
Expand All @@ -35,6 +38,17 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_19
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.5.1'
}
packaging {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

dependencies {
Expand All @@ -50,5 +64,16 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'

implementation 'androidx.wear:wear:1.3.0'
implementation platform('androidx.compose:compose-bom:2023.08.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.wear.compose:compose-material:1.2.1'
implementation 'androidx.wear.compose:compose-foundation:1.2.1'
implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'androidx.core:core-splashscreen:1.0.1'
androidTestImplementation platform('androidx.compose:compose-bom:2023.08.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
compileOnly 'com.google.android.wearable:wearable:2.9.0'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
8 changes: 8 additions & 0 deletions app/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Ignore the IconLocation for the Tile preview images -->
<issue id="IconLocation">
<ignore path="res/drawable/tile_preview.png" />
<ignore path="res/drawable-round/tile_preview.png" />
</issue>
</lint>
31 changes: 22 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<application
android:name=".Launcher"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault"
android:hardwareAccelerated="true">
android:theme="@android:style/Theme.DeviceDefault">
<uses-library
android:name="com.google.android.wearable"
android:required="true" />
Expand All @@ -30,15 +30,28 @@
android:name="com.google.android.wearable.standalone"
android:value="true" />

<activity
android:name=".presentation.BackToClock"
android:exported="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/clock"
android:label="Clock"
android:taskAffinity="com.agronick.launchersettings.presentation.BackToClock"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".presentation.LauncherSettings"
android:exported="true"
android:taskAffinity="com.agronick.launchersettings.presentation.LauncherSettings"
android:theme="@style/AppTheme"
android:label="Launcher Settings"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_settings"
android:hardwareAccelerated="true">

android:label="Launcher Settings"
android:taskAffinity="com.agronick.launchersettings.presentation.LauncherSettings"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -48,10 +61,10 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleInstance"
android:taskAffinity="com.agronick.launcher"
android:theme="@style/Theme.Wearable.Modal"
android:hardwareAccelerated="true">
android:theme="@style/Theme.Wearable.Modal">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

package com.agronick.launcher.presentation

import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity


class BackToClock : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)
val i = Intent(Intent.ACTION_MAIN)
i.addCategory(Intent.CATEGORY_HOME)
startActivity(i)

finish()
}
}

Binary file added app/src/main/res/mipmap-hdpi/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-mdpi/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xhdpi/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxxhdpi/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion app/src/main/res/values-round/strings.xml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<resources></resources>
<resources>
<string name="hello_world">From the Round world,\nHello, %1$s!</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
values-round/strings.xml for round devices.
-->
<string name="max_rows">Max rows</string>
<string name="title_activity_back_to_clock">BackToClock</string>
<!--
This string is used for square devices and overridden by hello_world in
values-round/strings.xml for round devices.
-->
<string name="hello_world">From the Square world,\nHello, %1$s!</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<color name="colorAccent">#7842f5</color>
<color name="background">#121212</color>
<color name="textColor">#b1bbc9</color>

<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
Expand All @@ -16,4 +17,10 @@
<item name="android:textColor">@color/textColor</item>
</style>

<style name="BackToClockTheme.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@android:color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
<item name="postSplashScreenTheme">@android:style/Theme.DeviceDefault</item>
</style>

</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.9.21'
ext.kotlin_version = '1.9.0'
repositories {
google()
mavenCentral()
Expand Down

0 comments on commit a4f3d1a

Please sign in to comment.