├── Part 1
├── AndroidClient
│ ├── app
│ │ ├── .gitignore
│ │ ├── .idea
│ │ │ ├── .name
│ │ │ ├── caches
│ │ │ │ ├── gradle_models.ser
│ │ │ │ └── build_file_checksums.ser
│ │ │ ├── vcs.xml
│ │ │ ├── misc.xml
│ │ │ ├── modules.xml
│ │ │ ├── libraries
│ │ │ │ ├── Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml
│ │ │ │ ├── Gradle__com_android_support_support_annotations_28_0_0_jar.xml
│ │ │ │ ├── Gradle__com_android_support_constraint_constraint_layout_solver_1_1_3_jar.xml
│ │ │ │ ├── Gradle__com_android_support_constraint_constraint_layout_1_1_3_aar.xml
│ │ │ │ ├── Gradle__com_squareup_okio_okio_1_9_0_jar.xml
│ │ │ │ ├── Gradle__android_arch_core_common_1_0_0_jar.xml
│ │ │ │ ├── Gradle__com_squareup_okhttp3_okhttp_3_4_1_jar.xml
│ │ │ │ ├── Gradle__android_arch_lifecycle_common_1_0_0_jar.xml
│ │ │ │ ├── Gradle__android_arch_lifecycle_runtime_1_0_0_aar.xml
│ │ │ │ ├── Gradle__com_android_support_test_monitor_1_0_2_aar.xml
│ │ │ │ ├── Gradle__com_android_support_test_runner_1_0_2_aar.xml
│ │ │ │ ├── Gradle__com_android_support_support_v4_26_1_0_aar.xml
│ │ │ │ ├── Gradle__com_android_support_appcompat_v7_26_1_0_aar.xml
│ │ │ │ ├── Gradle__junit_junit_4_12_jar.xml
│ │ │ │ ├── Gradle__com_android_support_support_compat_26_1_0_aar.xml
│ │ │ │ ├── Gradle__com_android_support_support_core_ui_26_1_0_aar.xml
│ │ │ │ ├── Gradle__com_android_support_support_fragment_26_1_0_aar.xml
│ │ │ │ ├── Gradle__com_android_support_support_core_utils_26_1_0_aar.xml
│ │ │ │ ├── Gradle__com_android_support_support_media_compat_26_1_0_aar.xml
│ │ │ │ ├── Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml
│ │ │ │ ├── Gradle__com_android_support_support_vector_drawable_26_1_0_aar.xml
│ │ │ │ ├── Gradle__com_android_support_test_espresso_espresso_core_3_0_2_aar.xml
│ │ │ │ ├── Gradle__com_android_support_animated_vector_drawable_26_1_0_aar.xml
│ │ │ │ ├── Gradle__javax_inject_javax_inject_1_jar.xml
│ │ │ │ ├── Gradle__com_android_support_test_espresso_espresso_idling_resource_3_0_2_aar.xml
│ │ │ │ ├── Gradle__com_squareup_javawriter_2_1_1_jar.xml
│ │ │ │ ├── Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml
│ │ │ │ ├── Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml
│ │ │ │ └── Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml
│ │ │ ├── runConfigurations.xml
│ │ │ ├── gradle.xml
│ │ │ ├── codeStyles
│ │ │ │ └── Project.xml
│ │ │ ├── assetWizardSettings.xml
│ │ │ └── workspace.xml
│ │ ├── src
│ │ │ ├── main
│ │ │ │ ├── res
│ │ │ │ │ ├── values
│ │ │ │ │ │ ├── strings.xml
│ │ │ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ │ │ ├── colors.xml
│ │ │ │ │ │ └── styles.xml
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ │ ├── xml
│ │ │ │ │ │ └── network_security_config.xml
│ │ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ │ ├── drawable-v24
│ │ │ │ │ │ └── ic_launcher_foreground.xml
│ │ │ │ │ ├── layout
│ │ │ │ │ │ └── activity_main.xml
│ │ │ │ │ └── drawable
│ │ │ │ │ │ └── ic_launcher_background.xml
│ │ │ │ ├── ic_launcher-web.png
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ └── java
│ │ │ │ │ └── gad
│ │ │ │ │ └── heartbeat
│ │ │ │ │ └── androidflask
│ │ │ │ │ └── easyupload
│ │ │ │ │ └── MainActivity.java
│ │ │ ├── test
│ │ │ │ └── java
│ │ │ │ │ └── gad
│ │ │ │ │ └── example
│ │ │ │ │ └── dell
│ │ │ │ │ └── androidflask
│ │ │ │ │ └── ExampleUnitTest.java
│ │ │ └── androidTest
│ │ │ │ └── java
│ │ │ │ └── gad
│ │ │ │ └── example
│ │ │ │ └── dell
│ │ │ │ └── androidflask
│ │ │ │ └── ExampleInstrumentedTest.java
│ │ ├── gradle
│ │ │ └── wrapper
│ │ │ │ ├── gradle-wrapper.jar
│ │ │ │ └── gradle-wrapper.properties
│ │ ├── release
│ │ │ └── output.json
│ │ ├── local.properties
│ │ ├── proguard-rules.pro
│ │ ├── build.gradle
│ │ ├── gradlew.bat
│ │ └── gradlew
│ ├── settings.gradle
│ ├── .idea
│ │ ├── caches
│ │ │ ├── gradle_models.ser
│ │ │ └── build_file_checksums.ser
│ │ ├── encodings.xml
│ │ ├── vcs.xml
│ │ ├── modules.xml
│ │ ├── runConfigurations.xml
│ │ ├── gradle.xml
│ │ ├── misc.xml
│ │ ├── codeStyles
│ │ │ └── Project.xml
│ │ └── assetWizardSettings.xml
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradlew.bat
│ └── gradlew
└── FlaskServer
│ └── flask_server.py
├── 3.jpg
├── 6.jpg
├── 7.jpg
├── 9.jpg
├── .gitattributes
├── Part 2
├── FlaskServer
│ ├── model.h5
│ ├── androidFlask.jpg
│ └── flask_server.py
└── MLP_MNIST_Keras.py
├── .github
└── FUNDING.yml
├── License.md
└── README.md
/Part 1/AndroidClient/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/.name:
--------------------------------------------------------------------------------
1 | AndroidClient
--------------------------------------------------------------------------------
/Part 1/AndroidClient/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/3.jpg
--------------------------------------------------------------------------------
/6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/6.jpg
--------------------------------------------------------------------------------
/7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/7.jpg
--------------------------------------------------------------------------------
/9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/9.jpg
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/Part 2/FlaskServer/model.h5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 2/FlaskServer/model.h5
--------------------------------------------------------------------------------
/Part 2/FlaskServer/androidFlask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 2/FlaskServer/androidFlask.jpg
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EasyUpload
3 |
4 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #604DA6
4 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmedfgad/AndroidFlask/HEAD/Part 1/AndroidClient/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"0.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jul 25 21:04:01 EET 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 20 00:10:08 EET 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 192.168.43.177
5 |
6 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Fri Sep 20 00:09:57 EET 2019
8 | sdk.dir=D\:\\AndroidSDK
9 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_support_annotations_28_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_constraint_constraint_layout_solver_1_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/test/java/gad/example/dell/androidflask/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package gad.example.dell.androidflask;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_constraint_constraint_layout_1_1_3_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_squareup_okio_okio_1_9_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__android_arch_core_common_1_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_4_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__android_arch_lifecycle_common_1_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.4.2'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__android_arch_lifecycle_runtime_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_test_monitor_1_0_2_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_test_runner_1_0_2_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_support_v4_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_appcompat_v7_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__junit_junit_4_12_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_support_compat_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_support_core_ui_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_support_fragment_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_support_core_utils_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_support_media_compat_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_support_vector_drawable_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_core_3_0_2_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_animated_vector_drawable_26_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 2/FlaskServer/flask_server.py:
--------------------------------------------------------------------------------
1 | import flask
2 | import werkzeug
3 | import keras.models
4 | import numpy
5 | import scipy.misc
6 |
7 | app = flask.Flask(__name__)
8 |
9 | @app.route('/', methods = ['GET', 'POST'])
10 | def handle_request():
11 | imagefile = flask.request.files['image0']
12 | filename = werkzeug.utils.secure_filename(imagefile.filename)
13 | print("\nReceived image File name : " + imagefile.filename)
14 | imagefile.save(filename)
15 |
16 | img = scipy.misc.imread(filename, mode="L")
17 | img = img.reshape(784)
18 | loaded_model = keras.models.load_model('model.h5')
19 | predicted_label = loaded_model.predict_classes(numpy.array([img]))[0]
20 | print(predicted_label)
21 |
22 | return str(predicted_label)
23 |
24 | app.run(host="0.0.0.0", port=5000, debug=True)
25 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | # paypal: http://paypal.me/ahmedfgad # Replace with a single Patreon username
5 | open_collective: pygad
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: ['https://donate.stripe.com/eVa5kO866elKgM0144', 'http://paypal.me/ahmedfgad'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_idling_resource_3_0_2_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/Part 1/FlaskServer/flask_server.py:
--------------------------------------------------------------------------------
1 | import flask
2 | import werkzeug
3 | import time
4 |
5 | app = flask.Flask(__name__)
6 |
7 | @app.route('/', methods = ['GET', 'POST'])
8 | def handle_request():
9 | files_ids = list(flask.request.files)
10 | print("\nNumber of Received Images : ", len(files_ids))
11 | image_num = 1
12 | for file_id in files_ids:
13 | print("\nSaving Image ", str(image_num), "/", len(files_ids))
14 | imagefile = flask.request.files[file_id]
15 | filename = werkzeug.utils.secure_filename(imagefile.filename)
16 | print("Image Filename : " + imagefile.filename)
17 | timestr = time.strftime("%Y%m%d-%H%M%S")
18 | imagefile.save(timestr+'_'+filename)
19 | image_num = image_num + 1
20 | print("\n")
21 | return "Image(s) Uploaded Successfully. Come Back Soon."
22 |
23 | app.run(host="0.0.0.0", port=5000, debug=True)
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/androidTest/java/gad/example/dell/androidflask/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package gad.example.dell.androidflask;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.dell.androidflask", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/License.md:
--------------------------------------------------------------------------------
1 | # MIT License
2 |
3 | Copyright (c) [2020] [**Ahmed Fawzy Mohamed Gad**]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "gad.heartbeat.androidflask.easyupload"
7 | minSdkVersion 19
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "0.1"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation 'com.android.support:support-annotations:28.0.0'
23 | implementation fileTree(dir: 'libs', include: ['*.jar'])
24 | implementation 'com.android.support:appcompat-v7:26.1.0'
25 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
26 | testImplementation 'junit:junit:4.12'
27 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
28 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
29 | implementation 'com.squareup.okhttp3:okhttp:3.4.1'
30 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AndroidFlask
2 |
3 | ## Image Upload from Android to a Python-Based Flask Server
4 |
5 | Documentation: https://heartbeat.comet.ml/uploading-images-from-android-to-a-python-based-flask-server-691e4092a95e
6 |
7 | The repository consists of 2 main folders:
8 | 1. **AndroidClient**: Represents the Android Studio project which builds an Android app working as a client.
9 | 2. **FlaskServer**: The Python-Based server using Flask.
10 |
11 | To use this project, do the following:
12 | * Open the **Android Studio** project and run it to create the APK and run the app.
13 | * After that, run the **Flask** app Python file. It is enough to run it in the console.
14 | * After the server is up and running, then go back to the Android app. Edit the EditText boxe of the **IPv4 address** to reflect the current IPv4 address of the server.
15 | * If the **port number** used in the project which is **5000** is used by another app in your machine, you need to change the port number in both the client and server.
16 | * Select an image file to be uploaded to the server by clikcing on the **Select Image** button.
17 | * Click on the **Connect to Server** button to establish a connection with the server and upload the selected image.
18 |
--------------------------------------------------------------------------------
/Part 2/MLP_MNIST_Keras.py:
--------------------------------------------------------------------------------
1 | import keras.datasets.mnist
2 | import keras.models
3 | import keras.layers
4 | import keras.optimizers
5 | import numpy
6 |
7 | batch_size = 128
8 | num_classes = 10
9 | epochs = 20
10 |
11 | # the data, split between train and test sets
12 | (x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
13 | print(x_train.shape) # (60000, 28, 28)
14 | print(y_train.shape) # (60000,)
15 |
16 | print(x_test.shape) # (10000, 28, 28)
17 | print(y_test.shape) # (10000,)
18 |
19 | x_train = x_train.reshape(60000, 784)
20 | x_test = x_test.reshape(10000, 784)
21 | x_train = x_train.astype('float32') / 255
22 | x_test = x_test.astype('float32') / 255
23 |
24 | y_train = keras.utils.to_categorical(y_train, num_classes) # (60000, 10)
25 | y_test = keras.utils.to_categorical(y_test, num_classes) # (10000, 10)
26 |
27 | model = keras.models.Sequential()
28 | model.add(keras.layers.Dense(512, activation='relu', input_shape=(784,)))
29 | model.add(keras.layers.Dropout(0.2))
30 | model.add(keras.layers.Dense(512, activation='relu'))
31 | model.add(keras.layers.Dropout(0.2))
32 | model.add(keras.layers.Dense(num_classes, activation='softmax'))
33 |
34 | model.summary()
35 |
36 | model.compile(loss='categorical_crossentropy',
37 | optimizer=keras.optimizers.RMSprop(),
38 | metrics=['accuracy'])
39 |
40 | history = model.fit(x_train, y_train,
41 | batch_size=batch_size,
42 | epochs=epochs,
43 | verbose=1,
44 | validation_data=(x_test, y_test))
45 |
46 | score = model.evaluate(x_test, y_test, verbose=0)
47 | print('Test loss:', score[0])
48 | print('Test accuracy:', score[1])
49 |
50 | model.save("model.h5")
51 |
52 | loaded_model = keras.models.load_model('model.h5')
53 | predicted_label = loaded_model.predict_classes(numpy.array([x_test[0, :]]))[0]
54 | print(predicted_label)
55 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
28 |
29 |
33 |
40 |
48 |
49 |
50 |
54 |
61 |
70 |
71 |
72 |
79 |
80 |
88 |
89 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/.idea/assetWizardSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/assetWizardSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/src/main/java/gad/heartbeat/androidflask/easyupload/MainActivity.java:
--------------------------------------------------------------------------------
1 | package gad.heartbeat.androidflask.easyupload;
2 |
3 | import android.Manifest;
4 | import android.content.ClipData;
5 | import android.content.ContentUris;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.content.pm.PackageManager;
9 | import android.database.Cursor;
10 | import android.graphics.Bitmap;
11 | import android.graphics.BitmapFactory;
12 | import android.net.Uri;
13 | import android.os.Build;
14 | import android.os.Environment;
15 | import android.provider.DocumentsContract;
16 | import android.provider.MediaStore;
17 | import android.support.v4.app.ActivityCompat;
18 | import android.support.v7.app.AppCompatActivity;
19 | import android.os.Bundle;
20 | import android.util.Log;
21 | import android.view.View;
22 | import android.widget.EditText;
23 | import android.widget.TextView;
24 | import android.widget.Toast;
25 |
26 | import java.io.ByteArrayOutputStream;
27 | import java.io.IOException;
28 | import java.util.ArrayList;
29 | import java.util.regex.Matcher;
30 | import java.util.regex.Pattern;
31 |
32 | import okhttp3.Call;
33 | import okhttp3.Callback;
34 | import okhttp3.MediaType;
35 | import okhttp3.MultipartBody;
36 | import okhttp3.OkHttpClient;
37 | import okhttp3.Request;
38 | import okhttp3.RequestBody;
39 | import okhttp3.Response;
40 |
41 | public class MainActivity extends AppCompatActivity {
42 | private static final Pattern IP_ADDRESS
43 | = Pattern.compile(
44 | "((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
45 | + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]"
46 | + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
47 | + "|[1-9][0-9]|[0-9]))");
48 | final int SELECT_MULTIPLE_IMAGES = 1;
49 | ArrayList selectedImagesPaths; // Paths of the image(s) selected by the user.
50 | boolean imagesSelected = false; // Whether the user selected at least an image or not.
51 |
52 | @Override
53 | protected void onCreate(Bundle savedInstanceState) {
54 | super.onCreate(savedInstanceState);
55 |
56 | ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.INTERNET}, 2);
57 | ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
58 |
59 | setContentView(R.layout.activity_main);
60 | }
61 |
62 | @Override
63 | public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
64 | switch (requestCode) {
65 | case 1: {
66 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
67 | // Toast.makeText(getApplicationContext(), "Access to Storage Permission Granted. Thanks.", Toast.LENGTH_SHORT).show();
68 | } else {
69 | // Toast.makeText(getApplicationContext(), "Access to Storage Permission Denied.", Toast.LENGTH_SHORT).show();
70 | }
71 | return;
72 | }
73 | case 2: {
74 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
75 | // Toast.makeText(getApplicationContext(), "Access to Internet Permission Granted. Thanks.", Toast.LENGTH_SHORT).show();
76 | } else {
77 | Toast.makeText(getApplicationContext(), "Access to Internet Permission Denied.", Toast.LENGTH_SHORT).show();
78 | }
79 | return;
80 | }
81 | }
82 | }
83 |
84 | public void connectServer(View v) {
85 | TextView responseText = findViewById(R.id.responseText);
86 | if (imagesSelected == false) { // This means no image is selected and thus nothing to upload.
87 | responseText.setText("No Image Selected to Upload. Select Image(s) and Try Again.");
88 | return;
89 | }
90 | responseText.setText("Sending the Files. Please Wait ...");
91 |
92 | EditText ipv4AddressView = findViewById(R.id.IPAddress);
93 | String ipv4Address = ipv4AddressView.getText().toString();
94 | EditText portNumberView = findViewById(R.id.portNumber);
95 | String portNumber = portNumberView.getText().toString();
96 |
97 | Matcher matcher = IP_ADDRESS.matcher(ipv4Address);
98 | if (!matcher.matches()) {
99 | responseText.setText("Invalid IPv4 Address. Please Check Your Inputs.");
100 | return;
101 | }
102 |
103 | String postUrl = "http://" + ipv4Address + ":" + portNumber + "/";
104 |
105 | MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
106 |
107 | for (int i = 0; i < selectedImagesPaths.size(); i++) {
108 | BitmapFactory.Options options = new BitmapFactory.Options();
109 | options.inPreferredConfig = Bitmap.Config.RGB_565;
110 |
111 | ByteArrayOutputStream stream = new ByteArrayOutputStream();
112 | try {
113 | // Read BitMap by file path.
114 | Bitmap bitmap = BitmapFactory.decodeFile(selectedImagesPaths.get(i), options);
115 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
116 | }catch(Exception e){
117 | responseText.setText("Please Make Sure the Selected File is an Image.");
118 | return;
119 | }
120 | byte[] byteArray = stream.toByteArray();
121 |
122 | multipartBodyBuilder.addFormDataPart("image" + i, "Android_Flask_" + i + ".jpg", RequestBody.create(MediaType.parse("image/*jpg"), byteArray));
123 | }
124 |
125 | RequestBody postBodyImage = multipartBodyBuilder.build();
126 |
127 | // RequestBody postBodyImage = new MultipartBody.Builder()
128 | // .setType(MultipartBody.FORM)
129 | // .addFormDataPart("image", "androidFlask.jpg", RequestBody.create(MediaType.parse("image/*jpg"), byteArray))
130 | // .build();
131 |
132 | postRequest(postUrl, postBodyImage);
133 | }
134 |
135 | void postRequest(String postUrl, RequestBody postBody) {
136 |
137 | OkHttpClient client = new OkHttpClient();
138 |
139 | Request request = new Request.Builder()
140 | .url(postUrl)
141 | .post(postBody)
142 | .build();
143 |
144 | client.newCall(request).enqueue(new Callback() {
145 | @Override
146 | public void onFailure(Call call, IOException e) {
147 | // Cancel the post on failure.
148 | call.cancel();
149 | Log.d("FAIL", e.getMessage());
150 |
151 | // In order to access the TextView inside the UI thread, the code is executed inside runOnUiThread()
152 | runOnUiThread(new Runnable() {
153 | @Override
154 | public void run() {
155 | TextView responseText = findViewById(R.id.responseText);
156 | responseText.setText("Failed to Connect to Server. Please Try Again.");
157 | }
158 | });
159 | }
160 |
161 | @Override
162 | public void onResponse(Call call, final Response response) throws IOException {
163 | // In order to access the TextView inside the UI thread, the code is executed inside runOnUiThread()
164 | runOnUiThread(new Runnable() {
165 | @Override
166 | public void run() {
167 | TextView responseText = findViewById(R.id.responseText);
168 | try {
169 | responseText.setText("Server's Response\n" + response.body().string());
170 | } catch (IOException e) {
171 | e.printStackTrace();
172 | }
173 | }
174 | });
175 | }
176 | });
177 | }
178 |
179 | public void selectImage(View v) {
180 | Intent intent = new Intent();
181 | intent.setType("*/*");
182 | intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
183 | intent.setAction(Intent.ACTION_GET_CONTENT);
184 | startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_MULTIPLE_IMAGES);
185 | }
186 |
187 | @Override
188 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
189 | try {
190 | if (requestCode == SELECT_MULTIPLE_IMAGES && resultCode == RESULT_OK && null != data) {
191 | // When a single image is selected.
192 | String currentImagePath;
193 | selectedImagesPaths = new ArrayList<>();
194 | TextView numSelectedImages = findViewById(R.id.numSelectedImages);
195 | if (data.getData() != null) {
196 | Uri uri = data.getData();
197 | currentImagePath = getPath(getApplicationContext(), uri);
198 | Log.d("ImageDetails", "Single Image URI : " + uri);
199 | Log.d("ImageDetails", "Single Image Path : " + currentImagePath);
200 | selectedImagesPaths.add(currentImagePath);
201 | imagesSelected = true;
202 | numSelectedImages.setText("Number of Selected Images : " + selectedImagesPaths.size());
203 | } else {
204 | // When multiple images are selected.
205 | // Thanks tp Laith Mihyar for this Stackoverflow answer : https://stackoverflow.com/a/34047251/5426539
206 | if (data.getClipData() != null) {
207 | ClipData clipData = data.getClipData();
208 | for (int i = 0; i < clipData.getItemCount(); i++) {
209 |
210 | ClipData.Item item = clipData.getItemAt(i);
211 | Uri uri = item.getUri();
212 |
213 | currentImagePath = getPath(getApplicationContext(), uri);
214 | selectedImagesPaths.add(currentImagePath);
215 | Log.d("ImageDetails", "Image URI " + i + " = " + uri);
216 | Log.d("ImageDetails", "Image Path " + i + " = " + currentImagePath);
217 | imagesSelected = true;
218 | numSelectedImages.setText("Number of Selected Images : " + selectedImagesPaths.size());
219 | }
220 | }
221 | }
222 | } else {
223 | Toast.makeText(this, "You haven't Picked any Image.", Toast.LENGTH_LONG).show();
224 | }
225 | Toast.makeText(getApplicationContext(), selectedImagesPaths.size() + " Image(s) Selected.", Toast.LENGTH_LONG).show();
226 | } catch (Exception e) {
227 | Toast.makeText(this, "Something Went Wrong.", Toast.LENGTH_LONG).show();
228 | e.printStackTrace();
229 | }
230 |
231 | super.onActivityResult(requestCode, resultCode, data);
232 | }
233 |
234 | // Implementation of the getPath() method and all its requirements is taken from the StackOverflow Paul Burke's answer: https://stackoverflow.com/a/20559175/5426539
235 | public static String getPath(final Context context, final Uri uri) {
236 |
237 | final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
238 |
239 | // DocumentProvider
240 | if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
241 | // ExternalStorageProvider
242 | if (isExternalStorageDocument(uri)) {
243 | final String docId = DocumentsContract.getDocumentId(uri);
244 | final String[] split = docId.split(":");
245 | final String type = split[0];
246 |
247 | if ("primary".equalsIgnoreCase(type)) {
248 | return Environment.getExternalStorageDirectory() + "/" + split[1];
249 | }
250 |
251 | // TODO handle non-primary volumes
252 | }
253 | // DownloadsProvider
254 | else if (isDownloadsDocument(uri)) {
255 |
256 | final String id = DocumentsContract.getDocumentId(uri);
257 | final Uri contentUri = ContentUris.withAppendedId(
258 | Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
259 |
260 | return getDataColumn(context, contentUri, null, null);
261 | }
262 | // MediaProvider
263 | else if (isMediaDocument(uri)) {
264 | final String docId = DocumentsContract.getDocumentId(uri);
265 | final String[] split = docId.split(":");
266 | final String type = split[0];
267 |
268 | Uri contentUri = null;
269 | if ("image".equals(type)) {
270 | contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
271 | } else if ("video".equals(type)) {
272 | contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
273 | } else if ("audio".equals(type)) {
274 | contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
275 | }
276 |
277 | final String selection = "_id=?";
278 | final String[] selectionArgs = new String[]{
279 | split[1]
280 | };
281 |
282 | return getDataColumn(context, contentUri, selection, selectionArgs);
283 | }
284 | }
285 | // MediaStore (and general)
286 | else if ("content".equalsIgnoreCase(uri.getScheme())) {
287 | return getDataColumn(context, uri, null, null);
288 | }
289 | // File
290 | else if ("file".equalsIgnoreCase(uri.getScheme())) {
291 | return uri.getPath();
292 | }
293 |
294 | return null;
295 | }
296 |
297 | public static String getDataColumn(Context context, Uri uri, String selection,
298 | String[] selectionArgs) {
299 |
300 | Cursor cursor = null;
301 | final String column = "_data";
302 | final String[] projection = {
303 | column
304 | };
305 |
306 | try {
307 | cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
308 | null);
309 | if (cursor != null && cursor.moveToFirst()) {
310 | final int column_index = cursor.getColumnIndexOrThrow(column);
311 | return cursor.getString(column_index);
312 | }
313 | } finally {
314 | if (cursor != null)
315 | cursor.close();
316 | }
317 | return null;
318 | }
319 |
320 | public static boolean isExternalStorageDocument(Uri uri) {
321 | return "com.android.externalstorage.documents".equals(uri.getAuthority());
322 | }
323 |
324 | public static boolean isDownloadsDocument(Uri uri) {
325 | return "com.android.providers.downloads.documents".equals(uri.getAuthority());
326 | }
327 |
328 | public static boolean isMediaDocument(Uri uri) {
329 | return "com.android.providers.media.documents".equals(uri.getAuthority());
330 | }
331 | }
332 |
333 |
334 |
335 |
--------------------------------------------------------------------------------
/Part 1/AndroidClient/app/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | failed to
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 | 1568930999922
238 |
239 |
240 | 1568930999922
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
--------------------------------------------------------------------------------