Browse Source

Move authors in an activity and spacing fixes

merge-requests/1287/head
Nicolas Pomepuy 5 years ago
parent
commit
4cb64850cd
  1. 3
      application/vlc-android/AndroidManifest.xml
  2. 36
      application/vlc-android/res/layout/about_authors_activity.xml
  3. 8
      application/vlc-android/res/layout/about_authors_item.xml
  4. 38
      application/vlc-android/res/layout/dialog_about_authors.xml
  5. 2
      application/vlc-android/res/layout/library_item.xml
  6. 2
      application/vlc-android/res/layout/license_activity.xml
  7. 86
      application/vlc-android/src/org/videolan/vlc/gui/AuthorsActivity.kt
  8. 127
      application/vlc-android/src/org/videolan/vlc/gui/dialogs/AboutAuthorsDialog.kt
  9. 2
      application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt

3
application/vlc-android/AndroidManifest.xml

@ -480,6 +480,9 @@
<activity
android:name=".gui.LibrariesActivity"
android:theme="@style/Theme.VLC"/>
<activity
android:name=".gui.AuthorsActivity"
android:theme="@style/Theme.VLC"/>
<activity
android:name=".gui.SearchActivity"
android:theme="@style/Theme.VLC"/>

36
application/vlc-android/res/layout/about_authors_activity.xml

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<merge
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/toolbar"
android:nextFocusLeft="@+id/ml_menu_search"
android:nextFocusRight="@+id/ml_menu_search"
android:nextFocusUp="@+id/ml_menu_search"
android:nextFocusDown="@+id/ml_menu_search"
android:nextFocusForward="@+id/ml_menu_search" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/authors_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</merge>
</layout>

8
application/vlc-android/res/layout/dialog_about_authors_item.xml → application/vlc-android/res/layout/about_authors_item.xml

@ -34,14 +34,14 @@
android:id="@+id/author_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginStart="32dp"
android:text="@{author}"
android:textColor="?attr/font_default"
tools:text="Jean-Baptiste Kempf"
android:textSize="16sp"
android:text="@{author}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView17"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:text="Jean-Baptiste Kempf" />
</androidx.constraintlayout.widget.ConstraintLayout>

38
application/vlc-android/res/layout/dialog_about_authors.xml

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/title"
style="@style/Theme.VLC.BottomSheetTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/authors"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/authors_list"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</layout>

2
application/vlc-android/res/layout/library_item.xml

@ -35,7 +35,7 @@
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="16dp"
android:text="@{library.title}"
android:textColor="?attr/font_default"

2
application/vlc-android/res/layout/license_activity.xml

@ -37,8 +37,6 @@
android:layout_gravity="center_horizontal|top"
android:background="?attr/background_default"
android:clipToPadding="false"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="48dp"
android:fastScrollEnabled="true"
android:scrollbars="vertical"

86
application/vlc-android/src/org/videolan/vlc/gui/AuthorsActivity.kt

@ -0,0 +1,86 @@
package org.videolan.vlc.gui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.*
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.appbar.MaterialToolbar
import com.squareup.moshi.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.withContext
import org.videolan.resources.AppContextProvider
import org.videolan.vlc.R
import org.videolan.vlc.databinding.AboutAuthorsActivityBinding
import org.videolan.vlc.databinding.AboutAuthorsItemBinding
import org.videolan.vlc.gui.helpers.SelectorViewHolder
/**
* Activity showing the different libraries used by VLC for Android and their licenses
*/
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
class AuthorsActivity : BaseActivity() {
internal lateinit var binding: AboutAuthorsActivityBinding
override fun getSnackAnchorView(overAudioPlayer:Boolean) = binding.root
override val displayTitle = true
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.about_authors_activity)
val toolbar = findViewById<MaterialToolbar>(R.id.main_toolbar)
setSupportActionBar(toolbar)
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_close_up)
title = getString(R.string.authors)
binding.authorsList.layoutManager = LinearLayoutManager(this)
loadAuthors()
}
/**
* Load the authors list from the json file in assets and then populate the list
*/
private fun loadAuthors() {
lifecycleScope.launchWhenStarted {
val authors = withContext(Dispatchers.IO) {
val jsonData = AppContextProvider.appContext.assets.open("authors.json").bufferedReader().use {
it.readText()
}
val moshi = Moshi.Builder().build()
val type = Types.newParameterizedType(MutableList::class.java, String::class.java)
val jsonAdapter: JsonAdapter<List<String>> = moshi.adapter(type)
jsonAdapter.fromJson(jsonData)!!
}
binding.authorsList.adapter = AuthorsAdapter(authors)
}
}
}
@ExperimentalCoroutinesApi
@ObsoleteCoroutinesApi
class AuthorsAdapter(val authors: List<String>) : DiffUtilAdapter<String, AuthorsAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(AboutAuthorsItemBinding.inflate(LayoutInflater.from(parent.context), parent, false))
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.binding.author = authors[position]
}
override fun getItemCount() = authors.size
inner class ViewHolder(vdb: AboutAuthorsItemBinding) : SelectorViewHolder<AboutAuthorsItemBinding>(vdb)
}

127
application/vlc-android/src/org/videolan/vlc/gui/dialogs/AboutAuthorsDialog.kt

@ -1,127 +0,0 @@
/**
* **************************************************************************
* PickTimeFragment.java
* ****************************************************************************
* Copyright © 2015 VLC authors and VideoLAN
*
* 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* ***************************************************************************
*/
package org.videolan.vlc.gui.dialogs
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.withContext
import org.videolan.resources.AppContextProvider
import org.videolan.vlc.databinding.DialogAboutAuthorsBinding
import org.videolan.vlc.databinding.DialogAboutAuthorsItemBinding
import org.videolan.vlc.gui.DiffUtilAdapter
import org.videolan.vlc.gui.helpers.SelectorViewHolder
/**
* Dialog showing the authors list of VLC for Android
*/
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
class AboutAuthorsDialog : VLCBottomSheetDialogFragment() {
private lateinit var binding: DialogAboutAuthorsBinding
companion object {
fun newInstance(): AboutAuthorsDialog {
return AboutAuthorsDialog()
}
}
override fun getDefaultState(): Int {
return STATE_EXPANDED
}
override fun needToManageOrientation(): Boolean {
return false
}
override fun initialFocusedView(): View = binding.authorsList
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View {
binding = DialogAboutAuthorsBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.authorsList.layoutManager = LinearLayoutManager(requireActivity())
loadAuthors()
}
/**
* Load the authors list from the json file in assets and then populate the list
*/
private fun loadAuthors() {
lifecycleScope.launchWhenStarted {
val authors = withContext(Dispatchers.IO) {
val jsonData = AppContextProvider.appContext.assets.open("authors.json").bufferedReader().use {
it.readText()
}
val moshi = Moshi.Builder().build()
val type = Types.newParameterizedType(MutableList::class.java, String::class.java)
val jsonAdapter: JsonAdapter<List<String>> = moshi.adapter(type)
jsonAdapter.fromJson(jsonData)!!
}
binding.authorsList.adapter = AuthorsAdapter(authors)
}
}
}
@ExperimentalCoroutinesApi
@ObsoleteCoroutinesApi
class AuthorsAdapter(val authors: List<String>) : DiffUtilAdapter<String, AuthorsAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(DialogAboutAuthorsItemBinding.inflate(LayoutInflater.from(parent.context), parent, false))
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.binding.author = authors[position]
}
override fun getItemCount() = authors.size
inner class ViewHolder(vdb: DialogAboutAuthorsItemBinding) : SelectorViewHolder<DialogAboutAuthorsItemBinding>(vdb)
}

2
application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt

@ -391,7 +391,7 @@ object UiTools {
}
v.findViewById<View>(R.id.about_authors_container).setOnClickListener {
AboutAuthorsDialog.newInstance().show(activity.supportFragmentManager, "AboutAuthorsDialog")
activity.startActivity(Intent(activity, AuthorsActivity::class.java))
}
v.findViewById<View>(R.id.about_libraries_container).setOnClickListener {
activity.startActivity(Intent(activity, LibrariesActivity::class.java))

Loading…
Cancel
Save