Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for crash on Samsung Clipboard ListView on Android 8.X #795

Merged
merged 3 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 13 additions & 1 deletion aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import android.view.WindowManager
import android.view.inputmethod.BaseInputConnection
import android.widget.CheckBox
import android.widget.EditText
import android.widget.Toast
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
Expand Down Expand Up @@ -1400,7 +1401,18 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
deleteInlineStyleFromTheBeginning()
}
}
else -> return super.onTextContextMenuItem(id)
// Fix for crash when pasting text on Samsung Devices running Android 8.
// Ref: https://github.com/wordpress-mobile/WordPress-Android/issues/8827
16908904,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value on my device : Samsung SM-T585 Android 8.1 is different -> 16908872.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.... 16908874 --> was from Android 8, and 16908904 from Android 9. I just added it since don't know if 8.X will get the latest version of their clipboard.

I guess i can add your other value to the list, but it's like going per-case. Anyway don't have better idea, since the src code of their clipboard isn't available.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniloercoli let me try something, and if doesn't work I will give the Approve so that we can move on.

16908874 -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Build.VERSION.SDK_INT < 28
&& Build.MANUFACTURER.toLowerCase().equals("samsung")) {
// Nope return true
Toast.makeText(context, R.string.samsung_disabled_custom_clipboard, Toast.LENGTH_LONG).show()
} else {
return super.onTextContextMenuItem(id)
}
} else -> return super.onTextContextMenuItem(id)
}

return true
Expand Down
1 change: 1 addition & 0 deletions aztec/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<!-- GENERAL -->
<string name="cursor_moved">Cursor moved</string>
<string name="samsung_disabled_custom_clipboard">Sorry, this feature is disabled on Android 8. Please use the Paste action instead.</string>

<!-- LINK DIALOG -->
<string name="link_dialog_title">Insert link</string>
Expand Down