-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99626ac
commit 4ea0de2
Showing
168 changed files
with
6,236 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.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 | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
namespace 'top.weixiansen574.hybridfilexfer' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "top.weixiansen574.hybridfilexfer" | ||
minSdk 24 | ||
targetSdk 34 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildFeatures { | ||
viewBinding true | ||
buildConfig = true | ||
aidl = true | ||
} | ||
|
||
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 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.11.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
implementation "dev.rikka.shizuku:api:13.1.5" | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "top.weixiansen574.hybridfilexfer", | ||
"variantName": "debug", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 1, | ||
"versionName": "1.0_1711385041641", | ||
"outputFile": "app-debug.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
...id/app/src/androidTest/java/top/weixiansen574/hybridfilexfer/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package top.weixiansen574.hybridfilexfer; | ||
|
||
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("top.weixiansen574.hybirdfilexfer", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission | ||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE" | ||
tools:ignore="ScopedStorage" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@drawable/logo" | ||
android:label="@string/app_name" | ||
|
||
android:supportsRtl="true" | ||
android:theme="@style/Theme.HybridFileXfer" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".TransferActivity" | ||
android:theme="@style/Theme.HybridFileXfer.NoActionBar" | ||
android:exported="false" /> | ||
|
||
<service | ||
android:name=".TransferServices" | ||
android:process=":TransferService" | ||
android:enabled="true"/> | ||
|
||
<activity | ||
android:name=".MainActivity" | ||
android:theme="@style/Theme.HybridFileXfer" | ||
android:exported="true"> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
28 changes: 28 additions & 0 deletions
28
...FileXfer-Android/app/src/main/aidl/top/weixiansen574/hybridfilexfer/ITransferService.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// ITransferService.aidl | ||
package top.weixiansen574.hybridfilexfer; | ||
|
||
// Declare any non-default types here with import statements | ||
|
||
interface ITransferService { | ||
void destroy() = 16777114; // Destroy method defined by Shizuku server | ||
|
||
void exit() = 1; // Exit method defined by user | ||
|
||
top.weixiansen574.hybridfilexfer.droidcore.Error startServer() = 2; | ||
void stopServer() = 3; | ||
void waitingForDied() = 4; | ||
void stopGetNextEvent() = 5; | ||
|
||
void transferToPc(in List<String> files,String localDir,String remoteDir) = 101; | ||
void transferToMe(in List<String> files, String remoteDir, String localDir) = 102; | ||
List<top.weixiansen574.hybridfilexfer.droidcore.ParcelableRemoteFile> listClientFiles(String path) = 100; | ||
top.weixiansen574.hybridfilexfer.droidcore.ParcelableFileTransferEvent getNextFileTransferEvent() = 110; | ||
top.weixiansen574.hybridfilexfer.droidcore.ParcelableTransferredBytesInfo getTransferredBytesInfo() = 111; | ||
|
||
List<top.weixiansen574.hybridfilexfer.droidcore.ParcelableRemoteFile> listLocalFiles(String path) = 200; | ||
top.weixiansen574.hybridfilexfer.droidcore.ParcelableRemoteFile getParentFile(String path) = 201; | ||
|
||
|
||
|
||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...dFileXfer-Android/app/src/main/aidl/top/weixiansen574/hybridfilexfer/droidcore/Error.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// ParcelableFileTransferEvent.aidl | ||
package top.weixiansen574.hybridfilexfer.droidcore; | ||
// Declare any non-default types here with import statements | ||
|
||
parcelable Error; |
5 changes: 5 additions & 0 deletions
5
...src/main/aidl/top/weixiansen574/hybridfilexfer/droidcore/ParcelableFileTransferEvent.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// ParcelableFileTransferEvent.aidl | ||
package top.weixiansen574.hybridfilexfer.droidcore; | ||
// Declare any non-default types here with import statements | ||
|
||
parcelable ParcelableFileTransferEvent; |
6 changes: 6 additions & 0 deletions
6
...id/app/src/main/aidl/top/weixiansen574/hybridfilexfer/droidcore/ParcelableRemoteFile.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// ParcelableRemoteFile.aidl | ||
package top.weixiansen574.hybridfilexfer.droidcore; | ||
|
||
// Declare any non-default types here with import statements | ||
|
||
parcelable ParcelableRemoteFile; |
5 changes: 5 additions & 0 deletions
5
.../main/aidl/top/weixiansen574/hybridfilexfer/droidcore/ParcelableTransferredBytesInfo.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// ParcelableFileTransferEvent.aidl | ||
package top.weixiansen574.hybridfilexfer.droidcore; | ||
// Declare any non-default types here with import statements | ||
|
||
parcelable ParcelableTransferredBytesInfo; |
26 changes: 26 additions & 0 deletions
26
HybridFileXfer-Android/app/src/main/java/top/weixiansen574/async/BackstageTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package top.weixiansen574.async; | ||
|
||
public abstract class BackstageTask<T extends EventHandler> implements Runnable{ | ||
private final T handle; | ||
public BackstageTask(T handle){ | ||
this.handle = handle; | ||
} | ||
|
||
@Override | ||
public void run(){ | ||
try { | ||
onStart(handle); | ||
} catch (Throwable e) { | ||
handle.sendError(e); | ||
} | ||
} | ||
public void execute(){TaskManger.execute(this);} | ||
protected abstract void onStart(T eventHandler) throws Throwable; | ||
protected void sleep(long time){ | ||
try { | ||
Thread.sleep(time); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
HybridFileXfer-Android/app/src/main/java/top/weixiansen574/async/EventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package top.weixiansen574.async; | ||
|
||
import android.os.Handler; | ||
import android.os.Looper; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public abstract class EventHandler extends Handler { | ||
public EventHandler() { | ||
super(); | ||
} | ||
|
||
public EventHandler(@NonNull Looper looper) { | ||
super(looper); | ||
} | ||
|
||
public void sendEventMessage(EventMessage message) { | ||
post(() -> handleEvent(message)); | ||
} | ||
|
||
public void sendEventMessage(int what,Object... objects){ | ||
post(() -> handleEvent(new EventMessage(what,objects))); | ||
} | ||
|
||
public void sendEmptyEventMessage(int what){ | ||
post(() -> handleEvent(new EventMessage(what))); | ||
} | ||
|
||
public void sendError(Throwable th) { | ||
post(() -> handleError(th)); | ||
} | ||
|
||
protected abstract void handleEvent(EventMessage message); | ||
|
||
protected abstract void handleError(Throwable th); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
HybridFileXfer-Android/app/src/main/java/top/weixiansen574/async/EventMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package top.weixiansen574.async; | ||
|
||
public class EventMessage { | ||
private final int what; | ||
private final Object[] objects; | ||
public EventMessage(Object[] objects,int what){ | ||
this.what = what; | ||
this.objects = objects; | ||
} | ||
public EventMessage(int what,Object... objects){ | ||
this.what = what; | ||
this.objects = objects; | ||
} | ||
|
||
public EventMessage(int what){ | ||
this.what = what; | ||
this.objects = new Object[0]; | ||
} | ||
|
||
public <T> T getObject(int index,Class<T> clazz){ | ||
return clazz.cast(objects[index]); | ||
} | ||
|
||
public int getWhat() { | ||
return what; | ||
} | ||
|
||
public Object[] getObjects(){ | ||
return objects; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
HybridFileXfer-Android/app/src/main/java/top/weixiansen574/async/TaskManger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package top.weixiansen574.async; | ||
|
||
import android.os.Handler; | ||
import android.os.Looper; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
public class TaskManger { | ||
private static volatile Handler mainThreadHandler; | ||
private static Handler getUiThreadHandler() { | ||
if (mainThreadHandler == null) { | ||
synchronized (TaskManger.class) { | ||
if (mainThreadHandler == null) { | ||
mainThreadHandler = new Handler(Looper.getMainLooper()); | ||
} | ||
} | ||
} | ||
return mainThreadHandler; | ||
} | ||
|
||
|
||
|
||
public static void postOnUiThread(Runnable runnable) { | ||
getUiThreadHandler().post(runnable); | ||
} | ||
private static final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); | ||
public static void start(Runnable runnable){ | ||
executorService.execute(runnable); | ||
} | ||
public static void execute(BackstageTask<?> backstageTask){ | ||
start(backstageTask); | ||
} | ||
} |
Oops, something went wrong.