Skip to content
Snippets Groups Projects
Commit e27f3d13 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Implement translation and actions for detailled info screen

parent 06002bb7
Branches
No related tags found
No related merge requests found
Showing
with 184 additions and 23 deletions
......@@ -3,7 +3,6 @@ package de.kuschku.quasseldroid.ui.chat.info
import de.kuschku.libquassel.quassel.syncables.IrcChannel
import de.kuschku.libquassel.quassel.syncables.IrcUser
import de.kuschku.libquassel.quassel.syncables.Network
import de.kuschku.quasseldroid.viewmodel.data.InfoGroup
data class InfoData(
val type: InfoType,
......
......@@ -7,6 +7,7 @@ import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import butterknife.BindView
import butterknife.ButterKnife
import de.kuschku.libquassel.util.Optional
......@@ -15,8 +16,6 @@ import de.kuschku.quasseldroid.R
import de.kuschku.quasseldroid.util.helper.toLiveData
import de.kuschku.quasseldroid.util.irc.format.ContentFormatter
import de.kuschku.quasseldroid.util.service.ServiceBoundFragment
import de.kuschku.quasseldroid.viewmodel.data.InfoGroup
import de.kuschku.quasseldroid.viewmodel.data.InfoProperty
import io.reactivex.Observable
import javax.inject.Inject
......@@ -52,26 +51,26 @@ class InfoFragment : ServiceBoundFragment() {
network = network,
properties = listOf(
InfoGroup(
name = "Identity",
name = getString(R.string.property_group_ircuser_identity),
properties = listOf(
InfoProperty(
name = "Nickname",
name = getString(R.string.property_ircuser_nick),
value = user.nick()
),
InfoProperty(
name = "Ident",
name = getString(R.string.property_ircuser_user),
value = user.user()
),
InfoProperty(
name = "Host",
name = getString(R.string.property_ircuser_host),
value = user.host()
),
InfoProperty(
name = "Real Name",
name = getString(R.string.property_ircuser_realname),
value = contentFormatter.format(requireContext(), user.realName())
),
InfoProperty(
name = "Account",
name = getString(R.string.property_ircuser_account),
value = user.account()
)
)
......@@ -89,11 +88,24 @@ class InfoFragment : ServiceBoundFragment() {
network = network,
properties = listOf(
InfoGroup(
name = "Channel",
name = getString(R.string.property_group_ircchannel_channel),
properties = listOf(
InfoProperty(
name = "Topic",
value = contentFormatter.format(requireContext(), channel.topic())
name = getString(R.string.property_ircchannel_topic),
value = contentFormatter.format(requireContext(), channel.topic()),
actions = listOf(
InfoPropertyAction(
name = getString(R.string.property_ircchannel_topic_action_edit),
featured = true,
onClick = {
Toast.makeText(
requireContext(),
"Not implemented",
Toast.LENGTH_SHORT
).show()
}
)
)
)
)
)
......
package de.kuschku.quasseldroid.viewmodel.data
package de.kuschku.quasseldroid.ui.chat.info
data class InfoGroup(
val name: String,
val name: CharSequence,
val properties: List<InfoProperty>
)
......@@ -12,7 +12,6 @@ import android.widget.TextView
import butterknife.BindView
import butterknife.ButterKnife
import de.kuschku.quasseldroid.R
import de.kuschku.quasseldroid.viewmodel.data.InfoGroup
class InfoGroupAdapter :
ListAdapter<InfoGroup, InfoGroupAdapter.InfoGroupViewHolder>(
......@@ -26,7 +25,7 @@ class InfoGroupAdapter :
) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = InfoGroupViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.widget_userinfo_group, parent, false)
LayoutInflater.from(parent.context).inflate(R.layout.widget_info_group, parent, false)
)
override fun onBindViewHolder(holder: InfoGroupViewHolder, position: Int) =
......@@ -39,13 +38,11 @@ class InfoGroupAdapter :
@BindView(R.id.properties)
lateinit var properties: RecyclerView
private val adapter: InfoPropertyAdapter
private val adapter = InfoPropertyAdapter()
init {
ButterKnife.bind(this, itemView)
adapter = InfoPropertyAdapter()
properties.layoutManager = LinearLayoutManager(itemView.context)
properties.adapter = adapter
properties.addItemDecoration(
......
package de.kuschku.quasseldroid.viewmodel.data
package de.kuschku.quasseldroid.ui.chat.info
import android.support.annotation.DrawableRes
data class InfoProperty(
val name: CharSequence? = null,
@DrawableRes val icon: Int? = null,
val value: CharSequence
val value: CharSequence,
val actions: List<InfoPropertyAction> = emptyList()
)
\ No newline at end of file
package de.kuschku.quasseldroid.ui.chat.info
data class InfoPropertyAction(
val name: CharSequence,
val featured: Boolean = false,
val onClick: () -> Unit
)
\ No newline at end of file
package de.kuschku.quasseldroid.ui.chat.info
import android.support.v7.recyclerview.extensions.ListAdapter
import android.support.v7.util.DiffUtil
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import butterknife.BindView
import butterknife.ButterKnife
import de.kuschku.quasseldroid.R
class InfoPropertyActionAdapter :
ListAdapter<InfoPropertyAction, InfoPropertyActionAdapter.InfoPropertyActionViewHolder>(
object : DiffUtil.ItemCallback<InfoPropertyAction>() {
override fun areItemsTheSame(oldItem: InfoPropertyAction, newItem: InfoPropertyAction) =
oldItem.name == newItem.name
override fun areContentsTheSame(oldItem: InfoPropertyAction, newItem: InfoPropertyAction) =
oldItem == newItem
}
) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = InfoPropertyActionViewHolder(
LayoutInflater.from(parent.context).inflate(
if (viewType == VIEWTYPE_FEATURED)
R.layout.widget_info_action_main
else
R.layout.widget_info_action,
parent,
false
)
)
override fun onBindViewHolder(holder: InfoPropertyActionViewHolder, position: Int) {
holder.bind(getItem(position))
}
override fun getItemViewType(position: Int) =
if (getItem(position).featured) VIEWTYPE_FEATURED else VIEWTYPE_NORMAL
class InfoPropertyActionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
@BindView(R.id.button)
lateinit var button: Button
private var onClick: (() -> Unit)? = null
init {
ButterKnife.bind(this, itemView)
button.setOnClickListener {
onClick?.invoke()
}
}
fun bind(item: InfoPropertyAction) {
this.onClick = item.onClick
button.text = item.name
}
}
companion object {
const val VIEWTYPE_NORMAL = 0
const val VIEWTYPE_FEATURED = 1
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package de.kuschku.quasseldroid.ui.chat.info
import android.support.v7.recyclerview.extensions.ListAdapter
import android.support.v7.util.DiffUtil
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
......@@ -12,7 +13,6 @@ import butterknife.BindView
import butterknife.ButterKnife
import de.kuschku.quasseldroid.R
import de.kuschku.quasseldroid.util.helper.visibleIf
import de.kuschku.quasseldroid.viewmodel.data.InfoProperty
import me.saket.bettermovementmethod.BetterLinkMovementMethod
class InfoPropertyAdapter :
......@@ -26,7 +26,7 @@ class InfoPropertyAdapter :
}
) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = InfoPropertyViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.widget_userinfo, parent, false)
LayoutInflater.from(parent.context).inflate(R.layout.widget_info_property, parent, false)
)
override fun onBindViewHolder(holder: InfoPropertyViewHolder, position: Int) =
......@@ -45,8 +45,17 @@ class InfoPropertyAdapter :
@BindView(R.id.value)
lateinit var value: TextView
@BindView(R.id.actions)
lateinit var actions: RecyclerView
private val adapter = InfoPropertyActionAdapter()
init {
ButterKnife.bind(this, itemView)
actions.layoutManager = LinearLayoutManager(itemView.context, RecyclerView.HORIZONTAL, false)
actions.adapter = adapter
value.movementMethod = BetterLinkMovementMethod.getInstance()
}
......@@ -55,6 +64,8 @@ class InfoPropertyAdapter :
name.text = item.name
value.text = item.value
adapter.submitList(item.actions)
iconFrame.visibleIf(item.icon != null)
}
}
......
......@@ -5,4 +5,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="12dp"
tools:listitem="@layout/widget_userinfo_group" />
\ No newline at end of file
tools:listitem="@layout/widget_info_group" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/button"
style="@style/Widget.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
tools:text="Change Topic" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/button"
style="@style/Widget.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
tools:text="Change Topic" />
\ No newline at end of file
......@@ -27,6 +27,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:itemCount="3"
tools:listitem="@layout/widget_userinfo" />
tools:listitem="@layout/widget_info_property" />
</LinearLayout>
\ No newline at end of file
......@@ -65,5 +65,14 @@
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?colorTextSecondary"
tools:text="@sample/userinfo_basic.json/data/value" />
<android.support.v7.widget.RecyclerView
android:id="@+id/actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-4dp"
android:layout_marginStart="-4dp"
android:orientation="horizontal"
tools:listitem="@layout/widget_info_action_main" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="property_group_ircuser_identity">Identität</string>
<string name="property_ircuser_nick">Spitzname</string>
<string name="property_ircuser_user">Ident</string>
<string name="property_ircuser_host">Host</string>
<string name="property_ircuser_realname">Realname</string>
<string name="property_ircuser_account">Account</string>
<string name="property_group_ircchannel_channel">Channel</string>
<string name="property_ircchannel_topic">Thema</string>
<string name="property_ircchannel_topic_action_edit">Thema ändern</string>
<string name="property_ircchannel_topic_default">Kein Thema gesetzt</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="property_group_ircuser_identity">Identity</string>
<string name="property_ircuser_nick">Nickname</string>
<string name="property_ircuser_user">Ident</string>
<string name="property_ircuser_host">Host</string>
<string name="property_ircuser_realname">Real Name</string>
<string name="property_ircuser_account">Account</string>
<string name="property_group_ircchannel_channel">Channel</string>
<string name="property_ircchannel_topic">Topic</string>
<string name="property_ircchannel_topic_action_edit">Edit Topic</string>
<string name="property_ircchannel_topic_default">No Topic Set</string>
</resources>
\ No newline at end of file
......@@ -2,6 +2,12 @@
<style name="Widget" />
<style name="Widget.Button.Borderless" parent="Widget.AppCompat.Button.Borderless">
<item name="android:textColor">?attr/colorTextPrimary</item>
</style>
<style name="Widget.Button.Borderless.Colored" parent="Widget.AppCompat.Button.Borderless.Colored" />
<style name="Widget.Button" parent="Widget.AppCompat.Button">
<item name="backgroundTint">?attr/colorBackgroundCard</item>
<item name="android:textColor">?attr/colorTextPrimary</item>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment