├── .gitignore
├── CameraModule
├── .gitignore
├── build.gradle
├── proguard-rules.txt
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ ├── squareup
│ │ └── picasso
│ │ │ └── PicassoTools.java
│ │ └── yalantis
│ │ └── cameramodule
│ │ ├── CameraConst.java
│ │ ├── ManagerInitializer.java
│ │ ├── activity
│ │ ├── BaseActivity.java
│ │ ├── BasePhotoActivity.java
│ │ ├── CameraActivity.java
│ │ ├── PhotoCropActivity.java
│ │ └── PhotoPreviewActivity.java
│ │ ├── adapters
│ │ ├── BaseListAdapter.java
│ │ └── ObjectToStringAdapter.java
│ │ ├── control
│ │ ├── CameraPreview.java
│ │ ├── PinchImageView.java
│ │ └── PreviewImageView.java
│ │ ├── fragment
│ │ ├── BaseDialogFragment.java
│ │ ├── BaseFragment.java
│ │ ├── CameraFragment.java
│ │ ├── CameraSettingsDialogFragment.java
│ │ ├── PhotoCropFragment.java
│ │ └── PhotoPreviewFragment.java
│ │ ├── interfaces
│ │ ├── CameraParamsChangedListener.java
│ │ ├── FocusCallback.java
│ │ ├── Initializer.java
│ │ ├── KeyEventsListener.java
│ │ ├── PhotoActionsCallback.java
│ │ ├── PhotoCroppedCallback.java
│ │ ├── PhotoSavedListener.java
│ │ ├── PhotoTakenCallback.java
│ │ ├── RawPhotoTakenCallback.java
│ │ └── StorageCallback.java
│ │ ├── manager
│ │ ├── ImageManager.java
│ │ ├── LoggerManager.java
│ │ └── SharedPrefManager.java
│ │ ├── model
│ │ ├── CachedValue.java
│ │ ├── FlashMode.java
│ │ ├── FocusMode.java
│ │ ├── HDRMode.java
│ │ ├── PictureSize.java
│ │ ├── Quality.java
│ │ └── Ratio.java
│ │ └── util
│ │ ├── CropPhotoTask.java
│ │ ├── ManagedTarget.java
│ │ ├── PhotoUtil.java
│ │ ├── RotatePhotoTask.java
│ │ ├── SavingBitmapTask.java
│ │ ├── SavingPhotoTask.java
│ │ └── ScaleTransformation.java
│ └── res
│ ├── drawable-hdpi
│ ├── ic_camera_capture.png
│ └── ic_camera_capture_pressed.png
│ ├── drawable-mdpi
│ ├── ic_camera_capture.png
│ └── ic_camera_capture_pressed.png
│ ├── drawable-xhdpi
│ ├── ic_camera_capture.png
│ └── ic_camera_capture_pressed.png
│ ├── drawable-xxhdpi
│ ├── cam_flash_auto_icn.png
│ ├── cam_flash_fill_flash_icn.png
│ ├── cam_flash_off_icn.png
│ ├── ic_camera_capture.png
│ └── ic_camera_capture_pressed.png
│ ├── drawable
│ ├── bg_transparent_clickable.xml
│ ├── camera_capture.xml
│ ├── input.9.png
│ ├── no_image.png
│ └── sheet_shadow.png
│ ├── layout
│ ├── activity_photo.xml
│ ├── activity_with_fragment.xml
│ ├── dialog_camera_params.xml
│ ├── fragment_camera.xml
│ ├── fragment_no_camera.xml
│ ├── fragment_photo_crop.xml
│ ├── fragment_photo_preview.xml
│ ├── object_to_string_dropdown_list_item.xml
│ └── object_to_string_list_item.xml
│ ├── menu
│ ├── photo_crop_options.xml
│ └── photo_preview_options.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.txt
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── yalantis
│ │ └── sample
│ │ ├── App.java
│ │ ├── Const.java
│ │ └── activity
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── layout
│ ├── activity_main.xml
│ └── fragment_camera_custom.xml
│ ├── menu
│ └── main.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # svn
2 | *.svn*
3 |
4 | # built application files
5 | *.apk
6 | *.ap_
7 |
8 | # files for the dex VM
9 | *.dex
10 |
11 | # Java class files
12 | *.class
13 |
14 | # generated GUI files
15 | */R.java
16 |
17 | # generated folder
18 | bin
19 | gen
20 |
21 | # local
22 | local.properties
23 | proguard.cfg
24 |
25 | # log files
26 | log*.txt
27 |
28 | # archives
29 | *.gz
30 | *.tar
31 | *.zip
32 |
33 | # eclipse
34 | *.metadata
35 | *.settings
36 |
37 | #idea
38 | *.idea
39 | *.iml
40 | out/
41 |
42 | #gradle
43 | /build
44 | .gradle/
--------------------------------------------------------------------------------
/CameraModule/.gitignore:
--------------------------------------------------------------------------------
1 | # svn
2 | *.svn*
3 |
4 | # built application files
5 | *.apk
6 | *.ap_
7 |
8 | # files for the dex VM
9 | *.dex
10 |
11 | # Java class files
12 | *.class
13 |
14 | # generated GUI files
15 | */R.java
16 |
17 | # generated folder
18 | bin
19 | gen
20 |
21 | # local
22 | local.properties
23 | proguard.cfg
24 |
25 | # log files
26 | log*.txt
27 |
28 | # archives
29 | *.gz
30 | *.tar
31 | *.zip
32 |
33 | # eclipse
34 | *.metadata
35 | *.settings
36 |
37 | #idea
38 | *.idea
39 | *.iml
40 | out/
41 |
42 | #gradle
43 | /build
44 | .gradle/
--------------------------------------------------------------------------------
/CameraModule/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | repositories {
4 | mavenCentral()
5 | }
6 |
7 | android {
8 | compileSdkVersion 19
9 | buildToolsVersion '19.1.0'
10 |
11 | defaultConfig {
12 | minSdkVersion 14
13 | targetSdkVersion 19
14 | versionCode 1
15 | versionName "1.0"
16 | }
17 |
18 | compileOptions {
19 | sourceCompatibility JavaVersion.VERSION_1_7
20 | targetCompatibility JavaVersion.VERSION_1_7
21 | }
22 | buildTypes {
23 | release {
24 | runProguard false
25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
26 | }
27 | }
28 | }
29 |
30 | dependencies {
31 | compile 'com.edmodo:cropper:1.0.1'
32 | compile 'com.squareup.picasso:picasso:2.2.0'
33 | compile 'com.jakewharton.timber:timber:2.2.2'
34 | compile fileTree(dir: 'libs', include: ['*.jar'])
35 | }
36 |
--------------------------------------------------------------------------------
/CameraModule/proguard-rules.txt:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:/androidsdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the ProGuard
5 | # include property in project.properties.
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 | #}
--------------------------------------------------------------------------------
/CameraModule/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
41 |
42 |
46 |
47 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/squareup/picasso/PicassoTools.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.squareup.picasso;
25 |
26 | public class PicassoTools {
27 |
28 | public static void clearCache(Picasso p) {
29 | p.cache.clear();
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/CameraConst.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule;
25 |
26 | public final class CameraConst {
27 |
28 | public static final boolean DEBUG = true;
29 |
30 | public static final int COMPRESS_QUALITY = 90;
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/ManagerInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule;
25 |
26 | import android.content.Context;
27 |
28 | import com.yalantis.cameramodule.interfaces.Initializer;
29 | import com.yalantis.cameramodule.manager.ImageManager;
30 | import com.yalantis.cameramodule.manager.LoggerManager;
31 | import com.yalantis.cameramodule.manager.SharedPrefManager;
32 |
33 | public enum ManagerInitializer implements Initializer {
34 | i;
35 |
36 | @Override
37 | public void init(Context context) {
38 | SharedPrefManager.i.init(context);
39 | LoggerManager.i.init(context);
40 | ImageManager.i.init(context);
41 | }
42 |
43 | @Override
44 | public void clear() {
45 | SharedPrefManager.i.clear();
46 | LoggerManager.i.clear();
47 | ImageManager.i.clear();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.activity;
25 |
26 | import android.app.Activity;
27 | import android.content.Context;
28 | import android.os.Bundle;
29 | import android.os.Handler;
30 | import android.os.Message;
31 | import android.view.MenuItem;
32 | import android.view.View;
33 | import android.view.inputmethod.InputMethodManager;
34 |
35 | public abstract class BaseActivity extends Activity {
36 |
37 | protected Handler handler;
38 |
39 | @Override
40 | public void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | handler = new Handler(new Handler.Callback() {
43 |
44 | @Override
45 | public boolean handleMessage(Message msg) {
46 | return BaseActivity.this.handleMessage(msg);
47 | }
48 | });
49 | }
50 |
51 | protected void hideKeyboard() {
52 | InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
53 | View view = this.getCurrentFocus();
54 | if (view != null) {
55 | if (inputManager != null) {
56 | inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
57 | }
58 | }
59 | }
60 |
61 | protected boolean handleMessage(Message msg) {
62 | return false;
63 | }
64 |
65 | protected void showActionBar() {
66 | if (getActionBar() != null) {
67 | getActionBar().show();
68 | }
69 | }
70 |
71 | protected void hideActionBar() {
72 | if (getActionBar() != null) {
73 | getActionBar().hide();
74 | }
75 | }
76 |
77 | public void showBack() {
78 | getActionBar().setDisplayShowHomeEnabled(false);
79 | getActionBar().setDisplayHomeAsUpEnabled(true);
80 | }
81 |
82 | public void hideBack() {
83 | getActionBar().setDisplayShowHomeEnabled(true);
84 | getActionBar().setDisplayHomeAsUpEnabled(false);
85 | }
86 |
87 | @Override
88 | public boolean onOptionsItemSelected(MenuItem menuItem) {
89 | switch (menuItem.getItemId()) {
90 | case android.R.id.home:
91 | super.onBackPressed();
92 | return true;
93 | }
94 | return super.onOptionsItemSelected(menuItem);
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/activity/BasePhotoActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.activity;
25 |
26 | import android.app.Fragment;
27 | import android.content.Intent;
28 | import android.graphics.Bitmap;
29 | import android.graphics.drawable.Drawable;
30 | import android.os.Bundle;
31 | import android.util.DisplayMetrics;
32 | import android.view.View;
33 |
34 | import com.squareup.picasso.Picasso;
35 | import com.squareup.picasso.Target;
36 | import com.yalantis.cameramodule.R;
37 | import com.yalantis.cameramodule.manager.ImageManager;
38 |
39 | public abstract class BasePhotoActivity extends BaseActivity {
40 |
41 | protected String path;
42 | protected String name;
43 | protected Bitmap bitmap;
44 |
45 | protected View progressBar;
46 |
47 | @Override
48 | public void onCreate(Bundle savedInstanceState) {
49 | super.onCreate(savedInstanceState);
50 | showActionBar();
51 | showBack();
52 | setContentView(R.layout.activity_photo);
53 |
54 | if (getIntent().hasExtra(EXTRAS.PATH)) {
55 | path = getIntent().getStringExtra(EXTRAS.PATH);
56 | } else {
57 | throw new RuntimeException("There is no path to image in extras");
58 | }
59 | if (getIntent().hasExtra(EXTRAS.NAME)) {
60 | name = getIntent().getStringExtra(EXTRAS.NAME);
61 | } else {
62 | throw new RuntimeException("There is no image name in extras");
63 | }
64 |
65 | progressBar = findViewById(R.id.progress);
66 |
67 | }
68 |
69 | @Override
70 | protected void onResume() {
71 | super.onResume();
72 | if (bitmap == null || bitmap.isRecycled()) {
73 | loadPhoto();
74 | }
75 | }
76 |
77 | protected abstract void showPhoto(Bitmap bitmap);
78 |
79 | protected void rotatePhoto(float angle) {
80 | synchronized (bitmap) {
81 | bitmap = ImageManager.i.rotatePhoto(path, angle);
82 | showPhoto(bitmap);
83 | }
84 | setResult(EXTRAS.RESULT_EDITED, setIntentData());
85 | }
86 |
87 | protected void deletePhoto() {
88 | setResult(EXTRAS.RESULT_DELETED, setIntentData());
89 | finish();
90 | }
91 |
92 | protected void loadPhoto() {
93 | DisplayMetrics metrics = new DisplayMetrics();
94 | getWindowManager().getDefaultDisplay().getMetrics(metrics);
95 | ImageManager.i.loadPhoto(path, metrics.widthPixels, metrics.heightPixels, loadingTarget);
96 | }
97 |
98 | protected void setFragment(Fragment fragment) {
99 | getFragmentManager()
100 | .beginTransaction()
101 | .replace(R.id.fragment_content, fragment)
102 | .commit();
103 | }
104 |
105 | private Target loadingTarget = new Target() {
106 |
107 | @Override
108 | public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
109 | progressBar.setVisibility(View.GONE);
110 | BasePhotoActivity.this.bitmap = bitmap;
111 | showPhoto(bitmap);
112 | }
113 |
114 | @Override
115 | public void onBitmapFailed(Drawable errorDrawable) {
116 | progressBar.setVisibility(View.GONE);
117 | bitmap = null;
118 | }
119 |
120 | @Override
121 | public void onPrepareLoad(Drawable placeHolderDrawable) {
122 | progressBar.setVisibility(View.VISIBLE);
123 | }
124 |
125 | };
126 |
127 | protected Intent setIntentData() {
128 | return setIntentData(null);
129 | }
130 |
131 | protected Intent setIntentData(Intent intent) {
132 | if (intent == null) {
133 | intent = new Intent();
134 | }
135 | intent.putExtra(EXTRAS.PATH, path);
136 | intent.putExtra(EXTRAS.NAME, name);
137 | return intent;
138 | }
139 |
140 | public static final class EXTRAS {
141 |
142 | public static final String PATH = "path";
143 |
144 | public static final String NAME = "name";
145 |
146 | public static final String FROM_CAMERA = "from_camera";
147 |
148 | public static final int REQUEST_PHOTO_EDIT = 7338;
149 |
150 | public static final int RESULT_EDITED = 338;
151 |
152 | public static final int RESULT_DELETED = 3583;
153 |
154 | }
155 |
156 | @Override
157 | public void onBackPressed() {
158 | super.onBackPressed();
159 | }
160 |
161 | }
162 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/activity/CameraActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.activity;
25 |
26 | import android.content.Intent;
27 | import android.media.ExifInterface;
28 | import android.os.Bundle;
29 | import android.os.Environment;
30 | import android.text.TextUtils;
31 | import android.view.KeyEvent;
32 | import android.widget.Toast;
33 | import com.yalantis.cameramodule.CameraConst;
34 | import com.yalantis.cameramodule.R;
35 | import com.yalantis.cameramodule.fragment.CameraFragment;
36 | import com.yalantis.cameramodule.interfaces.*;
37 | import com.yalantis.cameramodule.manager.SharedPrefManager;
38 | import com.yalantis.cameramodule.util.PhotoUtil;
39 | import com.yalantis.cameramodule.util.SavingPhotoTask;
40 | import timber.log.Timber;
41 |
42 | import java.io.IOException;
43 | import java.text.SimpleDateFormat;
44 | import java.util.Date;
45 |
46 | public class CameraActivity extends BaseActivity implements PhotoTakenCallback, PhotoSavedListener, RawPhotoTakenCallback,
47 | CameraParamsChangedListener {
48 |
49 | public static final String PATH = "path";
50 | public static final String USE_FRONT_CAMERA = "use_front_camera";
51 | public static final String OPEN_PHOTO_PREVIEW = "open_photo_preview";
52 | public static final String LAYOUT_ID = "layout_id";
53 |
54 | private static final String IMG_PREFIX = "IMG_";
55 | private static final String IMG_POSTFIX = ".jpg";
56 | private static final String TIME_FORMAT = "yyyyMMdd_HHmmss";
57 |
58 | private KeyEventsListener keyEventsListener;
59 | private PhotoSavedListener photoSavedListener;
60 |
61 | private String path;
62 | private boolean openPreview;
63 |
64 | private boolean saving;
65 |
66 | @Override
67 | public void onCreate(Bundle savedInstanceState) {
68 | super.onCreate(savedInstanceState);
69 | hideActionBar();
70 | setContentView(R.layout.activity_with_fragment);
71 | if (TextUtils.isEmpty(path = getIntent().getStringExtra(PATH))) {
72 | path = Environment.getExternalStorageDirectory().getPath();
73 | }
74 | openPreview = getIntent().getBooleanExtra(OPEN_PHOTO_PREVIEW, SharedPrefManager.i.isOpenPhotoPreview());
75 | if (openPreview != SharedPrefManager.i.isOpenPhotoPreview()) {
76 | SharedPrefManager.i.setOpenPhotoPreview(openPreview);
77 | }
78 | boolean useFrontCamera = getIntent().getBooleanExtra(USE_FRONT_CAMERA, SharedPrefManager.i.useFrontCamera());
79 | if (useFrontCamera != SharedPrefManager.i.useFrontCamera()) {
80 | SharedPrefManager.i.setUseFrontCamera(useFrontCamera);
81 | }
82 | init();
83 | }
84 |
85 | private void init() {
86 | CameraFragment fragment;
87 | int layoutId = getIntent().getIntExtra(LAYOUT_ID, -1);
88 | if (layoutId > 0) {
89 | fragment = CameraFragment.newInstance(layoutId, this, createCameraParams());
90 | } else {
91 | fragment = CameraFragment.newInstance(this, createCameraParams());
92 | }
93 | fragment.setParamsChangedListener(this);
94 | keyEventsListener = fragment;
95 | photoSavedListener = fragment;
96 | getFragmentManager()
97 | .beginTransaction()
98 | .replace(R.id.fragment_content, fragment)
99 | .commit();
100 | }
101 |
102 | private Bundle createCameraParams() {
103 | Bundle bundle = new Bundle();
104 |
105 | bundle.putInt(CameraFragment.RATIO, SharedPrefManager.i.getCameraRatio());
106 | bundle.putInt(CameraFragment.FLASH_MODE, SharedPrefManager.i.getCameraFlashMode());
107 | bundle.putInt(CameraFragment.HDR_MODE, SharedPrefManager.i.isHDR());
108 | bundle.putInt(CameraFragment.QUALITY, SharedPrefManager.i.getCameraQuality());
109 | bundle.putInt(CameraFragment.FOCUS_MODE, SharedPrefManager.i.getCameraFocusMode());
110 | bundle.putBoolean(CameraFragment.FRONT_CAMERA, SharedPrefManager.i.useFrontCamera());
111 |
112 | return bundle;
113 | }
114 |
115 | private String createName() {
116 | String timeStamp = new SimpleDateFormat(TIME_FORMAT).format(new Date());
117 | return IMG_PREFIX + timeStamp + IMG_POSTFIX;
118 | }
119 |
120 | @Override
121 | public void photoTaken(byte[] data, int orientation) {
122 | savePhoto(data, createName(), path, orientation);
123 | }
124 |
125 | @Override
126 | public void rawPhotoTaken(byte[] data) {
127 | Timber.d("rawPhotoTaken: data[%1d]", data.length);
128 | }
129 |
130 | private void savePhoto(byte[] data, String name, String path, int orientation) {
131 | saving = true;
132 | new SavingPhotoTask(data, name, path, orientation, this).execute();
133 | }
134 |
135 | @Override
136 | public void photoSaved(String path, String name) {
137 | saving = false;
138 | Toast.makeText(this, "Photo " + name + " saved", Toast.LENGTH_SHORT).show();
139 | Timber.d("Photo " + name + " saved");
140 | if (CameraConst.DEBUG) {
141 | printExifOrientation(path);
142 | }
143 | if (openPreview) {
144 | openPreview(path, name);
145 | }
146 | if (photoSavedListener != null) {
147 | photoSavedListener.photoSaved(path, name);
148 | }
149 | }
150 |
151 | private void openPreview(String path, String name) {
152 | Intent intent = new Intent(this, PhotoPreviewActivity.class);
153 | intent.putExtra(BasePhotoActivity.EXTRAS.PATH, path);
154 | intent.putExtra(BasePhotoActivity.EXTRAS.NAME, name);
155 | intent.putExtra(BasePhotoActivity.EXTRAS.FROM_CAMERA, true);
156 | startActivityForResult(intent, BasePhotoActivity.EXTRAS.REQUEST_PHOTO_EDIT);
157 | }
158 |
159 | @Override
160 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
161 | super.onActivityResult(requestCode, resultCode, data);
162 | if (requestCode == BasePhotoActivity.EXTRAS.REQUEST_PHOTO_EDIT) {
163 | switch (resultCode) {
164 | case BasePhotoActivity.EXTRAS.RESULT_DELETED:
165 | String path = data.getStringExtra(BasePhotoActivity.EXTRAS.PATH);
166 | PhotoUtil.deletePhoto(path);
167 | break;
168 | }
169 | }
170 | }
171 |
172 | private void printExifOrientation(String path) {
173 | try {
174 | ExifInterface exif = new ExifInterface(path);
175 | int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
176 | Timber.d("Orientation: " + orientation);
177 | } catch (IOException e) {
178 | Timber.e(e, e.getMessage());
179 | }
180 | }
181 |
182 | @Override
183 | public boolean onKeyDown(int keyCode, KeyEvent event) {
184 | switch (keyCode) {
185 | case KeyEvent.KEYCODE_VOLUME_UP:
186 | keyEventsListener.zoomIn();
187 | return true;
188 | case KeyEvent.KEYCODE_VOLUME_DOWN:
189 | keyEventsListener.zoomOut();
190 | return true;
191 | case KeyEvent.KEYCODE_BACK:
192 | onBackPressed();
193 | return true;
194 | case KeyEvent.KEYCODE_CAMERA:
195 | keyEventsListener.takePhoto();
196 | return true;
197 | }
198 | return false;
199 | }
200 |
201 | @Override
202 | public void onQualityChanged(int id) {
203 | SharedPrefManager.i.setCameraQuality(id);
204 | }
205 |
206 | @Override
207 | public void onRatioChanged(int id) {
208 | SharedPrefManager.i.setCameraRatio(id);
209 | }
210 |
211 | @Override
212 | public void onFlashModeChanged(int id) {
213 | SharedPrefManager.i.setCameraFlashMode(id);
214 | }
215 |
216 | @Override
217 | public void onHDRChanged(int id) {
218 | SharedPrefManager.i.setHDRMode(id);
219 | }
220 |
221 | @Override
222 | public void onFocusModeChanged(int id) {
223 | SharedPrefManager.i.setCameraFocusMode(id);
224 | }
225 |
226 | @Override
227 | public void onBackPressed() {
228 | if (!saving) {
229 | super.onBackPressed();
230 | }
231 | }
232 |
233 | }
234 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/activity/PhotoCropActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.activity;
25 |
26 | import android.graphics.Bitmap;
27 | import android.graphics.RectF;
28 | import android.view.Menu;
29 | import android.view.MenuInflater;
30 | import android.view.MenuItem;
31 |
32 | import com.yalantis.cameramodule.R;
33 | import com.yalantis.cameramodule.fragment.PhotoCropFragment;
34 | import com.yalantis.cameramodule.interfaces.PhotoCroppedCallback;
35 | import com.yalantis.cameramodule.interfaces.PhotoSavedListener;
36 | import com.yalantis.cameramodule.manager.ImageManager;
37 |
38 | public class PhotoCropActivity extends BasePhotoActivity implements PhotoCroppedCallback {
39 |
40 | private PhotoCropFragment cropFragment;
41 |
42 | @Override
43 | public boolean onCreateOptionsMenu(Menu menu) {
44 | MenuInflater inflater = getMenuInflater();
45 | inflater.inflate(R.menu.photo_crop_options, menu);
46 | return super.onCreateOptionsMenu(menu);
47 | }
48 |
49 | public void apply(MenuItem ite) {
50 | cropFragment.applyCrop();
51 | }
52 |
53 | public void cancel(MenuItem ite) {
54 | finish();
55 | }
56 |
57 | @Override
58 | protected void showPhoto(Bitmap bitmap) {
59 | if (cropFragment == null) {
60 | cropFragment = PhotoCropFragment.newInstance(bitmap);
61 | setFragment(cropFragment);
62 | } else {
63 | cropFragment.setBitmap(bitmap);
64 | }
65 | }
66 |
67 | @Override
68 | public void onPhotoCropped(int width, int height, Bitmap croppedBitmap, RectF cropRect) {
69 | ImageManager.i.cropBitmap(path, width, height, croppedBitmap, cropRect, new PhotoSavedListener() {
70 |
71 | @Override
72 | public void photoSaved(String path, String name) {
73 | setResult(EXTRAS.RESULT_EDITED, setIntentData());
74 | finish();
75 | }
76 | });
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/activity/PhotoPreviewActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.activity;
25 |
26 | import android.content.Intent;
27 | import android.graphics.Bitmap;
28 | import android.os.Bundle;
29 | import android.view.Menu;
30 | import android.view.MenuInflater;
31 | import android.view.MenuItem;
32 |
33 | import com.yalantis.cameramodule.R;
34 | import com.yalantis.cameramodule.fragment.PhotoPreviewFragment;
35 |
36 | public class PhotoPreviewActivity extends BasePhotoActivity {
37 |
38 | private PhotoPreviewFragment previewFragment;
39 |
40 | @Override
41 | public void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | if (getIntent().getBooleanExtra(EXTRAS.FROM_CAMERA, false)) {
44 | setTitle(R.string.lbl_take_another);
45 | }
46 | }
47 |
48 | @Override
49 | public boolean onCreateOptionsMenu(Menu menu) {
50 | MenuInflater inflater = getMenuInflater();
51 | inflater.inflate(R.menu.photo_preview_options, menu);
52 | return super.onCreateOptionsMenu(menu);
53 | }
54 |
55 | public void deletePhoto(MenuItem item) {
56 | deletePhoto();
57 | }
58 |
59 | public void rotateLeft(MenuItem item) {
60 | rotatePhoto(-90);
61 | }
62 |
63 | public void rotateRight(MenuItem item) {
64 | rotatePhoto(90);
65 | }
66 |
67 | public void openPhotoCropper(MenuItem item) {
68 | Intent intent = new Intent(this, PhotoCropActivity.class);
69 | startActivityForResult(setIntentData(intent), EXTRAS.REQUEST_PHOTO_EDIT);
70 | }
71 |
72 | @Override
73 | protected void showPhoto(Bitmap bitmap) {
74 | if (previewFragment == null) {
75 | previewFragment = PhotoPreviewFragment.newInstance(bitmap);
76 | setFragment(previewFragment);
77 | } else {
78 | previewFragment.setBitmap(bitmap);
79 | }
80 | }
81 |
82 | @Override
83 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
84 | super.onActivityResult(requestCode, resultCode, data);
85 | if (requestCode == EXTRAS.REQUEST_PHOTO_EDIT) {
86 | if (resultCode == EXTRAS.RESULT_EDITED) {
87 | setResult(EXTRAS.RESULT_EDITED, setIntentData());
88 | loadPhoto();
89 | }
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/adapters/BaseListAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.adapters;
25 |
26 | import java.util.List;
27 |
28 | import android.content.Context;
29 | import android.content.res.Resources;
30 | import android.view.LayoutInflater;
31 | import android.view.View;
32 | import android.widget.BaseAdapter;
33 |
34 | public abstract class BaseListAdapter extends BaseAdapter {
35 |
36 | private Context mContext;
37 | private List mList;
38 | private int mLayoutId;
39 |
40 | public BaseListAdapter(Context context, List list, int layout) {
41 | mContext = context;
42 | setList(list);
43 | mLayoutId = layout;
44 | }
45 |
46 | @Override
47 | public int getCount() {
48 | if (mList != null) {
49 | return mList.size();
50 | }
51 | return 0;
52 | }
53 |
54 | public void addItems(List items) {
55 | mList.addAll(items);
56 | notifyDataSetChanged();
57 | }
58 |
59 | public void addItem(T type) {
60 | mList.add(type);
61 | notifyDataSetChanged();
62 | }
63 |
64 | @Override
65 | public T getItem(int position) {
66 | return position >= 0 && position < mList.size() ? mList.get(position) : null;
67 | }
68 |
69 | @Override
70 | public long getItemId(int position) {
71 | return position;
72 | }
73 |
74 | public Context getContext() {
75 | return mContext;
76 | }
77 |
78 | public Resources getResources() {
79 | return getContext().getResources();
80 | }
81 |
82 | public List getList() {
83 | return mList;
84 | }
85 |
86 | public void setList(List list) {
87 | this.mList = list;
88 | }
89 |
90 | public void removeItem(int position) {
91 | mList.remove(position);
92 | notifyDataSetChanged();
93 | }
94 |
95 | public View getLayout() {
96 | return getInflater().inflate(getLayoutId(), null);
97 | }
98 |
99 | public int getLayoutId() {
100 | return mLayoutId;
101 | }
102 |
103 | public LayoutInflater getInflater() {
104 | return LayoutInflater.from(mContext);
105 | }
106 |
107 | public void clear() {
108 | mList.clear();
109 | notifyDataSetChanged();
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/adapters/ObjectToStringAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.adapters;
25 |
26 | import java.util.List;
27 |
28 | import android.content.Context;
29 | import android.view.View;
30 | import android.view.ViewGroup;
31 | import android.widget.TextView;
32 |
33 | import com.yalantis.cameramodule.R;
34 |
35 | public class ObjectToStringAdapter extends BaseListAdapter {
36 |
37 | public ObjectToStringAdapter(Context context, List list) {
38 | super(context, list, R.layout.object_to_string_list_item);
39 | }
40 |
41 | @Override
42 | public View getView(int position, View convertView, ViewGroup parent) {
43 | return createView(position, convertView, false);
44 | }
45 |
46 | @Override
47 | public View getDropDownView(int position, View convertView, ViewGroup parent) {
48 | return createView(position, convertView, true);
49 | }
50 |
51 | private View createView(int position, View convertView, boolean dropDown) {
52 | ViewHolder holder;
53 |
54 | if (convertView == null) {
55 | if (dropDown) {
56 | convertView = getDropDownLayout();
57 | } else {
58 | convertView = getLayout();
59 | }
60 | holder = new ViewHolder();
61 | holder.text = (TextView) convertView.findViewById(R.id.title);
62 |
63 | convertView.setTag(holder);
64 | } else {
65 | holder = (ViewHolder) convertView.getTag();
66 | }
67 |
68 | T item = getItem(position);
69 | if (item != null) {
70 | holder.text.setText(item.toString());
71 | }
72 |
73 | return convertView;
74 | }
75 |
76 | public View getDropDownLayout() {
77 | return getInflater().inflate(R.layout.object_to_string_dropdown_list_item, null);
78 | }
79 |
80 | class ViewHolder {
81 |
82 | TextView text;
83 |
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/control/PreviewImageView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.control;
25 |
26 | import android.content.Context;
27 | import android.util.AttributeSet;
28 | import android.widget.ImageView;
29 |
30 | public class PreviewImageView extends ImageView {
31 |
32 | public PreviewImageView(Context context) {
33 | super(context);
34 | }
35 |
36 | public PreviewImageView(Context context, AttributeSet attrs) {
37 | super(context, attrs);
38 | }
39 |
40 | @Override
41 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
42 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
43 | setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight());
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/fragment/BaseDialogFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.fragment;
25 |
26 | import android.app.Activity;
27 | import android.app.Dialog;
28 | import android.app.DialogFragment;
29 | import android.app.FragmentManager;
30 | import android.graphics.drawable.ColorDrawable;
31 | import android.os.Bundle;
32 | import android.view.Window;
33 |
34 | public abstract class BaseDialogFragment extends DialogFragment {
35 |
36 | protected Activity activity;
37 |
38 | @Override
39 | public Dialog onCreateDialog(Bundle savedInstanceState) {
40 | Dialog dialog = super.onCreateDialog(savedInstanceState);
41 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
42 | dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
43 | return dialog;
44 | }
45 |
46 | @Override
47 | public void onAttach(Activity activity) {
48 | super.onAttach(activity);
49 | this.activity = activity;
50 | }
51 |
52 | public abstract String getFragmentTag();
53 |
54 | public void show(FragmentManager manager) {
55 | super.show(manager, getFragmentTag());
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.fragment;
25 |
26 | import android.app.Activity;
27 | import android.app.Fragment;
28 | import android.os.Bundle;
29 | import android.os.Handler;
30 |
31 | public class BaseFragment extends Fragment {
32 |
33 | private Handler handler;
34 | protected Activity activity;
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | handler = new Handler();
40 | }
41 |
42 | @Override
43 | public void onAttach(Activity activity) {
44 | super.onAttach(activity);
45 | this.activity = activity;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/fragment/CameraSettingsDialogFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.fragment;
25 |
26 | import android.os.Bundle;
27 | import android.view.LayoutInflater;
28 | import android.view.View;
29 | import android.view.ViewGroup;
30 | import android.widget.AdapterView;
31 | import android.widget.CompoundButton;
32 | import android.widget.Spinner;
33 | import android.widget.Switch;
34 | import com.yalantis.cameramodule.R;
35 | import com.yalantis.cameramodule.adapters.ObjectToStringAdapter;
36 | import com.yalantis.cameramodule.interfaces.CameraParamsChangedListener;
37 | import com.yalantis.cameramodule.model.FocusMode;
38 | import com.yalantis.cameramodule.model.HDRMode;
39 | import com.yalantis.cameramodule.model.Quality;
40 | import com.yalantis.cameramodule.model.Ratio;
41 |
42 | import java.util.Arrays;
43 | import java.util.List;
44 |
45 | public class CameraSettingsDialogFragment extends BaseDialogFragment {
46 |
47 | public static final String TAG = CameraSettingsDialogFragment.class.getSimpleName();
48 |
49 | private CameraParamsChangedListener paramsChangedListener;
50 |
51 | private Quality quality;
52 | private Ratio ratio;
53 | private FocusMode focusMode;
54 | private HDRMode hdrMode;
55 | private List ratios = Arrays.asList(Ratio.values());
56 | private List qualities = Arrays.asList(Quality.values());
57 | private List focusModes = Arrays.asList(FocusMode.values());
58 |
59 | public static CameraSettingsDialogFragment newInstance(Bundle bundle, CameraParamsChangedListener listener) {
60 | CameraSettingsDialogFragment fragment = new CameraSettingsDialogFragment();
61 | fragment.setArguments(bundle);
62 | fragment.paramsChangedListener = listener;
63 | return fragment;
64 | }
65 |
66 | @Override
67 | public void onCreate(Bundle savedInstanceState) {
68 | super.onCreate(savedInstanceState);
69 | expandParams(getArguments());
70 | }
71 |
72 | private void expandParams(Bundle params) {
73 | if (params == null) {
74 | params = new Bundle();
75 | }
76 | int id = 0;
77 | if (params.containsKey(CameraFragment.QUALITY)) {
78 | id = params.getInt(CameraFragment.QUALITY, 0);
79 | }
80 | quality = Quality.getQualityById(id);
81 | id = 0;
82 | if (params.containsKey(CameraFragment.RATIO)) {
83 | id = params.getInt(CameraFragment.RATIO, 0);
84 | }
85 | ratio = Ratio.getRatioById(id);
86 | id = 0;
87 | if (params.containsKey(CameraFragment.FOCUS_MODE)) {
88 | id = params.getInt(CameraFragment.FOCUS_MODE);
89 | }
90 | focusMode = FocusMode.getFocusModeById(id);
91 | id = 0;
92 | if (params.containsKey(CameraFragment.HDR_MODE)) {
93 | id = params.getInt(CameraFragment.HDR_MODE);
94 | }
95 | hdrMode = HDRMode.getHDRModeById(id);
96 | }
97 |
98 | @Override
99 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
100 | View view = inflater.inflate(R.layout.dialog_camera_params, container, false);
101 |
102 | Spinner ratioSwitcher = (Spinner) view.findViewById(R.id.ratios);
103 | ratioSwitcher.setAdapter(new ObjectToStringAdapter<>(activity, ratios));
104 | ratioSwitcher.setSelection(ratios.indexOf(ratio));
105 | ratioSwitcher.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
106 |
107 | @Override
108 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
109 | if (ratio == ratios.get(position)) {
110 | return;
111 | }
112 | ratio = ratios.get(position);
113 | onRatioChanged(ratio.getId());
114 | }
115 |
116 | @Override
117 | public void onNothingSelected(AdapterView> parent) {
118 | }
119 | });
120 |
121 | Spinner qualitySwitcher = (Spinner) view.findViewById(R.id.qualities);
122 | qualitySwitcher.setAdapter(new ObjectToStringAdapter<>(activity, qualities));
123 | qualitySwitcher.setSelection(qualities.indexOf(quality));
124 | qualitySwitcher.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
125 |
126 | @Override
127 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
128 | if (quality == qualities.get(position)) {
129 | return;
130 | }
131 | quality = qualities.get(position);
132 | onQualityChanged(quality.getId());
133 | }
134 |
135 | @Override
136 | public void onNothingSelected(AdapterView> parent) {
137 | }
138 | });
139 |
140 | Spinner focusSwitcher = (Spinner) view.findViewById(R.id.focus_modes);
141 | focusSwitcher.setAdapter(new ObjectToStringAdapter<>(activity, focusModes));
142 | focusSwitcher.setSelection(focusModes.indexOf(focusMode));
143 | focusSwitcher.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
144 |
145 | @Override
146 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
147 | if (focusMode == focusModes.get(position)) {
148 | return;
149 | }
150 | focusMode = focusModes.get(position);
151 | onFocusModeChanged(focusMode.getId());
152 | }
153 |
154 | @Override
155 | public void onNothingSelected(AdapterView> parent) {
156 | }
157 | });
158 | if (hdrMode == HDRMode.NONE) {
159 | view.findViewById(R.id.relativeHdr).setVisibility(View.GONE);
160 | } else {
161 | view.findViewById(R.id.relativeHdr).setVisibility(View.VISIBLE);
162 | Switch hdrSwitch = (Switch) view.findViewById(R.id.switchHDR);
163 | hdrSwitch.setChecked(hdrMode == HDRMode.ON);
164 | hdrSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
165 |
166 | @Override
167 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
168 | onHDRChanged(isChecked ? HDRMode.ON.getId() : HDRMode.OFF.getId());
169 | }
170 | });
171 | }
172 |
173 | view.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
174 |
175 | @Override
176 | public void onClick(View v) {
177 | dismiss();
178 | }
179 |
180 | });
181 |
182 | return view;
183 | }
184 |
185 | public void onQualityChanged(int id) {
186 | if (paramsChangedListener != null) {
187 | paramsChangedListener.onQualityChanged(id);
188 | }
189 | }
190 |
191 | public void onHDRChanged(int id) {
192 | if (paramsChangedListener != null) {
193 | paramsChangedListener.onHDRChanged(id);
194 | }
195 | }
196 |
197 | public void onRatioChanged(int id) {
198 | if (paramsChangedListener != null) {
199 | paramsChangedListener.onRatioChanged(id);
200 | }
201 | }
202 |
203 | public void onFocusModeChanged(int id) {
204 | if (paramsChangedListener != null) {
205 | paramsChangedListener.onFocusModeChanged(id);
206 | }
207 | }
208 |
209 | @Override
210 | public String getFragmentTag() {
211 | return TAG;
212 | }
213 |
214 | }
215 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/fragment/PhotoCropFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.fragment;
25 |
26 | import android.app.Activity;
27 | import android.graphics.Bitmap;
28 | import android.os.Bundle;
29 | import android.view.LayoutInflater;
30 | import android.view.View;
31 | import android.view.ViewGroup;
32 |
33 | import com.edmodo.cropper.CropImageView;
34 | import com.yalantis.cameramodule.R;
35 | import com.yalantis.cameramodule.interfaces.PhotoCroppedCallback;
36 |
37 | public class PhotoCropFragment extends BaseFragment {
38 |
39 | private Bitmap bitmap;
40 | private CropImageView cropView;
41 |
42 | private PhotoCroppedCallback callback;
43 |
44 | public static PhotoCropFragment newInstance(Bitmap bitmap) {
45 | PhotoCropFragment fragment = new PhotoCropFragment();
46 | fragment.bitmap = bitmap;
47 |
48 | return fragment;
49 | }
50 |
51 | @Override
52 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
53 | return inflater.inflate(R.layout.fragment_photo_crop, container, false);
54 | }
55 |
56 | @Override
57 | public void onViewCreated(final View view, Bundle savedInstanceState) {
58 | super.onViewCreated(view, savedInstanceState);
59 |
60 | cropView = (CropImageView) view.findViewById(R.id.photo);
61 | cropView.setImageBitmap(bitmap);
62 | }
63 |
64 | @Override
65 | public void onAttach(Activity activity) {
66 | super.onAttach(activity);
67 | if (activity instanceof PhotoCroppedCallback) {
68 | callback = (PhotoCroppedCallback) activity;
69 | } else {
70 | throw new RuntimeException(activity.getClass().getName() + " must implement " + PhotoCroppedCallback.class.getName());
71 | }
72 | }
73 |
74 | public void setBitmap(Bitmap bitmap) {
75 | this.bitmap = bitmap;
76 | cropView.setImageBitmap(bitmap);
77 | }
78 |
79 | public void applyCrop() {
80 | callback.onPhotoCropped(bitmap.getWidth(), bitmap.getHeight(), cropView.getCroppedImage(), cropView.getActualCropRect());
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/fragment/PhotoPreviewFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.fragment;
25 |
26 | import android.graphics.Bitmap;
27 | import android.os.Bundle;
28 | import android.view.LayoutInflater;
29 | import android.view.View;
30 | import android.view.ViewGroup;
31 |
32 | import com.yalantis.cameramodule.R;
33 | import com.yalantis.cameramodule.control.PinchImageView;
34 |
35 | public class PhotoPreviewFragment extends BaseFragment {
36 |
37 | private Bitmap bitmap;
38 | private PinchImageView imageView;
39 |
40 | public static PhotoPreviewFragment newInstance(Bitmap bitmap) {
41 | PhotoPreviewFragment fragment = new PhotoPreviewFragment();
42 | fragment.bitmap = bitmap;
43 |
44 | return fragment;
45 | }
46 |
47 | @Override
48 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
49 | return inflater.inflate(R.layout.fragment_photo_preview, container, false);
50 | }
51 |
52 | @Override
53 | public void onViewCreated(final View view, Bundle savedInstanceState) {
54 | super.onViewCreated(view, savedInstanceState);
55 |
56 | imageView = (PinchImageView) view.findViewById(R.id.photo);
57 |
58 | if (bitmap != null && !bitmap.isRecycled()) {
59 | imageView.setImageBitmap(bitmap);
60 | } else {
61 | imageView.setImageResource(R.drawable.no_image);
62 | }
63 | }
64 |
65 | public void setBitmap(Bitmap bitmap) {
66 | this.bitmap = bitmap;
67 | imageView.setImageBitmap(bitmap);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/CameraParamsChangedListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | public interface CameraParamsChangedListener {
27 |
28 | public void onQualityChanged(int id);
29 |
30 | public void onRatioChanged(int id);
31 |
32 | public void onFlashModeChanged(int id);
33 |
34 | public void onHDRChanged(int id);
35 |
36 | public void onFocusModeChanged(int id);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/FocusCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | import android.hardware.Camera;
27 |
28 | public interface FocusCallback {
29 |
30 | public void onFocused(Camera camera);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/Initializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | import android.content.Context;
27 |
28 | public interface Initializer {
29 |
30 | public void init(Context context);
31 |
32 | public void clear();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/KeyEventsListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | public interface KeyEventsListener {
27 |
28 | public void zoomIn();
29 |
30 | public void zoomOut();
31 |
32 | public void takePhoto();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/PhotoActionsCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | public interface PhotoActionsCallback {
27 |
28 | public void onOpenPhotoPreview(String path, String name);
29 |
30 | public void onAddNote(int zpid, String name);
31 |
32 | public void onRetake(String name);
33 |
34 | public void onDeletePhoto(String name);
35 |
36 | public void onDeleteHomePhotos(int zpid);
37 |
38 | public void onDeleteAddressPhotos(String address);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/PhotoCroppedCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | import android.graphics.Bitmap;
27 | import android.graphics.RectF;
28 |
29 | public interface PhotoCroppedCallback {
30 |
31 | /**
32 | * @param width
33 | * width before crop
34 | * @param height
35 | * height before crop
36 | * @param croppedBitmap
37 | * cropped bitmap
38 | * @param cropRect
39 | * cropping rectangle
40 | */
41 | public void onPhotoCropped(int width, int height, Bitmap croppedBitmap, RectF cropRect);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/PhotoSavedListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | public interface PhotoSavedListener {
27 |
28 | public void photoSaved(String path, String name);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/PhotoTakenCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | public interface PhotoTakenCallback {
27 |
28 | public void photoTaken(byte[] data, int orientation);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/RawPhotoTakenCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | public interface RawPhotoTakenCallback {
27 |
28 | public void rawPhotoTaken(byte[] data);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/interfaces/StorageCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.interfaces;
25 |
26 | import android.graphics.Bitmap;
27 |
28 | import com.yalantis.cameramodule.util.ManagedTarget;
29 |
30 | public interface StorageCallback {
31 |
32 | public void setBitmap(String path, Bitmap bitmap);
33 |
34 | public void addTarget(ManagedTarget target);
35 |
36 | public void removeTarget(ManagedTarget target);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/manager/ImageManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.manager;
25 |
26 | import java.io.File;
27 | import java.lang.ref.WeakReference;
28 | import java.util.HashMap;
29 | import java.util.HashSet;
30 | import java.util.Map;
31 |
32 | import android.content.Context;
33 | import android.graphics.Bitmap;
34 | import android.graphics.Matrix;
35 | import android.graphics.RectF;
36 | import android.text.TextUtils;
37 |
38 | import com.squareup.picasso.Picasso;
39 | import com.squareup.picasso.PicassoTools;
40 | import com.squareup.picasso.Target;
41 | import com.yalantis.cameramodule.interfaces.Initializer;
42 | import com.yalantis.cameramodule.interfaces.PhotoSavedListener;
43 | import com.yalantis.cameramodule.interfaces.StorageCallback;
44 | import com.yalantis.cameramodule.util.CropPhotoTask;
45 | import com.yalantis.cameramodule.util.ManagedTarget;
46 | import com.yalantis.cameramodule.util.RotatePhotoTask;
47 | import com.yalantis.cameramodule.util.ScaleTransformation;
48 |
49 | public enum ImageManager implements Initializer, StorageCallback {
50 | i;
51 |
52 | private Context context;
53 | private Picasso picasso;
54 |
55 | private HashSet targets;
56 | private Map> bitmapMap;
57 |
58 | @Override
59 | public void init(Context context) {
60 | this.context = context;
61 | this.picasso = Picasso.with(context);
62 | bitmapMap = new HashMap<>();
63 | targets = new HashSet<>();
64 | }
65 |
66 | public void loadPhoto(String path, int width, int height, Target target) {
67 | File photo = !TextUtils.isEmpty(path) ? new File(path) : null;
68 | if (path == null) {
69 | target.onBitmapFailed(null);
70 | }
71 | Bitmap bitmap = getBitmap(path);
72 | if (bitmap != null && !bitmap.isRecycled()) {
73 | target.onBitmapLoaded(bitmap, Picasso.LoadedFrom.MEMORY);
74 | } else {
75 | ManagedTarget managedTarget = new ManagedTarget(target, path, this);
76 | Picasso.with(context)
77 | .load(photo)
78 | .skipMemoryCache()
79 | .config(Bitmap.Config.ARGB_8888)
80 | .transform(new ScaleTransformation(width, height))
81 | .into(managedTarget);
82 | }
83 | }
84 |
85 | public void cropBitmap(String path, int width, int height, Bitmap croppedBitmap, RectF rect, PhotoSavedListener callback) {
86 | setBitmap(path, croppedBitmap);
87 | new CropPhotoTask(path, width, height, rect, callback).execute();
88 | }
89 |
90 | public Bitmap rotatePhoto(String path, float angle) {
91 | Bitmap bitmap = getBitmap(path);
92 | if (bitmap != null && !bitmap.isRecycled()) {
93 | Matrix matrix = new Matrix();
94 | matrix.postRotate(angle);
95 | bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
96 | }
97 | setBitmap(path, bitmap);
98 | new RotatePhotoTask(path, angle, null).execute();
99 |
100 | return bitmap;
101 | }
102 |
103 | private Bitmap getBitmap(String path) {
104 | return bitmapMap.get(path) != null ? bitmapMap.get(path).get() : null;
105 | }
106 |
107 | @Override
108 | public void clear() {
109 | synchronized (bitmapMap) {
110 | for (WeakReference reference : bitmapMap.values()) {
111 | if (reference != null) {
112 | Bitmap bitmap = reference.get();
113 | if (bitmap != null && !bitmap.isRecycled()) {
114 | bitmap.recycle();
115 | }
116 | }
117 | }
118 | bitmapMap.clear();
119 | }
120 | PicassoTools.clearCache(picasso);
121 | }
122 |
123 | @Override
124 | public void setBitmap(String path, Bitmap bitmap) {
125 | bitmapMap.put(path, new WeakReference<>(bitmap));
126 | }
127 |
128 | @Override
129 | public void addTarget(ManagedTarget target) {
130 | removeTarget(target);
131 | targets.add(target);
132 | }
133 |
134 | @Override
135 | public void removeTarget(ManagedTarget target) {
136 | if (targets.contains(target)) {
137 | targets.remove(target);
138 | }
139 | }
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/manager/LoggerManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.manager;
25 |
26 | import timber.log.Timber;
27 | import android.content.Context;
28 |
29 | import com.yalantis.cameramodule.CameraConst;
30 | import com.yalantis.cameramodule.interfaces.Initializer;
31 |
32 | public enum LoggerManager implements Initializer {
33 | i;
34 |
35 | private Context context;
36 |
37 | @Override
38 | public void init(Context context) {
39 | this.context = context;
40 | if (CameraConst.DEBUG) {
41 | Timber.plant(new Timber.DebugTree());
42 | } else {
43 | Timber.plant(new CrashReportingTree());
44 | }
45 | }
46 |
47 | /** A tree which logs important information for crash reporting. */
48 | private static class CrashReportingTree extends Timber.DebugTree {
49 |
50 | @Override
51 | public void d(String message, Object... args) {
52 | }
53 |
54 | @Override
55 | public void d(Throwable t, String message, Object... args) {
56 | }
57 |
58 | @Override
59 | public void i(String message, Object... args) {
60 | }
61 |
62 | @Override
63 | public void i(Throwable t, String message, Object... args) {
64 | }
65 |
66 | @Override
67 | public void w(String message, Object... args) {
68 | }
69 |
70 | @Override
71 | public void w(Throwable t, String message, Object... args) {
72 | }
73 |
74 | @Override
75 | public void e(String message, Object... args) {
76 | super.e(message, args);
77 | }
78 |
79 | @Override
80 | public void e(Throwable t, String message, Object... args) {
81 | super.e(t, message, args);
82 | }
83 | }
84 |
85 | @Override
86 | public void clear() {
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/manager/SharedPrefManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.manager;
25 |
26 | import java.util.HashSet;
27 | import java.util.Set;
28 |
29 | import android.content.Context;
30 | import android.content.SharedPreferences;
31 |
32 | import com.yalantis.cameramodule.interfaces.Initializer;
33 | import com.yalantis.cameramodule.model.CachedValue;
34 |
35 | public enum SharedPrefManager implements Initializer {
36 | i;
37 |
38 | private static final String NAME = "sharedPrefs";
39 |
40 | public static final String OPEN_PHOTO_PREVIEW = "open_photo_preview";
41 | public static final String CAMERA_RATIO = "camera_ratio";
42 | public static final String CAMERA_QUALITY = "camera_quality";
43 | public static final String CAMERA_FLASH_MODE = "camera_flash_mode";
44 | public static final String CAMERA_HDR_MODE = "camera_hdr_mode";
45 | public static final String CAMERA_FOCUS_MODE = "camera_focus_mode";
46 | public static final String USE_FRONT_CAMERA = "use_front_camera";
47 |
48 | private static SharedPreferences sp;
49 |
50 | private Set cachedValues;
51 |
52 | private CachedValue openPhotoPreview;
53 | private CachedValue cameraRatio;
54 | private CachedValue cameraQuality;
55 | private CachedValue cameraFlashMode;
56 | private CachedValue isCameraHDRMode;
57 | private CachedValue cameraFocusMode;
58 | private CachedValue useFrontCamera;
59 |
60 | @Override
61 | public void init(Context context) {
62 | sp = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
63 | CachedValue.initialize(sp);
64 | cachedValues = new HashSet<>();
65 | cachedValues.add(openPhotoPreview = new CachedValue<>(OPEN_PHOTO_PREVIEW, true, Boolean.class));
66 | cachedValues.add(isCameraHDRMode = new CachedValue<>(CAMERA_HDR_MODE, 0, Integer.class));
67 | cachedValues.add(cameraRatio = new CachedValue<>(CAMERA_RATIO, 0, Integer.class));
68 | cachedValues.add(cameraQuality = new CachedValue<>(CAMERA_QUALITY, 0, Integer.class));
69 | cachedValues.add(cameraFlashMode = new CachedValue<>(CAMERA_FLASH_MODE, 0, Integer.class));
70 | cachedValues.add(cameraFocusMode = new CachedValue<>(CAMERA_FOCUS_MODE, 0, Integer.class));
71 | cachedValues.add(useFrontCamera = new CachedValue<>(USE_FRONT_CAMERA, false, Boolean.class));
72 | }
73 |
74 | public void setHDRMode(int isHDR) {
75 | this.isCameraHDRMode.setValue(isHDR);
76 | }
77 |
78 | public int isHDR() {
79 | return isCameraHDRMode.getValue();
80 | }
81 |
82 | public boolean isOpenPhotoPreview() {
83 | return openPhotoPreview.getValue();
84 | }
85 |
86 | public void setOpenPhotoPreview(boolean enabled) {
87 | this.openPhotoPreview.setValue(enabled);
88 | }
89 |
90 | public int getCameraRatio() {
91 | return cameraRatio.getValue();
92 | }
93 |
94 | public void setCameraRatio(int cameraRatio) {
95 | this.cameraRatio.setValue(cameraRatio);
96 | }
97 |
98 | public int getCameraQuality() {
99 | return cameraQuality.getValue();
100 | }
101 |
102 | public void setCameraQuality(int cameraQuality) {
103 | this.cameraQuality.setValue(cameraQuality);
104 | }
105 |
106 | public int getCameraFlashMode() {
107 | return cameraFlashMode.getValue();
108 | }
109 |
110 | public void setCameraFlashMode(int cameraFlashMode) {
111 | this.cameraFlashMode.setValue(cameraFlashMode);
112 | }
113 |
114 | public int getCameraFocusMode() {
115 | return cameraFocusMode.getValue();
116 | }
117 |
118 | public void setCameraFocusMode(int cameraFocusMode) {
119 | this.cameraFocusMode.setValue(cameraFocusMode);
120 | }
121 |
122 | public boolean useFrontCamera() {
123 | return useFrontCamera.getValue();
124 | }
125 |
126 | public void setUseFrontCamera(boolean frontCamera) {
127 | this.useFrontCamera.setValue(frontCamera);
128 | }
129 |
130 | @Override
131 | public void clear() {
132 | for (CachedValue value : cachedValues) {
133 | value.clear();
134 | }
135 | sp.edit().clear().commit();
136 | }
137 |
138 | }
139 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/model/CachedValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.model;
25 |
26 | import android.content.SharedPreferences;
27 |
28 | public class CachedValue {
29 |
30 | private static SharedPreferences sharedPref;
31 |
32 | private SharedPreferences sp;
33 |
34 | private T value;
35 | private T defValue;
36 | private Class type;
37 | private String name;
38 | private boolean loaded = false;
39 |
40 | public CachedValue(String name, Class type) {
41 | this(name, null, null, type);
42 | }
43 |
44 | public CachedValue(String name, T defValue, Class type) {
45 | this(name, null, defValue, type);
46 | }
47 |
48 | public CachedValue(String name, T value, T defValue, Class type) {
49 | this.sp = sharedPref;
50 | this.name = name;
51 | this.type = type;
52 | this.loaded = value != null;
53 | this.value = value;
54 | this.defValue = defValue;
55 | }
56 |
57 | public void setValue(T value) {
58 | loaded = true;
59 | write(this.value = value);
60 | }
61 |
62 | public T getValue() {
63 | if (!loaded) {
64 | this.value = load();
65 | loaded = true;
66 | }
67 | return this.value;
68 | }
69 |
70 | public String getName() {
71 | return name;
72 | }
73 |
74 | private void write(T value) {
75 | SharedPreferences.Editor editor = sp.edit();
76 |
77 | if (value instanceof String) {
78 |
79 | editor.putString(name, (String) value);
80 |
81 | } else if (value instanceof Integer) {
82 |
83 | editor.putInt(name, (Integer) value);
84 |
85 | } else if (value instanceof Float) {
86 |
87 | editor.putFloat(name, (Float) value);
88 |
89 | } else if (value instanceof Long) {
90 |
91 | editor.putLong(name, (Long) value);
92 |
93 | } else if (value instanceof Boolean) {
94 |
95 | editor.putBoolean(name, (Boolean) value);
96 |
97 | }
98 |
99 | editor.commit();
100 | }
101 |
102 | @SuppressWarnings("unchecked")
103 | private T load() {
104 |
105 | if (type == String.class) {
106 |
107 | return (T) sp.getString(name, (String) defValue);
108 |
109 | } else if (type == Integer.class) {
110 |
111 | return (T) Integer.valueOf(sp.getInt(name, (Integer) defValue));
112 |
113 | } else if (type == Float.class) {
114 |
115 | return (T) Float.valueOf(sp.getFloat(name, (Float) defValue));
116 |
117 | } else if (type == Long.class) {
118 |
119 | return (T) Long.valueOf(sp.getLong(name, (Long) defValue));
120 |
121 | } else if (type == Boolean.class) {
122 |
123 | return (T) Boolean.valueOf(sp.getBoolean(name, (Boolean) defValue));
124 |
125 | }
126 |
127 | return null;
128 | }
129 |
130 | public void delete() {
131 | sp.edit().remove(name).commit();
132 | clear();
133 | }
134 |
135 | public static void initialize(SharedPreferences sp) {
136 | CachedValue.sharedPref = sp;
137 | }
138 |
139 | public void setSharedPreferences(SharedPreferences sp) {
140 | this.sp = sp;
141 | }
142 |
143 | public void clear() {
144 | loaded = false;
145 | this.value = null;
146 | }
147 |
148 | }
149 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/model/FlashMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.model;
25 |
26 | public enum FlashMode {
27 | ON(0, "On"), AUTO(1, "Auto"), OFF(2, "Off");
28 |
29 | private int id;
30 |
31 | private String name;
32 |
33 | FlashMode(int id, String name) {
34 | this.id = id;
35 | this.name = name;
36 | }
37 |
38 | public int getId() {
39 | return id;
40 | }
41 |
42 | public static FlashMode getFlashModeById(int id) {
43 | for (FlashMode mode : values()) {
44 | if (mode.id == id) {
45 | return mode;
46 | }
47 | }
48 | return null;
49 | }
50 |
51 | @Override
52 | public String toString() {
53 | return name;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/model/FocusMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.model;
25 |
26 | public enum FocusMode {
27 |
28 | AUTO(0, "Auto"), TOUCH(1, "Touch");
29 |
30 | private int id;
31 |
32 | private String name;
33 |
34 | FocusMode(int id, String name) {
35 | this.id = id;
36 | this.name = name;
37 | }
38 |
39 | public int getId() {
40 | return id;
41 | }
42 |
43 | public static FocusMode getFocusModeById(int id) {
44 | for (FocusMode mode : values()) {
45 | if (mode.id == id) {
46 | return mode;
47 | }
48 | }
49 | return null;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return name;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/model/HDRMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.model;
25 |
26 | public enum HDRMode {
27 |
28 | NONE(0, "None"), ON(1, "On"), OFF(2, "Off");
29 |
30 | private int id;
31 | private String name;
32 |
33 | HDRMode(int id, String name) {
34 | this.id = id;
35 | this.name = name;
36 | }
37 |
38 | public int getId() {
39 | return id;
40 | }
41 |
42 | public static HDRMode getHDRModeById(int id) {
43 | for (HDRMode mode : values()) {
44 | if (mode.id == id) {
45 | return mode;
46 | }
47 | }
48 | return null;
49 | }
50 |
51 | @Override
52 | public String toString() {
53 | return name;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/model/PictureSize.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.model;
25 |
26 | public class PictureSize {
27 |
28 | public int width;
29 |
30 | public int height;
31 |
32 | public Ratio ratio;
33 |
34 | public PictureSize(int width, int height, Ratio ratio) {
35 | this.width = width;
36 | this.height = height;
37 | this.ratio = ratio;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/model/Quality.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.model;
25 |
26 | public enum Quality {
27 | HIGH(0, "High"), MEDIUM(1, "Medium"), LOW(2, "Low");
28 |
29 | private int id;
30 |
31 | private String name;
32 |
33 | Quality(int id, String name) {
34 | this.id = id;
35 | this.name = name;
36 | }
37 |
38 | public int getId() {
39 | return id;
40 | }
41 |
42 | public static Quality getQualityById(int id) {
43 | for (Quality mode : values()) {
44 | if (mode.id == id) {
45 | return mode;
46 | }
47 | }
48 | return null;
49 | }
50 |
51 | @Override
52 | public String toString() {
53 | return name;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/model/Ratio.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.model;
25 |
26 | public enum Ratio {
27 | R_4x3(0, 4, 3), R_16x9(1, 16, 9);
28 |
29 | private int id;
30 |
31 | public int w;
32 |
33 | public int h;
34 |
35 | Ratio(int id, int w, int h) {
36 | this.id = id;
37 | this.w = w;
38 | this.h = h;
39 | }
40 |
41 | public int getId() {
42 | return id;
43 | }
44 |
45 | public static Ratio getRatioById(int id) {
46 | for (Ratio ratio : values()) {
47 | if (ratio.id == id) {
48 | return ratio;
49 | }
50 | }
51 | return null;
52 | }
53 |
54 | public static Ratio pickRatio(int width, int height) {
55 | for (Ratio ratio : values()) {
56 | if (width / ratio.w == height / ratio.h) {
57 | return ratio;
58 | }
59 | }
60 | return null;
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | return w + ":" + h;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/util/CropPhotoTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.util;
25 |
26 | import java.io.File;
27 | import java.io.FileNotFoundException;
28 | import java.io.FileOutputStream;
29 | import java.io.IOException;
30 |
31 | import timber.log.Timber;
32 | import android.graphics.Bitmap;
33 | import android.graphics.BitmapFactory;
34 | import android.graphics.RectF;
35 | import android.os.AsyncTask;
36 |
37 | import com.yalantis.cameramodule.CameraConst;
38 | import com.yalantis.cameramodule.interfaces.PhotoSavedListener;
39 |
40 | public class CropPhotoTask extends AsyncTask {
41 |
42 | private String path;
43 | private int width;
44 | private int height;
45 | private RectF rect;
46 | private PhotoSavedListener callback;
47 |
48 | public CropPhotoTask(String path, int width, int height, RectF rect, PhotoSavedListener callback) {
49 | this.path = path;
50 | this.rect = rect;
51 | this.width = width;
52 | this.height = height;
53 | this.callback = callback;
54 | }
55 |
56 | @Override
57 | protected Void doInBackground(Void... params) {
58 | Bitmap src = BitmapFactory.decodeFile(path);
59 | float koefW = (float) width / (float) src.getWidth();
60 | float koefH = (float) height / (float) src.getHeight();
61 |
62 | rect.top /= koefH;
63 | rect.left /= koefW;
64 | rect.right /= koefW;
65 | rect.bottom /= koefH;
66 | width = (int) rect.width();
67 | height = (int) rect.height();
68 |
69 | Bitmap bitmap = Bitmap.createBitmap(src, (int) rect.left, (int) rect.top, width, height);
70 |
71 | FileOutputStream fos = null;
72 | try {
73 | fos = new FileOutputStream(new File(path));
74 |
75 | bitmap.compress(Bitmap.CompressFormat.JPEG, CameraConst.COMPRESS_QUALITY, fos);
76 |
77 | } catch (FileNotFoundException e) {
78 | Timber.e(e, "File not found: " + e.getMessage());
79 | } finally {
80 | try {
81 | if (fos != null) {
82 | fos.close();
83 | }
84 | } catch (IOException e) {
85 | Timber.e(e, e.getMessage());
86 | }
87 | }
88 | bitmap.recycle();
89 |
90 | return null;
91 | }
92 |
93 | @Override
94 | protected void onPostExecute(Void aVoid) {
95 | super.onPostExecute(aVoid);
96 | if (callback != null) {
97 | callback.photoSaved(path, null);
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/util/ManagedTarget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.util;
25 |
26 | import android.graphics.Bitmap;
27 | import android.graphics.drawable.Drawable;
28 |
29 | import com.squareup.picasso.Picasso;
30 | import com.squareup.picasso.Target;
31 | import com.yalantis.cameramodule.interfaces.StorageCallback;
32 |
33 | public class ManagedTarget implements Target {
34 |
35 | private Target target;
36 | private String path;
37 | private StorageCallback callback;
38 |
39 | public ManagedTarget(Target target, String path, StorageCallback callback) {
40 | this.target = target;
41 | this.path = path;
42 | this.callback = callback;
43 | callback.addTarget(this);
44 | }
45 |
46 | @Override
47 | public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
48 | target.onBitmapLoaded(bitmap, from);
49 | callback.setBitmap(path, bitmap);
50 | callback.removeTarget(this);
51 | }
52 |
53 | @Override
54 | public void onBitmapFailed(Drawable errorDrawable) {
55 | target.onBitmapFailed(errorDrawable);
56 | callback.removeTarget(this);
57 | }
58 |
59 | @Override
60 | public void onPrepareLoad(Drawable placeHolderDrawable) {
61 | target.onPrepareLoad(placeHolderDrawable);
62 | }
63 |
64 | @Override
65 | public int hashCode() {
66 | return path.hashCode();
67 | }
68 |
69 | @Override
70 | public boolean equals(Object o) {
71 | if (super.equals(o)) {
72 | return true;
73 | }
74 | if (o == null) {
75 | return false;
76 | }
77 | if (o.getClass() != this.getClass()) {
78 | return false;
79 | }
80 | ManagedTarget other = (ManagedTarget) o;
81 | return other.path.equals(path);
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/util/PhotoUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.util;
25 |
26 | import java.io.File;
27 |
28 | public class PhotoUtil {
29 |
30 | public static void deletePhoto(String path) {
31 | File file = new File(path);
32 | file.delete();
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/util/RotatePhotoTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.util;
25 |
26 | import java.io.File;
27 | import java.io.FileNotFoundException;
28 | import java.io.FileOutputStream;
29 | import java.io.IOException;
30 |
31 | import timber.log.Timber;
32 | import android.graphics.Bitmap;
33 | import android.graphics.BitmapFactory;
34 | import android.graphics.Matrix;
35 | import android.os.AsyncTask;
36 |
37 | import com.yalantis.cameramodule.CameraConst;
38 | import com.yalantis.cameramodule.interfaces.PhotoSavedListener;
39 |
40 | public class RotatePhotoTask extends AsyncTask {
41 |
42 | private String path;
43 | private float angle;
44 | private PhotoSavedListener callback;
45 |
46 | public RotatePhotoTask(String path, float angle, PhotoSavedListener callback) {
47 | this.path = path;
48 | this.angle = angle;
49 | this.callback = callback;
50 | }
51 |
52 | @Override
53 | protected Void doInBackground(Void... params) {
54 | Bitmap bitmap = BitmapFactory.decodeFile(path); // todo NPE
55 | Matrix matrix = new Matrix();
56 | matrix.postRotate(angle);
57 | bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
58 | FileOutputStream fos = null;
59 | try {
60 | fos = new FileOutputStream(new File(path));
61 |
62 | bitmap.compress(Bitmap.CompressFormat.JPEG, CameraConst.COMPRESS_QUALITY, fos);
63 |
64 | } catch (FileNotFoundException e) {
65 | Timber.e(e, "File not found: " + e.getMessage());
66 | } finally {
67 | try {
68 | if (fos != null) {
69 | fos.close();
70 | }
71 | } catch (IOException e) {
72 | Timber.e(e, e.getMessage());
73 | }
74 | }
75 | bitmap.recycle();
76 |
77 | return null;
78 | }
79 |
80 | @Override
81 | protected void onPostExecute(Void aVoid) {
82 | super.onPostExecute(aVoid);
83 | if (callback != null) {
84 | callback.photoSaved(path, null);
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/util/SavingBitmapTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.util;
25 |
26 | import java.io.File;
27 | import java.io.FileNotFoundException;
28 | import java.io.FileOutputStream;
29 | import java.io.IOException;
30 |
31 | import timber.log.Timber;
32 | import android.graphics.Bitmap;
33 | import android.os.AsyncTask;
34 |
35 | import com.yalantis.cameramodule.CameraConst;
36 | import com.yalantis.cameramodule.interfaces.PhotoSavedListener;
37 |
38 | public class SavingBitmapTask extends AsyncTask {
39 |
40 | private Bitmap bitmap;
41 | private String path;
42 | private PhotoSavedListener callback;
43 |
44 | public SavingBitmapTask(Bitmap bitmap, String path, PhotoSavedListener callback) {
45 | this.bitmap = bitmap;
46 | this.path = path;
47 | this.callback = callback;
48 | }
49 |
50 | @Override
51 | protected Void doInBackground(Void... params) {
52 | FileOutputStream fos = null;
53 | try {
54 | fos = new FileOutputStream(new File(path));
55 |
56 | if (bitmap != null && !bitmap.isRecycled()) {
57 | bitmap.compress(Bitmap.CompressFormat.JPEG, CameraConst.COMPRESS_QUALITY, fos);
58 | }
59 |
60 | } catch (FileNotFoundException e) {
61 | Timber.e(e, "File not found: " + e.getMessage());
62 | } finally {
63 | try {
64 | if (fos != null) {
65 | fos.close();
66 | }
67 | } catch (IOException e) {
68 | Timber.e(e, e.getMessage());
69 | }
70 | }
71 |
72 | return null;
73 | }
74 |
75 | @Override
76 | protected void onPostExecute(Void aVoid) {
77 | super.onPostExecute(aVoid);
78 | if (callback != null) {
79 | callback.photoSaved(path, null);
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/util/SavingPhotoTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.util;
25 |
26 | import java.io.File;
27 | import java.io.FileNotFoundException;
28 | import java.io.FileOutputStream;
29 | import java.io.IOException;
30 |
31 | import timber.log.Timber;
32 | import android.graphics.Bitmap;
33 | import android.graphics.BitmapFactory;
34 | import android.graphics.Matrix;
35 | import android.media.ExifInterface;
36 | import android.os.AsyncTask;
37 | import android.os.Environment;
38 |
39 | import com.yalantis.cameramodule.CameraConst;
40 | import com.yalantis.cameramodule.interfaces.PhotoSavedListener;
41 |
42 | public class SavingPhotoTask extends AsyncTask {
43 |
44 | private byte[] data;
45 | private String name;
46 | private String path;
47 | private int orientation;
48 | private PhotoSavedListener callback;
49 |
50 | public SavingPhotoTask(byte[] data, String name, String path, int orientation) {
51 | this(data, name, path, orientation, null);
52 | }
53 |
54 | public SavingPhotoTask(byte[] data, String name, String path, int orientation, PhotoSavedListener callback) {
55 | this.data = data;
56 | this.name = name;
57 | this.path = path;
58 | this.orientation = orientation;
59 | this.callback = callback;
60 | }
61 |
62 | @Override
63 | protected File doInBackground(Void... params) {
64 | File photo = getOutputMediaFile();
65 | if (photo == null) {
66 | Timber.e("Error creating media file, check storage permissions");
67 | return null;
68 | }
69 |
70 | FileOutputStream fos = null;
71 | try {
72 | fos = new FileOutputStream(photo);
73 | if (orientation == ExifInterface.ORIENTATION_UNDEFINED) {
74 | saveByteArray(fos, data);
75 | } else {
76 | saveByteArrayWithOrientation(fos, data, orientation);
77 | }
78 |
79 | } catch (FileNotFoundException e) {
80 | Timber.e(e, "File not found: " + e.getMessage());
81 | } catch (IOException e) {
82 | Timber.e(e, "File write failure: " + e.getMessage());
83 | } finally {
84 | try {
85 | if (fos != null) {
86 | fos.close();
87 | }
88 | } catch (IOException e) {
89 | Timber.e(e, e.getMessage());
90 | }
91 | }
92 |
93 | return photo;
94 | }
95 |
96 | private void saveByteArray(FileOutputStream fos, byte[] data) throws IOException {
97 | long time = System.currentTimeMillis();
98 | fos.write(data);
99 | Timber.d("saveByteArray: %1dms", System.currentTimeMillis() - time);
100 | }
101 |
102 | private void saveByteArrayWithOrientation(FileOutputStream fos, byte[] data, int orientation) {
103 | long totalTime = System.currentTimeMillis();
104 | long time = System.currentTimeMillis();
105 |
106 | Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
107 | Timber.d("decodeByteArray: %1dms", System.currentTimeMillis() - time);
108 |
109 | time = System.currentTimeMillis();
110 | if (orientation != 0 && bitmap.getWidth() > bitmap.getHeight()) {
111 | Matrix matrix = new Matrix();
112 | matrix.postRotate(orientation);
113 | bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
114 | Timber.d("createBitmap: %1dms", System.currentTimeMillis() - time);
115 | }
116 | time = System.currentTimeMillis();
117 | bitmap.compress(Bitmap.CompressFormat.JPEG, CameraConst.COMPRESS_QUALITY, fos);
118 | Timber.d("compress: %1dms", System.currentTimeMillis() - time);
119 |
120 | bitmap.recycle();
121 |
122 | Timber.d("saveByteArrayWithOrientation: %1dms", System.currentTimeMillis() - totalTime);
123 | }
124 |
125 | @Override
126 | protected void onPostExecute(File file) {
127 | super.onPostExecute(file);
128 | photoSaved(file);
129 | }
130 |
131 | private void photoSaved(File photo) {
132 | if (photo != null) {
133 | if (callback != null) {
134 | callback.photoSaved(photo.getPath(), photo.getName());
135 | }
136 | }
137 | }
138 |
139 | /**
140 | * Create a File for saving an image
141 | */
142 | private File getOutputMediaFile() {
143 | // To be safe, we should check that the SDCard is mounted
144 | if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
145 | Timber.e("External storage " + Environment.getExternalStorageState());
146 | return null;
147 | }
148 |
149 | File dir = new File(path);
150 | // Create the storage directory if it doesn't exist
151 | if (!dir.exists()) {
152 | if (!dir.mkdirs()) {
153 | Timber.e("Failed to create directory");
154 | return null;
155 | }
156 | }
157 |
158 | return new File(dir.getPath() + File.separator + name);
159 | }
160 |
161 | }
162 |
--------------------------------------------------------------------------------
/CameraModule/src/main/java/com/yalantis/cameramodule/util/ScaleTransformation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.cameramodule.util;
25 |
26 | import android.graphics.Bitmap;
27 | import android.graphics.Matrix;
28 |
29 | import com.squareup.picasso.Transformation;
30 |
31 | public class ScaleTransformation implements Transformation {
32 |
33 | private float width;
34 | private float height;
35 |
36 | public ScaleTransformation(float width, float height) {
37 | this.width = width;
38 | this.height = height;
39 | }
40 |
41 | @Override
42 | public Bitmap transform(Bitmap source) {
43 | float sWidth = source.getWidth();
44 | float sHeight = source.getHeight();
45 |
46 | float xScale;
47 | float yScale;
48 | if (sWidth < sHeight) {
49 | yScale = height / sHeight;
50 | xScale = yScale;
51 | } else {
52 | xScale = width / sWidth;
53 | yScale = xScale;
54 | }
55 |
56 | Matrix matrix = new Matrix();
57 | matrix.postScale(xScale, yScale);
58 | Bitmap scaledBitmap = Bitmap.createBitmap(source, 0, 0, (int) sWidth, (int) sHeight, matrix, true);
59 |
60 | scaledBitmap.getWidth();
61 | scaledBitmap.getHeight();
62 | if (scaledBitmap != source) {
63 | source.recycle();
64 | }
65 |
66 | return scaledBitmap;
67 | }
68 |
69 | @Override
70 | public String key() {
71 | return "scaleTo" + width + "x" + height;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-hdpi/ic_camera_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-hdpi/ic_camera_capture.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-hdpi/ic_camera_capture_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-hdpi/ic_camera_capture_pressed.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-mdpi/ic_camera_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-mdpi/ic_camera_capture.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-mdpi/ic_camera_capture_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-mdpi/ic_camera_capture_pressed.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-xhdpi/ic_camera_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-xhdpi/ic_camera_capture.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-xhdpi/ic_camera_capture_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-xhdpi/ic_camera_capture_pressed.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-xxhdpi/cam_flash_auto_icn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-xxhdpi/cam_flash_auto_icn.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-xxhdpi/cam_flash_fill_flash_icn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-xxhdpi/cam_flash_fill_flash_icn.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-xxhdpi/cam_flash_off_icn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-xxhdpi/cam_flash_off_icn.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-xxhdpi/ic_camera_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-xxhdpi/ic_camera_capture.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable-xxhdpi/ic_camera_capture_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable-xxhdpi/ic_camera_capture_pressed.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable/bg_transparent_clickable.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable/camera_capture.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable/input.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable/input.9.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable/no_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable/no_image.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/drawable/sheet_shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/CameraModule/src/main/res/drawable/sheet_shadow.png
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/activity_photo.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
30 |
31 |
35 |
36 |
42 |
43 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/activity_with_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
28 |
29 |
33 |
34 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/dialog_camera_params.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
28 |
29 |
31 |
32 |
35 |
36 |
39 |
40 |
41 |
42 |
44 |
45 |
48 |
49 |
52 |
53 |
54 |
55 |
56 |
57 |
60 |
61 |
64 |
65 |
66 |
67 |
70 |
71 |
74 |
75 |
78 |
79 |
80 |
81 |
87 |
88 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/fragment_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
29 |
30 |
34 |
35 |
40 |
41 |
46 |
47 |
55 |
56 |
65 |
66 |
75 |
76 |
85 |
86 |
87 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/fragment_no_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
28 |
29 |
36 |
37 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/fragment_photo_crop.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
25 |
26 |
29 |
30 |
35 |
36 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/fragment_photo_preview.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
25 |
26 |
29 |
30 |
35 |
36 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/object_to_string_dropdown_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
25 |
26 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/layout/object_to_string_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
25 |
26 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/menu/photo_crop_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
25 |
26 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/menu/photo_preview_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
25 |
26 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
26 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
26 | #66000000
27 | #777
28 | #99000000
29 |
30 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
26 | 15dp
27 | 10dp
28 | 20dp
29 | 100dp
30 | 5dp
31 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
26 |
27 | CameraModule
28 | Apply
29 | Cancel
30 | Delete
31 | Left
32 | Right
33 | Crop
34 | Camera is not available (in use or does not exist).\nPlease close applications, that may use camera.
35 |
36 | Zoom: %1.2fx
37 | Open preview photo after shot
38 | Settings
39 | HDR
40 | Close
41 | Focus mode
42 | Ratio
43 | Quality
44 | Take another
45 | Photo crop
46 | lbl_photo_preview
47 |
48 |
49 |
--------------------------------------------------------------------------------
/CameraModule/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
26 |
33 |
34 |
37 |
38 |
42 |
43 |
49 |
50 |
53 |
54 |
55 |
56 |
57 |
62 |
63 |
64 |
65 |
66 |
72 |
73 |
74 |
75 |
76 |
82 |
83 |
84 |
85 |
86 |
93 |
94 |
101 |
102 |
105 |
106 |
107 |
108 |
109 |
117 |
118 |
119 |
120 |
121 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | CameraModule
2 | ============
3 | Camera module for Android applications.
4 |
5 | Screenshots:
6 | https://www.dropbox.com/sh/2d7svoykpwpwmbw/AAAveLqvtaJ2Zt5NHaEu3-QSa
7 |
8 | Usage
9 | --------
10 | In your Application class call managers initializer:
11 |
12 | ```java
13 | public class App extends Application {
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 | ManagerInitializer.i.init(getApplicationContext());
18 | }
19 | }
20 | ```
21 |
22 | Then call `CameraActivity` to use camera:
23 |
24 | ```java
25 | Intent intent = new Intent(this, CameraActivity.class);
26 | intent.putExtra(CameraActivity.PATH, Environment.getExternalStorageDirectory().getPath());
27 | intent.putExtra(CameraActivity.OPEN_PHOTO_PREVIEW, true);
28 | intent.putExtra(CameraActivity.USE_FRONT_CAMERA, false);
29 | startActivity(intent);
30 | ```
31 |
32 | Customising
33 | --------
34 | To create custom layout for `CameraFragment`, please use this ids:
35 |
36 | `camera_preview` - Container for `CameraPreview` that extends ViewGroup.
37 |
38 | `capture` - View for capturing photos
39 |
40 | `zoom_ratio` - `TextView` for displaying zoom ratio value
41 |
42 | `flash_mode` - `ImageButton` for displaying and switching flash mode
43 |
44 | `progress` - `ProgressBar` that indicates that capturing or saving photo in progress
45 |
46 | `camera_settings` - `ImageButton` that call `CameraSettingsDialogFragment`
47 |
48 | Then put layout resources id to intent extras for `CameraActivty`:
49 | ```java
50 | Intent intent = new Intent(this, CameraActivity.class);
51 | intent.putExtra(CameraActivity.PATH, Environment.getExternalStorageDirectory().getPath());
52 | intent.putExtra(CameraActivity.OPEN_PHOTO_PREVIEW, true);
53 | intent.putExtra(CameraActivity.LAYOUT_ID, R.layout.fragment_camera_custom);
54 | startActivity(intent);
55 | ```
56 |
57 | #### Let us know!
58 |
59 | We’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation.
60 |
61 | P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for Android (iOS) better than better. Stay tuned!
62 |
63 | License
64 | --------
65 |
66 | The MIT License (MIT)
67 |
68 | Copyright (c) 2017 Zillow
69 |
70 | Permission is hereby granted, free of charge, to any person obtaining a copy
71 | of this software and associated documentation files (the "Software"), to deal
72 | in the Software without restriction, including without limitation the rights
73 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
74 | copies of the Software, and to permit persons to whom the Software is furnished
75 | to do so, subject to the following conditions:
76 |
77 | The above copyright notice and this permission notice shall be included in all
78 | copies or substantial portions of the Software.
79 |
80 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
81 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
82 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
83 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
84 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
85 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
25 |
26 | buildscript {
27 | repositories {
28 | mavenCentral()
29 | }
30 | dependencies {
31 | classpath 'com.android.tools.build:gradle:0.13.0'
32 | }
33 | }
34 |
35 | allprojects {
36 | repositories {
37 | mavenCentral()
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
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
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Oct 07 11:53:37 EEST 2014
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=http\://services.gradle.org/distributions/gradle-2.1-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | # svn
2 | *.svn*
3 |
4 | # built application files
5 | *.apk
6 | *.ap_
7 |
8 | # files for the dex VM
9 | *.dex
10 |
11 | # Java class files
12 | *.class
13 |
14 | # generated GUI files
15 | */R.java
16 |
17 | # generated folder
18 | bin
19 | gen
20 |
21 | # local
22 | local.properties
23 | proguard.cfg
24 |
25 | # log files
26 | log*.txt
27 |
28 | # archives
29 | *.gz
30 | *.tar
31 | *.zip
32 |
33 | # eclipse
34 | *.metadata
35 | *.settings
36 |
37 | #idea
38 | *.idea
39 | *.iml
40 | out/
41 |
42 | #gradle
43 | /build
44 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | apply plugin: 'com.android.application'
25 |
26 | repositories {
27 | mavenCentral()
28 | }
29 |
30 | android {
31 | compileSdkVersion 19
32 | buildToolsVersion '19.1.0'
33 |
34 | defaultConfig {
35 | minSdkVersion 14
36 | targetSdkVersion 19
37 | versionCode 1
38 | versionName "1.0"
39 | }
40 |
41 | compileOptions {
42 | sourceCompatibility JavaVersion.VERSION_1_7
43 | targetCompatibility JavaVersion.VERSION_1_7
44 | }
45 | buildTypes {
46 | release {
47 | runProguard false
48 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
49 | }
50 | }
51 | }
52 |
53 | dependencies {
54 | compile project(':CameraModule')
55 | compile fileTree(dir: 'libs', include: ['*.jar'])
56 | }
57 |
--------------------------------------------------------------------------------
/sample/proguard-rules.txt:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:/androidsdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the ProGuard
5 | # include property in project.properties.
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 | #}
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
27 |
28 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/yalantis/sample/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.sample;
25 |
26 | import android.app.Application;
27 | import com.yalantis.cameramodule.ManagerInitializer;
28 |
29 | public class App extends Application {
30 |
31 | @Override
32 | public void onCreate() {
33 | super.onCreate();
34 | ManagerInitializer.i.init(getApplicationContext());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/yalantis/sample/Const.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.sample;
25 |
26 | import android.os.Environment;
27 |
28 | import java.io.File;
29 |
30 | public final class Const {
31 |
32 | public static final boolean DEBUG = true;
33 |
34 | public static final class FOLDERS {
35 |
36 | private static final String ROOT = File.separator + "CameraModule";
37 |
38 | private static final String SD_CARD_PATH = Environment.getExternalStorageDirectory().getPath();
39 |
40 | public static final String PATH = SD_CARD_PATH + ROOT;
41 |
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/yalantis/sample/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014 Zillow
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is furnished
11 | * to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.yalantis.sample.activity;
25 |
26 | import android.app.Activity;
27 | import android.content.Intent;
28 | import android.os.Bundle;
29 | import android.view.Menu;
30 | import android.view.MenuItem;
31 | import android.view.View;
32 | import com.yalantis.cameramodule.activity.CameraActivity;
33 | import com.yalantis.sample.Const;
34 | import com.yalantis.sample.R;
35 |
36 | public class MainActivity extends Activity {
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_main);
42 | }
43 |
44 | @Override
45 | public boolean onCreateOptionsMenu(Menu menu) {
46 | getMenuInflater().inflate(R.menu.main, menu);
47 | return true;
48 | }
49 |
50 | @Override
51 | public boolean onOptionsItemSelected(MenuItem item) {
52 | switch (item.getItemId()) {
53 | case R.id.action_settings:
54 | return true;
55 | }
56 | return super.onOptionsItemSelected(item);
57 | }
58 |
59 | public void openCamera(View view) {
60 | Intent intent = new Intent(this, CameraActivity.class);
61 | intent.putExtra(CameraActivity.PATH, Const.FOLDERS.PATH);
62 | intent.putExtra(CameraActivity.OPEN_PHOTO_PREVIEW, true);
63 | intent.putExtra(CameraActivity.LAYOUT_ID, R.layout.fragment_camera_custom);
64 | intent.putExtra(CameraActivity.USE_FRONT_CAMERA, false);
65 | startActivity(intent);
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/sample/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/sample/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/sample/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yalantis/CameraModule/fca60cd2662c1768c68d383608600dd3361cc20f/sample/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
33 |
34 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_camera_custom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
25 |
26 |
30 |
31 |
35 |
36 |
41 |
42 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/sample/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
33 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
28 | 64dp
29 |
30 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
26 | 16dp
27 | 16dp
28 |
29 |
30 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
26 |
27 | My Module
28 | Hello world!
29 | Settings
30 | Open camera
31 |
32 |
33 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':CameraModule', ':sample', ':sample'
2 |
--------------------------------------------------------------------------------