Skip to content
Merged
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
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@
<data android:path="/place" />
<data android:queryPrefix="coordinate=" tools:targetApi="35" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name=".SplitscreenShortcut"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:excludeFromRecents="true"
android:taskAffinity=""/>
<service
android:name=".auto.MainService"
android:exported="true">
Expand Down
25 changes: 21 additions & 4 deletions app/src/main/java/be/mygod/reactmap/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class MainActivity : FragmentActivity(), Shizuku.OnRequestPermissionResultListen
const val ACTION_RESTART_GAME = "be.mygod.reactmap.action.RESTART_GAME"
const val ACTION_ACCUWEATHER = "be.mygod.reactmap.action.ACCUWEATHER"
private const val KEY_WELCOME = "welcome"
private const val PACKAGE_POKEMON_GO = "com.nianticlabs.pokemongo"
private const val PACKAGE_POKEMON_GO_ARES = "com.nianticlabs.pokemongo.ares"

private val forceStopPackage by lazy {
Class.forName("android.app.IActivityManager").getDeclaredMethod(
Expand Down Expand Up @@ -99,6 +101,7 @@ class MainActivity : FragmentActivity(), Shizuku.OnRequestPermissionResultListen
Snackbar.make(findViewById(R.id.content), R.string.restart_game_dialog_message,
Snackbar.LENGTH_LONG).show()
}
"be.mygod.reactmap.action.SPLITSCREEN" -> pendingSplitscreen = true
Intent.ACTION_VIEW -> {
Timber.d("Handling URI ${intent.data}")
if (currentFragment?.handleUri(intent.data) != true) pendingOverrideUri = intent.data
Expand All @@ -121,14 +124,28 @@ class MainActivity : FragmentActivity(), Shizuku.OnRequestPermissionResultListen
setPadding(padding, 0, padding, 0)
}
setView(switch)
setPositiveButton(R.string.restart_game_standard) { _, _ ->
restartGame("com.nianticlabs.pokemongo", switch.isChecked)
}
setPositiveButton(R.string.restart_game_standard) { _, _ -> restartGame(PACKAGE_POKEMON_GO, switch.isChecked) }
setNegativeButton(R.string.restart_game_samsung) { _, _ ->
restartGame("com.nianticlabs.pokemongo.ares", switch.isChecked)
restartGame(PACKAGE_POKEMON_GO_ARES, switch.isChecked)
}
setNeutralButton(android.R.string.cancel, null)
}.show()
private var pendingSplitscreen = false
override fun onEnterAnimationComplete() {
if (!pendingSplitscreen) return
startActivity(listOf(PACKAGE_POKEMON_GO, PACKAGE_POKEMON_GO_ARES)
.mapNotNull(app.packageManager::getLaunchIntentForPackage).let { list ->
when (list.size) {
0 -> Intent(Intent.ACTION_CHOOSER).putExtra(Intent.EXTRA_INTENT, Intent())
1 -> list.first()
else -> Intent(Intent.ACTION_CHOOSER).apply {
putExtra(Intent.EXTRA_INTENT, list.first())
putExtra(Intent.EXTRA_ALTERNATE_INTENTS, list.drop(1).toTypedArray())
}
}
}.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT))
pendingSplitscreen = false
}

override fun onRequestPermissionResult(requestCode: Int, grantResult: Int) {
if (grantResult != PackageManager.PERMISSION_GRANTED) {
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/be/mygod/reactmap/SplitscreenShortcut.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package be.mygod.reactmap

import android.app.Activity
import android.content.Intent
import android.os.Bundle

class SplitscreenShortcut : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// https://developer.android.com/develop/ui/views/launch/shortcuts/managing-shortcuts#start-one
startActivity(Intent(this, MainActivity::class.java).setAction(intent.action))
finish()
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_device_splitscreen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="@color/main_orange" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M18,4v5H6V4H18M18,2H6C4.9,2 4,2.9 4,4v5c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4C20,2.9 19.1,2 18,2zM18,15v5H6v-5H18M18,13H6c-1.1,0 -2,0.9 -2,2v5c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2v-5C20,13.9 19.1,13 18,13z"/>

</vector>
21 changes: 21 additions & 0 deletions app/src/main/res/drawable/ic_shortcut_splitscreen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp">
<shape
android:shape="oval">
<solid android:color="@color/material_grey_100" />
<size android:width="44dp" android:height="44dp" />
</shape>
</item>

<item
android:drawable="@drawable/ic_device_splitscreen"
android:left="12dp"
android:top="12dp"
android:right="12dp"
android:bottom="12dp" />
</layer-list>
2 changes: 2 additions & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@
<string name="error_webhook_human_not_found">Użytkownik nieznaleziony - brak dostępu do powiadomień</string>

<string name="pip_phone_enter_split">Włącz podzielony ekran</string>
<string name="shortcut_splitscreen_short">Podzielony ekran</string>
<string name="shortcut_splitscreen_long">Podziel ekran z grą</string>
<string name="web_refresh">Odśwież</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<string name="error_webhook_human_not_found">Human not found</string>

<string name="pip_phone_enter_split">Enter split screen</string>
<string name="shortcut_splitscreen_short">Split screen</string>
<string name="shortcut_splitscreen_long">Start split screen with game</string>
<string name="web_refresh">Refresh</string>

<string name="car_agreement_template"><big><b>Terms of Use</b></big>\nBy using %s (“the Map”) on your vehicle, you
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="splitScreen"
android:enabled="true"
android:icon="@drawable/ic_shortcut_splitscreen"
android:shortcutShortLabel="@string/shortcut_splitscreen_short"
android:shortcutLongLabel="@string/shortcut_splitscreen_long">
<intent
android:action="be.mygod.reactmap.action.SPLITSCREEN"
android:targetPackage="be.mygod.reactmap"
android:targetClass="be.mygod.reactmap.SplitscreenShortcut" />
</shortcut>
</shortcuts>