updating commons, kotlin + add some keyboard hiding

This commit is contained in:
tibbi 2022-02-05 21:07:43 +01:00
parent 54e02171f5
commit 8336ec0052
8 changed files with 13 additions and 17 deletions

View File

@ -62,7 +62,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:14033f9b50' implementation 'com.github.SimpleMobileTools:Simple-Commons:4d36cc84e9'
implementation 'org.greenrobot:eventbus:3.2.0' implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.klinkerapps:android-smsmms:5.2.6' implementation 'com.klinkerapps:android-smsmms:5.2.6'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61' implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'

View File

@ -263,6 +263,7 @@ class MainActivity : SimpleActivity() {
val currAdapter = conversations_list.adapter val currAdapter = conversations_list.adapter
if (currAdapter == null) { if (currAdapter == null) {
hideKeyboard()
ConversationsAdapter(this, sortedConversations, conversations_list) { ConversationsAdapter(this, sortedConversations, conversations_list) {
Intent(this, ThreadActivity::class.java).apply { Intent(this, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, (it as Conversation).threadId) putExtra(THREAD_ID, (it as Conversation).threadId)
@ -291,6 +292,7 @@ class MainActivity : SimpleActivity() {
} }
private fun launchNewConversation() { private fun launchNewConversation() {
hideKeyboard()
Intent(this, NewConversationActivity::class.java).apply { Intent(this, NewConversationActivity::class.java).apply {
startActivity(this) startActivity(this)
} }
@ -329,10 +331,12 @@ class MainActivity : SimpleActivity() {
} }
private fun launchSearch() { private fun launchSearch() {
hideKeyboard()
startActivity(Intent(applicationContext, SearchActivity::class.java)) startActivity(Intent(applicationContext, SearchActivity::class.java))
} }
private fun launchSettings() { private fun launchSettings() {
hideKeyboard()
startActivity(Intent(applicationContext, SettingsActivity::class.java)) startActivity(Intent(applicationContext, SettingsActivity::class.java))
} }

View File

@ -217,6 +217,7 @@ class NewConversationActivity : SimpleActivity() {
} }
private fun launchThreadActivity(phoneNumber: String, name: String) { private fun launchThreadActivity(phoneNumber: String, name: String) {
hideKeyboard()
val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: "" val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: ""
val numbers = phoneNumber.split(";").toSet() val numbers = phoneNumber.split(";").toSet()
val number = if (numbers.size == 1) phoneNumber else Gson().toJson(numbers) val number = if (numbers.size == 1) phoneNumber else Gson().toJson(numbers)

View File

@ -129,6 +129,7 @@ class SearchActivity : SimpleActivity() {
val currAdapter = search_results_list.adapter val currAdapter = search_results_list.adapter
if (currAdapter == null) { if (currAdapter == null) {
SearchResultsAdapter(this, searchResults, search_results_list, searchedText) { SearchResultsAdapter(this, searchResults, search_results_list, searchedText) {
hideKeyboard()
Intent(this, ThreadActivity::class.java).apply { Intent(this, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, (it as SearchResult).threadId) putExtra(THREAD_ID, (it as SearchResult).threadId)
putExtra(THREAD_TITLE, it.title) putExtra(THREAD_TITLE, it.title)

View File

@ -198,6 +198,7 @@ class ThreadActivity : SimpleActivity() {
} }
private fun onHomePressed() { private fun onHomePressed() {
hideKeyboard()
Intent(this, MainActivity::class.java).apply { Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(this) startActivity(this)
@ -376,6 +377,7 @@ class ThreadActivity : SimpleActivity() {
val newThreadId = getThreadId(numbers) val newThreadId = getThreadId(numbers)
if (threadId != newThreadId) { if (threadId != newThreadId) {
hideKeyboard()
Intent(this, ThreadActivity::class.java).apply { Intent(this, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, newThreadId) putExtra(THREAD_ID, newThreadId)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
@ -645,6 +647,7 @@ class ThreadActivity : SimpleActivity() {
} }
private fun launchPickPhotoVideoIntent() { private fun launchPickPhotoVideoIntent() {
hideKeyboard()
val mimeTypes = arrayOf("image/*", "video/*") val mimeTypes = arrayOf("image/*", "video/*")
Intent(Intent.ACTION_GET_CONTENT).apply { Intent(Intent.ACTION_GET_CONTENT).apply {
addCategory(Intent.CATEGORY_OPENABLE) addCategory(Intent.CATEGORY_OPENABLE)
@ -925,6 +928,7 @@ class ThreadActivity : SimpleActivity() {
} }
fun saveMMS(mimeType: String, path: String) { fun saveMMS(mimeType: String, path: String) {
hideKeyboard()
lastAttachmentUri = path lastAttachmentUri = path
Intent(Intent.ACTION_CREATE_DOCUMENT).apply { Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
type = mimeType type = mimeType

View File

@ -375,6 +375,7 @@ class ThreadAdapter(
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
try { try {
activity.hideKeyboard()
activity.startActivity(this) activity.startActivity(this)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
val newMimetype = filename.getMimeType() val newMimetype = filename.getMimeType()

View File

@ -938,18 +938,3 @@ fun Context.getFileSizeFromUri(uri: Uri): Long {
return FILE_SIZE_NONE return FILE_SIZE_NONE
} }
} }
fun Context.dialNumber(phoneNumber: String, callback: (() -> Unit)? = null) {
Intent(Intent.ACTION_DIAL).apply {
data = Uri.fromParts("tel", phoneNumber, null)
try {
startActivity(this)
callback?.invoke()
} catch (e: ActivityNotFoundException) {
toast(R.string.no_app_found)
} catch (e: Exception) {
showErrorToast(e)
}
}
}

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.6.0' ext.kotlin_version = '1.6.10'
repositories { repositories {
google() google()
jcenter() jcenter()