diff --git a/camerakit/src/main/java/com/flurgle/camerakit/utils/CenterCrop.java b/camerakit/src/main/java/com/flurgle/camerakit/utils/CenterCrop.java index a94febca..eb08fbd6 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/utils/CenterCrop.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/utils/CenterCrop.java @@ -27,10 +27,6 @@ public class CenterCrop { this.croppedJpeg = out.toByteArray(); } - public byte[] getJpeg() { - return croppedJpeg; - } - private static Rect getCrop(int currentWidth, int currentHeight, AspectRatio targetRatio) { AspectRatio currentRatio = AspectRatio.of(currentWidth, currentHeight); @@ -48,4 +44,8 @@ public class CenterCrop { return crop; } + public byte[] getJpeg() { + return croppedJpeg; + } + } diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index 7f5572c7..6bad6b6f 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -12,7 +12,8 @@ + android:screenOrientation="portrait" + android:theme="@style/Theme.MainActivity"> 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 8f43666c..149fccd1 100644 --- a/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java +++ b/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java @@ -103,6 +103,8 @@ public class MainActivity extends AppCompatActivity { captureModeRadioGroup.setOnCheckedChangeListener(captureModeChangedListener); cropModeRadioGroup.setOnCheckedChangeListener(cropModeChangedListener); tapToFocusModeRadioGroup.setOnCheckedChangeListener(tapToFocusModeChangedListener); + widthModeRadioGroup.setOnCheckedChangeListener(widthModeChangedListener); + heightModeRadioGroup.setOnCheckedChangeListener(heightModeChangedListener); } @Override @@ -220,11 +222,7 @@ public class MainActivity extends AppCompatActivity { @OnTextChanged(value = R.id.width, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) void widthChanged() { - if (String.valueOf(mCameraWidth).equals(width.getText().toString())) { - widthUpdate.setAlpha(.2f); - } else { - widthUpdate.setAlpha(1f); - } + } @OnClick(R.id.widthUpdate) @@ -234,13 +232,20 @@ public class MainActivity extends AppCompatActivity { } } + RadioGroup.OnCheckedChangeListener widthModeChangedListener = new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + widthUpdate.setEnabled(checkedId == R.id.widthCustom); + widthUpdate.setAlpha(checkedId == R.id.widthCustom ? 1f : 0.3f); + width.clearFocus(); + width.setEnabled(checkedId == R.id.widthCustom); + width.setAlpha(checkedId == R.id.widthCustom ? 1f : 0.5f); + } + }; + @OnTextChanged(value = R.id.height) void heightChanged() { - if (String.valueOf(mCameraHeight).equals(height.getText().toString())) { - heightUpdate.setAlpha(.2f); - } else { - heightUpdate.setAlpha(1f); - } + } @OnClick(R.id.heightUpdate) @@ -250,6 +255,17 @@ public class MainActivity extends AppCompatActivity { } } + RadioGroup.OnCheckedChangeListener heightModeChangedListener = new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + heightUpdate.setEnabled(checkedId == R.id.heightCustom); + heightUpdate.setAlpha(checkedId == R.id.heightCustom ? 1f : 0.3f); + height.clearFocus(); + height.setEnabled(checkedId == R.id.heightCustom); + height.setAlpha(checkedId == R.id.heightCustom ? 1f : 0.5f); + } + }; + private void updateCamera(boolean updateWidth, boolean updateHeight) { ViewGroup.LayoutParams cameraLayoutParams = camera.getLayoutParams(); int width = cameraLayoutParams.width; diff --git a/demo/src/main/res/drawable/launch_bg.xml b/demo/src/main/res/drawable/launch_bg.xml new file mode 100644 index 00000000..00b7dffc --- /dev/null +++ b/demo/src/main/res/drawable/launch_bg.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + diff --git a/demo/src/main/res/values/styles.xml b/demo/src/main/res/values/styles.xml index 90375456..58dc89ea 100644 --- a/demo/src/main/res/values/styles.xml +++ b/demo/src/main/res/values/styles.xml @@ -8,6 +8,10 @@ @color/colorAccent + +