demo app updates

pull/1/head
Dylan McIntyre 8 years ago
parent d1e8684850
commit 4567c66e9d
  1. 2
      camerakit/build.gradle
  2. 5
      camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
  3. BIN
      demo/src/main/ic_launcher-web.png
  4. 38
      demo/src/main/java/com/flurgle/camerakit/demo/AutoUnfocusEditText.java
  5. 92
      demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java
  6. 145
      demo/src/main/res/layout/activity_main.xml
  7. BIN
      demo/src/main/res/mipmap-hdpi/ic_launcher.png
  8. BIN
      demo/src/main/res/mipmap-mdpi/ic_launcher.png
  9. BIN
      demo/src/main/res/mipmap-xhdpi/ic_launcher.png
  10. BIN
      demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
  11. BIN
      demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  12. 6
      demo/src/main/res/values/colors.xml

@ -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 {

@ -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;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 50 KiB

@ -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);
}
}

@ -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);
}
@OnCheckedChanged({R.id.widthCustom, R.id.widthWrapContent, R.id.widthMatchParent})
void widthModeChanged(CompoundButton buttonCompat, boolean checked) {
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);
}
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 {

@ -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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<com.flurgle.camerakit.CameraView xmlns:app="http://schemas.android.com/apk/res-auto"
@ -21,7 +21,7 @@
app:ckCropOutput="true"
app:ckFacing="back"
app:ckFlash="off"
app:ckPictureMode="speed"
app:ckPictureMode="quality"
app:ckTapToFocus="visible" />
<LinearLayout
@ -109,27 +109,27 @@
android:textSize="14dp"
android:textStyle="bold" />
<LinearLayout
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:checkedButton="@+id/modeCaptureQuality"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/modeQuality"
<RadioButton
android:id="@+id/modeCaptureQuality"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Quality" />
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/modeSpeed"
<RadioButton
android:id="@+id/modeCaptureSpeed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Speed" />
</LinearLayout>
</RadioGroup>
</LinearLayout>
@ -160,26 +160,86 @@
android:textSize="14dp"
android:textStyle="bold" />
<LinearLayout
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:checkedButton="@+id/modeCropVisible"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatCheckBox
<RadioButton
android:id="@+id/modeCropVisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Crop to visible" />
<android.support.v7.widget.AppCompatCheckBox
<RadioButton
android:id="@+id/modeCropFullSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Full size" />
</RadioGroup>
</LinearLayout>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<View
android:layout_width="2.5dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="TAP TO FOCUS"
android:textColor="@android:color/black"
android:textSize="14dp"
android:textStyle="bold" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:checkedButton="@+id/modeTapToFocusVisible"
android:orientation="horizontal">
<RadioButton
android:id="@+id/modeTapToFocusVisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Visible" />
<RadioButton
android:id="@+id/modeTapToFocusInvisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Invisible" />
<RadioButton
android:id="@+id/modeTapToFocusOff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Off" />
</RadioGroup>
</LinearLayout>
</FrameLayout>
@ -198,6 +258,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">
<TextView
@ -218,34 +281,41 @@
android:textColor="@android:color/black"
android:textSize="11dp" />
<EditText
<com.flurgle.camerakit.demo.AutoUnFocusEditText
android:id="@+id/width"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="pixels"
android:inputType="number" />
<LinearLayout
android:layout_width="wrap_content"
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="center"
android:checkedButton="@+id/widthCustom"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatCheckBox
<RadioButton
android:id="@+id/widthCustom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom" />
<RadioButton
android:id="@+id/widthWrapContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="wrap_content" />
<android.support.v7.widget.AppCompatCheckBox
<RadioButton
android:id="@+id/widthMatchParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginLeft="10dp"
android:text="match_parent" />
</LinearLayout>
</RadioGroup>
</LinearLayout>
@ -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">
<TextView
@ -285,34 +358,42 @@
android:textColor="@android:color/black"
android:textSize="11dp" />
<EditText
<com.flurgle.camerakit.demo.AutoUnFocusEditText
android:id="@+id/height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="pixels"
android:inputType="number" />
<LinearLayout
android:layout_width="wrap_content"
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="center"
android:checkedButton="@+id/heightCustom"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatCheckBox
<RadioButton
android:id="@+id/heightCustom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom" />
<RadioButton
android:id="@+id/heightWrapContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="wrap_content" />
<android.support.v7.widget.AppCompatCheckBox
<RadioButton
android:id="@+id/heightMatchParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginLeft="10dp"
android:text="match_parent" />
</LinearLayout>
</RadioGroup>
</LinearLayout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 15 KiB

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorPrimary">#FF4444</color>
<color name="colorPrimaryDark">#D74141</color>
<color name="colorAccent">#2BCFE5</color>
</resources>

Loading…
Cancel
Save