Merge branch 'list-tabs'
This commit is contained in:
commit
6f1e7fb74b
|
@ -21,6 +21,7 @@ import androidx.fragment.app.Fragment
|
|||
import com.keylesspalace.tusky.components.conversation.ConversationsFragment
|
||||
import com.keylesspalace.tusky.fragment.NotificationsFragment
|
||||
import com.keylesspalace.tusky.fragment.TimelineFragment
|
||||
import java.net.URLDecoder
|
||||
|
||||
/** this would be a good case for a sealed class, but that does not work nice with Room */
|
||||
|
||||
|
@ -46,7 +47,7 @@ fun createTabDataFromId(id: String, arguments: List<String> = emptyList()): TabD
|
|||
FEDERATED -> TabData(FEDERATED, R.string.title_public_federated, R.drawable.ic_public_24dp, { TimelineFragment.newInstance(TimelineFragment.Kind.PUBLIC_FEDERATED) })
|
||||
DIRECT -> TabData(DIRECT, R.string.title_direct_messages, R.drawable.reblog_direct_dark, { ConversationsFragment.newInstance() })
|
||||
HASHTAG -> TabData(HASHTAG, R.string.hashtag, R.drawable.ic_hashtag, { args -> TimelineFragment.newInstance(TimelineFragment.Kind.TAG, args.getOrNull(0).orEmpty()) }, arguments)
|
||||
LIST -> TabData(LIST, R.string.list, R.drawable.ic_list, { args -> TimelineFragment.newInstance(TimelineFragment.Kind.LIST, args.getOrNull(0).orEmpty()) }, arguments)
|
||||
LIST -> TabData(LIST, R.string.list, R.drawable.ic_list, { args -> TimelineFragment.newInstance(TimelineFragment.Kind.LIST, args.getOrNull(0).orEmpty()) }, arguments.map { URLDecoder.decode(it, "UTF-8") })
|
||||
else -> throw IllegalArgumentException("unknown tab type")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,7 +219,8 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene
|
|||
{ lists ->
|
||||
adapter.addAll(lists)
|
||||
},
|
||||
{
|
||||
{ throwable ->
|
||||
throwable.printStackTrace()
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ import android.view.ViewGroup
|
|||
import android.widget.ArrayAdapter
|
||||
import com.keylesspalace.tusky.R
|
||||
import com.keylesspalace.tusky.entity.MastoList
|
||||
import kotlinx.android.synthetic.main.item_autocomplete_hashtag.view.*
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
import kotlinx.android.synthetic.main.item_picker_list.view.*
|
||||
|
||||
class ListSelectionAdapter(context: Context) : ArrayAdapter<MastoList>(context, R.layout.item_autocomplete_hashtag) {
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
|
@ -30,15 +31,15 @@ class ListSelectionAdapter(context: Context) : ArrayAdapter<MastoList>(context,
|
|||
|
||||
if (convertView == null) {
|
||||
val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
view = layoutInflater.inflate(R.layout.item_autocomplete_hashtag, parent, false)
|
||||
view = layoutInflater.inflate(R.layout.item_picker_list, parent, false)
|
||||
}
|
||||
view!!
|
||||
|
||||
val list = getItem(position)
|
||||
if (list != null) {
|
||||
val title = view.hashtag
|
||||
val title = view.title
|
||||
title.text = list.title
|
||||
val icon = context.getDrawable(R.drawable.ic_list)
|
||||
val icon = ThemeUtils.getTintedDrawable(context, R.drawable.ic_list, android.R.attr.textColorPrimary)
|
||||
title.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null)
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.keylesspalace.tusky.entity.Poll
|
|||
import com.keylesspalace.tusky.entity.Status
|
||||
import com.keylesspalace.tusky.json.SpannedTypeAdapter
|
||||
import com.keylesspalace.tusky.util.HtmlUtils
|
||||
import java.net.URLDecoder
|
||||
import java.net.URLEncoder
|
||||
import java.util.*
|
||||
|
||||
|
@ -63,12 +62,13 @@ class Converters {
|
|||
return str?.split(";")
|
||||
?.map {
|
||||
val data = it.split(":")
|
||||
createTabDataFromId(data[0], data.drop(1).map { s -> URLDecoder.decode(s, "UTF-8") })
|
||||
createTabDataFromId(data[0], data.drop(1))
|
||||
}
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun tabDataToString(tabData: List<TabData>?): String? {
|
||||
// List name may include ":"
|
||||
return tabData?.joinToString(";") { it.id + ":" + it.arguments.joinToString(":") { s -> URLEncoder.encode(s, "UTF-8") } }
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:drawablePadding="8dp"
|
||||
android:textSize="?attr/status_text_medium" />
|
Loading…
Reference in New Issue