Skip to content

Commit

Permalink
Merge branch 'release/0.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
cladel committed Aug 17, 2023
2 parents 983a611 + 0290d4d commit 295b361
Show file tree
Hide file tree
Showing 232 changed files with 12,383 additions and 6,127 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ jobs:
run: |
if [[ "${{ github.base_ref }}" == "main" || "${{github.ref}}" == "refs/heads/main" ]]; then
echo "app_env=production" >> $GITHUB_ENV
echo "upload_track=production" >> $GITHUB_ENV
else
echo "app_env=dev" >> $GITHUB_ENV
echo "upload_track=beta" >> $GITHUB_ENV
fi
- name: Version number
Expand Down Expand Up @@ -131,6 +133,6 @@ jobs:
serviceAccountJsonPlainText: ${{ secrets.ANDROID_SERVICE_ACCOUNT_JSON_TEXT }}
packageName: tech.oxymore.liane
releaseFiles: app/android/app/build/outputs/bundle/release/*.aab
track: beta
track: ${{env.upload_track}}
status: completed
inAppUpdatePriority: 5
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
username: ${{ secrets.USER }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: "/tmp/${{ env.project }}-test/test-results.trx"
source: "/tmp/it-${{ env.project }}/test-results.trx"
target: "test-results.trx"

- name: Test Report
Expand Down
16 changes: 13 additions & 3 deletions app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,19 @@ android {
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.google.android.gms:play-services-location:${rootProject.ext.googlePlayServicesVersion}")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.core:core-splashscreen:1.0.1")

implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
def activity_version = "1.6.1"
implementation( "androidx.activity:activity:$activity_version")
implementation ("androidx.activity:activity-ktx:$activity_version")

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")

implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
Expand All @@ -174,4 +183,5 @@ dependencies {
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'org.jetbrains.kotlin.android'
30 changes: 22 additions & 8 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:name=".MainApplication"
Expand All @@ -11,34 +13,46 @@
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notification" />
<activity
<!-- <activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme"
android:exported="true">

</activity>

</activity> -->
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="default" />

<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="liane" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"/>
<data android:host="liane.app"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="liane.app" />
<data android:scheme="https" android:host="dev.liane.app" />
</intent-filter>
</activity>
<service
android:foregroundServiceType="location"
android:name=".geolocation.LocationService"
android:enabled="true"/>
</application>
</manifest>
22 changes: 22 additions & 0 deletions app/android/app/src/main/java/tech/oxymore/liane/AppPackage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package tech.oxymore.liane

import android.view.View
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ReactShadowNode
import com.facebook.react.uimanager.ViewManager
import tech.oxymore.liane.geolocation.BackgroundGeolocationModule
import tech.oxymore.liane.splashscreen.SplashScreenModule

class AppPackage : ReactPackage {

override fun createViewManagers(
reactContext: ReactApplicationContext
): MutableList<ViewManager<View, ReactShadowNode<*>>> = mutableListOf()

override fun createNativeModules(
reactContext: ReactApplicationContext
): MutableList<NativeModule> = listOf(BackgroundGeolocationModule(reactContext), SplashScreenModule(reactContext)).toMutableList()
}

44 changes: 0 additions & 44 deletions app/android/app/src/main/java/tech/oxymore/liane/MainActivity.java

This file was deleted.

106 changes: 106 additions & 0 deletions app/android/app/src/main/java/tech/oxymore/liane/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package tech.oxymore.liane

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.bridge.Promise
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.concurrentReactEnabled
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.common.api.ResolvableApiException
import com.google.android.gms.location.*
import com.google.android.gms.tasks.Task
import tech.oxymore.liane.geolocation.LocationRequestHandler
import tech.oxymore.liane.geolocation.LogTag
import tech.oxymore.liane.splashscreen.SplashScreenActivity

class MainActivity : SplashScreenActivity(), LocationRequestHandler {
lateinit var locationRequestLauncher : ActivityResultLauncher<IntentSenderRequest>
var promise: Promise? = null
/**
* Required by react navigation to handle wake up
*/
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(null)
locationRequestLauncher = registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { r ->
if (r.resultCode == Activity.RESULT_OK) {
promise?.resolve(true)
} else {
promise?.reject("rejected")
}
promise = null
}

}

/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String {
return "liane"
}

/**
* Returns the instance of the [ReactActivityDelegate]. Here we use a util class [ ] which allows you to easily enable Fabric and Concurrent React
* (aka React 18) with two boolean flags.
*/
override fun createReactActivityDelegate(): ReactActivityDelegate {
return DefaultReactActivityDelegate(
this,
mainComponentName, // If you opted-in for the New Architecture, we enable the Fabric Renderer.
fabricEnabled, // fabricEnabled
// If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
concurrentReactEnabled // concurrentRootEnabled
)
}

override fun requestEnableLocation(promise: Promise) {
if (this.promise != null) return
val locationRequest: LocationRequest = LocationRequest.create()
locationRequest.setPriority(Priority.PRIORITY_HIGH_ACCURACY)
val builder = LocationSettingsRequest.Builder()
.addLocationRequest(locationRequest)

val result: Task<LocationSettingsResponse> =
LocationServices.getSettingsClient(this).checkLocationSettings(builder.build())



result.addOnCompleteListener { task ->
try {
val response = task.getResult(ApiException::class.java)
// All location settings are satisfied. The client can initialize location
// requests here.
promise.resolve(true)
} catch (exception: ApiException) {
when (exception.statusCode) {
LocationSettingsStatusCodes.RESOLUTION_REQUIRED ->
// Location settings are not satisfied. But could be fixed by showing the
// user a dialog.
try {
val resolvable = exception as ResolvableApiException
this.promise = promise
locationRequestLauncher.launch(IntentSenderRequest.Builder(resolvable.resolution).build())
} catch (e: Exception) {
Log.e(LogTag, e.message.toString())
promise.reject("rejected")
}

LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE -> {promise.reject("rejected")}
}
}
}



}


}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new AppPackage());
return packages;
}

@Override
protected String getJSMainModuleName() {
return "index";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package tech.oxymore.liane.geolocation


data class PingConfig(val url: String, val token: String, val userId: String, val lianeId: String)
data class GeolocationConfig(val defaultInterval: Long, val nearWayPointInterval: Long, val nearWayPointRadius: Int)




Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package tech.oxymore.liane.geolocation

import android.content.Intent
import android.util.Log
import com.facebook.react.bridge.*
import tech.oxymore.liane.geolocation.Util.isMyServiceRunning

public const val LogTag = "BackgroundGeoService"
class BackgroundGeolocationModule (context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {

private lateinit var mServiceIntent: Intent
override fun getName(): String {
return "BackgroundGeolocationServiceModule";
}

@ReactMethod
fun enableLocation(promise: Promise) {
if(currentActivity is LocationRequestHandler) (currentActivity as LocationRequestHandler).requestEnableLocation(promise)
else promise.reject("unsupported")
}


@ReactMethod
fun stopService(promise: Promise) {
if (::mServiceIntent.isInitialized) {
reactApplicationContext.stopService(mServiceIntent)
promise.resolve(null)
}
promise.reject("no service running")
}

@ReactMethod
fun isRunning(promise: Promise){
promise.resolve(isMyServiceRunning(LocationService::class.java, reactApplicationContext))
}

@ReactMethod
fun startService(config: ReadableMap, promise: Promise) {
if (!isMyServiceRunning(LocationService::class.java, reactApplicationContext)) {
mServiceIntent = Intent(reactApplicationContext, LocationService::class.java)
mServiceIntent.putExtras(Arguments.toBundle(config)!!)

reactApplicationContext.startService(mServiceIntent)
Log.d(LogTag, "start service")
promise.resolve(null)
} else {
Log.d(LogTag, "service was already started")
promise.reject("service already started")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package tech.oxymore.liane.geolocation

import com.facebook.react.bridge.Promise

interface LocationRequestHandler {
fun requestEnableLocation(promise: Promise)
}
Loading

0 comments on commit 295b361

Please sign in to comment.