diff --git a/app/build.gradle b/app/build.gradle index 981f79dd..5df924a7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'io.fabric' android { compileSdkVersion 29 - buildToolsVersion = '29.0.2' + buildToolsVersion = '29.0.3' defaultConfig { vectorDrawables.useSupportLibrary = true @@ -75,17 +75,17 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(":emojis") implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.preference:preference:1.1.0' + implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.legacy:legacy-preference-v14:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.0.0' - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-beta01' + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.exifinterface:exifinterface:1.1.0-rc01' - implementation 'com.google.android.material:material:1.0.0' - implementation 'com.google.firebase:firebase-core:17.0.0' - implementation 'com.google.firebase:firebase-messaging:19.0.1' + implementation 'androidx.exifinterface:exifinterface:1.2.0' + implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.firebase:firebase-analytics:17.4.1' + implementation 'com.google.firebase:firebase-messaging:20.1.7' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' implementation 'com.snatik:storage:2.1.0' implementation 'com.squareup.okhttp3:okhttp:3.12.0' //TODO: Warning: okhttp has dropped support for Android v.19 since okhttp 3.13! diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a808255e..66be4558 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ - + - - - - - + + + + +
  • OkHttp v3.14.2 (Copyright ©2019 Square, Inc.)
    diff --git a/app/src/main/assets/epl_libraries.html b/app/src/main/assets/epl_libraries.html index 5cbc1519..23802d2c 100644 --- a/app/src/main/assets/epl_libraries.html +++ b/app/src/main/assets/epl_libraries.html @@ -1,38 +1,6 @@ - + diff --git a/app/src/main/assets/libraries_style.css b/app/src/main/assets/libraries_style.css new file mode 100644 index 00000000..39372a93 --- /dev/null +++ b/app/src/main/assets/libraries_style.css @@ -0,0 +1,28 @@ +body { + font-family: sans-serif; + background-color: #333333; +} + +pre { + background-color: #3C3C3C; + color: #757575; + padding: 1em; + margin-left: 1em; + margin-right: 1em; + white-space: pre-wrap; + word-wrap: break-word; +} + +h4, h5 { + display: inline; + padding: 1em; +} + +a, h4, h5 { + color: #26A69A; + word-wrap: break-word; +} + +li { + color: #26A69A; +} \ No newline at end of file diff --git a/app/src/main/assets/mit_libraries.html b/app/src/main/assets/mit_libraries.html index a1cce5c6..cd30b2cb 100644 --- a/app/src/main/assets/mit_libraries.html +++ b/app/src/main/assets/mit_libraries.html @@ -1,38 +1,6 @@ - + diff --git a/app/src/main/assets/other_libraries.html b/app/src/main/assets/other_libraries.html index 53edb44c..59b89569 100644 --- a/app/src/main/assets/other_libraries.html +++ b/app/src/main/assets/other_libraries.html @@ -1,38 +1,6 @@ - + @@ -83,7 +51,7 @@ 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 +http://www.apache.org/licenses/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java index 1919608f..8ff6dfe5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java @@ -1,7 +1,9 @@ package gr.thmmy.mthmmy.activities; +import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.graphics.Color; import android.net.Uri; import android.os.Bundle; import android.text.SpannableString; @@ -26,6 +28,7 @@ import gr.thmmy.mthmmy.BuildConfig; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.base.BaseApplication; +import gr.thmmy.mthmmy.utils.io.AssetUtils; public class AboutActivity extends BaseActivity { private static final int TIME_INTERVAL = 1000; @@ -137,31 +140,35 @@ public class AboutActivity extends BaseActivity { public void displayLibraries(View v) { String libraryType = v.getTag().toString(); - String title="", fileUrl=""; + String title="", fileName=""; switch(libraryType) { case "APACHE": title=getString(R.string.apache_v2_0_libraries); - fileUrl="file:///android_asset/apache_libraries.html"; + fileName="apache_libraries.html"; break; case "MIT": title=getString(R.string.the_mit_libraries); - fileUrl="file:///android_asset/mit_libraries.html"; + fileName="mit_libraries.html"; break; case "EPL": title=getString(R.string.epl_libraries); - fileUrl="file:///android_asset/epl_libraries.html"; + fileName="epl_libraries.html"; break; case "OTHER": title=getString(R.string.other_libraries); - fileUrl="file:///android_asset/other_libraries.html"; + fileName="other_libraries.html"; break; default: break; } + String htmlContent = AssetUtils.readFileToText(this,fileName); + LayoutInflater inflater = LayoutInflater.from(this); WebView webView = (WebView) inflater.inflate(R.layout.dialog_licenses, coordinatorLayout, false); - webView.loadUrl(fileUrl); + webView.setBackgroundColor(Color.argb(1, 255, 255, 255)); + webView.loadDataWithBaseURL("file:///android_asset/", htmlContent, "text/html", "UTF-8", null); + int width = (int) (getResources().getDisplayMetrics().widthPixels * 0.95); int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.95); alertDialog = new AlertDialog.Builder(this, R.style.AppTheme_Dark_Dialog) @@ -173,9 +180,10 @@ public class AboutActivity extends BaseActivity { alertDialog.getWindow().setLayout(width, height); } + @SuppressLint("SourceLockedOrientationActivity") private void showEasterEgg(){ if(getResources().getConfiguration().orientation==ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){ - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //TODO: why? appBar.setVisibility(View.INVISIBLE); mainContent.setVisibility(View.INVISIBLE); easterEggImage.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index bd21f61b..6068304a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -45,10 +45,7 @@ import com.snatik.storage.Storage; import net.gotev.uploadservice.UploadService; -import java.io.BufferedReader; import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; import java.util.ArrayList; import gr.thmmy.mthmmy.R; @@ -67,6 +64,7 @@ import gr.thmmy.mthmmy.services.DownloadHelper; import gr.thmmy.mthmmy.services.UploadsReceiver; import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.utils.FileUtils; +import gr.thmmy.mthmmy.utils.io.AssetUtils; import gr.thmmy.mthmmy.viewmodel.BaseViewModel; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import okhttp3.OkHttpClient; @@ -840,32 +838,14 @@ public abstract class BaseActivity extends AppCompatActivity { privacyPolicyTextView.setPadding(30, 20, 30, 20); privacyPolicyTextView.setTextColor(ContextCompat.getColor(this, R.color.primary_text)); SpannableConfiguration configuration = SpannableConfiguration.builder(this).linkResolver(new LinkResolverDef()).build(); - StringBuilder stringBuilder = new StringBuilder(); - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(getAssets().open("PRIVACY.md"))); - String line; - - while ((line = reader.readLine()) != null) { - stringBuilder.append(line); - stringBuilder.append("\n"); - } - Markwon.setMarkdown(privacyPolicyTextView, configuration, stringBuilder.toString()); + + String privacyPolicy = AssetUtils.readFileToText(BaseActivity.this,"PRIVACY.md"); + if(privacyPolicy!=null){ + Markwon.setMarkdown(privacyPolicyTextView, configuration, privacyPolicy); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); builder.setView(privacyPolicyTextView); builder.setPositiveButton("Close", (dialogInterface, i) -> dialogInterface.dismiss()); builder.show(); - } catch (IOException e) { - Timber.e(e, "Error reading Privacy Policy from assets."); - } catch (Exception e) { - Timber.e(e, "Error in Privacy Policy dialog."); - } finally { - try { - if (reader != null) - reader.close(); - } catch (IOException e) { - Timber.e(e, "Error in Privacy Policy dialog (closing reader)."); - } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/io/AssetUtils.java b/app/src/main/java/gr/thmmy/mthmmy/utils/io/AssetUtils.java new file mode 100644 index 00000000..2ceb81d4 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/io/AssetUtils.java @@ -0,0 +1,39 @@ +package gr.thmmy.mthmmy.utils.io; + +import android.content.Context; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import timber.log.Timber; + +public class AssetUtils { + public static String readFileToText(Context context, String fileName) { + StringBuilder stringBuilder = new StringBuilder(); + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(context.getAssets().open(fileName))); + String line; + + while ((line = reader.readLine()) != null) { + stringBuilder.append(line); + stringBuilder.append("\n"); + } + return stringBuilder.toString(); + } catch (IOException e) { + Timber.e(e, "IO error reading file %s from assets.", fileName); + } catch (Exception e) { + Timber.e(e, "Error reading file %s from assets.", fileName); + } finally { + try { + if (reader != null) + reader.close(); + } catch (IOException e) { + Timber.e(e, "Error in AssetUtils (closing reader)."); + } + } + return null; + } +} + diff --git a/build.gradle b/build.gradle index efe5d780..d68e60f8 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.6.3' - classpath 'com.google.gms:google-services:4.3.2' + classpath 'com.google.gms:google-services:4.3.3' classpath 'io.fabric.tools:gradle:1.29.0' classpath 'org.ajoberstar.grgit:grgit-core:3.1.1' // Also change in app/gradle/grgit.gradle classpath "com.github.ben-manes:gradle-versions-plugin:0.21.0"