You are currently viewing Adding Acknowledgements section in the Settings of the app

Adding Acknowledgements section in the Settings of the app

The Open Event Android app uses innumerable open source softwares. Fortunately, android allows us to give credit to each OSS (Open Source Software). We can do this just by writing a few lines of code. In this blog we will illustrate about how we are showing a list of acknowle- dgements in the Open Event Android app.

First of all we will add all the dependencies required. In the app level gradle file, we will add the plugin.

apply plugin: ‘com.google.gms.oss.licenses.plugin’

We then add the implementation of oss licences in the app level file of build.gradle

implementation ‘com.google.android.gms:play-services-oss-licenses:16.0.0’

After that we add the classpath to the project level gradle file in dependencies.

classpath “com.google.gms:oss-licenses:0.9.2”

The google() function must be added in maven for this to work. So, after adding all these dependencies, we click the Sync button in Android Studio. We wait for the project to refresh.

In our Settings Fragment file, we add another preference called “Acknowledgements”. Let us head into the code below. In the SettingsFragment file.

if (preference?.key == resources.getString(R.string.key_acknowledgements)) {

startActivity(Intent(context, OssLicensesMenuActivity::class.java))

return true

}

As we can see, we have added a conditional in the onPreferenceClickListener. If the user clicks on a preference whose key is “key_acknowledgements”, an OssLicensesMenyActivity opens in the app. This is a predefined activity and is only available after we have successfully integrated oss licences. Heading onto some xml code for the feature. We move onto settings.xml file.

<Preference

android:key=”@string/key_acknowledgements”

android:title=”@string/acknowledgements_settings” />

This section is present under the main PreferenceScreen. It is nested and is actually present under a PreferenceCategory named “About”. The final thing we do to complete the process successfully is store our strings in the strings.xml file.

<string name=”key_acknowledgements”>key_acknowledgements</string>

<string name=”acknowledgements_settings”>Acknowledgements</string>

Thus, this is how we are able to show the user a list of acknowledgements successfully in the Open Event android app.

Additional Resources

Tags: GSoC18, FOSSASIA, Open Event, Android, OSS

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.