-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add open sources licenses section in About page
Fixes #15
- Loading branch information
1 parent
005366c
commit 1a9e076
Showing
11 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
about/src/main/java/com/haroldadmin/moonshot/about/Licenses.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.haroldadmin.moonshot.about | ||
|
||
val licenses = mapOf( | ||
"Kotlin Programming Language" to "https://github.com/JetBrains/kotlin/blob/master/license/LICENSE.txt", | ||
"Kotlin Coroutines" to "https://github.com/Kotlin/kotlinx.coroutines/blob/master/LICENSE.txt", | ||
"Koin" to "https://github.com/InsertKoinIO/koin/blob/master/LICENSE", | ||
"AndroidX" to "https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/LICENSE.txt", | ||
"Material Components for Android" to "https://github.com/material-components/material-components-android/blob/master/LICENSE", | ||
"Vector" to "https://github.com/haroldadmin/Vector/blob/master/LICENSE", | ||
"Epoxy" to "https://github.com/airbnb/epoxy/blob/master/LICENSE", | ||
"Coil" to "https://github.com/coil-kt/coil/blob/master/LICENSE.txt", | ||
"Lemniscate" to "https://github.com/VladimirWrites/Lemniscate/blob/master/LICENSE", | ||
"Lottie" to "https://github.com/airbnb/lottie-android/blob/master/LICENSE", | ||
"JodaTime" to "https://github.com/JodaOrg/joda-time/blob/master/LICENSE.txt", | ||
"Retrofit" to "https://github.com/square/retrofit/blob/master/LICENSE.txt", | ||
"OkHttp" to "https://github.com/square/okhttp/", | ||
"NetworkResponseAdapter" to "https://github.com/haroldadmin/NetworkResponseAdapter/blob/master/LICENSE", | ||
"Moshi" to "https://github.com/square/moshi/blob/master/LICENSE.txt", | ||
"JUnit" to "https://junit.org/junit4/license.html", | ||
"KotlinTest" to "https://github.com/kotlintest/kotlintest.git", | ||
"MockK" to "https://github.com/mockk/mockk/blob/master/LICENSE", | ||
"SpaceX-API" to "https://github.com/r-spacex/SpaceX-API/blob/master/LICENSE" | ||
) |
49 changes: 49 additions & 0 deletions
49
about/src/main/java/com/haroldadmin/moonshot/about/LicensesFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.haroldadmin.moonshot.about | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DividerItemDecoration | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.airbnb.epoxy.EpoxyController | ||
import com.airbnb.epoxy.EpoxyRecyclerView | ||
import com.haroldadmin.moonshot.about.views.licenseView | ||
import com.haroldadmin.moonshot.base.MoonShotFragment | ||
import com.haroldadmin.moonshot.base.simpleController | ||
|
||
class LicensesFragment: MoonShotFragment() { | ||
|
||
private lateinit var rvLicenses: EpoxyRecyclerView | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
val root = inflater.inflate(R.layout.fragment_licenses, container, false) | ||
rvLicenses = root.findViewById(R.id.rvLicenses) | ||
rvLicenses.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayoutManager.VERTICAL)) | ||
return root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
rvLicenses.setControllerAndBuildModels(epoxyController) | ||
} | ||
|
||
private val epoxyController: EpoxyController = simpleController { | ||
licenses.map { licenseEntry -> | ||
licenseView { | ||
id(licenseEntry.key) | ||
license(licenseEntry.key) | ||
onClick { _ -> | ||
Intent().apply { | ||
action = Intent.ACTION_VIEW | ||
data = Uri.parse(licenseEntry.value) | ||
}.also { | ||
startActivity(it) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
about/src/main/java/com/haroldadmin/moonshot/about/views/LicenseView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.haroldadmin.moonshot.about.views | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.util.AttributeSet | ||
import android.widget.FrameLayout | ||
import androidx.appcompat.widget.AppCompatTextView | ||
import com.airbnb.epoxy.CallbackProp | ||
import com.airbnb.epoxy.ModelProp | ||
import com.airbnb.epoxy.ModelView | ||
import com.airbnb.epoxy.OnViewRecycled | ||
import com.haroldadmin.moonshot.about.R | ||
import com.haroldadmin.moonshot.utils.asyncText | ||
|
||
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT) | ||
class LicenseView @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : FrameLayout(context, attrs, defStyleAttr) { | ||
|
||
init { | ||
inflate(context, R.layout.view_license, this) | ||
} | ||
|
||
private val license: AppCompatTextView = findViewById(R.id.license) | ||
|
||
@ModelProp | ||
fun setLicense(name: String) { | ||
license.asyncText(name) | ||
} | ||
|
||
@CallbackProp | ||
fun setOnClick(onClick: OnClickListener?) { | ||
if (onClick != null) { | ||
rootView.setOnClickListener(onClick) | ||
} | ||
} | ||
|
||
@OnViewRecycled | ||
fun cleanup() { | ||
rootView.setOnClickListener(null) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="14dp" | ||
android:height="16dp" | ||
android:viewportWidth="14" | ||
android:viewportHeight="16"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M7,4c-0.83,0 -1.5,-0.67 -1.5,-1.5S6.17,1 7,1s1.5,0.67 1.5,1.5S7.83,4 7,4zM14,10c0,1.11 -0.89,2 -2,2h-1c-1.11,0 -2,-0.89 -2,-2l2,-4h-1c-0.55,0 -1,-0.45 -1,-1L8,5v8c0.42,0 1,0.45 1,1h1c0.42,0 1,0.45 1,1L3,15c0,-0.55 0.58,-1 1,-1h1c0,-0.55 0.58,-1 1,-1h0.03L6,5L5,5c0,0.55 -0.45,1 -1,1L3,6l2,4c0,1.11 -0.89,2 -2,2L2,12c-1.11,0 -2,-0.89 -2,-2l2,-4L1,6L1,5h3c0,-0.55 0.45,-1 1,-1h4c0.55,0 1,0.45 1,1h3v1h-1l2,4zM2.5,7L1,10h3L2.5,7zM13,10l-1.5,-3 -1.5,3h3z" | ||
android:fillType="evenOdd"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/colorSurface"> | ||
|
||
<com.airbnb.epoxy.EpoxyRecyclerView | ||
android:id="@+id/rvLicenses" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:itemCount="5" | ||
tools:listitem="@layout/view_license" /> | ||
|
||
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<merge xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
<androidx.appcompat.widget.AppCompatTextView | ||
android:id="@+id/license" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="26sp" | ||
android:textColor="?attr/colorOnSurface" | ||
android:layout_margin="@dimen/marginLarge" | ||
tools:text="AndroidX"/> | ||
</merge> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters