add themes to license dialog
This commit is contained in:
parent
ced75a9b60
commit
74bda719a6
|
@ -15,9 +15,9 @@ Version 2, June 1991
|
|||
</p>
|
||||
|
||||
<pre>
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.<br/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA<br/>
|
||||
<br/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
</pre>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Mozilla Public License, version 2.0</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="mozilla-public-license-version-2.0">Mozilla Public License<br>Version 2.0</h1>
|
||||
<h2 id="definitions">1. Definitions</h2>
|
||||
|
|
|
@ -50,6 +50,10 @@ public class License implements Parcelable {
|
|||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
|
|
|
@ -8,17 +8,15 @@ import android.os.Bundle;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.*;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.util.ThemeHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
|
@ -58,7 +56,26 @@ public class LicenseFragment extends Fragment {
|
|||
alert.setTitle(license.getName());
|
||||
|
||||
WebView wv = new WebView(context);
|
||||
wv.loadUrl(license.getContentUri().toString());
|
||||
String licenseContent = "";
|
||||
String webViewData;
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(context.getAssets().open(license.getFilename()), "UTF-8"));
|
||||
String str;
|
||||
while ((str = in.readLine()) != null) {
|
||||
licenseContent += str;
|
||||
}
|
||||
in.close();
|
||||
|
||||
// split the HTML file and insert the stylesheet into the HEAD of the file
|
||||
String[] insert = licenseContent.split("</head>");
|
||||
webViewData = insert[0] + "<style type=\"text/css\">"
|
||||
+ getLicenseStylesheet(context) + "</style></head>"
|
||||
+ insert[1];
|
||||
} catch (Exception e) {
|
||||
throw new NullPointerException("could not get license file:" + getLicenseStylesheet(context));
|
||||
}
|
||||
wv.loadData(webViewData, "text/html", "utf-8");
|
||||
|
||||
alert.setView(wv);
|
||||
alert.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
@ -69,6 +86,32 @@ public class LicenseFragment extends Fragment {
|
|||
alert.show();
|
||||
}
|
||||
|
||||
public static String getLicenseStylesheet(Context context) {
|
||||
return "body{padding:12px 15px;margin:0;background:#"
|
||||
+ getHexRGBColor(context,(ThemeHelper.isLightThemeSelected(context))
|
||||
? R.color.light_license_background_color
|
||||
: R.color.dark_license_background_color)
|
||||
+ ";color:#"
|
||||
+ getHexRGBColor(context,(ThemeHelper.isLightThemeSelected(context))
|
||||
? R.color.light_license_text_color
|
||||
: R.color.dark_license_text_color) + ";}"
|
||||
+ "a[href]{color:#"
|
||||
+ getHexRGBColor(context,(ThemeHelper.isLightThemeSelected(context))
|
||||
? R.color.light_youtube_primary_color
|
||||
: R.color.dark_youtube_primary_color) + ";}"
|
||||
+ "pre{white-space: pre-wrap;}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast R.color to a hexadecimal color value
|
||||
* @param context the context to use
|
||||
* @param color the color number from R.color
|
||||
* @return a six characters long String with hexadecimal RGB values
|
||||
*/
|
||||
public static String getHexRGBColor(Context context, int color) {
|
||||
return context.getResources().getString(color).substring(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
<color name="light_ripple_color">#48868686</color>
|
||||
<color name="light_contrast_background_color">#1fa6a6a6</color>
|
||||
<color name="light_shadow_start_color">#5a000000</color>
|
||||
<color name="light_license_background_color">#ffffff</color>
|
||||
<color name="light_license_text_color">#212121</color>
|
||||
|
||||
<!-- Dark Theme -->
|
||||
<color name="dark_background_color">#222222</color>
|
||||
|
@ -20,6 +22,8 @@
|
|||
<color name="dark_ripple_color">#48ffffff</color>
|
||||
<color name="dark_contrast_background_color">#1f717171</color>
|
||||
<color name="dark_shadow_start_color">#82000000</color>
|
||||
<color name="dark_license_background_color">#424242</color>
|
||||
<color name="dark_license_text_color">#ffffff</color>
|
||||
|
||||
<!-- Black Theme -->
|
||||
<color name="black_background_color">#000</color>
|
||||
|
@ -37,8 +41,8 @@
|
|||
|
||||
<color name="subscribe_background_color">#e53935</color>
|
||||
<color name="subscribe_text_color">#fff</color>
|
||||
<color name="subscribed_background_color">#d6d6d6</color>d
|
||||
<color name="subscribed_text_color">#717171</color>d
|
||||
<color name="subscribed_background_color">#d6d6d6</color>
|
||||
<color name="subscribed_text_color">#717171</color>
|
||||
|
||||
<!-- GigaGet theme -->
|
||||
<color name="bluegray">#607D8B</color>
|
||||
|
|
Loading…
Reference in New Issue