mirror of
				https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
				synced 2025-06-05 21:49:22 +02:00 
			
		
		
		
	use the new way of launching activity intents
This commit is contained in:
		| @@ -543,7 +543,7 @@ class ThreadActivity : SimpleActivity() { | |||||||
|         var hadUnreadItems = false |         var hadUnreadItems = false | ||||||
|         val cnt = messages.size |         val cnt = messages.size | ||||||
|         for (i in 0 until cnt) { |         for (i in 0 until cnt) { | ||||||
|             val message = messages[i] |             val message = messages.getOrNull(i) ?: continue | ||||||
|             // do not show the date/time above every message, only if the difference between the 2 messages is at least MIN_DATE_TIME_DIFF_SECS |             // do not show the date/time above every message, only if the difference between the 2 messages is at least MIN_DATE_TIME_DIFF_SECS | ||||||
|             if (message.date - prevDateTime > MIN_DATE_TIME_DIFF_SECS) { |             if (message.date - prevDateTime > MIN_DATE_TIME_DIFF_SECS) { | ||||||
|                 val simCardID = subscriptionIdToSimId[message.subscriptionId] ?: "?" |                 val simCardID = subscriptionIdToSimId[message.subscriptionId] ?: "?" | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| package com.simplemobiletools.smsmessenger.adapters | package com.simplemobiletools.smsmessenger.adapters | ||||||
|  |  | ||||||
|  | import android.content.ActivityNotFoundException | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
| import android.graphics.Typeface | import android.graphics.Typeface | ||||||
| import android.net.Uri | import android.net.Uri | ||||||
| @@ -26,8 +27,10 @@ import com.simplemobiletools.smsmessenger.helpers.refreshMessages | |||||||
| import com.simplemobiletools.smsmessenger.models.Conversation | import com.simplemobiletools.smsmessenger.models.Conversation | ||||||
| import kotlinx.android.synthetic.main.item_conversation.view.* | import kotlinx.android.synthetic.main.item_conversation.view.* | ||||||
|  |  | ||||||
| class ConversationsAdapter(activity: SimpleActivity, var conversations: ArrayList<Conversation>, recyclerView: MyRecyclerView, fastScroller: FastScroller, | class ConversationsAdapter( | ||||||
|                            itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { |     activity: SimpleActivity, var conversations: ArrayList<Conversation>, recyclerView: MyRecyclerView, fastScroller: FastScroller, | ||||||
|  |     itemClick: (Any) -> Unit | ||||||
|  | ) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { | ||||||
|     private var fontSize = activity.getTextSize() |     private var fontSize = activity.getTextSize() | ||||||
|  |  | ||||||
|     init { |     init { | ||||||
| @@ -120,11 +123,13 @@ class ConversationsAdapter(activity: SimpleActivity, var conversations: ArrayLis | |||||||
|         Intent(Intent.ACTION_DIAL).apply { |         Intent(Intent.ACTION_DIAL).apply { | ||||||
|             data = Uri.fromParts("tel", conversation.phoneNumber, null) |             data = Uri.fromParts("tel", conversation.phoneNumber, null) | ||||||
|  |  | ||||||
|             if (resolveActivity(activity.packageManager) != null) { |             try { | ||||||
|                 activity.startActivity(this) |                 activity.startActivity(this) | ||||||
|                 finishActMode() |                 finishActMode() | ||||||
|             } else { |             } catch (e: ActivityNotFoundException) { | ||||||
|                 activity.toast(R.string.no_app_found) |                 activity.toast(R.string.no_app_found) | ||||||
|  |             } catch (e: Exception) { | ||||||
|  |                 activity.showErrorToast(e) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -185,12 +190,7 @@ class ConversationsAdapter(activity: SimpleActivity, var conversations: ArrayLis | |||||||
|             action = Intent.ACTION_INSERT_OR_EDIT |             action = Intent.ACTION_INSERT_OR_EDIT | ||||||
|             type = "vnd.android.cursor.item/contact" |             type = "vnd.android.cursor.item/contact" | ||||||
|             putExtra(KEY_PHONE, conversation.phoneNumber) |             putExtra(KEY_PHONE, conversation.phoneNumber) | ||||||
|  |             activity.launchActivityIntent(this) | ||||||
|             if (resolveActivity(activity.packageManager) != null) { |  | ||||||
|                 activity.startActivity(this) |  | ||||||
|             } else { |  | ||||||
|                 activity.toast(R.string.no_app_found) |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.simplemobiletools.smsmessenger.adapters | package com.simplemobiletools.smsmessenger.adapters | ||||||
|  |  | ||||||
| import android.annotation.SuppressLint | import android.annotation.SuppressLint | ||||||
|  | import android.content.ActivityNotFoundException | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
| import android.graphics.drawable.Drawable | import android.graphics.drawable.Drawable | ||||||
| import android.net.Uri | import android.net.Uri | ||||||
| @@ -315,15 +316,17 @@ class ThreadAdapter( | |||||||
|             setDataAndType(uri, mimetype) |             setDataAndType(uri, mimetype) | ||||||
|             addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) |             addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | ||||||
|  |  | ||||||
|             if (resolveActivity(activity.packageManager) != null) { |             try { | ||||||
|                 activity.startActivity(this) |                 activity.startActivity(this) | ||||||
|             } else { |             } catch (e: ActivityNotFoundException) { | ||||||
|                 val newMimetype = filename.getMimeType() |                 val newMimetype = filename.getMimeType() | ||||||
|                 if (newMimetype.isNotEmpty() && mimetype != newMimetype) { |                 if (newMimetype.isNotEmpty() && mimetype != newMimetype) { | ||||||
|                     launchViewIntent(uri, newMimetype, filename) |                     launchViewIntent(uri, newMimetype, filename) | ||||||
|                 } else { |                 } else { | ||||||
|                     activity.toast(R.string.no_app_found) |                     activity.toast(R.string.no_app_found) | ||||||
|                 } |                 } | ||||||
|  |             } catch (e: Exception) { | ||||||
|  |                 activity.showErrorToast(e) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user