From f29689c6cd7cd692338c18dba65f100b965ba3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Mon, 7 May 2018 16:05:57 +0200 Subject: [PATCH] Add about section in settings (#99) --- app/build.gradle | 4 ++ app/src/main/AndroidManifest.xml | 6 ++ .../wulkanowy/data/db/dao/entities/Exam.java | 4 +- .../ui/main/settings/AboutScreen.java | 67 +++++++++++++++++++ .../ui/main/settings/SettingsFragment.java | 31 ++++++++- .../github/wulkanowy/utils/AppConstant.java | 2 + app/src/main/res/values-pl/strings.xml | 12 ++++ app/src/main/res/values/strings.xml | 12 ++++ app/src/main/res/values/styles.xml | 4 +- app/src/main/res/xml/preferences.xml | 23 +++++++ build.gradle | 4 +- 11 files changed, 161 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/io/github/wulkanowy/ui/main/settings/AboutScreen.java diff --git a/app/build.gradle b/app/build.gradle index 634471511..d52336979 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,11 +2,13 @@ buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } maven { url 'https://maven.fabric.io/public' } + google() } dependencies { classpath "org.greenrobot:greendao-gradle-plugin:$greenDaoGradle" classpath "io.fabric.tools:gradle:$fabricGradle" + classpath "com.google.gms:oss-licenses:0.9.2" } } @@ -19,6 +21,7 @@ apply plugin: 'org.greenrobot.greendao' apply plugin: 'io.fabric' apply from: '../jacoco.gradle' apply from: '../android-sonarqube.gradle' +apply plugin: 'com.google.gms.oss.licenses.plugin' android { compileSdkVersion 26 @@ -87,6 +90,7 @@ dependencies { implementation "com.google.dagger:dagger-android-support:$dagger2" implementation "com.aurelhubert:ahbottomnavigation:$ahbottom" implementation "com.jakewharton.threetenabp:threetenabp:$threeTenABP" + implementation "com.google.android.gms:play-services-oss-licenses:$ossLicenses" implementation("com.crashlytics.sdk.android:crashlytics:$crashlyticsSdk@aar") { transitive = true diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2abcf5e7b..2c5567410 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -40,6 +40,12 @@ android:label="@string/activity_dashboard_text" android:launchMode="singleTop" android:theme="@style/WulkanowyTheme" /> + + click) { + return R.string.about_programmer_step3; + } + + return R.string.about_programmer; + } + }; + + public AboutScreen() { + // silence is golden + } + + @Override + public void onCreate(final Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + findPreference(SHARED_KEY_ABOUT_VERSION).setSummary(BuildConfig.VERSION_NAME); + findPreference(SHARED_KEY_ABOUT_VERSION).setOnPreferenceClickListener(onProgrammerListener); + findPreference(SHARED_KEY_ABOUT_REPO).setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(AppConstant.REPO_URL))); + findPreference(SHARED_KEY_ABOUT_LICENSES).setIntent(new Intent(getActivity(), OssLicensesMenuActivity.class) + .putExtra("title", getString(R.string.pref_about_osl))); + } + + @Override + public void onCreatePreferences(Bundle bundle, String rootKey) { + setPreferencesFromResource(R.xml.preferences, rootKey); + } +} diff --git a/app/src/main/java/io/github/wulkanowy/ui/main/settings/SettingsFragment.java b/app/src/main/java/io/github/wulkanowy/ui/main/settings/SettingsFragment.java index 8b53f0773..e08a49026 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/main/settings/SettingsFragment.java +++ b/app/src/main/java/io/github/wulkanowy/ui/main/settings/SettingsFragment.java @@ -2,13 +2,17 @@ package io.github.wulkanowy.ui.main.settings; import android.content.SharedPreferences; import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; import android.support.v7.preference.PreferenceFragmentCompat; +import android.support.v7.preference.PreferenceScreen; import io.github.wulkanowy.R; import io.github.wulkanowy.services.jobs.SyncJob; public class SettingsFragment extends PreferenceFragmentCompat - implements SharedPreferences.OnSharedPreferenceChangeListener { + implements SharedPreferences.OnSharedPreferenceChangeListener, + PreferenceFragmentCompat.OnPreferenceStartScreenCallback{ public static final String SHARED_KEY_START_TAB = "startup_tab"; @@ -29,6 +33,31 @@ public class SettingsFragment extends PreferenceFragmentCompat addPreferencesFromResource(R.xml.preferences); } + @Override + public void onCreate(final Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public Fragment getCallbackFragment() { + return this; + } + + @Override + public boolean onPreferenceStartScreen(PreferenceFragmentCompat preferenceFragmentCompat, + PreferenceScreen preferenceScreen) { + FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); + AboutScreen fragment = new AboutScreen(); + Bundle args = new Bundle(); + args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey()); + fragment.setArguments(args); + ft.add(R.id.main_activity_container, fragment, preferenceScreen.getKey()); + ft.addToBackStack(preferenceScreen.getKey()); + ft.commit(); + + return true; + } + @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(SHARED_KEY_SERVICES_ENABLE) || key.equals(SHARED_KEY_SERVICES_INTERVAL) diff --git a/app/src/main/java/io/github/wulkanowy/utils/AppConstant.java b/app/src/main/java/io/github/wulkanowy/utils/AppConstant.java index 27d76e756..2499974d5 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/AppConstant.java +++ b/app/src/main/java/io/github/wulkanowy/utils/AppConstant.java @@ -19,6 +19,8 @@ public final class AppConstant { public static final String DATE_PATTERN = "yyyy-MM-dd"; + public static final String REPO_URL = "https://github.com/wulkanowy/wulkanowy"; + private AppConstant() { throw new IllegalStateException("Utility class"); } diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 41eda2739..942dc4317 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -135,6 +135,18 @@ Interwał między odświeżaniem danych Synchronizacja tylko przez WiFi + O aplikacji + Informacje o Wulkanowym + Wulkanowy to nieoficjalny klient dziennika VULCAN UONET+ + Wersja + Licencje open source + Szczegóły licencji na oprogramowanie open source + Kod źródłowy i feedback + Nie, nie zostaniesz programistą! + Musisz bardziej się postarać! + Kliknij jeszcze parę razy + Odwiedź zakładkę Kod źródłowy i pokaż jaki z ciebie programista! + Nowe oceny Brak lekcji Dziś diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 630592835..2130120e6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -130,6 +130,18 @@ Interval between data refreshing Synchronization via WiFi only + About + About Wulkanowy + Wulkanowy is an unofficial VULCAN UONET+ log client + Version + Open source licenses + License details for open source software + Source code & feedback + No, you will not become a programmer! + You must try harder! + Click a few more times + Visit the Source code tab and show how good a programmer you are! + New grades No lessons Today diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 07ec76646..d72afb53c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -6,7 +6,7 @@ @color/colorPrimary @android:color/primary_text_dark @android:color/primary_text_light - @android:color/primary_text_light + @android:color/secondary_text_light @android:color/primary_text_dark @android:color/primary_text_light @android:color/primary_text_dark @@ -16,7 +16,7 @@ @style/PreferenceThemeOverlay.v14.Material -