Merge pull request #388 from Naveen3Singh/exceptions

Show longer toast errors
This commit is contained in:
Tibor Kaputa
2022-07-17 08:24:24 +02:00
committed by GitHub
2 changed files with 7 additions and 7 deletions

View File

@@ -23,7 +23,6 @@ import android.view.inputmethod.EditorInfo
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.LinearLayout.LayoutParams import android.widget.LinearLayout.LayoutParams
import android.widget.RelativeLayout import android.widget.RelativeLayout
import android.widget.Toast
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
@@ -742,7 +741,7 @@ class ThreadActivity : SimpleActivity() {
try { try {
startActivityForResult(this, PICK_ATTACHMENT_INTENT) startActivityForResult(this, PICK_ATTACHMENT_INTENT)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
toast(R.string.no_app_found) showErrorToast(getString(R.string.no_app_found))
} catch (e: Exception) { } catch (e: Exception) {
showErrorToast(e) showErrorToast(e)
} }
@@ -847,6 +846,7 @@ class ThreadActivity : SimpleActivity() {
private fun sendMessage() { private fun sendMessage() {
var msg = thread_type_message.value var msg = thread_type_message.value
if (msg.isEmpty() && attachmentSelections.isEmpty()) { if (msg.isEmpty() && attachmentSelections.isEmpty()) {
showErrorToast(getString(R.string.unknown_error_occurred))
return return
} }
@@ -880,7 +880,7 @@ class ThreadActivity : SimpleActivity() {
} catch (e: Exception) { } catch (e: Exception) {
showErrorToast(e) showErrorToast(e)
} catch (e: Error) { } catch (e: Error) {
toast(e.localizedMessage ?: getString(R.string.unknown_error_occurred)) showErrorToast(e.localizedMessage ?: getString(R.string.unknown_error_occurred))
} }
} }
} }
@@ -905,7 +905,7 @@ class ThreadActivity : SimpleActivity() {
} catch (e: Exception) { } catch (e: Exception) {
showErrorToast(e) showErrorToast(e)
} catch (e: Error) { } catch (e: Error) {
toast(e.localizedMessage ?: getString(R.string.unknown_error_occurred)) showErrorToast(e.localizedMessage ?: getString(R.string.unknown_error_occurred))
} }
} }
@@ -1009,7 +1009,7 @@ class ThreadActivity : SimpleActivity() {
action = Intent.ACTION_VIEW action = Intent.ACTION_VIEW
putExtra(CONTACT_ID, contact.rawId) putExtra(CONTACT_ID, contact.rawId)
putExtra(IS_PRIVATE, true) putExtra(IS_PRIVATE, true)
`package` = if (isPackageInstalled(simpleContacts)) simpleContacts else simpleContactsDebug setPackage(if (isPackageInstalled(simpleContacts)) simpleContacts else simpleContactsDebug)
setDataAndType(ContactsContract.Contacts.CONTENT_LOOKUP_URI, "vnd.android.cursor.dir/person") setDataAndType(ContactsContract.Contacts.CONTENT_LOOKUP_URI, "vnd.android.cursor.dir/person")
launchActivityIntent(this) launchActivityIntent(this)
} }
@@ -1035,7 +1035,7 @@ class ThreadActivity : SimpleActivity() {
try { try {
startActivityForResult(this, PICK_SAVE_FILE_INTENT) startActivityForResult(this, PICK_SAVE_FILE_INTENT)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
toast(R.string.system_service_disabled, Toast.LENGTH_LONG) showErrorToast(getString(R.string.system_service_disabled))
} catch (e: Exception) { } catch (e: Exception) {
showErrorToast(e) showErrorToast(e)
} }

View File

@@ -225,7 +225,7 @@
android:visibility="gone" android:visibility="gone"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<Button <com.simplemobiletools.commons.views.MyButton
android:id="@+id/thread_send_message" android:id="@+id/thread_send_message"
android:layout_width="@dimen/normal_icon_size" android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size" android:layout_height="@dimen/normal_icon_size"