add an option for showing character counter at sending messages

This commit is contained in:
tibbi 2020-11-04 12:36:02 +01:00
parent 87e1be8e1b
commit 82f78f002e
6 changed files with 65 additions and 5 deletions

View File

@ -34,6 +34,7 @@ class SettingsActivity : SimpleActivity() {
setupManageBlockedNumbers()
setupChangeDateTimeFormat()
setupFontSize()
setupShowCharacterCounter()
updateTextColors(settings_scrollview)
if (blockedNumbersAtPause != -1 && blockedNumbersAtPause != getBlockedNumbers().hashCode()) {
@ -106,4 +107,12 @@ class SettingsActivity : SimpleActivity() {
}
}
}
private fun setupShowCharacterCounter() {
settings_show_character_counter.isChecked = config.showCharacterCounter
settings_show_character_counter_holder.setOnClickListener {
settings_show_character_counter.toggle()
config.showCharacterCounter = settings_show_character_counter.isChecked
}
}
}

View File

@ -263,6 +263,7 @@ class ThreadActivity : SimpleActivity() {
thread_send_message.applyColorFilter(textColor)
confirm_manage_contacts.applyColorFilter(textColor)
thread_add_attachment.applyColorFilter(textColor)
thread_character_counter.beVisibleIf(config.showCharacterCounter)
thread_send_message.setOnClickListener {
sendMessage()
@ -271,6 +272,7 @@ class ThreadActivity : SimpleActivity() {
thread_send_message.isClickable = false
thread_type_message.onTextChangeListener {
checkSendMessageAvailability()
thread_character_counter.text = it.length.toString()
}
confirm_manage_contacts.setOnClickListener {

View File

@ -13,4 +13,8 @@ class Config(context: Context) : BaseConfig(context) {
}
fun getUseSIMIdAtNumber(number: String) = prefs.getInt(USE_SIM_ID_PREFIX + number, 0)
var showCharacterCounter: Boolean
get() = prefs.getBoolean(SHOW_CHARACTER_COUNTER, false)
set(showCharacterCounter) = prefs.edit().putBoolean(SHOW_CHARACTER_COUNTER, showCharacterCounter).apply()
}

View File

@ -11,6 +11,7 @@ const val THREAD_ATTACHMENT_URI = "thread_attachment_uri"
const val THREAD_ATTACHMENT_URIS = "thread_attachment_uris"
const val USE_SIM_ID_PREFIX = "use_sim_id_"
const val NOTIFICATION_CHANNEL = "simple_sms_messenger"
const val SHOW_CHARACTER_COUNTER = "show_character_counter"
private const val PATH = "com.simplemobiletools.smsmessenger.action."
const val MARK_AS_READ = PATH + "mark_as_read"

View File

@ -149,5 +149,28 @@
android:clickable="false" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_show_character_counter_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_show_character_counter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:text="@string/show_character_counter"
app:switchPadding="@dimen/medium_margin" />
</RelativeLayout>
</LinearLayout>
</ScrollView>

View File

@ -66,6 +66,7 @@
android:layout_marginStart="@dimen/medium_margin"
android:layout_marginEnd="@dimen/medium_margin"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/confirm_selection"
android:paddingStart="@dimen/medium_margin"
android:paddingEnd="@dimen/medium_margin"
android:src="@drawable/ic_check_vector"
@ -125,6 +126,7 @@
android:layout_marginEnd="@dimen/small_margin"
android:alpha="0.9"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/attachment"
android:padding="@dimen/normal_margin"
android:src="@drawable/ic_plus_vector" />
@ -166,14 +168,17 @@
<ImageView
android:id="@+id/thread_select_sim_icon"
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="@dimen/small_margin"
android:layout_toStartOf="@+id/thread_send_message"
android:layout_toStartOf="@+id/thread_character_counter"
android:alpha="0.9"
android:background="?selectableItemBackgroundBorderless"
android:padding="@dimen/normal_margin"
android:background="?attr/selectableItemBackgroundBorderless"
android:paddingStart="@dimen/medium_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/medium_margin"
android:paddingBottom="@dimen/normal_margin"
android:src="@drawable/ic_sim_vector"
android:visibility="gone" />
@ -190,6 +195,21 @@
android:visibility="gone"
tools:text="1" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/thread_character_counter"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignTop="@+id/thread_send_message"
android:layout_alignBottom="@+id/thread_send_message"
android:layout_toStartOf="@+id/thread_send_message"
android:gravity="center"
android:paddingStart="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
android:text="0"
android:textSize="@dimen/normal_text_size"
android:visibility="gone"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/thread_send_message"
android:layout_width="@dimen/normal_icon_size"
@ -201,6 +221,7 @@
android:alpha="0.4"
android:background="?selectableItemBackgroundBorderless"
android:clickable="false"
android:contentDescription="@string/ok"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_send_vector" />