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. 34
      app/src/main/assets/apache_libraries.html
  3. 34
      app/src/main/assets/epl_libraries.html
  4. 28
      app/src/main/assets/libraries_style.css
  5. 34
      app/src/main/assets/mit_libraries.html
  6. 36
      app/src/main/assets/other_libraries.html
  7. 22
      app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java
  8. 28
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  9. 39
      app/src/main/java/gr/thmmy/mthmmy/utils/io/AssetUtils.java
  10. 2
      build.gradle

16
app/build.gradle

@ -7,7 +7,7 @@ apply plugin: 'io.fabric'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion = '29.0.2' buildToolsVersion = '29.0.3'
defaultConfig { defaultConfig {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
@ -75,17 +75,17 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":emojis") implementation project(":emojis")
implementation 'androidx.appcompat:appcompat:1.1.0' 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-preference-v14:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-beta01' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.exifinterface:exifinterface:1.1.0-rc01' implementation 'androidx.exifinterface:exifinterface:1.2.0'
implementation 'com.google.android.material:material:1.0.0' implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.firebase:firebase-core:17.0.0' implementation 'com.google.firebase:firebase-analytics:17.4.1'
implementation 'com.google.firebase:firebase-messaging:19.0.1' implementation 'com.google.firebase:firebase-messaging:20.1.7'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.snatik:storage:2.1.0' 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! implementation 'com.squareup.okhttp3:okhttp:3.12.0' //TODO: Warning: okhttp has dropped support for Android v.19 since okhttp 3.13!

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

@ -1,38 +1,6 @@
<html> <html>
<head> <head>
<style> <link rel="stylesheet" type="text/css" href="libraries_style.css" />
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> </head>
<body> <body>

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

@ -1,38 +1,6 @@
<html> <html>
<head> <head>
<style> <link rel="stylesheet" type="text/css" href="libraries_style.css" />
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> </head>
<body> <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> <html>
<head> <head>
<style> <link rel="stylesheet" type="text/css" href="libraries_style.css" />
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> </head>
<body> <body>

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

@ -1,38 +1,6 @@
<html> <html>
<head> <head>
<style> <link rel="stylesheet" type="text/css" href="libraries_style.css" />
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> </head>
<body> <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 not use this file except in compliance with the License.
You may obtain a copy of the License at 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 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, 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; package gr.thmmy.mthmmy.activities;
import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableString; import android.text.SpannableString;
@ -26,6 +28,7 @@ import gr.thmmy.mthmmy.BuildConfig;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.base.BaseApplication; import gr.thmmy.mthmmy.base.BaseApplication;
import gr.thmmy.mthmmy.utils.io.AssetUtils;
public class AboutActivity extends BaseActivity { public class AboutActivity extends BaseActivity {
private static final int TIME_INTERVAL = 1000; private static final int TIME_INTERVAL = 1000;
@ -137,31 +140,35 @@ public class AboutActivity extends BaseActivity {
public void displayLibraries(View v) { public void displayLibraries(View v) {
String libraryType = v.getTag().toString(); String libraryType = v.getTag().toString();
String title="", fileUrl=""; String title="", fileName="";
switch(libraryType) { switch(libraryType) {
case "APACHE": case "APACHE":
title=getString(R.string.apache_v2_0_libraries); title=getString(R.string.apache_v2_0_libraries);
fileUrl="file:///android_asset/apache_libraries.html"; fileName="apache_libraries.html";
break; break;
case "MIT": case "MIT":
title=getString(R.string.the_mit_libraries); title=getString(R.string.the_mit_libraries);
fileUrl="file:///android_asset/mit_libraries.html"; fileName="mit_libraries.html";
break; break;
case "EPL": case "EPL":
title=getString(R.string.epl_libraries); title=getString(R.string.epl_libraries);
fileUrl="file:///android_asset/epl_libraries.html"; fileName="epl_libraries.html";
break; break;
case "OTHER": case "OTHER":
title=getString(R.string.other_libraries); title=getString(R.string.other_libraries);
fileUrl="file:///android_asset/other_libraries.html"; fileName="other_libraries.html";
break; break;
default: default:
break; break;
} }
String htmlContent = AssetUtils.readFileToText(this,fileName);
LayoutInflater inflater = LayoutInflater.from(this); LayoutInflater inflater = LayoutInflater.from(this);
WebView webView = (WebView) inflater.inflate(R.layout.dialog_licenses, coordinatorLayout, false); 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 width = (int) (getResources().getDisplayMetrics().widthPixels * 0.95);
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.95); int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.95);
alertDialog = new AlertDialog.Builder(this, R.style.AppTheme_Dark_Dialog) alertDialog = new AlertDialog.Builder(this, R.style.AppTheme_Dark_Dialog)
@ -173,9 +180,10 @@ public class AboutActivity extends BaseActivity {
alertDialog.getWindow().setLayout(width, height); alertDialog.getWindow().setLayout(width, height);
} }
@SuppressLint("SourceLockedOrientationActivity")
private void showEasterEgg(){ private void showEasterEgg(){
if(getResources().getConfiguration().orientation==ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){ if(getResources().getConfiguration().orientation==ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //TODO: why?
appBar.setVisibility(View.INVISIBLE); appBar.setVisibility(View.INVISIBLE);
mainContent.setVisibility(View.INVISIBLE); mainContent.setVisibility(View.INVISIBLE);
easterEggImage.setVisibility(View.VISIBLE); easterEggImage.setVisibility(View.VISIBLE);

28
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 net.gotev.uploadservice.UploadService;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import gr.thmmy.mthmmy.R; 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.services.UploadsReceiver;
import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.session.SessionManager;
import gr.thmmy.mthmmy.utils.FileUtils; import gr.thmmy.mthmmy.utils.FileUtils;
import gr.thmmy.mthmmy.utils.io.AssetUtils;
import gr.thmmy.mthmmy.viewmodel.BaseViewModel; import gr.thmmy.mthmmy.viewmodel.BaseViewModel;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
@ -840,32 +838,14 @@ public abstract class BaseActivity extends AppCompatActivity {
privacyPolicyTextView.setPadding(30, 20, 30, 20); privacyPolicyTextView.setPadding(30, 20, 30, 20);
privacyPolicyTextView.setTextColor(ContextCompat.getColor(this, R.color.primary_text)); privacyPolicyTextView.setTextColor(ContextCompat.getColor(this, R.color.primary_text));
SpannableConfiguration configuration = SpannableConfiguration.builder(this).linkResolver(new LinkResolverDef()).build(); 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) { String privacyPolicy = AssetUtils.readFileToText(BaseActivity.this,"PRIVACY.md");
stringBuilder.append(line); if(privacyPolicy!=null){
stringBuilder.append("\n"); Markwon.setMarkdown(privacyPolicyTextView, configuration, privacyPolicy);
}
Markwon.setMarkdown(privacyPolicyTextView, configuration, stringBuilder.toString());
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
builder.setView(privacyPolicyTextView); builder.setView(privacyPolicyTextView);
builder.setPositiveButton("Close", (dialogInterface, i) -> dialogInterface.dismiss()); builder.setPositiveButton("Close", (dialogInterface, i) -> dialogInterface.dismiss());
builder.show(); 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 { dependencies {
classpath 'com.android.tools.build:gradle:3.6.3' 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 'io.fabric.tools:gradle:1.29.0'
classpath 'org.ajoberstar.grgit:grgit-core:3.1.1' // Also change in app/gradle/grgit.gradle 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" classpath "com.github.ben-manes:gradle-versions-plugin:0.21.0"

Loading…
Cancel
Save