Initial commit
14
.gitignore
vendored
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
1
.idea/.name
generated
Executable file
@ -0,0 +1 @@
|
|||||||
|
cryptoGX
|
116
.idea/codeStyles/Project.xml
generated
Executable file
@ -0,0 +1,116 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
20
.idea/gradle.xml
generated
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="PLATFORM" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
30
.idea/jarRepositories.xml
generated
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="Google" />
|
||||||
|
<option name="name" value="Google" />
|
||||||
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://jitpack.io" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
9
.idea/misc.xml
generated
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
12
.idea/runConfigurations.xml
generated
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# ⚠️ UNFINISHED PROJECT ⚠️
|
||||||
|
|
||||||
|
> The unfinished port of [cryptoGX](https://github.com/ByteDream/cryptoGX) for android
|
1
app/.gitignore
vendored
Executable file
@ -0,0 +1 @@
|
|||||||
|
/build
|
44
app/build.gradle
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 29
|
||||||
|
buildToolsVersion "29.0.3"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "org.blueshard.android.cryptogx"
|
||||||
|
minSdkVersion 18
|
||||||
|
targetSdkVersion 29
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||||
|
implementation 'com.google.android.gms:play-services-ads:19.2.0'
|
||||||
|
implementation 'com.google.android.material:material:1.1.0'
|
||||||
|
implementation 'com.android.support:design:29.0.0'
|
||||||
|
}
|
21
app/proguard-rules.pro
vendored
Executable file
@ -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
|
BIN
app/release/cryptoGX_android_1.0.apk
Executable file
1
app/release/output.json
Executable file
@ -0,0 +1 @@
|
|||||||
|
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release","dirName":""},"path":"app-release.apk","properties":{}}]
|
@ -0,0 +1,27 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
|
||||||
|
assertEquals("org.blueshard.android.cryptogx", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
34
app/src/main/AndroidManifest.xml
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="org.blueshard.android.cryptogx">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/cryptogx_icon_android"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/cryptogx_icon_android"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
tools:replace="android:theme">
|
||||||
|
<activity android:name=".filedirchooser.FileDirChooser"></activity>
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:screenOrientation="portrait">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
||||||
|
android:value="@string/app_id" />
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
60
app/src/main/java/org/blueshard/android/cryptogx/CollectionPagerAdapter.java
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||||
|
|
||||||
|
public class CollectionPagerAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
|
public CollectionPagerAdapter(FragmentManager fragmentManager) {
|
||||||
|
super(fragmentManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
position++;
|
||||||
|
|
||||||
|
if (position == 1) {
|
||||||
|
Fragment fragment = new TextEnDecrypt();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(TextEnDecrypt.ARG, position);
|
||||||
|
return fragment;
|
||||||
|
} else if (position == 2) {
|
||||||
|
Fragment fragment = new FileEnDecrypt();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(FileEnDecrypt.ARG, position);
|
||||||
|
return fragment;
|
||||||
|
} else if (position == 3) {
|
||||||
|
Fragment fragment = new SecureDeleteFiles();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(SecureDeleteFiles.ARG, position);
|
||||||
|
return fragment;
|
||||||
|
} else {
|
||||||
|
return new Fragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public CharSequence getPageTitle(int position) {
|
||||||
|
position++;
|
||||||
|
if (position == 1) {
|
||||||
|
return "text en- / decrypt";
|
||||||
|
} else if (position == 2) {
|
||||||
|
return "file en- / decrypt";
|
||||||
|
} else if (position == 3) {
|
||||||
|
return "secure delete files";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
283
app/src/main/java/org/blueshard/android/cryptogx/EnDecrypt.java
Executable file
@ -0,0 +1,283 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import android.util.Base64;
|
||||||
|
|
||||||
|
import javax.crypto.*;
|
||||||
|
import javax.crypto.spec.PBEKeySpec;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.io.*;
|
||||||
|
import java.security.*;
|
||||||
|
import java.security.spec.InvalidKeySpecException;
|
||||||
|
|
||||||
|
|
||||||
|
public class EnDecrypt {
|
||||||
|
|
||||||
|
public static String UTF_8 = "UTF-8";
|
||||||
|
|
||||||
|
public static class AES extends Thread {
|
||||||
|
|
||||||
|
public int iterations = 65536;
|
||||||
|
|
||||||
|
private final String secretKeyFactoryAlgorithm = "PBKDF2WithHmacSHA1";
|
||||||
|
|
||||||
|
private int keySize = 256;
|
||||||
|
|
||||||
|
private final String key;
|
||||||
|
private final byte[] salt;
|
||||||
|
private final String algorithm;
|
||||||
|
|
||||||
|
public AES(String key, byte[] salt, String algorithm) {
|
||||||
|
this.key = key;
|
||||||
|
this.salt = salt;
|
||||||
|
this.algorithm = algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AES(String key, byte[] salt, String algorithm, int keySize) {
|
||||||
|
this.key = key;
|
||||||
|
this.salt = salt;
|
||||||
|
this.algorithm = algorithm;
|
||||||
|
this.keySize = keySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AES(String key, byte[] salt, String algorithm, int iterations, int keySize) {
|
||||||
|
this.key = key;
|
||||||
|
this.salt = salt;
|
||||||
|
this.iterations = iterations;
|
||||||
|
this.algorithm = algorithm;
|
||||||
|
this.keySize = keySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] createSecretKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||||
|
SecretKeyFactory factory = SecretKeyFactory.getInstance(secretKeyFactoryAlgorithm);
|
||||||
|
PBEKeySpec keySpec = new PBEKeySpec(key.toCharArray(), salt, iterations, keySize);
|
||||||
|
|
||||||
|
return factory.generateSecret(keySpec).getEncoded();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Writes {@param inputStream} to {@param outputStream}</p>
|
||||||
|
*
|
||||||
|
* @param inputStream from which is written
|
||||||
|
* @param outputStream to which is written
|
||||||
|
* @param buffer
|
||||||
|
* @throws IOException
|
||||||
|
*
|
||||||
|
* @since 1.12.0
|
||||||
|
*/
|
||||||
|
private void write(InputStream inputStream, OutputStream outputStream, byte[] buffer) throws IOException {
|
||||||
|
int numOfBytesRead;
|
||||||
|
while ((numOfBytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, numOfBytesRead);
|
||||||
|
}
|
||||||
|
outputStream.close();
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Encrypts the {@param inputStream} to {@param outputStream}</p>
|
||||||
|
*
|
||||||
|
* @param inputStream that should be encrypted
|
||||||
|
* @param outputStream to which the encrypted {@param inputFile} should be written to
|
||||||
|
* @param buffer
|
||||||
|
* @throws InvalidKeySpecException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
* @throws NoSuchPaddingException
|
||||||
|
* @throws InvalidKeyException
|
||||||
|
* @throws IOException
|
||||||
|
*
|
||||||
|
* @since 1.12.0
|
||||||
|
*/
|
||||||
|
public void encryptFile(InputStream inputStream, OutputStream outputStream, byte[] buffer) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IOException {
|
||||||
|
Key secretKey = new SecretKeySpec(createSecretKey(), "AES");
|
||||||
|
|
||||||
|
Cipher cipher = Cipher.getInstance(algorithm);
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||||
|
|
||||||
|
CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher);
|
||||||
|
write(cipherInputStream, outputStream, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Encrypts all files in the {@param inputDirectory} to the {@param outputDirectory}</p>
|
||||||
|
*
|
||||||
|
* @param inputDirectory that should be encrypted
|
||||||
|
* @param outputDirectory to which the encrypted {@param inputDirectory} files should be written to
|
||||||
|
* @param fileEnding get added to every file that gets encrypted (if the {@param fileEnding} starts and ends with
|
||||||
|
* a '@', the {@param fileEnding} will get removed from the file if it exists)
|
||||||
|
* @param buffer
|
||||||
|
* @throws InvalidKeySpecException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
* @throws NoSuchPaddingException
|
||||||
|
* @throws InvalidKeyException
|
||||||
|
* @throws IOException
|
||||||
|
*
|
||||||
|
* @since 1.12.0
|
||||||
|
*/
|
||||||
|
public void encryptDirectory(String inputDirectory, String outputDirectory, String fileEnding, byte[] buffer) throws IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, NoSuchPaddingException {
|
||||||
|
boolean remove = false;
|
||||||
|
|
||||||
|
if (fileEnding == null) {
|
||||||
|
fileEnding = "";
|
||||||
|
} else if (fileEnding.startsWith("@") && fileEnding.endsWith("@")) {
|
||||||
|
fileEnding = fileEnding.substring(1, fileEnding.length() - 1);
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Utils.RecursivelyGetDirFile decryptedDir = new Utils.RecursivelyGetDirFile(new File(inputDirectory));
|
||||||
|
for (File dir: decryptedDir.getDirectories()) {
|
||||||
|
String dirPath = dir.getAbsolutePath();
|
||||||
|
new File(dirPath.replace(inputDirectory, outputDirectory + "/")).mkdir();
|
||||||
|
}
|
||||||
|
for (File file: decryptedDir.getFiles()) {
|
||||||
|
String filePath = file.getAbsolutePath();
|
||||||
|
if (remove) {
|
||||||
|
encryptFile(new FileInputStream(file),new FileOutputStream(new File(filePath
|
||||||
|
.substring(0, filePath.lastIndexOf(fileEnding))
|
||||||
|
.replace(inputDirectory, outputDirectory + "/") + fileEnding)), buffer);
|
||||||
|
} else {
|
||||||
|
encryptFile(new FileInputStream(file),new FileOutputStream(new File(filePath
|
||||||
|
.replace(inputDirectory, outputDirectory + "/") + fileEnding)), buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Decrypts the {@param inputStream} to {@param outputStream}</p>
|
||||||
|
*
|
||||||
|
* @param inputStream that should be decrypted
|
||||||
|
* @param outputStream to which the decrypted {@param inputFile} should be written to
|
||||||
|
* @param buffer
|
||||||
|
* @throws InvalidKeySpecException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
* @throws NoSuchPaddingException
|
||||||
|
* @throws InvalidKeyException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws InvalidAlgorithmParameterException
|
||||||
|
*
|
||||||
|
* @since 1.12.0
|
||||||
|
*/
|
||||||
|
public void decryptFile(InputStream inputStream, OutputStream outputStream, byte[] buffer) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IOException{
|
||||||
|
Key secretKey = new SecretKeySpec(createSecretKey(), "AES");
|
||||||
|
|
||||||
|
Cipher cipher = Cipher.getInstance(algorithm);
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, secretKey);
|
||||||
|
|
||||||
|
CipherOutputStream cipherOutputStream = new CipherOutputStream(outputStream, cipher);
|
||||||
|
write(inputStream, cipherOutputStream, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Decrypts all files in the {@param inputDirectory} to the {@param outputDirectory}</p>
|
||||||
|
*
|
||||||
|
* @param inputDirectory that should be decrypted
|
||||||
|
* @param outputDirectory to which the decrypted {@param inputDirectory} files should be written to
|
||||||
|
* @param fileEnding get added to every file that gets decrypted (if the {@param fileEnding} starts and ends with
|
||||||
|
* a '@', the {@param fileEnding} will get removed from the file if it exists)
|
||||||
|
* @param buffer
|
||||||
|
* @throws InvalidKeySpecException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
* @throws NoSuchPaddingException
|
||||||
|
* @throws InvalidKeyException
|
||||||
|
* @throws IOException
|
||||||
|
*
|
||||||
|
* @since 1.12.0
|
||||||
|
*/
|
||||||
|
public void decryptDirectory(String inputDirectory, String outputDirectory, String fileEnding, byte[] buffer) throws IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, NoSuchPaddingException {
|
||||||
|
boolean remove = false;
|
||||||
|
|
||||||
|
if (fileEnding == null) {
|
||||||
|
fileEnding = "";
|
||||||
|
} else if (fileEnding.startsWith("@") && fileEnding.endsWith("@")) {
|
||||||
|
fileEnding = fileEnding.substring(1, fileEnding.length() - 1);
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Utils.RecursivelyGetDirFile decryptedDir = new Utils.RecursivelyGetDirFile(new File(inputDirectory));
|
||||||
|
for (File dir: decryptedDir.getDirectories()) {
|
||||||
|
String dirPath = dir.getAbsolutePath();
|
||||||
|
new File(dirPath.replace(inputDirectory, outputDirectory + "/")).mkdir();
|
||||||
|
}
|
||||||
|
for (File file: decryptedDir.getFiles()) {
|
||||||
|
String filePath = file.getAbsolutePath();
|
||||||
|
if (remove) {
|
||||||
|
decryptFile(new FileInputStream(file),new FileOutputStream(new File(filePath
|
||||||
|
.substring(0, filePath.lastIndexOf(fileEnding))
|
||||||
|
.replace(inputDirectory, outputDirectory + "/") + fileEnding)), buffer);
|
||||||
|
} else {
|
||||||
|
decryptFile(new FileInputStream(file),new FileOutputStream(new File(filePath
|
||||||
|
.replace(inputDirectory, outputDirectory + "/") + fileEnding)), buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Encrypt {@param bytes}</p>
|
||||||
|
*
|
||||||
|
* @param bytes that should be encrypted
|
||||||
|
* @return encrypted bytes
|
||||||
|
* @throws BadPaddingException
|
||||||
|
* @throws IllegalBlockSizeException
|
||||||
|
* @throws NoSuchPaddingException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
* @throws InvalidKeySpecException
|
||||||
|
* @throws InvalidKeyException
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public byte[] encrypt(byte[] bytes) throws BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException {
|
||||||
|
Key secretKey = new SecretKeySpec(createSecretKey(), "AES");
|
||||||
|
|
||||||
|
Cipher encryptCipher = Cipher.getInstance(algorithm);
|
||||||
|
encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||||
|
return encryptCipher.doFinal(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Encrypt {@param bytes}</p>
|
||||||
|
*
|
||||||
|
* @param string that should be encrypted
|
||||||
|
*
|
||||||
|
* @see EnDecrypt.AES#encrypt(byte[])
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public String encrypt(String string) throws BadPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException, InvalidKeySpecException, UnsupportedEncodingException {
|
||||||
|
return android.util.Base64.encodeToString(encrypt(string.getBytes(UTF_8)), Base64.DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Decrypt encrypted {@param bytes}</p>
|
||||||
|
*
|
||||||
|
* @param bytes that should be decrypted
|
||||||
|
* @return decrypted bytes
|
||||||
|
* @throws BadPaddingException
|
||||||
|
* @throws IllegalBlockSizeException
|
||||||
|
* @throws NoSuchPaddingException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
* @throws InvalidKeySpecException
|
||||||
|
* @throws InvalidKeyException
|
||||||
|
*
|
||||||
|
* @since 1.12.0
|
||||||
|
*/
|
||||||
|
public byte[] decrypt(byte[] bytes) throws BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException {
|
||||||
|
Key secretKey = new SecretKeySpec(createSecretKey(), "AES");
|
||||||
|
|
||||||
|
Cipher decryptCipher = Cipher.getInstance(algorithm);
|
||||||
|
decryptCipher.init(Cipher.DECRYPT_MODE, secretKey);
|
||||||
|
return decryptCipher.doFinal(android.util.Base64.decode(bytes, Base64.DEFAULT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Decrypt encrypted {@param string}</p>
|
||||||
|
*
|
||||||
|
* @param string that should be decrypted
|
||||||
|
*
|
||||||
|
* @see EnDecrypt.AES#decrypt(byte[])
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public String decrypt(String string) throws BadPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException, InvalidKeySpecException, UnsupportedEncodingException {
|
||||||
|
return new String(decrypt(string.getBytes(UTF_8)), UTF_8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
306
app/src/main/java/org/blueshard/android/cryptogx/FileEnDecrypt.java
Executable file
@ -0,0 +1,306 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.gms.ads.AdSize;
|
||||||
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;;
|
||||||
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.spec.InvalidKeySpecException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
|
||||||
|
public class FileEnDecrypt extends Fragment {
|
||||||
|
|
||||||
|
public static final String ARG = "fileEnDecrypt";
|
||||||
|
|
||||||
|
private static Fragment fragment;
|
||||||
|
private static boolean permission = false;
|
||||||
|
private static byte[] buffer = new byte[64];
|
||||||
|
private static Map<String, Uri> idFileMap = Collections.synchronizedMap(new HashMap<String, Uri>());
|
||||||
|
private static final int fileChooseReturnCode = 23905;
|
||||||
|
|
||||||
|
private static ListView fileEnDecryptFileBox;
|
||||||
|
private static Spinner fileEnDecryptAlgorithms;
|
||||||
|
private static TextInputEditText fileEnDecryptKeyEntry;
|
||||||
|
private static TextInputEditText fileEnDecryptSaltEntry;
|
||||||
|
|
||||||
|
private static ArrayAdapter<String> fileEnDecryptFileBoxAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
if (requestCode == fileChooseReturnCode && resultCode == Activity.RESULT_OK) {
|
||||||
|
if (data.getClipData() != null) {
|
||||||
|
for (int i = 0; i < data.getClipData().getItemCount(); i++) {
|
||||||
|
try {
|
||||||
|
Uri uri = data.getClipData().getItemAt(i).getUri();
|
||||||
|
idFileMap.put(Utils.getFileName(this.getContext(), uri), uri);
|
||||||
|
fileEnDecryptFileBoxAdapter.add(Utils.getFileName(this.getContext(), uri));
|
||||||
|
fileEnDecryptFileBoxAdapter.notifyDataSetChanged();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (data.getData() != null) {
|
||||||
|
try {
|
||||||
|
Uri uri = data.getData();
|
||||||
|
idFileMap.put(Utils.getFileName(this.getContext(), uri), uri);
|
||||||
|
fileEnDecryptFileBoxAdapter.add(Utils.getFileName(this.getContext(), uri));
|
||||||
|
fileEnDecryptFileBoxAdapter.notifyDataSetChanged();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case 0:
|
||||||
|
permission = grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults.length > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.file_en_decrypt, container, false);
|
||||||
|
|
||||||
|
fragment = this;
|
||||||
|
|
||||||
|
fileEnDecryptKeyEntry = view.findViewById(R.id.fileEnDecryptKeyEntry);
|
||||||
|
fileEnDecryptSaltEntry = view.findViewById(R.id.fileEnDecryptSaltEntry);
|
||||||
|
fileEnDecryptFileBox = view.findViewById(R.id.fileEnDecryptFileBox);
|
||||||
|
fileEnDecryptFileBoxAdapter = new ArrayAdapter<>(this.getContext(), android.R.layout.simple_list_item_1);
|
||||||
|
fileEnDecryptFileBox.setAdapter(fileEnDecryptFileBoxAdapter);
|
||||||
|
fileEnDecryptAlgorithms = view.findViewById(R.id.fileEnDecryptAlgorithm);
|
||||||
|
|
||||||
|
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||||
|
int bannerSize = AdSize.BANNER.getHeight();
|
||||||
|
|
||||||
|
fileEnDecryptFileBox.getLayoutParams().height = Utils.percentOf(displayMetrics.heightPixels - bannerSize, 30);
|
||||||
|
|
||||||
|
int fileEnDecryptAdvancedTextWidth = view.findViewById(R.id.fileEnDecryptAdvancedText).getLayoutParams().width;
|
||||||
|
View fileEnDecryptSeparator1 = view.findViewById(R.id.fileEnDecryptSeparator1);
|
||||||
|
View fileEnDecryptSeparator2 = view.findViewById(R.id.fileEnDecryptSeparator2);
|
||||||
|
fileEnDecryptSeparator1.getLayoutParams().width = (displayMetrics.widthPixels - fileEnDecryptAdvancedTextWidth) / 2 - 10;
|
||||||
|
fileEnDecryptSeparator2.getLayoutParams().width = (displayMetrics.widthPixels - fileEnDecryptAdvancedTextWidth) / 2 - 10;
|
||||||
|
|
||||||
|
fileEnDecryptAlgorithms = view.findViewById(R.id.fileEnDecryptAlgorithm);
|
||||||
|
String[] algorithms = Utils.algorithms.keySet().toArray(new String[Utils.algorithms.size()]);
|
||||||
|
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(view.getContext(), android.R.layout.simple_list_item_1, algorithms);
|
||||||
|
fileEnDecryptAlgorithms.setAdapter(arrayAdapter);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void chooseFiles(View view) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
intent.setType("*/*");
|
||||||
|
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||||
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
|
||||||
|
fragment.startActivityForResult(Intent.createChooser(intent, "Choose files"), fileChooseReturnCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void encrypt(View view) {
|
||||||
|
permission = Utils.askPermission(fragment, Manifest.permission.WRITE_EXTERNAL_STORAGE, 0);
|
||||||
|
|
||||||
|
if (permission) {
|
||||||
|
File cryptoGXFileDir = new File(Environment.getExternalStorageDirectory() + "/cryptoGX/");
|
||||||
|
if (!cryptoGXFileDir.isDirectory()) {
|
||||||
|
if (!cryptoGXFileDir.mkdir()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.could_not_create_folder) + " cryptoGX", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
File cryptoGXEncryptedFilesDir = new File(cryptoGXFileDir + "/encrypted/");
|
||||||
|
if (!cryptoGXEncryptedFilesDir.isDirectory()) {
|
||||||
|
if (!cryptoGXEncryptedFilesDir.mkdir()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.could_not_create_folder) + " cryptoGX/encrypted", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String key = fileEnDecryptKeyEntry.getText().toString();
|
||||||
|
byte[] salt;
|
||||||
|
|
||||||
|
if (key.isEmpty()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.empty_key), Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fileEnDecryptSaltEntry.getText().toString().isEmpty()) {
|
||||||
|
salt = new byte[16];
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
salt = fileEnDecryptSaltEntry.getText().toString().getBytes(Utils.UTF_8);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
salt = new byte[16];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int lenght;
|
||||||
|
|
||||||
|
try {
|
||||||
|
lenght = Integer.parseInt(fileEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 7));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
try {
|
||||||
|
lenght = Integer.parseInt(fileEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 8));
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
lenght = Integer.parseInt(fileEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 6));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet<String> success = new HashSet<>();
|
||||||
|
|
||||||
|
EnDecrypt.AES encrypt = new EnDecrypt.AES(key,
|
||||||
|
salt,
|
||||||
|
Utils.algorithms.get(fileEnDecryptAlgorithms.getSelectedItem().toString()),
|
||||||
|
lenght);
|
||||||
|
|
||||||
|
for (Map.Entry<String, Uri> entry : idFileMap.entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
Uri file = entry.getValue();
|
||||||
|
|
||||||
|
try {
|
||||||
|
encrypt.encryptFile(view.getContext().getContentResolver().openInputStream(file), new FileOutputStream(cryptoGXEncryptedFilesDir + "/" + name + ".cryptoGX"), buffer);
|
||||||
|
success.add(name);
|
||||||
|
} catch (NoSuchPaddingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidKeyException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidKeySpecException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String name: success) {
|
||||||
|
idFileMap.remove(name);
|
||||||
|
fileEnDecryptFileBoxAdapter.remove(name);
|
||||||
|
}
|
||||||
|
fileEnDecryptFileBoxAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void decrypt(View view) {
|
||||||
|
permission = Utils.askPermission(fragment, Manifest.permission.WRITE_EXTERNAL_STORAGE, 0);
|
||||||
|
|
||||||
|
if (permission) {
|
||||||
|
File cryptoGXFileDir = new File(Environment.getExternalStorageDirectory() + "/cryptoGX/");
|
||||||
|
if (!cryptoGXFileDir.isDirectory()) {
|
||||||
|
if (!cryptoGXFileDir.mkdir()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.could_not_create_folder) + " cryptoGX", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
File cryptoGXDecryptedFilesDir = new File(cryptoGXFileDir + "/decrypted/");
|
||||||
|
if (!cryptoGXDecryptedFilesDir.isDirectory()) {
|
||||||
|
if (!cryptoGXDecryptedFilesDir.mkdir()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.could_not_create_folder) + " cryptoGX/decrypted", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String key = fileEnDecryptKeyEntry.getText().toString();
|
||||||
|
byte[] salt;
|
||||||
|
|
||||||
|
if (key.isEmpty()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.empty_key), Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fileEnDecryptSaltEntry.getText().toString().isEmpty()) {
|
||||||
|
salt = new byte[16];
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
salt = fileEnDecryptSaltEntry.getText().toString().getBytes(Utils.UTF_8);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
salt = new byte[16];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int lenght;
|
||||||
|
|
||||||
|
try {
|
||||||
|
lenght = Integer.parseInt(fileEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 7));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
try {
|
||||||
|
lenght = Integer.parseInt(fileEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 8));
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
lenght = Integer.parseInt(fileEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 6));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet<String> success = new HashSet<>();
|
||||||
|
|
||||||
|
EnDecrypt.AES decrypt = new EnDecrypt.AES(key,
|
||||||
|
salt,
|
||||||
|
Utils.algorithms.get(fileEnDecryptAlgorithms.getSelectedItem().toString()),
|
||||||
|
lenght);
|
||||||
|
|
||||||
|
for (Map.Entry<String, Uri> entry : idFileMap.entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
Uri file = entry.getValue();
|
||||||
|
|
||||||
|
try {
|
||||||
|
decrypt.decryptFile(view.getContext().getContentResolver().openInputStream(file), new FileOutputStream(cryptoGXDecryptedFilesDir + "/" + name + ".cryptoGX"), buffer);
|
||||||
|
success.add(name);
|
||||||
|
} catch (NoSuchPaddingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidKeyException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidKeySpecException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String name: success) {
|
||||||
|
idFileMap.remove(name);
|
||||||
|
fileEnDecryptFileBoxAdapter.remove(name);
|
||||||
|
}
|
||||||
|
fileEnDecryptFileBoxAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
223
app/src/main/java/org/blueshard/android/cryptogx/MainActivity.java
Executable file
@ -0,0 +1,223 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
|
import com.google.android.gms.ads.AdRequest;
|
||||||
|
import com.google.android.gms.ads.AdSize;
|
||||||
|
import com.google.android.gms.ads.AdView;
|
||||||
|
import com.google.android.gms.ads.MobileAds;
|
||||||
|
import com.google.android.gms.ads.initialization.InitializationStatus;
|
||||||
|
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Set<Thread> textEnDecryptThreads = Collections.synchronizedSet(new HashSet<Thread>());
|
||||||
|
private Set<Thread> fileEnDecryptThreads = Collections.synchronizedSet(new HashSet<Thread>());
|
||||||
|
private Set<Thread> fileDeleteThreads = Collections.synchronizedSet(new HashSet<Thread>());
|
||||||
|
private AppCompatActivity mainView;
|
||||||
|
|
||||||
|
CollectionPagerAdapter fragmentChanger;
|
||||||
|
ViewPager viewPager;
|
||||||
|
|
||||||
|
@SuppressLint("SourceLockedOrientationActivity")
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
mainView = this;
|
||||||
|
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
|
||||||
|
MobileAds.initialize(this, new OnInitializationCompleteListener() {
|
||||||
|
@Override
|
||||||
|
public void onInitializationComplete(InitializationStatus initializationStatus) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AdView adView = new AdView(this);
|
||||||
|
adView.setAdSize(AdSize.BANNER);
|
||||||
|
adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
|
||||||
|
|
||||||
|
adView = findViewById(R.id.adView);
|
||||||
|
AdRequest adRequest = new AdRequest.Builder().build();
|
||||||
|
adView.loadAd(adRequest);
|
||||||
|
|
||||||
|
fragmentChanger = new CollectionPagerAdapter(getSupportFragmentManager());
|
||||||
|
viewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
|
viewPager.setAdapter(fragmentChanger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void encryptTextButton(final View view) {
|
||||||
|
final ProgressBar textEnDecryptProgressBar = mainView.findViewById(R.id.textEnDecryptProgressBar);
|
||||||
|
textEnDecryptProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
Thread thread = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
textEnDecryptThreads.add(Thread.currentThread());
|
||||||
|
TextEnDecrypt.encrypt(view);
|
||||||
|
if (textEnDecryptThreads.size() - 1 <= 0) {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
textEnDecryptProgressBar.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
textEnDecryptThreads.remove(Thread.currentThread());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decryptTextButton(final View view) {
|
||||||
|
final ProgressBar textEnDecryptProgressBar = mainView.findViewById(R.id.textEnDecryptProgressBar);
|
||||||
|
textEnDecryptProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
Thread thread = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
textEnDecryptThreads.add(currentThread());
|
||||||
|
TextEnDecrypt.decrypt(view);
|
||||||
|
if (textEnDecryptThreads.size() - 1 <= 0) {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
textEnDecryptProgressBar.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
textEnDecryptThreads.remove(currentThread());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------//
|
||||||
|
|
||||||
|
public void fileEnDecryptChooseFiles(View view) {
|
||||||
|
FileEnDecrypt.chooseFiles(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void encryptFileButton(final View view) {
|
||||||
|
final ProgressBar fileEnDecryptProgressBar = mainView.findViewById(R.id.fileEnDecryptProgressBar);
|
||||||
|
fileEnDecryptProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
Thread thread = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fileEnDecryptThreads.add(currentThread());
|
||||||
|
FileEnDecrypt.encrypt(view);
|
||||||
|
if (fileEnDecryptThreads.size() - 1 <= 0) {
|
||||||
|
fileEnDecryptProgressBar.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
fileEnDecryptThreads.remove(currentThread());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decryptFileButton(final View view) {
|
||||||
|
final ProgressBar fileEnDecryptProgressBar = mainView.findViewById(R.id.fileEnDecryptProgressBar);
|
||||||
|
fileEnDecryptProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
Thread thread = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fileEnDecryptThreads.add(currentThread());
|
||||||
|
FileEnDecrypt.decrypt(view);
|
||||||
|
if (fileEnDecryptThreads.size() - 1 <= 0) {
|
||||||
|
fileEnDecryptProgressBar.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
fileEnDecryptThreads.remove(currentThread());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelEnDecryptFileButton(View view) {
|
||||||
|
for (Iterator<Thread> iterator = fileEnDecryptThreads.iterator(); iterator.hasNext();) {
|
||||||
|
Thread thread = iterator.next();
|
||||||
|
while (thread.isAlive() && !thread.isInterrupted()) {
|
||||||
|
thread.stop();
|
||||||
|
thread.interrupt();
|
||||||
|
}
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
mainView.findViewById(R.id.fileEnDecryptProgressBar).setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------//
|
||||||
|
|
||||||
|
public void fileDeleteChooseFiles(View view) {
|
||||||
|
SecureDeleteFiles.chooseFiles(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteFileButton(final View view) {
|
||||||
|
final ProgressBar fileEnDecryptProgressBar = mainView.findViewById(R.id.fileDeleteProgressBar);
|
||||||
|
fileEnDecryptProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
Thread thread = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fileDeleteThreads.add(currentThread());
|
||||||
|
SecureDeleteFiles.delete(view);
|
||||||
|
if (fileDeleteThreads.size() - 1 <= 0) {
|
||||||
|
fileEnDecryptProgressBar.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
fileDeleteThreads.remove(currentThread());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelDeleteFileButton(View view) {
|
||||||
|
for (Iterator<Thread> iterator = fileDeleteThreads.iterator(); iterator.hasNext();) {
|
||||||
|
Thread thread = iterator.next();
|
||||||
|
while (thread.isAlive() && !thread.isInterrupted()) {
|
||||||
|
thread.stop();
|
||||||
|
thread.interrupt();
|
||||||
|
}
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
mainView.findViewById(R.id.fileDeleteProgressBar).setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
196
app/src/main/java/org/blueshard/android/cryptogx/SecureDelete.java
Executable file
@ -0,0 +1,196 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class SecureDelete {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Overwrites the file {@param iterations} times at once with random bytes an delete it</p>
|
||||||
|
*
|
||||||
|
* @see SecureDelete#deleteFileAllInOne(File, int)
|
||||||
|
*/
|
||||||
|
public static boolean deleteFileAllInOne(String filename, int iterations) throws IOException, NoSuchAlgorithmException {
|
||||||
|
return deleteFileAllInOne(new File(filename), iterations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Overwrites the file {@param iterations} times at once with random bytes and delete it</p>
|
||||||
|
*
|
||||||
|
* @param file that should be deleted
|
||||||
|
* @param iterations how many times the file should be overwritten before it gets deleted
|
||||||
|
* @return if the file could be deleted
|
||||||
|
* @throws IOException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
*/
|
||||||
|
public static boolean deleteFileAllInOne(File file, int iterations) throws IOException, NoSuchAlgorithmException {
|
||||||
|
long fileLength = file.length() + 1 ;
|
||||||
|
for (int i=0; i<iterations; i++) {
|
||||||
|
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
|
||||||
|
if (fileLength > 1000000000) {
|
||||||
|
int numOfByteArrays = (int) Math.ceil((double) fileLength / 1000000000);
|
||||||
|
for (int len=0; len<numOfByteArrays; len++) {
|
||||||
|
int newMaxFileSize = (int) fileLength / numOfByteArrays;
|
||||||
|
int newMinFileSize = 0;
|
||||||
|
byte[] randomBytes = new byte[new Random().nextInt(newMaxFileSize - newMinFileSize) + newMinFileSize];
|
||||||
|
SecureRandom.getInstance("SHA1PRNG").nextBytes(randomBytes);
|
||||||
|
bufferedOutputStream.write(randomBytes);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
byte[] randomBytes = new byte[new Random().nextInt((int) fileLength)];
|
||||||
|
SecureRandom.getInstance("SHA1PRNG").nextBytes(randomBytes);
|
||||||
|
bufferedOutputStream.write(randomBytes);
|
||||||
|
}
|
||||||
|
bufferedOutputStream.flush();
|
||||||
|
bufferedOutputStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Overwrites the file {@param iterations} times at once with random bytes (minimal size {@param minFileSize}; maximal size {@param maxFileSize}) and delete it</p>
|
||||||
|
*
|
||||||
|
* @see SecureDelete#deleteFileAllInOne(String, int, long, long)
|
||||||
|
*/
|
||||||
|
public static boolean deleteFileAllInOne(String filename, int iterations, long minFileSize, long maxFileSize) throws IOException, NoSuchAlgorithmException {
|
||||||
|
return deleteFileAllInOne(new File(filename), iterations, minFileSize, maxFileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Overwrites the file {@param iterations} times at once with random bytes (minimal size {@param minFileSize}; maximal size {@param maxFileSize}) and delete it</p>
|
||||||
|
*
|
||||||
|
* @param file that should be deleted
|
||||||
|
* @param iterations how many times the file should be overwritten before it gets deleted
|
||||||
|
* @param minFileSize is the minimal file size for every {@param iterations}
|
||||||
|
* @param maxFileSize is the maximal file size for every {@param iterations}
|
||||||
|
* @return if the file could be deleted
|
||||||
|
* @throws IOException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
*/
|
||||||
|
public static boolean deleteFileAllInOne(File file, int iterations, long minFileSize, long maxFileSize) throws IOException, NoSuchAlgorithmException {
|
||||||
|
for (int i = 0; i < iterations; i++) {
|
||||||
|
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
|
||||||
|
if (maxFileSize > 1000000000) {
|
||||||
|
int numOfByteArrays = (int) Math.ceil((double) maxFileSize / 1000000000);
|
||||||
|
for (int len = 0; len < numOfByteArrays; len++) {
|
||||||
|
int newMaxFileSize = (int) maxFileSize / numOfByteArrays;
|
||||||
|
int newMinFileSize = 0;
|
||||||
|
if (minFileSize != 0) {
|
||||||
|
newMinFileSize = (int) minFileSize / numOfByteArrays;
|
||||||
|
}
|
||||||
|
byte[] randomBytes = new byte[new Random().nextInt(newMaxFileSize - newMinFileSize) + newMinFileSize];
|
||||||
|
SecureRandom.getInstance("SHA1PRNG").nextBytes(randomBytes);
|
||||||
|
bufferedOutputStream.write(randomBytes);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
byte[] randomBytes = new byte[new Random().nextInt((int) maxFileSize - (int) minFileSize) + (int) minFileSize];
|
||||||
|
SecureRandom.getInstance("SHA1PRNG").nextBytes(randomBytes);
|
||||||
|
bufferedOutputStream.write(randomBytes);
|
||||||
|
}
|
||||||
|
bufferedOutputStream.flush();
|
||||||
|
bufferedOutputStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Overwrites the file {@param iterations} times line by line with random bytes and delete it</p>
|
||||||
|
*
|
||||||
|
* @see SecureDelete#deleteFileLineByLine(File, int)
|
||||||
|
*/
|
||||||
|
public static boolean deleteFileLineByLine(String filename, int iterations) throws NoSuchAlgorithmException, IOException {
|
||||||
|
return deleteFileLineByLine(new File(filename), iterations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Overwrites the file {@param iterations} times line by line with random bytes and delete it</p>
|
||||||
|
*
|
||||||
|
* @param file that should be deleted
|
||||||
|
* @param iterations how many times the file should be overwritten before it gets deleted
|
||||||
|
* @return if the file could be deleted
|
||||||
|
* @throws IOException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
*/
|
||||||
|
public static boolean deleteFileLineByLine(File file, int iterations) throws NoSuchAlgorithmException, IOException {
|
||||||
|
long fileLength = file.length() + 1 ;
|
||||||
|
for (int i=0; i<iterations; i++) {
|
||||||
|
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
|
||||||
|
if (fileLength > 1000000000) {
|
||||||
|
int numOfByteArrays = (int) Math.ceil((double) fileLength / 1000000000);
|
||||||
|
for (int len=0; len<numOfByteArrays; len++) {
|
||||||
|
int newMaxFileSize = (int) fileLength / numOfByteArrays;
|
||||||
|
int newMinFileSize = 0;
|
||||||
|
byte[] randomBytes = new byte[new Random().nextInt(newMaxFileSize - newMinFileSize) + newMinFileSize];
|
||||||
|
SecureRandom.getInstance("SHA1PRNG").nextBytes(randomBytes);
|
||||||
|
for (byte b: randomBytes) {
|
||||||
|
bufferedOutputStream.write(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
byte[] randomBytes = new byte[new Random().nextInt((int) fileLength)];
|
||||||
|
SecureRandom.getInstance("SHA1PRNG").nextBytes(randomBytes);
|
||||||
|
for (byte b : randomBytes) {
|
||||||
|
bufferedOutputStream.write(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bufferedOutputStream.flush();
|
||||||
|
bufferedOutputStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Overwrites the file {@param iterations} times line by line with random bytes (minimal size {@param minFileSize}; maximal size {@param maxFileSize}) and delete it</p>
|
||||||
|
*/
|
||||||
|
public static boolean deleteFileLineByLine(String filename, int iterations, long minFileSize, long maxFileSize) throws NoSuchAlgorithmException, IOException {
|
||||||
|
return deleteFileLineByLine(new File(filename), iterations, minFileSize, maxFileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Overwrites the file {@param iterations} times line by line with random bytes (minimal size {@param minFileSize}; maximal size {@param maxFileSize}) and delete it</p>
|
||||||
|
*
|
||||||
|
* @param file that should be deleted
|
||||||
|
* @param iterations how many times the file should be overwritten before it gets deleted
|
||||||
|
* @param minFileSize is the minimal file size for every {@param iterations}
|
||||||
|
* @param maxFileSize is the maximal file size for every {@param iterations}
|
||||||
|
* @return if the file could be deleted
|
||||||
|
* @throws IOException
|
||||||
|
* @throws NoSuchAlgorithmException
|
||||||
|
*/
|
||||||
|
public static boolean deleteFileLineByLine(File file, int iterations, long minFileSize, long maxFileSize) throws NoSuchAlgorithmException, IOException {
|
||||||
|
for (int i=0; i<iterations; i++) {
|
||||||
|
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
|
||||||
|
if (maxFileSize > 1000000000) {
|
||||||
|
int numOfByteArrays = (int) Math.ceil((double) maxFileSize / 1000000000);
|
||||||
|
for (int len=0; len<numOfByteArrays; len++) {
|
||||||
|
int newMaxFileSize = (int) maxFileSize / numOfByteArrays;
|
||||||
|
int newMinFileSize = 0;
|
||||||
|
if (minFileSize != 0) {
|
||||||
|
newMinFileSize = (int) minFileSize / numOfByteArrays;
|
||||||
|
}
|
||||||
|
byte[] randomBytes = new byte[new Random().nextInt(newMaxFileSize - newMinFileSize) + newMinFileSize];
|
||||||
|
SecureRandom.getInstance("SHA1PRNG").nextBytes(randomBytes);
|
||||||
|
for (byte b: randomBytes) {
|
||||||
|
bufferedOutputStream.write(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
byte[] randomBytes = new byte[new Random().nextInt((int) maxFileSize - (int) minFileSize) + (int) minFileSize];
|
||||||
|
SecureRandom.getInstance("SHA1PRNG").nextBytes(randomBytes);
|
||||||
|
for (byte b : randomBytes) {
|
||||||
|
bufferedOutputStream.write(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bufferedOutputStream.flush();
|
||||||
|
bufferedOutputStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
166
app/src/main/java/org/blueshard/android/cryptogx/SecureDeleteFiles.java
Executable file
@ -0,0 +1,166 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.android.gms.ads.AdSize;
|
||||||
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
|
|
||||||
|
import org.blueshard.android.cryptogx.filedirchooser.FileDirChooser;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SecureDeleteFiles extends Fragment {
|
||||||
|
|
||||||
|
public static final String ARG = "secureDeleteFiles";
|
||||||
|
|
||||||
|
private static Fragment fragment;
|
||||||
|
private static boolean permission;
|
||||||
|
private static final int fileChooseReturnCode = 34589;
|
||||||
|
|
||||||
|
private static ListView fileDeleteFileBox;
|
||||||
|
private static TextInputEditText fileDeleteIterationsEntry;
|
||||||
|
|
||||||
|
private static Map<String, Uri> idFileMap = Collections.synchronizedMap(new HashMap<String, Uri>());
|
||||||
|
|
||||||
|
private static ArrayAdapter<String> fileDeleteFileBoxAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
if (requestCode == fileChooseReturnCode && resultCode == Activity.RESULT_OK) {
|
||||||
|
if (data.getClipData() != null) {
|
||||||
|
for (int i = 0; i < data.getClipData().getItemCount(); i++) {
|
||||||
|
try {
|
||||||
|
Uri uri = data.getClipData().getItemAt(i).getUri();
|
||||||
|
idFileMap.put(Utils.getFileName(this.getContext(), uri), uri);
|
||||||
|
fileDeleteFileBoxAdapter.add(Utils.getFileName(this.getContext(), uri));
|
||||||
|
fileDeleteFileBoxAdapter.notifyDataSetChanged();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (data.getData() != null) {
|
||||||
|
try {
|
||||||
|
Uri uri = data.getData();
|
||||||
|
idFileMap.put(Utils.getFileName(this.getContext(), uri), uri);
|
||||||
|
fileDeleteFileBoxAdapter.add(Utils.getFileName(this.getContext(), uri));
|
||||||
|
fileDeleteFileBoxAdapter.notifyDataSetChanged();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case 0:
|
||||||
|
permission = grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults.length > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.secure_delete_files, container, false);
|
||||||
|
|
||||||
|
fragment = this;
|
||||||
|
|
||||||
|
fileDeleteFileBox = view.findViewById(R.id.fileDeleteFileBox);
|
||||||
|
fileDeleteFileBoxAdapter = new ArrayAdapter<>(this.getContext(), android.R.layout.simple_list_item_1);
|
||||||
|
fileDeleteFileBox.setAdapter(fileDeleteFileBoxAdapter);
|
||||||
|
fileDeleteIterationsEntry = view.findViewById(R.id.fileDeleteIterationsEntry);
|
||||||
|
|
||||||
|
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||||
|
int bannerSize = AdSize.BANNER.getHeight();
|
||||||
|
|
||||||
|
ListView fileDeleteFileBox = view.findViewById(R.id.fileDeleteFileBox);
|
||||||
|
fileDeleteFileBox.getLayoutParams().height = Utils.percentOf(displayMetrics.heightPixels - bannerSize, 44);
|
||||||
|
|
||||||
|
int fileDeleteAdvancedTextWidth = view.findViewById(R.id.fileDeleteAdvancedText).getLayoutParams().width;
|
||||||
|
View fileDeleteSeparator1 = view.findViewById(R.id.fileDeleteSeparator1);
|
||||||
|
View fileDeleteSeparator2 = view.findViewById(R.id.fileDeleteSeparator2);
|
||||||
|
fileDeleteSeparator1.getLayoutParams().width = (displayMetrics.widthPixels - fileDeleteAdvancedTextWidth) / 2 - 10;
|
||||||
|
fileDeleteSeparator2.getLayoutParams().width = (displayMetrics.widthPixels - fileDeleteAdvancedTextWidth) / 2 - 10;
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void chooseFiles(View view) {
|
||||||
|
Intent i = new Intent(fragment.getContext(), FileDirChooser.class);
|
||||||
|
fragment.startActivity(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void delete(View view) {
|
||||||
|
permission = Utils.askPermission(fragment, Manifest.permission.WRITE_EXTERNAL_STORAGE, 0);
|
||||||
|
|
||||||
|
if (permission) {
|
||||||
|
HashSet<String> success = new HashSet<>();
|
||||||
|
int iterations;
|
||||||
|
try {
|
||||||
|
String iterationEntry = fileDeleteIterationsEntry.getText().toString();
|
||||||
|
if (iterationEntry.isEmpty()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.empty_iterations), Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
iterations = Integer.parseInt(iterationEntry);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.wrong_iterations), Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, Uri> entry: idFileMap.entrySet()) {
|
||||||
|
try {
|
||||||
|
File file = new File(Utils.getPath(view.getContext(), entry.getValue()));
|
||||||
|
if (file == null) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.no_file_path) + " " + entry.getKey(), Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
SecureDelete.deleteFileLineByLine(file, iterations);
|
||||||
|
while (file.isFile()) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
success.add(entry.getKey());
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String name: success) {
|
||||||
|
idFileMap.remove(name);
|
||||||
|
fileDeleteFileBoxAdapter.remove(name);
|
||||||
|
}
|
||||||
|
fileDeleteFileBoxAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
171
app/src/main/java/org/blueshard/android/cryptogx/TextEnDecrypt.java
Executable file
@ -0,0 +1,171 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.google.android.gms.ads.AdSize;
|
||||||
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.spec.InvalidKeySpecException;
|
||||||
|
|
||||||
|
import javax.crypto.BadPaddingException;
|
||||||
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
|
||||||
|
public class TextEnDecrypt extends Fragment {
|
||||||
|
|
||||||
|
private static TextInputEditText textEnDecryptKeyEntry;
|
||||||
|
private static TextInputEditText textEnDecryptSaltEntry;
|
||||||
|
private static EditText textEnDecryptDecryptedText;
|
||||||
|
private static EditText textEnDecryptEncryptedText;
|
||||||
|
private static Spinner textEnDecryptAlgorithms;
|
||||||
|
|
||||||
|
public static final String ARG = "textEnDecrypt";
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.text_en_decrypt, container, false);
|
||||||
|
|
||||||
|
textEnDecryptKeyEntry = view.findViewById(R.id.textEnDecryptKeyEntry);
|
||||||
|
textEnDecryptSaltEntry = view.findViewById(R.id.textEnDecryptSaltEntry);
|
||||||
|
textEnDecryptDecryptedText = view.findViewById(R.id.textEnDecryptDecryptedText);
|
||||||
|
textEnDecryptEncryptedText = view.findViewById(R.id.textEnDecryptEncryptedText);
|
||||||
|
|
||||||
|
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||||
|
int bannerSize = AdSize.BANNER.getHeight();
|
||||||
|
|
||||||
|
EditText textEnDecryptDecryptedText = view.findViewById(R.id.textEnDecryptDecryptedText);
|
||||||
|
textEnDecryptDecryptedText.getLayoutParams().height = Utils.percentOf(displayMetrics.heightPixels - bannerSize, 21);
|
||||||
|
|
||||||
|
EditText textEnDecryptEncryptedText = view.findViewById(R.id.textEnDecryptEncryptedText);
|
||||||
|
textEnDecryptEncryptedText.getLayoutParams().height = Utils.percentOf(displayMetrics.heightPixels - bannerSize, 21);
|
||||||
|
|
||||||
|
int textEnDecryptAdvancedTextWidth = view.findViewById(R.id.textEnDecryptAdvancedText).getLayoutParams().width;
|
||||||
|
View textEnDecryptSeparator1 = view.findViewById(R.id.textEnDecryptSeparator1);
|
||||||
|
View textEnDecryptSeparator2 = view.findViewById(R.id.textEnDecryptSeparator2);
|
||||||
|
textEnDecryptSeparator1.getLayoutParams().width = (displayMetrics.widthPixels - textEnDecryptAdvancedTextWidth) / 2 - 10;
|
||||||
|
textEnDecryptSeparator2.getLayoutParams().width = (displayMetrics.widthPixels - textEnDecryptAdvancedTextWidth) / 2 - 10;
|
||||||
|
|
||||||
|
textEnDecryptAlgorithms = view.findViewById(R.id.textEnDecryptAlgorithms);
|
||||||
|
String[] algorithms = Utils.algorithms.keySet().toArray(new String[Utils.algorithms.size()]);
|
||||||
|
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(view.getContext(), android.R.layout.simple_spinner_item, algorithms);
|
||||||
|
textEnDecryptAlgorithms.setAdapter(arrayAdapter);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void encrypt(View view) {
|
||||||
|
if (textEnDecryptKeyEntry.getText().toString().isEmpty()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.empty_key), Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
byte[] salt;
|
||||||
|
int lenght;
|
||||||
|
|
||||||
|
try {
|
||||||
|
lenght = Integer.parseInt(textEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 7));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
try {
|
||||||
|
lenght = Integer.parseInt(textEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 8));
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
lenght = Integer.parseInt(textEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 6));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textEnDecryptSaltEntry.getText().toString().isEmpty()) {
|
||||||
|
salt = new byte[16];
|
||||||
|
} else {
|
||||||
|
salt = textEnDecryptSaltEntry.getText().toString().getBytes(EnDecrypt.UTF_8);
|
||||||
|
}
|
||||||
|
EnDecrypt.AES encrypt = new EnDecrypt.AES(textEnDecryptKeyEntry.getText().toString(),
|
||||||
|
salt,
|
||||||
|
Utils.algorithms.get(textEnDecryptAlgorithms.getSelectedItem().toString()),
|
||||||
|
lenght);
|
||||||
|
String encryptedText = encrypt.encrypt(textEnDecryptDecryptedText.getText().toString());
|
||||||
|
textEnDecryptEncryptedText.setText(encryptedText);
|
||||||
|
} catch (InvalidKeySpecException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (BadPaddingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidKeyException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchPaddingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalBlockSizeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void decrypt(View view) {
|
||||||
|
if (textEnDecryptKeyEntry.getText().toString().isEmpty()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.empty_key), Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
} else if (textEnDecryptEncryptedText.getText().toString().isEmpty()) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.empty_encrypted_text), Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
byte[] salt;
|
||||||
|
int lenght;
|
||||||
|
|
||||||
|
try {
|
||||||
|
lenght = Integer.parseInt(textEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 7));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
try {
|
||||||
|
lenght = Integer.parseInt(textEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 8));
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
lenght = Integer.parseInt(textEnDecryptAlgorithms.getSelectedItem().toString().substring(4, 6));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textEnDecryptSaltEntry.getText().toString().isEmpty()) {
|
||||||
|
salt = new byte[16];
|
||||||
|
} else {
|
||||||
|
salt = textEnDecryptSaltEntry.getText().toString().getBytes(EnDecrypt.UTF_8);
|
||||||
|
}
|
||||||
|
EnDecrypt.AES decrypt = new EnDecrypt.AES(textEnDecryptKeyEntry.getText().toString(),
|
||||||
|
salt,
|
||||||
|
Utils.algorithms.get(textEnDecryptAlgorithms.getSelectedItem().toString()),
|
||||||
|
lenght);
|
||||||
|
String encryptedText = decrypt.decrypt(textEnDecryptEncryptedText.getText().toString());
|
||||||
|
textEnDecryptDecryptedText.setText(encryptedText);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Toast.makeText(view.getContext(), view.getResources().getString(R.string.empty_key), Toast.LENGTH_LONG).show();
|
||||||
|
} catch (InvalidKeySpecException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (BadPaddingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidKeyException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchPaddingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalBlockSizeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
314
app/src/main/java/org/blueshard/android/cryptogx/Utils.java
Executable file
@ -0,0 +1,314 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.ContentUris;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.media.ThumbnailUtils;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.DocumentsContract;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.provider.OpenableColumns;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.Size;
|
||||||
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
|
||||||
|
public static final int normalFile = 0;
|
||||||
|
public static final int imageFile = 1;
|
||||||
|
public static final int audioFile = 2;
|
||||||
|
public static final int videoFile = 3;
|
||||||
|
|
||||||
|
public static String UTF_8 = "UTF-8";
|
||||||
|
public static TreeMap<String, String> algorithms = allAlgorithms();
|
||||||
|
|
||||||
|
private static TreeMap<String, String> allAlgorithms() {
|
||||||
|
TreeMap<String, String> return_map = new TreeMap<>();
|
||||||
|
|
||||||
|
int[] aesKeySizes = {128, 192, 256};
|
||||||
|
|
||||||
|
for (int i: aesKeySizes) {
|
||||||
|
return_map.put("AES-" + i, "AES");
|
||||||
|
}
|
||||||
|
|
||||||
|
return return_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean askPermission(Fragment fragment, String permission, int requestCode) {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||||
|
int permissionCheck = fragment.getContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
|
||||||
|
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
fragment.requestPermissions(new String[]{permission}, requestCode);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFileName(Context context, Uri uri) {
|
||||||
|
String result = null;
|
||||||
|
if (uri.getScheme().equals("content")) {
|
||||||
|
Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
|
||||||
|
try {
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result == null) {
|
||||||
|
result = uri.getPath();
|
||||||
|
int cut = result.lastIndexOf('/');
|
||||||
|
if (cut != -1) {
|
||||||
|
result = result.substring(cut + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPath(final Context context, final Uri uri) {
|
||||||
|
|
||||||
|
// check here to KITKAT or new version
|
||||||
|
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||||
|
|
||||||
|
// DocumentProvider
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
|
||||||
|
// ExternalStorageProvider
|
||||||
|
if (GetPathUtils.isExternalStorageDocument(uri)) {
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
final String type = split[0];
|
||||||
|
|
||||||
|
if ("primary".equalsIgnoreCase(type)) {
|
||||||
|
return Environment.getExternalStorageDirectory() + "/"
|
||||||
|
+ split[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// DownloadsProvider
|
||||||
|
else if (GetPathUtils.isDownloadsDocument(uri)) {
|
||||||
|
|
||||||
|
final String id = DocumentsContract.getDocumentId(uri);
|
||||||
|
final Uri contentUri = ContentUris.withAppendedId(
|
||||||
|
Uri.parse("content://downloads/public_downloads"),
|
||||||
|
Long.valueOf(id));
|
||||||
|
|
||||||
|
return GetPathUtils.getDataColumn(context, contentUri, null, null);
|
||||||
|
}
|
||||||
|
// MediaProvider
|
||||||
|
else if (GetPathUtils.isMediaDocument(uri)) {
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
final String type = split[0];
|
||||||
|
|
||||||
|
Uri contentUri = null;
|
||||||
|
if ("image".equals(type)) {
|
||||||
|
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
} else if ("video".equals(type)) {
|
||||||
|
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
} else if ("audio".equals(type)) {
|
||||||
|
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String selection = "_id=?";
|
||||||
|
final String[] selectionArgs = new String[]{split[1]};
|
||||||
|
|
||||||
|
return GetPathUtils.getDataColumn(context, contentUri, selection,
|
||||||
|
selectionArgs);
|
||||||
|
}
|
||||||
|
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||||
|
|
||||||
|
// Return the remote address
|
||||||
|
if (GetPathUtils.isGooglePhotosUri(uri))
|
||||||
|
return uri.getLastPathSegment();
|
||||||
|
|
||||||
|
return GetPathUtils.getDataColumn(context, uri, null, null);
|
||||||
|
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||||
|
return uri.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class GetPathUtils {
|
||||||
|
/**
|
||||||
|
* Get the value of the data column for this Uri. This is useful for
|
||||||
|
* MediaStore Uris, and other file-based ContentProviders.
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* The context.
|
||||||
|
* @param uri
|
||||||
|
* The Uri to query.
|
||||||
|
* @param selection
|
||||||
|
* (Optional) Filter used in the query.
|
||||||
|
* @param selectionArgs
|
||||||
|
* (Optional) Selection arguments used in the query.
|
||||||
|
* @return The value of the _data column, which is typically a file path.
|
||||||
|
*/
|
||||||
|
public static String getDataColumn(Context context, Uri uri,
|
||||||
|
String selection, String[] selectionArgs) {
|
||||||
|
|
||||||
|
Cursor cursor = null;
|
||||||
|
final String column = "_data";
|
||||||
|
final String[] projection = { column };
|
||||||
|
|
||||||
|
try {
|
||||||
|
cursor = context.getContentResolver().query(uri, projection,
|
||||||
|
selection, selectionArgs, null);
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
final int index = cursor.getColumnIndexOrThrow(column);
|
||||||
|
return cursor.getString(index);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (cursor != null)
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri
|
||||||
|
* The Uri to check.
|
||||||
|
* @return Whether the Uri authority is ExternalStorageProvider.
|
||||||
|
*/
|
||||||
|
public static boolean isExternalStorageDocument(Uri uri) {
|
||||||
|
return "com.android.externalstorage.documents".equals(uri
|
||||||
|
.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri
|
||||||
|
* The Uri to check.
|
||||||
|
* @return Whether the Uri authority is DownloadsProvider.
|
||||||
|
*/
|
||||||
|
public static boolean isDownloadsDocument(Uri uri) {
|
||||||
|
return "com.android.providers.downloads.documents".equals(uri
|
||||||
|
.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri
|
||||||
|
* The Uri to check.
|
||||||
|
* @return Whether the Uri authority is MediaProvider.
|
||||||
|
*/
|
||||||
|
public static boolean isMediaDocument(Uri uri) {
|
||||||
|
return "com.android.providers.media.documents".equals(uri
|
||||||
|
.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri
|
||||||
|
* The Uri to check.
|
||||||
|
* @return Whether the Uri authority is Google Photos.
|
||||||
|
*/
|
||||||
|
public static boolean isGooglePhotosUri(Uri uri) {
|
||||||
|
return "com.google.android.apps.photos.content".equals(uri
|
||||||
|
.getAuthority());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getTypeOfFile(String fname) {
|
||||||
|
if (!fname.contains(".")) {
|
||||||
|
return normalFile;
|
||||||
|
}
|
||||||
|
switch (fname.substring(fname.lastIndexOf(".") + 1)) {
|
||||||
|
case "bpm":
|
||||||
|
case "gif":
|
||||||
|
case "jpg":
|
||||||
|
case "png":
|
||||||
|
case "webp":
|
||||||
|
return imageFile;
|
||||||
|
case "heic":
|
||||||
|
case "heif":
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
return imageFile;
|
||||||
|
} else {
|
||||||
|
return normalFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "m4a":
|
||||||
|
case "acc":
|
||||||
|
case "flac":
|
||||||
|
case "gsm":
|
||||||
|
case "mid":
|
||||||
|
case "xmf":
|
||||||
|
case "mxmf":
|
||||||
|
case "rtttl":
|
||||||
|
case "rtx":
|
||||||
|
case "ota":
|
||||||
|
case "imy":
|
||||||
|
case "mp3":
|
||||||
|
case "wav":
|
||||||
|
case "ogg":
|
||||||
|
return audioFile;
|
||||||
|
|
||||||
|
case "3gp":
|
||||||
|
case "mp4":
|
||||||
|
case "ts":
|
||||||
|
case "webm":
|
||||||
|
case "mkv":
|
||||||
|
return videoFile;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
return normalFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int percentOf(int i, float percent) {
|
||||||
|
return (int) (i * (percent / 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RecursivelyGetDirFile {
|
||||||
|
|
||||||
|
private TreeSet<File> directories = new TreeSet<>();
|
||||||
|
private TreeSet<File> files = new TreeSet<>();
|
||||||
|
|
||||||
|
RecursivelyGetDirFile(File file) {
|
||||||
|
getAll(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getAll(File startFile) {
|
||||||
|
for (File file: startFile.listFiles()) {
|
||||||
|
if (file.isFile()) {
|
||||||
|
files.add(file);
|
||||||
|
} else {
|
||||||
|
directories.add(file);
|
||||||
|
getAll(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TreeSet<File> getDirectories() {
|
||||||
|
return directories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TreeSet<File> getFiles() {
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
|||||||
|
package org.blueshard.android.cryptogx.filedirchooser;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import org.blueshard.android.cryptogx.R;
|
||||||
|
|
||||||
|
|
||||||
|
public class FileDirAdapter extends RecyclerView.Adapter<FileDirAdapter.FileDirHolder> {
|
||||||
|
|
||||||
|
private FileDirData[] dataSet;
|
||||||
|
private View.OnClickListener onClickListener;
|
||||||
|
private View.OnLongClickListener onLongClickListener;
|
||||||
|
|
||||||
|
public FileDirAdapter(FileDirData[] dataSet, View.OnClickListener onClickListener, View.OnLongClickListener onLongClickListener) {
|
||||||
|
this.dataSet = dataSet;
|
||||||
|
this.onClickListener = onClickListener;
|
||||||
|
this.onLongClickListener = onLongClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FileDirHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
private final TextView textView;
|
||||||
|
private final ImageView imageView;
|
||||||
|
|
||||||
|
public FileDirHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
this.textView = view.findViewById(R.id.fileDirText);
|
||||||
|
this.imageView = view.findViewById(R.id.fileDirImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public FileDirHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View chooserItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.file_dir_item, parent, false);
|
||||||
|
|
||||||
|
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) chooserItem.getLayoutParams();
|
||||||
|
params.height = 200;
|
||||||
|
chooserItem.setLayoutParams(params);
|
||||||
|
|
||||||
|
chooserItem.setOnClickListener(onClickListener);
|
||||||
|
chooserItem.setOnLongClickListener(onLongClickListener);
|
||||||
|
|
||||||
|
return new FileDirHolder(chooserItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull FileDirHolder holder, int position) {
|
||||||
|
FileDirData data = dataSet[position];
|
||||||
|
if (data != null) {
|
||||||
|
holder.textView.setText(data.getFile().getName());
|
||||||
|
holder.imageView.setImageDrawable(data.getImage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return dataSet.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileDirData getData(int index) {
|
||||||
|
return dataSet[index];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
package org.blueshard.android.cryptogx.filedirchooser;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.blueshard.android.cryptogx.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class FileDirChooser extends AppCompatActivity {
|
||||||
|
|
||||||
|
private RecyclerView files;
|
||||||
|
private RecyclerView selectedFileDirs;
|
||||||
|
private FileDirAdapter filesAdapter;
|
||||||
|
private SelectedFileDirsAdapter selectedFileDirsAdapter;
|
||||||
|
private Context context = this;
|
||||||
|
private FileDirData[] dataSet;
|
||||||
|
private ArrayList<FileDirData> selectedDataSet;
|
||||||
|
|
||||||
|
private boolean multipleMode = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_file_dir_chooser);
|
||||||
|
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.replace(R.id.fileDirFragment, new FileDirFragment());
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commit();
|
||||||
|
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
Bundle extras = intent.getExtras();
|
||||||
|
File startDirectory;
|
||||||
|
if (extras != null) {
|
||||||
|
String directory = extras.getString("directory");
|
||||||
|
if (directory != null && !directory.equals("<root>")) {
|
||||||
|
startDirectory = new File(directory);
|
||||||
|
} else {
|
||||||
|
startDirectory = Environment.getExternalStorageDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
multipleMode = extras.getBoolean("multipleMode");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
startDirectory = Environment.getExternalStorageDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSet = new FileDirData[startDirectory.listFiles().length];
|
||||||
|
|
||||||
|
filesInDir(startDirectory);
|
||||||
|
|
||||||
|
filesAdapter = new FileDirAdapter(dataSet, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
File file = filesAdapter.getData(files.getChildLayoutPosition(view)).getFile();
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.replace(R.id.fileDirFragment, new FileDirFragment());
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commit();
|
||||||
|
} else if (!multipleMode) {
|
||||||
|
View selectedFileDirs = findViewById(R.id.selectedFileDirs);
|
||||||
|
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) selectedFileDirs.getLayoutParams();
|
||||||
|
params.height = 0;
|
||||||
|
selectedFileDirs.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
FileDirData data = filesAdapter.getData(files.getChildLayoutPosition(view));
|
||||||
|
if (multipleMode) {
|
||||||
|
selectedDataSet.add(data);
|
||||||
|
selectedFileDirsAdapter.notifyDataSetChanged();
|
||||||
|
return true;
|
||||||
|
} else if (data.getFile().isFile()) {
|
||||||
|
setResult(Activity.RESULT_OK, intent);
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
files = findViewById(R.id.files);
|
||||||
|
files.setAdapter(filesAdapter);
|
||||||
|
files.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||||
|
|
||||||
|
selectedFileDirs = findViewById(R.id.selectedFileDirs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package org.blueshard.android.cryptogx.filedirchooser;
|
||||||
|
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class FileDirData {
|
||||||
|
|
||||||
|
private final File file;
|
||||||
|
private final Drawable image;
|
||||||
|
|
||||||
|
public FileDirData(File file, Drawable image) {
|
||||||
|
this.file = file;
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,159 @@
|
|||||||
|
package org.blueshard.android.cryptogx.filedirchooser;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
|
||||||
|
import org.blueshard.android.cryptogx.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class FileDirFragment extends Fragment {
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
private File directory;
|
||||||
|
private RecyclerView files;
|
||||||
|
private RecyclerView selectedFileDirs;
|
||||||
|
private FileDirAdapter filesAdapter;
|
||||||
|
private SelectedFileDirsAdapter selectedFileDirsAdapter;
|
||||||
|
private FileDirData[] dataSet;
|
||||||
|
private ArrayList<FileDirData> selectedDataSet;
|
||||||
|
|
||||||
|
private boolean multipleMode = false;
|
||||||
|
|
||||||
|
public FileDirFragment(File directory) {
|
||||||
|
dataSet = new FileDirData[directory.listFiles().length];
|
||||||
|
this.directory = directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
context = view.getContext();
|
||||||
|
|
||||||
|
RecyclerView files = (RecyclerView) view.findViewById(R.id.files);
|
||||||
|
|
||||||
|
filesInDir(directory);
|
||||||
|
|
||||||
|
filesAdapter = new FileDirAdapter(dataSet, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
File file = filesAdapter.getData(files.getChildLayoutPosition(view)).getFile();
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.replace(R.id.fileDirFragment, new FileDirFragment());
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commit();
|
||||||
|
} else if (!multipleMode) {
|
||||||
|
View selectedFileDirs = findViewById(R.id.selectedFileDirs);
|
||||||
|
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) selectedFileDirs.getLayoutParams();
|
||||||
|
params.height = 0;
|
||||||
|
selectedFileDirs.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
FileDirData data = filesAdapter.getData(files.getChildLayoutPosition(view));
|
||||||
|
if (multipleMode) {
|
||||||
|
selectedDataSet.add(data);
|
||||||
|
selectedFileDirsAdapter.notifyDataSetChanged();
|
||||||
|
return true;
|
||||||
|
} else if (data.getFile().isFile()) {
|
||||||
|
setResult(Activity.RESULT_OK, intent);
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
files = view.findViewById(R.id.files);
|
||||||
|
files.setAdapter(filesAdapter);
|
||||||
|
files.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||||
|
|
||||||
|
selectedFileDirs = new FileDirChooser().findViewById(R.id.selectedFileDirs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void filesInDir(File directory) {
|
||||||
|
final File[] files = directory.listFiles();
|
||||||
|
|
||||||
|
System.out.println(Arrays.toString(files));
|
||||||
|
|
||||||
|
if (files != null) {
|
||||||
|
Arrays.sort(files, new Comparator<File>() {
|
||||||
|
@Override
|
||||||
|
public int compare(File object1, File object2) {
|
||||||
|
return object1.getName().compareToIgnoreCase(object2.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final int cores;
|
||||||
|
if (files.length == 0) {
|
||||||
|
return;
|
||||||
|
} else if (files.length < Runtime.getRuntime().availableProcessors()) {
|
||||||
|
cores = files.length;
|
||||||
|
} else {
|
||||||
|
cores = (int) Math.ceil(files.length / Runtime.getRuntime().availableProcessors());
|
||||||
|
}
|
||||||
|
final AtomicInteger itemsPerThread = new AtomicInteger((int) Math.ceil(files.length / cores));
|
||||||
|
for (int core = 0; core < cores; core++) {
|
||||||
|
final int finalCore = core;
|
||||||
|
Thread thread = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
File file;
|
||||||
|
for (int i = itemsPerThread.get() * finalCore; i < i + itemsPerThread.get(); i++) {
|
||||||
|
try {
|
||||||
|
file = files[i];
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
dataSet[i] = new FileDirData(file, getResources().getDrawable(R.drawable.normal_folder));
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
/*FileInputStream fis = new FileInputStream(file);
|
||||||
|
Bitmap imageBitmap = BitmapFactory.decodeStream(fis);
|
||||||
|
|
||||||
|
Float width = new Float(imageBitmap.getWidth());
|
||||||
|
Float height = new Float(imageBitmap.getHeight());
|
||||||
|
Float ratio = width/height;
|
||||||
|
imageBitmap = Bitmap.createScaledBitmap(imageBitmap, (int)(64 * ratio), 64, false);
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
|
||||||
|
byte[] imageData = baos.toByteArray();
|
||||||
|
BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
|
||||||
|
dataSet[i] = new FileDirData(file, new BitmapDrawable(BitmapFactory.decodeByteArray(imageData, 0, imageData.length)));*/
|
||||||
|
dataSet[i] = new FileDirData(file, context.getResources().getDrawable(R.drawable.image_file));
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
dataSet[i] = new FileDirData(file, getResources().getDrawable(R.drawable.normal_file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package org.blueshard.android.cryptogx.filedirchooser;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import org.blueshard.android.cryptogx.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class SelectedFileDirsAdapter extends RecyclerView.Adapter<SelectedFileDirsAdapter.SelectedFileDirsHolder>{
|
||||||
|
|
||||||
|
private ArrayList<FileDirData> dataSet;
|
||||||
|
private View.OnClickListener onClickListener;
|
||||||
|
private View.OnLongClickListener onLongClickListener;
|
||||||
|
|
||||||
|
public SelectedFileDirsAdapter(ArrayList<FileDirData> dataSet, View.OnClickListener onClickListener, View.OnLongClickListener onLongClickListener) {
|
||||||
|
this.dataSet = dataSet;
|
||||||
|
this.onClickListener = onClickListener;
|
||||||
|
this.onLongClickListener = onLongClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SelectedFileDirsHolder extends RecyclerView.ViewHolder {
|
||||||
|
public final TextView textView;
|
||||||
|
public final ImageView imageView;
|
||||||
|
|
||||||
|
public SelectedFileDirsHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
this.textView = view.findViewById(R.id.fileImage);
|
||||||
|
this.imageView = view.findViewById(R.id.fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public SelectedFileDirsHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View selectedItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.selected_file_dirs_item, parent, false);
|
||||||
|
|
||||||
|
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) selectedItem.getLayoutParams();
|
||||||
|
params.width = 120;
|
||||||
|
selectedItem.setLayoutParams(params);
|
||||||
|
|
||||||
|
selectedItem.setOnClickListener(onClickListener);
|
||||||
|
selectedItem.setOnLongClickListener(onLongClickListener);
|
||||||
|
|
||||||
|
return new SelectedFileDirsHolder(selectedItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull SelectedFileDirsHolder holder, int position) {
|
||||||
|
FileDirData data = dataSet.get(position);
|
||||||
|
if (data != null) {
|
||||||
|
holder.imageView.setImageDrawable(data.getImage());
|
||||||
|
holder.textView.setText(data.getFile().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return dataSet.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileDirData getData(int index) {
|
||||||
|
return dataSet.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
BIN
app/src/main/res/drawable/audio_file.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
7
app/src/main/res/drawable/cancel_button_style.xml
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#A6FF4444"/>
|
||||||
|
<corners android:radius="15dp"/>
|
||||||
|
|
||||||
|
</shape>
|
7
app/src/main/res/drawable/choose_files_style.xml
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#9999CC00"/>
|
||||||
|
<corners android:radius="15dp"/>
|
||||||
|
|
||||||
|
</shape>
|
15
app/src/main/res/drawable/decrypt_border_style.xml
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:thickness="0dp" android:shape="rectangle">
|
||||||
|
|
||||||
|
<stroke android:width="2dp"
|
||||||
|
android:color="#9999CC00"/>
|
||||||
|
|
||||||
|
<corners android:radius="10dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<padding android:left="10dp"
|
||||||
|
android:top="5dp"
|
||||||
|
android:right="10dp"
|
||||||
|
android:bottom="5dp"/>
|
||||||
|
|
||||||
|
</shape>
|
15
app/src/main/res/drawable/encrypt_border_style.xml
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:thickness="0dp" android:shape="rectangle">
|
||||||
|
|
||||||
|
<stroke android:width="2dp"
|
||||||
|
android:color="#80FF4444"/>
|
||||||
|
|
||||||
|
<corners android:radius="10dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<padding android:left="10dp"
|
||||||
|
android:top="5dp"
|
||||||
|
android:right="10dp"
|
||||||
|
android:bottom="5dp"/>
|
||||||
|
|
||||||
|
</shape>
|
8
app/src/main/res/drawable/file_box_style.xml
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@android:color/transparent" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="#B29C27B0" />
|
||||||
|
</shape>
|
170
app/src/main/res/drawable/ic_launcher_background.xml
Executable file
@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
BIN
app/src/main/res/drawable/image_file.png
Executable file
After Width: | Height: | Size: 908 B |
BIN
app/src/main/res/drawable/normal_file.png
Executable file
After Width: | Height: | Size: 962 B |
BIN
app/src/main/res/drawable/normal_folder.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
7
app/src/main/res/drawable/round_button_style.xml
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#6700DDFF"/>
|
||||||
|
<corners android:radius="15dp"/>
|
||||||
|
|
||||||
|
</shape>
|
BIN
app/src/main/res/drawable/spinner_drop.png
Executable file
After Width: | Height: | Size: 3.7 KiB |
8
app/src/main/res/drawable/spinner_style.xml
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@android:color/transparent" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="#AAAAAA" />
|
||||||
|
</shape>
|
BIN
app/src/main/res/drawable/video_file.png
Executable file
After Width: | Height: | Size: 1.3 KiB |
45
app/src/main/res/layout/activity_file_dir_chooser.xml
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fileDirFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@+id/selectedFileDirs"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginBottom="0dp">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/files"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginBottom="0dp"
|
||||||
|
android:fadeScrollbars="false"
|
||||||
|
android:scrollbarSize="5dp"
|
||||||
|
android:scrollbarThumbVertical="@android:color/darker_gray"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/selectedFileDirs"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:context=".filedirchooser.FileDirChooser" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/selectedFileDirs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:fadeScrollbars="false"
|
||||||
|
android:scrollbarSize="5dp"
|
||||||
|
android:scrollbarThumbVertical="@android:color/darker_gray"
|
||||||
|
android:scrollbars="horizontal"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent" >
|
||||||
|
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
25
app/src/main/res/layout/activity_main.xml
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".MainActivity"
|
||||||
|
tools:ignore="ExtraText">
|
||||||
|
|
||||||
|
<com.google.android.gms.ads.AdView
|
||||||
|
android:id="@+id/adView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:adSize="BANNER"
|
||||||
|
app:adUnitId="@string/app_id" />
|
||||||
|
|
||||||
|
<androidx.viewpager.widget.ViewPager
|
||||||
|
android:id="@+id/pager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
</androidx.viewpager.widget.ViewPager>
|
||||||
|
|
||||||
|
</LinearLayout>
|
9
app/src/main/res/layout/file_dir_chooser.xml
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/aaa"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
tools:context=".filedirchooser.FileDirChooser" />
|
17
app/src/main/res/layout/file_dir_item.xml
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/fileDirImage"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileDirText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
226
app/src/main/res/layout/file_en_decrypt.xml
Executable file
@ -0,0 +1,226 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/textEnDecryptFrameLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="visible"
|
||||||
|
tools:context=".TextEnDecrypt">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileEnDecryptHeaderText"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/file_en_decrypt_headline"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.0"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/fileEnDecryptKeyLayout"
|
||||||
|
android:layout_width="308dp"
|
||||||
|
android:layout_height="65dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.504"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptHeaderText"
|
||||||
|
app:layout_constraintVertical_bias="0.0"
|
||||||
|
app:passwordToggleEnabled="true">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/fileEnDecryptKeyEntry"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/key_hint"
|
||||||
|
android:inputType="text" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fileEnDecryptChooseFiles"
|
||||||
|
android:layout_width="209dp"
|
||||||
|
android:layout_height="43dp"
|
||||||
|
android:background="@drawable/choose_files_style"
|
||||||
|
android:gravity="center"
|
||||||
|
android:onClick="fileEnDecryptChooseFiles"
|
||||||
|
android:text="@string/choose_files_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileEnDecryptFileBox"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptKeyLayout" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/fileEnDecryptFileBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="270dp"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:background="@drawable/file_box_style"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.35" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fileEnDecryptCancelButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="43dp"
|
||||||
|
android:background="@drawable/cancel_button_style"
|
||||||
|
android:onClick="cancelEnDecryptFileButton"
|
||||||
|
android:text="@string/cancel_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.504"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptProgressBar" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fileEnDecryptEncryptButton"
|
||||||
|
android:layout_width="125dp"
|
||||||
|
android:layout_height="43dp"
|
||||||
|
android:background="@drawable/round_button_style"
|
||||||
|
android:onClick="encryptFileButton"
|
||||||
|
android:text="@string/text_en_decrypt_encrypt_button_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.055"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptFileBox"
|
||||||
|
app:layout_constraintVertical_bias="0.288" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/fileEnDecryptProgressBar"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:visibility="invisible"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/fileEnDecryptDecryptButton"
|
||||||
|
app:layout_constraintHorizontal_bias="0.493"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/fileEnDecryptEncryptButton"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptFileBox"
|
||||||
|
app:layout_constraintVertical_bias="0.29000002" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fileEnDecryptDecryptButton"
|
||||||
|
android:layout_width="125dp"
|
||||||
|
android:layout_height="43dp"
|
||||||
|
android:background="@drawable/round_button_style"
|
||||||
|
android:onClick="decryptFileButton"
|
||||||
|
android:text="@string/text_en_decrypt_decrypt_button_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.944"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptFileBox"
|
||||||
|
app:layout_constraintVertical_bias="0.288" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/fileEnDecryptSeparator1"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@android:color/darker_gray"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileEnDecryptAdvancedText"
|
||||||
|
android:layout_width="85dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="18dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/advanced_text"
|
||||||
|
android:textColor="#000000"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/fileEnDecryptSeparator2"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/fileEnDecryptSeparator1"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/fileEnDecryptSeparator2"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@android:color/darker_gray"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/fileEnDecryptSaltLayout"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="69dp"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.06"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptAdvancedText"
|
||||||
|
app:passwordToggleEnabled="true">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/fileEnDecryptSaltEntry"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/salt_hint"
|
||||||
|
android:inputType="text" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileEnDecryptAlgorithmText"
|
||||||
|
android:layout_width="109dp"
|
||||||
|
android:layout_height="29dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/algorithm_text"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.84"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintVertical_bias="0.135" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/fileEnDecryptAlgorithm"
|
||||||
|
android:layout_width="160dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:background="@drawable/spinner_style"
|
||||||
|
android:spinnerMode="dropdown"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.93"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileEnDecryptAlgorithmText"
|
||||||
|
app:layout_constraintVertical_bias="0.0">
|
||||||
|
|
||||||
|
</Spinner>
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
179
app/src/main/res/layout/secure_delete_files.xml
Executable file
@ -0,0 +1,179 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/textEnDecryptFrameLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="visible"
|
||||||
|
tools:context=".TextEnDecrypt">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileDeleteHeaderText"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/secure_delete_files_headline"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.0"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/fileDeleteKeyLayout"
|
||||||
|
android:layout_width="308dp"
|
||||||
|
android:layout_height="65dp"
|
||||||
|
android:visibility="invisible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteHeaderText"
|
||||||
|
app:layout_constraintVertical_bias="0.0"
|
||||||
|
app:passwordToggleEnabled="true">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/key_hint"
|
||||||
|
android:inputType="text" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fileDeleteChooseFiles"
|
||||||
|
android:layout_width="209dp"
|
||||||
|
android:layout_height="43dp"
|
||||||
|
android:background="@drawable/choose_files_style"
|
||||||
|
android:gravity="center"
|
||||||
|
android:onClick="fileDeleteChooseFiles"
|
||||||
|
android:text="@string/choose_files_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileDeleteFileBox"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteHeaderText" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/fileDeleteFileBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="350dp"
|
||||||
|
android:background="@drawable/file_box_style"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileDeleteAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.133" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fileDeleteDeleteButton"
|
||||||
|
android:layout_width="125dp"
|
||||||
|
android:layout_height="43dp"
|
||||||
|
android:background="@drawable/round_button_style"
|
||||||
|
android:onClick="deleteFileButton"
|
||||||
|
android:text="@string/delete_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileDeleteAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.055"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteFileBox"
|
||||||
|
app:layout_constraintVertical_bias="0.56" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/fileDeleteProgressBar"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:visibility="invisible"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileDeleteAdvancedText"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/fileDeleteCancelButton"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/fileDeleteDeleteButton"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteFileBox"
|
||||||
|
app:layout_constraintVertical_bias="0.575" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fileDeleteCancelButton"
|
||||||
|
android:layout_width="125dp"
|
||||||
|
android:layout_height="43dp"
|
||||||
|
android:background="@drawable/cancel_button_style"
|
||||||
|
android:onClick="cancelDeleteFileButton"
|
||||||
|
android:text="@string/cancel_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/fileDeleteAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.944"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteFileBox"
|
||||||
|
app:layout_constraintVertical_bias="0.56" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/fileDeleteSeparator1"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@android:color/darker_gray"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/fileDeleteSeparator2"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileDeleteAdvancedText"
|
||||||
|
android:layout_width="85dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="18dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/advanced_text"
|
||||||
|
android:textColor="#000000"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/fileDeleteSeparator2"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/fileDeleteSeparator1"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/fileDeleteSeparator2"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@android:color/darker_gray"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/fileDeleteIterationsLayout"
|
||||||
|
android:layout_width="184dp"
|
||||||
|
android:layout_height="69dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileDeleteAdvancedText"
|
||||||
|
app:layout_constraintVertical_bias="0.517"
|
||||||
|
app:passwordToggleEnabled="true">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/fileDeleteIterationsEntry"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/iterations_hint"
|
||||||
|
android:inputType="number"
|
||||||
|
android:text="5" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
27
app/src/main/res/layout/selected_file_dirs_item.xml
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/fileImage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/audio_file" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileName"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.498"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/fileImage" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
218
app/src/main/res/layout/text_en_decrypt.xml
Executable file
@ -0,0 +1,218 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/textEnDecryptFrameLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="visible"
|
||||||
|
tools:context=".TextEnDecrypt">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/textEnDecryptLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textEnDecryptHeaderText"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/text_en_decrypt_headline"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.0"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/textEnDecryptKeyLayout"
|
||||||
|
android:layout_width="308dp"
|
||||||
|
android:layout_height="65dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.504"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptHeaderText"
|
||||||
|
app:layout_constraintVertical_bias="0.0"
|
||||||
|
app:passwordToggleEnabled="true">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/textEnDecryptKeyEntry"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/key_hint"
|
||||||
|
android:inputType="text" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/textEnDecryptDecryptedText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="185dp"
|
||||||
|
android:background="@drawable/decrypt_border_style"
|
||||||
|
android:gravity="top"
|
||||||
|
android:hint="@string/text_en_decrypt_decrypted_text_hint"
|
||||||
|
android:inputType="text|textMultiLine"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:autoSizeTextType="uniform"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/textEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.073"
|
||||||
|
tools:layout_editor_absoluteX="0dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/textEnDecryptEncryptedText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="185dp"
|
||||||
|
android:width="165dp"
|
||||||
|
android:background="@drawable/encrypt_border_style"
|
||||||
|
android:gravity="top"
|
||||||
|
android:hint="@string/text_en_decrypt_encrypted_text_hint"
|
||||||
|
android:inputType="text|textMultiLine"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:autoSizeTextType="uniform"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/textEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptDecryptedText"
|
||||||
|
app:layout_constraintVertical_bias="0.17000002"
|
||||||
|
tools:layout_editor_absoluteX="1dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/textEnDecryptEncryptButton"
|
||||||
|
android:layout_width="125dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:background="@drawable/round_button_style"
|
||||||
|
android:onClick="encryptTextButton"
|
||||||
|
android:text="@string/text_en_decrypt_encrypt_button_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/textEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.053"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptEncryptedText"
|
||||||
|
app:layout_constraintVertical_bias="0.538" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/textEnDecryptProgressBar"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:visibility="invisible"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/textEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/textEnDecryptDecryptButton"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/textEnDecryptEncryptButton"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptEncryptedText"
|
||||||
|
app:layout_constraintVertical_bias="0.58000004" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/textEnDecryptDecryptButton"
|
||||||
|
android:layout_width="125dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:background="@drawable/round_button_style"
|
||||||
|
android:onClick="decryptTextButton"
|
||||||
|
android:text="@string/text_en_decrypt_decrypt_button_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/textEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.946"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptEncryptedText"
|
||||||
|
app:layout_constraintVertical_bias="0.538" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/textEnDecryptSeparator1"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@android:color/darker_gray"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textEnDecryptAdvancedText"
|
||||||
|
android:layout_width="85dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="18dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/advanced_text"
|
||||||
|
android:textColor="#000000"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/textEnDecryptSeparator2"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/textEnDecryptSeparator1"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/textEnDecryptSeparator2"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@android:color/darker_gray"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptKeyLayout"
|
||||||
|
app:layout_constraintVertical_bias="0.79" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/textEnDecryptSaltLayout"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="69dp"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.06"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptAdvancedText"
|
||||||
|
app:passwordToggleEnabled="true">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/textEnDecryptSaltEntry"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/salt_hint"
|
||||||
|
android:inputType="text" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textEnDecryptAlgorithmText"
|
||||||
|
android:layout_width="109dp"
|
||||||
|
android:layout_height="29dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/algorithm_text"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.84"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptAdvancedText"
|
||||||
|
app:layout_constraintVertical_bias="0.135" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/textEnDecryptAlgorithms"
|
||||||
|
android:layout_width="160dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:background="@drawable/spinner_style"
|
||||||
|
android:spinnerMode="dropdown"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.93"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textEnDecryptAlgorithmText"
|
||||||
|
app:layout_constraintVertical_bias="0.0">
|
||||||
|
|
||||||
|
</Spinner>
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 3.5 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Executable file
After Width: | Height: | Size: 5.2 KiB |
BIN
app/src/main/res/mipmap-mdpi/cryptogx_icon_android.png
Executable file
After Width: | Height: | Size: 124 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Executable file
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Executable file
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 7.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Executable file
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 10 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Executable file
After Width: | Height: | Size: 16 KiB |
27
app/src/main/res/values-de/strings.xml
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="text_en_decrypt_headline">Text ent- / verschlüsseln</string>
|
||||||
|
<string name="file_en_decrypt_headline">Dateien ent- / verschlüsseln</string>
|
||||||
|
<string name="secure_delete_files_headline">Dateien sicher löschen</string>
|
||||||
|
<string name="key_hint">Schlüssel</string>
|
||||||
|
<string name="show_text_en_decrypt_key">Schlüssel anzeigen</string>
|
||||||
|
<string name="text_en_decrypt_encrypted_text_hint">Verschlüsselter Text</string>
|
||||||
|
<string name="text_en_decrypt_decrypted_text_hint">Entschlüsselter Text</string>
|
||||||
|
<string name="text_en_decrypt_encrypt_button_text">Verschlüsseln</string>
|
||||||
|
<string name="text_en_decrypt_decrypt_button_text">Entschlüsseln</string>
|
||||||
|
<string name="advanced_text">Erweitert</string>
|
||||||
|
<string name="algorithm_text">Algorithmus</string>
|
||||||
|
<string name="salt_hint">Salt</string>
|
||||||
|
<string name="file_en_decrypt_choose_files">Dateien auswählen...</string>
|
||||||
|
<string name="cancel_text">Stoppen</string>
|
||||||
|
<string name="choose_files_text">Dateien auswählen...</string>
|
||||||
|
<string name="iterations_hint">Wiederholungen</string>
|
||||||
|
<string name="delete_text">Löschen</string>
|
||||||
|
<string name="empty_key">Leerer Schlüssel wurde gegeben</string>
|
||||||
|
<string name="empty_encrypted_text">Leerer verschlüsselter Text wurde gegeben</string>
|
||||||
|
<string name="output_file_hint">Ausgabe Datei</string>
|
||||||
|
<string name="could_not_create_folder">"Ordner konnte nicht erstellt werden: "</string>
|
||||||
|
<string name="no_file_path">Pfad der Datei konnte nicht gefunden werden:</string>
|
||||||
|
<string name="empty_iterations">Keine Wiederholungen gegeben</string>
|
||||||
|
<string name="wrong_iterations">Falsche Wiederholungen gegeben</string>
|
||||||
|
</resources>
|
26
app/src/main/res/values-en/strings.xml
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="text_en_decrypt_headline">En- / decrypt text</string>
|
||||||
|
<string name="file_en_decrypt_headline">En- / decrypt files</string>
|
||||||
|
<string name="secure_delete_files_headline">Secure delete files</string>
|
||||||
|
<string name="key_hint">Key</string>
|
||||||
|
<string name="show_text_en_decrypt_key">Show key</string>
|
||||||
|
<string name="text_en_decrypt_encrypted_text_hint">Encrypted text</string>
|
||||||
|
<string name="text_en_decrypt_decrypted_text_hint">Decrypted text</string>
|
||||||
|
<string name="text_en_decrypt_encrypt_button_text">Encrypt</string>
|
||||||
|
<string name="text_en_decrypt_decrypt_button_text">Decrypt</string>
|
||||||
|
<string name="advanced_text">Advanced</string>
|
||||||
|
<string name="algorithm_text">Algorithm</string>
|
||||||
|
<string name="salt_hint">Salt</string>
|
||||||
|
<string name="file_en_decrypt_choose_files">Choose files...</string>
|
||||||
|
<string name="cancel_text">Cancel</string>
|
||||||
|
<string name="choose_files_text">Choose files...</string>
|
||||||
|
<string name="iterations_hint">Iterations</string>
|
||||||
|
<string name="delete_text">Delete</string>
|
||||||
|
<string name="empty_key">Empty key is given</string>
|
||||||
|
<string name="empty_encrypted_text">Empty encrypted text is given</string>
|
||||||
|
<string name="output_file_hint">Output file</string>
|
||||||
|
<string name="could_not_create_folder">Couldn\'t create folder:</string>
|
||||||
|
<string name="no_file_path">Couldn\'t get path from file:</string>
|
||||||
|
<string name="empty_iterations">No iterations are given</string>
|
||||||
|
<string name="wrong_iterations">Wrong iterations are given</string>
|
||||||
|
</resources>
|
6
app/src/main/res/values/colors.xml
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#6200EE</color>
|
||||||
|
<color name="colorPrimaryDark">#3700B3</color>
|
||||||
|
<color name="colorAccent">#03DAC5</color>
|
||||||
|
</resources>
|
33
app/src/main/res/values/strings.xml
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name" translatable="false">cryptoGX</string>
|
||||||
|
|
||||||
|
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
|
||||||
|
<!-- ca-app-pub-8690297592769912~2837426184-->
|
||||||
|
<string name="app_id" translatable="false">ca-app-pub-8690297592769912~2837426184</string>
|
||||||
|
|
||||||
|
<string name="text_en_decrypt_headline">En- / decrypt text</string>
|
||||||
|
<string name="file_en_decrypt_headline">En- / decrypt files</string>
|
||||||
|
<string name="secure_delete_files_headline">Secure delete files</string>
|
||||||
|
<string name="key_hint">Key</string>
|
||||||
|
<string name="show_text_en_decrypt_key">Show key</string>
|
||||||
|
<string name="text_en_decrypt_encrypted_text_hint">Encrypted text</string>
|
||||||
|
<string name="text_en_decrypt_decrypted_text_hint">Decrypted text</string>
|
||||||
|
<string name="text_en_decrypt_encrypt_button_text">Encrypt</string>
|
||||||
|
<string name="text_en_decrypt_decrypt_button_text">Decrypt</string>
|
||||||
|
<string name="advanced_text">Advanced</string>
|
||||||
|
<string name="algorithm_text">Algortihm</string>
|
||||||
|
<string name="salt_hint">Salt</string>
|
||||||
|
<string name="file_en_decrypt_choose_files">Choose files...</string>
|
||||||
|
<string name="cancel_text">Cancel</string>
|
||||||
|
<string name="choose_files_text">Choose files...</string>
|
||||||
|
<string name="iterations_hint">Iterations</string>
|
||||||
|
<string name="delete_text">Delete</string>
|
||||||
|
<string name="empty_key">Empty key is given</string>
|
||||||
|
<string name="empty_encrypted_text">Empty encrypted text is given</string>
|
||||||
|
<string name="output_file_hint">Output file</string>
|
||||||
|
<string name="could_not_create_folder">Couldn\'t create folder:</string>
|
||||||
|
<string name="no_file_path">Couldn\'t get path from file:</string>
|
||||||
|
<string name="empty_iterations">Empty iterations are given</string>
|
||||||
|
<string name="wrong_iterations">Wrong iterations are given</string>
|
||||||
|
</resources>
|
17
app/src/main/res/values/styles.xml
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
<item name="android:windowFullscreen">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
17
app/src/test/java/org/blueshard/android/cryptogx/ExampleUnitTest.java
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
package org.blueshard.android.cryptogx;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
public class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
public void addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2);
|
||||||
|
}
|
||||||
|
}
|
29
build.gradle
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:4.0.0'
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
BIN
cryptoGX_mobile_key.jks
Executable file
20
gradle.properties
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
|
android.enableJetifier=true
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Executable file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#Sun Jun 28 20:31:48 CEST 2020
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
172
gradlew
vendored
Executable file
@ -0,0 +1,172 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
84
gradlew.bat
vendored
Executable file
@ -0,0 +1,84 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
2
password
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
Key store password: Bv=D+P24a(\W{pNzhjj&
|
||||||
|
Key password: %jMB97_xN'7n[wGP5S~b
|
2
settings.gradle
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
rootProject.name='cryptoGX'
|
||||||
|
include ':app'
|