Skip to content

Commit

Permalink
feat: add automatically generated oss license screen (#2543)
Browse files Browse the repository at this point in the history
Co-authored-by: Anashuman Singh <125425881+AsCress@users.noreply.github.com>
  • Loading branch information
marcnause and AsCress authored Sep 1, 2024
1 parent 424a9f3 commit 5d6b449
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 3 deletions.
7 changes: 6 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("com.android.application")
id("com.google.android.gms.oss-licenses-plugin")
}

apply(plugin = "realm-android")
Expand All @@ -17,7 +18,7 @@ android {
targetSdk = 34
versionCode = System.getenv("VERSION_CODE")?.toInt() ?: 1
versionName = System.getenv("VERSION_NAME") ?: "1.0.0"
resConfigs("en","ru","ar","si","pl")
resConfigs("en", "ru", "ar", "si", "pl")
}

signingConfigs {
Expand Down Expand Up @@ -114,4 +115,8 @@ dependencies {

// Realm
implementation("com.github.realm:realm-android-adapters:v4.0.0")

// OSS license plugin
implementation("com.google.android.gms:play-services-oss-licenses:17.1.0")

}
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
<activity
android:name=".activity.DustSensorActivity"
android:screenOrientation="fullSensor" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/OssLicenseScreenTheme" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/OssLicenseScreenTheme" />

<receiver android:name=".receivers.USBDetachReceiver" />

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/io/pslab/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.snackbar.Snackbar;

Expand Down Expand Up @@ -324,6 +325,10 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
drawer.closeDrawers();
}
break;
case R.id.nav_third_party_libs:
OssLicensesMenuActivity.setActivityTitle(getString(R.string.third_party_libs));
startActivity(new Intent(MainActivity.this, OssLicensesMenuActivity.class));
break;
default:
navItemIndex = 0;
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/baseline_attribution_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M12,8.5c-0.91,0 -2.75,0.46 -2.75,1.38v4.62h1.5V19h2.5v-4.5h1.5V9.88C14.75,8.97 12.91,8.5 12,8.5z"/>

<path android:fillColor="@android:color/white" android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10s10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8s8,3.58 8,8S16.42,20 12,20z"/>

<path android:fillColor="@android:color/white" android:pathData="M12,6.5m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0"/>

</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_star_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>

</vector>
8 changes: 6 additions & 2 deletions app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<item
android:id="@+id/nav_rate"
android:checkable="true"
android:icon="@android:drawable/btn_star"
android:icon="@drawable/baseline_star_24"
android:title="@string/rateapp" />
<item
android:id="@+id/nav_buy_pslab"
Expand All @@ -64,6 +64,10 @@
<item
android:id="@+id/nav_privacy_policy"
android:icon="@drawable/baseline_article_24"
android:title="@string/privacy_policy"/>
android:title="@string/privacy_policy" />
<item
android:id="@+id/nav_third_party_libs"
android:icon="@drawable/baseline_attribution_24"
android:title="@string/third_party_libs" />
</group>
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@
<string name="unit_volts">\u0020V</string>
<string name="no_playback_data">No data to display</string>
<string name="privacy_policy">Privacy Policy</string>
<string name="third_party_libs">Open Source Licenses</string>
<string name="auto_scale_error">No input found</string>
<string name="auto_scale">Auto</string>
<string name="control_stop">Stop</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<item name="colorPrimaryDark">@color/darkWhite</item>
</style>

<style name="OssLicenseScreenTheme" parent="AppTheme">
<item name="windowActionBar">true</item>
<item name="windowNoTitle">false</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
Expand Down
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ buildscript {
}
dependencies {
classpath("io.realm:realm-gradle-plugin:10.18.0")
classpath("com.google.android.gms:oss-licenses-plugin:0.10.6")

}
}

Expand Down

0 comments on commit 5d6b449

Please sign in to comment.