Rename to TagPickerActivity

Delete some more unused code
pull/2850/head
Alex Baker 2 weeks ago
parent e6e275834a
commit 4b892a0eb1

@ -145,7 +145,6 @@ android {
}
}
/*
testOptions {
managedDevices {
localDevices {
@ -157,7 +156,6 @@ android {
}
}
}
*/
namespace = "org.tasks"
}

@ -618,9 +618,7 @@
android:taskAffinity=""
android:theme="@style/TranslucentDialog"/>
<!-- <activity android:name=".tags.TagPickerActivity" /> -->
<activity android:name=".tags.TagPickerActivityCompose" />
<activity android:name=".tags.TagPickerActivity" />
<activity
android:name=".etebase.EtebaseCalendarSettingsActivity"

@ -116,8 +116,11 @@ import org.tasks.markdown.MarkdownProvider
import org.tasks.preferences.Device
import org.tasks.preferences.Preferences
import org.tasks.sync.SyncAdapters
import org.tasks.tags.TagPickerActivityCompose
import org.tasks.tasklist.*
import org.tasks.tags.TagPickerActivity
import org.tasks.tasklist.DragAndDropRecyclerAdapter
import org.tasks.tasklist.SectionedDataSource
import org.tasks.tasklist.TaskViewHolder
import org.tasks.tasklist.ViewHolderFactory
import org.tasks.themes.ColorProvider
import org.tasks.themes.ThemeColor
import org.tasks.ui.TaskEditEvent
@ -655,10 +658,10 @@ class TaskListFragment : Fragment(), OnRefreshListener, Toolbar.OnMenuItemClickL
lifecycleScope.launch {
val modified = tagDataDao.applyTags(
taskDao
.fetch(data!!.getSerializableExtra(TagPickerActivityCompose.EXTRA_TASKS) as ArrayList<Long>)
.fetch(data!!.getSerializableExtra(TagPickerActivity.EXTRA_TASKS) as ArrayList<Long>)
.filterNot { it.readOnly },
data.getParcelableArrayListExtra(TagPickerActivityCompose.EXTRA_PARTIALLY_SELECTED)!!,
data.getParcelableArrayListExtra(TagPickerActivityCompose.EXTRA_SELECTED)!!
data.getParcelableArrayListExtra(TagPickerActivity.EXTRA_PARTIALLY_SELECTED)!!,
data.getParcelableArrayListExtra(TagPickerActivity.EXTRA_SELECTED)!!
)
taskDao.touch(modified)
}
@ -724,13 +727,13 @@ class TaskListFragment : Fragment(), OnRefreshListener, Toolbar.OnMenuItemClickL
R.id.edit_tags -> {
lifecycleScope.launch {
val tags = tagDataDao.getTagSelections(selected)
val intent = Intent(context, TagPickerActivityCompose::class.java)
intent.putExtra(TagPickerActivityCompose.EXTRA_TASKS, selected)
val intent = Intent(context, TagPickerActivity::class.java)
intent.putExtra(TagPickerActivity.EXTRA_TASKS, selected)
intent.putParcelableArrayListExtra(
TagPickerActivityCompose.EXTRA_PARTIALLY_SELECTED,
TagPickerActivity.EXTRA_PARTIALLY_SELECTED,
ArrayList(tagDataDao.getByUuid(tags.first!!)))
intent.putParcelableArrayListExtra(
TagPickerActivityCompose.EXTRA_SELECTED, ArrayList(tagDataDao.getByUuid(tags.second!!)))
TagPickerActivity.EXTRA_SELECTED, ArrayList(tagDataDao.getByUuid(tags.second!!)))
startActivityForResult(intent, REQUEST_TAG_TASKS)
}
true

@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.update
import org.tasks.R
import org.tasks.compose.collectAsStateLifecycleAware
import org.tasks.compose.edit.TagsRow
import org.tasks.tags.TagPickerActivityCompose
import org.tasks.tags.TagPickerActivity
import org.tasks.ui.ChipProvider
import org.tasks.ui.TaskEditControlFragment
import javax.inject.Inject
@ -21,8 +21,8 @@ class TagsControlSet : TaskEditControlFragment() {
@Inject lateinit var chipProvider: ChipProvider
private fun onRowClick() {
val intent = Intent(context, TagPickerActivityCompose::class.java)
intent.putParcelableArrayListExtra(TagPickerActivityCompose.EXTRA_SELECTED, viewModel.selectedTags.value)
val intent = Intent(context, TagPickerActivity::class.java)
intent.putParcelableArrayListExtra(TagPickerActivity.EXTRA_SELECTED, viewModel.selectedTags.value)
startActivityForResult(intent, REQUEST_TAG_PICKER_ACTIVITY)
}
@ -48,7 +48,7 @@ class TagsControlSet : TaskEditControlFragment() {
if (requestCode == REQUEST_TAG_PICKER_ACTIVITY) {
if (resultCode == Activity.RESULT_OK && data != null) {
viewModel.selectedTags.value =
data.getParcelableArrayListExtra(TagPickerActivityCompose.EXTRA_SELECTED)
data.getParcelableArrayListExtra(TagPickerActivity.EXTRA_SELECTED)
?: ArrayList()
}
} else {

@ -31,8 +31,8 @@ import org.tasks.preferences.Preferences
import org.tasks.repeats.BasicRecurrenceDialog
import org.tasks.repeats.BasicRecurrenceDialog.Companion.EXTRA_RRULE
import org.tasks.repeats.RepeatRuleToString
import org.tasks.tags.TagPickerActivityCompose
import org.tasks.tags.TagPickerActivityCompose.Companion.EXTRA_SELECTED
import org.tasks.tags.TagPickerActivity
import org.tasks.tags.TagPickerActivity.Companion.EXTRA_SELECTED
import javax.inject.Inject
private const val FRAG_TAG_DEFAULT_LIST_SELECTION = "frag_tag_default_list_selection"
@ -108,7 +108,7 @@ class TaskDefaults : InjectingPreferenceFragment() {
findPreference(R.string.p_default_tags)
.setOnPreferenceClickListener {
lifecycleScope.launch {
val intent = Intent(context, TagPickerActivityCompose::class.java)
val intent = Intent(context, TagPickerActivity::class.java)
.putParcelableArrayListExtra(
EXTRA_SELECTED,
ArrayList(defaultTags())

@ -1,22 +1,5 @@
package org.tasks.tags
/*
* TagPickerActivityCompose is a replacement for TagPickerActivity reimplemented
* using JetPack Compose framework.
*
* The modification eliminates TagRecycleAdapter.
* TriStateCheckbox from Compose is used instead of CheckBoxTriState.
* Source code for TagRecycleAdapter and TagPickerActivity were deleted because they became incompatible
* with modified TagPickerViewModel, but were not excluded from build due to the hilt logic.
*
* There is a tag "FeatureReady" in the git commits log which marks the state when the main logic was
* already implemented via Compose but but viewModel was modified with backward compatibility so to
* switch back to View implementation its enough to find lines like this
* //val intent = Intent(context, TagPickerActivity::class.java)
* val intent = Intent(context, TagPickerActivityCompose::class.java)
* in TaskListFragment.kt and TagsControlSet.kt and move comment mark to another line.
*/
import android.app.Activity
import android.content.Intent
import android.os.Bundle
@ -67,7 +50,7 @@ import org.tasks.themes.Theme
import javax.inject.Inject
@AndroidEntryPoint
class TagPickerActivityCompose : ThemedInjectingAppCompatActivity() {
class TagPickerActivity : ThemedInjectingAppCompatActivity() {
@Inject lateinit var theme: Theme
@Inject lateinit var inventory: Inventory
@Inject lateinit var colorProvider: ColorProvider

@ -1,70 +0,0 @@
package org.tasks.tags
import android.content.Context
import android.view.View
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import org.tasks.R
import org.tasks.data.TagData
import org.tasks.databinding.RowTagPickerBinding
import org.tasks.themes.DrawableUtil
class TagPickerViewHolder internal constructor(
private val context: Context,
binding: RowTagPickerBinding,
private val callback: (TagData, TagPickerViewHolder) -> Unit
) : RecyclerView.ViewHolder(binding.root) {
val isChecked: Boolean
get() = checkBox.isChecked
private val text: TextView = binding.text
private val checkBox: CheckBoxTriStates = binding.checkbox.apply {
setOnCheckedChangeListener { _, _ -> onCheckedChanged() }
}
private var tagData: TagData? = null
private fun onClickRow() {
if (tagData!!.id == null) {
callback(tagData!!, this)
} else {
checkBox.toggle()
}
}
private fun onCheckedChanged() {
callback(tagData!!, this)
}
fun bind(
tagData: TagData, color: Int, icon: Int?, state: CheckBoxTriStates.State) {
var icon = icon
this.tagData = tagData
if (tagData.id == null) {
text.text = context.getString(R.string.create_new_tag, tagData.name)
icon = R.drawable.ic_outline_add_24px
checkBox.visibility = View.GONE
} else {
text.text = tagData.name
if (state == CheckBoxTriStates.State.CHECKED) {
checkBox.isChecked = true
} else {
updateCheckbox(state)
}
if (icon == null) {
icon = R.drawable.ic_outline_label_24px
}
}
DrawableUtil.setLeftDrawable(context, text, icon)
DrawableUtil.setTint(DrawableUtil.getLeftDrawable(text), color)
}
fun updateCheckbox(state: CheckBoxTriStates.State) {
checkBox.setState(state, false)
checkBox.visibility = View.VISIBLE
}
init {
binding.tagRow.setOnClickListener { onClickRow() }
}
}

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:descendantFocusability="beforeDescendants"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="@dimen/elevation_toolbar"
android:theme="@style/ToolbarTheme"
android:background="@color/content_background"
app:popupTheme="@style/popup_overlay"
app:titleTextColor="@color/text_primary"
tools:ignore="UnusedAttribute">
<EditText
android:id="@+id/search_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:hint="@string/enter_tag_name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textAutoCorrect"
android:lines="1"
android:maxLines="1"
android:scrollbars="vertical"
android:textColor="@color/text_primary"
android:textColorHint="@color/text_secondary" />
</androidx.appcompat.widget.Toolbar>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tag_row"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true">
<org.tasks.tags.CheckBoxTriStates
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:clickable="true"
android:focusable="true"
android:layout_centerVertical="true"
android:padding="12dp" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/checkbox"
android:drawablePadding="@dimen/keyline_second"
android:textColor="@color/text_primary"
android:layout_centerVertical="true"
android:paddingStart="@dimen/keyline_first"
android:paddingEnd="@dimen/keyline_first"
android:textSize="@dimen/task_edit_text_size" />
</RelativeLayout>
Loading…
Cancel
Save