[AA] Enabled rudimentary Android Auto Support
Enabled the app for Android Auto, currently no real functionality yet, but to be added in future commits.
This commit is contained in:
@@ -13,7 +13,8 @@ android {
|
|||||||
minSdk 32
|
minSdk 32
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0" // ... other configurations
|
||||||
|
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -31,11 +32,12 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.7.0'
|
implementation 'androidx.appcompat:appcompat:1.7.0'
|
||||||
implementation 'com.google.android.material:material:1.12.0'
|
implementation 'com.google.android.material:material:1.12.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
|
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
|
||||||
implementation 'io.reactivex.rxjava3:rxjava:3.1.5'
|
implementation 'io.reactivex.rxjava3:rxjava:3.1.5'
|
||||||
|
implementation 'androidx.car.app:app:1.4.0'
|
||||||
|
implementation 'androidx.concurrent:concurrent-futures:1.2.0'
|
||||||
|
|
||||||
//Google Maps SDK
|
//Google Maps SDK
|
||||||
implementation 'com.google.android.gms:play-services-maps:19.1.0'
|
implementation 'com.google.android.gms:play-services-maps:19.1.0'
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.geo.API_KEY"
|
android:name="com.google.android.geo.API_KEY"
|
||||||
android:value="AIzaSyB7C4QCJEBvS7mFa_DeIZdzqe2hddtl-vk" />
|
android:value="AIzaSyB7C4QCJEBvS7mFa_DeIZdzqe2hddtl-vk" />
|
||||||
|
<meta-data android:name="com.google.android.gms.car.application"
|
||||||
|
android:resource="@xml/automotive_app_desc"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".FlashlightActivity"
|
android:name=".FlashlightActivity"
|
||||||
@@ -66,6 +68,13 @@
|
|||||||
android:name=".workers.ShareLocationBackgroundWorker"
|
android:name=".workers.ShareLocationBackgroundWorker"
|
||||||
android:foregroundServiceType="location" />
|
android:foregroundServiceType="location" />
|
||||||
|
|
||||||
|
<service android:name=".auto.ShareLocationCarAppService"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="androidx.car.app.action.SERVICE" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".DoerflingerHelpersDeviceAdminReceiver"
|
android:name=".DoerflingerHelpersDeviceAdminReceiver"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.aldo.apps.familyhelpers.auto;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.car.app.CarAppService;
|
||||||
|
import androidx.car.app.Session;
|
||||||
|
import androidx.car.app.validation.HostValidator;
|
||||||
|
|
||||||
|
public class ShareLocationCarAppService extends CarAppService {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public HostValidator createHostValidator() {
|
||||||
|
return HostValidator.ALLOW_ALL_HOSTS_VALIDATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Session onCreateSession() {
|
||||||
|
return new ShareLocationSession();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.aldo.apps.familyhelpers.auto;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.car.app.CarContext;
|
||||||
|
import androidx.car.app.Screen;
|
||||||
|
import androidx.car.app.model.CarIcon;
|
||||||
|
import androidx.car.app.model.GridTemplate;
|
||||||
|
import androidx.car.app.model.ItemList;
|
||||||
|
import androidx.car.app.model.Row;
|
||||||
|
import androidx.car.app.model.Template;
|
||||||
|
import androidx.core.graphics.drawable.IconCompat;
|
||||||
|
|
||||||
|
import com.aldo.apps.familyhelpers.R;
|
||||||
|
import com.aldo.apps.familyhelpers.workers.ShareLocationBackgroundWorker;
|
||||||
|
|
||||||
|
public class ShareLocationScreen extends Screen {
|
||||||
|
|
||||||
|
// Constructor for ShareLocationScreen
|
||||||
|
protected ShareLocationScreen(@NonNull CarContext carContext) {
|
||||||
|
super(carContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Template onGetTemplate() {
|
||||||
|
// Create an ItemList to hold the rows
|
||||||
|
final ItemList itemList = new ItemList.Builder()
|
||||||
|
.addItem(new Row.Builder()
|
||||||
|
.setTitle("Start Sharing Location") // Set the title of the row
|
||||||
|
.setOnClickListener(() -> {
|
||||||
|
// Create an intent to start the ShareLocationBackgroundWorker service
|
||||||
|
final Intent startServiceIntent = new Intent(getCarContext(), ShareLocationBackgroundWorker.class);
|
||||||
|
// Start the service using the car context
|
||||||
|
getCarContext().startForegroundService(startServiceIntent);
|
||||||
|
Log.d("ShareLocationScreen", "Starting ShareLocationBackgroundWorker Service");
|
||||||
|
})
|
||||||
|
.setImage(new CarIcon.Builder(
|
||||||
|
IconCompat.createWithResource(getCarContext(),
|
||||||
|
R.drawable.ic_location_helper)).build())
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
// Return a GridTemplate with the ItemList
|
||||||
|
return new GridTemplate.Builder()
|
||||||
|
.setSingleList(itemList)
|
||||||
|
.setTitle("Share Location")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.aldo.apps.familyhelpers.auto;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.car.app.Session;
|
||||||
|
|
||||||
|
public class ShareLocationSession extends Session {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public androidx.car.app.Screen onCreateScreen(@NonNull Intent intent) {
|
||||||
|
return new ShareLocationScreen(getCarContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,7 +82,7 @@ public final class LocationHelper {
|
|||||||
for (final Location location : allReceivedLocations) {
|
for (final Location location : allReceivedLocations) {
|
||||||
if (location.hasSpeed()) {
|
if (location.hasSpeed()) {
|
||||||
Log.d(TAG, "onLocationResult: Location with speed received, continue...");
|
Log.d(TAG, "onLocationResult: Location with speed received, continue...");
|
||||||
handleReceivedLocation(location);
|
handleReceivedLocation(location);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,4 +68,10 @@
|
|||||||
<string name="pref_key_flashlight_store_brightness" translatable="false">store_last_brightness</string>
|
<string name="pref_key_flashlight_store_brightness" translatable="false">store_last_brightness</string>
|
||||||
<string name="pref_key_flashlight_default_brightness" translatable="false">flashlight_default_brightness</string>
|
<string name="pref_key_flashlight_default_brightness" translatable="false">flashlight_default_brightness</string>
|
||||||
|
|
||||||
|
<!-- Android Auto related Strings -->
|
||||||
|
<string name="android_auto_message_currently_sharing" translatable="false">You are already sharing your location with your family, do you wanna stop?</string>
|
||||||
|
<string name="android_auto_message_not_sharing" translatable="false">Android Auto start has been detected, do you wanna share your location?</string>
|
||||||
|
<string name="android_auto_actions_start_sharing" translatable="false">Yes, start to share</string>
|
||||||
|
<string name="android_auto_actions_stop_sharing" translatable="false">Yes, stop sharing</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
4
app/src/main/res/xml/automotive_app_desc.xml
Normal file
4
app/src/main/res/xml/automotive_app_desc.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<automotiveApp>
|
||||||
|
<uses name="notification" />
|
||||||
|
</automotiveApp>
|
||||||
@@ -4,3 +4,9 @@ plugins {
|
|||||||
id 'com.google.gms.google-services' version '4.4.2' apply false
|
id 'com.google.gms.google-services' version '4.4.2' apply false
|
||||||
id("com.google.firebase.crashlytics") version "3.0.3" apply false
|
id("com.google.firebase.crashlytics") version "3.0.3" apply false
|
||||||
}
|
}
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
Reference in New Issue
Block a user