rename to demo, automatically centerCrop camera preview based on size

pull/1/head
Dylan McIntyre 8 years ago
parent 4fe5277feb
commit 7fbda858dc
  1. 22
      .idea/compiler.xml
  2. 3
      .idea/copyright/profiles_settings.xml
  3. 19
      .idea/gradle.xml
  4. 12
      .idea/libraries/animated_vector_drawable_25_0_1.xml
  5. 15
      .idea/libraries/appcompat_v7_25_0_1.xml
  6. 14
      .idea/libraries/support_annotations_25_0_1.xml
  7. 16
      .idea/libraries/support_compat_25_0_1.xml
  8. 16
      .idea/libraries/support_core_ui_25_0_1.xml
  9. 16
      .idea/libraries/support_core_utils_25_0_1.xml
  10. 16
      .idea/libraries/support_fragment_25_0_1.xml
  11. 16
      .idea/libraries/support_media_compat_25_0_1.xml
  12. 10
      .idea/libraries/support_v4_25_0_1.xml
  13. 12
      .idea/libraries/support_vector_drawable_25_0_1.xml
  14. 36
      .idea/misc.xml
  15. 10
      .idea/modules.xml
  16. 12
      .idea/runConfigurations.xml
  17. 14
      camerakit/build.gradle
  18. 1
      camerakit/src/main/java/com/wonderkiln/camerakit/Camera2.java
  19. 5
      camerakit/src/main/java/com/wonderkiln/camerakit/CameraView.java
  20. 8
      camerakit/src/main/java/com/wonderkiln/camerakit/PreviewImpl.java
  21. 1
      camerakit/src/main/java/com/wonderkiln/camerakit/TextureViewPreview.java
  22. 0
      demo/.gitignore
  23. 0
      demo/build.gradle
  24. 0
      demo/proguard-rules.pro
  25. 0
      demo/src/androidTest/java/com/wonderkiln/camerakit/demo/ExampleInstrumentedTest.java
  26. 0
      demo/src/main/AndroidManifest.xml
  27. 9
      demo/src/main/java/com/wonderkiln/camerakit/demo/MainActivity.java
  28. 5
      demo/src/main/res/layout/activity_main.xml
  29. 0
      demo/src/main/res/mipmap-hdpi/ic_launcher.png
  30. 0
      demo/src/main/res/mipmap-hdpi/ic_launcher_round.png
  31. 0
      demo/src/main/res/mipmap-mdpi/ic_launcher.png
  32. 0
      demo/src/main/res/mipmap-mdpi/ic_launcher_round.png
  33. 0
      demo/src/main/res/mipmap-xhdpi/ic_launcher.png
  34. 0
      demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  35. 0
      demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
  36. 0
      demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  37. 0
      demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  38. 0
      demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  39. 0
      demo/src/main/res/values/colors.xml
  40. 0
      demo/src/main/res/values/strings.xml
  41. 0
      demo/src/main/res/values/styles.xml
  42. 0
      demo/src/test/java/com/wonderkiln/camerakit/demo/ExampleUnitTest.java
  43. 2
      settings.gradle

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/camerakit" />
<option value="$PROJECT_DIR$/demo" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,12 @@
<component name="libraryTable">
<library name="animated-vector-drawable-25.0.1">
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/a14dfd4122d9ec8ac647e1599ab6330756ed764f/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/a14dfd4122d9ec8ac647e1599ab6330756ed764f/output/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/25.0.1/animated-vector-drawable-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,15 @@
<component name="libraryTable">
<library name="appcompat-v7-25.0.1">
<ANNOTATIONS>
<root url="jar://$USER_HOME$/.android/build-cache/3dc0fd89d2c701002f1eaa15f76f1946492d475e/output/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/3dc0fd89d2c701002f1eaa15f76f1946492d475e/output/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/3dc0fd89d2c701002f1eaa15f76f1946492d475e/output/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/25.0.1/appcompat-v7-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="support-annotations-25.0.1">
<ANNOTATIONS>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/25.0.1/support-annotations-25.0.1-annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/25.0.1/support-annotations-25.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/25.0.1/support-annotations-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,16 @@
<component name="libraryTable">
<library name="support-compat-25.0.1">
<ANNOTATIONS>
<root url="jar://$USER_HOME$/.android/build-cache/61a0a0ddfbb28af4e3621c3bbd38787bd341ea75/output/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/61a0a0ddfbb28af4e3621c3bbd38787bd341ea75/output/jars/classes.jar!/" />
<root url="jar://$USER_HOME$/.android/build-cache/61a0a0ddfbb28af4e3621c3bbd38787bd341ea75/output/jars/libs/internal_impl-25.0.1.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/61a0a0ddfbb28af4e3621c3bbd38787bd341ea75/output/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-compat/25.0.1/support-compat-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,16 @@
<component name="libraryTable">
<library name="support-core-ui-25.0.1">
<ANNOTATIONS>
<root url="jar://$USER_HOME$/.android/build-cache/3ffa9a41c8f42cddb64a7c7ef58bb643868fff95/output/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/3ffa9a41c8f42cddb64a7c7ef58bb643868fff95/output/jars/libs/internal_impl-25.0.1.jar!/" />
<root url="jar://$USER_HOME$/.android/build-cache/3ffa9a41c8f42cddb64a7c7ef58bb643868fff95/output/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/3ffa9a41c8f42cddb64a7c7ef58bb643868fff95/output/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-core-ui/25.0.1/support-core-ui-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,16 @@
<component name="libraryTable">
<library name="support-core-utils-25.0.1">
<ANNOTATIONS>
<root url="jar://$USER_HOME$/.android/build-cache/3e94c7f8bca080cfbc1c8643adc728143557f195/output/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/3e94c7f8bca080cfbc1c8643adc728143557f195/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/3e94c7f8bca080cfbc1c8643adc728143557f195/output/jars/classes.jar!/" />
<root url="jar://$USER_HOME$/.android/build-cache/3e94c7f8bca080cfbc1c8643adc728143557f195/output/jars/libs/internal_impl-25.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-core-utils/25.0.1/support-core-utils-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,16 @@
<component name="libraryTable">
<library name="support-fragment-25.0.1">
<ANNOTATIONS>
<root url="jar://$USER_HOME$/.android/build-cache/beffe7960a95b7cd19161bf33cf77ccc04a16ba8/output/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/beffe7960a95b7cd19161bf33cf77ccc04a16ba8/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/beffe7960a95b7cd19161bf33cf77ccc04a16ba8/output/jars/classes.jar!/" />
<root url="jar://$USER_HOME$/.android/build-cache/beffe7960a95b7cd19161bf33cf77ccc04a16ba8/output/jars/libs/internal_impl-25.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-fragment/25.0.1/support-fragment-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,16 @@
<component name="libraryTable">
<library name="support-media-compat-25.0.1">
<ANNOTATIONS>
<root url="jar://$USER_HOME$/.android/build-cache/79f7995dc61f3acc4da1baf0acc53718857b78d0/output/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/79f7995dc61f3acc4da1baf0acc53718857b78d0/output/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/79f7995dc61f3acc4da1baf0acc53718857b78d0/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/79f7995dc61f3acc4da1baf0acc53718857b78d0/output/jars/libs/internal_impl-25.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-media-compat/25.0.1/support-media-compat-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="support-v4-25.0.1">
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/d6d4c86939de301ed7868ff574de32e494441379/output/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/d6d4c86939de301ed7868ff574de32e494441379/output/res" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -0,0 +1,12 @@
<component name="libraryTable">
<library name="support-vector-drawable-25.0.1">
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/1d4074d5b53f293292f1c881bb91c9e73b9907d3/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/1d4074d5b53f293292f1c881bb91c9e73b9907d3/output/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-vector-drawable/25.0.1/support-vector-drawable-25.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8 (2)" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/camerakit/camerakit.iml" filepath="$PROJECT_DIR$/camerakit/camerakit.iml" />
<module fileurl="file://$PROJECT_DIR$/camerakit-android.iml" filepath="$PROJECT_DIR$/camerakit-android.iml" />
<module fileurl="file://$PROJECT_DIR$/demo/demo.iml" filepath="$PROJECT_DIR$/demo/demo.iml" />
</modules>
</component>
</project>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

@ -1,5 +1,11 @@
apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'com.wonderkiln'
PUBLISH_ARTIFACT_ID = 'camerakit'
PUBLISH_VERSION = '0.9.0'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
@ -9,9 +15,6 @@ android {
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
@ -22,5 +25,8 @@ android {
}
dependencies {
compile 'com.android.support:appcompat-v7:25.0.1'
}
apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'

@ -371,6 +371,7 @@ public class Camera2 extends CameraViewImpl {
}
Size previewSize = getOptimalPreviewSize();
mPreview.setBufferSize(previewSize.getWidth(), previewSize.getHeight());
Surface surface = mPreview.getSurface();
try {

@ -97,11 +97,6 @@ public class CameraView extends FrameLayout {
super.onDetachedFromWindow();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected Parcelable onSaveInstanceState() {
SavedState state = new SavedState(super.onSaveInstanceState());

@ -44,6 +44,14 @@ abstract class PreviewImpl {
}
void setBufferSize(int width, int height) {
AspectRatio aspectRatio = AspectRatio.of(width, height);
int targetHeight = (int) (getView().getWidth() * aspectRatio.toFloat());
float scaleY = (float) targetHeight / (float) getView().getHeight();
if (scaleY > 1) {
getView().setScaleY(scaleY);
} else {
getView().setScaleX(1 / scaleY);
}
}
void setSize(int width, int height) {

@ -91,6 +91,7 @@ public class TextureViewPreview extends PreviewImpl {
@TargetApi(15)
@Override
void setBufferSize(int width, int height) {
super.setBufferSize(width, height);
mTextureView.getSurfaceTexture().setDefaultBufferSize(width, height);
}

@ -1,14 +1,21 @@
package com.wonderkiln.camerakit.demo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.wonderkiln.camerakit.CameraView;
public class MainActivity extends AppCompatActivity {
private CameraView camera;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
camera = (CameraView) findViewById(R.id.camera);
camera.start();
}
}

@ -3,6 +3,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.wonderkiln.camerakit.CameraView
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

@ -1 +1 @@
include ':app', ':camerakit'
include ':demo', ':camerakit'

Loading…
Cancel
Save