Merge pull request #1362 from falih-mulyana/feature/text-selection-action

Feature/text selection action
This commit is contained in:
Suji Yan 2020-09-14 22:19:54 +08:00 committed by GitHub
commit b473d9d6d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -72,7 +72,7 @@ PayPal: http://paypal.me/yisiliu2
AliPay: `String.format("%s@%s", "mariotaku.lee", "gmail.com");` AliPay: `String.format("%s@%s", "mariotaku.lee", "gmail.com");`
Bitcoin: `1FHAVAzge7cj1LfCTMfnLL49DgA3mVUCuW` Bitcoin: `3CzmxZa6jseNCYVvM2phs3jmiqNgVBwD7P`
Ethereum & ERC20 Tokens: `0x6ff82FC45aff81D4081DA7B257fb8ee5F71A2CeC` Ethereum & ERC20 Tokens: `0x6ff82FC45aff81D4081DA7B257fb8ee5F71A2CeC`

View File

@ -249,6 +249,13 @@
<data android:mimeType="image/*"/> <data android:mimeType="image/*"/>
<data android:mimeType="text/plain"/> <data android:mimeType="text/plain"/>
</intent-filter> </intent-filter>
<intent-filter android:label="@string/title_compose">
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"

View File

@ -32,6 +32,7 @@ import android.graphics.Canvas
import android.graphics.Rect import android.graphics.Rect
import android.location.* import android.location.*
import android.net.Uri import android.net.Uri
import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.widget.TextViewCompat import androidx.core.widget.TextViewCompat
@ -1145,6 +1146,12 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
} else { } else {
editText.setSelection(selection.coerceIn(0..editText.length())) editText.setSelection(selection.coerceIn(0..editText.length()))
} }
if (intent.hasExtra(Intent.EXTRA_PROCESS_TEXT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
val charSequences = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT)
charSequences?.let {
editText.setText(it.toString())
}
}
editText.requestFocus() editText.requestFocus()
return true return true
} }