├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── scopes
│ └── scope_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── capture.png
│ │ │ │ ├── photo_mode.png
│ │ │ │ ├── video_mode.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── record_start.png
│ │ │ │ ├── record_stop.png
│ │ │ │ └── capture_pressed.png
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── photo_mode.png
│ │ │ │ ├── video_mode.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── photo_mode.png
│ │ │ │ └── video_mode.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── styles.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── strings.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── geocine
│ │ │ └── sjremote
│ │ │ ├── http
│ │ │ ├── HttpGetter.java
│ │ │ └── SJRemoteRestClient.java
│ │ │ └── MainActivity.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── geocine
│ │ └── sjremote
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── SJRemote.iml
├── LICENSE.md
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | SJ Remote
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-mdpi/capture.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/photo_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-hdpi/photo_mode.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/video_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-hdpi/video_mode.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/photo_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-mdpi/photo_mode.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/video_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-mdpi/video_mode.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/record_start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-mdpi/record_start.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/record_stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-mdpi/record_stop.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/photo_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-xhdpi/photo_mode.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/video_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-xhdpi/video_mode.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/capture_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geocine/sjremote/HEAD/app/src/main/res/drawable-mdpi/capture_pressed.png
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SJ Remote
5 | Hello world!
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.apk
2 | *.ap_
3 | *.dex
4 | *.class
5 | local.properties
6 |
7 | .classpath
8 | .project
9 |
10 | .gradle
11 | /local.properties
12 | /.idea/workspace.xml
13 | /.idea/libraries
14 | Thumbs.db
15 | .DS_Store
16 | /build
17 |
18 | manifest-merger-release-report.txt
19 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
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-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/geocine/sjremote/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.geocine.sjremote;
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/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 C:\adt-bundle-windows-x86_64-20140702\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/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "com.geocine.sjremote"
9 | minSdkVersion 8
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled true
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:21.0.3'
25 | compile 'com.loopj.android:android-async-http:1.4.5'
26 | }
27 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.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 |
23 |
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SJ Remote
2 |
3 |
4 |
5 |
6 |
7 | **[Click Here To Download](https://dl.dropboxusercontent.com/u/16422464/com.geocine.sjremote.apk)**
8 |
9 | A very simple remote for **[SJCam](http://www.sjcam.com/)** on Android via wifi. This application supports *Android 2.2.x* **Froyo** and up.
10 |
11 | This application does not have a video preview, this is just a remote control. It only contains the following features:
12 | - video mode
13 | - photo mode
14 | - take picture
15 | - start record video
16 | - stop record video
17 |
18 | Because the application is very lightweight and does not contain unneeded features , it is fast on very slow devices.
19 |
20 | This has only been tested on **SJ5000 Wifi**
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Android API 10 Platform
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SJRemote.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ### License
2 |
3 | New BSD License
4 |
5 | Copyright (c) 2015, Aivan Monceller
6 |
7 | All rights reserved.
8 |
9 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10 |
11 | - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12 | - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
13 | - Neither the name of Aivan Monceller nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/geocine/sjremote/http/HttpGetter.java:
--------------------------------------------------------------------------------
1 | package com.geocine.sjremote.http;
2 |
3 | import android.os.AsyncTask;
4 | import android.util.Log;
5 |
6 | import org.apache.http.HttpEntity;
7 | import org.apache.http.HttpResponse;
8 | import org.apache.http.StatusLine;
9 | import org.apache.http.client.ClientProtocolException;
10 | import org.apache.http.client.HttpClient;
11 | import org.apache.http.client.methods.HttpGet;
12 | import org.apache.http.impl.client.DefaultHttpClient;
13 |
14 | import java.io.BufferedReader;
15 | import java.io.IOException;
16 | import java.io.InputStream;
17 | import java.io.InputStreamReader;
18 | import java.net.URI;
19 | import java.net.URL;
20 |
21 | /**
22 | * Created by Aivan on 4/9/2015.
23 | */
24 | public class HttpGetter extends AsyncTask {
25 |
26 | @Override
27 | protected Void doInBackground(String... urls) {
28 | // TODO Auto-generated method stub
29 | StringBuilder builder = new StringBuilder();
30 | HttpClient client = new DefaultHttpClient();
31 | HttpGet httpGet = new HttpGet(urls[0]);
32 |
33 | try {
34 | HttpResponse response = client.execute(httpGet);
35 | StatusLine statusLine = response.getStatusLine();
36 | int statusCode = statusLine.getStatusCode();
37 | if (statusCode == 200) {
38 | HttpEntity entity = response.getEntity();
39 | InputStream content = entity.getContent();
40 | BufferedReader reader = new BufferedReader(
41 | new InputStreamReader(content));
42 | String line;
43 | while ((line = reader.readLine()) != null) {
44 | builder.append(line);
45 | }
46 | Log.v("Getter", "Your data: " + builder.toString()); //response data
47 | } else {
48 | Log.e("Getter", "Failed to download file");
49 | }
50 | } catch (ClientProtocolException e) {
51 | e.printStackTrace();
52 | } catch (IOException e) {
53 | e.printStackTrace();
54 | }
55 |
56 | return null;
57 | }
58 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
19 |
20 |
21 |
27 |
28 |
35 |
36 |
37 |
38 |
39 |
40 |
46 |
47 |
48 |
55 |
56 |
57 |
58 |
59 |
60 |
66 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/geocine/sjremote/http/SJRemoteRestClient.java:
--------------------------------------------------------------------------------
1 | package com.geocine.sjremote.http;
2 |
3 | /**
4 | * Created by Aivan on 4/9/2015.
5 | */
6 | import android.content.Context;
7 | import android.util.Log;
8 | import android.widget.Toast;
9 |
10 | import com.loopj.android.http.*;
11 |
12 | import org.apache.http.Header;
13 |
14 | public class SJRemoteRestClient {
15 | private static final String BASE_URL = "http://192.168.1.254/?custom=1";
16 | public static Integer PHOTO_MODE = 0;
17 | public static Integer VIDEO_MODE = 1;
18 | private static String[] mode = { "photo" , "video" };
19 | private static String[] record = { "stopped" , "recording" };
20 |
21 | private static AsyncHttpClient client = new AsyncHttpClient();
22 |
23 | public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
24 | Log.d("URL", getAbsoluteUrl(url));
25 | client.get(getAbsoluteUrl(url), params, responseHandler);
26 | }
27 |
28 | public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
29 | client.post(getAbsoluteUrl(url), params, responseHandler);
30 | }
31 |
32 | private static String getAbsoluteUrl(String relativeUrl) {
33 | return BASE_URL + relativeUrl;
34 | }
35 |
36 | public static void takePhoto(final Context context){
37 |
38 | //HttpGetter get = new HttpGetter();
39 | //get.execute(getAbsoluteUrl("&cmd=1001"));
40 | SJRemoteRestClient.get("&cmd=1001", null, new TextHttpResponseHandler() {
41 | @Override
42 | public void onSuccess(int statusCode, Header[] headers, String responseString) {
43 | //Toast.makeText(context, "Photo success!", Toast.LENGTH_SHORT).show();
44 | }
45 |
46 | @Override
47 | public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
48 | Toast.makeText(context, "Cannot take photo!", Toast.LENGTH_SHORT).show();
49 | }
50 | });
51 | }
52 |
53 | public static void switchMode(final Context context, final Integer mode){
54 |
55 | SJRemoteRestClient.get("&cmd=3001&par="+mode, null, new AsyncHttpResponseHandler() {
56 | @Override
57 | public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
58 | //Toast.makeText(context, "Now in " + SJRemoteRestClient.mode[mode] + " mode !", Toast.LENGTH_SHORT).show();
59 | }
60 |
61 | @Override
62 | public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
63 | Toast.makeText(context, "Cannot change modes!", Toast.LENGTH_SHORT).show();
64 | }
65 | });
66 | }
67 |
68 | public static void toggleRecord(final Context context, final Boolean start){
69 | final Integer mode = start ? 1 : 0;
70 | SJRemoteRestClient.get("&cmd=2001&par="+mode, null, new AsyncHttpResponseHandler() {
71 | @Override
72 | public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
73 | //Toast.makeText(context, "Video is now "+ SJRemoteRestClient.record[mode] + " !", Toast.LENGTH_SHORT).show();
74 | }
75 |
76 | @Override
77 | public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
78 | Toast.makeText(context, "Cannot toggle record!", Toast.LENGTH_SHORT).show();
79 | }
80 | });
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
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 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/app/src/main/java/com/geocine/sjremote/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.geocine.sjremote;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.PorterDuff;
6 | import android.support.v7.app.ActionBarActivity;
7 | import android.os.Bundle;
8 | import android.view.Menu;
9 | import android.view.MenuItem;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 | import android.widget.ImageView;
13 | import android.widget.Toast;
14 |
15 | import com.geocine.sjremote.http.SJRemoteRestClient;
16 | import com.loopj.android.http.AsyncHttpResponseHandler;
17 |
18 | import org.apache.http.Header;
19 |
20 |
21 | public class MainActivity extends ActionBarActivity {
22 |
23 | Context context;
24 | Boolean isVideoMode = false;
25 | Boolean isRecording = false;
26 |
27 |
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_main);
33 | context = getApplicationContext();
34 |
35 | final ImageView actionButton = (ImageView)findViewById(R.id.actionButton);
36 |
37 | switchVideoMode();
38 | isVideoMode = true;
39 |
40 | actionButton.setOnClickListener(new View.OnClickListener(){
41 | @Override
42 | public void onClick(View v) {
43 | if(isVideoMode){
44 | if(isRecording){
45 | stopRecordVideo();
46 | isRecording = false;
47 | actionButton.setImageResource(R.drawable.record_start);
48 | } else {
49 | recordVideo();
50 | isRecording = true;
51 | actionButton.setImageResource(R.drawable.record_stop);
52 | }
53 | } else {
54 | takePhoto();
55 | }
56 | }
57 | });
58 |
59 | actionButton.setOnTouchListener(new View.OnTouchListener() {
60 | @Override
61 | public boolean onTouch(View v, MotionEvent event) {
62 | if (event.getAction() == MotionEvent.ACTION_DOWN) {
63 | if(!isVideoMode) {
64 | actionButton.setImageResource(R.drawable.capture_pressed);
65 | }
66 | }
67 | if (event.getAction() == MotionEvent.ACTION_UP) {
68 | if(!isVideoMode) {
69 | actionButton.setImageResource(R.drawable.capture);
70 | }
71 | }
72 | return false;
73 | }
74 | });
75 |
76 | final ImageView photoModeButton = (ImageView)findViewById(R.id.photoModeButton);
77 |
78 | photoModeButton.setOnClickListener(new View.OnClickListener(){
79 | @Override
80 | public void onClick(View v) {
81 | switchPhotoMode();
82 | isVideoMode = false;
83 | actionButton.setImageResource(R.drawable.capture);
84 | }
85 | });
86 |
87 | photoModeButton.setOnTouchListener(new View.OnTouchListener() {
88 | @Override
89 | public boolean onTouch(View v, MotionEvent event) {
90 | if (event.getAction() == MotionEvent.ACTION_DOWN) {
91 | photoModeButton.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_ATOP);
92 | }
93 | if (event.getAction() == MotionEvent.ACTION_UP) {
94 | photoModeButton.setColorFilter(Color.argb(0, 0, 0, 0));
95 | }
96 | return false;
97 | }
98 | });
99 |
100 | final ImageView videoModeButton = (ImageView)findViewById(R.id.videoModeButton);
101 |
102 | videoModeButton.setOnClickListener(new View.OnClickListener(){
103 | @Override
104 | public void onClick(View v) {
105 | switchVideoMode();
106 | isVideoMode = true;
107 | actionButton.setImageResource(R.drawable.record_start);
108 | }
109 | });
110 |
111 | videoModeButton.setOnTouchListener(new View.OnTouchListener() {
112 | @Override
113 | public boolean onTouch(View v, MotionEvent event) {
114 | if (event.getAction() == MotionEvent.ACTION_DOWN) {
115 | videoModeButton.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_ATOP);
116 | }
117 | if (event.getAction() == MotionEvent.ACTION_UP) {
118 | videoModeButton.setColorFilter(Color.argb(0, 0, 0, 0));
119 | }
120 | return false;
121 | }
122 | });
123 |
124 |
125 | }
126 |
127 | @Override
128 | public boolean onCreateOptionsMenu(Menu menu) {
129 | // Inflate the menu; this adds items to the action bar if it is present.
130 | getMenuInflater().inflate(R.menu.menu_main, menu);
131 | return true;
132 | }
133 |
134 | @Override
135 | public boolean onOptionsItemSelected(MenuItem item) {
136 | // Handle action bar item clicks here. The action bar will
137 | // automatically handle clicks on the Home/Up button, so long
138 | // as you specify a parent activity in AndroidManifest.xml.
139 | int id = item.getItemId();
140 |
141 | //noinspection SimplifiableIfStatement
142 | if (id == R.id.action_settings) {
143 | return true;
144 | }
145 |
146 | return super.onOptionsItemSelected(item);
147 | }
148 |
149 | public void takePhoto(){
150 | SJRemoteRestClient.takePhoto(context);
151 | }
152 |
153 | public void switchPhotoMode(){
154 | SJRemoteRestClient.switchMode(context,SJRemoteRestClient.PHOTO_MODE);
155 | }
156 |
157 | public void switchVideoMode(){
158 | SJRemoteRestClient.switchMode(context,SJRemoteRestClient.VIDEO_MODE);
159 | }
160 |
161 | public void recordVideo(){
162 | SJRemoteRestClient.toggleRecord(context,true);
163 | }
164 |
165 | public void stopRecordVideo(){
166 | SJRemoteRestClient.toggleRecord(context,false);
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------