-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* World Clock / UTC renamed to World Clock 1 - uses Timezone 1 ID * World Clock 2 - uses Timezone 2 ID * Gradle version 7.4.1
- Loading branch information
1 parent
e3ec8ab
commit 58e7393
Showing
28 changed files
with
377 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
wear/src/main/java/com/weartools/weekdayutccomp/FlashlightActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.weartools.weekdayutccomp | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
import android.view.WindowManager | ||
import com.weartools.weekdayutccomp.databinding.FlashlightBinding | ||
|
||
|
||
class FlashlightActivity : Activity() { | ||
|
||
private lateinit var binding: FlashlightBinding | ||
private var flashlightstate: Int = 1 | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
binding = FlashlightBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
val lp: WindowManager.LayoutParams = this@FlashlightActivity.window.attributes | ||
val brightness = 1.0f | ||
lp.screenBrightness = brightness | ||
this@FlashlightActivity.window.attributes = lp | ||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) | ||
flashlightstate = 1 | ||
|
||
binding.flashlightContainer.setOnClickListener { | ||
changeImage() | ||
} | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
when (flashlightstate) { | ||
3 -> { | ||
val lp: WindowManager.LayoutParams = this@FlashlightActivity.window.attributes | ||
val brightness = 1.0f | ||
lp.screenBrightness = brightness | ||
this@FlashlightActivity.window.attributes = lp | ||
binding.flashlightContainer.setBackgroundResource(R.drawable.bg_white) | ||
binding.flashlightImage.setImageResource(R.drawable.ic_flashlight_on_1) | ||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) // Keep screen -> ON | ||
flashlightstate = 1 | ||
} | ||
} | ||
|
||
} | ||
|
||
private fun changeImage() { | ||
when (flashlightstate) { | ||
1 -> { | ||
binding.flashlightContainer.setBackgroundResource(R.drawable.bg_red) | ||
binding.flashlightImage.setImageResource(R.drawable.ic_flashlight_on_2) | ||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) // Keep screen -> ON | ||
flashlightstate = 2 | ||
} | ||
2 -> { | ||
val lp: WindowManager.LayoutParams = this@FlashlightActivity.window.attributes | ||
val brightness = 0.2f | ||
lp.screenBrightness = brightness | ||
this@FlashlightActivity.window.attributes = lp | ||
binding.flashlightContainer.setBackgroundResource(R.drawable.bg_black) | ||
binding.flashlightImage.setImageResource(R.drawable.ic_flashlight_off) | ||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) // Keep screen -> OFF | ||
flashlightstate = 3 | ||
} | ||
else -> { | ||
val lp: WindowManager.LayoutParams = this@FlashlightActivity.window.attributes | ||
val brightness = 1.0f | ||
lp.screenBrightness = brightness | ||
this@FlashlightActivity.window.attributes = lp | ||
binding.flashlightContainer.setBackgroundResource(R.drawable.bg_white) | ||
binding.flashlightImage.setImageResource(R.drawable.ic_flashlight_on_1) | ||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) // Keep screen -> ON | ||
flashlightstate = 1 | ||
} | ||
} | ||
} | ||
|
||
} |
120 changes: 120 additions & 0 deletions
120
wear/src/main/java/com/weartools/weekdayutccomp/FlashlightComplicationService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Copyright 2022 amoledwatchfaces™ | ||
* [email protected] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.weartools.weekdayutccomp | ||
|
||
import android.app.PendingIntent | ||
import android.content.Intent | ||
import android.graphics.drawable.Icon.createWithResource | ||
import android.util.Log | ||
import androidx.wear.watchface.complications.data.* | ||
import androidx.wear.watchface.complications.datasource.ComplicationRequest | ||
import androidx.wear.watchface.complications.datasource.SuspendingComplicationDataSourceService | ||
import com.weartools.weekdayutccomp.R.drawable | ||
|
||
class FlashlightComplicationService : SuspendingComplicationDataSourceService() { | ||
|
||
override fun onComplicationActivated( | ||
complicationInstanceId: Int, | ||
type: ComplicationType | ||
) { | ||
Log.d(TAG, "onComplicationActivated(): $complicationInstanceId") | ||
} | ||
|
||
private fun openScreen(): PendingIntent? { | ||
|
||
val intent = Intent(this, FlashlightActivity::class.java) | ||
// | ||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK | ||
|
||
return PendingIntent.getActivity( | ||
this, 0, intent, | ||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE | ||
|
||
) | ||
} | ||
|
||
override fun getPreviewData(type: ComplicationType): ComplicationData? { | ||
return when (type) { | ||
ComplicationType.MONOCHROMATIC_IMAGE -> MonochromaticImageComplicationData.Builder( | ||
monochromaticImage = MonochromaticImage.Builder( | ||
createWithResource(this, drawable.ic_flashlight) | ||
) | ||
.setAmbientImage(createWithResource(this, drawable.ic_flashlight)) | ||
.build(), | ||
contentDescription = PlainComplicationText.Builder(text = "Flashlight").build() | ||
) | ||
.setTapAction(null) | ||
.build() | ||
ComplicationType.SMALL_IMAGE -> SmallImageComplicationData.Builder( | ||
smallImage = SmallImage.Builder( | ||
image = createWithResource(this, drawable.ic_flashlight), | ||
type = SmallImageType.ICON | ||
).build(), | ||
contentDescription = PlainComplicationText.Builder(text = "Flashlight").build() | ||
) | ||
.setTapAction(null) | ||
.build() | ||
else -> {null} | ||
} | ||
} | ||
|
||
override suspend fun onComplicationRequest(request: ComplicationRequest): ComplicationData? { | ||
Log.d(TAG, "onComplicationRequest() id: ${request.complicationInstanceId}") | ||
|
||
return when (request.complicationType) { | ||
|
||
ComplicationType.MONOCHROMATIC_IMAGE -> MonochromaticImageComplicationData.Builder( | ||
monochromaticImage = MonochromaticImage.Builder( | ||
createWithResource(this, drawable.ic_flashlight) | ||
) | ||
.setAmbientImage(createWithResource(this, drawable.ic_flashlight)) | ||
.build(), | ||
contentDescription = PlainComplicationText.Builder(text = "Flashlight").build() | ||
) | ||
.setTapAction(openScreen()) | ||
.build() | ||
|
||
|
||
ComplicationType.SMALL_IMAGE -> SmallImageComplicationData.Builder( | ||
smallImage = SmallImage.Builder( | ||
image = createWithResource(this, drawable.ic_flashlight), | ||
type = SmallImageType.ICON | ||
).build(), | ||
contentDescription = PlainComplicationText.Builder(text = "Flashlight").build() | ||
) | ||
.setTapAction(openScreen()) | ||
.build() | ||
|
||
else -> { | ||
if (Log.isLoggable(TAG, Log.WARN)) { | ||
Log.w(TAG, "Unexpected complication type ${request.complicationType}") | ||
} | ||
null | ||
} | ||
|
||
} | ||
} | ||
|
||
override fun onComplicationDeactivated(complicationInstanceId: Int) { | ||
Log.d(TAG, "onComplicationDeactivated(): $complicationInstanceId") | ||
} | ||
|
||
companion object { | ||
private const val TAG = "FlashlightComplication" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<color android:color="#000" | ||
xmlns:android="http://schemas.android.com/apk/res/android" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector | ||
android:height="192.0dip" | ||
android:width="192.0dip" | ||
android:viewportWidth="192.0" | ||
android:viewportHeight="192.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path | ||
android:fillColor="@drawable/bg_red_0" | ||
android:pathData="M96,192a96,96 0,1 0,0 -192a96,96 0,1 0,0 192z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<gradient | ||
android:type="radial" | ||
android:centerX="96.0" | ||
android:centerY="96.0" | ||
android:gradientRadius="96.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="#FF0000" android:offset="0.0" /> | ||
<item android:color="#FF0000" android:offset="0.874762" /> | ||
<item android:color="#00FF0000" android:offset="1.0" /> | ||
</gradient> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector | ||
android:height="192.0dip" | ||
android:width="192.0dip" | ||
android:viewportWidth="192.0" | ||
android:viewportHeight="192.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path | ||
android:fillColor="@drawable/bg_white_0" | ||
android:pathData="M96,192a96,96 0,1 0,0 -192a96,96 0,1 0,0 192z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<gradient | ||
android:type="radial" | ||
android:centerX="96.0" | ||
android:centerY="96.0" | ||
android:gradientRadius="96.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="#fff" android:offset="0.0" /> | ||
<item android:color="#fff" android:offset="0.874762" /> | ||
<item android:color="#00FFFFFF" android:offset="1.0" /> | ||
</gradient> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector | ||
android:tint="#fff" | ||
android:height="32.0dip" | ||
android:width="32.0dip" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#fff" android:pathData="M18,2L6,2v6l2,3v11h8L16,11l2,-3L18,2zM16,4v1L8,5L8,4h8zM14,10.4L14,20h-4v-9.61l-2,-3L8,7h8v0.39l-2,3.01z" /> | ||
<path android:fillColor="#fff" android:pathData="M12,14m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector | ||
android:tint="#fff" | ||
android:height="32.0dip" | ||
android:width="32.0dip" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#fff" android:pathData="M21.19,21.19L2.81,2.81 1.39,4.22 8,10.83L8,22h8v-3.17l3.78,3.78 1.41,-1.42zM14,20h-4v-7.17l4,4L14,20zM16,7v0.39l-2,3v0.78l2,2L16,11l2,-3L18,2L6,2v1.17L9.83,7L16,7zM8,4h8v1L8,5L8,4zM10.5,14c0,-0.2 0.04,-0.39 0.11,-0.56l1.95,1.95c-0.17,0.07 -0.36,0.11 -0.56,0.11 -0.83,0 -1.5,-0.67 -1.5,-1.5z" /> | ||
</vector> |
Oops, something went wrong.