Skip to content

Commit

Permalink
Revamp LicenseDialog + Update Licenses + Stop Bintray Usage
Browse files Browse the repository at this point in the history
* Update licenses for dependent projects
* Add copyright notices (as provided)
* Revamp styling for `LicenseDialog` 
* Fix invisible `PreferenceDialog` buttons in Settings
* Consolidating color variables into `colorPrimary`, `backgroundColor` and `backgroundColorVariant`
* Use `com.google.android.flexbox:flexbox:3.0.0` (Google Maven) rather than `com.google.android:flexbox:2.0.1` (Bintray)
  • Loading branch information
PixelyIon committed Oct 26, 2021
1 parent bbf28d1 commit 1d57bab
Show file tree
Hide file tree
Showing 16 changed files with 319 additions and 141 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ dependencies {
implementation 'androidx.fragment:fragment-ktx:1.3.6'
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation 'com.google.android:flexbox:2.0.1'
implementation 'com.google.android.flexbox:flexbox:3.0.0'

/* Kotlin */
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/cpp/emu_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication(

InputWeak.reset();

logger->InfoNoPrefix("Emulation has ended");

auto end{std::chrono::steady_clock::now()};
logger->InfoNoPrefix("Done in: {} ms", (std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()));
logger->Write(skyline::Logger::LogLevel::Info, fmt::format("Emulation has ended in {}ms", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()));

close(romFd);
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/emu/skyline/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class MainActivity : AppCompatActivity() {
setupAppList()

binding.swipeRefreshLayout.apply {
setProgressBackgroundColorSchemeColor(obtainStyledAttributes(intArrayOf(R.attr.colorPrimary)).use { it.getColor(0, Color.BLACK) })
setProgressBackgroundColorSchemeColor(getColor(R.color.backgroundColorVariant))
setColorSchemeColors(obtainStyledAttributes(intArrayOf(R.attr.colorAccent)).use { it.getColor(0, Color.BLACK) })
post { setDistanceToTriggerSync(binding.swipeRefreshLayout.height / 3) }
setOnRefreshListener { loadRoms(false) }
Expand Down Expand Up @@ -150,6 +150,7 @@ class MainActivity : AppCompatActivity() {
post { startTitleAnimation() }
}
}

window.decorView.findViewById<View>(android.R.id.content).viewTreeObserver.addOnTouchModeChangeListener { isInTouchMode ->
refreshIconVisible = !isInTouchMode
}
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/java/emu/skyline/preference/LicenseDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ package emu.skyline.preference
import android.graphics.Rect
import android.os.Bundle
import android.view.*
import androidx.fragment.app.DialogFragment
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import emu.skyline.databinding.LicenseDialogBinding

/**
* This dialog is used to display the contents of a license for a particular project
* Dialog for displaying the contents of a license for a particular library
*/
class LicenseDialog : DialogFragment() {
class LicenseDialog : BottomSheetDialogFragment() {
private lateinit var binding : LicenseDialogBinding

/**
Expand All @@ -35,8 +35,12 @@ class LicenseDialog : DialogFragment() {
override fun onViewCreated(view : View, savedInstanceState : Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.licenseUrl.text = requireArguments().getString("libraryUrl")
binding.licenseContent.text = getString(requireArguments().getInt("libraryLicense"))
binding.libraryTitle.text = requireArguments().getString(LicensePreference.LIBRARY_TITLE_ARG)
binding.libraryUrl.text = requireArguments().getString(LicensePreference.LIBRARY_URL_ARG)
binding.libraryCopyright.text = requireArguments().getString(LicensePreference.LIBRARY_COPYRIGHT_ARG)
if (binding.libraryCopyright.text.isEmpty())
binding.libraryCopyright.visibility = View.GONE
binding.licenseContent.text = getString(requireArguments().getInt(LicensePreference.LIBRARY_LICENSE_ARG))

dialog?.setOnKeyListener { _, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_BUTTON_B && event.action == KeyEvent.ACTION_UP) {
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/emu/skyline/preference/LicensePreference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ class LicensePreference @JvmOverloads constructor(context : Context?, attrs : At
private val fragmentManager = (context as AppCompatActivity).supportFragmentManager

companion object {
private const val LIBRARY_URL_ARG = "libraryUrl"
private const val LIBRARY_LICENSE_ARG = "libraryLicense"
const val LIBRARY_TITLE_ARG = "libraryTitle"
const val LIBRARY_URL_ARG = "libraryUrl"
const val LIBRARY_COPYRIGHT_ARG = "libraryCopyright"
const val LIBRARY_LICENSE_ARG = "libraryLicense"

private val DIALOG_TAG = LicensePreference::class.java.simpleName
}

/**
* The copyright notice of the library
*/
private var libraryCopyright : String? = null

/**
* The URL of the library
*/
Expand All @@ -43,7 +50,7 @@ class LicensePreference @JvmOverloads constructor(context : Context?, attrs : At
for (i in 0 until attrs!!.attributeCount) {
when (attrs.getAttributeName(i)) {
LIBRARY_URL_ARG -> libraryUrl = attrs.getAttributeValue(i)

LIBRARY_COPYRIGHT_ARG -> libraryCopyright = attrs.getAttributeValue(i)
LIBRARY_LICENSE_ARG -> libraryLicense = attrs.getAttributeValue(i).substring(1).toInt()
}
}
Expand All @@ -56,7 +63,9 @@ class LicensePreference @JvmOverloads constructor(context : Context?, attrs : At
fragmentManager.findFragmentByTag(DIALOG_TAG) ?: run {
LicenseDialog().apply {
arguments = Bundle().apply {
putString(LIBRARY_TITLE_ARG, title.toString())
putString(LIBRARY_URL_ARG, libraryUrl)
putString(LIBRARY_COPYRIGHT_ARG, libraryCopyright)
putInt(LIBRARY_LICENSE_ARG, libraryLicense)
}
}.show(fragmentManager, DIALOG_TAG)
Expand Down
58 changes: 41 additions & 17 deletions app/src/main/res/layout/license_dialog.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
xmlns:tools="http://schemas.android.com/tools"
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:paddingHorizontal="2.5dp"
android:paddingTop="10dp">

<TextView
android:id="@+id/library_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
android:textSize="25sp"
tools:text="Skyline" />

<TextView
android:id="@+id/library_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="10dp">
android:autoLink="web"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
android:textSize="15sp"
tools:text="https://github.com/skyline-emu/skyline" />

<TextView
android:id="@+id/license_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textSize="15sp" />
android:id="@+id/library_copyright"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline4"
android:textSize="17sp"
tools:text="Copyright © 2019-2021 Skyline Team and Contributors (https://github.com/skyline-emu/)" />

<TextView
android:id="@+id/license_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" />
android:id="@+id/license_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:paddingTop="10dp"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
tools:text="@string/mpl2_license" />

</LinearLayout>
</ScrollView>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/titlebar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
app:elevation="0dp"
android:fitsSystemWindows="true">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:elevation="16dp"
app:layout_scrollFlags="scroll" />
</com.google.android.material.appbar.AppBarLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#FF424242</color>
<color name="colorPrimaryVariant">#FF121212</color>
<color name="backgroundColor">#FF121212</color>
<color name="backgroundColorVariant">#323232</color>
</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@
<!-- Whether the preference should request a game list refresh or not. Defaults to false. -->
<attr format="boolean" name="refreshRequired"/>
</declare-styleable>
<declare-styleable name="LicensePreference">
<!-- An optional copyright notice for the library -->
<attr format="string" name="libraryCopyright"/>
<!-- A reference to a string resource containing the license of the library -->
<attr format="reference" name="libraryLicense"/>
<!-- A URL to the library -->
<attr format="string" name="libraryUrl"/>
</declare-styleable>
</resources>
6 changes: 3 additions & 3 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">@color/cardview_light_background</color>
<color name="colorPrimaryVariant">@android:color/white</color>
<color name="colorOnPrimary">#FFFF0000</color>
<color name="colorPrimary">#FFFF0000</color>
<color name="backgroundColor">@android:color/white</color>
<color name="backgroundColorVariant">#F8F8F8</color>
</resources>
Loading

0 comments on commit 1d57bab

Please sign in to comment.