├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ └── bg_shadow.9.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── hzitoun │ │ │ │ └── camera2SecretPictureTaker │ │ │ │ ├── listeners │ │ │ │ └── PictureCapturingListener.java │ │ │ │ ├── services │ │ │ │ ├── APictureCapturingService.java │ │ │ │ └── PictureCapturingServiceImpl.java │ │ │ │ └── activities │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── hzitoun │ │ │ └── camera2SecretPictureTaker │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── hzitoun │ │ └── camera2SecretPictureTaker │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── preview └── demo.png ├── .idea ├── copyright │ └── profiles_settings.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .travis.yml ├── gradle.properties ├── LICENSE ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /preview/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzitoun/android-camera2-secret-picture-taker/HEAD/preview/demo.png -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzitoun/android-camera2-secret-picture-taker/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzitoun/android-camera2-secret-picture-taker/HEAD/app/src/main/res/drawable/bg_shadow.9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzitoun/android-camera2-secret-picture-taker/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzitoun/android-camera2-secret-picture-taker/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzitoun/android-camera2-secret-picture-taker/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzitoun/android-camera2-secret-picture-taker/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzitoun/android-camera2-secret-picture-taker/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 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.14.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Camera 2 Secret Picture Taker 3 | Take photos 4 | Front Camera Picture 5 | Back Camera Picture 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/test/java/com/hzitoun/camera2SecretPictureTaker/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.hzitoun.camera2SecretPictureTaker; 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 | } -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.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 | # User-specific configurations 11 | .idea/libraries/ 12 | .idea/workspace.xml 13 | .idea/tasks.xml 14 | .idea/.name 15 | .idea/compiler.xml 16 | .idea/copyright/profiles_settings.xml 17 | .idea/encodings.xml 18 | .idea/misc.xml 19 | .idea/modules.xml 20 | .idea/scopes/scope_settings.xml 21 | .idea/dictionaries 22 | .idea/vcs.xml 23 | .idea/jsLibraryMappings.xml 24 | .idea/datasources.xml 25 | .idea/dataSources.ids 26 | .idea/sqlDataSources.xml 27 | .idea/dynamic.xml 28 | .idea/uiDesigner.xml 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | env: 4 | android: 5 | components: 6 | - tools 7 | - build-tools-25.0.2 8 | - android-25 9 | - platform-tools 10 | - extra-android-m2repository 11 | before_install: 12 | - chmod +x gradlew 13 | install: 14 | - echo y | android update sdk -u -a -t tools 15 | - echo y | android update sdk -u -a -t platform-tools 16 | - echo y | android update sdk -u -a -t build-tools-25.0.2 17 | - echo y | android update sdk -u -a -t android-25 18 | - echo y | android update sdk -u -a -t extra-google-m2repository 19 | - echo y | android update sdk -u -a -t extra-android-m2repository 20 | script: 21 | - ./gradlew assembleRelease 22 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /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:\Users\hamed\AppData\Local\Android\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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/hzitoun/camera2SecretPictureTaker/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.hzitoun.camera2SecretPictureTaker; 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 | * Instrumentation 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.hzitoun.camera2secretpicturetaker", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/hzitoun/camera2SecretPictureTaker/listeners/PictureCapturingListener.java: -------------------------------------------------------------------------------- 1 | package com.hzitoun.camera2SecretPictureTaker.listeners; 2 | 3 | import java.util.TreeMap; 4 | 5 | /** 6 | * Picture capturing listener 7 | * 8 | * @author hzitoun (zitoun.hamed@gmail.com) 9 | */ 10 | public interface PictureCapturingListener { 11 | 12 | /** 13 | * a callback called when we've done taking a picture from a single camera 14 | * (use this method if you don't want to wait for ALL taken pictures to be ready @see onDoneCapturingAllPhotos) 15 | * 16 | * @param pictureUrl taken picture's location on the device 17 | * @param pictureData taken picture's data as a byte array 18 | */ 19 | void onCaptureDone(String pictureUrl, byte[] pictureData); 20 | 21 | /** 22 | * a callback called when we've done taking pictures from ALL AVAILABLE cameras 23 | * OR when NO camera was detected on the device 24 | * 25 | * @param picturesTaken : a Map 26 | */ 27 | void onDoneCapturingAllPhotos(TreeMap picturesTaken); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Hamed ZITOUN 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 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.hzitoun.camera2secretpicturetaker" 8 | minSdkVersion 21 9 | targetSdkVersion 25 10 | versionCode 2 11 | versionName "1.0.1" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | jackOptions { 14 | enabled true 15 | } 16 | } 17 | compileOptions { 18 | sourceCompatibility JavaVersion.VERSION_1_8 19 | targetCompatibility JavaVersion.VERSION_1_8 20 | } 21 | buildTypes { 22 | release { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | } 28 | 29 | dependencies { 30 | compile fileTree(dir: 'libs', include: ['*.jar']) 31 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 32 | exclude group: 'com.android.support', module: 'support-annotations' 33 | }) 34 | compile 'com.android.support:appcompat-v7:25.1.0' 35 | testCompile 'junit:junit:4.12' 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/hzitoun/camera2SecretPictureTaker/services/APictureCapturingService.java: -------------------------------------------------------------------------------- 1 | package com.hzitoun.camera2SecretPictureTaker.services; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.hardware.camera2.CameraManager; 6 | import android.util.SparseIntArray; 7 | import android.view.Surface; 8 | 9 | import com.hzitoun.camera2SecretPictureTaker.listeners.PictureCapturingListener; 10 | 11 | /** 12 | * Abstract Picture Taking Service. 13 | * 14 | * @author hzitoun (zitoun.hamed@gmail.com) 15 | */ 16 | public abstract class APictureCapturingService { 17 | 18 | private static final SparseIntArray ORIENTATIONS = new SparseIntArray(); 19 | 20 | static { 21 | ORIENTATIONS.append(Surface.ROTATION_0, 90); 22 | ORIENTATIONS.append(Surface.ROTATION_90, 0); 23 | ORIENTATIONS.append(Surface.ROTATION_180, 270); 24 | ORIENTATIONS.append(Surface.ROTATION_270, 180); 25 | } 26 | 27 | private final Activity activity; 28 | final Context context; 29 | final CameraManager manager; 30 | 31 | /*** 32 | * constructor. 33 | * 34 | * @param activity the activity used to get display manager and the application context 35 | */ 36 | APictureCapturingService(final Activity activity) { 37 | this.activity = activity; 38 | this.context = activity.getApplicationContext(); 39 | this.manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); 40 | } 41 | 42 | /*** 43 | * @return orientation 44 | */ 45 | int getOrientation() { 46 | final int rotation = this.activity.getWindowManager().getDefaultDisplay().getRotation(); 47 | return ORIENTATIONS.get(rotation); 48 | } 49 | 50 | 51 | /** 52 | * starts pictures capturing process. 53 | * 54 | * @param listener picture capturing listener 55 | */ 56 | public abstract void startCapturing(final PictureCapturingListener listener); 57 | } 58 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 18 | 19 | 24 | 25 | 31 | 32 | 33 | 34 | 39 | 40 | 45 | 46 | 47 | 48 |