first commit
14
.gitignore
vendored
Normal 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
|
116
.idea/codeStyles/Project.xml
generated
Normal 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>
|
21
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?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="gradleJvm" value="1.8" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
25
.idea/jarRepositories.xml
generated
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?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>
|
||||||
|
</component>
|
||||||
|
</project>
|
9
.idea/misc.xml
generated
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" 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
Normal 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>
|
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/build
|
42
app/build.gradle
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 30
|
||||||
|
buildToolsVersion "30.0.1"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.localtransfer"
|
||||||
|
minSdkVersion 24
|
||||||
|
targetSdkVersion 30
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
|
implementation 'com.google.android.material:material:1.1.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
|
implementation 'androidx.preference:preference:1.1.1'
|
||||||
|
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 'lib.kashif:folderpicker:2.4'
|
||||||
|
|
||||||
|
}
|
21
app/proguard-rules.pro
vendored
Normal 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
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
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("com.localtransfer", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
60
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.localtransfer">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".TransferService" />
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/provider_paths" />
|
||||||
|
</provider>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".SettingsActivity"
|
||||||
|
android:label="@string/title_activity_settings">
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="*/*" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="*/*" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
58
app/src/main/java/com/localtransfer/Extra.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class Extra implements Parcelable {
|
||||||
|
|
||||||
|
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
|
||||||
|
public Extra createFromParcel(Parcel in) {
|
||||||
|
return new Extra(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Extra[] newArray(int size) {
|
||||||
|
return new Extra[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
public long size;
|
||||||
|
public String href;
|
||||||
|
public String uri;
|
||||||
|
public int id;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public Extra(Uri uri, String name, long size, String href, View view){
|
||||||
|
this.uri = uri.toString();
|
||||||
|
this.name = name;
|
||||||
|
this.size = size;
|
||||||
|
this.href = href;
|
||||||
|
this.id = view.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Parcelling part
|
||||||
|
public Extra(Parcel in){
|
||||||
|
this.uri = in.readString();
|
||||||
|
this.name = in.readString();
|
||||||
|
this.size = in.readLong();
|
||||||
|
this.href = in.readString();
|
||||||
|
this.id = in.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(this.uri);
|
||||||
|
dest.writeString(this.name);
|
||||||
|
dest.writeLong(this.size);
|
||||||
|
dest.writeString(this.href);
|
||||||
|
dest.writeInt(this.id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class HttpErrorException extends IOException {
|
||||||
|
public HttpErrorException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
212
app/src/main/java/com/localtransfer/MainActivity.java
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
|
||||||
|
ViewPager viewPager = findViewById(R.id.view_pager);
|
||||||
|
viewPager.setAdapter(sectionsPagerAdapter);
|
||||||
|
TabLayout tabs = findViewById(R.id.tabs);
|
||||||
|
tabs.setupWithViewPager(viewPager);
|
||||||
|
FloatingActionButton fab = findViewById(R.id.flotUpload);
|
||||||
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
checkAndRequestPermissions();
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
if(prefs.getString("host", null) == null)
|
||||||
|
prefs.edit()
|
||||||
|
.putString("host", getString(R.string.server_host_def))
|
||||||
|
.putString("port", getString(R.string.server_port_def))
|
||||||
|
.putString("root", getString(R.string.server_root_def))
|
||||||
|
.putString("local_storage", getString(R.string.local_storage_def))
|
||||||
|
.apply();
|
||||||
|
|
||||||
|
Transfer.parameter(this);
|
||||||
|
Transfer.activity = this;
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
String action = intent.getAction();
|
||||||
|
String type = intent.getType();
|
||||||
|
|
||||||
|
Transfer tr = new Transfer();
|
||||||
|
|
||||||
|
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||||
|
viewPager.setCurrentItem(2);
|
||||||
|
if ("text/plain".equals(type)) {
|
||||||
|
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
tr.handleSendText(sharedText);
|
||||||
|
} else {
|
||||||
|
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||||
|
new Thread(() -> tr.handleSendFile(uri)).start();
|
||||||
|
}
|
||||||
|
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
|
||||||
|
viewPager.setCurrentItem(2);
|
||||||
|
ArrayList<Uri> fileUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
||||||
|
int nbItem = fileUris.size();
|
||||||
|
Toast.makeText(this, "You select " + nbItem + " files", Toast.LENGTH_SHORT).show();
|
||||||
|
if (fileUris != null)
|
||||||
|
for(Uri uri : fileUris) tr.handleSendFile(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume(){
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
Progress.app_started = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause(){
|
||||||
|
super.onPause();
|
||||||
|
|
||||||
|
Progress.app_started = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
File dir = getCacheDir();
|
||||||
|
deleteDirContent(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void deleteDirContent(File dir) {
|
||||||
|
if (dir != null && dir.isDirectory()) {
|
||||||
|
String[] children = dir.list();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
File file = new File(dir, children[i]);
|
||||||
|
if (file.isFile())
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
int id = item.getItemId();
|
||||||
|
switch (id) {
|
||||||
|
case R.id.action_settings:
|
||||||
|
Intent settings = new Intent(this, SettingsActivity.class);
|
||||||
|
startActivity(settings);
|
||||||
|
break;
|
||||||
|
case R.id.action_folder:
|
||||||
|
String save_location = Environment.getExternalStorageDirectory() + "/" + Transfer.local_storage;
|
||||||
|
Uri selectedUri = Uri.parse(save_location.toString());
|
||||||
|
boolean intentSuccess = false;
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(selectedUri, "resource/folder");
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT |
|
||||||
|
Intent.FLAG_ACTIVITY_NEW_TASK |
|
||||||
|
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
intentSuccess = true;
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
intentSuccess = false;
|
||||||
|
}
|
||||||
|
if( ! intentSuccess && isPackageInstalled("com.sec.android.app.myfiles", getPackageManager())){
|
||||||
|
|
||||||
|
Intent intent = getPackageManager().getLaunchIntentForPackage("com.sec.android.app.myfiles");
|
||||||
|
intent.setData(selectedUri);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
else if(! intentSuccess)
|
||||||
|
Toast.makeText(this, "No file Manager", Toast.LENGTH_SHORT).show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int REQUEST_ID_READ_EXTERNAL_STORAGE = 2001;
|
||||||
|
|
||||||
|
private boolean checkAndRequestPermissions() {
|
||||||
|
|
||||||
|
if (ContextCompat.checkSelfPermission(
|
||||||
|
this, Manifest.permission.READ_EXTERNAL_STORAGE) ==
|
||||||
|
PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Log.d("READ_EXTERNAL_STORAGE", "already granted");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ActivityCompat.requestPermissions(this, new String[] {android.Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_ID_READ_EXTERNAL_STORAGE);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
|
String permissions[],
|
||||||
|
int[] grantResults) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_ID_READ_EXTERNAL_STORAGE:
|
||||||
|
if (grantResults.length > 0 &&
|
||||||
|
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Log.d("READ_EXTERNAL_STORAGE", "granted");
|
||||||
|
} else {
|
||||||
|
Log.d("READ_EXTERNAL_STORAGE", "No granted");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPackageInstalled(String packageName, PackageManager packageManager) {
|
||||||
|
try {
|
||||||
|
packageManager.getPackageInfo(packageName, 0);
|
||||||
|
return true;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
188
app/src/main/java/com/localtransfer/Progress.java
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
public class Progress {
|
||||||
|
|
||||||
|
public static final int UPLOAD = 1000;
|
||||||
|
public static final int DOWNLOAD = 1001;
|
||||||
|
|
||||||
|
|
||||||
|
private static NotificationCompat.Builder bl = new NotificationCompat.Builder(Transfer.activity, null);
|
||||||
|
private static NotificationManagerCompat notifiManager = NotificationManagerCompat.from(Transfer.activity);
|
||||||
|
private static final LayoutInflater inflater = (LayoutInflater) Transfer.activity.getSystemService(Transfer.activity.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
|
private static List instances = new ArrayList();
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private long size;
|
||||||
|
|
||||||
|
public long loaded;
|
||||||
|
public long percent;
|
||||||
|
|
||||||
|
public static View root;
|
||||||
|
public static boolean fragment_on = false;
|
||||||
|
public static boolean app_started = false;
|
||||||
|
|
||||||
|
private Timer timer = new Timer();
|
||||||
|
private int drawable;
|
||||||
|
private String info;
|
||||||
|
|
||||||
|
public Button button;
|
||||||
|
private boolean run = false;
|
||||||
|
|
||||||
|
public Progress(String name, long size, int type) {
|
||||||
|
|
||||||
|
instances.add(this);
|
||||||
|
|
||||||
|
run = true;
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
this.size = size;
|
||||||
|
|
||||||
|
id = View.generateViewId();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case Progress.DOWNLOAD:
|
||||||
|
drawable = R.drawable.ic_download_24;
|
||||||
|
info = "Download complete";
|
||||||
|
break;
|
||||||
|
case Progress.UPLOAD:
|
||||||
|
drawable = R.drawable.ic_upload_24;
|
||||||
|
info = "Upload complete";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unexpected value: " + type);
|
||||||
|
}
|
||||||
|
|
||||||
|
timer.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
showProgress();
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List getInstances() {
|
||||||
|
return instances;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopProgress() {
|
||||||
|
timer.cancel();
|
||||||
|
showProgress();
|
||||||
|
|
||||||
|
run = false;
|
||||||
|
|
||||||
|
if(! app_started) {
|
||||||
|
bl.setSmallIcon(R.drawable.ic_upload_and_download_from_the_cloud)
|
||||||
|
.setContentTitle(name)
|
||||||
|
.setContentText(info)
|
||||||
|
.setProgress(0, 0, false)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setOngoing(false);
|
||||||
|
notifiManager.notify(id, bl.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
instances.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Progress getProgress(int id) {
|
||||||
|
|
||||||
|
for (Object obj: instances) {
|
||||||
|
Progress p = (Progress) obj;
|
||||||
|
if (p.id == id) return p;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean setButton(String name, Button button) {
|
||||||
|
|
||||||
|
for (Object obj: instances) {
|
||||||
|
Progress p = (Progress) obj;
|
||||||
|
if (name.equals(p.name) && p.run) {
|
||||||
|
p.button = button;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void showProgress(){
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
String HumanLoaded = Transfer.humanReadableByteCountBin(loaded);
|
||||||
|
String HumanSize = Transfer.humanReadableByteCountBin(size);
|
||||||
|
|
||||||
|
if(app_started) {
|
||||||
|
notifiManager.cancel(id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Intent intent = new Intent(Transfer.activity, MainActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getActivity(Transfer.activity, 0, intent, 0);
|
||||||
|
|
||||||
|
bl.setSmallIcon(R.drawable.ic_upload_and_download_from_the_cloud)
|
||||||
|
.setContentTitle(name)
|
||||||
|
.setContentText(String.format("%d%% %s/%s", percent, HumanLoaded, HumanSize))
|
||||||
|
.setProgress(100, (int) percent, false)
|
||||||
|
.setContentIntent(pendingIntent)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setOngoing(true);
|
||||||
|
notifiManager.notify(id, bl.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(app_started && fragment_on) {
|
||||||
|
LinearLayout groot = root.findViewById(R.id.groot);
|
||||||
|
|
||||||
|
final View progress;
|
||||||
|
|
||||||
|
if (groot.findViewById(id) != null) {
|
||||||
|
progress = groot.findViewById(id);
|
||||||
|
} else {
|
||||||
|
progress = inflater.inflate(R.layout.progress, null);
|
||||||
|
progress.setId(id);
|
||||||
|
Transfer.activity.runOnUiThread(() -> {
|
||||||
|
groot.addView(progress, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Transfer.activity.runOnUiThread(() -> {
|
||||||
|
((ProgressBar) progress.findViewById(R.id.progressBar)).setProgress((int) percent);
|
||||||
|
((ImageView) progress.findViewById(R.id.transferType)).setImageResource(drawable);
|
||||||
|
((TextView) progress.findViewById(R.id.progressText)).setText(percent + " %");
|
||||||
|
((TextView) progress.findViewById(R.id.fileName)).setText(name);
|
||||||
|
((TextView) progress.findViewById(R.id.fileSize)).setText(String.format("%s/%s", HumanLoaded, HumanSize));
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ConcurrentModificationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
|
|
||||||
|
import com.localtransfer.fragment.DownloadFragment;
|
||||||
|
import com.localtransfer.fragment.ProgressFragment;
|
||||||
|
import com.localtransfer.fragment.UploadFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [FragmentPagerAdapter] that returns a fragment corresponding to
|
||||||
|
* one of the sections/tabs/pages.
|
||||||
|
*/
|
||||||
|
public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
|
@StringRes
|
||||||
|
private static final int[] TAB_TITLES = new int[]{R.string.download, R.string.upload, R.string.progress};
|
||||||
|
private final Context mContext;
|
||||||
|
|
||||||
|
public SectionsPagerAdapter(Context context, FragmentManager fm) {
|
||||||
|
super(fm);
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
// getItem is called to instantiate the fragment for the given page.
|
||||||
|
// Return a PlaceholderFragment (defined as a static inner class below).
|
||||||
|
switch (position){
|
||||||
|
case 0: //Page number 1
|
||||||
|
return DownloadFragment.newInstance();
|
||||||
|
case 1: //Page number 2
|
||||||
|
return UploadFragment.newInstance();
|
||||||
|
case 2: //Page number 3
|
||||||
|
return ProgressFragment.newInstance();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public CharSequence getPageTitle(int position) {
|
||||||
|
return mContext.getResources().getString(TAB_TITLES[position]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
93
app/src/main/java/com/localtransfer/SettingsActivity.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import lib.folderpicker.FolderPicker;
|
||||||
|
|
||||||
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.settings_activity);
|
||||||
|
getSupportFragmentManager()
|
||||||
|
.beginTransaction()
|
||||||
|
.replace(R.id.settings, new SettingsFragment())
|
||||||
|
.commit();
|
||||||
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
|
private final static int REQUEST_DIRECTORY_PICKER = 4000;
|
||||||
|
static Preference directory;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
|
setPreferencesFromResource(R.xml.root_preferences, rootKey);
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
directory = findPreference("local_storage");
|
||||||
|
directory.setSummary(prefs.getString("local_storage", null));
|
||||||
|
directory.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Intent intent = new Intent(getContext(), FolderPicker.class);
|
||||||
|
startActivityForResult(intent, REQUEST_DIRECTORY_PICKER);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_DIRECTORY_PICKER:
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
String currentPath = data.getExtras().getString("data");
|
||||||
|
if(currentPath.contains(Environment.getExternalStorageDirectory() + "/")) {
|
||||||
|
String save_location = currentPath.replace(Environment.getExternalStorageDirectory() + "/", "");
|
||||||
|
Log.d("Path", save_location);
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
prefs.edit().putString("local_storage", save_location).apply();
|
||||||
|
directory.setSummary(save_location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
Transfer.parameter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
int id = item.getItemId();
|
||||||
|
|
||||||
|
if (id == android.R.id.home) {
|
||||||
|
onBackPressed(); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
461
app/src/main/java/com/localtransfer/Transfer.java
Normal file
@ -0,0 +1,461 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.provider.OpenableColumns;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.LinearInterpolator;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.ProtocolException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.text.CharacterIterator;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.text.StringCharacterIterator;
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import static java.lang.Integer.valueOf;
|
||||||
|
|
||||||
|
public class Transfer {
|
||||||
|
|
||||||
|
public static String host;
|
||||||
|
public static Integer port;
|
||||||
|
public static String root;
|
||||||
|
public static String protocol;
|
||||||
|
public static String local_storage;
|
||||||
|
|
||||||
|
public static Activity activity;
|
||||||
|
|
||||||
|
public static void parameter(Context context) {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
host = prefs.getString("host", null);
|
||||||
|
port = valueOf(prefs.getString("port", null));
|
||||||
|
root = prefs.getString("root", null);
|
||||||
|
local_storage = prefs.getString("local_storage", null);
|
||||||
|
if(prefs.getBoolean("protocol", false))
|
||||||
|
protocol = "https";
|
||||||
|
else
|
||||||
|
protocol = "http";
|
||||||
|
}
|
||||||
|
|
||||||
|
private URL checkRedirection(URL url) throws IOException {
|
||||||
|
String location = null;
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
int responseCode;
|
||||||
|
int nbRedirect = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setInstanceFollowRedirects(false);
|
||||||
|
conn.setConnectTimeout(2000);
|
||||||
|
|
||||||
|
conn.connect();
|
||||||
|
responseCode = conn.getResponseCode();
|
||||||
|
|
||||||
|
Log.d("Réponse Code", String.valueOf(responseCode));
|
||||||
|
|
||||||
|
if(responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = conn.getHeaderField("Location");
|
||||||
|
Log.d("Location", location);
|
||||||
|
|
||||||
|
url = new URL(location);
|
||||||
|
|
||||||
|
|
||||||
|
conn.disconnect();
|
||||||
|
|
||||||
|
nbRedirect++;
|
||||||
|
if(nbRedirect > 10) {
|
||||||
|
throw new ProtocolException("Too many follow-up requests: " + nbRedirect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} while (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleSendFile(Uri uri) {
|
||||||
|
if (uri != null) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
uploadFile(uri);
|
||||||
|
} catch (IOException e) {
|
||||||
|
final String ExceptionName = e.getClass().getSimpleName();
|
||||||
|
final String ExceptionMess = e.getMessage();
|
||||||
|
|
||||||
|
if(ExceptionName != null && ExceptionMess != null) {
|
||||||
|
Transfer.error(ExceptionName + ": " + ExceptionMess, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleSendText(String sharedText) {
|
||||||
|
if (sharedText != null) {
|
||||||
|
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||||
|
Date now = new Date();
|
||||||
|
String strDate = sdfDate.format(now);
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
File outputFile = new File(activity.getCacheDir(), strDate + ".txt");
|
||||||
|
FileOutputStream fileOut = new FileOutputStream(outputFile);
|
||||||
|
OutputStreamWriter OutWriter = new OutputStreamWriter(fileOut);
|
||||||
|
OutWriter.append(sharedText);
|
||||||
|
OutWriter.close();
|
||||||
|
|
||||||
|
fileOut.flush();
|
||||||
|
fileOut.close();
|
||||||
|
|
||||||
|
Uri uri = FileProvider.getUriForFile(activity, activity.getPackageName(), outputFile);
|
||||||
|
|
||||||
|
uploadFile(uri);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String uploadFile(Uri uri) throws IOException {
|
||||||
|
String message = null;
|
||||||
|
URL url = null;
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
DataOutputStream request = null;
|
||||||
|
String boundary = "*****";
|
||||||
|
int maxBufferSize = 1 * 1024 * 1024;
|
||||||
|
byte[] buffer = new byte[maxBufferSize];
|
||||||
|
int bufferLength;
|
||||||
|
long loaded = 0;
|
||||||
|
|
||||||
|
Cursor cursor = activity.getContentResolver().query(uri, null, null, null, null);
|
||||||
|
cursor.moveToFirst();
|
||||||
|
String fileName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
|
||||||
|
String fileNameUTF8 = new String(fileName.getBytes(), StandardCharsets.ISO_8859_1);
|
||||||
|
long fileSize = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE));
|
||||||
|
String type = activity.getContentResolver().getType(uri);
|
||||||
|
|
||||||
|
url = new URL(protocol, host, port, root + "/upload.php");
|
||||||
|
|
||||||
|
url = checkRedirection(url);
|
||||||
|
|
||||||
|
Progress p = new Progress(fileName, fileSize, Progress.UPLOAD);
|
||||||
|
|
||||||
|
if(url != null) {
|
||||||
|
|
||||||
|
Log.d("URL", url.toString());
|
||||||
|
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setDoInput(true); // Allow Inputs
|
||||||
|
conn.setDoOutput(true); // Allow Outputs
|
||||||
|
conn.setUseCaches(false); // Don't use a Cached Copy
|
||||||
|
conn.setChunkedStreamingMode(maxBufferSize);
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setRequestProperty("Connection", "keep-alive");
|
||||||
|
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
|
||||||
|
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
request = new DataOutputStream(conn.getOutputStream());
|
||||||
|
|
||||||
|
request.writeBytes("--" + boundary + "\r\n");
|
||||||
|
request.writeBytes("Content-Disposition: form-data; name=\"file\"; filename=\"" + fileNameUTF8 + "\"\r\n");
|
||||||
|
request.writeBytes("Content-Type: " + type + "\r\n\r\n");
|
||||||
|
|
||||||
|
InputStream in = activity.getContentResolver().openInputStream(uri);
|
||||||
|
|
||||||
|
while ((bufferLength = in.read(buffer)) > 0) {
|
||||||
|
request.write(buffer, 0, bufferLength);
|
||||||
|
loaded+= (long) bufferLength;
|
||||||
|
p.loaded = loaded;
|
||||||
|
p.percent = ((loaded * 100) / fileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
request.writeBytes("\r\n");
|
||||||
|
request.writeBytes("--" + boundary + "--\r\n");
|
||||||
|
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
int responseCode = conn.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
message = "File " + fileName + " successful upload";
|
||||||
|
p.stopProgress();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String s = conn.getResponseMessage();
|
||||||
|
throw new HttpErrorException("error code: " + responseCode + " " + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
request.flush();
|
||||||
|
|
||||||
|
request.close();
|
||||||
|
|
||||||
|
conn.disconnect();
|
||||||
|
|
||||||
|
System.out.println(message);
|
||||||
|
if (activity != null) {
|
||||||
|
String finalMessage = message;
|
||||||
|
activity.runOnUiThread(() ->
|
||||||
|
Snackbar.make(activity.findViewById(R.id.view_pager), finalMessage, Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Action", null).show());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileList() throws IOException {
|
||||||
|
URL url = null;
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
|
||||||
|
String fileList = "";
|
||||||
|
int buf;
|
||||||
|
|
||||||
|
url = new URL(protocol, host, port, root + "/list.php");
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setConnectTimeout(2000);
|
||||||
|
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
int responseCode = conn.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
InputStreamReader isw = new InputStreamReader(conn.getInputStream());
|
||||||
|
|
||||||
|
while ((buf = isw.read()) > 0) {
|
||||||
|
fileList = fileList + (char) buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String s = conn.getResponseMessage();
|
||||||
|
throw new HttpErrorException("error code: " + responseCode + " " + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.disconnect();
|
||||||
|
|
||||||
|
return fileList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void downloadFile(final Uri uri, String name, long fileSize, String href, Button button) throws IOException {
|
||||||
|
|
||||||
|
/*final LinearLayout layout = activity.findViewById(id);
|
||||||
|
final Button button;
|
||||||
|
if(layout != null)
|
||||||
|
button = layout.findViewById(R.id.file_download);
|
||||||
|
else
|
||||||
|
button = null;*/
|
||||||
|
|
||||||
|
final File file = new File(uri.getPath());
|
||||||
|
|
||||||
|
URL url = null;
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
int maxBufferSize = 1 * 1024 * 1024;
|
||||||
|
byte[] buffer = new byte[maxBufferSize];
|
||||||
|
int bufferLength;
|
||||||
|
long loaded = 0;
|
||||||
|
|
||||||
|
final Drawable image = activity.getDrawable(R.drawable.ic_spinner_rotate);
|
||||||
|
|
||||||
|
Progress p = new Progress(name, fileSize, Progress.DOWNLOAD);
|
||||||
|
if(button != null)
|
||||||
|
p.button = button;
|
||||||
|
|
||||||
|
if(p.button != null) {
|
||||||
|
activity.runOnUiThread(() -> {
|
||||||
|
int h = image.getIntrinsicHeight();
|
||||||
|
int w = image.getIntrinsicWidth();
|
||||||
|
image.setBounds(0, 0, w, h);
|
||||||
|
p.button.setCompoundDrawables(button.getCompoundDrawables()[0], null, image, null);
|
||||||
|
ObjectAnimator anim = ObjectAnimator.ofInt(image, "level", 0, 10000);
|
||||||
|
anim.setDuration(1000);
|
||||||
|
anim.setRepeatCount(Animation.INFINITE);
|
||||||
|
anim.setInterpolator(new LinearInterpolator());
|
||||||
|
anim.start();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = href.split("/");
|
||||||
|
String path = "";
|
||||||
|
for(int i=0; i< parts.length - 1; i++) {
|
||||||
|
path = path + parts[i] + "/";
|
||||||
|
}
|
||||||
|
String query = URLEncoder.encode(parts[parts.length - 1], StandardCharsets.UTF_8.toString());
|
||||||
|
url = new URL(protocol, host, port, path + query.replace("+", "%20"));
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setConnectTimeout(2000);
|
||||||
|
|
||||||
|
Log.d("URL", url.toString());
|
||||||
|
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
int responseCode = conn.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
|
||||||
|
FileOutputStream fileOutput = new FileOutputStream(file);
|
||||||
|
InputStream in = conn.getInputStream();
|
||||||
|
|
||||||
|
while ((bufferLength = in.read(buffer)) > 0) {
|
||||||
|
fileOutput.write(buffer, 0, bufferLength);
|
||||||
|
loaded+= (long) bufferLength;
|
||||||
|
p.loaded = loaded;
|
||||||
|
p.percent = ((loaded * 100) / fileSize);
|
||||||
|
if(Progress.app_started && p.button != null)
|
||||||
|
activity.runOnUiThread(() -> p.button.setText(String.format("Download in progress %d%%", p.percent)));
|
||||||
|
}
|
||||||
|
fileOutput.close();
|
||||||
|
|
||||||
|
conn.disconnect();
|
||||||
|
|
||||||
|
p.stopProgress();
|
||||||
|
|
||||||
|
if(p.button != null) {
|
||||||
|
activity.runOnUiThread(() -> {
|
||||||
|
final LinearLayout layout = (LinearLayout) p.button.getParent();
|
||||||
|
layout.findViewById(R.id.file_view).setVisibility(LinearLayout.VISIBLE);
|
||||||
|
layout.findViewById(R.id.file_share).setVisibility(LinearLayout.VISIBLE);
|
||||||
|
p.button.setVisibility(LinearLayout.GONE);
|
||||||
|
p.button.setEnabled(true);
|
||||||
|
|
||||||
|
p.button.setText(activity.getString(R.string.file_download));
|
||||||
|
p.button.setCompoundDrawables(p.button.getCompoundDrawables()[0], null, null, null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
activity.runOnUiThread(() -> {
|
||||||
|
String message = "File " + name + " successful download";
|
||||||
|
System.out.println(message);
|
||||||
|
Snackbar.make(activity.findViewById(R.id.view_pager), message, Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Action", null).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String s = conn.getResponseMessage();
|
||||||
|
throw new HttpErrorException("error code: " + responseCode + " " + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteFile(String file) throws IOException {
|
||||||
|
|
||||||
|
URL url = null;
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
|
||||||
|
String message;
|
||||||
|
|
||||||
|
String query = URLEncoder.encode(file, StandardCharsets.UTF_8.toString());
|
||||||
|
String serverUrl = root + "/delete.php?file=" + query;
|
||||||
|
url = new URL(protocol, host, port, serverUrl);
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setConnectTimeout(2000);
|
||||||
|
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
int responseCode = conn.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
|
||||||
|
message = "File " + file + " successful deleted";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String s = conn.getResponseMessage();
|
||||||
|
throw new HttpErrorException("error code: " + responseCode + " " + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.disconnect();
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int timeout;
|
||||||
|
|
||||||
|
public static void error(final String message, final TextView title, final LinearLayout layout) {
|
||||||
|
|
||||||
|
System.out.println(message);
|
||||||
|
|
||||||
|
if (timeout == 0) {
|
||||||
|
if (activity != null) {
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(layout != null)
|
||||||
|
layout.removeAllViews();
|
||||||
|
if(title != null) {
|
||||||
|
layout.addView(title);
|
||||||
|
title.setText(message);
|
||||||
|
}
|
||||||
|
Snackbar.make(activity.findViewById(R.id.view_pager), message, Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Action", null).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
timeout = 1;
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
timeout = 0;
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String humanReadableByteCountBin(long bytes) {
|
||||||
|
long absB = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes);
|
||||||
|
if (absB < 1024) {
|
||||||
|
return bytes + " B";
|
||||||
|
}
|
||||||
|
long value = absB;
|
||||||
|
CharacterIterator ci = new StringCharacterIterator("KMGTPE");
|
||||||
|
for (int i = 40; i >= 0 && absB > 0xfffccccccccccccL >> i; i -= 10) {
|
||||||
|
value >>= 10;
|
||||||
|
ci.next();
|
||||||
|
}
|
||||||
|
value *= Long.signum(bytes);
|
||||||
|
return String.format("%.1f %ciB", value / 1024.0, ci.current());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
75
app/src/main/java/com/localtransfer/TransferService.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
import android.app.IntentService;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class TransferService extends IntentService {
|
||||||
|
|
||||||
|
public static final String ACTION_UPLOAD = "com.localtransfer.action.FOO";
|
||||||
|
public static final String ACTION_DOWNLOAD = "com.localtransfer.action.BAZ";
|
||||||
|
|
||||||
|
public static final String EXTRA_URI = "com.localtransfer.extra.URI";
|
||||||
|
public static final String EXTRA = "com.localtransfer.extra.EXTRA";
|
||||||
|
|
||||||
|
public TransferService() {
|
||||||
|
super("TransferService");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onHandleIntent(Intent intent) {
|
||||||
|
if (intent != null) {
|
||||||
|
final String action = intent.getAction();
|
||||||
|
switch (action) {
|
||||||
|
case ACTION_UPLOAD:
|
||||||
|
handleUpload(intent);
|
||||||
|
break;
|
||||||
|
case ACTION_DOWNLOAD:
|
||||||
|
handleDownload(intent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleUpload(Intent intent) {
|
||||||
|
final Uri uri = intent.getParcelableExtra(EXTRA_URI);
|
||||||
|
|
||||||
|
Transfer tr = new Transfer();
|
||||||
|
try {
|
||||||
|
tr.uploadFile(uri);
|
||||||
|
} catch (IOException e) {
|
||||||
|
final String ExceptionName = e.getClass().getSimpleName();
|
||||||
|
final String ExceptionMess = e.getMessage();
|
||||||
|
|
||||||
|
if(ExceptionName != null && ExceptionMess != null) {
|
||||||
|
Transfer.error(ExceptionName + ": " + ExceptionMess, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleDownload(Intent intent) {
|
||||||
|
Extra ex = (Extra) intent.getExtras().getParcelable(EXTRA);
|
||||||
|
final LinearLayout layout = Transfer.activity.findViewById(ex.id);
|
||||||
|
Button button = null;
|
||||||
|
if(layout != null)
|
||||||
|
button = layout.findViewById(R.id.file_download);
|
||||||
|
|
||||||
|
Transfer tr = new Transfer();
|
||||||
|
try {
|
||||||
|
tr.downloadFile(Uri.parse(ex.uri), ex.name, ex.size, ex.href, button);
|
||||||
|
} catch (IOException e) {
|
||||||
|
final String ExceptionName = e.getClass().getSimpleName();
|
||||||
|
final String ExceptionMess = e.getMessage();
|
||||||
|
|
||||||
|
if(ExceptionName != null && ExceptionMess != null) {
|
||||||
|
Transfer.error(ExceptionName + ": " + ExceptionMess, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,416 @@
|
|||||||
|
package com.localtransfer.fragment;
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.ContextMenu;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.LinearInterpolator;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.localtransfer.BuildConfig;
|
||||||
|
import com.localtransfer.Extra;
|
||||||
|
import com.localtransfer.Progress;
|
||||||
|
import com.localtransfer.R;
|
||||||
|
import com.localtransfer.Transfer;
|
||||||
|
import com.localtransfer.TransferService;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.text.CharacterIterator;
|
||||||
|
import java.text.StringCharacterIterator;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
public class DownloadFragment extends Fragment {
|
||||||
|
|
||||||
|
public DownloadFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
private View root;
|
||||||
|
|
||||||
|
public static DownloadFragment newInstance() {
|
||||||
|
DownloadFragment fragment = new DownloadFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
root = inflater.inflate(R.layout.fragment_download, container, false);
|
||||||
|
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
showFileList();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
SwipeRefreshLayout refresh = root.findViewById(R.id.refresh);
|
||||||
|
|
||||||
|
refresh.setOnRefreshListener(() -> {
|
||||||
|
new Thread(() -> showFileList()).start();
|
||||||
|
refresh.setRefreshing(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause(){
|
||||||
|
super.onPause();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||||
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
|
menu.add ( 0 , v.getId (), 0 , "Delete" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
|
if (item.getTitle() == "Delete") {
|
||||||
|
LinearLayout fileDesc = (LinearLayout) root.findViewById(item.getItemId());
|
||||||
|
final String file = String.valueOf(fileDesc.getTag(R.id.ID_FILE_NAME));
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Transfer tr = new Transfer();
|
||||||
|
String message = tr.deleteFile(file);
|
||||||
|
System.out.println(message);
|
||||||
|
Transfer.activity.runOnUiThread(() ->
|
||||||
|
Snackbar.make(getActivity().findViewById(R.id.view_pager), message, Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Action", null).show());
|
||||||
|
showFileList();
|
||||||
|
} catch (IOException e) {
|
||||||
|
String ExceptionName = e.getClass().getSimpleName();
|
||||||
|
String ExceptionMess = e.getMessage();
|
||||||
|
|
||||||
|
if(ExceptionName != null && ExceptionMess != null) {
|
||||||
|
Transfer.error(ExceptionName + ": " + ExceptionMess, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showFileList() {
|
||||||
|
|
||||||
|
final TextView title = new TextView(Transfer.activity);
|
||||||
|
title.setTextSize(18);
|
||||||
|
title.setGravity(Gravity.CENTER);
|
||||||
|
final LinearLayout main_layout = root.findViewById(R.id.main_layout);
|
||||||
|
final LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(getContext().LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
|
Transfer tr = new Transfer();
|
||||||
|
|
||||||
|
String data = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
data = tr.getFileList();
|
||||||
|
} catch (IOException e) {
|
||||||
|
final String ExceptionName = e.getClass().getSimpleName();
|
||||||
|
final String ExceptionMess = e.getMessage();
|
||||||
|
|
||||||
|
if(ExceptionName != null && ExceptionMess != null) {
|
||||||
|
Transfer.error(ExceptionName + ": " + ExceptionMess, title, main_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (data.equals("[]")) {
|
||||||
|
Transfer.activity.runOnUiThread(() -> {
|
||||||
|
main_layout.removeAllViews();
|
||||||
|
main_layout.addView(title);
|
||||||
|
title.setHeight(1000);
|
||||||
|
title.setText("No file to download");
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
JSONArray array;
|
||||||
|
array = new JSONArray(data);
|
||||||
|
|
||||||
|
Transfer.activity.runOnUiThread(() -> {
|
||||||
|
main_layout.removeAllViews();
|
||||||
|
final View line = inflater.inflate(R.layout.horizontal_line, null);
|
||||||
|
main_layout.addView(line);
|
||||||
|
});
|
||||||
|
for (int i = 0; i < array.length(); i++) {
|
||||||
|
JSONObject row = array.getJSONObject(i);
|
||||||
|
final String name = row.getString("name");
|
||||||
|
final String href = row.getString("href");
|
||||||
|
final long size = row.getLong("size");
|
||||||
|
final String mime = row.getString("mime");
|
||||||
|
final String type = row.getString("type");
|
||||||
|
|
||||||
|
Transfer.activity.runOnUiThread(() -> {
|
||||||
|
title.setText("Choose file to download");
|
||||||
|
View file_info = inflater.inflate(R.layout.file_info, null);
|
||||||
|
main_layout.addView(file_info);
|
||||||
|
ImageView image = file_info.findViewById(R.id.file_image);
|
||||||
|
TextView viewName = file_info.findViewById(R.id.file_name);
|
||||||
|
TextView viewType = file_info.findViewById(R.id.file_type);
|
||||||
|
TextView viewSize = file_info.findViewById(R.id.file_size);
|
||||||
|
LinearLayout fileDesc = file_info.findViewById(R.id.file_desc);
|
||||||
|
LinearLayout file_buttons = file_info.findViewById(R.id.file_buttons);
|
||||||
|
|
||||||
|
fileDesc.setId(View.generateViewId());
|
||||||
|
file_buttons.setId(View.generateViewId());
|
||||||
|
file_buttons.setTag(R.id.ID_FILE_BUTTONS, "FOR VISIBILITY");
|
||||||
|
|
||||||
|
registerForContextMenu(fileDesc);
|
||||||
|
fileDesc.setTag(R.id.ID_FILE_NAME, name);
|
||||||
|
|
||||||
|
viewName.setText(name);
|
||||||
|
viewType.setText(mime);
|
||||||
|
viewSize.setText(Transfer.humanReadableByteCountBin(size));
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "file-image":
|
||||||
|
image.setImageResource(R.drawable.ic_icon_image);
|
||||||
|
break;
|
||||||
|
case "file-audio":
|
||||||
|
image.setImageResource(R.drawable.ic_icon_music);
|
||||||
|
break;
|
||||||
|
case "file-video":
|
||||||
|
image.setImageResource(R.drawable.ic_icon_video);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
image.setImageResource(R.drawable.ic_icon_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
fileDesc.setOnClickListener(view -> {
|
||||||
|
String save_location;
|
||||||
|
|
||||||
|
if (mime.equals("text/plain"))
|
||||||
|
save_location = getContext().getCacheDir().toString();
|
||||||
|
else
|
||||||
|
save_location = Environment.getExternalStorageDirectory() + "/" + Transfer.local_storage;
|
||||||
|
|
||||||
|
File file = new File(save_location, name);
|
||||||
|
|
||||||
|
file_buttons.setId(View.generateViewId());
|
||||||
|
|
||||||
|
Button Bview = file_buttons.findViewById(R.id.file_view);
|
||||||
|
Button Bshare = file_buttons.findViewById(R.id.file_share);
|
||||||
|
Button dl = file_buttons.findViewById(R.id.file_download);
|
||||||
|
|
||||||
|
dl.setOnClickListener(ListenerDL);
|
||||||
|
Bview.setOnClickListener(ListenerView);
|
||||||
|
Bshare.setOnClickListener(ListenerShare);
|
||||||
|
|
||||||
|
if (file.exists() && file.length() == size) {
|
||||||
|
Bview.setVisibility(LinearLayout.VISIBLE);
|
||||||
|
Bshare.setVisibility(LinearLayout.VISIBLE);
|
||||||
|
dl.setVisibility(LinearLayout.GONE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dl.setVisibility(LinearLayout.VISIBLE);
|
||||||
|
Bview.setVisibility(LinearLayout.GONE);
|
||||||
|
Bshare.setVisibility(LinearLayout.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Progress.setButton(name, dl)) {
|
||||||
|
dl.setEnabled(false);
|
||||||
|
final Drawable spinner = Transfer.activity.getDrawable(R.drawable.ic_spinner_rotate);
|
||||||
|
int h = spinner.getIntrinsicHeight();
|
||||||
|
int w = spinner.getIntrinsicWidth();
|
||||||
|
spinner.setBounds(0, 0, w, h);
|
||||||
|
dl.setCompoundDrawables(dl.getCompoundDrawables()[0], null, spinner, null);
|
||||||
|
ObjectAnimator anim = ObjectAnimator.ofInt(spinner, "level", 0, 10000);
|
||||||
|
anim.setDuration(1000);
|
||||||
|
anim.setRepeatCount(Animation.INFINITE);
|
||||||
|
anim.setInterpolator(new LinearInterpolator());
|
||||||
|
anim.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
file_buttons.setTag(R.id.ID_FILE_NAME, name);
|
||||||
|
file_buttons.setTag(R.id.ID_FILE_SIZE, size);
|
||||||
|
file_buttons.setTag(R.id.ID_FILE_HREF, href);
|
||||||
|
file_buttons.setTag(R.id.ID_FILE_MIME, mime);
|
||||||
|
file_buttons.setTag(R.id.ID_SAVE_LOCATION, save_location);
|
||||||
|
int state = file_buttons.getVisibility();
|
||||||
|
if(state == LinearLayout.GONE) {
|
||||||
|
for(View child : getAllChildren(main_layout)) {
|
||||||
|
if(child.getTag(R.id.ID_FILE_BUTTONS) != null)
|
||||||
|
child.setVisibility(LinearLayout.GONE);
|
||||||
|
}
|
||||||
|
file_buttons.setVisibility(LinearLayout.VISIBLE);
|
||||||
|
}
|
||||||
|
else if(state == LinearLayout.VISIBLE)
|
||||||
|
file_buttons.setVisibility(LinearLayout.GONE);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private View.OnClickListener ListenerDL = v -> {
|
||||||
|
v.setEnabled(false);
|
||||||
|
final LinearLayout layout = (LinearLayout) v.getParent();
|
||||||
|
final String name = (String) layout.getTag(R.id.ID_FILE_NAME);
|
||||||
|
final String save_location = String.valueOf(layout.getTag(R.id.ID_SAVE_LOCATION));
|
||||||
|
final long fileSize = (long) layout.getTag(R.id.ID_FILE_SIZE);
|
||||||
|
final String href = (String) layout.getTag(R.id.ID_FILE_HREF);
|
||||||
|
|
||||||
|
new File(save_location).mkdirs();
|
||||||
|
Uri uri = Uri.fromFile(new File(save_location, name));
|
||||||
|
|
||||||
|
Intent intent = new Intent(getActivity(), TransferService.class);
|
||||||
|
intent.setAction(TransferService.ACTION_DOWNLOAD);
|
||||||
|
intent.putExtra(TransferService.EXTRA, new Extra(uri, name, fileSize, href, layout));
|
||||||
|
getActivity().startService(intent);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener ListenerShare = v -> {
|
||||||
|
LinearLayout layout = (LinearLayout) v.getParent();
|
||||||
|
final String name = (String) layout.getTag(R.id.ID_FILE_NAME);
|
||||||
|
final String type = (String) layout.getTag(R.id.ID_FILE_MIME);
|
||||||
|
|
||||||
|
final String save_location = String.valueOf(layout.getTag(R.id.ID_SAVE_LOCATION));
|
||||||
|
File file = new File(save_location, name);
|
||||||
|
Uri uri = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID, file);
|
||||||
|
|
||||||
|
if(type.equals("text/plain")) {
|
||||||
|
String text = null;
|
||||||
|
try {
|
||||||
|
InputStream is = new FileInputStream(file);
|
||||||
|
BufferedReader buf = new BufferedReader(new InputStreamReader(is));
|
||||||
|
|
||||||
|
String line;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
while((line = buf.readLine()) != null) {
|
||||||
|
sb.append(line).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
text = sb.toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
|
intent.setType(type);
|
||||||
|
intent.putExtra(Intent.EXTRA_TEXT, text);
|
||||||
|
startActivity(Intent.createChooser(intent, getString(R.string.share_title)));
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
|
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
|
intent.setType(type);
|
||||||
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
startActivity(Intent.createChooser(intent, getString(R.string.share_title)));
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener ListenerView = v -> {
|
||||||
|
LinearLayout layout = (LinearLayout) v.getParent();
|
||||||
|
final String name = (String) layout.getTag(R.id.ID_FILE_NAME);
|
||||||
|
final String type = (String) layout.getTag(R.id.ID_FILE_MIME);
|
||||||
|
|
||||||
|
final String save_location = String.valueOf(layout.getTag(R.id.ID_SAVE_LOCATION));
|
||||||
|
File file = new File(save_location, name);
|
||||||
|
Uri uri = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID, file);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(uri, type);
|
||||||
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private List<View> getAllChildren(View v) {
|
||||||
|
|
||||||
|
if (!(v instanceof ViewGroup)) {
|
||||||
|
ArrayList<View> viewArrayList = new ArrayList<View>();
|
||||||
|
viewArrayList.add(v);
|
||||||
|
return viewArrayList;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<View> result = new ArrayList<View>();
|
||||||
|
|
||||||
|
ViewGroup viewGroup = (ViewGroup) v;
|
||||||
|
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||||
|
|
||||||
|
View child = viewGroup.getChildAt(i);
|
||||||
|
|
||||||
|
//add child
|
||||||
|
result.add(child);
|
||||||
|
|
||||||
|
//Do the same with child of child
|
||||||
|
result.addAll(getAllChildren(child));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package com.localtransfer.fragment;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.localtransfer.Progress;
|
||||||
|
import com.localtransfer.R;
|
||||||
|
import com.localtransfer.Transfer;
|
||||||
|
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
public class ProgressFragment extends Fragment {
|
||||||
|
|
||||||
|
public ProgressFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProgressFragment newInstance() {
|
||||||
|
ProgressFragment fragment = new ProgressFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
Progress.root = inflater.inflate(R.layout.fragment_progress, container, false);
|
||||||
|
|
||||||
|
return Progress.root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume(){
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
Progress.fragment_on = true;
|
||||||
|
|
||||||
|
List instances = Progress.getInstances();
|
||||||
|
for (Object obj: instances) {
|
||||||
|
Progress p = (Progress) obj;
|
||||||
|
p.showProgress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause(){
|
||||||
|
super.onPause();
|
||||||
|
|
||||||
|
Progress.fragment_on = false;
|
||||||
|
}
|
||||||
|
}
|
103
app/src/main/java/com/localtransfer/fragment/UploadFragment.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package com.localtransfer.fragment;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.localtransfer.MainActivity;
|
||||||
|
import com.localtransfer.R;
|
||||||
|
import com.localtransfer.Transfer;
|
||||||
|
import com.localtransfer.TransferService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class UploadFragment extends Fragment {
|
||||||
|
|
||||||
|
public UploadFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UploadFragment newInstance() {
|
||||||
|
UploadFragment fragment = new UploadFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
final View root = inflater.inflate(R.layout.fragment_upload, container, false);
|
||||||
|
|
||||||
|
Button upload = (Button) root.findViewById(R.id.upload);
|
||||||
|
upload.setOnClickListener(v -> selectFile());
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int REQUEST_ID_CHOOSE_FILES = 2002;
|
||||||
|
|
||||||
|
private void selectFile() {
|
||||||
|
Intent intent = new Intent()
|
||||||
|
.setType("*/*")
|
||||||
|
.setAction(Intent.ACTION_GET_CONTENT)
|
||||||
|
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||||
|
|
||||||
|
startActivityForResult(Intent.createChooser(intent, "Select a file"), REQUEST_ID_CHOOSE_FILES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
Log.d("RequestCode", String.valueOf(requestCode));
|
||||||
|
if (requestCode == REQUEST_ID_CHOOSE_FILES && resultCode == Activity.RESULT_OK) {
|
||||||
|
String type = data.getType();
|
||||||
|
|
||||||
|
ViewPager viewPager = getActivity().findViewById(R.id.view_pager);
|
||||||
|
viewPager.setCurrentItem(2);
|
||||||
|
|
||||||
|
Transfer tr = new Transfer();
|
||||||
|
|
||||||
|
if (type != null) {
|
||||||
|
String sharedText = data.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
tr.handleSendText(sharedText);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ArrayList<Uri> fileUris = new ArrayList<>();
|
||||||
|
if (data.getClipData() != null) { // Checking for selection multiple files
|
||||||
|
int nbItem = data.getClipData().getItemCount();
|
||||||
|
Toast.makeText(getContext(), "You select " + nbItem + " files", Toast.LENGTH_SHORT).show();
|
||||||
|
for (int i = 0; i < nbItem; i++) {
|
||||||
|
Uri uri = data.getClipData().getItemAt(i).getUri();
|
||||||
|
fileUris.add(uri);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Uri uri = data.getData(); //The uri with the location of the file
|
||||||
|
fileUris.add(uri);
|
||||||
|
}
|
||||||
|
for (Uri uri : fileUris) {
|
||||||
|
Intent intent = new Intent(getActivity(), TransferService.class);
|
||||||
|
intent.setAction(TransferService.ACTION_UPLOAD);
|
||||||
|
intent.putExtra(TransferService.EXTRA_URI, uri);
|
||||||
|
getActivity().startService(intent);
|
||||||
|
//tr.handleSendFile(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
app/src/main/res/drawable/circle_shape.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="ring"
|
||||||
|
android:innerRadiusRatio="2.5"
|
||||||
|
android:thickness="3dp"
|
||||||
|
android:useLevel="false">
|
||||||
|
|
||||||
|
<solid android:color="#CCC" />
|
||||||
|
|
||||||
|
</shape>
|
19
app/src/main/res/drawable/circular_progress_bar.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromDegrees="270"
|
||||||
|
android:toDegrees="270">
|
||||||
|
<shape
|
||||||
|
android:innerRadiusRatio="2.5"
|
||||||
|
android:shape="ring"
|
||||||
|
android:thickness="3dp"
|
||||||
|
android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->
|
||||||
|
|
||||||
|
<gradient
|
||||||
|
android:angle="0"
|
||||||
|
android:endColor="#007DD6"
|
||||||
|
android:startColor="#007DD6"
|
||||||
|
android:type="sweep"
|
||||||
|
android:useLevel="false" />
|
||||||
|
</shape>
|
||||||
|
|
||||||
|
</rotate>
|
9
app/src/main/res/drawable/ic_download.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="512dp"
|
||||||
|
android:height="512dp"
|
||||||
|
android:viewportWidth="512"
|
||||||
|
android:viewportHeight="512">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M216,0h80c13.3,0 24,10.7 24,24v168h87.7c17.8,0 26.7,21.5 14.1,34.1L269.7,378.3c-7.5,7.5 -19.8,7.5 -27.3,0L90.1,226.1c-12.6,-12.6 -3.7,-34.1 14.1,-34.1L192,192L192,24c0,-13.3 10.7,-24 24,-24zM512,376v112c0,13.3 -10.7,24 -24,24L24,512c-13.3,0 -24,-10.7 -24,-24L0,376c0,-13.3 10.7,-24 24,-24h146.7l49,49c20.1,20.1 52.5,20.1 72.6,0l49,-49L488,352c13.3,0 24,10.7 24,24zM388,464c0,-11 -9,-20 -20,-20s-20,9 -20,20 9,20 20,20 20,-9 20,-20zM452,464c0,-11 -9,-20 -20,-20s-20,9 -20,20 9,20 20,20 20,-9 20,-20z"/>
|
||||||
|
</vector>
|
11
app/src/main/res/drawable/ic_download_24.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:drawable="@drawable/ic_download"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
|
</layer-list >
|
10
app/src/main/res/drawable/ic_folder_open.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8h16v10z"/>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_icon_file.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6L6,2zM13,9L13,3.5L18.5,9L13,9z"/>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_icon_image.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_icon_music.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,3v10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55 -2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4V7h4V3h-6z"/>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_icon_video.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M8,5v14l11,-7z"/>
|
||||||
|
</vector>
|
14
app/src/main/res/drawable/ic_launcher.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<group android:scaleX="0.12105304"
|
||||||
|
android:scaleY="0.12105304"
|
||||||
|
android:translateX="24.3"
|
||||||
|
android:translateY="24.3">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M490.694,271.546c0,60.687 -49.379,110.064 -110.064,110.064h-28.561v-23.235h28.561c47.877,0 86.829,-38.945 86.829,-86.823c0,-47.877 -38.952,-86.82 -86.829,-86.82c-4.504,0 -9.257,0.432 -14.523,1.321l-7.43,1.253l-4.173,-6.271c-16.172,-24.296 -43.207,-38.798 -72.312,-38.798c-2.908,0 -5.876,0.153 -8.79,0.443l-9.794,0.993l-2.583,-9.505c-10.243,-37.702 -44.656,-64.043 -83.693,-64.043c-47.871,0 -86.82,38.949 -86.82,86.82c0,6.011 0.641,12.105 1.918,18.11l2.211,10.392l-10.152,3.129c-36.641,11.275 -61.25,44.626 -61.25,82.981c0,45.082 34.534,82.213 78.524,86.41c-2.746,1.395 -5.228,3.351 -7.128,5.887c-2.657,3.559 -4.117,7.968 -4.117,12.401c0,1.199 0.121,2.399 0.328,3.569C39.301,370.7 0,325.683 0,271.558c0,-45.188 26.953,-84.887 68.039,-101.745c-0.508,-4.286 -0.763,-8.588 -0.763,-12.862c0,-60.683 49.37,-110.056 110.056,-110.056c46.308,0 87.477,29.211 103.229,72.123c35.11,-0.44 67.844,15.552 88.98,43.113c3.83,-0.417 7.495,-0.629 11.101,-0.629C441.315,161.491 490.694,210.861 490.694,271.546zM218.657,365.185l-37.102,14.652V254.168c0,-1.637 -1.324,-2.973 -2.97,-2.973h-29.731c-1.64,0 -2.967,1.336 -2.967,2.973v125.669l-37.09,-14.652c-1.248,-0.491 -2.663,-0.089 -3.467,0.976c-0.396,0.531 -0.6,1.158 -0.6,1.791c0,0.632 0.204,1.276 0.618,1.814l56.022,72.867c0.562,0.733 1.433,1.165 2.361,1.165c0.925,0 1.791,-0.432 2.353,-1.165l56.031,-72.867c0.816,-1.064 0.816,-2.542 0.018,-3.605C221.326,365.096 219.898,364.694 218.657,365.185zM371.326,328.833c0.39,-0.532 0.597,-1.164 0.597,-1.791c0,-0.638 -0.207,-1.276 -0.62,-1.809L315.28,252.36c-0.562,-0.732 -1.431,-1.164 -2.358,-1.164s-1.785,0.432 -2.358,1.164l-56.022,72.874c-0.821,1.059 -0.821,2.536 -0.023,3.6c0.804,1.064 2.229,1.466 3.47,0.976l37.102,-14.652v125.668c0,1.644 1.324,2.974 2.974,2.974h29.731c1.637,0 2.973,-1.33 2.973,-2.974V315.157l37.096,14.652C369.092,330.299 370.522,329.898 371.326,328.833z"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
14
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<group android:scaleX="0.12105304"
|
||||||
|
android:scaleY="0.12105304"
|
||||||
|
android:translateX="24.3"
|
||||||
|
android:translateY="24.3">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M490.694,271.546c0,60.687 -49.379,110.064 -110.064,110.064h-28.561v-23.235h28.561c47.877,0 86.829,-38.945 86.829,-86.823c0,-47.877 -38.952,-86.82 -86.829,-86.82c-4.504,0 -9.257,0.432 -14.523,1.321l-7.43,1.253l-4.173,-6.271c-16.172,-24.296 -43.207,-38.798 -72.312,-38.798c-2.908,0 -5.876,0.153 -8.79,0.443l-9.794,0.993l-2.583,-9.505c-10.243,-37.702 -44.656,-64.043 -83.693,-64.043c-47.871,0 -86.82,38.949 -86.82,86.82c0,6.011 0.641,12.105 1.918,18.11l2.211,10.392l-10.152,3.129c-36.641,11.275 -61.25,44.626 -61.25,82.981c0,45.082 34.534,82.213 78.524,86.41c-2.746,1.395 -5.228,3.351 -7.128,5.887c-2.657,3.559 -4.117,7.968 -4.117,12.401c0,1.199 0.121,2.399 0.328,3.569C39.301,370.7 0,325.683 0,271.558c0,-45.188 26.953,-84.887 68.039,-101.745c-0.508,-4.286 -0.763,-8.588 -0.763,-12.862c0,-60.683 49.37,-110.056 110.056,-110.056c46.308,0 87.477,29.211 103.229,72.123c35.11,-0.44 67.844,15.552 88.98,43.113c3.83,-0.417 7.495,-0.629 11.101,-0.629C441.315,161.491 490.694,210.861 490.694,271.546zM218.657,365.185l-37.102,14.652V254.168c0,-1.637 -1.324,-2.973 -2.97,-2.973h-29.731c-1.64,0 -2.967,1.336 -2.967,2.973v125.669l-37.09,-14.652c-1.248,-0.491 -2.663,-0.089 -3.467,0.976c-0.396,0.531 -0.6,1.158 -0.6,1.791c0,0.632 0.204,1.276 0.618,1.814l56.022,72.867c0.562,0.733 1.433,1.165 2.361,1.165c0.925,0 1.791,-0.432 2.353,-1.165l56.031,-72.867c0.816,-1.064 0.816,-2.542 0.018,-3.605C221.326,365.096 219.898,364.694 218.657,365.185zM371.326,328.833c0.39,-0.532 0.597,-1.164 0.597,-1.791c0,-0.638 -0.207,-1.276 -0.62,-1.809L315.28,252.36c-0.562,-0.732 -1.431,-1.164 -2.358,-1.164s-1.785,0.432 -2.358,1.164l-56.022,72.874c-0.821,1.059 -0.821,2.536 -0.023,3.6c0.804,1.064 2.229,1.466 3.47,0.976l37.102,-14.652v125.668c0,1.644 1.324,2.974 2.974,2.974h29.731c1.637,0 2.973,-1.33 2.973,-2.974V315.157l37.096,14.652C369.092,330.299 370.522,329.898 371.326,328.833z"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_open.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z"/>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_settings.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_share.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
|
||||||
|
</vector>
|
4
app/src/main/res/drawable/ic_spinner.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<vector android:height="24dp" android:viewportHeight="1792"
|
||||||
|
android:viewportWidth="1792" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M526,1394q0,53 -37.5,90.5t-90.5,37.5q-52,0 -90,-38t-38,-90q0,-53 37.5,-90.5t90.5,-37.5 90.5,37.5 37.5,90.5zM1024,1600q0,53 -37.5,90.5t-90.5,37.5 -90.5,-37.5 -37.5,-90.5 37.5,-90.5 90.5,-37.5 90.5,37.5 37.5,90.5zM320,896q0,53 -37.5,90.5t-90.5,37.5 -90.5,-37.5 -37.5,-90.5 37.5,-90.5 90.5,-37.5 90.5,37.5 37.5,90.5zM1522,1394q0,52 -38,90t-90,38q-53,0 -90.5,-37.5t-37.5,-90.5 37.5,-90.5 90.5,-37.5 90.5,37.5 37.5,90.5zM558,398q0,66 -47,113t-113,47 -113,-47 -47,-113 47,-113 113,-47 113,47 47,113zM1728,896q0,53 -37.5,90.5t-90.5,37.5 -90.5,-37.5 -37.5,-90.5 37.5,-90.5 90.5,-37.5 90.5,37.5 37.5,90.5zM1088,192q0,80 -56,136t-136,56 -136,-56 -56,-136 56,-136 136,-56 136,56 56,136zM1618,398q0,93 -66,158.5t-158,65.5q-93,0 -158.5,-65.5t-65.5,-158.5q0,-92 65.5,-158t158.5,-66q92,0 158,66t66,158z"/>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_spinner_rotate.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<rotate
|
||||||
|
android:drawable="@drawable/ic_spinner"
|
||||||
|
android:fromDegrees="0"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:toDegrees="360" />
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
9
app/src/main/res/drawable/ic_upload.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="512dp"
|
||||||
|
android:height="512dp"
|
||||||
|
android:viewportWidth="512"
|
||||||
|
android:viewportHeight="512">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M296,384h-80c-13.3,0 -24,-10.7 -24,-24L192,192h-87.7c-17.8,0 -26.7,-21.5 -14.1,-34.1L242.3,5.7c7.5,-7.5 19.8,-7.5 27.3,0l152.2,152.2c12.6,12.6 3.7,34.1 -14.1,34.1L320,192v168c0,13.3 -10.7,24 -24,24zM512,376v112c0,13.3 -10.7,24 -24,24L24,512c-13.3,0 -24,-10.7 -24,-24L0,376c0,-13.3 10.7,-24 24,-24h136v8c0,30.9 25.1,56 56,56h80c30.9,0 56,-25.1 56,-56v-8h136c13.3,0 24,10.7 24,24zM388,464c0,-11 -9,-20 -20,-20s-20,9 -20,20 9,20 20,20 20,-9 20,-20zM452,464c0,-11 -9,-20 -20,-20s-20,9 -20,20 9,20 20,20 20,-9 20,-20z"/>
|
||||||
|
</vector>
|
11
app/src/main/res/drawable/ic_upload_24.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:drawable="@drawable/ic_upload"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
|
</layer-list >
|
11
app/src/main/res/drawable/ic_upload_32.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:drawable="@drawable/ic_upload"
|
||||||
|
android:width="@dimen/icon_size"
|
||||||
|
android:height="@dimen/icon_size"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
|
</layer-list >
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="490.694dp"
|
||||||
|
android:height="490.694dp"
|
||||||
|
android:viewportWidth="490.694"
|
||||||
|
android:viewportHeight="490.694">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M490.694,271.546c0,60.687 -49.379,110.064 -110.064,110.064h-28.561v-23.235h28.561c47.877,0 86.829,-38.945 86.829,-86.823c0,-47.877 -38.952,-86.82 -86.829,-86.82c-4.504,0 -9.257,0.432 -14.523,1.321l-7.43,1.253l-4.173,-6.271c-16.172,-24.296 -43.207,-38.798 -72.312,-38.798c-2.908,0 -5.876,0.153 -8.79,0.443l-9.794,0.993l-2.583,-9.505c-10.243,-37.702 -44.656,-64.043 -83.693,-64.043c-47.871,0 -86.82,38.949 -86.82,86.82c0,6.011 0.641,12.105 1.918,18.11l2.211,10.392l-10.152,3.129c-36.641,11.275 -61.25,44.626 -61.25,82.981c0,45.082 34.534,82.213 78.524,86.41c-2.746,1.395 -5.228,3.351 -7.128,5.887c-2.657,3.559 -4.117,7.968 -4.117,12.401c0,1.199 0.121,2.399 0.328,3.569C39.301,370.7 0,325.683 0,271.558c0,-45.188 26.953,-84.887 68.039,-101.745c-0.508,-4.286 -0.763,-8.588 -0.763,-12.862c0,-60.683 49.37,-110.056 110.056,-110.056c46.308,0 87.477,29.211 103.229,72.123c35.11,-0.44 67.844,15.552 88.98,43.113c3.83,-0.417 7.495,-0.629 11.101,-0.629C441.315,161.491 490.694,210.861 490.694,271.546zM218.657,365.185l-37.102,14.652V254.168c0,-1.637 -1.324,-2.973 -2.97,-2.973h-29.731c-1.64,0 -2.967,1.336 -2.967,2.973v125.669l-37.09,-14.652c-1.248,-0.491 -2.663,-0.089 -3.467,0.976c-0.396,0.531 -0.6,1.158 -0.6,1.791c0,0.632 0.204,1.276 0.618,1.814l56.022,72.867c0.562,0.733 1.433,1.165 2.361,1.165c0.925,0 1.791,-0.432 2.353,-1.165l56.031,-72.867c0.816,-1.064 0.816,-2.542 0.018,-3.605C221.326,365.096 219.898,364.694 218.657,365.185zM371.326,328.833c0.39,-0.532 0.597,-1.164 0.597,-1.791c0,-0.638 -0.207,-1.276 -0.62,-1.809L315.28,252.36c-0.562,-0.732 -1.431,-1.164 -2.358,-1.164s-1.785,0.432 -2.358,1.164l-56.022,72.874c-0.821,1.059 -0.821,2.536 -0.023,3.6c0.804,1.064 2.229,1.466 3.47,0.976l37.102,-14.652v125.668c0,1.644 1.324,2.974 2.974,2.974h29.731c1.637,0 2.973,-1.33 2.973,-2.974V315.157l37.096,14.652C369.092,330.299 370.522,329.898 371.326,328.833z"/>
|
||||||
|
</vector>
|
42
app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabLayout
|
||||||
|
android:id="@+id/tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorPrimary" />
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.viewpager.widget.ViewPager
|
||||||
|
android:id="@+id/view_pager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/flotUpload"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
app:srcCompat="@drawable/ic_upload_24" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
97
app/src/main/res/layout/file_info.xml
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/file_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/file_desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/file_image"
|
||||||
|
android:layout_width="81dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:scaleX="2"
|
||||||
|
android:scaleY="2" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/file_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="5dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/file_type"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:maxWidth="200dp"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:paddingEnd="10dp"
|
||||||
|
android:singleLine="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/file_size"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:paddingEnd="10dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/file_buttons"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/file_download"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawableStart="@drawable/ic_download_24"
|
||||||
|
android:text="@string/file_download" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/file_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawableStart="@drawable/ic_open"
|
||||||
|
android:text="@string/file_view" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/file_share"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawableStart="@drawable/ic_share"
|
||||||
|
android:text="@string/file_share" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/horizontal_line" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
37
app/src/main/res/layout/fragment_download.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?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"
|
||||||
|
tools:context=".fragment.DownloadFragment">
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
android:id="@+id/refresh"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
tools:layout_editor_absoluteX="153dp">
|
||||||
|
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/main_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/horizontal_line" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
23
app/src/main/res/layout/fragment_main.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?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:id="@+id/constraintLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.main.PlaceholderFragment">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/section_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||||
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/constraintLayout"
|
||||||
|
tools:layout_constraintLeft_creator="1"
|
||||||
|
tools:layout_constraintTop_creator="1" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
22
app/src/main/res/layout/fragment_progress.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout 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"
|
||||||
|
tools:context=".fragment.ProgressFragment" >
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/groot"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
26
app/src/main/res/layout/fragment_upload.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?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"
|
||||||
|
tools:context=".fragment.UploadFragment">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/upload"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:drawableStart="@drawable/ic_upload_32"
|
||||||
|
android:drawablePadding="10dp"
|
||||||
|
android:paddingLeft="70dp"
|
||||||
|
android:paddingTop="50dp"
|
||||||
|
android:paddingRight="70dp"
|
||||||
|
android:paddingBottom="50dp"
|
||||||
|
android:text="@string/upload"
|
||||||
|
android:textSize="18sp"
|
||||||
|
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.39" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
13
app/src/main/res/layout/horizontal_line.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/horizontal_line"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@android:color/darker_gray" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
65
app/src/main/res/layout/progress.xml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:paddingEnd="10dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/transferType"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:paddingEnd="10dp"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileSize"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/progressContainer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:indeterminate="false"
|
||||||
|
android:max="100"
|
||||||
|
android:progress="0"
|
||||||
|
android:progressDrawable="@drawable/circular_progress_bar" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/progressText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:text="0 %" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
9
app/src/main/res/layout/settings_activity.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/settings"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</LinearLayout>
|
16
app/src/main/res/menu/main.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_folder"
|
||||||
|
android:icon="@drawable/ic_folder_open"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_folder"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:icon="@drawable/ic_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_settings"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
</menu>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal 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="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal 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="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 12 KiB |
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||||
|
(such as screen margins) for screens with more than 820dp of available width. This
|
||||||
|
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||||
|
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||||
|
</resources>
|
12
app/src/main/res/values/arrays.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- Reply Preference -->
|
||||||
|
<string-array name="reply_entries">
|
||||||
|
<item>Reply</item>
|
||||||
|
<item>Reply to all</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="reply_values">
|
||||||
|
<item>reply</item>
|
||||||
|
<item>reply_all</item>
|
||||||
|
</string-array>
|
||||||
|
</resources>
|
6
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#008478</color>
|
||||||
|
<color name="colorPrimaryDark">#00746A</color>
|
||||||
|
<color name="colorAccent">#2196F3</color>
|
||||||
|
</resources>
|
9
app/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
<dimen name="appbar_padding">16dp</dimen>
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
|
<dimen name="appbar_padding_top">8dp</dimen>
|
||||||
|
<dimen name="icon_size">32dp</dimen>
|
||||||
|
</resources>
|
4
app/src/main/res/values/ic_launcher_background.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#3DDC84</color>
|
||||||
|
</resources>
|
9
app/src/main/res/values/ids.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<item name="ID_FILE_NAME" type="id" />
|
||||||
|
<item name="ID_FILE_SIZE" type="id" />
|
||||||
|
<item name="ID_FILE_HREF" type="id" />
|
||||||
|
<item name="ID_FILE_MIME" type="id" />
|
||||||
|
<item name="ID_SAVE_LOCATION" type="id" />
|
||||||
|
<item name="ID_FILE_BUTTONS" type="id" />
|
||||||
|
</resources>
|
43
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Local Transfer</string>
|
||||||
|
|
||||||
|
<!-- NavigationUI Summary -->
|
||||||
|
<string name="nav_header_title">Local Transfer</string>
|
||||||
|
<string name="nav_header_subtitle">File transfer in local area network</string>
|
||||||
|
<string name="nav_header_desc"></string>
|
||||||
|
|
||||||
|
<!-- Menu Titles -->
|
||||||
|
<string name="action_folder">Open Download Folder</string>
|
||||||
|
<string name="action_settings">Settings</string>
|
||||||
|
|
||||||
|
<!-- Tabs Titles -->
|
||||||
|
<string name="download">Download</string>
|
||||||
|
<string name="upload">Upload</string>
|
||||||
|
<string name="progress">Progress</string>
|
||||||
|
<string name="title_activity_settings">Preferences</string>
|
||||||
|
|
||||||
|
<!-- Preference Titles -->
|
||||||
|
<string name="server_header">Server Preferences</string>
|
||||||
|
<string name="local_header">Local Preferences</string>
|
||||||
|
|
||||||
|
<!-- Server Preferences -->
|
||||||
|
<string name="server_host">Host</string>
|
||||||
|
<string name="server_protocol">Use secure https</string>
|
||||||
|
<string name="server_host_def">netdldata.lan</string>
|
||||||
|
<string name="server_port">Port</string>
|
||||||
|
<string name="server_port_def">80</string>
|
||||||
|
<string name="server_root">Root</string>
|
||||||
|
<string name="server_root_def">/projects/transfer</string>
|
||||||
|
|
||||||
|
<!-- Local Preferences -->
|
||||||
|
<string name="local_storage">Local Storage</string>
|
||||||
|
<string name="local_storage_def">Download/TransferLocal</string>
|
||||||
|
|
||||||
|
<!-- File buttons -->
|
||||||
|
<string name="file_share">Share</string>
|
||||||
|
<string name="file_view">View</string>
|
||||||
|
<string name="file_download">Download</string>
|
||||||
|
|
||||||
|
<string name="share_title">Open with</string>
|
||||||
|
|
||||||
|
</resources>
|
19
app/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<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">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
|
||||||
|
</resources>
|
19
app/src/main/res/xml/preference_edit_text_input.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<EditText android:id="@android:id/edit"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="number"
|
||||||
|
android:singleLine="true"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
android:layout_marginStart="21dp"
|
||||||
|
android:layout_marginEnd="21dp"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
8
app/src/main/res/xml/provider_paths.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<paths>
|
||||||
|
<files-path name="files" path="/"/>
|
||||||
|
<cache-path name="cache" path="/"/>
|
||||||
|
<external-path name="ExtPath" path="/"/>
|
||||||
|
<external-files-path name="ExtFiles" path="/"/>
|
||||||
|
<external-cache-path name="CacheFiles" path="/"/>
|
||||||
|
<external-media-path name="MediaFiles" path="/"/>
|
||||||
|
</paths>
|
42
app/src/main/res/xml/root_preferences.xml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
app:title="@string/server_header">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="protocol"
|
||||||
|
android:title="@string/server_protocol" />
|
||||||
|
<EditTextPreference
|
||||||
|
app:defaultValue="@string/server_host_def"
|
||||||
|
app:key="host"
|
||||||
|
app:title="@string/server_host"
|
||||||
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
app:defaultValue="@string/server_port_def"
|
||||||
|
app:key="port"
|
||||||
|
app:title="@string/server_port"
|
||||||
|
app:useSimpleSummaryProvider="true"
|
||||||
|
app:dialogLayout="@xml/preference_edit_text_input" />
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
app:defaultValue="@string/server_root_def"
|
||||||
|
app:key="root"
|
||||||
|
app:title="@string/server_root"
|
||||||
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory app:title="@string/local_header">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:key="local_storage"
|
||||||
|
app:title="@string/local_storage"
|
||||||
|
app:defaultValue="@string/local_storage_def"
|
||||||
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
17
app/src/test/java/com/localtransfer/ExampleUnitTest.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.localtransfer;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
24
build.gradle
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.1"
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
19
gradle.properties
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# 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=-Xmx2048m
|
||||||
|
# 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
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#Fri Aug 07 14:16:09 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
Normal 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
settings.gradle
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
include ':app'
|
||||||
|
rootProject.name = "LocalTransfer"
|