* List tabs

* Add comment

* Move decoder part to TabData.createTabDataFromId

* Fix drawable tint

* Use dedicated view for list picker

* Error log

* Fix logging

Co-Authored-By: Konrad Pozniak <connyduck@users.noreply.github.com>

* Fix tint color

Co-Authored-By: Konrad Pozniak <connyduck@users.noreply.github.com>

* Fix missing import

* Move encoding part too

* Fix comment

* Fix decoder

* Revert "Fix decoder"

This reverts commit fdc45aac9c113348f8740e6692d2d8e9ace14f7f.

* Revert "Fix comment"

This reverts commit 704b4e6d2e5545d5f2d20c9bc6bc276d6257d119.

* Revert "Move encoding part too"

This reverts commit 32e77346ff98ae1133e76ab6dfd880b26171005e.

* Revert "Move decoder part to TabData.createTabDataFromId"

This reverts commit d1cd2070ab564d2e33874225272a71f0904d681e.
This commit is contained in:
kyori19 2019-12-03 00:53:24 +09:00 committed by Konrad Pozniak
commit d6ae071a09
9 changed files with 125 additions and 5 deletions

View file

@ -0,0 +1,48 @@
/* Copyright 2019 kyori19
*
* This file is a part of Tusky.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tusky; if not,
* see <http://www.gnu.org/licenses>. */
package com.keylesspalace.tusky.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.entity.MastoList
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 {
var view = convertView
if (convertView == null) {
val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
view = layoutInflater.inflate(R.layout.item_picker_list, parent, false)
}
view!!
val list = getItem(position)
if (list != null) {
val title = view.title
title.text = list.title
val icon = ThemeUtils.getTintedDrawable(context, R.drawable.ic_list, android.R.attr.textColorTertiary)
title.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null)
}
return view
}
}

View file

@ -21,6 +21,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.keylesspalace.tusky.HASHTAG
import com.keylesspalace.tusky.LIST
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.TabData
import com.keylesspalace.tusky.util.ThemeUtils
@ -57,7 +58,11 @@ class TabAdapter(private var data: List<TabData>,
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val context = holder.itemView.context
holder.itemView.textView.setText(data[position].text)
if (!small && data[position].id == LIST) {
holder.itemView.textView.text = data[position].arguments.getOrNull(1).orEmpty()
} else {
holder.itemView.textView.setText(data[position].text)
}
val iconDrawable = ThemeUtils.getTintedDrawable(context, data[position].icon, android.R.attr.textColorSecondary)
holder.itemView.textView.setCompoundDrawablesRelativeWithIntrinsicBounds(iconDrawable, null, null, null)
if (small) {