1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-12-22 10:58:01 +01:00

Merge license and changelog dialog on first start

This commit is contained in:
Gregor Santner 2018-04-08 09:01:52 +02:00
parent 82ccc54436
commit d53128e5cb
No known key found for this signature in database
GPG key ID: 7E83A7834AECB009
7 changed files with 20 additions and 25 deletions

View file

@ -263,7 +263,7 @@ public class AboutActivity extends ThemedActivity
contributors.setTextFormatted(getString(R.string.fragment_license__contributors_thank_you,
ContextUtils.get().loadMarkdownForTextViewFromRaw(R.raw.contributors, "")));
thirdPartyLibs.setTextFormatted(
ContextUtils.get().loadMarkdownForTextViewFromRaw(R.raw.license_third_party, ""));
ContextUtils.get().loadMarkdownForTextViewFromRaw(R.raw.licenses_3rd_party, ""));
}
@OnClick({R.id.fragment_license__leafpic_button, R.id.fragment_license__license_button})

View file

@ -229,23 +229,16 @@ public class MainActivity extends ThemedActivity
}
}
// Show first start dialog
// Show first start / update dialog
try {
SimpleMarkdownParser mdParser = SimpleMarkdownParser.get().setDefaultSmpFilter(SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW);
if (_appSettings.isAppFirstStart()) {
mdParser.parse(
getResources().openRawResource(R.raw.license), "");
String html = mdParser.getHtml()
+ "<br/><br/><br/>"
+ "<h1>" + getString(R.string.fragment_license__thirdparty_libs) + "</h1>"
+ mdParser.parse(getResources().openRawResource(R.raw.license_third_party), "");
html = mdParser.setHtml(html).removeMultiNewlines().getHtml();
ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.about_activity__title_about_license, html);
_appSettings.isAppCurrentVersionFirstStart();
} else if (_appSettings.isAppCurrentVersionFirstStart()) {
SimpleMarkdownParser smp = new SimpleMarkdownParser().parse(
getResources().openRawResource(R.raw.changelog), "");
ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.changelog, smp.getHtml());
if (_appSettings.isAppCurrentVersionFirstStart(true)) {
SimpleMarkdownParser smp = SimpleMarkdownParser.get().setDefaultSmpFilter(SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW);
String html = "";
html += smp.parse(getString(R.string.copyright_license_text_official).replace("\n", " \n"), "").getHtml();
html += "<br/><br/><br/><big><big>" + getString(R.string.changelog) + "</big></big><br/>" + smp.parse(getResources().openRawResource(R.raw.changelog), "", SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW, SimpleMarkdownParser.FILTER_CHANGELOG).getHtml();
html += "<br/><br/><br/><big><big>" + getString(R.string.licenses) + "</big></big><br/>" + smp.parse(getResources().openRawResource(R.raw.licenses_3rd_party), "").getHtml();
ActivityUtils _au = new ActivityUtils(this);
_au.showDialogWithHtmlTextView(R.string.licenses, html);
}
} catch (IOException e) {
e.printStackTrace();

View file

@ -21,7 +21,7 @@ import java.util.Locale;
@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue"})
public class ActivityUtils extends net.gsantner.opoc.util.ActivityUtils {
protected ActivityUtils(Activity activity) {
public ActivityUtils(Activity activity) {
super(activity);
}

View file

@ -367,9 +367,11 @@ public class AppSettings extends SharedPreferencesPropertyBackend {
return value;
}
public boolean isAppCurrentVersionFirstStart() {
public boolean isAppCurrentVersionFirstStart(boolean doSet) {
int value = getInt(R.string.pref_key__app_first_start_current_version, -1);
setInt(R.string.pref_key__app_first_start_current_version, BuildConfig.VERSION_CODE);
if (doSet) {
setInt(R.string.pref_key__app_first_start_current_version, BuildConfig.VERSION_CODE);
}
return value != BuildConfig.VERSION_CODE && !BuildConfig.IS_TEST_BUILD;
}

View file

@ -108,14 +108,14 @@
style="@android:style/TextAppearance.DeviceDefault.Large"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/fragment_license__license"
android:text="@string/licenses"
android:layout_marginBottom="8dp"/>
<TextView
android:textAppearance="@style/TextAppearance.AppCompat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/fragment_license__license_text"/>
android:text="@string/copyright_license_text_official"/>
<Button
android:id="@+id/fragment_license__license_button"

View file

@ -46,9 +46,9 @@
<string name="fragment_license__maintainers_text">This app is currently being developed and maintained by &lt;br>&lt;br>%1$s</string>
<string name="fragment_license__contributors">Contributors</string>
<string name="fragment_license__contributors_thank_you">%1$s&lt;br>&lt;br>Thank you!</string>
<string name="fragment_license__license" translatable="false">@string/about_activity__title_about_license</string>
<string name="fragment_license__license_text" translatable="false">
Copyright © 2015-2017
<string name="licenses" translatable="false">@string/about_activity__title_about_license</string>
<string name="copyright_license_text_official" translatable="false">
Copyright © 2015-2018
\nThis 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.
\n
\nThis 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.