Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Request #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ It is not in the app store yet. See [this guide](https://www.reddit.com/r/WearOS
<img src="https://github.com/agronick/Flattery/assets/2042303/c9ac9c51-7ba8-42c3-8e47-1c4e8c18b1ea" alt="Running on a Galaxy Watch 4" width="250"/>

<img src="https://github.com/agronick/Flattery/assets/2042303/e4caf242-4fb3-4d02-a608-4b793ad48b8d" alt="Reordering" width="250"/>
<img src="https://github.com/JesusC0der/Flattery/assets/57578170/a1ff84f8-ab70-4755-8eb1-f236eeeb9f8b" width="250"/>

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>
32 changes: 29 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-feature android:name="android.hardware.type.watch" />

<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />


<application
android:name="com.agronick.launcher.Launcher"
android:name=".Launcher"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand All @@ -29,18 +30,43 @@
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" />
</intent-filter>
</activity>
<activity
android:name=".presentation.LauncherSettings"
android:exported="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_settings"
android:label="Launcher Settings"
android:taskAffinity="com.agronick.launchersettings.presentation.LauncherSettings"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleInstance"
android:taskAffinity="com.agronick.launcher"
android:theme="@style/Theme.Wearable.Modal">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>
2 changes: 1 addition & 1 deletion app/src/main/java/com/agronick/launcher/AppListProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import java.io.FileWriter
class AppListProvider(appList: List<PInfo>, context: Context) {

val positions = HashMap<Int, HashMap<Int, PInfo?>>().withDefault { HashMap() }
val filePath = "${context.dataDir}/appPositions2.json"
val filePath = "${context.dataDir}/appPositions.json"
val mapping = appList.map {
it.asKey() to it
}.toMap().toMutableMap()
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/agronick/launcher/Container.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import kotlin.math.roundToInt
import kotlin.math.sqrt

class Container(val appList: AppListProvider, density: Float) {
val appCircleSize = (StaticValues.normalAppSize * density).roundToInt()
val appCircleMargin = (StaticValues.margin * density).roundToInt()
private val flatAppList: List<App>
var appCircleSize = (StaticValues.normalAppSize * density).roundToInt()
var appCircleMargin = (StaticValues.margin * density).roundToInt()
val flatAppList: List<App>
var lastCircle: Circle? = null

var topLimit = 0f
Expand Down Expand Up @@ -102,17 +102,17 @@ class Container(val appList: AppListProvider, density: Float) {
}
}

private fun calcPositions(row: Int, col: Int): Pair<Float, Float> {
fun calcPositions(row: Int, col: Int): Pair<Float, Float> {
var left = calcPosition(col) * equalizerOffset
if (kotlin.math.abs(row) % 2 == 1) {
// Add offset for haxagon shape
// Add offset for hexagon shape
left -= appCircleSize + appCircleMargin
}
val top = (row * (appCircleSize * 2) + row * appCircleMargin).toFloat()
var top = (row * (appCircleSize * 2) + row * appCircleMargin).toFloat()
return Pair(left, top)
}

private fun calcPosition(num: Int): Float {
fun calcPosition(num: Int): Float {
var pos = ceil(num * 0.5f)
pos = pos * (appCircleSize * 2) + pos * appCircleMargin
if (num % 2 == 0) {
Expand Down
59 changes: 56 additions & 3 deletions app/src/main/java/com/agronick/launcher/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,53 @@
package com.agronick.launcher

import StaticValues
import android.app.Activity
import android.content.ComponentName
import android.content.Intent
import android.os.Bundle
import android.transition.Fade
import android.util.Log
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.Window
import androidx.core.view.GestureDetectorCompat
import com.google.android.wearable.input.RotaryEncoderHelper


class MainActivity : Activity(), GestureDetector.OnGestureListener {
private var wasScrolling = false
private lateinit var mDetector: GestureDetectorCompat
private lateinit var mainView: MainView

//Bezel scroll listener and conditional parameters for launcher zoom.
override fun onGenericMotionEvent(event: MotionEvent): Boolean {

if (event.action == MotionEvent.ACTION_SCROLL && RotaryEncoderHelper.isFromRotaryEncoder(event)) {

val delta = -RotaryEncoderHelper.getRotaryAxisValue(event)
Log.d("MainActivity", "Before modification: ${StaticValues.normalAppSize} ${StaticValues.margin}")

//If bezel is turned clockwise, increase size of icons up to a size of 24.
if (delta > 0 && StaticValues.normalAppSize <= 24) {
StaticValues.normalAppSize++
} else {
//If bezel is turned counter-clockwise, decrease size of icons down to a size of 12.
if (StaticValues.normalAppSize >= 12) {
StaticValues.normalAppSize--
}
}

mainView.updateIconSize(StaticValues.normalAppSize)
mainView.updateMarginSize(StaticValues.margin)

Log.d("MainActivity", "After modification: ${StaticValues.normalAppSize} ${StaticValues.margin}")
return true

}
return super.onGenericMotionEvent(event)

}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
with(window) {
Expand Down Expand Up @@ -70,17 +102,38 @@ class MainActivity : Activity(), GestureDetector.OnGestureListener {
private fun getInstalledApps(): List<PInfo> {
val mainIntent = Intent(Intent.ACTION_MAIN, null)
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER)
return packageManager.queryIntentActivities(mainIntent, 0).mapNotNull {
if (it.activityInfo.packageName.startsWith("com.agronick.launcher")) {

val appName = applicationContext.packageName
val packages = packageManager.queryIntentActivities(mainIntent, 0).mapNotNull {
if (it.activityInfo.packageName == appName) {
return@mapNotNull null
}

PInfo(
appname = it.activityInfo.packageName,
pname = it.activityInfo.packageName,
icon = it.activityInfo.loadIcon(packageManager),
activityName = it.activityInfo.name,
)
}
}.toMutableList()

packages.add(
PInfo(
appname = appName,
pname = appName,
icon = getDrawable(R.mipmap.clock),
activityName = "${appName}.presentation.BackToClock",
)
)
packages.add(
PInfo(
appname = appName,
pname = appName,
icon = getDrawable(R.mipmap.ic_settings),
activityName = "${appName}.presentation.LauncherSettings",
)
)
return packages
}

override fun onSaveInstanceState(outState: Bundle) {
Expand Down
Loading