├── .gitignore ├── .idea ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── Demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── cktim │ │ └── camera2record │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── cktim │ │ │ └── camera2record │ │ │ ├── Camera2RecordFinishActivity.java │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── activity_record_detail.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── cktim │ └── camera2record │ └── ExampleUnitTest.java ├── README.md ├── build.gradle ├── camera2library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── cktim │ │ └── camera2library │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── cktim │ │ │ └── camera2library │ │ │ ├── Camera2Config.java │ │ │ └── camera │ │ │ ├── Camera2RecordActivity.java │ │ │ ├── Camera2Util.java │ │ │ └── ProgressView.java │ └── res │ │ ├── drawable │ │ ├── ic_capture_btn.png │ │ ├── ic_capture_delete.webp │ │ ├── ic_capture_light_off.webp │ │ ├── ic_capture_light_on.webp │ │ ├── ic_capture_switch.webp │ │ └── selector_capture_light.xml │ │ ├── layout │ │ └── activity_camera2_record.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── cktim │ └── camera2library │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.cktim.camera2record" 7 | minSdkVersion 21 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:26.1.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 28 | implementation project(':camera2library') 29 | } 30 | -------------------------------------------------------------------------------- /Demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /Demo/src/androidTest/java/com/cktim/camera2record/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.cktim.camera2record; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.cktim.camera2record", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Demo/src/main/java/com/cktim/camera2record/Camera2RecordFinishActivity.java: -------------------------------------------------------------------------------- 1 | package com.cktim.camera2record; 2 | 3 | import android.graphics.BitmapFactory; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.text.TextUtils; 7 | import android.view.View; 8 | import android.view.Window; 9 | import android.view.WindowManager; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.cktim.camera2library.Camera2Config; 14 | 15 | public class Camera2RecordFinishActivity extends AppCompatActivity { 16 | private String picPath;//图片地址 17 | private String videoPath;//视频地址 18 | 19 | private ImageView iv; 20 | private TextView tv; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | //全屏模式 26 | requestWindowFeature(Window.FEATURE_NO_TITLE); 27 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 28 | setContentView(R.layout.activity_record_detail); 29 | 30 | iv = findViewById(R.id.iv); 31 | tv = findViewById(R.id.tv); 32 | 33 | if (getIntent() != null) { 34 | //获取传递过来的图片地址 35 | picPath = getIntent().getStringExtra(Camera2Config.INTENT_PATH_SAVE_PIC); 36 | if (TextUtils.isEmpty(picPath)) { 37 | iv.setVisibility(View.GONE); 38 | } else { 39 | iv.setImageBitmap(BitmapFactory.decodeFile(picPath)); 40 | } 41 | 42 | //获取传递过来的视频地址 43 | videoPath = getIntent().getStringExtra(Camera2Config.INTENT_PATH_SAVE_VIDEO); 44 | if (TextUtils.isEmpty(videoPath)) { 45 | tv.setVisibility(View.GONE); 46 | } else { 47 | tv.setText("我是一段视频,这是我的存放地址:" + videoPath + ",你可以在这里加个播放器或者做其他处理"); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Demo/src/main/java/com/cktim/camera2record/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cktim.camera2record; 2 | 3 | import android.os.Bundle; 4 | import android.os.Environment; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.cktim.camera2library.Camera2Config; 10 | import com.cktim.camera2library.camera.Camera2RecordActivity; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | private Button btnOpenCamera2; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | btnOpenCamera2=findViewById(R.id.btn_openCamera2); 20 | 21 | //配置Camera2相关参数, 22 | Camera2Config.RECORD_MAX_TIME = 10; 23 | Camera2Config.RECORD_MIN_TIME=2; 24 | Camera2Config.RECORD_PROGRESS_VIEW_COLOR=R.color.colorAccent; 25 | Camera2Config.PREVIEW_MAX_HEIGHT=1300; 26 | Camera2Config.PATH_SAVE_VIDEO= Environment.getExternalStorageDirectory().getAbsolutePath() + "/CameraV2222/"; 27 | Camera2Config.PATH_SAVE_PIC= Environment.getExternalStorageDirectory().getAbsolutePath() + "/CameraV2222/CameraV22222222/"; 28 | Camera2Config.ENABLE_CAPTURE=true; 29 | Camera2Config.ENABLE_CAPTURE=true; 30 | 31 | Camera2Config.ACTIVITY_AFTER_CAPTURE = Camera2RecordFinishActivity.class; 32 | 33 | btnOpenCamera2.setOnClickListener(new View.OnClickListener() { 34 | @Override 35 | public void onClick(View view) { 36 | Camera2RecordActivity.start(MainActivity.this); 37 | } 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Demo/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /Demo/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /Demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |