diff --git a/README.md b/README.md
index 165ce20..e632c95 100644
--- a/README.md
+++ b/README.md
@@ -115,4 +115,12 @@ cameraFragment.setStateListener(new CameraFragmentStateListener() {
## Text
-CameraFragment can ping you with the current record duration with `CameraFragmentTextListener`
\ No newline at end of file
+CameraFragment can ping you with the current record duration with `CameraFragmentTextListener`
+
+# Widgets
+
+CameraFragment comes with some default views
+
+`RecordButton`, `MediaActionSwitchView`, `FlashSwitchView`, `CameraSwitchView`, `CameraSettingsView`
+
+[![png](https://raw.githubusercontent.com/florent37/CameraFragment/master/media/buttons.png)](https://github.com/florent37/CameraFragment)
diff --git a/app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java b/app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java
index b11812a..dae6bcc 100644
--- a/app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java
+++ b/app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java
@@ -302,11 +302,6 @@ public class MainActivity extends AppCompatActivity {
}
-
- cameraSwitchView.displayBackCamera();
- flashSwitchView.displayFlashAuto();
- recordButton.displayPhotoState();
- mediaActionSwitchView.displayActionWillSwitchVideo();
}
private CameraFragmentApi getCameraFragment() {
diff --git a/app/src/main/res/layout/activity_fragment.xml b/app/src/main/res/layout/activity_fragment.xml
index fc650d7..1a58d4e 100644
--- a/app/src/main/res/layout/activity_fragment.xml
+++ b/app/src/main/res/layout/activity_fragment.xml
@@ -15,6 +15,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
+ tools:visibility="gone"
android:text="Add camera" />
+ />
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true">
-
-
+
+
diff --git a/app/src/main/res/layout/sample.xml b/app/src/main/res/layout/sample.xml
new file mode 100644
index 0000000..6c82f39
--- /dev/null
+++ b/app/src/main/res/layout/sample.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/configuration/Configuration.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/configuration/Configuration.java
index 7f861de..9d2fd34 100644
--- a/camerafragment/src/main/java/com/github/florent37/camerafragment/configuration/Configuration.java
+++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/configuration/Configuration.java
@@ -45,17 +45,6 @@ public final class Configuration implements Serializable {
public static final int FLASH_MODE_OFF = 2;
public static final int FLASH_MODE_AUTO = 3;
- public interface Arguments {
- String REQUEST_CODE = "io.memfis19.annca.request_code";
- String MEDIA_ACTION = "io.memfis19.annca.media_action";
- String MEDIA_QUALITY = "io.memfis19.annca.camera_media_quality";
- String VIDEO_DURATION = "io.memfis19.annca.video_duration";
- String MINIMUM_VIDEO_DURATION = "io.memfis19.annca.minimum.video_duration";
- String VIDEO_FILE_SIZE = "io.memfis19.annca.camera_video_file_size";
- String FLASH_MODE = "io.memfis19.annca.camera_flash_mode";
- String FILE_PATH = "io.memfis19.annca.camera_video_file_path";
- }
-
@IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST})
@Retention(RetentionPolicy.SOURCE)
public @interface MediaQuality {
diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera1Manager.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera1Manager.java
index 19a8895..7cc96ec 100644
--- a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera1Manager.java
+++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera1Manager.java
@@ -230,7 +230,7 @@ public class Camera1Manager extends BaseCameraManager previewSizes = Size.fromList(camera.getParameters().getSupportedPreviewSizes());
- List pictureSizes = Size.fromList(camera.getParameters().getSupportedPictureSizes());
+ final List previewSizes = Size.fromList(camera.getParameters().getSupportedPreviewSizes());
+ final List pictureSizes = Size.fromList(camera.getParameters().getSupportedPictureSizes());
List videoSizes;
if (Build.VERSION.SDK_INT > 10)
videoSizes = Size.fromList(camera.getParameters().getSupportedVideoSizes());
@@ -360,11 +360,11 @@ public class Camera1Manager extends BaseCameraManager videoQualities = new ArrayList<>();
+ final List videoQualities = new ArrayList<>();
if (configurationProvider.getMinimumVideoDuration() > 0)
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_AUTO, getCurrentCameraId()), configurationProvider.getMinimumVideoDuration()));
@@ -599,7 +599,7 @@ public class Camera1Manager extends BaseCameraManager photoQualities = new ArrayList<>();
+ final List photoQualities = new ArrayList<>();
photoQualities.add(new PhotoQualityOption(Configuration.MEDIA_QUALITY_HIGHEST, getPhotoSizeForQuality(Configuration.MEDIA_QUALITY_HIGHEST)));
photoQualities.add(new PhotoQualityOption(Configuration.MEDIA_QUALITY_HIGH, getPhotoSizeForQuality(Configuration.MEDIA_QUALITY_HIGH)));
photoQualities.add(new PhotoQualityOption(Configuration.MEDIA_QUALITY_MEDIUM, getPhotoSizeForQuality(Configuration.MEDIA_QUALITY_MEDIUM)));
photoQualities.add(new PhotoQualityOption(Configuration.MEDIA_QUALITY_LOWEST, getPhotoSizeForQuality(Configuration.MEDIA_QUALITY_LOWEST)));
- CharSequence[] array = new CharSequence[photoQualities.size()];
+ final CharSequence[] array = new CharSequence[photoQualities.size()];
photoQualities.toArray(array);
return array;
diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera2Manager.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera2Manager.java
index 7050044..4674f92 100644
--- a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera2Manager.java
+++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera2Manager.java
@@ -122,8 +122,7 @@ public final class Camera2Manager extends BaseCameraManager surfaces = new ArrayList<>();
+ final List surfaces = new ArrayList<>();
- Surface previewSurface = workingSurface;
+ final Surface previewSurface = workingSurface;
surfaces.add(previewSurface);
previewRequestBuilder.addTarget(previewSurface);
@@ -406,7 +405,7 @@ public final class Camera2Manager extends BaseCameraManager videoQualities = new ArrayList<>();
+ final List videoQualities = new ArrayList<>();
if (configurationProvider.getMinimumVideoDuration() > 0)
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_AUTO, getCurrentCameraId()), configurationProvider.getMinimumVideoDuration()));
@@ -809,13 +810,13 @@ public final class Camera2Manager extends BaseCameraManager photoQualities = new ArrayList<>();
+ final List photoQualities = new ArrayList<>();
photoQualities.add(new PhotoQualityOption(Configuration.MEDIA_QUALITY_HIGHEST, getPhotoSizeForQuality(Configuration.MEDIA_QUALITY_HIGHEST)));
photoQualities.add(new PhotoQualityOption(Configuration.MEDIA_QUALITY_HIGH, getPhotoSizeForQuality(Configuration.MEDIA_QUALITY_HIGH)));
photoQualities.add(new PhotoQualityOption(Configuration.MEDIA_QUALITY_MEDIUM, getPhotoSizeForQuality(Configuration.MEDIA_QUALITY_MEDIUM)));
photoQualities.add(new PhotoQualityOption(Configuration.MEDIA_QUALITY_LOWEST, getPhotoSizeForQuality(Configuration.MEDIA_QUALITY_LOWEST)));
- CharSequence[] array = new CharSequence[photoQualities.size()];
+ final CharSequence[] array = new CharSequence[photoQualities.size()];
photoQualities.toArray(array);
return array;
diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSettingsView.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSettingsView.java
index aa4e9ed..b0691cb 100644
--- a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSettingsView.java
+++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSettingsView.java
@@ -6,25 +6,36 @@ import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageButton;
+import com.github.florent37.camerafragment.R;
+
/**
* Created by memfis on 8/23/16.
*/
public class CameraSettingsView extends ImageButton {
+
public CameraSettingsView(Context context) {
- super(context);
+ this(context, null);
}
public CameraSettingsView(Context context, AttributeSet attrs) {
- super(context, attrs);
+ this(context, attrs, 0);
}
public CameraSettingsView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
+ init();
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public CameraSettingsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
+ init();
+ }
+
+ private void init() {
+ setBackgroundResource(R.drawable.circle_frame_background_dark);
+ setImageResource(R.drawable.ic_settings_white_24dp);
+ setScaleType(ScaleType.CENTER);
}
@Override
diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSwitchView.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSwitchView.java
index c07797f..aa4ff37 100644
--- a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSwitchView.java
+++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSwitchView.java
@@ -50,6 +50,8 @@ public class CameraSwitchView extends AppCompatImageButton {
padding = Utils.convertDipToPixels(context, padding);
setPadding(padding, padding, padding, padding);
+
+ displayBackCamera();
}
public void displayFrontCamera() {
diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/FlashSwitchView.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/FlashSwitchView.java
index fd1ef47..d6865e0 100644
--- a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/FlashSwitchView.java
+++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/FlashSwitchView.java
@@ -37,6 +37,7 @@ public class FlashSwitchView extends ImageButton {
private void init() {
setBackgroundColor(Color.TRANSPARENT);
+ displayFlashAuto();
}
public void displayFlashOff() {
diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/MediaActionSwitchView.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/MediaActionSwitchView.java
index 3a92f96..ba5de5b 100644
--- a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/MediaActionSwitchView.java
+++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/MediaActionSwitchView.java
@@ -67,6 +67,8 @@ public class MediaActionSwitchView extends ImageButton {
padding = Utils.convertDipToPixels(context, padding);
setPadding(padding, padding, padding, padding);
+
+ displayActionWillSwitchVideo();
}
public void displayActionWillSwitchPhoto(){
diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/RecordButton.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/RecordButton.java
index 8630bc3..ebdb85f 100644
--- a/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/RecordButton.java
+++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/RecordButton.java
@@ -68,6 +68,8 @@ public class RecordButton extends ImageButton {
});
setSoundEffectsEnabled(false);
setIconPadding(iconPadding);
+
+ displayPhotoState();
}
//public void setup(@Configuration.MediaAction int mediaAction) {
diff --git a/media/buttons.png b/media/buttons.png
new file mode 100644
index 0000000..e8ed7c4
Binary files /dev/null and b/media/buttons.png differ