10 changed files with 918 additions and 4 deletions
-
54src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/LicenseAdapter.kt
-
10src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt
-
59src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicenseBottomSheetDialogFragment.kt
-
137src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt
-
16src/android/app/src/main/java/org/yuzu/yuzu_emu/model/License.kt
-
64src/android/app/src/main/res/layout/dialog_license.xml
-
33src/android/app/src/main/res/layout/fragment_about.xml
-
30src/android/app/src/main/res/layout/fragment_licenses.xml
-
11src/android/app/src/main/res/navigation/home_navigation.xml
-
508src/android/app/src/main/res/values/strings.xml
@ -0,0 +1,54 @@ |
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
package org.yuzu.yuzu_emu.adapters |
|||
|
|||
import android.view.LayoutInflater |
|||
import android.view.View |
|||
import android.view.ViewGroup |
|||
import androidx.appcompat.app.AppCompatActivity |
|||
import androidx.recyclerview.widget.RecyclerView |
|||
import androidx.recyclerview.widget.RecyclerView.ViewHolder |
|||
import org.yuzu.yuzu_emu.YuzuApplication |
|||
import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding |
|||
import org.yuzu.yuzu_emu.fragments.LicenseBottomSheetDialogFragment |
|||
import org.yuzu.yuzu_emu.model.License |
|||
|
|||
class LicenseAdapter(private val activity: AppCompatActivity, var licenses: List<License>) : |
|||
RecyclerView.Adapter<LicenseAdapter.LicenseViewHolder>(), |
|||
View.OnClickListener { |
|||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LicenseViewHolder { |
|||
val binding = |
|||
ListItemSettingBinding.inflate(LayoutInflater.from(parent.context), parent, false) |
|||
binding.root.setOnClickListener(this) |
|||
return LicenseViewHolder(binding) |
|||
} |
|||
|
|||
override fun getItemCount(): Int = licenses.size |
|||
|
|||
override fun onBindViewHolder(holder: LicenseViewHolder, position: Int) { |
|||
holder.bind(licenses[position]) |
|||
} |
|||
|
|||
override fun onClick(view: View) { |
|||
val license = (view.tag as LicenseViewHolder).license |
|||
LicenseBottomSheetDialogFragment.newInstance(license) |
|||
.show(activity.supportFragmentManager, LicenseBottomSheetDialogFragment.TAG) |
|||
} |
|||
|
|||
inner class LicenseViewHolder(val binding: ListItemSettingBinding) : ViewHolder(binding.root) { |
|||
lateinit var license: License |
|||
|
|||
init { |
|||
itemView.tag = this |
|||
} |
|||
|
|||
fun bind(license: License) { |
|||
this.license = license |
|||
|
|||
val context = YuzuApplication.appContext |
|||
binding.textSettingName.text = context.getString(license.titleId) |
|||
binding.textSettingDescription.text = context.getString(license.descriptionId) |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
package org.yuzu.yuzu_emu.fragments |
|||
|
|||
import android.os.Bundle |
|||
import android.view.LayoutInflater |
|||
import android.view.View |
|||
import android.view.ViewGroup |
|||
import com.google.android.material.bottomsheet.BottomSheetBehavior |
|||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment |
|||
import org.yuzu.yuzu_emu.databinding.DialogLicenseBinding |
|||
import org.yuzu.yuzu_emu.model.License |
|||
import org.yuzu.yuzu_emu.utils.SerializableHelper.parcelable |
|||
|
|||
class LicenseBottomSheetDialogFragment : BottomSheetDialogFragment() { |
|||
private var _binding: DialogLicenseBinding? = null |
|||
private val binding get() = _binding!! |
|||
|
|||
override fun onCreateView( |
|||
inflater: LayoutInflater, |
|||
container: ViewGroup?, |
|||
savedInstanceState: Bundle? |
|||
): View { |
|||
_binding = DialogLicenseBinding.inflate(layoutInflater) |
|||
return binding.root |
|||
} |
|||
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|||
super.onViewCreated(view, savedInstanceState) |
|||
BottomSheetBehavior.from<View>(view.parent as View).state = |
|||
BottomSheetBehavior.STATE_HALF_EXPANDED |
|||
|
|||
val license = requireArguments().parcelable<License>(LICENSE)!! |
|||
|
|||
binding.apply { |
|||
textTitle.setText(license.titleId) |
|||
textLink.setText(license.linkId) |
|||
textCopyright.setText(license.copyrightId) |
|||
textLicense.setText(license.licenseId) |
|||
} |
|||
} |
|||
|
|||
companion object { |
|||
const val TAG = "LicenseBottomSheetDialogFragment" |
|||
|
|||
const val LICENSE = "License" |
|||
|
|||
fun newInstance( |
|||
license: License |
|||
): LicenseBottomSheetDialogFragment { |
|||
val dialog = LicenseBottomSheetDialogFragment() |
|||
val bundle = Bundle() |
|||
bundle.putParcelable(LICENSE, license) |
|||
dialog.arguments = bundle |
|||
return dialog |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
package org.yuzu.yuzu_emu.fragments |
|||
|
|||
import android.os.Bundle |
|||
import android.view.LayoutInflater |
|||
import android.view.View |
|||
import android.view.ViewGroup |
|||
import android.view.ViewGroup.MarginLayoutParams |
|||
import androidx.appcompat.app.AppCompatActivity |
|||
import androidx.core.view.ViewCompat |
|||
import androidx.core.view.WindowInsetsCompat |
|||
import androidx.core.view.updatePadding |
|||
import androidx.fragment.app.Fragment |
|||
import androidx.fragment.app.activityViewModels |
|||
import androidx.navigation.findNavController |
|||
import androidx.recyclerview.widget.LinearLayoutManager |
|||
import com.google.android.material.transition.MaterialSharedAxis |
|||
import org.yuzu.yuzu_emu.R |
|||
import org.yuzu.yuzu_emu.adapters.LicenseAdapter |
|||
import org.yuzu.yuzu_emu.databinding.FragmentLicensesBinding |
|||
import org.yuzu.yuzu_emu.model.HomeViewModel |
|||
import org.yuzu.yuzu_emu.model.License |
|||
|
|||
class LicensesFragment : Fragment() { |
|||
private var _binding: FragmentLicensesBinding? = null |
|||
private val binding get() = _binding!! |
|||
|
|||
private val homeViewModel: HomeViewModel by activityViewModels() |
|||
|
|||
override fun onCreate(savedInstanceState: Bundle?) { |
|||
super.onCreate(savedInstanceState) |
|||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true) |
|||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false) |
|||
} |
|||
|
|||
override fun onCreateView( |
|||
inflater: LayoutInflater, |
|||
container: ViewGroup?, |
|||
savedInstanceState: Bundle? |
|||
): View { |
|||
_binding = FragmentLicensesBinding.inflate(layoutInflater) |
|||
return binding.root |
|||
} |
|||
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|||
homeViewModel.setNavigationVisibility(visible = false, animated = true) |
|||
homeViewModel.setStatusBarShadeVisibility(visible = false) |
|||
|
|||
binding.toolbarLicenses.setNavigationOnClickListener { |
|||
binding.root.findNavController().popBackStack() |
|||
} |
|||
|
|||
val licenses = listOf( |
|||
License( |
|||
R.string.license_fidelityfx_fsr, |
|||
R.string.license_fidelityfx_fsr_description, |
|||
R.string.license_fidelityfx_fsr_link, |
|||
R.string.license_fidelityfx_fsr_copyright, |
|||
R.string.license_fidelityfx_fsr_text |
|||
), |
|||
License( |
|||
R.string.license_cubeb, |
|||
R.string.license_cubeb_description, |
|||
R.string.license_cubeb_link, |
|||
R.string.license_cubeb_copyright, |
|||
R.string.license_cubeb_text |
|||
), |
|||
License( |
|||
R.string.license_dynarmic, |
|||
R.string.license_dynarmic_description, |
|||
R.string.license_dynarmic_link, |
|||
R.string.license_dynarmic_copyright, |
|||
R.string.license_dynarmic_text |
|||
), |
|||
License( |
|||
R.string.license_ffmpeg, |
|||
R.string.license_ffmpeg_description, |
|||
R.string.license_ffmpeg_link, |
|||
R.string.license_ffmpeg_copyright, |
|||
R.string.license_ffmpeg_text |
|||
), |
|||
License( |
|||
R.string.license_opus, |
|||
R.string.license_opus_description, |
|||
R.string.license_opus_link, |
|||
R.string.license_opus_copyright, |
|||
R.string.license_opus_text |
|||
), |
|||
License( |
|||
R.string.license_sirit, |
|||
R.string.license_sirit_description, |
|||
R.string.license_sirit_link, |
|||
R.string.license_sirit_copyright, |
|||
R.string.license_sirit_text |
|||
), |
|||
License( |
|||
R.string.license_adreno_tools, |
|||
R.string.license_adreno_tools_description, |
|||
R.string.license_adreno_tools_link, |
|||
R.string.license_adreno_tools_copyright, |
|||
R.string.license_adreno_tools_text |
|||
) |
|||
) |
|||
|
|||
binding.listLicenses.apply { |
|||
layoutManager = LinearLayoutManager(requireContext()) |
|||
adapter = LicenseAdapter(requireActivity() as AppCompatActivity, licenses) |
|||
} |
|||
|
|||
setInsets() |
|||
} |
|||
|
|||
private fun setInsets() = |
|||
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _: View, windowInsets: WindowInsetsCompat -> |
|||
val barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) |
|||
val cutoutInsets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout()) |
|||
|
|||
val leftInsets = barInsets.left + cutoutInsets.left |
|||
val rightInsets = barInsets.right + cutoutInsets.right |
|||
|
|||
val mlpAppBar = binding.appbarLicenses.layoutParams as MarginLayoutParams |
|||
mlpAppBar.leftMargin = leftInsets |
|||
mlpAppBar.rightMargin = rightInsets |
|||
binding.appbarLicenses.layoutParams = mlpAppBar |
|||
|
|||
val mlpScrollAbout = binding.listLicenses.layoutParams as MarginLayoutParams |
|||
mlpScrollAbout.leftMargin = leftInsets |
|||
mlpScrollAbout.rightMargin = rightInsets |
|||
binding.listLicenses.layoutParams = mlpScrollAbout |
|||
|
|||
binding.listLicenses.updatePadding(bottom = barInsets.bottom) |
|||
|
|||
windowInsets |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
package org.yuzu.yuzu_emu.model |
|||
|
|||
import android.os.Parcelable |
|||
import kotlinx.parcelize.Parcelize |
|||
|
|||
@Parcelize |
|||
data class License( |
|||
val titleId: Int, |
|||
val descriptionId: Int, |
|||
val linkId: Int, |
|||
val copyrightId: Int, |
|||
val licenseId: Int |
|||
) : Parcelable |
|||
@ -0,0 +1,64 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
xmlns:tools="http://schemas.android.com/tools"> |
|||
|
|||
<androidx.core.widget.NestedScrollView |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content"> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="vertical" |
|||
android:layout_marginHorizontal="16dp"> |
|||
|
|||
<com.google.android.material.bottomsheet.BottomSheetDragHandleView |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_gravity="center_horizontal"/> |
|||
|
|||
<com.google.android.material.textview.MaterialTextView |
|||
style="@style/TextAppearance.Material3.HeadlineLarge" |
|||
android:id="@+id/text_title" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:gravity="center" |
|||
tools:text="@string/license_adreno_tools" /> |
|||
|
|||
<com.google.android.material.textview.MaterialTextView |
|||
style="@style/TextAppearance.Material3.BodyLarge" |
|||
android:id="@+id/text_link" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:gravity="center" |
|||
android:layout_marginTop="16dp" |
|||
android:autoLink="all" |
|||
tools:text="@string/license_adreno_tools_link" /> |
|||
|
|||
<com.google.android.material.textview.MaterialTextView |
|||
style="@style/TextAppearance.Material3.BodyLarge" |
|||
android:id="@+id/text_copyright" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:gravity="center" |
|||
android:layout_marginTop="16dp" |
|||
android:textStyle="bold" |
|||
tools:text="@string/license_adreno_tools_copyright" /> |
|||
|
|||
<com.google.android.material.textview.MaterialTextView |
|||
style="@style/TextAppearance.Material3.BodyMedium" |
|||
android:id="@+id/text_license" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_gravity="center" |
|||
android:layout_marginVertical="16dp" |
|||
android:autoLink="all" |
|||
tools:text="@string/license_adreno_tools_text" /> |
|||
|
|||
</LinearLayout> |
|||
|
|||
</androidx.core.widget.NestedScrollView> |
|||
|
|||
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
android:id="@+id/coordinator_licenses" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:background="?attr/colorSurface"> |
|||
|
|||
<com.google.android.material.appbar.AppBarLayout |
|||
android:id="@+id/appbar_licenses" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:fitsSystemWindows="true"> |
|||
|
|||
<com.google.android.material.appbar.MaterialToolbar |
|||
android:id="@+id/toolbar_licenses" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="?attr/actionBarSize" |
|||
app:title="@string/licenses" |
|||
app:navigationIcon="@drawable/ic_back" /> |
|||
|
|||
</com.google.android.material.appbar.AppBarLayout> |
|||
|
|||
<androidx.recyclerview.widget.RecyclerView |
|||
android:id="@+id/list_licenses" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> |
|||
|
|||
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue