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
26 changes: 13 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="to.dev.dev_android">
xmlns:tools="http://schemas.android.com/tools"
package="to.dev.dev_android">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:fullBackupContent="true"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute"
>
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
<activity
android:name=".view.main.view.MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</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"/>
<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="dev.to"
/>
android:scheme="https" />
</intent-filter>
</activity>
</application>
Expand Down
32 changes: 16 additions & 16 deletions app/src/main/java/to/dev/dev_android/view/main/view/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.net.Uri
import android.os.Bundle
import android.view.View
import android.webkit.ValueCallback
import androidx.core.app.ActivityCompat
import to.dev.dev_android.R
import to.dev.dev_android.base.BuildConfig
import to.dev.dev_android.base.activity.BaseActivity
Expand All @@ -17,7 +16,7 @@ import to.dev.dev_android.util.AndroidWebViewBridge
class MainActivity : BaseActivity<ActivityMainBinding>(), CustomWebChromeClient.CustomListener {
private val webViewBridge: AndroidWebViewBridge = AndroidWebViewBridge()

private var mFilePathCallback: ValueCallback<Array<Uri>>? = null
private var filePathCallback: ValueCallback<Array<Uri>>? = null

override fun layout(): Int {
return R.layout.activity_main
Expand Down Expand Up @@ -75,16 +74,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), CustomWebChromeClient.
}

override fun launchGallery(filePathCallback: ValueCallback<Array<Uri>>?) {
mFilePathCallback = filePathCallback
this.filePathCallback = filePathCallback

val galleryIntent = Intent()
// Show only images, no videos or anything else
galleryIntent.type = "image/*"
galleryIntent.action = Intent.ACTION_PICK
val galleryIntent = Intent().apply {
// Show only images, no videos or anything else
type = "image/*"
action = Intent.ACTION_PICK
}

// Always show the chooser (if there are multiple options available)
ActivityCompat.startActivityForResult(
this,
startActivityForResult(
Intent.createChooser(galleryIntent, "Select Picture"),
PIC_CHOOSER_REQUEST,
null // No additional data
Expand All @@ -96,14 +95,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), CustomWebChromeClient.
return super.onActivityResult(requestCode, resultCode, data)
}

if (resultCode == Activity.RESULT_OK) {
if (data != null) {
mFilePathCallback?.onReceiveValue(arrayOf(data.data))
mFilePathCallback = null
when (resultCode) {
Activity.RESULT_OK -> data?.data?.let {
filePathCallback?.onReceiveValue(arrayOf(it))
filePathCallback = null
}
Activity.RESULT_CANCELED -> {
filePathCallback?.onReceiveValue(null)
filePathCallback = null
}
} else if (resultCode == Activity.RESULT_CANCELED) {
mFilePathCallback?.onReceiveValue(null)
mFilePathCallback = null
}
}

Expand Down