Skip to content

Commit f0674f0

Browse files
committed
remove media3
1 parent 441b113 commit f0674f0

File tree

7 files changed

+5
-629
lines changed

7 files changed

+5
-629
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Android](https://img.shields.io/badge/Android-15%2B-3DDC84?style=for-the-badge&logo=android&logoColor=white)](https://www.android.com/)
44
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg?style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0)
5-
[![Obtainium](https://img.shields.io/badge/Get%20it%20on-Obtainium-orange?style=for-the-badge)](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22com.kododake.aabrowser%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2Fkododake%2FAABrowser%22%2C%22author%22%3A%22kododake%22%2C%22name%22%3A%22AABrowser%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22includePrereleases%5C%22%3Afalse%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22filterReleaseNotesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22sortMethodChoice%5C%22%3A%5C%22date%5C%22%2C%5C%22useLatestAssetDateAsReleaseDate%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%2C%5C%22trackOnly%5C%22%3Afalse%2C%5C%22versionExtractionRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22matchGroupToUse%5C%22%3A%5C%22%5C%22%2C%5C%22versionDetection%5C%22%3Atrue%2C%5C%22releaseDateAsVersion%5C%22%3Afalse%2C%5C%22useVersionCodeAsOSVersion%5C%22%3Afalse%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22invertAPKFilter%5C%22%3Afalse%2C%5C%22autoApkFilterByArch%5C%22%3Atrue%2C%5C%22appName%5C%22%3A%5C%22%5C%22%2C%5C%22appAuthor%5C%22%3A%5C%22%5C%22%2C%5C%22shizukuPretendToBeGooglePlay%5C%22%3Afalse%2C%5C%22allowInsecure%5C%22%3Afalse%2C%5C%22exemptFromBackgroundUpdates%5C%22%3Afalse%2C%5C%22skipUpdateNotifications%5C%22%3Afalse%2C%5C%22about%5C%22%3A%5C%22%5C%22%2C%5C%22refreshBeforeDownload%5C%22%3Afalse%2C%5C%22includeZips%5C%22%3Afalse%2C%5C%22zippedApkFilterRegEx%5C%22%3A%5C%22%5C%22%7D%22%2C%22overrideSource%22%3Anull%7D)
5+
[![Obtainium](https://github.com/user-attachments/assets/1551eaef-432d-4634-875c-f085870d00a1)](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22com.kododake.aabrowser%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2Fkododake%2FAABrowser%22%2C%22author%22%3A%22kododake%22%2C%22name%22%3A%22AABrowser%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22includePrereleases%5C%22%3Afalse%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22filterReleaseNotesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22sortMethodChoice%5C%22%3A%5C%22date%5C%22%2C%5C%22useLatestAssetDateAsReleaseDate%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%2C%5C%22trackOnly%5C%22%3Afalse%2C%5C%22versionExtractionRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22matchGroupToUse%5C%22%3A%5C%22%5C%22%2C%5C%22versionDetection%5C%22%3Atrue%2C%5C%22releaseDateAsVersion%5C%22%3Afalse%2C%5C%22useVersionCodeAsOSVersion%5C%22%3Afalse%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22invertAPKFilter%5C%22%3Afalse%2C%5C%22autoApkFilterByArch%5C%22%3Atrue%2C%5C%22appName%5C%22%3A%5C%22%5C%22%2C%5C%22appAuthor%5C%22%3A%5C%22%5C%22%2C%5C%22shizukuPretendToBeGooglePlay%5C%22%3Afalse%2C%5C%22allowInsecure%5C%22%3Afalse%2C%5C%22exemptFromBackgroundUpdates%5C%22%3Afalse%2C%5C%22skipUpdateNotifications%5C%22%3Afalse%2C%5C%22about%5C%22%3A%5C%22%5C%22%2C%5C%22refreshBeforeDownload%5C%22%3Afalse%2C%5C%22includeZips%5C%22%3Afalse%2C%5C%22zippedApkFilterRegEx%5C%22%3A%5C%22%5C%22%7D%22%2C%22overrideSource%22%3Anull%7D)
66

77
**The ultimate WebView browser experience for Android Auto head units.**
88
Transform your "parked time" with a sleek, modern browser designed specifically for the road.
@@ -78,8 +78,8 @@ Every contribution makes AA Browser better!
7878
<table>
7979
<tbody>
8080
<tr>
81-
<td align="center" valign="top" width="50%"><a href="https://github.com/kododake"><img src="https://github.com/kododake.png?s=100" width="100px;" alt="kododake"/><br /><sub><b>kododake</b></sub></a><br /><sub>Project Lead & Lead Developer</sub></td>
82-
<td align="center" valign="top" width="50%"><a href="https://github.com/cmacrowther"><img src="https://github.com/cmacrowther.png?s=100" width="100px;" alt="cmacrowther"/><br /><sub><b>Colin Crowther</b></sub></a><br /><sub>Contributed significantly to improving the design and functionality!</sub></td>
81+
<td align="center" valign="top" width="30%"><a href="https://github.com/kododake"><img src="https://github.com/kododake.png?s=100" width="100px;" alt="kododake"/><br /><sub><b>kododake</b></sub></a><br /><sub>Project Lead & Lead Developer</sub></td>
82+
<td align="center" valign="top" width="30%"><a href="https://github.com/cmacrowther"><img src="https://github.com/cmacrowther.png?s=100" width="100px;" alt="cmacrowther"/><br /><sub><b>Colin Crowther</b></sub></a><br /><sub>Contributed significantly to improving the design and functionality!</sub></td>
8383
</tr>
8484
</tbody>
8585
</table>

app/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ android {
1717
applicationId = "com.kododake.aabrowser"
1818
minSdk = 35
1919
targetSdk = 36
20-
versionCode = 4
21-
versionName = "1.4"
20+
versionCode = 5
21+
versionName = "1.5"
2222

2323
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2424
}
@@ -112,8 +112,6 @@ dependencies {
112112
implementation(libs.okhttp)
113113
implementation(libs.kotlinx.serialization.json)
114114
implementation(libs.google.oss.licenses)
115-
implementation(libs.androidx.media3.exoplayer)
116-
implementation(libs.androidx.media3.session)
117115
implementation("com.github.woheller69:FreeDroidWarn:V1.+")
118116

119117
testImplementation(libs.junit)

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
<uses-permission android:name="android.permission.INTERNET" />
66
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
7-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
8-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
97
<uses-permission android:name="androidx.car.app.ACCESS_SURFACE" />
108
<uses-permission android:name="androidx.car.app.MAP_TEMPLATES" />
119

@@ -98,17 +96,6 @@
9896
android:exported="false"
9997
android:theme="@style/Theme.AABrowser" />
10098

101-
<service
102-
android:name=".media.WebMediaSessionService"
103-
android:enabled="true"
104-
android:exported="true"
105-
android:foregroundServiceType="mediaPlayback">
106-
<intent-filter>
107-
<action android:name="androidx.media3.session.MediaSessionService" />
108-
</intent-filter>
109-
</service>
110-
111-
11299
</application>
113100

114101
</manifest>

app/src/main/java/com/kododake/aabrowser/MainActivity.kt

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import com.google.zxing.BarcodeFormat
5050
import com.google.zxing.qrcode.QRCodeWriter
5151
import com.google.zxing.common.BitMatrix
5252
import android.widget.RadioGroup
53-
import com.kododake.aabrowser.media.WebViewMediaSessionBridge
5453
import com.kododake.aabrowser.settings.SettingsViews
5554
import org.woheller69.freeDroidWarn.R as FreeDroidWarnR
5655

@@ -71,41 +70,6 @@ class MainActivity : AppCompatActivity() {
7170
handler.postDelayed(autoHideMenuFab, MENU_BUTTON_AUTO_HIDE_DELAY_MS)
7271
}
7372

74-
private val webStateFetcher = object : Runnable {
75-
override fun run() {
76-
if (isDestroyed || isFinishing) return
77-
webView?.evaluateJavascript("""
78-
(function(){
79-
var medias = document.querySelectorAll('video, audio');
80-
for(var i=0; i<medias.length; i++) {
81-
if(!medias[i].paused && !medias[i].muted) {
82-
var dur = isNaN(medias[i].duration) ? 0 : medias[i].duration;
83-
return medias[i].currentTime + ',' + dur + ',' + medias[i].paused;
84-
}
85-
}
86-
if(medias.length > 0) {
87-
var dur = isNaN(medias[0].duration) ? 0 : medias[0].duration;
88-
return medias[0].currentTime + ',' + dur + ',' + medias[0].paused;
89-
}
90-
return '';
91-
})();
92-
""".trimIndent()) { result ->
93-
if (!result.isNullOrBlank() && result != "\"\"" && result != "null") {
94-
runCatching {
95-
val parts = result.replace("\"", "").split(",")
96-
if (parts.size == 3) {
97-
val current = parts[0].toDouble()
98-
val dur = parts[1].toDouble()
99-
val paused = parts[2].toBoolean()
100-
webViewMediaSessionBridge?.updatePlaybackState(current, dur, paused)
101-
}
102-
}
103-
}
104-
}
105-
handler.postDelayed(this, 1000)
106-
}
107-
}
108-
10973
private var webView: android.webkit.WebView? = null
11074
private var currentUrl: String = BrowserPreferences.defaultUrl()
11175
private var currentPageTitle: String = ""
@@ -114,7 +78,6 @@ class MainActivity : AppCompatActivity() {
11478
private var customView: View? = null
11579
private var customViewCallback: WebChromeClient.CustomViewCallback? = null
11680
private var isShowingCleartextDialog: Boolean = false
117-
private var webViewMediaSessionBridge: WebViewMediaSessionBridge? = null
11881
private var latestReleaseUrl: String = "https://github.com/kododake/AABrowser/releases"
11982
private val umamiTracker: UmamiTracker by lazy { UmamiTracker(applicationContext) }
12083

@@ -136,88 +99,6 @@ class MainActivity : AppCompatActivity() {
13699

137100
setupUi()
138101
setupBackPressHandling()
139-
webViewMediaSessionBridge = WebViewMediaSessionBridge(
140-
context = this,
141-
onPlayRequested = {
142-
runOnUiThread {
143-
webView?.evaluateJavascript("""
144-
(function(){
145-
var medias = document.querySelectorAll('video, audio');
146-
for(var i=0; i<medias.length; i++) medias[i].play();
147-
})();
148-
""".trimIndent(), null)
149-
}
150-
},
151-
onPauseRequested = {
152-
runOnUiThread {
153-
webView?.evaluateJavascript("""
154-
(function(){
155-
var medias = document.querySelectorAll('video, audio');
156-
for(var i=0; i<medias.length; i++) medias[i].pause();
157-
})();
158-
""".trimIndent(), null)
159-
}
160-
},
161-
onSkipForwardRequested = {
162-
runOnUiThread {
163-
webView?.evaluateJavascript("""
164-
(function(){
165-
function clickControl(re) {
166-
var controls = document.querySelectorAll('button, [role="button"], [aria-label], [title], [data-tooltip]');
167-
for (var i = 0; i < controls.length; i++) {
168-
var el = controls[i];
169-
if (!el) continue;
170-
var label = (el.getAttribute('aria-label') || el.getAttribute('title') || el.getAttribute('data-tooltip') || el.textContent || '').toLowerCase();
171-
if (re.test(label)) {
172-
el.click();
173-
return true;
174-
}
175-
}
176-
return false;
177-
}
178-
if (clickControl(/next|next track|skip/)) return;
179-
var medias = document.querySelectorAll('video, audio');
180-
for (var i = 0; i < medias.length; i++) medias[i].currentTime += 10;
181-
})();
182-
""".trimIndent(), null)
183-
}
184-
},
185-
onSkipBackwardRequested = {
186-
runOnUiThread {
187-
webView?.evaluateJavascript("""
188-
(function(){
189-
function clickControl(re) {
190-
var controls = document.querySelectorAll('button, [role="button"], [aria-label], [title], [data-tooltip]');
191-
for (var i = 0; i < controls.length; i++) {
192-
var el = controls[i];
193-
if (!el) continue;
194-
var label = (el.getAttribute('aria-label') || el.getAttribute('title') || el.getAttribute('data-tooltip') || el.textContent || '').toLowerCase();
195-
if (re.test(label)) {
196-
el.click();
197-
return true;
198-
}
199-
}
200-
return false;
201-
}
202-
if (clickControl(/previous|prev|back/)) return;
203-
var medias = document.querySelectorAll('video, audio');
204-
for (var i = 0; i < medias.length; i++) medias[i].currentTime -= 10;
205-
})();
206-
""".trimIndent(), null)
207-
}
208-
},
209-
onSeekRequested = { positionMs ->
210-
runOnUiThread {
211-
webView?.evaluateJavascript("""
212-
(function(){
213-
var medias = document.querySelectorAll('video, audio');
214-
for(var i=0; i<medias.length; i++) medias[i].currentTime = ${positionMs / 1000.0};
215-
})();
216-
""".trimIndent(), null)
217-
}
218-
}
219-
)
220-
webViewMediaSessionBridge?.updateNowPlaying(currentPageTitle, currentUrl)
221102
ensureNotificationPermissionIfNeeded()
222103
showFreeDroidWarnOnUpgradeMaterial()
223104
}
@@ -228,38 +109,23 @@ class MainActivity : AppCompatActivity() {
228109
extractBrowsableUrl(intent)?.let { loadUrlFromIntent(it) }
229110
}
230111

231-
override fun onStart() {
232-
super.onStart()
233-
webViewMediaSessionBridge?.onHostResume()
234-
}
235-
236112
override fun onResume() {
237113
super.onResume()
238-
handler.post(webStateFetcher)
239114
webView?.onResume()
240115
refreshBookmarks()
241116
syncUserAgentProfile()
242117
}
243118

244119
override fun onPause() {
245-
handler.removeCallbacks(webStateFetcher)
246120
exitFullscreen()
247121
webView?.onPause()
248122
super.onPause()
249123
}
250124

251-
override fun onStop() {
252-
webViewMediaSessionBridge?.onHostPause()
253-
super.onStop()
254-
}
255-
256125
override fun onDestroy() {
257-
handler.removeCallbacks(webStateFetcher)
258126
handler.removeCallbacks(autoHideMenuFab)
259127
handler.removeCallbacks(showMenuFabRunnable)
260128
exitFullscreen()
261-
webViewMediaSessionBridge?.release()
262-
webViewMediaSessionBridge = null
263129
binding.webView.releaseCompletely()
264130
webView = null
265131
super.onDestroy()
@@ -335,7 +201,6 @@ class MainActivity : AppCompatActivity() {
335201
binding.addressEdit.setSelection(binding.addressEdit.text?.length ?: 0)
336202
}
337203
BrowserPreferences.persistUrl(this, url)
338-
webViewMediaSessionBridge?.updateNowPlaying(currentPageTitle, currentUrl)
339204
updateNavigationButtons()
340205
updateConnectionSecurityIcon(url)
341206
}
@@ -345,7 +210,6 @@ class MainActivity : AppCompatActivity() {
345210
val resolvedTitle = title.orEmpty()
346211
currentPageTitle = resolvedTitle
347212
binding.pageTitle.text = resolvedTitle
348-
webViewMediaSessionBridge?.updateNowPlaying(currentPageTitle, currentUrl)
349213
}
350214
},
351215
onProgressChange = { progress ->

0 commit comments

Comments
 (0)