From 4a62aff7d2bda038ffb211b245f0c9e901d2ce56 Mon Sep 17 00:00:00 2001 From: Tamim Hossain <132823494+CodeWithTamim@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:04:37 +0600 Subject: [PATCH] Add OSS Licenses Plugin to Display Open Source Licenses (#4022) ### Commit Message - Integrated Google OSS Licenses Plugin to display the licenses of third-party libraries used in the app. - Added the plugin to app-level Gradle file and included the required dependencies. - Created a pre-built activity (`OssLicensesMenuActivity`) to show the licenses, accessible via a button/menu. - Verified the implementation, ensuring the licenses are displayed correctly. - Tested on release builds to confirm functionality and compliance. This implementation ensures transparency and complies with open-source license requirements. --- V2rayNG/app/build.gradle.kts | 3 +++ .../java/com/v2ray/ang/ui/AboutActivity.kt | 5 ++++ .../src/main/res/drawable/license_24px.xml | 10 ++++++++ .../src/main/res/layout/activity_about.xml | 24 +++++++++++++++++++ V2rayNG/app/src/main/res/values/strings.xml | 1 + V2rayNG/build.gradle.kts | 9 ++++++- V2rayNG/gradle/libs.versions.toml | 4 ++++ 7 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 V2rayNG/app/src/main/res/drawable/license_24px.xml diff --git a/V2rayNG/app/build.gradle.kts b/V2rayNG/app/build.gradle.kts index 2a7c7872..971de3b6 100644 --- a/V2rayNG/app/build.gradle.kts +++ b/V2rayNG/app/build.gradle.kts @@ -1,6 +1,7 @@ plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) + id("com.google.android.gms.oss-licenses-plugin") } android { @@ -145,4 +146,6 @@ dependencies { androidTestImplementation(libs.androidx.espresso.core) testImplementation(libs.org.mockito.mockito.inline) testImplementation(libs.mockito.kotlin) + // Oss Licenses + implementation(libs.play.services.oss.licenses) } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/AboutActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/AboutActivity.kt index 612de540..59ed0505 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/AboutActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/AboutActivity.kt @@ -20,6 +20,8 @@ import com.v2ray.ang.util.ZipUtil import java.io.File import java.text.SimpleDateFormat import java.util.Locale +import com.google.android.gms.oss.licenses.OssLicensesMenuActivity + class AboutActivity : BaseActivity() { private val binding by lazy { ActivityAboutBinding.inflate(layoutInflater) } @@ -87,6 +89,9 @@ class AboutActivity : BaseActivity() { binding.layoutFeedback.setOnClickListener { Utils.openUri(this, AppConfig.v2rayNGIssues) } + binding.layoutOssLicenses.setOnClickListener{ + startActivity(Intent(this, OssLicensesMenuActivity::class.java)) + } binding.layoutTgChannel.setOnClickListener { Utils.openUri(this, AppConfig.TgChannelUrl) diff --git a/V2rayNG/app/src/main/res/drawable/license_24px.xml b/V2rayNG/app/src/main/res/drawable/license_24px.xml new file mode 100644 index 00000000..99b9354b --- /dev/null +++ b/V2rayNG/app/src/main/res/drawable/license_24px.xml @@ -0,0 +1,10 @@ + + + diff --git a/V2rayNG/app/src/main/res/layout/activity_about.xml b/V2rayNG/app/src/main/res/layout/activity_about.xml index 37b889f9..15262fd6 100644 --- a/V2rayNG/app/src/main/res/layout/activity_about.xml +++ b/V2rayNG/app/src/main/res/layout/activity_about.xml @@ -135,6 +135,30 @@ android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> + + + + + + + Privacy policy About Source code + Open Source licenses Telegram channel Backup configuration Storage location: [%s], The backup will be cleared after uninstalling the app or clearing the storage diff --git a/V2rayNG/build.gradle.kts b/V2rayNG/build.gradle.kts index f55768e8..82e677d9 100644 --- a/V2rayNG/build.gradle.kts +++ b/V2rayNG/build.gradle.kts @@ -3,4 +3,11 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.kotlin.android) apply false -} \ No newline at end of file +} + +buildscript { + dependencies { + classpath(libs.oss.licenses.plugin) + } +} + diff --git a/V2rayNG/gradle/libs.versions.toml b/V2rayNG/gradle/libs.versions.toml index 6cf7ef5a..222e917b 100644 --- a/V2rayNG/gradle/libs.versions.toml +++ b/V2rayNG/gradle/libs.versions.toml @@ -11,6 +11,8 @@ activity = "1.9.3" constraintlayout = "2.2.0" mmkvStatic = "1.3.9" gson = "2.11.0" +ossLicensesPlugin = "0.10.6" +playServicesOssLicenses = "17.1.0" rxjava = "3.1.9" rxandroid = "3.0.2" rxpermissions = "0.12" @@ -36,6 +38,8 @@ androidx-activity = { group = "androidx.activity", name = "activity", version.re androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } mmkv-static = { module = "com.tencent:mmkv-static", version.ref = "mmkvStatic" } gson = { module = "com.google.code.gson:gson", version.ref = "gson" } +oss-licenses-plugin = { module = "com.google.android.gms:oss-licenses-plugin", version.ref = "ossLicensesPlugin" } +play-services-oss-licenses = { module = "com.google.android.gms:play-services-oss-licenses", version.ref = "playServicesOssLicenses" } rxjava = { module = "io.reactivex.rxjava3:rxjava", version.ref = "rxjava" } rxandroid = { module = "io.reactivex.rxjava3:rxandroid", version.ref = "rxandroid" } rxpermissions = { module = "com.github.tbruyelle:rxpermissions", version.ref = "rxpermissions" }