removing Speed Dial related things

This commit is contained in:
tibbi 2020-05-23 20:19:47 +02:00
parent 6158b2d095
commit a38e5ac68b
7 changed files with 0 additions and 230 deletions

View file

@ -230,11 +230,6 @@
android:label="@string/blocked_numbers"
android:parentActivityName=".activities.SettingsActivity"/>
<activity
android:name=".activities.ManageSpeedDialActivity"
android:label="@string/speed_dial"
android:parentActivityName=".activities.SettingsActivity"/>
<activity
android:name=".activities.DialpadActivity"
android:label="@string/dialpad"

View file

@ -1,68 +0,0 @@
package com.simplemobiletools.contacts.pro.activities
import android.os.Bundle
import com.google.gson.Gson
import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.adapters.SpeedDialAdapter
import com.simplemobiletools.contacts.pro.dialogs.SelectContactsDialog
import com.simplemobiletools.contacts.pro.extensions.config
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
import com.simplemobiletools.contacts.pro.interfaces.RemoveSpeedDialListener
import com.simplemobiletools.contacts.pro.models.Contact
import com.simplemobiletools.contacts.pro.models.SpeedDial
import kotlinx.android.synthetic.main.activity_manage_speed_dial.*
class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
private var allContacts = ArrayList<Contact>()
private var speedDialValues = ArrayList<SpeedDial>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_manage_speed_dial)
speedDialValues = config.getSpeedDialValues()
updateAdapter()
ContactsHelper(this).getContacts { contacts ->
allContacts = contacts
}
updateTextColors(manage_speed_dial_scrollview)
}
override fun onStop() {
super.onStop()
config.speedDial = Gson().toJson(speedDialValues)
}
private fun updateAdapter() {
SpeedDialAdapter(this, speedDialValues, this, speed_dial_list) {
val clickedContact = it as SpeedDial
if (allContacts.isEmpty()) {
return@SpeedDialAdapter
}
SelectContactsDialog(this, allContacts, false, true) { addedContacts, removedContacts ->
val selectedContact = addedContacts.first()
speedDialValues.first { it.id == clickedContact.id }.apply {
displayName = selectedContact.getNameToDisplay()
number = selectedContact.phoneNumbers.first().value
}
updateAdapter()
}
}.apply {
speed_dial_list.adapter = this
}
}
override fun removeSpeedDial(ids: ArrayList<Int>) {
ids.forEach {
val dialId = it
speedDialValues.first { it.id == dialId }.apply {
displayName = ""
number = ""
}
}
updateAdapter()
}
}

View file

@ -35,7 +35,6 @@ class SettingsActivity : SimpleActivity() {
setupManageShownContactFields()
setupManageShownTabs()
setupManageBlockedNumbers()
setupManageSpeedDial()
setupFontSize()
setupUseEnglish()
setupShowContactThumbnails()
@ -83,12 +82,6 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupManageSpeedDial() {
settings_manage_speed_dial_holder.setOnClickListener {
startActivity(Intent(this, ManageSpeedDialActivity::class.java))
}
}
private fun setupFontSize() {
settings_font_size.text = getFontSizeText()
settings_font_size_holder.setOnClickListener {

View file

@ -1,80 +0,0 @@
package com.simplemobiletools.contacts.pro.adapters
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import com.simplemobiletools.contacts.pro.interfaces.RemoveSpeedDialListener
import com.simplemobiletools.contacts.pro.models.SpeedDial
import kotlinx.android.synthetic.main.item_speed_dial.view.*
import java.util.*
class SpeedDialAdapter(activity: SimpleActivity, var speedDialValues: ArrayList<SpeedDial>, private val removeListener: RemoveSpeedDialListener,
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
init {
setupDragListener(true)
}
override fun getActionMenuId() = R.menu.cab_delete_only
override fun prepareActionMode(menu: Menu) {}
override fun actionItemPressed(id: Int) {
if (selectedKeys.isEmpty()) {
return
}
when (id) {
R.id.cab_delete -> deleteSpeedDial()
}
}
override fun getSelectableItemCount() = speedDialValues.size
override fun getIsItemSelectable(position: Int) = speedDialValues[position].isValid()
override fun getItemSelectionKey(position: Int) = speedDialValues.getOrNull(position)?.hashCode()
override fun getItemKeyPosition(key: Int) = speedDialValues.indexOfFirst { it.hashCode() == key }
override fun onActionModeCreated() {}
override fun onActionModeDestroyed() {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_speed_dial, parent)
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val speedDial = speedDialValues[position]
holder.bindView(speedDial, true, true) { itemView, layoutPosition ->
setupView(itemView, speedDial)
}
bindViewHolder(holder)
}
override fun getItemCount() = speedDialValues.size
private fun getSelectedItems() = speedDialValues.filter { selectedKeys.contains(it.hashCode()) } as ArrayList<SpeedDial>
private fun deleteSpeedDial() {
val ids = getSelectedItems().map { it.id }.toMutableList() as ArrayList<Int>
removeListener.removeSpeedDial(ids)
finishActMode()
}
private fun setupView(view: View, speedDial: SpeedDial) {
view.apply {
var displayName = "${speedDial.id}. "
displayName += if (speedDial.isValid()) speedDial.displayName else ""
speed_dial_label.apply {
text = displayName
isSelected = selectedKeys.contains(speedDial.hashCode())
setTextColor(textColor)
}
}
}
}

View file

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/manage_speed_dial_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/manage_speed_dial_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="HardcodedText">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/manage_speed_dial_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/normal_margin"
android:text="@string/speed_dial_label"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/speed_dial_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
</LinearLayout>
</ScrollView>

View file

@ -118,27 +118,6 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_manage_speed_dial_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.MyTextView
android:id="@+id/settings_manage_speed_dial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingStart="@dimen/medium_margin"
android:text="@string/manage_speed_dial" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_font_size_holder"
android:layout_width="match_parent"

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.simplemobiletools.commons.views.MyTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/speed_dial_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:foreground="@drawable/selector"
android:lines="1"
android:maxLines="1"
android:padding="@dimen/activity_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size" />