-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
- Loading branch information
There are no files selected for viewing
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 |
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.
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.
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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') | ||
} |
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 *; | ||
#} |
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); | ||
} | ||
} |