1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-11-23 12:16:13 -06:00

Add about section in settings (#99)

This commit is contained in:
Mikołaj Pich 2018-05-07 16:05:57 +02:00 committed by Rafał Borcz
parent dd2c69601a
commit f29689c6cd
11 changed files with 161 additions and 8 deletions

View File

@ -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

View File

@ -40,6 +40,12 @@
android:label="@string/activity_dashboard_text"
android:launchMode="singleTop"
android:theme="@style/WulkanowyTheme" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/WulkanowyTheme.LoginTheme" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/WulkanowyTheme.LoginTheme" />
<service
android:name=".services.jobs.SyncJob"

View File

@ -165,9 +165,7 @@ public class Exam implements Serializable {
myDao.update(this);
}
/**
* called by internal mechanisms, do not call yourself.
*/
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 1730563422)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;

View File

@ -0,0 +1,67 @@
package io.github.wulkanowy.ui.main.settings;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.widget.Toast;
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
import io.github.wulkanowy.BuildConfig;
import io.github.wulkanowy.R;
import io.github.wulkanowy.utils.AppConstant;
public class AboutScreen extends SettingsFragment {
public static final String SHARED_KEY_ABOUT_VERSION = "about_version";
public static final String SHARED_KEY_ABOUT_LICENSES = "about_osl";
public static final String SHARED_KEY_ABOUT_REPO = "about_repo";
private Preference.OnPreferenceClickListener onProgrammerListener = new Preference.OnPreferenceClickListener() {
private int clicks = 0;
@Override
public boolean onPreferenceClick(Preference preference) {
Toast.makeText(getActivity(), getVersionToast(clicks++), Toast.LENGTH_SHORT).show();
return true;
}
private int getVersionToast(int click) {
if (0 == click) {
return R.string.about_programmer_step1;
}
if (1 == click) {
return R.string.about_programmer_step2;
}
if (9 > 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);
}
}

View File

@ -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)

View File

@ -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");
}

View File

@ -135,6 +135,18 @@
<string name="pref_services_interval">Interwał między odświeżaniem danych</string>
<string name="pref_services_mobile_data">Synchronizacja tylko przez WiFi</string>
<string name="pref_about_header">O aplikacji</string>
<string name="pref_about">Informacje o Wulkanowym</string>
<string name="pref_about_summary">Wulkanowy to nieoficjalny klient dziennika VULCAN UONET+</string>
<string name="pref_about_version">Wersja</string>
<string name="pref_about_osl">Licencje open source</string>
<string name="pref_about_osl_summary">Szczegóły licencji na oprogramowanie open source</string>
<string name="pref_about_support">Kod źródłowy i feedback</string>
<string name="about_programmer_step1">Nie, nie zostaniesz programistą!</string>
<string name="about_programmer_step2">Musisz bardziej się postarać!</string>
<string name="about_programmer_step3">Kliknij jeszcze parę razy</string>
<string name="about_programmer">Odwiedź zakładkę Kod źródłowy i pokaż jaki z ciebie programista!</string>
<string name="notify_grade_channel">Nowe oceny</string>
<string name="widget_timetable_no_lesson">Brak lekcji</string>
<string name="widget_timetable_today">Dziś</string>

View File

@ -130,6 +130,18 @@
<string name="pref_services_interval">Interval between data refreshing</string>
<string name="pref_services_mobile_data">Synchronization via WiFi only</string>
<string name="pref_about_header">About</string>
<string name="pref_about">About Wulkanowy</string>
<string name="pref_about_summary">Wulkanowy is an unofficial VULCAN UONET+ log client</string>
<string name="pref_about_version">Version</string>
<string name="pref_about_osl">Open source licenses</string>
<string name="pref_about_osl_summary">License details for open source software</string>
<string name="pref_about_support">Source code &amp; feedback</string>
<string name="about_programmer_step1">No, you will not become a programmer!</string>
<string name="about_programmer_step2">You must try harder!</string>
<string name="about_programmer_step3">Click a few more times</string>
<string name="about_programmer">Visit the Source code tab and show how good a programmer you are!</string>
<string name="notify_grade_channel">New grades</string>
<string name="widget_timetable_no_lesson">No lessons</string>
<string name="widget_timetable_today">Today</string>

View File

@ -6,7 +6,7 @@
<item name="colorAccent">@color/colorPrimary</item>
<item name="actionMenuTextColor">@android:color/primary_text_dark</item>
<item name="android:textColorPrimary">@android:color/primary_text_light</item>
<item name="android:textColorSecondary">@android:color/primary_text_light</item>
<item name="android:textColorSecondary">@android:color/secondary_text_light</item>
<item name="android:textColorSecondaryInverse">@android:color/primary_text_dark</item>
<item name="android:textColorTertiary">@android:color/primary_text_light</item>
<item name="android:textColorTertiaryInverse">@android:color/primary_text_dark</item>
@ -16,7 +16,7 @@
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
<style name="WulkanowyTheme.LoginTheme" parent="@style/Theme.AppCompat.Light">
<style name="WulkanowyTheme.LoginTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>

View File

@ -45,4 +45,27 @@
android:key="notify_enable"
android:title="@string/pref_notify_switch" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_about_header">
<PreferenceScreen
android:key="pref_about"
android:title="@string/pref_about"
android:persistent="false">
<PreferenceCategory android:title="@string/pref_about">
<Preference
android:selectable="false"
android:summary="@string/pref_about_summary"/>
<Preference
android:key="about_version"
android:title="@string/pref_about_version"/>
<Preference
android:key="about_osl"
android:title="@string/pref_about_osl"
android:summary="@string/pref_about_osl_summary"/>
<Preference
android:key="about_repo"
android:title="@string/pref_about_support">
</Preference>
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>

View File

@ -14,7 +14,6 @@ buildscript {
}
plugins {
// gradle dependencyUpdates -Drevision=release
id "com.github.ben-manes.versions" version "0.17.0"
}
@ -45,10 +44,11 @@ ext {
greenDaoGradle = "3.2.2"
butterknife = "8.8.1"
threeTenABP = "1.1.0"
dagger2 = "2.15"
dagger2 = "2.16"
ahbottom = "2.2.0"
jsoup = "1.11.3"
gson = "2.8.4"
ossLicenses = "15.0.1"
debugDb = "1.0.3"
sqlcipher = "3.5.9"