diff --git a/app/build.gradle b/app/build.gradle index fdb72bf..05f9890 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,10 +1,8 @@ apply plugin: 'com.android.application' - apply plugin: 'kotlin-android' - apply plugin: 'kotlin-android-extensions' - apply plugin: 'kotlin-kapt' +apply plugin: 'com.jaredsburrows.license' android { compileSdkVersion 29 @@ -37,7 +35,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.1.0' implementation 'com.google.android.material:material:1.0.0' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e23c585..564207b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,6 +21,10 @@ + diff --git a/app/src/main/assets/open_source_licenses.html b/app/src/main/assets/open_source_licenses.html new file mode 100644 index 0000000..2eb3689 --- /dev/null +++ b/app/src/main/assets/open_source_licenses.html @@ -0,0 +1,432 @@ + + + + Open source licenses + + +

Notice for packages:

+ + + diff --git a/app/src/main/java/net/underdesk/circolapp/LicensesActivity.kt b/app/src/main/java/net/underdesk/circolapp/LicensesActivity.kt new file mode 100644 index 0000000..f8b9483 --- /dev/null +++ b/app/src/main/java/net/underdesk/circolapp/LicensesActivity.kt @@ -0,0 +1,32 @@ +/* + * Circolapp + * Copyright (C) 2019 Matteo Schiff + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.underdesk.circolapp + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.activity_licenses.* + +class LicensesActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_licenses) + licenses_webview.loadUrl("file:///android_asset/open_source_licenses.html") + } +} diff --git a/app/src/main/java/net/underdesk/circolapp/MainActivity.kt b/app/src/main/java/net/underdesk/circolapp/MainActivity.kt index ca7b476..5f1acae 100644 --- a/app/src/main/java/net/underdesk/circolapp/MainActivity.kt +++ b/app/src/main/java/net/underdesk/circolapp/MainActivity.kt @@ -18,7 +18,12 @@ package net.underdesk.circolapp +import android.content.Context +import android.content.Intent import android.os.Bundle +import android.view.Menu +import android.view.MenuItem +import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.navigation.findNavController import androidx.navigation.ui.AppBarConfiguration @@ -48,5 +53,50 @@ class MainActivity : AppCompatActivity() { navView.setupWithNavController(navController) PollWork.enqueue(this) + + if (getPreferences(Context.MODE_PRIVATE).getBoolean("first_start", true)) { + showInfoDialog() + + getPreferences(Context.MODE_PRIVATE).edit().apply { + putBoolean("first_start", false) + apply() + } + } + } + + override fun onCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.menu_main, menu) + return true + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + // Handle item selection + return when (item.itemId) { + R.id.menu_main_about -> { + showInfoDialog() + true + } + else -> super.onOptionsItemSelected(item) + } + } + + private fun showInfoDialog() { + val builder = AlertDialog.Builder(this) + builder.apply { + setTitle(R.string.dialog_info_title) + setMessage(R.string.dialog_info_content) + setPositiveButton( + R.string.dialog_ok + ) { dialog, _ -> + dialog.dismiss() + } + setNeutralButton( + R.string.dialog_licenses + ) { _, _ -> + startActivity(Intent(this@MainActivity, LicensesActivity::class.java)) + } + } + + builder.create().show() } } diff --git a/app/src/main/res/layout/activity_licenses.xml b/app/src/main/res/layout/activity_licenses.xml new file mode 100644 index 0000000..36f33cf --- /dev/null +++ b/app/src/main/res/layout/activity_licenses.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml new file mode 100644 index 0000000..ae71f2f --- /dev/null +++ b/app/src/main/res/menu/menu_main.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 29774c3..a3f7dc9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,6 +3,9 @@ Circular letters Favourites Reminders + Third party licenses + + About Circular letter number %1$d New circulars published @@ -22,6 +25,12 @@ OK Next Cancel + Show third party licenses + + About Circolapp + Circolapp is released under the GPL v3 license (https://github.com/Matte23/circolapp/blob/master/LICENSE):\n\n + © 2019 Matteo Schiff\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it + under certain conditions. Network not available. Results may be outdated diff --git a/build.gradle b/build.gradle index eccd7a6..d57d9cc 100644 --- a/build.gradle +++ b/build.gradle @@ -10,6 +10,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.jaredsburrows:gradle-license-plugin:0.8.5' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }