Browse Source

Up libs, libraries popup cleanup

pull/68/head
Ezerous 5 years ago
parent
commit
338776d615
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 16
      app/build.gradle
  2. 2
      app/src/main/AndroidManifest.xml
  3. 42
      app/src/main/assets/apache_libraries.html
  4. 34
      app/src/main/assets/epl_libraries.html
  5. 28
      app/src/main/assets/libraries_style.css
  6. 34
      app/src/main/assets/mit_libraries.html
  7. 36
      app/src/main/assets/other_libraries.html
  8. 22
      app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java
  9. 30
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  10. 39
      app/src/main/java/gr/thmmy/mthmmy/utils/io/AssetUtils.java
  11. 2
      build.gradle

16
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!

2
app/src/main/AndroidManifest.xml

@ -10,7 +10,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:name=".base.BaseApplication"
android:allowBackup="true"

42
app/src/main/assets/apache_libraries.html

@ -1,41 +1,9 @@
<html>
<head>
<style>
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;
}
h4,
h5 {
display: inline;
padding: 1em;
}
a,
h4,
h5 {
color: #26A69A;
word-wrap: break-word;
}
li {
color: #26A69A;
}
</style>
</head>
<body>
<head>
<link rel="stylesheet" type="text/css" href="libraries_style.css" />
</head>
<body>
<ul>
<li>
<h5><a href="https://square.github.io/okhttp/">OkHttp</a>&nbsp;v3.14.2 (Copyright ©2019 Square, Inc.)</h5>

34
app/src/main/assets/epl_libraries.html

@ -1,38 +1,6 @@
<html>
<head>
<style>
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;
}
h4,
h5 {
display: inline;
padding: 1em;
}
a,
h4,
h5 {
color: #26A69A;
word-wrap: break-word;
}
li {
color: #26A69A;
}
</style>
<link rel="stylesheet" type="text/css" href="libraries_style.css" />
</head>
<body>

28
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;
}

34
app/src/main/assets/mit_libraries.html

@ -1,38 +1,6 @@
<html>
<head>
<style>
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;
}
h4,
h5 {
display: inline;
padding: 1em;
}
a,
h4,
h5 {
color: #26A69A;
word-wrap: break-word;
}
li {
color: #26A69A;
}
</style>
<link rel="stylesheet" type="text/css" href="libraries_style.css" />
</head>
<body>

36
app/src/main/assets/other_libraries.html

@ -1,38 +1,6 @@
<html>
<head>
<style>
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;
}
h4,
h5 {
display: inline;
padding: 1em;
}
a,
h4,
h5 {
color: #26A69A;
word-wrap: break-word;
}
li {
color: #26A69A;
}
</style>
<link rel="stylesheet" type="text/css" href="libraries_style.css" />
</head>
<body>
@ -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
<a href="http://www.apache.org/licenses/">http://www.apache.org/licenses/</a>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,

22
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);

30
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).");
}
}
}

39
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;
}
}

2
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"

Loading…
Cancel
Save