Skip to content

Commit

Permalink
Add new sample YIVirtualCamera.
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyubo committed Dec 7, 2016
1 parent 1f71948 commit d8b9f22
Show file tree
Hide file tree
Showing 212 changed files with 2,974 additions and 0 deletions.
Binary file modified sdk/java/libs/libyiaction.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions sdk/java/samples/YIVirtualCamera/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
22 changes: 22 additions & 0 deletions sdk/java/samples/YIVirtualCamera/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions sdk/java/samples/YIVirtualCamera/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions sdk/java/samples/YIVirtualCamera/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions sdk/java/samples/YIVirtualCamera/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions sdk/java/samples/YIVirtualCamera/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions sdk/java/samples/YIVirtualCamera/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdk/java/samples/YIVirtualCamera/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
28 changes: 28 additions & 0 deletions sdk/java/samples/YIVirtualCamera/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"

defaultConfig {
applicationId "com.xiaoyi.yivirtualcamera"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile files('libs/libyiaction.jar')
}
Binary file not shown.
17 changes: 17 additions & 0 deletions sdk/java/samples/YIVirtualCamera/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/xyb/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
23 changes: 23 additions & 0 deletions sdk/java/samples/YIVirtualCamera/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xiaoyi.yivirtualcamera">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>

<application
android:allowBackup="true"
android:icon="@drawable/white_camera"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:name=".VirtualCameraActivity" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.xiaoyi.yivirtualcamera;

/**
* Created by xyb on 11/16/2016.
*/

public interface CameraObserver {
void onCameraSettingsUpdated();
void onBatteryLifeChanged(int restBatteryLife);
void onVideoFinderChanged(boolean started);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.xiaoyi.yivirtualcamera;

import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.util.AttributeSet;
import android.widget.VideoView;

/**
* Created by xyb on 12/4/2016.
*/

public class CustomVideoView extends VideoView {
public CustomVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public void play(String uri) {
setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
start();
}
});
setVideoURI(Uri.parse(uri));
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.xiaoyi.yivirtualcamera;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Movie;
import android.util.AttributeSet;
import android.widget.ImageView;

public class GifView extends ImageView {
private Movie mMovie;
private long mStart;

public GifView(Context context, AttributeSet attrs) {
super(context, attrs);

int src = attrs.getAttributeResourceValue( "http://schemas.android.com/apk/res/android", "src", 0);
mMovie = Movie.decodeStream(getResources().openRawResource(src));
}

@Override
protected void onDraw(Canvas canvas) {
if (mMovie != null) {
long now = android.os.SystemClock.uptimeMillis();
if (mStart == 0) {
mStart = now;
}

int duration = mMovie.duration();
if (duration == 0) {
duration = 100;
}
mMovie.setTime((int) ((now - mStart) % duration));
canvas.scale(getWidth() / mMovie.width(), getHeight() / mMovie.height());
mMovie.draw(canvas, 0, 0);
invalidate();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.xiaoyi.yivirtualcamera;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

/**
* Created by xyb on 11/22/2016.
*/

public class ModeSelectionView {
private VirtualCameraActivity mActivity;
private View mSelfView;

ModeSelectionView(VirtualCameraActivity activity) {
mActivity = activity;
showContent();
}

private void showContent() {
mSelfView = LayoutInflater.from(mActivity).inflate(R.layout.model_selection_view, null);
mActivity.getScreenPanel().addView(mSelfView);

int totalHeight = mActivity.getScreenPanel().getMeasuredHeight();
setHeight((LinearLayout)mSelfView.findViewById(R.id.model_row_1), totalHeight / 3);
setHeight((LinearLayout)mSelfView.findViewById(R.id.model_row_2), totalHeight / 3);
setHeight((LinearLayout)mSelfView.findViewById(R.id.model_row_3), totalHeight / 3);

mSelfView.findViewById(R.id.exit_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mActivity.getScreenPanel().removeView(mSelfView);
}
});
}

private void setHeight(LinearLayout view, int height) {
ViewGroup.LayoutParams params = view.getLayoutParams();
params.height = height;
view.setLayoutParams(params);
}
}
Loading

0 comments on commit d8b9f22

Please sign in to comment.