Add missing app info extras

This commit is contained in:
Rahul Kumar Patel
2021-02-22 00:42:28 +05:30
parent f1b304c892
commit 31bacc687f
3 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store 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 2 of the License, or
* (at your option) any later version.
*
* Aurora Store 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 Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.epoxy.views.details
import android.content.Context
import android.util.AttributeSet
import android.widget.RelativeLayout
import com.airbnb.epoxy.ModelProp
import com.airbnb.epoxy.ModelView
import com.airbnb.epoxy.OnViewRecycled
import com.aurora.store.R
import com.aurora.store.databinding.ViewInfoBinding
import com.aurora.store.view.epoxy.views.BaseView
import java.util.*
@ModelView(
autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT,
baseModelClass = BaseView::class
)
class InfoView : RelativeLayout {
private lateinit var B: ViewInfoBinding
constructor(context: Context?) : super(context) {
init(context, null)
}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
init(context, attrs)
}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
init(context, attrs)
}
private fun init(context: Context?, attrs: AttributeSet?) {
val view = inflate(context, R.layout.view_info, this)
B = ViewInfoBinding.bind(view)
}
@ModelProp
fun badge(info: Map.Entry<String, String>) {
B.txtTitle.text = info.key
.replace("_", " ")
.toLowerCase(Locale.getDefault())
.capitalize(Locale.getDefault())
B.txtSubtitle.text = info.value
}
@OnViewRecycled
fun clear() {
}
}

View File

@@ -33,8 +33,10 @@ import com.aurora.store.view.epoxy.views.HeaderViewModel_
import com.aurora.store.view.epoxy.views.app.NoAppAltViewModel_
import com.aurora.store.view.epoxy.views.details.AppDependentViewModel_
import com.aurora.store.view.epoxy.views.details.FileViewModel_
import com.aurora.store.view.epoxy.views.details.InfoViewModel_
import com.aurora.store.view.epoxy.views.details.MoreBadgeViewModel_
import com.aurora.store.view.ui.commons.BaseActivity
import com.google.protobuf.MapEntry
import nl.komponents.kovenant.task
import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.successUi
@@ -135,6 +137,21 @@ class DetailsMoreActivity : BaseActivity() {
}
}
}
if (app.appInfo.appInfoMap.isNotEmpty()){
add(
HeaderViewModel_()
.id("info_header")
.title("Info")
)
app.appInfo.appInfoMap.forEach{
add(
InfoViewModel_()
.id(it.key)
.badge(it)
)
}
}
}
}