Merge pull request #104 from amadeu01/master

Fixed lint issues
pull/109/head
Florent CHAMPIGNY 7 years ago committed by GitHub
commit 16680dcbd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivity.java
  2. 2
      app/src/main/java/com/github/florent37/camerafragment/sample/CameraFragmentMainActivityCustoms.java
  3. 2
      app/src/main/res/values/strings.xml
  4. 2
      camerafragment/src/main/java/com/github/florent37/camerafragment/internal/manager/impl/Camera2Manager.java
  5. 9
      camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/CountdownTask.java
  6. 18
      camerafragment/src/main/java/com/github/florent37/camerafragment/internal/timer/TimerTask.java
  7. 16
      camerafragment/src/main/java/com/github/florent37/camerafragment/internal/ui/BaseAnncaFragment.java
  8. 11
      camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSettingsView.java
  9. 5
      camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/CameraSwitchView.java
  10. 6
      camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/FlashSwitchView.java
  11. 10
      camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/MediaActionSwitchView.java
  12. 4
      camerafragment/src/main/java/com/github/florent37/camerafragment/widgets/RecordButton.java
  13. 7
      camerafragment/src/main/res/color/switch_camera_mode_selector.xml
  14. 7
      camerafragment/src/main/res/drawable/switch_camera_mode_selector.xml
  15. 2
      camerafragment/src/main/res/values/styles.xml

@ -1,6 +1,7 @@
package com.github.florent37.camerafragment.sample; package com.github.florent37.camerafragment.sample;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -34,6 +35,7 @@ import butterknife.Bind;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
@SuppressLint("MissingPermission")
public class CameraFragmentMainActivity extends AppCompatActivity { public class CameraFragmentMainActivity extends AppCompatActivity {
public static final String FRAGMENT_TAG = "camera"; public static final String FRAGMENT_TAG = "camera";

@ -1,6 +1,7 @@
package com.github.florent37.camerafragment.sample; package com.github.florent37.camerafragment.sample;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
@ -28,6 +29,7 @@ import butterknife.Bind;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
@SuppressLint("MissingPermission")
public class CameraFragmentMainActivityCustoms extends AppCompatActivity { public class CameraFragmentMainActivityCustoms extends AppCompatActivity {
private static final int REQUEST_CAMERA_PERMISSIONS = 931; private static final int REQUEST_CAMERA_PERMISSIONS = 931;

@ -1,3 +1,3 @@
<resources> <resources>
<string name="app_name">CameraFragment</string> <string translatable="false" name="app_name">CameraFragment</string>
</resources> </resources>

@ -1,5 +1,6 @@
package com.github.florent37.camerafragment.internal.manager.impl; package com.github.florent37.camerafragment.internal.manager.impl;
import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.graphics.ImageFormat; import android.graphics.ImageFormat;
@ -54,6 +55,7 @@ import java.util.Objects;
* Created by memfis on 8/9/16. * Created by memfis on 8/9/16.
*/ */
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
@SuppressLint("MissingPermission")
public final class Camera2Manager extends BaseCameraManager<String, TextureView.SurfaceTextureListener> public final class Camera2Manager extends BaseCameraManager<String, TextureView.SurfaceTextureListener>
implements ImageReader.OnImageAvailableListener, TextureView.SurfaceTextureListener { implements ImageReader.OnImageAvailableListener, TextureView.SurfaceTextureListener {

@ -1,7 +1,6 @@
package com.github.florent37.camerafragment.internal.timer; package com.github.florent37.camerafragment.internal.timer;
import android.graphics.Color; import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.github.florent37.camerafragment.internal.utils.DateTimeUtils; import com.github.florent37.camerafragment.internal.utils.DateTimeUtils;
@ -28,7 +27,8 @@ public class CountdownTask extends TimerTaskBase implements Runnable {
if (callback != null) { if (callback != null) {
callback.setText( callback.setText(
String.format("%02d:%02d", String.format(Locale.getDefault(),
"%02d:%02d",
TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toMinutes(millis),
TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MILLISECONDS.toSeconds(millis) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)) TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))
@ -52,7 +52,8 @@ public class CountdownTask extends TimerTaskBase implements Runnable {
recordingTimeSeconds = maxDurationMilliseconds / 1000; recordingTimeSeconds = maxDurationMilliseconds / 1000;
if (callback != null) { if (callback != null) {
callback.setText( callback.setText(
String.format("%02d:%02d", String.format(Locale.getDefault(),
"%02d:%02d",
TimeUnit.MILLISECONDS.toMinutes(maxDurationMilliseconds), TimeUnit.MILLISECONDS.toMinutes(maxDurationMilliseconds),
TimeUnit.MILLISECONDS.toSeconds(maxDurationMilliseconds) - TimeUnit.MILLISECONDS.toSeconds(maxDurationMilliseconds) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(maxDurationMilliseconds)) TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(maxDurationMilliseconds))

@ -2,6 +2,8 @@ package com.github.florent37.camerafragment.internal.timer;
import com.github.florent37.camerafragment.internal.utils.DateTimeUtils; import com.github.florent37.camerafragment.internal.utils.DateTimeUtils;
import java.util.Locale;
/* /*
* Created by florentchampigny on 13/01/2017. * Created by florentchampigny on 13/01/2017.
*/ */
@ -22,7 +24,13 @@ public class TimerTask extends TimerTaskBase implements Runnable {
} }
if(callback != null) { if(callback != null) {
callback.setText( callback.setText(
String.format("%02d:%02d", recordingTimeMinutes, recordingTimeSeconds)); String.format(
Locale.getDefault(),
"%02d:%02d",
recordingTimeMinutes,
recordingTimeSeconds
)
);
} }
if (alive) handler.postDelayed(this, DateTimeUtils.SECOND); if (alive) handler.postDelayed(this, DateTimeUtils.SECOND);
} }
@ -33,7 +41,13 @@ public class TimerTask extends TimerTaskBase implements Runnable {
recordingTimeSeconds = 0; recordingTimeSeconds = 0;
if(callback != null) { if(callback != null) {
callback.setText( callback.setText(
String.format("%02d:%02d", recordingTimeMinutes, recordingTimeSeconds)); String.format(
Locale.getDefault(),
"%02d:%02d",
recordingTimeMinutes,
recordingTimeSeconds
)
);
callback.setTextVisible(true); callback.setTextVisible(true);
} }
handler.postDelayed(this, DateTimeUtils.SECOND); handler.postDelayed(this, DateTimeUtils.SECOND);

@ -1,5 +1,6 @@
package com.github.florent37.camerafragment.internal.ui; package com.github.florent37.camerafragment.internal.ui;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@ -54,9 +55,10 @@ import java.util.ArrayList;
/* /*
* Created by memfis on 12/1/16. * Created by memfis on 12/1/16.
* Updated by Florent37 * Updated by amadeu01
*/ */
@SuppressLint("WrongConstant")
public abstract class BaseAnncaFragment<CameraId> extends Fragment implements CameraFragmentApi { public abstract class BaseAnncaFragment<CameraId> extends Fragment implements CameraFragmentApi {
public static final String ARG_CONFIGURATION = "configuration"; public static final String ARG_CONFIGURATION = "configuration";
@ -152,7 +154,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment implements Ca
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View decorView = ((Activity) container.getContext()).getWindow().getDecorView(); 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; int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions); decorView.setSystemUiVisibility(uiOptions);
} }
@ -347,8 +349,8 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment implements Ca
public PhotoQualityOption[] getPhotoQualities() { public PhotoQualityOption[] getPhotoQualities() {
ArrayList<PhotoQualityOption> photoQualityOptions = new ArrayList<>(); ArrayList<PhotoQualityOption> photoQualityOptions = new ArrayList<>();
for (CharSequence photoQualitie: photoQualities) { for (CharSequence photoQuality: photoQualities) {
photoQualityOptions.add((PhotoQualityOption) photoQualitie); photoQualityOptions.add((PhotoQualityOption) photoQuality);
} }
return photoQualityOptions.toArray(new PhotoQualityOption[photoQualityOptions.size()]); return photoQualityOptions.toArray(new PhotoQualityOption[photoQualityOptions.size()]);
} }
@ -604,7 +606,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment implements Ca
} }
protected void takePhoto(CameraFragmentResultListener callback, @Nullable String directoryPath, @Nullable String fileName) { 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); new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK);
} }
setRecordState(Record.TAKE_PHOTO_STATE); setRecordState(Record.TAKE_PHOTO_STATE);
@ -615,7 +617,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment implements Ca
} }
protected void startRecording(@Nullable String directoryPath, @Nullable String fileName) { 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); new MediaActionSound().play(MediaActionSound.START_VIDEO_RECORDING);
} }
@ -628,7 +630,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment implements Ca
} }
protected void stopRecording(CameraFragmentResultListener callback) { 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); new MediaActionSound().play(MediaActionSound.STOP_VIDEO_RECORDING);
} }

@ -1,17 +1,16 @@
package com.github.florent37.camerafragment.widgets; package com.github.florent37.camerafragment.widgets;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.ImageButton;
import com.github.florent37.camerafragment.R; import com.github.florent37.camerafragment.R;
/* /*
* Created by memfis on 8/23/16. * 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) { public CameraSettingsView(Context context) {
this(context, null); this(context, null);
@ -26,12 +25,6 @@ public class CameraSettingsView extends ImageButton {
init(); 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() { private void init() {
setBackgroundResource(R.drawable.circle_frame_background_dark); setBackgroundResource(R.drawable.circle_frame_background_dark);
setImageResource(R.drawable.ic_settings_white_24dp); setImageResource(R.drawable.ic_settings_white_24dp);

@ -15,6 +15,7 @@ import com.github.florent37.camerafragment.internal.utils.Utils;
/* /*
* Created by memfis on 6/24/16. * Created by memfis on 6/24/16.
* Updated by amadeu01 on 17/04/17
*/ */
public class CameraSwitchView extends AppCompatImageButton { public class CameraSwitchView extends AppCompatImageButton {
@ -39,11 +40,11 @@ public class CameraSwitchView extends AppCompatImageButton {
Context context = getContext(); Context context = getContext();
frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp); frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp);
frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable); 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 = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp);
rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable); 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); setBackgroundResource(R.drawable.circle_frame_background_dark);
displayBackCamera(); displayBackCamera();

@ -5,19 +5,17 @@ import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageButton;
import com.github.florent37.camerafragment.R; import com.github.florent37.camerafragment.R;
/* /*
* Created by memfis on 7/6/16. * 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 flashOnDrawable;
private Drawable flashOffDrawable; private Drawable flashOffDrawable;

@ -8,15 +8,15 @@ import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.ImageButton;
import com.github.florent37.camerafragment.R; import com.github.florent37.camerafragment.R;
import com.github.florent37.camerafragment.internal.utils.Utils; import com.github.florent37.camerafragment.internal.utils.Utils;
/* /*
* Created by memfis on 6/24/16. * 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 @Nullable
private OnMediaActionStateChangeListener onMediaActionStateChangeListener; private OnMediaActionStateChangeListener onMediaActionStateChangeListener;
@ -47,11 +47,11 @@ public class MediaActionSwitchView extends ImageButton {
photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp); photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp);
photoDrawable = DrawableCompat.wrap(photoDrawable); 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 = ContextCompat.getDrawable(context, R.drawable.ic_videocam_white_24dp);
videoDrawable = DrawableCompat.wrap(videoDrawable); 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_dark);
// setBackgroundResource(R.drawable.circle_frame_background); // setBackgroundResource(R.drawable.circle_frame_background);
@ -79,7 +79,7 @@ public class MediaActionSwitchView extends ImageButton {
setImageDrawable(videoDrawable); setImageDrawable(videoDrawable);
} }
public void setOnMediaActionStateChangeListener(OnMediaActionStateChangeListener onMediaActionStateChangeListener) { public void setOnMediaActionStateChangeListener(@Nullable OnMediaActionStateChangeListener onMediaActionStateChangeListener) {
this.onMediaActionStateChangeListener = onMediaActionStateChangeListener; this.onMediaActionStateChangeListener = onMediaActionStateChangeListener;
} }

@ -8,15 +8,15 @@ import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.ImageButton;
import com.github.florent37.camerafragment.R; import com.github.florent37.camerafragment.R;
import com.github.florent37.camerafragment.internal.utils.Utils; import com.github.florent37.camerafragment.internal.utils.Utils;
/* /*
* Created by memfis on 7/6/16. * 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 { public interface RecordButtonListener {
void onRecordButtonClicked(); void onRecordButtonClicked();

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#ffeb3b"/>
<item android:color="#fafafa"/>
</selector>

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#ffeb3b"></item>
<item android:color="#fafafa"></item>
</selector>

@ -7,7 +7,7 @@
<item name="android:layout_weight">1</item> <item name="android:layout_weight">1</item>
<item name="android:gravity">center_horizontal</item> <item name="android:gravity">center_horizontal</item>
<item name="android:background">?attr/selectableItemBackground</item> <item name="android:background">?attr/selectableItemBackground</item>
<item name="android:textSize">10dp</item> <item name="android:textSize">10sp</item>
<item name="android:clickable">true</item> <item name="android:clickable">true</item>
<item name="android:textColor">#fafafa</item> <item name="android:textColor">#fafafa</item>
</style> </style>

Loading…
Cancel
Save