Added open source licenses dialog.

This commit is contained in:
Karim Abou Zeid 2015-12-28 01:06:09 +01:00
commit afd72a7129
12 changed files with 191 additions and 14 deletions

View file

@ -132,4 +132,5 @@ dependencies {
compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
//noinspection GradleDynamicVersion
compile 'com.anjlab.android.iab.v3:library:1.0.+'
compile('de.psdev.licensesdialog:licensesdialog:1.8.0')
}

View file

@ -76,8 +76,8 @@ public class ChangelogDialog extends LeakDetectDialogFragment {
in.close();
// Inject color values for WebView body background and links
final String backgroundColor = ThemeSingleton.get().darkTheme ? "444444" : "fff";
final String contentColor = ThemeSingleton.get().darkTheme ? "fff" : "000";
final String backgroundColor = ThemeSingleton.get().darkTheme ? "424242" : "ffffff";
final String contentColor = ThemeSingleton.get().darkTheme ? "ffffff" : "000000";
webView.loadData(buf.toString()
.replace("{style-placeholder}",
String.format("body { background-color: #%s; color: #%s; }", backgroundColor, contentColor))

View file

@ -15,6 +15,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.afollestad.materialdialogs.internal.ThemeSingleton;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.dialogs.ChangelogDialog;
import com.kabouzeid.gramophone.dialogs.DonationDialog;
@ -24,6 +25,7 @@ import com.kabouzeid.gramophone.util.ViewUtil;
import butterknife.Bind;
import butterknife.ButterKnife;
import de.psdev.licensesdialog.LicensesDialog;
/**
* @author Karim Abou Zeid (kabouzeid)
@ -57,6 +59,8 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
TextView appVersion;
@Bind(R.id.changelog)
LinearLayout changelog;
@Bind(R.id.licenses)
LinearLayout licenses;
@Bind(R.id.add_to_google_plus_circles)
LinearLayout addToGooglePlusCircles;
@Bind(R.id.follow_on_twitter)
@ -92,6 +96,8 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
ImageView iconInfo;
@Bind(R.id.icon_changelog)
ImageView iconChangelog;
@Bind(R.id.icon_licenses)
ImageView iconLicenses;
@Bind(R.id.icon_bug_report)
ImageView iconBugReport;
@Bind(R.id.icon_google_plus_community)
@ -147,6 +153,7 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
private void setUpOnClickListeners() {
changelog.setOnClickListener(this);
licenses.setOnClickListener(this);
addToGooglePlusCircles.setOnClickListener(this);
followOnTwitter.setOnClickListener(this);
forkOnGitHub.setOnClickListener(this);
@ -165,18 +172,20 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
}
private void setUpIconTint() {
iconInfo.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconChangelog.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconBugReport.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconGooglePlusCommunity.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconFlag.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconRate.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconDonate.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconAuthor.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconGooglePlus.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconTwitter.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconGithub.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
iconWebsite.setColorFilter(ColorUtil.resolveColor(this, android.R.attr.textColorSecondary));
int iconColor = ColorUtil.resolveColor(this, R.attr.icon_color);
iconInfo.setColorFilter(iconColor);
iconChangelog.setColorFilter(iconColor);
iconLicenses.setColorFilter(iconColor);
iconBugReport.setColorFilter(iconColor);
iconGooglePlusCommunity.setColorFilter(iconColor);
iconFlag.setColorFilter(iconColor);
iconRate.setColorFilter(iconColor);
iconDonate.setColorFilter(iconColor);
iconAuthor.setColorFilter(iconColor);
iconGooglePlus.setColorFilter(iconColor);
iconTwitter.setColorFilter(iconColor);
iconGithub.setColorFilter(iconColor);
iconWebsite.setColorFilter(iconColor);
}
@Override
@ -201,6 +210,8 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
public void onClick(View v) {
if (v == changelog) {
ChangelogDialog.create().show(getSupportFragmentManager(), "CHANGELOG_DIALOG");
} else if (v == licenses) {
showLicenseDialog();
} else if (v == addToGooglePlusCircles) {
openUrl(GOOGLE_PLUS);
} else if (v == followOnTwitter) {
@ -241,6 +252,20 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
startActivity(i);
}
private void showLicenseDialog() {
new LicensesDialog.Builder(this)
.setNotices(R.raw.notices)
.setTitle(R.string.licenses)
.setNoticesCssStyle(getString(R.string.license_dialog_style)
.replace("{bg-color}", ThemeSingleton.get().darkTheme ? "424242" : "ffffff")
.replace("{text-color}", ThemeSingleton.get().darkTheme ? "ffffff" : "000000")
.replace("{license-bg-color}", ThemeSingleton.get().darkTheme ? "535353" : "eeeeee")
)
.setIncludeOwnLicense(true)
.build()
.showAppCompat();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
boolean darkContent = ColorUtil.useDarkTextColorOnBackground(getThemeColorPrimary());

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

View file

@ -113,6 +113,37 @@
</LinearLayout>
<LinearLayout
android:id="@+id/licenses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?rect_selector"
android:clickable="true"
android:gravity="center_vertical"
android:minHeight="@dimen/md_listitem_height"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:id="@+id/icon_licenses"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_description_white_24dp"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="@string/licenses"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>

View file

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 Philip Schiffer
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<notices>
<notice>
<name>Advanced RecyclerView</name>
<url>https://github.com/h6ah4i/android-advancedrecyclerview</url>
<copyright>Copyright (C) 2015 Haruki Hasegawa</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Material Contextual Action Bar</name>
<url>https://github.com/afollestad/material-cab</url>
<copyright>Copyright 2016 Aidan Follestad</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>LeakCanary</name>
<url>https://github.com/square/leakcanary</url>
<copyright>Copyright 2015 Square, Inc.</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Android Support Libraries</name>
<url>http://developer.android.com/tools/support-library/index.html</url>
<copyright>Copyright (C) 2015 The Android Open Source Project</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Android-ObservableScrollView</name>
<url>https://github.com/ksoichiro/Android-ObservableScrollView</url>
<copyright>Copyright 2014 Soichiro Kashima</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Android Sliding Up Panel</name>
<url>https://github.com/umano/AndroidSlidingUpPanel</url>
<copyright />
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Retrofit</name>
<url>https://github.com/square/retrofit</url>
<copyright>Copyright 2013 Square, Inc.</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>OkHttp</name>
<url>https://github.com/square/okhttp</url>
<copyright />
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Universal Image Loader</name>
<url>https://github.com/nostra13/Android-Universal-Image-Loader</url>
<copyright>Copyright 2011-2015 Sergey Tarasevich</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Butter Knife</name>
<url>https://github.com/JakeWharton/butterknife</url>
<copyright>Copyright 2013 Jake Wharton</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Linear Layout Manager</name>
<url>https://github.com/serso/android-linear-layout-manager</url>
<copyright>Copyright 2014 serso aka se.solovyev</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Android In-App Billing v3 Library</name>
<url>https://github.com/anjlab/android-inapp-billing-v3</url>
<copyright>Copyright 2014 AnjLab</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Material Dialogs</name>
<url>https://github.com/afollestad/material-dialogs</url>
<copyright>Copyright (c) 2015 Aidan Michael Follestad</copyright>
<license>MIT License</license>
</notice>
<notice>
<name>SeekArc</name>
<url>https://github.com/Triggertrap/SeekArc</url>
<copyright>Copyright (c) 2013 Triggertrap Ltd
Author Neil Davies
</copyright>
<license>MIT License</license>
</notice>
</notices>

View file

@ -22,4 +22,18 @@
<item>donation_5</item>
<item>donation_6</item>
</string-array>
<string name="license_dialog_style" translatable="false">
body {
background-color: #{bg-color};
color: #{text-color};
font-family: sans-serif;
overflow-wrap: break-word;
}
pre {
background-color: #{license-bg-color};
padding: 1em;
white-space: pre-wrap;
}
</string>
</resources>

View file

@ -179,6 +179,7 @@
<string name="colored_footers">Colored footers</string>
<string name="special_thanks_to">Special thanks to</string>
<string name="changelog">Changelog</string>
<string name="licenses">Licenses</string>
<string name="permission_to_access_external_storage_denied">Permission to access external storage denied.</string>
<string name="back">back</string>
<string name="support_development">Support development</string>