Skip to content

Commit

Permalink
Merge pull request #38 from SimpleAppProjects/develop
Browse files Browse the repository at this point in the history
v1.14.0
  • Loading branch information
thewizrd committed May 16, 2024
2 parents 679ed40 + 0ad08dd commit 727da9d
Show file tree
Hide file tree
Showing 181 changed files with 10,788 additions and 9,837 deletions.
46 changes: 25 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,48 @@ buildscript {
minSdkVersion = 24
targetSdkVersion = 33

kotlin_version = '1.9.0'
kotlinx_version = '1.7.3'
kotlin_version = '1.9.23'
kotlinx_version = '1.8.1'

desugar_version = '2.0.3'
desugar_version = '2.0.4'

firebase_version = '32.3.1'
firebase_version = '32.8.1'

activity_version = '1.9.0'
appcompat_version = '1.6.1'
constraintlayout_version = '2.1.4'
core_version = '1.12.0'
fragment_version = '1.6.1'
lifecycle_version = '2.6.2'
core_version = '1.13.1'
fragment_version = '1.7.1'
lifecycle_version = '2.8.0'
preference_version = '1.2.1'
recyclerview_version = '1.3.1'
coresplash_version = '1.0.0'
work_version = '2.8.1'
recyclerview_version = '1.3.2'
coresplash_version = '1.0.1'
work_version = '2.9.0'
navigation_version = '2.7.7'

test_core_version = '1.5.0'
test_runner_version = '1.5.2'
test_rules_version = '1.5.0'
junit_version = '1.1.5'
androidx_truth_version = '1.5.0'
google_truth_version = '1.1.5'
google_truth_version = '1.4.2'

material_version = '1.9.0'
material_version = '1.12.0'

compose_compiler_version = '1.5.2'
compose_version = '1.5.1'
wear_compose_version = '1.2.0'
horologist_version = '0.4.12'
accompanist_version = '0.30.1'
compose_bom_version = '2024.05.00'
compose_compiler_version = '1.5.13'
wear_compose_version = '1.3.1'
wear_tiles_version = '1.3.0'
wear_watchface_version = '1.2.1'
horologist_version = '0.5.27'
accompanist_version = '0.34.0'

gson_version = '2.10.1'
timber_version = '5.0.1'

// Shizuku
shizuku_version = '13.1.5'
refine_version = '4.3.0'
refine_version = '4.4.0'
}

repositories {
Expand All @@ -52,8 +56,8 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.android.tools.build:gradle:8.4.0'
classpath 'com.google.gms:google-services:4.4.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -69,6 +73,6 @@ allprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
9 changes: 5 additions & 4 deletions hidden-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ android {
minifyEnabled false
}
release {
minifyEnabled true
// Let the app module take care of this
minifyEnabled false
}
}

Expand All @@ -37,7 +38,7 @@ android {
}

dependencies {
annotationProcessor 'dev.rikka.tools.refine:annotation-processor:4.3.0'
compileOnly 'dev.rikka.tools.refine:annotation:4.3.0'
implementation 'androidx.annotation:annotation:1.7.0'
annotationProcessor 'dev.rikka.tools.refine:annotation-processor:4.4.0'
compileOnly 'dev.rikka.tools.refine:annotation:4.4.0'
implementation 'androidx.annotation:annotation:1.8.0'
}
22 changes: 22 additions & 0 deletions hidden-api/src/main/java/android/content/pm/IPackageManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package android.content.pm;

import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.IInterface;

import androidx.annotation.DeprecatedSinceApi;

public interface IPackageManager extends IInterface {

void grantRuntimePermission(String packageName, String permissionName, int userId);

@DeprecatedSinceApi(api = Build.VERSION_CODES.R)
void revokeRuntimePermission(String packageName, String permissionName, int userId);

abstract class Stub extends Binder implements IPackageManager {
public static IPackageManager asInterface(IBinder obj) {
throw new RuntimeException("Stub!");
}
}
}
20 changes: 20 additions & 0 deletions hidden-api/src/main/java/android/location/ILocationManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package android.location;

import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.IInterface;

import androidx.annotation.RequiresApi;

public interface ILocationManager extends IInterface {

@RequiresApi(api = Build.VERSION_CODES.P)
void setLocationEnabledForUser(boolean enabled, int userId);

abstract class Stub extends Binder implements ILocationManager {
public static ILocationManager asInterface(IBinder obj) {
throw new RuntimeException("Stub!");
}
}
}
23 changes: 23 additions & 0 deletions hidden-api/src/main/java/android/net/IConnectivityManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package android.net;

import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.IInterface;
import android.os.ResultReceiver;

import androidx.annotation.DeprecatedSinceApi;

public interface IConnectivityManager extends IInterface {
@DeprecatedSinceApi(api = Build.VERSION_CODES.R)
void startTethering(int type, ResultReceiver receiver, boolean showProvisioningUi);

@DeprecatedSinceApi(api = Build.VERSION_CODES.R)
void stopTethering(int type);

abstract class Stub extends Binder implements IConnectivityManager {
public static IConnectivityManager asInterface(IBinder obj) {
throw new RuntimeException("Stub!");
}
}
}
8 changes: 5 additions & 3 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
// NOTE: Version Code Format [TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)]
versionCode 331913100
versionName "1.13.1"
versionCode 331914040
versionName "1.14.0"

vectorDrawables.useSupportLibrary = true
}
Expand Down Expand Up @@ -90,14 +90,16 @@ dependencies {
implementation "androidx.core:core-splashscreen:$coresplash_version"

implementation 'com.google.android.gms:play-services-wearable:18.1.0'
implementation 'com.google.android.play:app-update-ktx:2.1.0'

implementation platform("com.google.firebase:firebase-bom:$firebase_version")
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-config'

implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation 'androidx.media:media:1.6.0'
implementation 'androidx.media:media:1.7.0'

implementation "com.google.android.material:material:$material_version"

Expand Down
18 changes: 17 additions & 1 deletion mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
<!-- InCallController permissions -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.MANAGE_ONGOING_CALLS" />
<uses-permission
android:name="android.permission.MANAGE_ONGOING_CALLS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.REQUEST_COMPANION_PROFILE_WATCH" />
<uses-permission android:name="android.permission.REQUEST_COMPANION_START_FOREGROUND_SERVICES_FROM_BACKGROUND" />

Expand All @@ -52,6 +54,8 @@
<queries>
<package android:name="com.thewizrd.simplesleeptimer" />
<package android:name="com.thewizrd.simplesleeptimer.debug" />
<package android:name="com.thewizrd.wearsettings" />
<package android:name="com.thewizrd.wearsettings.debug" />

<intent>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -174,6 +178,18 @@
</intent-filter>
</receiver>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<!-- If you are using androidx.startup to initialize other components -->
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>

</application>

</manifest>
15 changes: 12 additions & 3 deletions mobile/src/main/java/com/thewizrd/simplewear/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.thewizrd.shared_resources.helpers.AppState
import com.thewizrd.shared_resources.utils.CrashlyticsLoggingTree
import com.thewizrd.shared_resources.utils.JSONParser
import com.thewizrd.shared_resources.utils.Logger
import com.thewizrd.simplewear.camera.TorchListener
import com.thewizrd.simplewear.media.MediaControllerService
import com.thewizrd.simplewear.services.CallControllerService
import com.thewizrd.simplewear.telephony.SubscriptionListener
Expand Down Expand Up @@ -183,6 +184,13 @@ class App : Application(), ApplicationLib, ActivityLifecycleCallbacks, Configura
}
}

runCatching {
if (appContext.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {
// Register listener for camera flash
TorchListener.registerListener(appContext)
}
}

val oldHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { t, e ->
Logger.writeLine(Log.ERROR, e, "Uncaught exception!")
Expand Down Expand Up @@ -214,6 +222,8 @@ class App : Application(), ApplicationLib, ActivityLifecycleCallbacks, Configura
}

override fun onTerminate() {
SubscriptionListener.unregisterListener(appContext)
TorchListener.unregisterListener(appContext)
contentResolver.unregisterContentObserver(mContentObserver)
appContext.unregisterReceiver(mActionsReceiver)
// Shutdown logger
Expand Down Expand Up @@ -245,9 +255,8 @@ class App : Application(), ApplicationLib, ActivityLifecycleCallbacks, Configura
}
}

override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
override val workManagerConfiguration: Configuration
get() = Configuration.Builder()
.setMinimumLoggingLevel(if (BuildConfig.DEBUG) Log.DEBUG else Log.INFO)
.build()
}
}
55 changes: 46 additions & 9 deletions mobile/src/main/java/com/thewizrd/simplewear/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
package com.thewizrd.simplewear

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.ViewTreeObserver
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.lifecycleScope
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.color.DynamicColors
import com.thewizrd.simplewear.updates.InAppUpdateManager
import kotlinx.coroutines.launch

class MainActivity : AppCompatActivity() {
companion object {
private const val INSTALL_REQUESTCODE = 168
}

private lateinit var inAppUpdateManager: InAppUpdateManager
private var isReadyToView = false

override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)

val splashScreen = installSplashScreen()

// Note: needed due to splash screen theme
DynamicColors.applyIfAvailable(this)

inAppUpdateManager = InAppUpdateManager.create(applicationContext)

// Stop activity from rendering until next activity or if immediate update available
val content = findViewById<View>(android.R.id.content)
content.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
Expand All @@ -34,18 +44,45 @@ class MainActivity : AppCompatActivity() {

setContentView(R.layout.activity_main)

// Check if fragment exists
if (supportFragmentManager.findFragmentById(R.id.fragment_container) == null) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, PermissionCheckFragment())
.runOnCommit {
isReadyToView = true
lifecycleScope.launch {
if (inAppUpdateManager.shouldStartImmediateUpdateFlow()) {
inAppUpdateManager.startImmediateUpdateFlow(this@MainActivity, INSTALL_REQUESTCODE)
} else {
// Check if fragment exists
if (supportFragmentManager.findFragmentById(R.id.fragment_container) == null) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, PermissionCheckFragment())
.runOnCommit {
isReadyToView = true
}
.commit()
}
.commit()
}
}

val appBarLayout = findViewById<AppBarLayout>(R.id.app_bar)
appBarLayout.liftOnScrollTargetViewId = R.id.scrollView
appBarLayout.isLiftOnScroll = true
}

override fun onResume() {
super.onResume()

// Checks that the update is not stalled during 'onResume()'.
// However, you should execute this check at all entry points into the app.
inAppUpdateManager.resumeUpdateIfStarted(this, INSTALL_REQUESTCODE)
isReadyToView = true
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == INSTALL_REQUESTCODE) {
if (resultCode != RESULT_OK) {
// Update flow failed; exit
finishAffinity()
}
} else {
super.onActivityResult(requestCode, resultCode, data)
}
}
}
Loading

0 comments on commit 727da9d

Please sign in to comment.