Skip to content

Commit

Permalink
feat: UseUse editor library as module
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxGalaxy committed Nov 22, 2023
1 parent 4434abe commit f618e00
Show file tree
Hide file tree
Showing 641 changed files with 446,797 additions and 62 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,7 @@ dependencies {

implementation platform('com.google.firebase:firebase-bom:32.3.1')
implementation 'com.google.firebase:firebase-analytics'

implementation project(path:':common')
implementation project(path:':editor')
}
Binary file removed app/libs/editor-debug.aar
Binary file not shown.
62 changes: 0 additions & 62 deletions app/src/main/java/android/code/editor/common/utils/FileUtils.java

This file was deleted.

1 change: 1 addition & 0 deletions common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
plugins {
id 'com.android.library'
}

android {
compileSdk 32
buildToolsVersion "33.0.2"
useLibrary 'org.apache.http.legacy'
namespace "android.code.editor.common"

defaultConfig {
minSdk 21
targetSdk 28
compileSdkVersion 33
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

buildFeatures {
viewBinding true
}
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.code.gson:gson:2.8.7'
}
21 changes: 21 additions & 0 deletions common/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of Android Code Editor.
*
* Android Code Editor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Android Code Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Android Code Editor. If not, see <https://www.gnu.org/licenses/>.
*/

package android.code.editor.common.interfaces;

import java.io.File;

public interface FileDeleteListener {
public void onProgressUpdate(int deleteDone);

public void onTotalCount(int total);

public void onDeleting(File path);

public void onDeleteComplete(File path);

public void onTaskComplete();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package android.code.editor.common.utils;

import android.content.Context;
import android.content.res.AssetManager;

public class AssetsManager {
private Context myContext;

public AssetsManager(Context c) {
myContext = c;
}

public void saveFile(String path, String pathTo) {
copyFile(path, pathTo);
}

public void saveFolder(String path, String pathTo) {
copyAssets(path, pathTo);
}

private void copyAssets(final String _folder, final String _to) {
AssetManager assetManager = myContext.getAssets();
String[] files = null;
try {
files = assetManager.list(_folder);
} catch (java.io.IOException e) {
}
if (files != null)
for (String filename : files) {
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = assetManager.open(_folder + "/" + filename);
if (!new java.io.File(_to).exists()) {
new java.io.File(_to).mkdir();

java.io.File outFile = new java.io.File(_to, filename);
if (!(outFile.exists())) {
out = new java.io.FileOutputStream(outFile);
copyFile(in, out);
}

} else {

java.io.File outFile = new java.io.File(_to, filename);
if (!(outFile.exists())) {
out = new java.io.FileOutputStream(outFile);
copyFile(in, out);
}
}
} catch (java.io.IOException e) {
} finally {
if (in != null) {
try {
in.close();
} catch (java.io.IOException e) {
}
}
if (out != null) {
try {
out.close();
} catch (java.io.IOException e) {
}
}
}
}
}

private void copyFile(java.io.InputStream in, java.io.OutputStream out)
throws java.io.IOException {
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
}

private void copyFile(String filename, String outPath) {
AssetManager assetManager = myContext.getAssets();

java.io.InputStream in;
java.io.OutputStream out;
try {
in = assetManager.open(filename);
String newFileName = outPath + "/" + filename;
out = new java.io.FileOutputStream(newFileName);

byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
in.close();
out.flush();
out.close();
} catch (Exception e) {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package android.code.editor.common.utils;

import android.content.Context;
import com.google.android.material.color.MaterialColors;

public class ColorUtils {
public static String materialIntToHexColor(Context context, int res) {
return String.format("#%06X", (0xFFFFFF & MaterialColors.getColor(context, res, "#000000")));
}
}
Loading

0 comments on commit f618e00

Please sign in to comment.