diff --git a/camerakit/build.gradle b/camerakit/build.gradle index 5855010d..9b89961e 100644 --- a/camerakit/build.gradle +++ b/camerakit/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.library' ext { PUBLISH_GROUP_ID = 'com.flurgle' PUBLISH_ARTIFACT_ID = 'camerakit' - PUBLISH_VERSION = '0.9.9' + PUBLISH_VERSION = '0.9.10' } android { diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java index dfefc723..4a46765c 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java @@ -241,6 +241,11 @@ public class CameraView extends FrameLayout { this.mPictureMode = pictureMode; } + @PictureMode + public int getPictureMode() { + return mPictureMode; + } + public void setCropOutput(boolean cropOutput) { this.mCropOutput = cropOutput; } diff --git a/demo/src/main/ic_launcher-web.png b/demo/src/main/ic_launcher-web.png index d5e90cdf..3ff1c5ad 100644 Binary files a/demo/src/main/ic_launcher-web.png and b/demo/src/main/ic_launcher-web.png differ diff --git a/demo/src/main/java/com/flurgle/camerakit/demo/AutoUnfocusEditText.java b/demo/src/main/java/com/flurgle/camerakit/demo/AutoUnfocusEditText.java new file mode 100644 index 00000000..0109ade0 --- /dev/null +++ b/demo/src/main/java/com/flurgle/camerakit/demo/AutoUnfocusEditText.java @@ -0,0 +1,38 @@ +package com.flurgle.camerakit.demo; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.KeyEvent; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; + +public class AutoUnFocusEditText extends EditText { + + public AutoUnFocusEditText(Context context) { + super(context); + } + + public AutoUnFocusEditText(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public AutoUnFocusEditText(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + public boolean onKeyPreIme(int keyCode, KeyEvent event) { + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { + closeKeyboard(); + clearFocus(); + return true; + } + return super.dispatchKeyEvent(event); + } + + private void closeKeyboard() { + InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(getWindowToken(), 0); + } + +} \ No newline at end of file diff --git a/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java b/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java index 7c703f6f..527506f9 100644 --- a/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java +++ b/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java @@ -8,9 +8,9 @@ import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; -import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; +import android.widget.RadioButton; import android.widget.TextView; import android.widget.Toast; @@ -24,7 +24,6 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnCheckedChanged; import butterknife.OnClick; -import butterknife.OnFocusChange; import butterknife.OnTextChanged; public class MainActivity extends AppCompatActivity { @@ -35,11 +34,11 @@ public class MainActivity extends AppCompatActivity { @BindView(R.id.camera) CameraView camera; - @BindView(R.id.modeQuality) - CheckBox modeQuality; + @BindView(R.id.modeCaptureQuality) + RadioButton modeQuality; - @BindView(R.id.modeSpeed) - CheckBox modeSpeed; + @BindView(R.id.modeCaptureSpeed) + RadioButton modeSpeed; @BindView(R.id.screenWidth) TextView screenWidth; @@ -48,10 +47,10 @@ public class MainActivity extends AppCompatActivity { EditText width; @BindView(R.id.widthWrapContent) - CheckBox widthWrapContent; + RadioButton widthWrapContent; @BindView(R.id.widthMatchParent) - CheckBox widthMatchParent; + RadioButton widthMatchParent; @BindView(R.id.screenHeight) TextView screenHeight; @@ -59,10 +58,6 @@ public class MainActivity extends AppCompatActivity { @BindView(R.id.height) EditText height; - int pictureMode = CameraKit.Constants.PICTURE_MODE_QUALITY; - - boolean blockInvalidation; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -160,29 +155,13 @@ public class MainActivity extends AppCompatActivity { } } - @OnCheckedChanged(R.id.modeQuality) - void modeQuality(CompoundButton buttonCompat, boolean checked) { - modeSpeed.setChecked(false); - if (checked) { - camera.setPictureMode(CameraKit.Constants.PICTURE_MODE_QUALITY); - } - - invalidateParameters(); - } - - @OnCheckedChanged(R.id.modeSpeed) - void modeSpeed(CompoundButton buttonCompat, boolean checked) { - modeQuality.setChecked(false); - if (checked) { - camera.setPictureMode(CameraKit.Constants.PICTURE_MODE_SPEED); - } - - invalidateParameters(); - } - - @OnFocusChange({R.id.width, R.id.height}) - void inputFocusChanged(View view, boolean f) { - blockInvalidation = view.isFocused(); + @OnCheckedChanged({R.id.modeCaptureQuality, R.id.modeCaptureSpeed}) + void pictureModeChanged(CompoundButton buttonCompat, boolean checked) { + camera.setPictureMode( + modeQuality.isChecked() ? + CameraKit.Constants.PICTURE_MODE_QUALITY : + CameraKit.Constants.PICTURE_MODE_SPEED + ); } @OnTextChanged(value = R.id.width, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) @@ -192,54 +171,25 @@ public class MainActivity extends AppCompatActivity { } } - @OnCheckedChanged(R.id.widthWrapContent) - void widthWrapContent(CompoundButton buttonCompat, boolean checked) { - if (checked) { - ViewGroup.LayoutParams layoutParams = camera.getLayoutParams(); - layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; - camera.setLayoutParams(layoutParams); - - widthMatchParent.setChecked(false); - } - - invalidateParameters(); - } - - @OnCheckedChanged(R.id.widthMatchParent) - void widthMatchParent(CompoundButton buttonCompat, boolean checked) { - if (checked) { - ViewGroup.LayoutParams layoutParams = camera.getLayoutParams(); - layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; - camera.setLayoutParams(layoutParams); - - widthWrapContent.setChecked(false); - } + @OnCheckedChanged({R.id.widthCustom, R.id.widthWrapContent, R.id.widthMatchParent}) + void widthModeChanged(CompoundButton buttonCompat, boolean checked) { - invalidateParameters(); } - @OnTextChanged(value = R.id.height, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) + @OnTextChanged(value = R.id.height) void heightChanged() { if (height.isFocused()) { new Handler().postDelayed(new UpdateCameraRunnable(height), 2000); } } - @OnCheckedChanged(R.id.heightWrapContent) - void heightWrapContent() { - invalidateParameters(); - } + @OnCheckedChanged({R.id.heightCustom, R.id.heightWrapContent, R.id.heightMatchParent}) + void heightModeChanged() { - @OnCheckedChanged(R.id.heightMatchParent) - void heightMatchParent() { - invalidateParameters(); } - private void invalidateParameters() { - if (blockInvalidation) return; - - blockInvalidation = true; + private void invalidateParameters() { if (!widthMatchParent.isChecked() && !widthWrapContent.isChecked()) { width.setText(String.valueOf(camera.getWidth())); width.setHint("pixels"); @@ -252,8 +202,6 @@ public class MainActivity extends AppCompatActivity { } height.setText(String.valueOf(camera.getHeight())); - - blockInvalidation = false; } private class UpdateCameraRunnable implements Runnable { diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index 17cbe044..c9f876ea 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -3,14 +3,14 @@ android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/white"> + android:background="@android:color/white" + android:descendantFocusability="beforeDescendants" + android:focusable="true" + android:focusableInTouchMode="true"> - - - - + @@ -160,25 +160,27 @@ android:textSize="14dp" android:textStyle="bold" /> - - - - + @@ -200,6 +202,67 @@ android:layout_marginLeft="10dp" android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + - - - + + - - + @@ -265,6 +335,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" + android:descendantFocusability="beforeDescendants" + android:focusable="true" + android:focusableInTouchMode="true" android:orientation="vertical"> - - - + + - - + + diff --git a/demo/src/main/res/mipmap-hdpi/ic_launcher.png b/demo/src/main/res/mipmap-hdpi/ic_launcher.png index 5af37150..a5b43ee5 100644 Binary files a/demo/src/main/res/mipmap-hdpi/ic_launcher.png and b/demo/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/demo/src/main/res/mipmap-mdpi/ic_launcher.png b/demo/src/main/res/mipmap-mdpi/ic_launcher.png index 0973cc3e..fd71b7d7 100644 Binary files a/demo/src/main/res/mipmap-mdpi/ic_launcher.png and b/demo/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/demo/src/main/res/mipmap-xhdpi/ic_launcher.png b/demo/src/main/res/mipmap-xhdpi/ic_launcher.png index a85cbc11..28317796 100644 Binary files a/demo/src/main/res/mipmap-xhdpi/ic_launcher.png and b/demo/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png b/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png index 53d48558..0384038c 100644 Binary files a/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png index e02c6eab..8c78dc57 100644 Binary files a/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/demo/src/main/res/values/colors.xml b/demo/src/main/res/values/colors.xml index 3ab3e9cb..2743ca0d 100644 --- a/demo/src/main/res/values/colors.xml +++ b/demo/src/main/res/values/colors.xml @@ -1,6 +1,6 @@ - #3F51B5 - #303F9F - #FF4081 + #FF4444 + #D74141 + #2BCFE5