├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── app-release.apk ├── build.gradle ├── jpg │ ├── first.png │ ├── ftp.png │ ├── p2p.png │ └── scan.png ├── libs │ ├── commons-beanutils.jar │ ├── commons-io-2.4.jar │ ├── gson-2.3.1.jar │ ├── okhttp-2.6.0.jar │ ├── okhttputils.jar │ ├── okio-1.6.0.jar │ └── zxing.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── cn │ │ └── edu │ │ └── sdust │ │ └── silence │ │ └── itransfer │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── config.properties │ │ └── users.properties │ ├── java │ │ └── cn │ │ │ └── edu │ │ │ └── sdust │ │ │ └── silence │ │ │ └── itransfer │ │ │ ├── activity │ │ │ ├── CaptureActivity.java │ │ │ ├── ChoseFileActivity.java │ │ │ ├── FtpManagerActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── ReceiveActivity.java │ │ │ ├── ReceiveFromComputerActivity.java │ │ │ ├── SendActivity.java │ │ │ └── SendToComputerActivity.java │ │ │ ├── application │ │ │ └── ITransferApp.java │ │ │ ├── filemanage │ │ │ └── FileManager.java │ │ │ ├── ftpserver │ │ │ └── ppareit │ │ │ │ └── ppareit │ │ │ │ ├── android │ │ │ │ └── DynamicMultiSelectListPreference.java │ │ │ │ └── swiftp │ │ │ │ ├── Defaults.java │ │ │ │ ├── FsService.java │ │ │ │ ├── FsSettings.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── MediaUpdater.java │ │ │ │ ├── NsdService.java │ │ │ │ ├── RequestStartStopReceiver.java │ │ │ │ ├── Util.java │ │ │ │ ├── WifiStateChangeReceiver.java │ │ │ │ ├── gui │ │ │ │ ├── FolderPickerDialogBuilder.java │ │ │ │ ├── FsNotification.java │ │ │ │ ├── FsPreferenceActivity.java │ │ │ │ └── FsWidgetProvider.java │ │ │ │ └── server │ │ │ │ ├── Account.java │ │ │ │ ├── CmdAPPE.java │ │ │ │ ├── CmdAbstractListing.java │ │ │ │ ├── CmdAbstractStore.java │ │ │ │ ├── CmdCDUP.java │ │ │ │ ├── CmdCWD.java │ │ │ │ ├── CmdDELE.java │ │ │ │ ├── CmdFEAT.java │ │ │ │ ├── CmdLIST.java │ │ │ │ ├── CmdMDTM.java │ │ │ │ ├── CmdMFMT.java │ │ │ │ ├── CmdMKD.java │ │ │ │ ├── CmdMap.java │ │ │ │ ├── CmdNLST.java │ │ │ │ ├── CmdNOOP.java │ │ │ │ ├── CmdOPTS.java │ │ │ │ ├── CmdPASS.java │ │ │ │ ├── CmdPASV.java │ │ │ │ ├── CmdPORT.java │ │ │ │ ├── CmdPWD.java │ │ │ │ ├── CmdQUIT.java │ │ │ │ ├── CmdREST.java │ │ │ │ ├── CmdRETR.java │ │ │ │ ├── CmdRMD.java │ │ │ │ ├── CmdRNFR.java │ │ │ │ ├── CmdRNTO.java │ │ │ │ ├── CmdSITE.java │ │ │ │ ├── CmdSIZE.java │ │ │ │ ├── CmdSTOR.java │ │ │ │ ├── CmdSYST.java │ │ │ │ ├── CmdTYPE.java │ │ │ │ ├── CmdTemplate.java │ │ │ │ ├── CmdUSER.java │ │ │ │ ├── FtpCmd.java │ │ │ │ ├── LocalDataSocket.java │ │ │ │ ├── SessionThread.java │ │ │ │ └── TcpListener.java │ │ │ ├── handler │ │ │ ├── ReceiveActivityHandler.java │ │ │ ├── ReceiveFromComputerActivityHandler.java │ │ │ ├── SendActivityHandler.java │ │ │ └── SendToComputerActivityHandler.java │ │ │ ├── qrcode │ │ │ ├── camera │ │ │ │ ├── AutoFocusManager.java │ │ │ │ ├── CameraConfigurationManager.java │ │ │ │ ├── CameraManager.java │ │ │ │ ├── PreviewCallback.java │ │ │ │ └── open │ │ │ │ │ └── OpenCameraInterface.java │ │ │ ├── decode │ │ │ │ ├── DecodeFormatManager.java │ │ │ │ ├── DecodeHandler.java │ │ │ │ └── DecodeThread.java │ │ │ └── utils │ │ │ │ ├── BeepManager.java │ │ │ │ ├── CaptureActivityHandler.java │ │ │ │ └── InactivityTimer.java │ │ │ ├── reciever │ │ │ └── WifiP2PBroadcastReceiver.java │ │ │ ├── thread │ │ │ ├── DataReceiveThread.java │ │ │ ├── DataReceiveThread2.java │ │ │ ├── DataServerThread2.java │ │ │ ├── DateServerThread.java │ │ │ ├── DownLoadFileThread.java │ │ │ ├── ListFileThread.java │ │ │ ├── ReceiveManager.java │ │ │ ├── ReceiveManager2.java │ │ │ ├── ScanThread.java │ │ │ ├── ServerManager.java │ │ │ ├── ServerManager2.java │ │ │ └── UploadFileThread.java │ │ │ ├── ui │ │ │ ├── TestRecyclerViewAdapter.java │ │ │ ├── actionbutton │ │ │ │ ├── ActionButtonActivity.java │ │ │ │ ├── AddFloatingActionButton.java │ │ │ │ ├── FloatingActionButton.java │ │ │ │ ├── FloatingActionsMenu.java │ │ │ │ └── TouchDelegateGroup.java │ │ │ ├── file │ │ │ │ ├── EventHandler.java │ │ │ │ ├── FileManager.java │ │ │ │ └── ThumbnailCreator.java │ │ │ ├── fragment │ │ │ │ ├── CarpaccioRecyclerViewFragment.java │ │ │ │ ├── ChoseFileRecyclerViewFragment.java │ │ │ │ ├── ChoseFileToComputerRecyclerViewFragment.java │ │ │ │ ├── RecyclerViewFragment.java │ │ │ │ ├── ScrollFragment.java │ │ │ │ └── WebViewFragment.java │ │ │ ├── loading │ │ │ │ └── RotateLoading.java │ │ │ ├── progress │ │ │ │ ├── NumberProgressBar.java │ │ │ │ └── OnProgressBarListener.java │ │ │ └── scan │ │ │ │ ├── been │ │ │ │ └── Info.java │ │ │ │ ├── custom │ │ │ │ ├── CircleView.java │ │ │ │ ├── CustomViewPager.java │ │ │ │ ├── RadarView.java │ │ │ │ └── RadarViewGroup.java │ │ │ │ └── utils │ │ │ │ ├── DepthPageTransformer.java │ │ │ │ ├── DisplayUtils.java │ │ │ │ ├── FixedSpeedScroller.java │ │ │ │ └── ZoomOutPageTransformer.java │ │ │ ├── util │ │ │ ├── ConfigUtil.java │ │ │ ├── Log.java │ │ │ └── ThumbnailCreator.java │ │ │ └── web │ │ │ ├── HttpUtils.java │ │ │ ├── ITransferClient.java │ │ │ ├── ITransferClientImpl.java │ │ │ ├── OKHttp.java │ │ │ ├── ResponseParser.java │ │ │ ├── ResponseParserImpl.java │ │ │ └── domain │ │ │ ├── FileLog.java │ │ │ └── Result.java │ └── res │ │ ├── drawable-hdpi │ │ ├── apk_icon.png │ │ ├── back_icon.png │ │ ├── btn_download_bg.9.png │ │ ├── choosefile_bg.png │ │ ├── circle.xml │ │ ├── download_bg_header.png │ │ ├── excel_icon.png │ │ ├── fab_bg_mini.png │ │ ├── fab_bg_normal.png │ │ ├── fab_label_background.xml │ │ ├── file_bg.png │ │ ├── file_icon.png │ │ ├── flying.png │ │ ├── ftp_header_bg.png │ │ ├── girl.png │ │ ├── history_bg.png │ │ ├── huojian_img.png │ │ ├── ic_fab_star.png │ │ ├── icon.png │ │ ├── icon_my.png │ │ ├── icon_net.png │ │ ├── icon_pc.png │ │ ├── icon_receice.png │ │ ├── icon_wlan.png │ │ ├── music_icon.png │ │ ├── notfound_icon.png │ │ ├── oee.png │ │ ├── pdf_icon.png │ │ ├── pic_icon.png │ │ ├── ppt_icon.png │ │ ├── receive_icon.png │ │ ├── scan_bg.png │ │ ├── send_icon.png │ │ ├── send_to_computer_bg.png │ │ ├── txt_icon.png │ │ ├── video_icon.png │ │ ├── viewpager_item_bg.xml │ │ ├── viewpager_item_hello_bg.xml │ │ ├── word_icon.png │ │ ├── xml_icon.png │ │ └── zip_icon.png │ │ ├── drawable-ldpi │ │ ├── notification.png │ │ ├── qr_code_bg.9.png │ │ ├── scan_line.png │ │ ├── shadow.png │ │ ├── widget_off.png │ │ └── widget_on.png │ │ ├── drawable │ │ └── bg_item_recyclerview.xml │ │ ├── layout │ │ ├── activity_action_button.xml │ │ ├── activity_capture.xml │ │ ├── activity_chose_file.xml │ │ ├── activity_ftp_manager.xml │ │ ├── activity_main.xml │ │ ├── activity_main2.xml │ │ ├── activity_receive_from_computer.xml │ │ ├── activity_scan.xml │ │ ├── activity_send_to_computer.xml │ │ ├── chose_to_computer_dialog.xml │ │ ├── dialog_download_file.xml │ │ ├── dialog_receive_file.xml │ │ ├── dialog_rename_file.xml │ │ ├── fragment_chosefile_recyclerview.xml │ │ ├── fragment_recyclerview.xml │ │ ├── fragment_recyclerview_carpaccio.xml │ │ ├── fragment_scroll.xml │ │ ├── fragment_webview.xml │ │ ├── header_logo_text.xml │ │ ├── list_item_card_big.xml │ │ ├── list_item_card_small.xml │ │ └── widget_layout.xml │ │ ├── menu │ │ └── menu.xml │ │ ├── mipmap-mdpi │ │ └── icon.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── launcher.png │ │ └── notification.png │ │ ├── raw │ │ └── beep.ogg │ │ ├── values-w820dp │ │ ├── attrs.xml │ │ ├── dimens.xml │ │ └── ids.xml │ │ ├── values │ │ ├── colors.xml │ │ ├── defaults.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ ├── preferences.xml │ │ └── widget_info.xml │ └── test │ └── java │ └── cn │ └── edu │ └── sdust │ └── silence │ └── itransfer │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | iTransfer -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | Android API 23 Platform 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | iTransfer 2 | ==== 3 | 这是一款可以在不同的Android设备之间,Android设备和PC之间传输文件的Android应用。
4 | 这是我的第一个开源项目,后续我会继续维护该项目。 5 | 6 | #主要技术 7 | - Android WiFi p2p 8 | - ftp 9 | - Material Design 10 | 11 | #[安装包(爱传1.0)](https://github.com/cloudups/iTransfer/blob/master/app/app-release.apk?raw=true) 12 | 13 | #程序截图 14 | 15 | - 主界面
16 | 主界面 17 | 18 | - Android扫描传输界面
19 | 主界面 20 | 21 | 22 | - Android开启ftp管理界面
23 | 主界面 24 | 25 | - 二维码扫描进行web传输界面
26 | 主界面 27 | 28 | 29 | 30 | 31 | #感谢 32 | - [@florent37](https://github.com/florent37/MaterialViewPager) 33 | - [@zxing](https://github.com/zxing/zxing) 34 | - [@nexes](https://github.com/nexes/Android-File-Manager) 35 | - [@ppareit](https://github.com/ppareit/swiftp) 36 | 37 | 38 | #反馈 39 | 如果你对该项目有什么想法或者建议,可以联系我
40 | feiqishi@foxmail.com 41 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/app-release.apk -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'me.tatarka.retrolambda' 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | applicationId "cn.edu.sdust.silence.itransfer" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | } 15 | 16 | useLibrary 'org.apache.http.legacy' 17 | packagingOptions { 18 | exclude 'META-INF/DEPENDENCIES.txt' 19 | exclude 'META-INF/LICENSE.txt' 20 | exclude 'META-INF/NOTICE.txt' 21 | exclude 'META-INF/NOTICE' 22 | exclude 'META-INF/LICENSE' 23 | exclude 'META-INF/DEPENDENCIES' 24 | exclude 'META-INF/notice.txt' 25 | exclude 'META-INF/license.txt' 26 | exclude 'META-INF/dependencies.txt' 27 | exclude 'META-INF/LGPL2.1' 28 | } 29 | 30 | buildTypes { 31 | release { 32 | minifyEnabled false 33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 34 | } 35 | } 36 | 37 | compileOptions { 38 | sourceCompatibility JavaVersion.VERSION_1_8 39 | targetCompatibility JavaVersion.VERSION_1_8 40 | } 41 | } 42 | buildscript { 43 | repositories { 44 | mavenCentral() 45 | } 46 | 47 | dependencies { 48 | classpath 'me.tatarka:gradle-retrolambda:3.2.1' 49 | } 50 | } 51 | dependencies { 52 | compile fileTree(dir: 'libs', include: ['*.jar']) 53 | testCompile 'junit:junit:4.12' 54 | compile 'com.android.support:appcompat-v7:23.0.0' 55 | compile 'com.android.support:design:23.0.0' 56 | compile 'com.android.support:support-annotations:23.0.0' 57 | compile('com.github.florent37:materialviewpager:1.1.3@aar') { 58 | transitive = true 59 | } 60 | compile('com.github.florent37:carpaccio:1.0.1@aar') { 61 | transitive = true 62 | } 63 | // compile 'org.apache.httpcomponents:httpclient:4.5.2' 64 | compile('org.apache.httpcomponents:httpmime:4.3.6') { 65 | exclude module: 'httpclient' 66 | } 67 | compile 'org.apache.httpcomponents:httpclient-android:4.3.5' 68 | } 69 | -------------------------------------------------------------------------------- /app/jpg/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/jpg/first.png -------------------------------------------------------------------------------- /app/jpg/ftp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/jpg/ftp.png -------------------------------------------------------------------------------- /app/jpg/p2p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/jpg/p2p.png -------------------------------------------------------------------------------- /app/jpg/scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/jpg/scan.png -------------------------------------------------------------------------------- /app/libs/commons-beanutils.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/libs/commons-beanutils.jar -------------------------------------------------------------------------------- /app/libs/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/libs/commons-io-2.4.jar -------------------------------------------------------------------------------- /app/libs/gson-2.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/libs/gson-2.3.1.jar -------------------------------------------------------------------------------- /app/libs/okhttp-2.6.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/libs/okhttp-2.6.0.jar -------------------------------------------------------------------------------- /app/libs/okhttputils.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/libs/okhttputils.jar -------------------------------------------------------------------------------- /app/libs/okio-1.6.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/libs/okio-1.6.0.jar -------------------------------------------------------------------------------- /app/libs/zxing.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/libs/zxing.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\MyWin8Soft\Android02\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/cn/edu/sdust/silence/itransfer/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/assets/config.properties: -------------------------------------------------------------------------------- 1 | address=http://119.29.153.56/itransfer/ -------------------------------------------------------------------------------- /app/src/main/assets/users.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/assets/users.properties -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/activity/ChoseFileActivity.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.activity; 2 | 3 | import android.content.DialogInterface; 4 | import android.os.Bundle; 5 | import android.support.v4.app.FragmentActivity; 6 | import android.support.v4.app.FragmentManager; 7 | import android.support.v4.app.FragmentTransaction; 8 | import android.support.v7.app.AlertDialog; 9 | import android.view.KeyEvent; 10 | import android.view.View; 11 | import cn.edu.sdust.silence.itransfer.R; 12 | import cn.edu.sdust.silence.itransfer.ui.fragment.ChoseFileRecyclerViewFragment; 13 | 14 | /** 15 | * 16 | * create by shifeiqi 17 | */ 18 | public class ChoseFileActivity extends FragmentActivity { 19 | 20 | private ChoseFileRecyclerViewFragment recyclerView; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_chose_file); 26 | initView(); 27 | } 28 | 29 | private void initView() { 30 | recyclerView = ChoseFileRecyclerViewFragment.newInstance(); 31 | recyclerView.setContext(this); 32 | setDefaultFragment(); 33 | findViewById(R.id.back).setOnClickListener(new View.OnClickListener() { 34 | @Override 35 | public void onClick(View v) { 36 | AlertDialog.Builder builder = new AlertDialog.Builder(ChoseFileActivity.this); 37 | builder.setTitle("提示"); 38 | builder.setMessage("确定要取消选择发送文件吗?"); 39 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 40 | @Override 41 | public void onClick(DialogInterface dialog, int which) { 42 | dialog.cancel(); 43 | finish(); 44 | } 45 | }); 46 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 47 | @Override 48 | public void onClick(DialogInterface dialog, int which) { 49 | dialog.cancel(); 50 | } 51 | }); 52 | builder.show(); 53 | } 54 | }); 55 | } 56 | 57 | private void setDefaultFragment() { 58 | FragmentManager fm = getSupportFragmentManager(); 59 | FragmentTransaction transaction = fm.beginTransaction(); 60 | transaction.replace(R.id.frame, recyclerView); 61 | transaction.commit(); 62 | } 63 | 64 | @Override 65 | public boolean onKeyDown(int keyCode, KeyEvent event) { 66 | 67 | boolean key = recyclerView.ismUseBackKey(); 68 | boolean isHomePath = recyclerView.isHomeDirectory(); 69 | if (keyCode == KeyEvent.KEYCODE_BACK && key && !isHomePath) { 70 | recyclerView.backPreviousDirectory(); 71 | return true; 72 | } else if (keyCode == KeyEvent.KEYCODE_BACK && key && isHomePath) { 73 | finish(); 74 | return false; 75 | } 76 | return false; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/application/ITransferApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011-2013 Pieter Pareit 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.application; 21 | 22 | import android.app.Application; 23 | import android.content.Context; 24 | import android.content.pm.PackageManager; 25 | import android.content.pm.PackageManager.NameNotFoundException; 26 | import android.os.Environment; 27 | import android.util.Log; 28 | 29 | public class ITransferApp extends Application { 30 | 31 | public static String username = "admin"; 32 | public static String password = "admin"; 33 | public static boolean allow_anonymous = true; 34 | public static String chrootDir = Environment.getExternalStorageDirectory().toString(); 35 | public static int portNum = 2121; 36 | public static boolean shouldTakeFullWakeLock = true; 37 | 38 | private static final String TAG = ITransferApp.class.getSimpleName(); 39 | private static Context sContext; 40 | 41 | @Override 42 | public void onCreate() { 43 | super.onCreate(); 44 | sContext = getApplicationContext(); 45 | } 46 | 47 | /** 48 | * @return the Context of this application 49 | */ 50 | public static Context getAppContext() { 51 | if (sContext == null) { 52 | Log.e(TAG, "Global context not set"); 53 | } 54 | return sContext; 55 | } 56 | 57 | /** 58 | * @return true if this is the free version 59 | */ 60 | public static boolean isFreeVersion() { 61 | try { 62 | Context context = getAppContext(); 63 | return context.getPackageName().contains("free"); 64 | } catch (Exception ignored) { 65 | } 66 | return false; 67 | } 68 | 69 | /** 70 | * Get the version from the manifest. 71 | * 72 | * @return The version as a String. 73 | */ 74 | public static String getVersion() { 75 | Context context = getAppContext(); 76 | String packageName = context.getPackageName(); 77 | try { 78 | PackageManager pm = context.getPackageManager(); 79 | return pm.getPackageInfo(packageName, 0).versionName; 80 | } catch (NameNotFoundException e) { 81 | Log.e(TAG, "Unable to find the name " + packageName + " in the package"); 82 | return null; 83 | } 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/android/DynamicMultiSelectListPreference.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.android; 2 | 3 | import android.content.Context; 4 | import android.preference.MultiSelectListPreference; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | 8 | 9 | /** 10 | * Created by ppareit on 31/12/15. 11 | */ 12 | public class DynamicMultiSelectListPreference extends MultiSelectListPreference { 13 | 14 | OnPopulateListener mPopulateListener; 15 | 16 | public DynamicMultiSelectListPreference(Context context, AttributeSet attrs) { 17 | super(context, attrs); 18 | } 19 | 20 | @Override 21 | protected View onCreateDialogView() { 22 | // Cat.d("Creating dialog view"); 23 | 24 | mPopulateListener.onPopulate(this); 25 | 26 | return super.onCreateDialogView(); 27 | } 28 | 29 | public void setOnPopulateListener(OnPopulateListener listener) { 30 | mPopulateListener = listener; 31 | } 32 | 33 | public interface OnPopulateListener { 34 | void onPopulate(DynamicMultiSelectListPreference preference); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/Defaults.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011-2013 Pieter Pareit 3 | Copyright 2009 David Revell 4 | 5 | This file is part of SwiFTP. 6 | 7 | SwiFTP is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | SwiFTP is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with SwiFTP. If not, see . 19 | */ 20 | 21 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp; 22 | 23 | public class Defaults { 24 | protected static int inputBufferSize = 256; 25 | public static int dataChunkSize = 65536; // do file I/O in 64k chunks 26 | public static final int tcpConnectionBacklog = 5; 27 | public static final int SO_TIMEOUT_MS = 30000; // socket timeout millis 28 | // FTP control sessions should start out in ASCII, according to the RFC. 29 | // However, many clients don't turn on UTF-8 even though they support it, 30 | // so we just turn it on by default. 31 | public static final String SESSION_ENCODING = "UTF-8"; 32 | 33 | public static final boolean do_mediascanner_notify = true; 34 | 35 | public static int getInputBufferSize() { 36 | return inputBufferSize; 37 | } 38 | 39 | public static void setInputBufferSize(int inputBufferSize) { 40 | Defaults.inputBufferSize = inputBufferSize; 41 | } 42 | 43 | public static int getDataChunkSize() { 44 | return dataChunkSize; 45 | } 46 | 47 | public static void setDataChunkSize(int dataChunkSize) { 48 | Defaults.dataChunkSize = dataChunkSize; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import cn.edu.sdust.silence.itransfer.R; 10 | 11 | public class MainActivity extends Activity { 12 | 13 | private Button button; 14 | private boolean started = false; 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | // button = (Button)this.findViewById(R.id.button); 20 | 21 | button.setOnClickListener(new View.OnClickListener() { 22 | @Override 23 | public void onClick(View v) { 24 | if(!started){ 25 | startServer(); 26 | started=true; 27 | }else { 28 | stopServer(); 29 | started = false; 30 | } 31 | } 32 | }); 33 | } 34 | 35 | private void startServer() { 36 | sendBroadcast(new Intent(FsService.ACTION_START_FTPSERVER)); 37 | } 38 | 39 | private void stopServer() { 40 | sendBroadcast(new Intent(FsService.ACTION_STOP_FTPSERVER)); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/RequestStartStopReceiver.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Environment; 7 | import android.util.Log; 8 | import android.view.Gravity; 9 | import android.widget.Toast; 10 | 11 | import cn.edu.sdust.silence.itransfer.R; 12 | import cn.edu.sdust.silence.itransfer.application.ITransferApp; 13 | 14 | public class RequestStartStopReceiver extends BroadcastReceiver { 15 | 16 | static final String TAG = RequestStartStopReceiver.class.getSimpleName(); 17 | 18 | @Override 19 | public void onReceive(Context context, Intent intent) { 20 | Log.v(TAG, "Received: " + intent.getAction()); 21 | 22 | // TODO: analog code as in ServerPreferenceActivity.start/stopServer(), refactor 23 | try { 24 | if (intent.getAction().equals(FsService.ACTION_START_FTPSERVER)) { 25 | Intent serverService = new Intent(context, FsService.class); 26 | if (!FsService.isRunning()) { 27 | warnIfNoExternalStorage(); 28 | context.startService(serverService); 29 | } 30 | } else if (intent.getAction().equals(FsService.ACTION_STOP_FTPSERVER)) { 31 | Intent serverService = new Intent(context, FsService.class); 32 | context.stopService(serverService); 33 | } 34 | } catch (Exception e) { 35 | Log.e(TAG, "Failed to start/stop on intent " + e.getMessage()); 36 | } 37 | } 38 | 39 | /** 40 | * Will check if the device contains external storage (sdcard) and display a warning 41 | * for the user if there is no external storage. Nothing more. 42 | */ 43 | private void warnIfNoExternalStorage() { 44 | String storageState = Environment.getExternalStorageState(); 45 | if (!storageState.equals(Environment.MEDIA_MOUNTED)) { 46 | Log.v(TAG, "Warning due to storage state " + storageState); 47 | Toast toast = Toast.makeText(ITransferApp.getAppContext(), 48 | R.string.storage_warning, Toast.LENGTH_LONG); 49 | toast.setGravity(Gravity.CENTER, 0, 0); 50 | toast.show(); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/Account.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | public class Account { 23 | private String mUserName = null; 24 | 25 | public String getUsername() { 26 | return mUserName; 27 | } 28 | 29 | public void setUsername(String username) { 30 | mUserName = username; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdAPPE.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | 23 | public class CmdAPPE extends CmdAbstractStore implements Runnable { 24 | protected String input; 25 | 26 | public CmdAPPE(SessionThread sessionThread, String input) { 27 | super(sessionThread, CmdAPPE.class.toString()); 28 | this.input = input; 29 | } 30 | 31 | @Override 32 | public void run() { 33 | doStorOrAppe(getParameter(input), true); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdCDUP.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | 27 | public class CmdCDUP extends FtpCmd implements Runnable { 28 | private static final String TAG = CmdCDUP.class.getSimpleName(); 29 | protected String input; 30 | 31 | public CmdCDUP(SessionThread sessionThread, String input) { 32 | super(sessionThread); 33 | } 34 | 35 | @Override 36 | public void run() { 37 | Log.d(TAG, "CDUP executing"); 38 | File newDir; 39 | String errString = null; 40 | mainBlock: { 41 | File workingDir = sessionThread.getWorkingDir(); 42 | newDir = workingDir.getParentFile(); 43 | if (newDir == null) { 44 | errString = "550 Current dir cannot find parent\r\n"; 45 | break mainBlock; 46 | } 47 | // Ensure the new path does not violate the chroot restriction 48 | if (violatesChroot(newDir)) { 49 | errString = "550 Invalid name or chroot violation\r\n"; 50 | break mainBlock; 51 | } 52 | 53 | try { 54 | newDir = newDir.getCanonicalFile(); 55 | if (!newDir.isDirectory()) { 56 | errString = "550 Can't CWD to invalid directory\r\n"; 57 | break mainBlock; 58 | } else if (newDir.canRead()) { 59 | sessionThread.setWorkingDir(newDir); 60 | } else { 61 | errString = "550 That path is inaccessible\r\n"; 62 | break mainBlock; 63 | } 64 | } catch (IOException e) { 65 | errString = "550 Invalid path\r\n"; 66 | break mainBlock; 67 | } 68 | } 69 | if (errString != null) { 70 | sessionThread.writeString(errString); 71 | Log.i(TAG, "CDUP error: " + errString); 72 | } else { 73 | sessionThread.writeString("200 CDUP successful\r\n"); 74 | Log.d(TAG, "CDUP success"); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdCWD.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | 27 | public class CmdCWD extends FtpCmd implements Runnable { 28 | private static final String TAG = CmdCWD.class.getSimpleName(); 29 | 30 | protected String input; 31 | 32 | public CmdCWD(SessionThread sessionThread, String input) { 33 | super(sessionThread); 34 | this.input = input; 35 | } 36 | 37 | @Override 38 | public void run() { 39 | Log.d(TAG, "CWD executing"); 40 | String param = getParameter(input); 41 | File newDir; 42 | String errString = null; 43 | mainblock: { 44 | newDir = inputPathToChrootedFile(sessionThread.getWorkingDir(), param); 45 | 46 | // Ensure the new path does not violate the chroot restriction 47 | if (violatesChroot(newDir)) { 48 | errString = "550 Invalid name or chroot violation\r\n"; 49 | sessionThread.writeString(errString); 50 | Log.i(TAG, errString); 51 | break mainblock; 52 | } 53 | 54 | try { 55 | newDir = newDir.getCanonicalFile(); 56 | Log.i(TAG, "New directory: " + newDir); 57 | if (!newDir.isDirectory()) { 58 | sessionThread.writeString("550 Can't CWD to invalid directory\r\n"); 59 | } else if (newDir.canRead()) { 60 | sessionThread.setWorkingDir(newDir); 61 | sessionThread.writeString("250 CWD successful\r\n"); 62 | } else { 63 | sessionThread.writeString("550 That path is inaccessible\r\n"); 64 | } 65 | } catch (IOException e) { 66 | sessionThread.writeString("550 Invalid path\r\n"); 67 | break mainblock; 68 | } 69 | } 70 | Log.d(TAG, "CWD complete"); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdDELE.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.io.File; 25 | 26 | import cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.MediaUpdater; 27 | 28 | 29 | public class CmdDELE extends FtpCmd implements Runnable { 30 | private static final String TAG = CmdDELE.class.getSimpleName(); 31 | 32 | protected String input; 33 | 34 | public CmdDELE(SessionThread sessionThread, String input) { 35 | super(sessionThread); 36 | this.input = input; 37 | } 38 | 39 | @Override 40 | public void run() { 41 | Log.d(TAG, "DELE executing"); 42 | String param = getParameter(input); 43 | File storeFile = inputPathToChrootedFile(sessionThread.getWorkingDir(), param); 44 | String errString = null; 45 | if (violatesChroot(storeFile)) { 46 | errString = "550 Invalid name or chroot violation\r\n"; 47 | } else if (storeFile.isDirectory()) { 48 | errString = "550 Can't DELE a directory\r\n"; 49 | } else if (!storeFile.delete()) { 50 | errString = "450 Error deleting file\r\n"; 51 | } 52 | 53 | if (errString != null) { 54 | sessionThread.writeString(errString); 55 | Log.i(TAG, "DELE failed: " + errString.trim()); 56 | } else { 57 | sessionThread.writeString("250 File successfully deleted\r\n"); 58 | MediaUpdater.notifyFileDeleted(storeFile.getPath()); 59 | } 60 | Log.d(TAG, "DELE finished"); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdFEAT.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | public class CmdFEAT extends FtpCmd implements Runnable { 25 | private static final String TAG = CmdFEAT.class.getSimpleName(); 26 | 27 | public CmdFEAT(SessionThread sessionThread, String input) { 28 | super(sessionThread); 29 | } 30 | 31 | @Override 32 | public void run() { 33 | Log.d(TAG, "run: Giving FEAT"); 34 | sessionThread.writeString("211-Features supported by FTP Server\r\n"); 35 | sessionThread.writeString(" UTF8\r\n"); 36 | sessionThread.writeString(" MDTM\r\n"); 37 | sessionThread.writeString(" MFMT\r\n"); 38 | sessionThread.writeString("211 End\r\n"); 39 | Log.d(TAG, "run: Gave FEAT"); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdMDTM.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Pieter Pareit 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.io.File; 25 | 26 | import cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.Util; 27 | 28 | 29 | /** 30 | * Implements File Modification Time 31 | */ 32 | public class CmdMDTM extends FtpCmd implements Runnable { 33 | private static final String TAG = CmdMDTM.class.getSimpleName(); 34 | 35 | private String mInput; 36 | 37 | public CmdMDTM(SessionThread sessionThread, String input) { 38 | super(sessionThread); 39 | mInput = input; 40 | } 41 | 42 | @Override 43 | public void run() { 44 | Log.d(TAG, "run: MDTM executing, input: " + mInput); 45 | String param = getParameter(mInput); 46 | File file = inputPathToChrootedFile(sessionThread.getWorkingDir(), param); 47 | 48 | if (file.exists()) { 49 | long lastModified = file.lastModified(); 50 | String response = "213 " + Util.getFtpDate(lastModified) + "\r\n"; 51 | sessionThread.writeString(response); 52 | } else { 53 | Log.w(TAG, "run: file does not exist"); 54 | sessionThread.writeString("550 file does not exist\r\n"); 55 | } 56 | 57 | Log.d(TAG, "run: MDTM completed"); 58 | } 59 | 60 | } 61 | 62 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdMKD.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.io.File; 25 | 26 | public class CmdMKD extends FtpCmd implements Runnable { 27 | private static final String TAG = CmdMKD.class.getSimpleName(); 28 | 29 | String input; 30 | 31 | public CmdMKD(SessionThread sessionThread, String input) { 32 | super(sessionThread); 33 | this.input = input; 34 | } 35 | 36 | @Override 37 | public void run() { 38 | Log.d(TAG, "MKD executing"); 39 | String param = getParameter(input); 40 | File toCreate; 41 | String errString = null; 42 | mainblock: { 43 | // If the param is an absolute path, use it as is. If it's a 44 | // relative path, prepend the current working directory. 45 | if (param.length() < 1) { 46 | errString = "550 Invalid name\r\n"; 47 | break mainblock; 48 | } 49 | toCreate = inputPathToChrootedFile(sessionThread.getWorkingDir(), param); 50 | if (violatesChroot(toCreate)) { 51 | errString = "550 Invalid name or chroot violation\r\n"; 52 | break mainblock; 53 | } 54 | if (toCreate.exists()) { 55 | errString = "550 Already exists\r\n"; 56 | break mainblock; 57 | } 58 | if (!toCreate.mkdir()) { 59 | errString = "550 Error making directory (permissions?)\r\n"; 60 | break mainblock; 61 | } 62 | } 63 | if (errString != null) { 64 | sessionThread.writeString(errString); 65 | Log.i(TAG, "MKD error: " + errString.trim()); 66 | } else { 67 | sessionThread.writeString("250 Directory created\r\n"); 68 | } 69 | Log.i(TAG, "MKD complete"); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | public class CmdMap { 23 | protected Class cmdClass; 24 | String name; 25 | 26 | 27 | public CmdMap(String name, Class cmdClass) { 28 | super(); 29 | this.name = name; 30 | this.cmdClass = cmdClass; 31 | } 32 | 33 | public Class getCommand() { 34 | return cmdClass; 35 | } 36 | 37 | public void setCommand(Class cmdClass) { 38 | this.cmdClass = cmdClass; 39 | } 40 | 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdNOOP.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | public class CmdNOOP extends FtpCmd implements Runnable { 23 | public static final String message = "TEMPLATE!!"; 24 | 25 | public CmdNOOP(SessionThread sessionThread, String input) { 26 | super(sessionThread); 27 | } 28 | 29 | @Override 30 | public void run() { 31 | sessionThread.writeString("200 NOOP ok\r\n"); 32 | // myLog.l(Log.INFO, "Executing NOOP, done"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdOPTS.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | public class CmdOPTS extends FtpCmd implements Runnable { 25 | private static final String TAG = CmdOPTS.class.getSimpleName(); 26 | 27 | public static final String message = "TEMPLATE!!"; 28 | private final String input; 29 | 30 | public CmdOPTS(SessionThread sessionThread, String input) { 31 | super(sessionThread); 32 | this.input = input; 33 | } 34 | 35 | @Override 36 | public void run() { 37 | String param = getParameter(input); 38 | String errString = null; 39 | 40 | mainBlock: { 41 | if (param == null) { 42 | errString = "550 Need argument to OPTS\r\n"; 43 | Log.w(TAG, "Couldn't understand empty OPTS command"); 44 | break mainBlock; 45 | } 46 | String[] splits = param.split(" "); 47 | if (splits.length != 2) { 48 | errString = "550 Malformed OPTS command\r\n"; 49 | Log.w(TAG, "Couldn't parse OPTS command"); 50 | break mainBlock; 51 | } 52 | String optName = splits[0].toUpperCase(); 53 | String optVal = splits[1].toUpperCase(); 54 | if (optName.equals("UTF8")) { 55 | // OK, whatever. Don't really know what to do here. We 56 | // always operate in UTF8 mode. 57 | if (optVal.equals("ON")) { 58 | Log.d(TAG, "Got OPTS UTF8 ON"); 59 | sessionThread.setEncoding("UTF-8"); 60 | } else { 61 | Log.i(TAG, "Ignoring OPTS UTF8 for something besides ON"); 62 | } 63 | break mainBlock; 64 | } else { 65 | Log.d(TAG, "Unrecognized OPTS option: " + optName); 66 | errString = "502 Unrecognized option\r\n"; 67 | break mainBlock; 68 | } 69 | } 70 | if (errString != null) { 71 | sessionThread.writeString(errString); 72 | } else { 73 | sessionThread.writeString("200 OPTS accepted\r\n"); 74 | Log.d(TAG, "Handled OPTS ok"); 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdPASS.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.FsSettings; 25 | import cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.Util; 26 | 27 | 28 | public class CmdPASS extends FtpCmd implements Runnable { 29 | private static final String TAG = CmdPASS.class.getSimpleName(); 30 | 31 | String input; 32 | 33 | public CmdPASS(SessionThread sessionThread, String input) { 34 | super(sessionThread); 35 | this.input = input; 36 | } 37 | 38 | @Override 39 | public void run() { 40 | Log.d(TAG, "Executing PASS"); 41 | String attemptPassword = getParameter(input, true); // silent 42 | // Always first USER command, then PASS command 43 | String attemptUsername = sessionThread.account.getUsername(); 44 | if (attemptUsername == null) { 45 | sessionThread.writeString("503 Must send USER first\r\n"); 46 | return; 47 | } 48 | String username = FsSettings.getUserName(); 49 | String password = FsSettings.getPassWord(); 50 | if (username == null || password == null) { 51 | Log.e(TAG, "Username or password misconfigured"); 52 | sessionThread.writeString("500 Internal error during authentication"); 53 | } else if (username.equals(attemptUsername) && password.equals(attemptPassword)) { 54 | sessionThread.writeString("230 Access granted\r\n"); 55 | Log.i(TAG, "User " + username + " password verified"); 56 | sessionThread.authAttempt(true); 57 | } else if (attemptUsername.equals("anonymous") && FsSettings.allowAnoymous()) { 58 | sessionThread.writeString("230 Guest login ok, read only access.\r\n"); 59 | Log.i(TAG, "Guest logged in with email: " + attemptPassword); 60 | } else { 61 | Log.i(TAG, "Failed authentication"); 62 | Util.sleepIgnoreInterupt(1000); // sleep to foil brute force attack 63 | sessionThread.writeString("530 Login incorrect.\r\n"); 64 | sessionThread.authAttempt(false); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdPASV.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.net.InetAddress; 25 | 26 | public class CmdPASV extends FtpCmd implements Runnable { 27 | private static final String TAG = CmdPASV.class.getSimpleName(); 28 | 29 | public CmdPASV(SessionThread sessionThread, String input) { 30 | super(sessionThread); 31 | } 32 | 33 | @Override 34 | public void run() { 35 | String cantOpen = "502 Couldn't open a port\r\n"; 36 | Log.d(TAG, "PASV running"); 37 | int port; 38 | if ((port = sessionThread.onPasv()) == 0) { 39 | // There was a problem opening a port 40 | Log.e(TAG, "Couldn't open a port for PASV"); 41 | sessionThread.writeString(cantOpen); 42 | return; 43 | } 44 | InetAddress addr = sessionThread.getDataSocketPasvIp(); 45 | if (addr == null) { 46 | Log.e(TAG, "PASV IP string invalid"); 47 | sessionThread.writeString(cantOpen); 48 | return; 49 | } 50 | Log.d(TAG, "PASV sending IP: " + addr.getHostAddress()); 51 | if (port < 1) { 52 | Log.e(TAG, "PASV port number invalid"); 53 | sessionThread.writeString(cantOpen); 54 | return; 55 | } 56 | StringBuilder response = new StringBuilder("227 Entering Passive Mode ("); 57 | // Output our IP address in the format xxx,xxx,xxx,xxx 58 | response.append(addr.getHostAddress().replace('.', ',')); 59 | response.append(","); 60 | // Output our port in the format p1,p2 where port=p1*256+p2 61 | response.append(port / 256); 62 | response.append(","); 63 | response.append(port % 256); 64 | response.append(").\r\n"); 65 | String responseString = response.toString(); 66 | sessionThread.writeString(responseString); 67 | Log.d(TAG, "PASV completed, sent: " + responseString); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdPWD.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.io.IOException; 25 | 26 | import cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.FsSettings; 27 | 28 | 29 | public class CmdPWD extends FtpCmd implements Runnable { 30 | private static final String TAG = CmdPWD.class.getSimpleName(); 31 | 32 | public CmdPWD(SessionThread sessionThread, String input) { 33 | super(sessionThread); 34 | } 35 | 36 | @Override 37 | public void run() { 38 | Log.d(TAG, "PWD executing"); 39 | // We assume that the chroot restriction has been applied, and that 40 | // therefore the current directory is located somewhere within the 41 | // chroot directory. Therefore, we can just slice of the chroot 42 | // part of the current directory path in order to get the 43 | // user-visible path (inside the chroot directory). 44 | try { 45 | String currentDir = sessionThread.getWorkingDir().getCanonicalPath(); 46 | currentDir = currentDir.substring(FsSettings.getChrootDir().getCanonicalPath() 47 | .length()); 48 | // The root directory requires special handling to restore its 49 | // leading slash 50 | if (currentDir.length() == 0) { 51 | currentDir = "/"; 52 | } 53 | sessionThread.writeString("257 \"" + currentDir + "\"\r\n"); 54 | } catch (IOException e) { 55 | // This shouldn't happen unless our input validation has failed 56 | Log.e(TAG, "PWD canonicalize"); 57 | sessionThread.closeSocket(); // should cause thread termination 58 | } 59 | Log.d(TAG, "PWD complete"); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdQUIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | public class CmdQUIT extends FtpCmd implements Runnable { 25 | private static final String TAG = CmdQUIT.class.getSimpleName(); 26 | 27 | public CmdQUIT(SessionThread sessionThread, String input) { 28 | super(sessionThread); 29 | } 30 | 31 | @Override 32 | public void run() { 33 | Log.d(TAG, "QUIT executing"); 34 | sessionThread.writeString("221 Goodbye\r\n"); 35 | sessionThread.closeSocket(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdREST.java: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SwiFTP. 3 | 4 | SwiFTP is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SwiFTP is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with SwiFTP. If not, see . 16 | */ 17 | 18 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 19 | 20 | import android.util.Log; 21 | 22 | public class CmdREST extends FtpCmd implements Runnable { 23 | private static final String TAG = CmdREST.class.getSimpleName(); 24 | 25 | protected String input; 26 | 27 | public CmdREST(SessionThread sessionThread, String input) { 28 | super(sessionThread); 29 | this.input = input; 30 | } 31 | 32 | @Override 33 | public void run() { 34 | String param = getParameter(input); 35 | long offset; 36 | try { 37 | offset = Long.parseLong(param); 38 | } catch (NumberFormatException e) { 39 | sessionThread.writeString("550 No valid restart position\r\n"); 40 | return; 41 | } 42 | Log.d(TAG, "run REST with offset " + offset); 43 | if (sessionThread.isBinaryMode()) { 44 | sessionThread.offset = offset; 45 | sessionThread.writeString("350 Restart position accepted (" + offset 46 | + ")\r\n"); 47 | } else { 48 | if (offset != 0) { 49 | sessionThread.writeString("550 Restart position > 0 not accepted" 50 | + " in ASCII mode\r\n"); 51 | } else { 52 | sessionThread.offset = offset; 53 | sessionThread.writeString("350 Restart position accepted (" + offset 54 | + ")\r\n"); 55 | } 56 | } 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdRNFR.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.io.File; 25 | 26 | public class CmdRNFR extends FtpCmd implements Runnable { 27 | private static final String TAG = CmdRNFR.class.getSimpleName(); 28 | 29 | protected String input; 30 | 31 | public CmdRNFR(SessionThread sessionThread, String input) { 32 | super(sessionThread); 33 | this.input = input; 34 | } 35 | 36 | @Override 37 | public void run() { 38 | Log.d(TAG, "Executing RNFR"); 39 | String param = getParameter(input); 40 | String errString = null; 41 | File file = null; 42 | mainblock: { 43 | file = inputPathToChrootedFile(sessionThread.getWorkingDir(), param); 44 | if (violatesChroot(file)) { 45 | errString = "550 Invalid name or chroot violation\r\n"; 46 | break mainblock; 47 | } 48 | if (!file.exists()) { 49 | errString = "450 Cannot rename nonexistent file\r\n"; 50 | } 51 | } 52 | if (errString != null) { 53 | sessionThread.writeString(errString); 54 | Log.d(TAG, "RNFR failed: " + errString.trim()); 55 | sessionThread.setRenameFrom(null); 56 | } else { 57 | sessionThread.writeString("350 Filename noted, now send RNTO\r\n"); 58 | sessionThread.setRenameFrom(file); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdSITE.java: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SwiFTP. 3 | 4 | SwiFTP is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SwiFTP is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with SwiFTP. If not, see . 16 | */ 17 | 18 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 19 | 20 | public class CmdSITE extends FtpCmd implements Runnable { 21 | 22 | public CmdSITE(SessionThread sessionThread, String input) { 23 | super(sessionThread); 24 | } 25 | 26 | @Override 27 | public void run() { 28 | sessionThread.writeString("250 SITE is a NOP\r\n"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdSIZE.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | 8 | public class CmdSIZE extends FtpCmd { 9 | private static final String TAG = CmdSIZE.class.getSimpleName(); 10 | 11 | protected String input; 12 | 13 | public CmdSIZE(SessionThread sessionThread, String input) { 14 | super(sessionThread); 15 | this.input = input; 16 | } 17 | 18 | @Override 19 | public void run() { 20 | Log.d(TAG, "SIZE executing"); 21 | String errString = null; 22 | String param = getParameter(input); 23 | long size = 0; 24 | mainblock: { 25 | File currentDir = sessionThread.getWorkingDir(); 26 | if (param.contains(File.separator)) { 27 | errString = "550 No directory traversal allowed in SIZE param\r\n"; 28 | break mainblock; 29 | } 30 | File target = new File(currentDir, param); 31 | // We should have caught any invalid location access before now, but 32 | // here we check again, just to be explicitly sure. 33 | if (violatesChroot(target)) { 34 | errString = "550 SIZE target violates chroot\r\n"; 35 | break mainblock; 36 | } 37 | if (!target.exists()) { 38 | errString = "550 Cannot get the SIZE of nonexistent object\r\n"; 39 | try { 40 | Log.i(TAG, "Failed getting size of: " + target.getCanonicalPath()); 41 | } catch (IOException e) { 42 | } 43 | break mainblock; 44 | } 45 | if (!target.isFile()) { 46 | errString = "550 Cannot get the size of a non-file\r\n"; 47 | break mainblock; 48 | } 49 | size = target.length(); 50 | } 51 | if (errString != null) { 52 | sessionThread.writeString(errString); 53 | } else { 54 | sessionThread.writeString("213 " + size + "\r\n"); 55 | } 56 | Log.d(TAG, "SIZE complete"); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdSTOR.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | public class CmdSTOR extends CmdAbstractStore implements Runnable { 23 | protected String input; 24 | 25 | public CmdSTOR(SessionThread sessionThread, String input) { 26 | super(sessionThread, CmdSTOR.class.toString()); 27 | this.input = input; 28 | } 29 | 30 | @Override 31 | public void run() { 32 | doStorOrAppe(getParameter(input), false); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdSYST.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | public class CmdSYST extends FtpCmd implements Runnable { 25 | private static final String TAG = CmdSYST.class.getSimpleName(); 26 | 27 | // This is considered a safe response to the SYST command, see 28 | // http://cr.yp.to/ftp/syst.html 29 | public static final String response = "215 UNIX Type: L8\r\n"; 30 | 31 | public CmdSYST(SessionThread sessionThread, String input) { 32 | super(sessionThread); 33 | } 34 | 35 | @Override 36 | public void run() { 37 | Log.d(TAG, "SYST executing"); 38 | sessionThread.writeString(response); 39 | Log.d(TAG, "SYST finished"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdTYPE.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | public class CmdTYPE extends FtpCmd implements Runnable { 25 | private static final String TAG = CmdTYPE.class.getSimpleName(); 26 | 27 | String input; 28 | 29 | public CmdTYPE(SessionThread sessionThread, String input) { 30 | super(sessionThread); 31 | this.input = input; 32 | } 33 | 34 | @Override 35 | public void run() { 36 | String output; 37 | Log.d(TAG, "TYPE executing"); 38 | String param = getParameter(input); 39 | if (param.equals("I") || param.equals("L 8")) { 40 | output = "200 Binary type set\r\n"; 41 | sessionThread.setBinaryMode(true); 42 | } else if (param.equals("A") || param.equals("A N")) { 43 | output = "200 ASCII type set\r\n"; 44 | sessionThread.setBinaryMode(false); 45 | } else { 46 | output = "503 Malformed TYPE command\r\n"; 47 | } 48 | sessionThread.writeString(output); 49 | Log.d(TAG, "TYPE complete"); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdTemplate.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | public class CmdTemplate extends FtpCmd implements Runnable { 25 | private static final String TAG = CmdTemplate.class.getSimpleName(); 26 | 27 | public static final String message = "TEMPLATE!!"; 28 | 29 | public CmdTemplate(SessionThread sessionThread, String input) { 30 | super(sessionThread); 31 | } 32 | 33 | @Override 34 | public void run() { 35 | sessionThread.writeString(message); 36 | Log.i(TAG, "Template log message"); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/CmdUSER.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | public class CmdUSER extends FtpCmd implements Runnable { 25 | private static final String TAG = CmdUSER.class.getSimpleName(); 26 | 27 | protected String input; 28 | 29 | public CmdUSER(SessionThread sessionThread, String input) { 30 | super(sessionThread); 31 | this.input = input; 32 | 33 | } 34 | 35 | @Override 36 | public void run() { 37 | Log.d(TAG, "USER executing"); 38 | String username = FtpCmd.getParameter(input); 39 | if (!username.matches("[A-Za-z0-9]+")) { 40 | sessionThread.writeString("530 Invalid username\r\n"); 41 | return; 42 | } 43 | sessionThread.writeString("331 Send password\r\n"); 44 | sessionThread.account.setUsername(username); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ftpserver/ppareit/ppareit/swiftp/server/TcpListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 David Revell 3 | 4 | This file is part of SwiFTP. 5 | 6 | SwiFTP is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | SwiFTP is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with SwiFTP. If not, see . 18 | */ 19 | 20 | package cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.server; 21 | 22 | import android.util.Log; 23 | 24 | import java.net.ServerSocket; 25 | import java.net.Socket; 26 | 27 | import cn.edu.sdust.silence.itransfer.ftpserver.ppareit.ppareit.swiftp.FsService; 28 | 29 | 30 | public class TcpListener extends Thread { 31 | private static final String TAG = TcpListener.class.getSimpleName(); 32 | 33 | ServerSocket listenSocket; 34 | FsService ftpServerService; 35 | 36 | public TcpListener(ServerSocket listenSocket, FsService ftpServerService) { 37 | this.listenSocket = listenSocket; 38 | this.ftpServerService = ftpServerService; 39 | } 40 | 41 | public void quit() { 42 | try { 43 | listenSocket.close(); // if the TcpListener thread is blocked on accept, 44 | // closing the socket will raise an exception 45 | } catch (Exception e) { 46 | Log.d(TAG, "Exception closing TcpListener listenSocket"); 47 | } 48 | } 49 | 50 | @Override 51 | public void run() { 52 | try { 53 | while (true) { 54 | Socket clientSocket = listenSocket.accept(); 55 | Log.i(TAG, "New connection, spawned thread"); 56 | SessionThread newSession = new SessionThread(clientSocket, 57 | new LocalDataSocket()); 58 | newSession.start(); 59 | ftpServerService.registerSessionThread(newSession); 60 | } 61 | } catch (Exception e) { 62 | Log.d(TAG, "Exception in TcpListener"); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/handler/ReceiveActivityHandler.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.handler; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | import cn.edu.sdust.silence.itransfer.activity.ReceiveActivity; 6 | 7 | 8 | /** 9 | * Created by feiqishi on 2016/5/8. 10 | */ 11 | public class ReceiveActivityHandler extends Handler { 12 | 13 | public static int TYPE_PROCESS; 14 | private ReceiveActivity activity; 15 | 16 | public ReceiveActivityHandler(ReceiveActivity activity) { 17 | this.activity = activity; 18 | } 19 | 20 | @Override 21 | public void handleMessage(Message msg) { 22 | if (msg.what == TYPE_PROCESS) { 23 | activity.setProcess(msg.arg1); 24 | } 25 | 26 | super.handleMessage(msg); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/handler/ReceiveFromComputerActivityHandler.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.handler; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | import java.util.List; 6 | import cn.edu.sdust.silence.itransfer.activity.ReceiveFromComputerActivity; 7 | import cn.edu.sdust.silence.itransfer.web.domain.FileLog; 8 | 9 | 10 | /** 11 | * Created by feiqishi on 2016/5/8. 12 | */ 13 | public class ReceiveFromComputerActivityHandler extends Handler { 14 | 15 | public static int TYPE_LIST_SUCCESS = 1; 16 | public static int TYPE_LIST_FAIL = 2; 17 | public static int TYPE_DOWNLOAD_SUCCESS = 3; 18 | public static int TYPE_DOWNLOAD_FAIL = 4; 19 | private ReceiveFromComputerActivity activity; 20 | 21 | public ReceiveFromComputerActivityHandler(ReceiveFromComputerActivity activity) { 22 | this.activity = activity; 23 | } 24 | 25 | @Override 26 | public void handleMessage(Message msg) { 27 | if (msg.what == TYPE_LIST_SUCCESS) { 28 | List files = (List) msg.obj; 29 | activity.listSuccess(files); 30 | } else if (msg.what == TYPE_LIST_FAIL) { 31 | activity.listFail(); 32 | } else if (msg.what == TYPE_DOWNLOAD_SUCCESS) { 33 | activity.downloadSuccess(); 34 | } else if (msg.what == TYPE_DOWNLOAD_FAIL) { 35 | activity.downloadFail(); 36 | } 37 | super.handleMessage(msg); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/handler/SendActivityHandler.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.handler; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | import cn.edu.sdust.silence.itransfer.activity.SendActivity; 7 | 8 | /** 9 | * Created by feiqishi on 2016/5/16. 10 | */ 11 | public class SendActivityHandler extends Handler { 12 | 13 | private SendActivity activity; 14 | 15 | public SendActivityHandler(SendActivity activity) { 16 | this.activity = activity; 17 | } 18 | 19 | @Override 20 | public void handleMessage(Message msg) { 21 | if(msg.what == SendActivity.PROGRESS){ 22 | activity.freshProgress(msg.arg1); 23 | } 24 | super.handleMessage(msg); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/handler/SendToComputerActivityHandler.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.handler; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | import java.util.List; 7 | 8 | import cn.edu.sdust.silence.itransfer.activity.SendToComputerActivity; 9 | import cn.edu.sdust.silence.itransfer.web.domain.FileLog; 10 | 11 | /** 12 | * Created by feiqishi on 2016/5/16. 13 | */ 14 | public class SendToComputerActivityHandler extends Handler { 15 | 16 | private SendToComputerActivity activity; 17 | 18 | public SendToComputerActivityHandler(SendToComputerActivity activity) { 19 | this.activity = activity; 20 | } 21 | 22 | @Override 23 | public void handleMessage(Message msg) { 24 | if (msg.what == SendToComputerActivity.TYPE_SUCCESS) { 25 | activity.uploadSuccess((List) msg.obj); 26 | } else if (msg.what == SendToComputerActivity.TYPE_FAIL) { 27 | activity.uploadFail(); 28 | }else if(msg.what == SendToComputerActivity.TYPE_SCAN){ 29 | activity.scanSuccess(msg.obj.toString()); 30 | } 31 | super.handleMessage(msg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/qrcode/camera/PreviewCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package cn.edu.sdust.silence.itransfer.qrcode.camera; 18 | 19 | import android.graphics.Point; 20 | import android.hardware.Camera; 21 | import android.os.Handler; 22 | import android.os.Message; 23 | import android.util.Log; 24 | 25 | public class PreviewCallback implements Camera.PreviewCallback { 26 | 27 | private static final String TAG = PreviewCallback.class.getSimpleName(); 28 | 29 | private final CameraConfigurationManager configManager; 30 | private Handler previewHandler; 31 | private int previewMessage; 32 | 33 | public PreviewCallback(CameraConfigurationManager configManager) { 34 | this.configManager = configManager; 35 | } 36 | 37 | public void setHandler(Handler previewHandler, int previewMessage) { 38 | this.previewHandler = previewHandler; 39 | this.previewMessage = previewMessage; 40 | } 41 | 42 | @Override 43 | public void onPreviewFrame(byte[] data, Camera camera) { 44 | Point cameraResolution = configManager.getCameraResolution(); 45 | Handler thePreviewHandler = previewHandler; 46 | if (cameraResolution != null && thePreviewHandler != null) { 47 | Message message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, data); 48 | message.sendToTarget(); 49 | previewHandler = null; 50 | } else { 51 | Log.d(TAG, "Got preview callback, but no handler or resolution available"); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/qrcode/camera/open/OpenCameraInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package cn.edu.sdust.silence.itransfer.qrcode.camera.open; 18 | 19 | import android.hardware.Camera; 20 | import android.util.Log; 21 | 22 | public class OpenCameraInterface { 23 | 24 | private static final String TAG = OpenCameraInterface.class.getName(); 25 | 26 | /** 27 | * Opens the requested camera with {@link Camera#open(int)}, if one exists. 28 | * 29 | * @param cameraId 30 | * camera ID of the camera to use. A negative value means 31 | * "no preference" 32 | * @return handle to {@link Camera} that was opened 33 | */ 34 | public static Camera open(int cameraId) { 35 | 36 | int numCameras = Camera.getNumberOfCameras(); 37 | if (numCameras == 0) { 38 | Log.w(TAG, "No cameras!"); 39 | return null; 40 | } 41 | 42 | boolean explicitRequest = cameraId >= 0; 43 | 44 | if (!explicitRequest) { 45 | // Select a camera if no explicit camera requested 46 | int index = 0; 47 | while (index < numCameras) { 48 | Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); 49 | Camera.getCameraInfo(index, cameraInfo); 50 | if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { 51 | break; 52 | } 53 | index++; 54 | } 55 | 56 | cameraId = index; 57 | } 58 | 59 | Camera camera; 60 | if (cameraId < numCameras) { 61 | Log.i(TAG, "Opening camera #" + cameraId); 62 | camera = Camera.open(cameraId); 63 | } else { 64 | if (explicitRequest) { 65 | Log.w(TAG, "Requested camera does not exist: " + cameraId); 66 | camera = null; 67 | } else { 68 | Log.i(TAG, "No camera facing back; returning camera #0"); 69 | camera = Camera.open(0); 70 | } 71 | } 72 | 73 | return camera; 74 | } 75 | 76 | /** 77 | * Opens a rear-facing camera with {@link Camera#open(int)}, if one exists, 78 | * or opens camera 0. 79 | * 80 | * @return handle to {@link Camera} that was opened 81 | */ 82 | public static Camera open() { 83 | return open(-1); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/qrcode/decode/DecodeFormatManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package cn.edu.sdust.silence.itransfer.qrcode.decode; 18 | 19 | import com.google.zxing.BarcodeFormat; 20 | 21 | import java.util.Collection; 22 | import java.util.EnumSet; 23 | import java.util.Set; 24 | 25 | public class DecodeFormatManager { 26 | 27 | // 1D解码 28 | private static final Set PRODUCT_FORMATS; 29 | private static final Set INDUSTRIAL_FORMATS; 30 | private static final Set ONE_D_FORMATS; 31 | 32 | // 二维码解码 33 | private static final Set QR_CODE_FORMATS; 34 | 35 | static { 36 | PRODUCT_FORMATS = EnumSet.of(BarcodeFormat.UPC_A, BarcodeFormat.UPC_E, BarcodeFormat.EAN_13, BarcodeFormat.EAN_8, BarcodeFormat.RSS_14, BarcodeFormat.RSS_EXPANDED); 37 | INDUSTRIAL_FORMATS = EnumSet.of(BarcodeFormat.CODE_39, BarcodeFormat.CODE_93, BarcodeFormat.CODE_128, BarcodeFormat.ITF, BarcodeFormat.CODABAR); 38 | ONE_D_FORMATS = EnumSet.copyOf(PRODUCT_FORMATS); 39 | ONE_D_FORMATS.addAll(INDUSTRIAL_FORMATS); 40 | 41 | QR_CODE_FORMATS = EnumSet.of(BarcodeFormat.QR_CODE); 42 | } 43 | 44 | public static Collection getQrCodeFormats() { 45 | return QR_CODE_FORMATS; 46 | } 47 | 48 | public static Collection getBarCodeFormats() { 49 | return ONE_D_FORMATS; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/qrcode/decode/DecodeThread.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package cn.edu.sdust.silence.itransfer.qrcode.decode; 18 | 19 | import android.os.Handler; 20 | import android.os.Looper; 21 | 22 | import com.google.zxing.BarcodeFormat; 23 | import com.google.zxing.DecodeHintType; 24 | 25 | import java.util.ArrayList; 26 | import java.util.Collection; 27 | import java.util.EnumMap; 28 | import java.util.EnumSet; 29 | import java.util.Map; 30 | import java.util.concurrent.CountDownLatch; 31 | 32 | import cn.edu.sdust.silence.itransfer.activity.CaptureActivity; 33 | 34 | /** 35 | * This thread does all the heavy lifting of decoding the images. 36 | * 37 | * @author dswitkin@google.com (Daniel Switkin) 38 | */ 39 | public class DecodeThread extends Thread { 40 | 41 | public static final String BARCODE_BITMAP = "barcode_bitmap"; 42 | 43 | public static final int BARCODE_MODE = 0X100; 44 | public static final int QRCODE_MODE = 0X200; 45 | public static final int ALL_MODE = 0X300; 46 | 47 | private final CaptureActivity activity; 48 | private final Map hints; 49 | private Handler handler; 50 | private final CountDownLatch handlerInitLatch; 51 | 52 | public DecodeThread(CaptureActivity activity, int decodeMode) { 53 | 54 | this.activity = activity; 55 | handlerInitLatch = new CountDownLatch(1); 56 | 57 | hints = new EnumMap(DecodeHintType.class); 58 | 59 | Collection decodeFormats = new ArrayList(); 60 | decodeFormats.addAll(EnumSet.of(BarcodeFormat.AZTEC)); 61 | decodeFormats.addAll(EnumSet.of(BarcodeFormat.PDF_417)); 62 | 63 | switch (decodeMode) { 64 | case BARCODE_MODE: 65 | decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats()); 66 | break; 67 | 68 | case QRCODE_MODE: 69 | decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats()); 70 | break; 71 | 72 | case ALL_MODE: 73 | decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats()); 74 | decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats()); 75 | break; 76 | 77 | default: 78 | break; 79 | } 80 | 81 | hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); 82 | } 83 | 84 | public Handler getHandler() { 85 | try { 86 | handlerInitLatch.await(); 87 | } catch (InterruptedException ie) { 88 | // continue? 89 | } 90 | return handler; 91 | } 92 | 93 | @Override 94 | public void run() { 95 | Looper.prepare(); 96 | handler = new DecodeHandler(activity, hints); 97 | handlerInitLatch.countDown(); 98 | Looper.loop(); 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/reciever/WifiP2PBroadcastReceiver.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.reciever; 2 | 3 | import android.app.Activity; 4 | import android.content.BroadcastReceiver; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.net.NetworkInfo; 8 | import android.net.wifi.p2p.WifiP2pManager; 9 | import android.util.Log; 10 | 11 | public class WifiP2PBroadcastReceiver extends BroadcastReceiver { 12 | 13 | private WifiP2pManager mManager; 14 | private WifiP2pManager.Channel mChannel; 15 | private Activity mActivity; 16 | private WifiP2pManager.PeerListListener mPeerListListener; 17 | private WifiP2pManager.ConnectionInfoListener mInfoListener; 18 | 19 | public WifiP2PBroadcastReceiver(WifiP2pManager manager, WifiP2pManager.Channel channel, Activity activity, 20 | WifiP2pManager.PeerListListener peerListListener, 21 | WifiP2pManager.ConnectionInfoListener infoListener 22 | ) { 23 | this.mManager = manager; 24 | this.mChannel = channel; 25 | this.mPeerListListener = peerListListener; 26 | this.mActivity = activity; 27 | this.mInfoListener = infoListener; 28 | } 29 | 30 | 31 | @Override 32 | public void onReceive(Context context, Intent intent) { 33 | 34 | String action = intent.getAction(); 35 | 36 | /*check if the wifi is enable*/ 37 | if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) { 38 | int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1); 39 | } 40 | 41 | /*get the list*/ 42 | else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) { 43 | 44 | mManager.requestPeers(mChannel, mPeerListListener); 45 | } else if (WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION.equals(action)) { 46 | int State = intent.getIntExtra(WifiP2pManager.EXTRA_DISCOVERY_STATE, -1); 47 | // if (State == WifiP2pManager.WIFI_P2P_DISCOVERY_STARTED) 48 | // Toast.makeText(mActivity, "搜索开启", Toast.LENGTH_SHORT).show(); 49 | // else if (State == WifiP2pManager.WIFI_P2P_DISCOVERY_STOPPED) 50 | // Toast.makeText(mActivity, "搜索已关闭", Toast.LENGTH_SHORT).show(); 51 | 52 | } 53 | /*Respond to new connection or disconnections*/ 54 | else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) { 55 | 56 | if (mManager == null) { 57 | return; 58 | } 59 | 60 | NetworkInfo networkInfo = (NetworkInfo) intent 61 | .getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO); 62 | 63 | if (networkInfo.isConnected()) { 64 | Log.i("xyz", "已连接"); 65 | mManager.requestConnectionInfo(mChannel, mInfoListener); 66 | } else { 67 | Log.i("xyz", "断开连接"); 68 | return; 69 | } 70 | } 71 | 72 | /*Respond to this device's wifi state changing*/ 73 | else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) { 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/thread/DownLoadFileThread.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.thread; 2 | 3 | import android.os.Message; 4 | 5 | import org.apache.http.client.ClientProtocolException; 6 | 7 | import java.io.IOException; 8 | 9 | import cn.edu.sdust.silence.itransfer.handler.ReceiveFromComputerActivityHandler; 10 | import cn.edu.sdust.silence.itransfer.web.ITransferClient; 11 | import cn.edu.sdust.silence.itransfer.web.ITransferClientImpl; 12 | import cn.edu.sdust.silence.itransfer.web.ResponseParser; 13 | 14 | /** 15 | * Created by shifeiqi on 16-6-8. 16 | */ 17 | public class DownLoadFileThread extends Thread { 18 | 19 | private String fileName, storeName, path,fid; 20 | private ITransferClient client = null; 21 | private ReceiveFromComputerActivityHandler handler; 22 | 23 | public DownLoadFileThread(String fid,String fileName, String storeName, String path, ReceiveFromComputerActivityHandler handler) { 24 | this.fid = fid; 25 | this.fileName = fileName; 26 | this.storeName = storeName; 27 | this.path = path; 28 | this.handler = handler; 29 | client = new ITransferClientImpl(); 30 | } 31 | 32 | @Override 33 | public void run() { 34 | try { 35 | downloadFiles(fid,fileName, storeName, path); 36 | } catch (IOException e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | /** 42 | * @throws IOException 43 | * @throws ClientProtocolException 44 | */ 45 | public void downloadFiles(String fid,String fileName, String storeName, String path) throws IOException { 46 | // 提供要下载文件的filename,storeName和下载文件保存路径即可 47 | ResponseParser parser = client.downloadFile(fid,fileName, storeName, path); 48 | ResponseParser.ResultType type = parser.parse(); 49 | if (type == ResponseParser.ResultType.Error) { 50 | Message msg = new Message(); 51 | msg.what = ReceiveFromComputerActivityHandler.TYPE_DOWNLOAD_FAIL; 52 | handler.sendMessage(msg); 53 | // System.out.println("错误信息:" + parser.getResult().getMessage()); 54 | } else if (type == ResponseParser.ResultType.Download) { 55 | Message msg = new Message(); 56 | msg.what = ReceiveFromComputerActivityHandler.TYPE_DOWNLOAD_SUCCESS; 57 | handler.sendMessage(msg); 58 | System.out.println("文件下载成功!!!"); 59 | } 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/thread/ListFileThread.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.thread; 2 | 3 | import android.os.Message; 4 | 5 | import org.apache.http.client.ClientProtocolException; 6 | 7 | import java.io.IOException; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | import cn.edu.sdust.silence.itransfer.handler.ReceiveFromComputerActivityHandler; 13 | import cn.edu.sdust.silence.itransfer.web.ITransferClient; 14 | import cn.edu.sdust.silence.itransfer.web.ITransferClientImpl; 15 | import cn.edu.sdust.silence.itransfer.web.ResponseParser; 16 | import cn.edu.sdust.silence.itransfer.web.domain.FileLog; 17 | 18 | /** 19 | * Created by shifeiqi on 16-6-8. 20 | */ 21 | public class ListFileThread extends Thread { 22 | 23 | private String fileCode, password; 24 | private ITransferClient client = null; 25 | private ReceiveFromComputerActivityHandler handler; 26 | private List files; 27 | 28 | public ListFileThread(String fileCode, String password, ReceiveFromComputerActivityHandler handler) { 29 | this.fileCode = fileCode; 30 | this.password = password; 31 | this.handler = handler; 32 | client = new ITransferClientImpl(); 33 | } 34 | 35 | @Override 36 | public void run() { 37 | try { 38 | listFiles(fileCode, password); 39 | } catch (IOException e) { 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | /** 45 | * @throws IOException 46 | */ 47 | public void listFiles(String fileCode, String password) throws IOException { 48 | // 提供文件id和临时密码即可查看文件 49 | Map params = new HashMap(); 50 | params.put("filecode", fileCode); 51 | params.put("password", password); 52 | ResponseParser parser = client.sendForm("query", params); 53 | ResponseParser.ResultType type = parser.parse(); 54 | if (type == ResponseParser.ResultType.Error) { 55 | System.out.println("错误信息:" + parser.getResult().getMessage()); 56 | Message message = new Message(); 57 | message.what = ReceiveFromComputerActivityHandler.TYPE_LIST_FAIL; 58 | handler.sendMessage(message); 59 | } else if (type == ResponseParser.ResultType.FileLog) { 60 | files = parser.getResult().getFileLogs(); 61 | Message message = new Message(); 62 | message.what = ReceiveFromComputerActivityHandler.TYPE_LIST_SUCCESS; 63 | message.obj = files; 64 | handler.sendMessage(message); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/thread/ReceiveManager.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.thread; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | import android.os.Message; 6 | import android.util.Log; 7 | 8 | import java.io.IOException; 9 | import java.net.ServerSocket; 10 | import java.net.Socket; 11 | 12 | import cn.edu.sdust.silence.itransfer.handler.ReceiveActivityHandler; 13 | 14 | /** 15 | * 接收文件子线程管理线程 16 | * 17 | * Created by feiqishi on 2016/5/15. 18 | */ 19 | public class ReceiveManager extends Thread { 20 | 21 | private ReceiveActivityHandler receiveActivityHandler; 22 | private ServerSocket serverSocket; 23 | private Socket socket = null; 24 | private Handler managerHandler; 25 | 26 | public static int FINISH = 1; 27 | public static int RETRY = 2; 28 | 29 | public ReceiveManager(ReceiveActivityHandler handler) { 30 | this.receiveActivityHandler = handler; 31 | try { 32 | serverSocket = new ServerSocket(8888); 33 | } catch (IOException e) { 34 | e.printStackTrace(); 35 | } 36 | } 37 | 38 | @Override 39 | public void run() { 40 | Looper.prepare(); 41 | managerHandler = new Handler() { 42 | 43 | public void handleMessage(Message msg) { 44 | 45 | if(msg.what == RETRY){ 46 | try { 47 | socket = serverSocket.accept(); 48 | } catch (IOException e) { 49 | e.printStackTrace(); 50 | } 51 | DataReceiveThread2 thread = new DataReceiveThread2(managerHandler, receiveActivityHandler, socket); 52 | thread.start(); 53 | } 54 | if (msg.what == FINISH) { 55 | try { 56 | serverSocket.close(); 57 | } catch (IOException e) { 58 | e.printStackTrace(); 59 | } 60 | managerHandler.getLooper().quit(); 61 | Thread.interrupted(); 62 | } 63 | } 64 | }; 65 | 66 | try { 67 | socket = serverSocket.accept(); 68 | DataReceiveThread2 thread = new DataReceiveThread2(managerHandler, receiveActivityHandler, socket); 69 | thread.start(); 70 | } catch (IOException e) { 71 | e.printStackTrace(); 72 | } 73 | 74 | Looper.loop(); 75 | } 76 | 77 | @Override 78 | public void destroy() { 79 | try { 80 | serverSocket.close(); 81 | } catch (IOException e) { 82 | e.printStackTrace(); 83 | } 84 | super.destroy(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/thread/ReceiveManager2.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.thread; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | import android.os.Message; 6 | import android.util.Log; 7 | 8 | import cn.edu.sdust.silence.itransfer.handler.ReceiveActivityHandler; 9 | 10 | /** 11 | * 接收文件子线程管理线程 12 | * 13 | * Created by feiqishi on 2016/5/15. 14 | */ 15 | public class ReceiveManager2 extends Thread { 16 | 17 | public static int RETRY = 01; 18 | public static int FINISH = 02; 19 | private Handler managerHandler; 20 | private ReceiveActivityHandler receiveActivityHandler; 21 | private String ip; 22 | 23 | public ReceiveManager2(ReceiveActivityHandler receiveActivityHandler, String ip) { 24 | this.receiveActivityHandler = receiveActivityHandler; 25 | this.ip = ip; 26 | } 27 | 28 | @Override 29 | public void run() { 30 | 31 | Looper.prepare(); 32 | managerHandler = new Handler() { 33 | 34 | public void handleMessage(Message msg) { 35 | 36 | if (msg.what == RETRY) { 37 | DataReceiveThread thread = new DataReceiveThread(managerHandler, receiveActivityHandler, ip); 38 | thread.start(); 39 | } else if (msg.what == FINISH) { 40 | managerHandler.getLooper().quit(); 41 | Thread.interrupted(); 42 | } 43 | } 44 | }; 45 | 46 | DataReceiveThread thread = new DataReceiveThread(managerHandler, receiveActivityHandler, ip); 47 | thread.start(); 48 | Looper.loop(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/thread/ScanThread.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.thread; 2 | 3 | import android.os.Message; 4 | 5 | import org.apache.http.client.ClientProtocolException; 6 | 7 | import java.io.IOException; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | import cn.edu.sdust.silence.itransfer.qrcode.utils.CaptureActivityHandler; 12 | import cn.edu.sdust.silence.itransfer.web.ITransferClient; 13 | import cn.edu.sdust.silence.itransfer.web.ITransferClientImpl; 14 | import cn.edu.sdust.silence.itransfer.web.ResponseParser; 15 | 16 | /** 17 | * Created by shifeiqi on 16-6-8. 18 | */ 19 | public class ScanThread extends Thread { 20 | 21 | 22 | private ITransferClient client = null; 23 | private String fileCode, password, fileName; 24 | private CaptureActivityHandler handler; 25 | 26 | public ScanThread(String fileCode, String password, String fileName, CaptureActivityHandler handler) { 27 | this.fileCode = fileCode; 28 | this.password = password; 29 | this.fileName = fileName; 30 | this.handler = handler; 31 | client = new ITransferClientImpl(); 32 | } 33 | 34 | @Override 35 | public void run() { 36 | try { 37 | scan(fileCode, password, fileName); 38 | } catch (IOException e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | 43 | /** 44 | * 扫描二维码 45 | * 46 | * @throws IOException 47 | * @throws ClientProtocolException 48 | */ 49 | public void scan(String fileCode, String password, String fileName) throws IOException { 50 | // 提供文件id和临时密码即可查看文件 51 | Map params = new HashMap(); 52 | //手机本身有的 53 | params.put("filecode", fileCode); 54 | params.put("password", password); 55 | 56 | //二维码扫描得到的 57 | params.put("filename", fileName); 58 | 59 | ResponseParser parser = client.sendForm("scan", params); 60 | System.out.println(parser.getObj()); 61 | 62 | Message msg = new Message(); 63 | msg.what = CaptureActivityHandler.SCAN_FINISH; 64 | msg.obj = parser.getObj(); 65 | handler.sendMessage(msg); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/thread/ServerManager.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.thread; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | import android.os.Message; 6 | import android.util.Log; 7 | 8 | import java.io.IOException; 9 | import java.net.ServerSocket; 10 | import java.net.Socket; 11 | 12 | import cn.edu.sdust.silence.itransfer.handler.SendActivityHandler; 13 | 14 | /** 15 | * 发送文件子线程管理线程 16 | * 17 | * Created by feiqishi on 2016/5/15. 18 | */ 19 | public class ServerManager extends Thread { 20 | 21 | private String filePath; 22 | private ServerSocket serverSocket; 23 | private Socket socket; 24 | private int PORT = 8888; 25 | 26 | public static int RETRY = 1; 27 | public static int FINISH = 2; 28 | 29 | private Handler managerHandler; 30 | private SendActivityHandler sendActivityHandler; 31 | 32 | public ServerManager(SendActivityHandler sendActivityHandler, String filePath) { 33 | this.sendActivityHandler = sendActivityHandler; 34 | this.filePath = filePath; 35 | 36 | try { 37 | serverSocket = new ServerSocket(PORT); 38 | } catch (IOException e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | 43 | @Override 44 | public void run() { 45 | 46 | 47 | Looper.prepare(); 48 | managerHandler = new Handler() { 49 | 50 | public void handleMessage(Message msg) { 51 | 52 | if (msg.what == RETRY) { 53 | try { 54 | socket = serverSocket.accept(); 55 | DateServerThread thread = new DateServerThread(sendActivityHandler, managerHandler, filePath, socket); 56 | thread.start(); 57 | } catch (IOException e) { 58 | e.printStackTrace(); 59 | } 60 | } 61 | if (msg.what == FINISH) { 62 | try { 63 | serverSocket.close(); 64 | } catch (IOException e) { 65 | e.printStackTrace(); 66 | } 67 | managerHandler.getLooper().quit(); 68 | Thread.interrupted(); 69 | } 70 | } 71 | }; 72 | 73 | try { 74 | socket = serverSocket.accept(); 75 | DateServerThread thread = new DateServerThread(sendActivityHandler, managerHandler, filePath, socket); 76 | thread.start(); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | 81 | Looper.loop(); 82 | } 83 | 84 | @Override 85 | public void destroy() { 86 | try { 87 | serverSocket.close(); 88 | } catch (IOException e) { 89 | e.printStackTrace(); 90 | } 91 | super.destroy(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/thread/ServerManager2.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.thread; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | import android.os.Message; 6 | import android.util.Log; 7 | 8 | import cn.edu.sdust.silence.itransfer.handler.SendActivityHandler; 9 | 10 | /** 11 | * 发送文件子线程管理线程 12 | * 13 | * Created by feiqishi on 2016/5/15. 14 | */ 15 | public class ServerManager2 extends Thread { 16 | 17 | private String ip; 18 | private String filePath; 19 | private Handler managerHandler; 20 | private SendActivityHandler sendActivityHandler; 21 | 22 | public static int RETRY = 1; 23 | public static int FINISH = 2; 24 | 25 | public ServerManager2(SendActivityHandler sendActivityHandler, String ip, String filePath) { 26 | this.sendActivityHandler = sendActivityHandler; 27 | this.ip = ip; 28 | this.filePath = filePath; 29 | } 30 | 31 | @Override 32 | public void run() { 33 | Looper.prepare(); 34 | managerHandler = new Handler() { 35 | @Override 36 | public void handleMessage(Message msg) { 37 | if (msg.what == RETRY) { 38 | DataServerThread2 server = new DataServerThread2(sendActivityHandler,managerHandler, ip, filePath); 39 | server.start(); 40 | } else if (msg.what == FINISH) { 41 | managerHandler.getLooper().quit(); 42 | Thread.interrupted(); 43 | } 44 | } 45 | }; 46 | DataServerThread2 server = new DataServerThread2(sendActivityHandler,managerHandler, ip, filePath); 47 | server.start(); 48 | Looper.loop(); 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/thread/UploadFileThread.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.thread; 2 | 3 | import android.os.Message; 4 | 5 | import org.apache.http.client.ClientProtocolException; 6 | 7 | import java.io.File; 8 | import java.io.IOException; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | import cn.edu.sdust.silence.itransfer.activity.SendToComputerActivity; 14 | import cn.edu.sdust.silence.itransfer.handler.SendToComputerActivityHandler; 15 | import cn.edu.sdust.silence.itransfer.web.ITransferClient; 16 | import cn.edu.sdust.silence.itransfer.web.ITransferClientImpl; 17 | import cn.edu.sdust.silence.itransfer.web.ResponseParser; 18 | import cn.edu.sdust.silence.itransfer.web.domain.FileLog; 19 | 20 | /** 21 | * Created by shifeiqi on 16-6-8. 22 | * 23 | */ 24 | public class UploadFileThread extends Thread { 25 | 26 | 27 | private String password; 28 | private List files; 29 | private ITransferClient client = null; 30 | private SendToComputerActivityHandler handler; 31 | private List fileLogs; 32 | 33 | public UploadFileThread(String password, List files, SendToComputerActivityHandler handler) { 34 | this.password = password; 35 | this.files = files; 36 | this.handler = handler; 37 | client = new ITransferClientImpl(); 38 | } 39 | 40 | @Override 41 | public void run() { 42 | 43 | try { 44 | uploadFiles(password, files); 45 | } catch (IOException e) { 46 | e.printStackTrace(); 47 | } 48 | } 49 | 50 | /** 51 | * @throws IOException 52 | * @throws ClientProtocolException 53 | */ 54 | public List uploadFiles(String password, List files) throws ClientProtocolException, IOException { 55 | Map params = new HashMap(); 56 | params.put("password", password);// 临时验证密码 57 | 58 | ResponseParser parser = client.sendFileForm("upload", files, params); 59 | ResponseParser.ResultType type = parser.parse(); 60 | if (type == ResponseParser.ResultType.Error) { 61 | System.out.println("错误信息:" + parser.getResult().getMessage()); 62 | Message msg = new Message(); 63 | msg.what = SendToComputerActivity.TYPE_FAIL; 64 | handler.sendMessage(msg); 65 | } else if (type == ResponseParser.ResultType.FileLog) { 66 | System.out.println("已上传的文件列表:" + parser.getResult().getFileLogs()); 67 | for (FileLog fileLog : parser.getResult().getFileLogs()) { 68 | System.out.println(fileLog); 69 | } 70 | fileLogs = parser.getResult().getFileLogs(); 71 | 72 | Message msg = new Message(); 73 | msg.what = SendToComputerActivity.TYPE_SUCCESS; 74 | msg.obj = fileLogs; 75 | handler.sendMessage(msg); 76 | return fileLogs; 77 | } 78 | return null; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/actionbutton/ActionButtonActivity.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.actionbutton; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | import cn.edu.sdust.silence.itransfer.R; 7 | 8 | 9 | public class ActionButtonActivity extends Activity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_action_button); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/actionbutton/AddFloatingActionButton.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.actionbutton; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.Paint.Style; 8 | import android.graphics.drawable.Drawable; 9 | import android.graphics.drawable.ShapeDrawable; 10 | import android.graphics.drawable.shapes.Shape; 11 | import android.support.annotation.ColorRes; 12 | import android.support.annotation.DrawableRes; 13 | import android.util.AttributeSet; 14 | 15 | import cn.edu.sdust.silence.itransfer.R; 16 | 17 | 18 | public class AddFloatingActionButton extends FloatingActionButton { 19 | int mPlusColor; 20 | 21 | public AddFloatingActionButton(Context context) { 22 | this(context, null); 23 | } 24 | 25 | public AddFloatingActionButton(Context context, AttributeSet attrs) { 26 | super(context, attrs); 27 | } 28 | 29 | public AddFloatingActionButton(Context context, AttributeSet attrs, int defStyle) { 30 | super(context, attrs, defStyle); 31 | } 32 | 33 | @Override 34 | void init(Context context, AttributeSet attributeSet) { 35 | TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.AddFloatingActionButton, 0, 0); 36 | mPlusColor = attr.getColor(R.styleable.AddFloatingActionButton_fab_plusIconColor, getColor(android.R.color.white)); 37 | attr.recycle(); 38 | 39 | super.init(context, attributeSet); 40 | } 41 | 42 | /** 43 | * @return the current Color of plus icon. 44 | */ 45 | public int getPlusColor() { 46 | return mPlusColor; 47 | } 48 | 49 | public void setPlusColorResId(@ColorRes int plusColor) { 50 | setPlusColor(getColor(plusColor)); 51 | } 52 | 53 | public void setPlusColor(int color) { 54 | if (mPlusColor != color) { 55 | mPlusColor = color; 56 | updateBackground(); 57 | } 58 | } 59 | 60 | @Override 61 | public void setIcon(@DrawableRes int icon) { 62 | throw new UnsupportedOperationException("Use FloatingActionButton if you want to use custom icon"); 63 | } 64 | 65 | @Override 66 | Drawable getIconDrawable() { 67 | final float iconSize = getDimension(R.dimen.fab_icon_size); 68 | final float iconHalfSize = iconSize / 2f; 69 | 70 | final float plusSize = getDimension(R.dimen.fab_plus_icon_size); 71 | final float plusHalfStroke = getDimension(R.dimen.fab_plus_icon_stroke) / 2f; 72 | final float plusOffset = (iconSize - plusSize) / 2f; 73 | 74 | final Shape shape = new Shape() { 75 | @Override 76 | public void draw(Canvas canvas, Paint paint) { 77 | canvas.drawRect(plusOffset, iconHalfSize - plusHalfStroke, iconSize - plusOffset, iconHalfSize + plusHalfStroke, paint); 78 | canvas.drawRect(iconHalfSize - plusHalfStroke, plusOffset, iconHalfSize + plusHalfStroke, iconSize - plusOffset, paint); 79 | } 80 | }; 81 | 82 | ShapeDrawable drawable = new ShapeDrawable(shape); 83 | 84 | final Paint paint = drawable.getPaint(); 85 | paint.setColor(mPlusColor); 86 | paint.setStyle(Style.FILL); 87 | paint.setAntiAlias(true); 88 | 89 | return drawable; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/actionbutton/TouchDelegateGroup.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.actionbutton; 2 | 3 | import android.graphics.Rect; 4 | import android.support.annotation.NonNull; 5 | import android.view.MotionEvent; 6 | import android.view.TouchDelegate; 7 | import android.view.View; 8 | 9 | import java.util.ArrayList; 10 | 11 | public class TouchDelegateGroup extends TouchDelegate { 12 | private static final Rect USELESS_HACKY_RECT = new Rect(); 13 | private final ArrayList mTouchDelegates = new ArrayList(); 14 | private TouchDelegate mCurrentTouchDelegate; 15 | private boolean mEnabled; 16 | 17 | public TouchDelegateGroup(View uselessHackyView) { 18 | super(USELESS_HACKY_RECT, uselessHackyView); 19 | } 20 | 21 | public void addTouchDelegate(@NonNull TouchDelegate touchDelegate) { 22 | mTouchDelegates.add(touchDelegate); 23 | } 24 | 25 | public void removeTouchDelegate(TouchDelegate touchDelegate) { 26 | mTouchDelegates.remove(touchDelegate); 27 | if (mCurrentTouchDelegate == touchDelegate) { 28 | mCurrentTouchDelegate = null; 29 | } 30 | } 31 | 32 | public void clearTouchDelegates() { 33 | mTouchDelegates.clear(); 34 | mCurrentTouchDelegate = null; 35 | } 36 | 37 | @Override 38 | public boolean onTouchEvent(@NonNull MotionEvent event) { 39 | if (!mEnabled) return false; 40 | 41 | TouchDelegate delegate = null; 42 | 43 | switch (event.getAction()) { 44 | case MotionEvent.ACTION_DOWN: 45 | for (int i = 0; i < mTouchDelegates.size(); i++) { 46 | TouchDelegate touchDelegate = mTouchDelegates.get(i); 47 | if (touchDelegate.onTouchEvent(event)) { 48 | mCurrentTouchDelegate = touchDelegate; 49 | return true; 50 | } 51 | } 52 | break; 53 | 54 | case MotionEvent.ACTION_MOVE: 55 | delegate = mCurrentTouchDelegate; 56 | break; 57 | 58 | case MotionEvent.ACTION_CANCEL: 59 | case MotionEvent.ACTION_UP: 60 | delegate = mCurrentTouchDelegate; 61 | mCurrentTouchDelegate = null; 62 | break; 63 | } 64 | 65 | return delegate != null && delegate.onTouchEvent(event); 66 | } 67 | 68 | public void setEnabled(boolean enabled) { 69 | mEnabled = enabled; 70 | } 71 | } -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/fragment/CarpaccioRecyclerViewFragment.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Toast; 10 | 11 | import com.github.florent37.carpaccio.Carpaccio; 12 | import com.github.florent37.carpaccio.controllers.adapter.OnItemClickListener; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | import cn.edu.sdust.silence.itransfer.R; 18 | 19 | 20 | /** 21 | * Created by florentchampigny on 24/04/15. 22 | */ 23 | public class CarpaccioRecyclerViewFragment extends Fragment { 24 | 25 | private static int ITEM_COUNT = 0; 26 | private List mContentItems = new ArrayList<>(); 27 | Carpaccio carpaccio; 28 | 29 | public static CarpaccioRecyclerViewFragment newInstance() { 30 | return new CarpaccioRecyclerViewFragment(); 31 | } 32 | 33 | @Override 34 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 35 | return inflater.inflate(R.layout.fragment_recyclerview_carpaccio, container, false); 36 | } 37 | 38 | @Override 39 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 40 | super.onViewCreated(view, savedInstanceState); 41 | carpaccio = (Carpaccio) view.findViewById(R.id.carpaccio); 42 | 43 | for (int i = 0; i < ITEM_COUNT; ++i) 44 | mContentItems.add(new Object()); 45 | 46 | carpaccio.mapList("card",mContentItems); 47 | carpaccio.onItemClick("card", new OnItemClickListener() { 48 | @Override 49 | public void onItemClick(Object o, int i, View view) { 50 | Toast.makeText(getActivity(),"position :"+i,Toast.LENGTH_SHORT).show(); 51 | } 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/fragment/ScrollFragment.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.github.florent37.materialviewpager.MaterialViewPagerHelper; 11 | import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; 12 | 13 | import cn.edu.sdust.silence.itransfer.R; 14 | 15 | 16 | /** 17 | * Created by florentchampigny on 24/04/15. 18 | */ 19 | public class ScrollFragment extends Fragment { 20 | 21 | private ObservableScrollView mScrollView; 22 | 23 | public static ScrollFragment newInstance() { 24 | return new ScrollFragment(); 25 | } 26 | 27 | @Override 28 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 29 | return inflater.inflate(R.layout.fragment_scroll, container, false); 30 | } 31 | 32 | @Override 33 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 34 | super.onViewCreated(view, savedInstanceState); 35 | mScrollView = (ObservableScrollView) view.findViewById(R.id.scrollView); 36 | 37 | MaterialViewPagerHelper.registerScrollView(getActivity(), mScrollView, null); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/fragment/WebViewFragment.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.webkit.WebView; 10 | import android.webkit.WebViewClient; 11 | 12 | import com.github.florent37.materialviewpager.MaterialViewPagerHelper; 13 | import com.github.ksoichiro.android.observablescrollview.ObservableWebView; 14 | 15 | import cn.edu.sdust.silence.itransfer.R; 16 | 17 | 18 | /** 19 | * Created by florentchampigny on 24/04/15. 20 | */ 21 | public class WebViewFragment extends Fragment { 22 | 23 | private ObservableWebView mWebView; 24 | 25 | public static WebViewFragment newInstance() { 26 | return new WebViewFragment(); 27 | } 28 | 29 | @Override 30 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 31 | return inflater.inflate(R.layout.fragment_webview, container, false); 32 | } 33 | 34 | @Override 35 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 36 | super.onViewCreated(view, savedInstanceState); 37 | mWebView = (ObservableWebView) view.findViewById(R.id.webView); 38 | 39 | //must be called before loadUrl() 40 | MaterialViewPagerHelper.preLoadInjectHeader(mWebView); 41 | 42 | //have to inject header when WebView page loaded 43 | mWebView.setWebViewClient(new WebViewClient() { 44 | @Override 45 | public void onPageFinished(WebView view, String url) { 46 | MaterialViewPagerHelper.injectHeader(mWebView, true); 47 | } 48 | 49 | @Override 50 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 51 | view.loadUrl(url); 52 | return true; 53 | } 54 | }); 55 | 56 | mWebView.loadUrl("http://mobile.francetvinfo.fr/"); 57 | 58 | MaterialViewPagerHelper.registerWebView(getActivity(), mWebView, null); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/progress/OnProgressBarListener.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.progress; 2 | 3 | /** 4 | * Created by lelexxx on 15-4-23. 5 | */ 6 | public interface OnProgressBarListener { 7 | 8 | void onProgressChange(int current, int max); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/scan/been/Info.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.scan.been; 2 | 3 | public class Info { 4 | private int portraitId;//头像id 5 | private String name;//名字 6 | private String age;//年龄 7 | private boolean sex;//false为男,true为女 8 | private float distance;//距离 9 | 10 | public int getPortraitId() { 11 | return portraitId; 12 | } 13 | 14 | public void setPortraitId(int portraitId) { 15 | this.portraitId = portraitId; 16 | } 17 | 18 | public String getAge() { 19 | return age; 20 | } 21 | 22 | public void setAge(String age) { 23 | this.age = age; 24 | } 25 | 26 | public float getDistance() { 27 | return distance; 28 | } 29 | 30 | public void setDistance(float distance) { 31 | this.distance = distance; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean getSex() { 43 | return sex; 44 | } 45 | 46 | public void setSex(boolean sex) { 47 | this.sex = sex; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/scan/custom/CustomViewPager.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.scan.custom; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | 8 | public class CustomViewPager extends ViewPager { 9 | private long downTime; 10 | private float LastX; 11 | private float mSpeed; 12 | 13 | public CustomViewPager(Context context) { 14 | super(context); 15 | } 16 | 17 | public CustomViewPager(Context context, AttributeSet attrs) { 18 | super(context, attrs); 19 | } 20 | 21 | @Override 22 | public boolean dispatchTouchEvent(MotionEvent ev) { 23 | float x = ev.getX(); 24 | switch (ev.getAction()) { 25 | case MotionEvent.ACTION_DOWN: 26 | downTime = System.currentTimeMillis(); 27 | LastX = x; 28 | break; 29 | case MotionEvent.ACTION_MOVE: 30 | x = ev.getX(); 31 | break; 32 | case MotionEvent.ACTION_UP: 33 | //计算得到手指从按下到离开的滑动速度 34 | mSpeed = (x - LastX) * 1000 / (System.currentTimeMillis() - downTime); 35 | break; 36 | } 37 | return super.dispatchTouchEvent(ev); 38 | } 39 | 40 | public float getSpeed() { 41 | return mSpeed; 42 | } 43 | 44 | public void setSpeed(float mSpeed) { 45 | this.mSpeed = mSpeed; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/scan/utils/DepthPageTransformer.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.scan.utils; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.support.v4.view.ViewPager; 5 | import android.view.View; 6 | 7 | 8 | 9 | public class DepthPageTransformer implements ViewPager.PageTransformer { 10 | private static float MIN_SCALE = 0.75f; 11 | 12 | @SuppressLint("NewApi") 13 | @Override 14 | public void transformPage(View view, float position) { 15 | int pageWidth = view.getWidth(); 16 | if (position < -1) { // [-Infinity,-1) 17 | // This page is way off-screen to the left. 18 | //view.setAlpha(0); 19 | } else if (position <= 0) { // [-1,0] 20 | // Use the default slide transition when 21 | // moving to the left page 22 | view.setAlpha(1); 23 | view.setTranslationX(0); 24 | view.setScaleX(1); 25 | view.setScaleY(1); 26 | } else if (position <= 1) { // (0,1] 27 | // Fade the page out. 28 | view.setAlpha(1 - position); 29 | // Counteract the default slide transition 30 | view.setTranslationX(pageWidth * -position); 31 | // Scale the page down (between MIN_SCALE and 1) 32 | float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) 33 | * (1 - Math.abs(position)); 34 | view.setScaleX(scaleFactor); 35 | view.setScaleY(scaleFactor); 36 | } else { // (1,+Infinity] 37 | // This page is way off-screen to the right. 38 | //view.setAlpha(0); 39 | 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/scan/utils/DisplayUtils.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.scan.utils; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.util.DisplayMetrics; 6 | 7 | public class DisplayUtils { 8 | /** 9 | * 将px值转换为dp值 10 | */ 11 | public static int px2dp(Context context, float pxValue) { 12 | final float scale = context.getResources().getDisplayMetrics().density; 13 | return (int) (pxValue / scale + 0.5f); 14 | } 15 | 16 | /** 17 | * 将dp值转换为px值 18 | */ 19 | public static int dp2px(Context context, float dpValue) { 20 | final float scale = context.getResources().getDisplayMetrics().density; 21 | return (int) (dpValue * scale + 0.5f); 22 | } 23 | 24 | /** 25 | * 将px值转换为sp值 26 | */ 27 | public static int px2sp(Context context, float pxValue) { 28 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; 29 | return (int) (pxValue / fontScale + 0.5f); 30 | } 31 | 32 | /** 33 | * 将sp值转换为px值 34 | */ 35 | public static int sp2px(Context context, float spValue) { 36 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; 37 | return (int) (spValue * fontScale + 0.5f); 38 | } 39 | 40 | /** 41 | * 获取屏幕宽度 42 | */ 43 | public static int getScreenWidthPixels(Activity context) { 44 | DisplayMetrics metric = new DisplayMetrics(); 45 | context.getWindowManager().getDefaultDisplay().getMetrics(metric); 46 | return metric.widthPixels; 47 | } 48 | 49 | /** 50 | * 获取屏幕高度 51 | */ 52 | public static int getScreenHeightPixels(Activity context) { 53 | DisplayMetrics metric = new DisplayMetrics(); 54 | context.getWindowManager().getDefaultDisplay().getMetrics(metric); 55 | return metric.heightPixels; 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/scan/utils/FixedSpeedScroller.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.scan.utils; 2 | 3 | import android.content.Context; 4 | import android.view.animation.AccelerateInterpolator; 5 | import android.widget.Scroller; 6 | 7 | 8 | public class FixedSpeedScroller extends Scroller { 9 | private int mDuration = 1000; 10 | 11 | public FixedSpeedScroller(Context context, AccelerateInterpolator accelerateInterpolator) { 12 | super(context,accelerateInterpolator); 13 | } 14 | 15 | @Override 16 | public void startScroll(int startX, int startY, int dx, int dy) { 17 | super.startScroll(startX, startY, dx, dy,mDuration); 18 | } 19 | 20 | @Override 21 | public void startScroll(int startX, int startY, int dx, int dy, int duration) { 22 | super.startScroll(startX, startY, dx, dy, mDuration); 23 | } 24 | public void setmDuration(int time) { 25 | mDuration = time; 26 | } 27 | 28 | public int getmDuration() { 29 | return mDuration; 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/ui/scan/utils/ZoomOutPageTransformer.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.ui.scan.utils; 2 | 3 | import android.support.v4.view.ViewPager; 4 | import android.view.View; 5 | 6 | public class ZoomOutPageTransformer implements ViewPager.PageTransformer { 7 | private static final float MIN_SCALE = 0.70f; 8 | private static final float MIN_ALPHA = 0.5f; 9 | 10 | public void transformPage(View view, float position) { 11 | int pageWidth = view.getWidth(); 12 | int pageHeight = view.getHeight(); 13 | if (position < -1) { // [-Infinity,-1) 14 | // This page is way off-screen to the left. 15 | view.setAlpha(MIN_ALPHA); 16 | view.setScaleX(MIN_SCALE); 17 | view.setScaleY(MIN_SCALE); 18 | } else if (position <= 1) { // [-1,1] 19 | // Modify the default slide transition to shrink the page as well 20 | float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); 21 | float vertMargin = pageHeight * (1 - scaleFactor) / 2; 22 | float horzMargin = pageWidth * (1 - scaleFactor) / 2; 23 | if (position < 0) { 24 | view.setTranslationX(horzMargin - vertMargin / 2); 25 | view.setScaleX(1 + 0.3f * position); 26 | view.setScaleY(1 + 0.3f * position); 27 | } else { 28 | view.setTranslationX(-horzMargin + vertMargin / 2); 29 | 30 | view.setScaleX(1 - 0.3f * position); 31 | view.setScaleY(1 - 0.3f * position); 32 | } 33 | 34 | // Scale the page down (between MIN_SCALE and 1) 35 | 36 | // Fade the page relative to its size. 37 | view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA)); 38 | 39 | } else { // (1,+Infinity] 40 | // This page is way off-screen to the right. 41 | view.setScaleX(MIN_SCALE); 42 | view.setScaleY(MIN_SCALE); 43 | view.setAlpha(MIN_ALPHA); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/util/ConfigUtil.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.util; 2 | 3 | public class ConfigUtil { 4 | 5 | public static String getProperty(String key) { 6 | return "http://119.29.153.56/itransfer/"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/util/Log.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.util; 2 | 3 | /** 4 | * Created by feiqishi on 2016/5/16. 5 | */ 6 | public class Log { 7 | private static String TAG = "xyz"; 8 | 9 | public static void log(String log) { 10 | android.util.Log.i(TAG, log); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/util/ThumbnailCreator.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.util; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | import android.os.Handler; 6 | import android.os.Message; 7 | 8 | import java.io.File; 9 | import java.lang.ref.SoftReference; 10 | import java.util.ArrayList; 11 | import java.util.HashMap; 12 | 13 | public class ThumbnailCreator extends Thread { 14 | private int mWidth; 15 | private int mHeight; 16 | private SoftReference mThumb; 17 | private static HashMap mCacheMap = null; 18 | private ArrayList mFiles; 19 | private String mDir; 20 | private Handler mHandler; 21 | private boolean mStop = false; 22 | 23 | public ThumbnailCreator(int width, int height) { 24 | mHeight = height; 25 | mWidth = width; 26 | 27 | if(mCacheMap == null) 28 | mCacheMap = new HashMap(); 29 | } 30 | 31 | public Bitmap isBitmapCached(String name) { 32 | return mCacheMap.get(name); 33 | } 34 | 35 | public void setCancelThumbnails(boolean stop) { 36 | mStop = stop; 37 | } 38 | 39 | public void createNewThumbnail(ArrayList files, String dir, Handler handler) { 40 | this.mFiles = files; 41 | this.mDir = dir; 42 | this.mHandler = handler; 43 | } 44 | 45 | @Override 46 | public void run() { 47 | int len = mFiles.size(); 48 | 49 | for (int i = 0; i < len; i++) { 50 | if (mStop) { 51 | mStop = false; 52 | mFiles = null; 53 | return; 54 | } 55 | final File file = new File(mDir + "/" + mFiles.get(i)); 56 | 57 | if (isImageFile(file.getName())) { 58 | long len_kb = file.length() / 1024; 59 | 60 | BitmapFactory.Options options = new BitmapFactory.Options(); 61 | options.outWidth = mWidth; 62 | options.outHeight = mHeight; 63 | 64 | if (len_kb > 1000 && len_kb < 5000) { 65 | options.inSampleSize = 32; 66 | options.inPurgeable = true; 67 | mThumb = new SoftReference(BitmapFactory.decodeFile(file.getPath(), options)); 68 | 69 | } else if (len_kb >= 5000) { 70 | options.inSampleSize = 32; 71 | options.inPurgeable = true; 72 | mThumb = new SoftReference(BitmapFactory.decodeFile(file.getPath(), options)); 73 | 74 | } else if (len_kb <= 1000) { 75 | options.inPurgeable = true; 76 | mThumb = new SoftReference(Bitmap.createScaledBitmap( 77 | BitmapFactory.decodeFile(file.getPath()), 78 | mWidth, 79 | mHeight, 80 | false)); 81 | } 82 | 83 | mCacheMap.put(file.getPath(), mThumb.get()); 84 | 85 | mHandler.post(new Runnable() { 86 | @Override 87 | public void run() { 88 | Message msg = mHandler.obtainMessage(); 89 | msg.obj = (Bitmap)mThumb.get(); 90 | msg.sendToTarget(); 91 | } 92 | }); 93 | } 94 | } 95 | } 96 | 97 | private boolean isImageFile(String file) { 98 | String ext = file.substring(file.lastIndexOf(".") + 1); 99 | 100 | if (ext.equalsIgnoreCase("png") || ext.equalsIgnoreCase("jpg") || 101 | ext.equalsIgnoreCase("jpeg")|| ext.equalsIgnoreCase("gif") || 102 | ext.equalsIgnoreCase("tiff")|| ext.equalsIgnoreCase("tif")) 103 | return true; 104 | 105 | return false; 106 | } 107 | } -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/web/HttpUtils.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.web; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.lang.reflect.InvocationTargetException; 7 | import java.math.BigInteger; 8 | import java.security.MessageDigest; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | import org.apache.commons.beanutils.BeanUtils; 12 | 13 | public class HttpUtils { 14 | 15 | // 计算文件MD5码 16 | public static String getFileMD5(File file) { 17 | if (!file.isFile()) { 18 | return null; 19 | } 20 | MessageDigest digest = null; 21 | FileInputStream in = null; 22 | byte buffer[] = new byte[1024]; 23 | int len; 24 | try { 25 | digest = MessageDigest.getInstance("MD5"); 26 | in = new FileInputStream(file); 27 | while ((len = in.read(buffer, 0, 1024)) != -1) { 28 | digest.update(buffer, 0, len); 29 | } 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | return null; 33 | } finally { 34 | if (in != null) { 35 | try { 36 | in.close(); 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | } 40 | in = null; 41 | } 42 | } 43 | BigInteger bigInt = new BigInteger(1, digest.digest()); 44 | return bigInt.toString(16); 45 | } 46 | 47 | // 计算文件夹所有文件的MD5码 48 | public Map getDirMD5(File file, boolean listChild) { 49 | if (!file.isDirectory()) { 50 | return null; 51 | } 52 | // 53 | Map map = new HashMap(); 54 | String md5; 55 | File files[] = file.listFiles(); 56 | for (int i = 0; i < files.length; i++) { 57 | File f = files[i]; 58 | if (f.isDirectory() && listChild) { 59 | map.putAll(getDirMD5(f, listChild)); 60 | } else { 61 | md5 = getFileMD5(f); 62 | if (md5 != null) { 63 | map.put(f.getPath(), md5); 64 | } 65 | } 66 | } 67 | return map; 68 | } 69 | 70 | public static Map bean2Map(Object bean) { 71 | 72 | try { 73 | Map map = BeanUtils.describe(bean); 74 | return map; 75 | } catch (Exception e) { 76 | e.printStackTrace(); 77 | throw new RuntimeException(e); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/web/ITransferClient.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.web; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.apache.http.client.ClientProtocolException; 9 | 10 | public interface ITransferClient { 11 | 12 | /** 13 | * 发送普通表单 14 | * 15 | * @param 16 | * @param 17 | * @return 18 | * @throws ClientProtocolException 19 | * @throws IOException 20 | */ 21 | public abstract ResponseParser sendForm(String operation, 22 | Map params) throws ClientProtocolException, 23 | IOException; 24 | 25 | /** 26 | * 发送文件上传表单 27 | * 28 | * @param 29 | * @param 30 | * @param 31 | * @return 32 | * @throws ClientProtocolException 33 | * @throws IOException 34 | */ 35 | public abstract ResponseParser sendFileForm(String operation, List files, 36 | Map params) throws ClientProtocolException, 37 | IOException; 38 | 39 | /** 40 | * 下载文件 41 | * 42 | * @param 43 | * @param 44 | * @return 45 | * @throws ClientProtocolException 46 | * @throws IOException 47 | */ 48 | public abstract ResponseParser downloadFile(String fid,String filename, String storeName, String savePath) 49 | throws ClientProtocolException, IOException; 50 | 51 | } -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/web/ResponseParser.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.web; 2 | 3 | import java.util.List; 4 | 5 | import cn.edu.sdust.silence.itransfer.web.domain.Result; 6 | 7 | 8 | public interface ResponseParser { 9 | 10 | /** 11 | * 标记该Response的类型 12 | * 13 | * @author Silence团队 2015-11-15 14 | * 15 | */ 16 | public enum ResultType { 17 | //出错状态码 18 | ResponseCode, 19 | // 成功查询文件 20 | FileLog, 21 | //成功下载 22 | Download, 23 | //出错 24 | Error 25 | } 26 | 27 | /** 28 | * 进行结果解析 29 | * 30 | * @return 返回解析完成的类型 31 | */ 32 | public abstract ResultType parse(); 33 | 34 | 35 | /** 36 | * 返回http响应码 37 | * 38 | * @return 39 | */ 40 | public abstract int getResponseCode(); 41 | 42 | 43 | public abstract Result getResult(); 44 | 45 | public abstract Object getObj() ; 46 | 47 | public abstract void setObj(Object obj) ; 48 | } -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/web/ResponseParserImpl.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.web; 2 | 3 | 4 | import com.google.gson.Gson; 5 | 6 | import cn.edu.sdust.silence.itransfer.web.domain.Result; 7 | 8 | /* 9 | * http响应类型解析 10 | * 1.为空 Null 11 | * 2.http状态码不为200,解析出具体的状态码 12 | * 以下为正常通信情况下的自定义类型 13 | * 3.error:返回提交产生的错误信息,包括String和HashMap两种格式的错误信息 14 | * 4.completed:上传文件已存在,返回已存在的文件实体 15 | * 5.success:返回当次请求的所需要的实体或者成功信息或为空 16 | */ 17 | 18 | /** 19 | * 解析http的Response解析类 20 | * 21 | * @author Silence团队 2015-11-15 22 | * 23 | */ 24 | public class ResponseParserImpl implements ResponseParser { 25 | 26 | /** 27 | * 传入的Response结果 28 | */ 29 | private Object obj; 30 | /** 31 | * 服务器http响应码 32 | */ 33 | private int responseCode; 34 | /** 35 | * Response响应结果体 36 | */ 37 | private Result result; 38 | /** 39 | * 该Response解析之后的类型 40 | */ 41 | private ResultType resultType; 42 | /** 43 | * 标记该Response是否解析过 44 | */ 45 | private boolean parsed = false; 46 | 47 | public ResponseParserImpl(ResultType resultType) { 48 | this.resultType = resultType; 49 | responseCode = 200; 50 | parsed = true; 51 | // 保存最新请求时间 52 | } 53 | 54 | public ResponseParserImpl(Object result) { 55 | this.obj = result; 56 | responseCode = 200; 57 | // 保存最新请求时间 58 | 59 | System.out.println("结果:" + result); 60 | } 61 | 62 | /* 63 | * (non-Javadoc) 64 | * 65 | * @see cn.edu.sdust.cise.ushare.ResponseParser#parse() 66 | */ 67 | @Override 68 | public ResultType parse() { 69 | if (parsed) 70 | return resultType; 71 | if (obj instanceof String) { 72 | String str = (String) obj; 73 | result = new Gson().fromJson(str, Result.class); 74 | System.out.println("gson:"+result); 75 | if(result.getType().equals("message")){ 76 | resultType=ResultType.Error; 77 | }else if(result.getType().equals("file")){ 78 | resultType=ResultType.FileLog; 79 | } 80 | parsed = true; 81 | return resultType; 82 | } 83 | return ResultType.Error; 84 | } 85 | 86 | /* 87 | * (non-Javadoc) 88 | * 89 | * @see cn.edu.sdust.cise.ushare.ResponseParser#getResponseCode() 90 | */ 91 | @Override 92 | public int getResponseCode() { 93 | return responseCode; 94 | } 95 | 96 | /* (non-Javadoc) 97 | * @see cn.edu.sdust.cise.itransfer.ResponseParser#getResult() 98 | */ 99 | @Override 100 | public Result getResult() { 101 | return result; 102 | } 103 | 104 | public Object getObj() { 105 | return obj; 106 | } 107 | 108 | public void setObj(Object obj) { 109 | this.obj = obj; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/web/domain/FileLog.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.web.domain; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by 宇强 on 2016/4/30 0030. 8 | */ 9 | public class FileLog implements Serializable{ 10 | 11 | /** 12 | * 文件唯一id 13 | */ 14 | private int fid; 15 | /** 16 | * 用户文件名 17 | */ 18 | private String filename; 19 | /** 20 | * 服务器文件储存名 21 | */ 22 | private String storeName; 23 | /** 24 | * 该文件md5 25 | */ 26 | private String md5; 27 | /** 28 | * 文件后缀名 29 | */ 30 | private String extension; 31 | /** 32 | * 文件上传时间 33 | */ 34 | private Date time; 35 | /** 36 | * 文件唯一查找识别id 37 | */ 38 | private int filecode; 39 | /** 40 | * 文件安全验证密码 41 | */ 42 | private String password; 43 | 44 | @Override 45 | public String toString() { 46 | return "FileLog{" + 47 | "fid=" + fid + 48 | ", filename='" + filename + '\'' + 49 | ", storeName='" + storeName + '\'' + 50 | ", md5='" + md5 + '\'' + 51 | ", extension='" + extension + '\'' + 52 | ", time=" + time + 53 | ", filecode=" + filecode + 54 | ", password='" + password + '\'' + 55 | '}'; 56 | } 57 | 58 | public FileLog() { 59 | } 60 | 61 | public void init(String filename, String storeName, String md5, String extension, Date time, int filecode, String password) { 62 | this.filename = filename; 63 | this.storeName = storeName; 64 | this.md5 = md5; 65 | this.extension = extension; 66 | this.time = time; 67 | this.filecode = filecode; 68 | this.password = password; 69 | } 70 | 71 | public int getFilecode() { 72 | return filecode; 73 | } 74 | 75 | public void setFilecode(int filecode) { 76 | this.filecode = filecode; 77 | } 78 | 79 | public int getFid() { 80 | return fid; 81 | } 82 | 83 | public void setFid(int fid) { 84 | this.fid = fid; 85 | } 86 | 87 | public String getFilename() { 88 | return filename; 89 | } 90 | 91 | public void setFilename(String filename) { 92 | this.filename = filename; 93 | } 94 | 95 | public String getStoreName() { 96 | return storeName; 97 | } 98 | 99 | public void setStoreName(String storeName) { 100 | this.storeName = storeName; 101 | } 102 | 103 | public String getMd5() { 104 | return md5; 105 | } 106 | 107 | public void setMd5(String md5) { 108 | this.md5 = md5; 109 | } 110 | 111 | public String getExtension() { 112 | return extension; 113 | } 114 | 115 | public void setExtension(String extension) { 116 | this.extension = extension; 117 | } 118 | 119 | public Date getTime() { 120 | return time; 121 | } 122 | 123 | public void setTime(Date time) { 124 | this.time = time; 125 | } 126 | 127 | public String getPassword() { 128 | return password; 129 | } 130 | 131 | public void setPassword(String password) { 132 | this.password = password; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /app/src/main/java/cn/edu/sdust/silence/itransfer/web/domain/Result.java: -------------------------------------------------------------------------------- 1 | package cn.edu.sdust.silence.itransfer.web.domain; 2 | 3 | import com.google.gson.Gson; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 宇强 on 2016/5/24 0024. 9 | */ 10 | public class Result { 11 | private String type; 12 | private List fileLogs; 13 | private String message; 14 | 15 | @Override 16 | public String toString() { 17 | Gson gson = new Gson(); 18 | return gson.toJson(this); 19 | } 20 | 21 | public String getType() { 22 | return type; 23 | } 24 | 25 | public void setType(String type) { 26 | this.type = type; 27 | } 28 | 29 | public List getFileLogs() { 30 | return fileLogs; 31 | } 32 | 33 | public void setFileLogs(List fileLogs) { 34 | this.fileLogs = fileLogs; 35 | } 36 | 37 | public String getMessage() { 38 | return message; 39 | } 40 | 41 | public void setMessage(String message) { 42 | this.message = message; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/apk_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/apk_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/back_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/back_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_download_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/btn_download_bg.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/choosefile_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/choosefile_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/download_bg_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/download_bg_header.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/excel_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/excel_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/fab_bg_mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/fab_bg_mini.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/fab_bg_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/fab_bg_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/fab_label_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/file_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/file_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/flying.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/flying.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ftp_header_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/ftp_header_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/girl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/girl.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/history_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/history_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/huojian_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/huojian_img.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_fab_star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/ic_fab_star.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_my.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/icon_my.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/icon_net.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_pc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/icon_pc.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_receice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/icon_receice.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_wlan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/icon_wlan.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/music_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/music_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/notfound_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/notfound_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/oee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/oee.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/pdf_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/pdf_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/pic_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/pic_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ppt_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/ppt_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/receive_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/receive_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/scan_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/scan_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/send_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/send_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/send_to_computer_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/send_to_computer_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/txt_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/txt_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/video_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/video_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/viewpager_item_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/viewpager_item_hello_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/word_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/word_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/xml_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/xml_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/zip_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-hdpi/zip_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-ldpi/notification.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/qr_code_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-ldpi/qr_code_bg.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/scan_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-ldpi/scan_line.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-ldpi/shadow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/widget_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-ldpi/widget_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/widget_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudups/iTransfer/292ebda39a3c96d44e27980e83a4c7f102fe8616/app/src/main/res/drawable-ldpi/widget_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_item_recyclerview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_action_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 28 | 29 | 36 | 37 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_chose_file.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 15 | 22 | 23 | 31 | 32 | 33 | 34 | 35 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ftp_manager.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 35 | 36 | 44 | 45 | 53 | 54 | 55 | 59 | 60 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 30 | 31 | 32 | 38 | 39 | 48 | 49 | 56 | 57 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main2.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_receive_from_computer.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 14 | 15 | 22 | 23 | 24 | 25 | 34 | 35 |