-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.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
diff --git a/app/src/main/assets/mpl2.html b/app/src/main/assets/mpl2.html
index 5009391a0..5e988a70c 100644
--- a/app/src/main/assets/mpl2.html
+++ b/app/src/main/assets/mpl2.html
@@ -4,6 +4,7 @@
Mozilla Public License, version 2.0
+
Mozilla Public License Version 2.0
1. Definitions
diff --git a/app/src/main/java/org/schabi/newpipe/about/License.java b/app/src/main/java/org/schabi/newpipe/about/License.java
index 312ad5087..e51e1d0f1 100644
--- a/app/src/main/java/org/schabi/newpipe/about/License.java
+++ b/app/src/main/java/org/schabi/newpipe/about/License.java
@@ -50,6 +50,10 @@ public class License implements Parcelable {
public String getAbbreviation() {
return abbreviation;
}
+
+ public String getFilename() {
+ return filename;
+ }
@Override
public int describeContents() {
diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java b/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
index 8b0e67d18..42e886d30 100644
--- a/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
@@ -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("");
+ webViewData = insert[0] + ""
+ + 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);
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 9f8a41bc5..3008f68ee 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -10,6 +10,8 @@
#48868686#1fa6a6a6#5a000000
+ #ffffff
+ #212121#222222
@@ -20,6 +22,8 @@
#48ffffff#1f717171#82000000
+ #424242
+ #ffffff#000
@@ -37,8 +41,8 @@
#e53935#fff
- #d6d6d6d
- #717171d
+ #d6d6d6
+ #717171#607D8B
From 0040ee5cb674da9832ea1b85fdee6742d7a82a99 Mon Sep 17 00:00:00 2001
From: TobiGr
Date: Fri, 20 Oct 2017 23:41:30 +0200
Subject: [PATCH 2/2] Fix charset issue. Move Java I/O related methods to
separate thread.
---
.../schabi/newpipe/about/LicenseFragment.java | 73 +-----------
.../newpipe/about/LicenseFragmentHelper.java | 111 ++++++++++++++++++
2 files changed, 112 insertions(+), 72 deletions(-)
create mode 100644 app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java b/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
index 42e886d30..4400cac53 100644
--- a/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
@@ -1,22 +1,15 @@
package org.schabi.newpipe.about;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
-import android.support.v7.app.AlertDialog;
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;
@@ -46,70 +39,7 @@ public class LicenseFragment extends Fragment {
* @param license the license to show
*/
public static void showLicense(Context context, License license) {
- if(context == null) {
- throw new NullPointerException("context is null");
- }
- if(license == null) {
- throw new NullPointerException("license is null");
- }
- AlertDialog.Builder alert = new AlertDialog.Builder(context);
- alert.setTitle(license.getName());
-
- WebView wv = new WebView(context);
- 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("");
- webViewData = insert[0] + ""
- + 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
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- });
- 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);
+ new LicenseFragmentHelper().execute(context, license);
}
@Override
@@ -154,7 +84,6 @@ public class LicenseFragment extends Fragment {
});
softwareComponentsView.addView(componentView);
registerForContextMenu(componentView);
-
}
return rootView;
}
diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
new file mode 100644
index 000000000..726e97ec2
--- /dev/null
+++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
@@ -0,0 +1,111 @@
+package org.schabi.newpipe.about;
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.os.AsyncTask;
+import android.support.v7.app.AlertDialog;
+import android.webkit.WebView;
+import org.schabi.newpipe.R;
+import org.schabi.newpipe.util.ThemeHelper;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+public class LicenseFragmentHelper extends AsyncTask