diff --git a/app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivity.java b/app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivity.java index 45d8459..8367e32 100644 --- a/app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivity.java +++ b/app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivity.java @@ -1,6 +1,7 @@ package com.github.florent37.camerafragment.sample; import android.Manifest; +import android.annotation.SuppressLint; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; @@ -34,6 +35,7 @@ import butterknife.Bind; import butterknife.ButterKnife; import butterknife.OnClick; +@SuppressLint("MissingPermission") public class CameraFragmentMainActivity extends AppCompatActivity { public static final String FRAGMENT_TAG = "camera"; diff --git a/app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivityCustoms.java b/app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivityCustoms.java index f42e521..5207898 100644 --- a/app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivityCustoms.java +++ b/app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivityCustoms.java @@ -1,6 +1,7 @@ package com.github.florent37.camerafragment.sample; import android.Manifest; +import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Build; @@ -28,6 +29,7 @@ import butterknife.Bind; import butterknife.ButterKnife; import butterknife.OnClick; +@SuppressLint("MissingPermission") public class CameraFragmentMainActivityCustoms extends AppCompatActivity { private static final int REQUEST_CAMERA_PERMISSIONS = 931; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 269d1b6..d515d4b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - CameraFragment + CameraFragment 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 3daf714..6e01c66 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 @@ -1,5 +1,6 @@ package com.github.florent37.camerafragment.internal.manager.impl; +import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; import android.graphics.ImageFormat; @@ -54,6 +55,7 @@ import java.util.Objects; * Created by memfis on 8/9/16. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) +@SuppressLint("MissingPermission") public final class Camera2Manager extends BaseCameraManager implements ImageReader.OnImageAvailableListener, TextureView.SurfaceTextureListener { diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/CountdownTask.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/CountdownTask.java index e1e37d9..193bd9b 100644 --- a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/CountdownTask.java +++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/CountdownTask.java @@ -1,7 +1,6 @@ package com.github.florent37.camerafragment.internal.timer; -import android.graphics.Color; - +import java.util.Locale; import java.util.concurrent.TimeUnit; import com.github.florent37.camerafragment.internal.utils.DateTimeUtils; @@ -28,7 +27,8 @@ public class CountdownTask extends TimerTaskBase implements Runnable { if (callback != null) { callback.setText( - String.format("%02d:%02d", + String.format(Locale.getDefault(), + "%02d:%02d", TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)) @@ -52,7 +52,8 @@ public class CountdownTask extends TimerTaskBase implements Runnable { recordingTimeSeconds = maxDurationMilliseconds / 1000; if (callback != null) { callback.setText( - String.format("%02d:%02d", + String.format(Locale.getDefault(), + "%02d:%02d", TimeUnit.MILLISECONDS.toMinutes(maxDurationMilliseconds), TimeUnit.MILLISECONDS.toSeconds(maxDurationMilliseconds) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(maxDurationMilliseconds)) diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/TimerTask.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/TimerTask.java index c434338..ac565fc 100644 --- a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/TimerTask.java +++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/TimerTask.java @@ -2,6 +2,8 @@ package com.github.florent37.camerafragment.internal.timer; import com.github.florent37.camerafragment.internal.utils.DateTimeUtils; +import java.util.Locale; + /* * Created by florentchampigny on 13/01/2017. */ @@ -22,7 +24,13 @@ public class TimerTask extends TimerTaskBase implements Runnable { } if(callback != null) { callback.setText( - String.format("%02d:%02d", recordingTimeMinutes, recordingTimeSeconds)); + String.format( + Locale.getDefault(), + "%02d:%02d", + recordingTimeMinutes, + recordingTimeSeconds + ) + ); } if (alive) handler.postDelayed(this, DateTimeUtils.SECOND); } @@ -33,7 +41,13 @@ public class TimerTask extends TimerTaskBase implements Runnable { recordingTimeSeconds = 0; if(callback != null) { callback.setText( - String.format("%02d:%02d", recordingTimeMinutes, recordingTimeSeconds)); + String.format( + Locale.getDefault(), + "%02d:%02d", + recordingTimeMinutes, + recordingTimeSeconds + ) + ); callback.setTextVisible(true); } handler.postDelayed(this, DateTimeUtils.SECOND); diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/ui/BaseAnncaFragment.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/ui/BaseAnncaFragment.java index 3e68d19..ea5a016 100644 --- a/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/ui/BaseAnncaFragment.java +++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/internal/ui/BaseAnncaFragment.java @@ -1,5 +1,6 @@ package com.github.florent37.camerafragment.internal.ui; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; @@ -54,9 +55,10 @@ import java.util.ArrayList; /* * Created by memfis on 12/1/16. - * Updated by Florent37 + * Updated by amadeu01 */ +@SuppressLint("WrongConstant") public abstract class BaseAnncaFragment extends Fragment implements CameraFragmentApi { public static final String ARG_CONFIGURATION = "configuration"; @@ -152,7 +154,7 @@ public abstract class BaseAnncaFragment extends Fragment implements Ca @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View decorView = ((Activity) container.getContext()).getWindow().getDecorView(); - if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); } @@ -347,8 +349,8 @@ public abstract class BaseAnncaFragment extends Fragment implements Ca public PhotoQualityOption[] getPhotoQualities() { ArrayList photoQualityOptions = new ArrayList<>(); - for (CharSequence photoQualitie: photoQualities) { - photoQualityOptions.add((PhotoQualityOption) photoQualitie); + for (CharSequence photoQuality: photoQualities) { + photoQualityOptions.add((PhotoQualityOption) photoQuality); } return photoQualityOptions.toArray(new PhotoQualityOption[photoQualityOptions.size()]); } @@ -604,7 +606,7 @@ public abstract class BaseAnncaFragment extends Fragment implements Ca } protected void takePhoto(CameraFragmentResultListener callback, @Nullable String directoryPath, @Nullable String fileName) { - if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK); } setRecordState(Record.TAKE_PHOTO_STATE); @@ -615,7 +617,7 @@ public abstract class BaseAnncaFragment extends Fragment implements Ca } protected void startRecording(@Nullable String directoryPath, @Nullable String fileName) { - if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { new MediaActionSound().play(MediaActionSound.START_VIDEO_RECORDING); } @@ -628,7 +630,7 @@ public abstract class BaseAnncaFragment extends Fragment implements Ca } protected void stopRecording(CameraFragmentResultListener callback) { - if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { new MediaActionSound().play(MediaActionSound.STOP_VIDEO_RECORDING); } 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 1c0d154..ae88b7d 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 @@ -1,17 +1,16 @@ package com.github.florent37.camerafragment.widgets; -import android.annotation.TargetApi; import android.content.Context; 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. + * Updated by amadeu01 on 17/04/17 */ -public class CameraSettingsView extends ImageButton { +public class CameraSettingsView extends android.support.v7.widget.AppCompatImageButton { public CameraSettingsView(Context context) { this(context, null); @@ -26,12 +25,6 @@ public class CameraSettingsView extends ImageButton { 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); 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 c2ce623..c043823 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 @@ -15,6 +15,7 @@ import com.github.florent37.camerafragment.internal.utils.Utils; /* * Created by memfis on 6/24/16. + * Updated by amadeu01 on 17/04/17 */ public class CameraSwitchView extends AppCompatImageButton { @@ -39,11 +40,11 @@ public class CameraSwitchView extends AppCompatImageButton { Context context = getContext(); frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp); frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable); - DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); + DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.color.switch_camera_mode_selector)); rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp); rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable); - DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); + DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.color.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); displayBackCamera(); 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 45cbfe2..e270979 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 @@ -5,19 +5,17 @@ import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.util.AttributeSet; -import android.view.View; -import android.widget.ImageButton; import com.github.florent37.camerafragment.R; /* * Created by memfis on 7/6/16. + * Updated by amadeu01 on 17/04/17 */ -public class FlashSwitchView extends ImageButton { +public class FlashSwitchView extends android.support.v7.widget.AppCompatImageButton { private Drawable flashOnDrawable; private Drawable flashOffDrawable; 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 17d8948..3258f73 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 @@ -8,15 +8,15 @@ import android.support.v4.content.ContextCompat; import android.support.v4.graphics.drawable.DrawableCompat; import android.util.AttributeSet; import android.view.View; -import android.widget.ImageButton; import com.github.florent37.camerafragment.R; import com.github.florent37.camerafragment.internal.utils.Utils; /* * Created by memfis on 6/24/16. + * Updated by amadeu01 on 17/04/17 */ -public class MediaActionSwitchView extends ImageButton { +public class MediaActionSwitchView extends android.support.v7.widget.AppCompatImageButton { @Nullable private OnMediaActionStateChangeListener onMediaActionStateChangeListener; @@ -47,11 +47,11 @@ public class MediaActionSwitchView extends ImageButton { photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp); photoDrawable = DrawableCompat.wrap(photoDrawable); - DrawableCompat.setTintList(photoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); + DrawableCompat.setTintList(photoDrawable.mutate(), ContextCompat.getColorStateList(context, R.color.switch_camera_mode_selector)); videoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_videocam_white_24dp); videoDrawable = DrawableCompat.wrap(videoDrawable); - DrawableCompat.setTintList(videoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); + DrawableCompat.setTintList(videoDrawable.mutate(), ContextCompat.getColorStateList(context, R.color.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); // setBackgroundResource(R.drawable.circle_frame_background); @@ -79,7 +79,7 @@ public class MediaActionSwitchView extends ImageButton { setImageDrawable(videoDrawable); } - public void setOnMediaActionStateChangeListener(OnMediaActionStateChangeListener onMediaActionStateChangeListener) { + public void setOnMediaActionStateChangeListener(@Nullable OnMediaActionStateChangeListener onMediaActionStateChangeListener) { this.onMediaActionStateChangeListener = onMediaActionStateChangeListener; } 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 ba489e4..90e2e35 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 @@ -8,15 +8,15 @@ import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.util.AttributeSet; import android.view.View; -import android.widget.ImageButton; import com.github.florent37.camerafragment.R; import com.github.florent37.camerafragment.internal.utils.Utils; /* * Created by memfis on 7/6/16. + * Updated by amadeu01 on 17/04/17 */ -public class RecordButton extends ImageButton { +public class RecordButton extends android.support.v7.widget.AppCompatImageButton { public interface RecordButtonListener { void onRecordButtonClicked(); diff --git a/camerafragment/src/main/res/color/switch_camera_mode_selector.xml b/camerafragment/src/main/res/color/switch_camera_mode_selector.xml new file mode 100644 index 0000000..82c5e84 --- /dev/null +++ b/camerafragment/src/main/res/color/switch_camera_mode_selector.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/camerafragment/src/main/res/drawable/switch_camera_mode_selector.xml b/camerafragment/src/main/res/drawable/switch_camera_mode_selector.xml deleted file mode 100644 index 2399709..0000000 --- a/camerafragment/src/main/res/drawable/switch_camera_mode_selector.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/camerafragment/src/main/res/values/styles.xml b/camerafragment/src/main/res/values/styles.xml index d95683a..028ab07 100755 --- a/camerafragment/src/main/res/values/styles.xml +++ b/camerafragment/src/main/res/values/styles.xml @@ -7,7 +7,7 @@ 1 center_horizontal ?attr/selectableItemBackground - 10dp + 10sp true #fafafa