WebView User Agent Updated

This commit is contained in:
Shabinder 2020-11-04 20:29:48 +05:30
parent 86062f405c
commit 172c8d1f55
4 changed files with 12 additions and 19 deletions

View File

@ -35,8 +35,8 @@ android {
applicationId 'com.shabinder.spotiflyer'
minSdkVersion 22
targetSdkVersion 29
versionCode 6
versionName "1.5"
versionCode 7
versionName "1.5.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
packagingOptions {

View File

@ -45,12 +45,10 @@ import kotlinx.coroutines.launch
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import javax.inject.Inject
@Suppress("DEPRECATION")
@AndroidEntryPoint
class MainActivity : AppCompatActivity(){
@ -134,17 +132,13 @@ class MainActivity : AppCompatActivity(){
* */
private fun implementSpotifyService(token: String) {
val httpClient: OkHttpClient.Builder = OkHttpClient.Builder()
httpClient.addInterceptor(object : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
httpClient.addInterceptor(Interceptor { chain ->
val request: Request =
chain.request().newBuilder().addHeader(
"Authorization",
"Bearer $token"
).build()
return chain.proceed(request)
}
chain.proceed(request)
})
val retrofit = Retrofit.Builder()

View File

@ -258,14 +258,13 @@ object SpotifyDownloadHelper {
@SuppressLint("SetJavaScriptEnabled")
fun applyWebViewSettings(webView: WebView) {
val desktopUserAgent =
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0"
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0"
val mobileUserAgent =
"Mozilla/5.0 (Linux; U; Android 4.4; en-us; Nexus 4 Build/JOP24G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
//Choose Mobile/Desktop client.
webView.settings.userAgentString = desktopUserAgent
webView.settings.loadWithOverviewMode = true
webView.settings.loadWithOverviewMode = true
webView.settings.builtInZoomControls = true
webView.settings.setSupportZoom(true)
webView.isScrollbarFadingEnabled = false

View File

@ -18,8 +18,8 @@
<AppUpdater>
<update>
<latestVersion>1.5</latestVersion>
<latestVersionCode>6</latestVersionCode>
<latestVersion>1.5.1</latestVersion>
<latestVersionCode>7</latestVersionCode>
<url>https://github.com/Shabinder/SpotiFlyer/releases/download/1.5/SpotiFlyer-v1.5.apk</url>
</update>
</AppUpdater>