diff --git a/PLDroidShortVideoDemo/app/build.gradle b/PLDroidShortVideoDemo/app/build.gradle index 9bac469..559427d 100644 --- a/PLDroidShortVideoDemo/app/build.gradle +++ b/PLDroidShortVideoDemo/app/build.gradle @@ -15,7 +15,7 @@ android { minSdkVersion 18 targetSdkVersion 25 versionCode 26 - versionName "2.2.1" + versionName "3.0.0" multiDexEnabled true buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L" ndk { @@ -32,7 +32,7 @@ android { dependencies { compile 'com.qiniu:qiniu-android-sdk:7.3.11' - compile files('libs/pldroid-shortvideo-2.2.1.jar') + compile files('libs/pldroid-shortvideo-3.0.0.jar') compile files('libs/pldroid-player-2.1.8.jar') compile files('libs/EasyAR.jar') compile files('libs/EasyAR3D.jar') diff --git a/PLDroidShortVideoDemo/app/libs/pldroid-shortvideo-2.2.1.jar b/PLDroidShortVideoDemo/app/libs/pldroid-shortvideo-3.0.0.jar similarity index 78% rename from PLDroidShortVideoDemo/app/libs/pldroid-shortvideo-2.2.1.jar rename to PLDroidShortVideoDemo/app/libs/pldroid-shortvideo-3.0.0.jar index 7f61f8c..96f16fc 100644 Binary files a/PLDroidShortVideoDemo/app/libs/pldroid-shortvideo-2.2.1.jar and b/PLDroidShortVideoDemo/app/libs/pldroid-shortvideo-3.0.0.jar differ diff --git a/PLDroidShortVideoDemo/app/src/main/AndroidManifest.xml b/PLDroidShortVideoDemo/app/src/main/AndroidManifest.xml index 9ef13da..9b6383b 100644 --- a/PLDroidShortVideoDemo/app/src/main/AndroidManifest.xml +++ b/PLDroidShortVideoDemo/app/src/main/AndroidManifest.xml @@ -21,6 +21,7 @@ android:largeHeap="true" android:supportsRtl="true" android:theme="@style/AppTheme"> + @@ -38,6 +39,9 @@ + adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.PREVIEW_SIZE_RATIO_TIPS_ARRAY); + mPreviewSizeRatioSpinner.setAdapter(adapter); + mPreviewSizeRatioSpinner.setSelection(PREVIEW_SIZE_RATIO_POS); + mPreviewSizeRatioSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + PREVIEW_SIZE_RATIO_POS = position; + } + @Override + public void onNothingSelected(AdapterView parent) {} + }); + + adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.PREVIEW_SIZE_LEVEL_TIPS_ARRAY); + mPreviewSizeLevelSpinner.setAdapter(adapter); + mPreviewSizeLevelSpinner.setSelection(PREVIEW_SIZE_LEVEL_POS); + mPreviewSizeLevelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + PREVIEW_SIZE_LEVEL_POS = position; + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.ENCODING_MODE_LEVEL_TIPS_ARRAY); + mEncodingModeLevelSpinner.setAdapter(adapter); + mEncodingModeLevelSpinner.setSelection(ENCODING_MODE_LEVEL_POS); + mEncodingModeLevelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + ENCODING_MODE_LEVEL_POS = position; + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.ENCODING_SIZE_LEVEL_TIPS_ARRAY); + mEncodingSizeLevelSpinner.setAdapter(adapter); + mEncodingSizeLevelSpinner.setSelection(ENCODING_SIZE_LEVEL_POS); + mEncodingSizeLevelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + ENCODING_SIZE_LEVEL_POS = position; + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.ENCODING_BITRATE_LEVEL_TIPS_ARRAY); + mEncodingBitrateLevelSpinner.setAdapter(adapter); + mEncodingBitrateLevelSpinner.setSelection(ENCODING_BITRATE_LEVEL_POS); + mEncodingBitrateLevelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + ENCODING_BITRATE_LEVEL_POS = position; + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.AUDIO_CHANNEL_NUM_TIPS_ARRAY); + mAudioChannelNumSpinner.setAdapter(adapter); + mAudioChannelNumSpinner.setSelection(AUDIO_CHANNEL_NUM_POS); + mAudioChannelNumSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + AUDIO_CHANNEL_NUM_POS = position; + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + } + + public void onClickBack(View view) { + finish(); + } +} diff --git a/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/activity/ImportAndEditActivity.java b/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/activity/ImportAndEditActivity.java new file mode 100644 index 0000000..f442979 --- /dev/null +++ b/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/activity/ImportAndEditActivity.java @@ -0,0 +1,75 @@ +package com.qiniu.pili.droid.shortvideo.demo.activity; + +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.view.View; + +import com.qiniu.pili.droid.shortvideo.demo.R; +import com.qiniu.pili.droid.shortvideo.demo.utils.PermissionChecker; +import com.qiniu.pili.droid.shortvideo.demo.utils.ToastUtils; + +public class ImportAndEditActivity extends AppCompatActivity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_import_and_edit); + } + + public void onClickImport(View v) { + if (isPermissionOK()) { + jumpToActivity(VideoTrimActivity.class); + } + } + + public void onClickTransitionMake(View v) { + if (isPermissionOK()) { + jumpToActivity(VideoDivideActivity.class); + } + } + + public void onClickVideoCompose(View v) { + if (isPermissionOK()) { + jumpToActivity(VideoComposeActivity.class); + } + } + + public void onClickTranscode(View v) { + if (isPermissionOK()) { + jumpToActivity(VideoTranscodeActivity.class); + } + } + + public void onClickMultipleCompose(View v) { + if (isPermissionOK()) { + jumpToActivity(MultipleComposeActivity.class); + } + } + + public void onClickExternalMediaRecord(View v) { + if (isPermissionOK()) { + jumpToActivity(ExternalMediaRecordActivity.class); + } + } + + private boolean isPermissionOK() { + PermissionChecker checker = new PermissionChecker(this); + boolean isPermissionOK = Build.VERSION.SDK_INT < Build.VERSION_CODES.M || checker.checkPermission(); + if (!isPermissionOK) { + ToastUtils.s(this, "Some permissions is not approved !!!"); + } + return isPermissionOK; + } + + private void jumpToActivity(Class cls) { + Intent intent = new Intent(ImportAndEditActivity.this, cls); + startActivity(intent); + } + + public void onClickBack(View view) { + finish(); + } +} diff --git a/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/activity/MainActivity.java b/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/activity/MainActivity.java index f3035c1..637b860 100644 --- a/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/activity/MainActivity.java +++ b/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/activity/MainActivity.java @@ -7,17 +7,13 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.Spinner; -import android.widget.TextView; - import com.qiniu.pili.droid.shortvideo.PLAuthenticationResultCallback; import com.qiniu.pili.droid.shortvideo.PLShortVideoEnv; import com.qiniu.pili.droid.shortvideo.demo.BuildConfig; import com.qiniu.pili.droid.shortvideo.demo.R; import com.qiniu.pili.droid.shortvideo.demo.utils.PermissionChecker; -import com.qiniu.pili.droid.shortvideo.demo.utils.RecordSettings; import com.qiniu.pili.droid.shortvideo.demo.utils.ToastUtils; +import com.qiniu.pili.droid.shortvideo.demo.view.ItemView; import java.text.SimpleDateFormat; import java.util.Locale; @@ -25,51 +21,16 @@ public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; - private Spinner mPreviewSizeRatioSpinner; - private Spinner mPreviewSizeLevelSpinner; - private Spinner mEncodingModeLevelSpinner; - private Spinner mEncodingSizeLevelSpinner; - private Spinner mEncodingBitrateLevelSpinner; - private Spinner mAudioChannelNumSpinner; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - TextView versionInfoTextView = (TextView) findViewById(R.id.VersionInfoTextView); - String info = "版本号:" + getVersionDescription() + ",编译时间:" + getBuildTimeDescription(); - versionInfoTextView.setText(info); - - mPreviewSizeRatioSpinner = (Spinner) findViewById(R.id.PreviewSizeRatioSpinner); - mPreviewSizeLevelSpinner = (Spinner) findViewById(R.id.PreviewSizeLevelSpinner); - mEncodingModeLevelSpinner = (Spinner) findViewById(R.id.EncodingModeLevelSpinner); - mEncodingSizeLevelSpinner = (Spinner) findViewById(R.id.EncodingSizeLevelSpinner); - mEncodingBitrateLevelSpinner = (Spinner) findViewById(R.id.EncodingBitrateLevelSpinner); - mAudioChannelNumSpinner = (Spinner) findViewById(R.id.AudioChannelNumSpinner); - - ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.PREVIEW_SIZE_RATIO_TIPS_ARRAY); - mPreviewSizeRatioSpinner.setAdapter(adapter); - - adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.PREVIEW_SIZE_LEVEL_TIPS_ARRAY); - mPreviewSizeLevelSpinner.setAdapter(adapter); - mPreviewSizeLevelSpinner.setSelection(3); - - adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.ENCODING_MODE_LEVEL_TIPS_ARRAY); - mEncodingModeLevelSpinner.setAdapter(adapter); - mEncodingModeLevelSpinner.setSelection(0); - - adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.ENCODING_SIZE_LEVEL_TIPS_ARRAY); - mEncodingSizeLevelSpinner.setAdapter(adapter); - mEncodingSizeLevelSpinner.setSelection(7); - - adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.ENCODING_BITRATE_LEVEL_TIPS_ARRAY); - mEncodingBitrateLevelSpinner.setAdapter(adapter); - mEncodingBitrateLevelSpinner.setSelection(2); + ItemView itemVersionInfo = (ItemView) findViewById(R.id.item_version_info); + itemVersionInfo.setValue("" + getVersionDescription()); - adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, RecordSettings.AUDIO_CHANNEL_NUM_TIPS_ARRAY); - mAudioChannelNumSpinner.setAdapter(adapter); - mAudioChannelNumSpinner.setSelection(0); + ItemView itemCompileInfo = (ItemView) findViewById(R.id.item_compile_info); + itemCompileInfo.setValue(""+ getBuildTimeDescription()); PLShortVideoEnv.checkAuthentication(getApplicationContext(), new PLAuthenticationResultCallback() { @Override @@ -111,9 +72,10 @@ public void onClickAudioCapture(View v) { } } - public void onClickImport(View v) { - if (isPermissionOK()) { - jumpToActivity(VideoTrimActivity.class); + public void onClickImportAndRecord(View v){ + if (isPermissionOK()){ + Intent intent = new Intent(this, ImportAndEditActivity.class); + startActivity(intent); } } @@ -123,12 +85,6 @@ public void onClickMixRecord(View v) { } } - public void onClickTranscode(View v) { - if (isPermissionOK()) { - jumpToActivity(VideoTranscodeActivity.class); - } - } - public void onClickMakeGIF(View v) { if (isPermissionOK()) { jumpToActivity(MakeGIFActivity.class); @@ -141,35 +97,18 @@ public void onClickScreenRecord(View v) { } } - public void onClickVideoCompose(View v) { - if (isPermissionOK()) { - jumpToActivity(VideoComposeActivity.class); - } - } - public void onClickImageCompose(View v) { if (isPermissionOK()) { jumpToActivity(ImageComposeActivity.class); } } - public void onClickMultipleCompose(View v) { - if (isPermissionOK()) { - jumpToActivity(MultipleComposeActivity.class); - } - } - public void onClickAR(View v) { if (isPermissionOK()) { jumpToActivity(ArRecordActivity.class); } } - public void onClickTransitionMake(View v) { - if (isPermissionOK()) { - jumpToActivity(VideoDivideActivity.class); - } - } public void onClickDraftBox(View v) { if (isPermissionOK()) { @@ -177,12 +116,6 @@ public void onClickDraftBox(View v) { } } - public void onClickExternalMediaRecord(View v) { - if (isPermissionOK()) { - jumpToActivity(ExternalMediaRecordActivity.class); - } - } - public void onClickVideoMix(View v) { if (isPermissionOK()) { jumpToActivity(VideoMixActivity.class); @@ -196,19 +129,19 @@ private void jumpToActivity(Class cls) { public void jumpToCaptureActivity() { Intent intent = new Intent(MainActivity.this, VideoRecordActivity.class); - intent.putExtra(VideoRecordActivity.PREVIEW_SIZE_RATIO, mPreviewSizeRatioSpinner.getSelectedItemPosition()); - intent.putExtra(VideoRecordActivity.PREVIEW_SIZE_LEVEL, mPreviewSizeLevelSpinner.getSelectedItemPosition()); - intent.putExtra(VideoRecordActivity.ENCODING_MODE, mEncodingModeLevelSpinner.getSelectedItemPosition()); - intent.putExtra(VideoRecordActivity.ENCODING_SIZE_LEVEL, mEncodingSizeLevelSpinner.getSelectedItemPosition()); - intent.putExtra(VideoRecordActivity.ENCODING_BITRATE_LEVEL, mEncodingBitrateLevelSpinner.getSelectedItemPosition()); - intent.putExtra(VideoRecordActivity.AUDIO_CHANNEL_NUM, mAudioChannelNumSpinner.getSelectedItemPosition()); + intent.putExtra(VideoRecordActivity.PREVIEW_SIZE_RATIO, ConfigActivity.PREVIEW_SIZE_RATIO_POS); + intent.putExtra(VideoRecordActivity.PREVIEW_SIZE_LEVEL, ConfigActivity.PREVIEW_SIZE_LEVEL_POS); + intent.putExtra(VideoRecordActivity.ENCODING_MODE, ConfigActivity.ENCODING_MODE_LEVEL_POS); + intent.putExtra(VideoRecordActivity.ENCODING_SIZE_LEVEL,ConfigActivity.ENCODING_SIZE_LEVEL_POS); + intent.putExtra(VideoRecordActivity.ENCODING_BITRATE_LEVEL, ConfigActivity.ENCODING_BITRATE_LEVEL_POS); + intent.putExtra(VideoRecordActivity.AUDIO_CHANNEL_NUM, ConfigActivity.AUDIO_CHANNEL_NUM_POS); startActivity(intent); } public void jumpToAudioCaptureActivity() { Intent intent = new Intent(MainActivity.this, AudioRecordActivity.class); - intent.putExtra(AudioRecordActivity.ENCODING_MODE, mEncodingModeLevelSpinner.getSelectedItemPosition()); - intent.putExtra(AudioRecordActivity.AUDIO_CHANNEL_NUM, mAudioChannelNumSpinner.getSelectedItemPosition()); + intent.putExtra(AudioRecordActivity.ENCODING_MODE, ConfigActivity.ENCODING_MODE_LEVEL_POS); + intent.putExtra(AudioRecordActivity.AUDIO_CHANNEL_NUM, ConfigActivity.AUDIO_CHANNEL_NUM_POS); startActivity(intent); } @@ -226,4 +159,8 @@ private String getVersionDescription() { protected String getBuildTimeDescription() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(BuildConfig.BUILD_TIMESTAMP); } + + public void onClickSetting(View view) { + jumpToActivity(ConfigActivity.class); + } } diff --git a/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/view/ItemView.java b/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/view/ItemView.java new file mode 100644 index 0000000..a85fbda --- /dev/null +++ b/PLDroidShortVideoDemo/app/src/main/java/com/qiniu/pili/droid/shortvideo/demo/view/ItemView.java @@ -0,0 +1,47 @@ +package com.qiniu.pili.droid.shortvideo.demo.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.support.annotation.Nullable; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.FrameLayout; +import android.widget.TextView; + +import com.qiniu.pili.droid.shortvideo.demo.R; + +public class ItemView extends FrameLayout { + + private TextView tvName; + private TextView tvValue; + + public ItemView(Context context) { + this(context, null); + } + + public ItemView(Context context, @Nullable AttributeSet attrs) { + this(context, attrs, 0); + } + + public ItemView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + LayoutInflater.from(context).inflate(R.layout.v_item, this); + tvName = (TextView) findViewById(R.id.tv_name); + tvValue = (TextView) findViewById(R.id.tv_value); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ItemView); + String text = typedArray.getString(R.styleable.ItemView_text); + + if(!TextUtils.isEmpty(text)){ + tvName.setText(text); + } + + typedArray.recycle(); + } + + public void setValue(String v){ + tvValue.setText(v); + } + +} diff --git a/PLDroidShortVideoDemo/app/src/main/res/drawable/ic_chevron_right_black_24dp.xml b/PLDroidShortVideoDemo/app/src/main/res/drawable/ic_chevron_right_black_24dp.xml new file mode 100644 index 0000000..1c71336 --- /dev/null +++ b/PLDroidShortVideoDemo/app/src/main/res/drawable/ic_chevron_right_black_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/PLDroidShortVideoDemo/app/src/main/res/drawable/ic_settings_white_24dp.xml b/PLDroidShortVideoDemo/app/src/main/res/drawable/ic_settings_white_24dp.xml new file mode 100644 index 0000000..1397d37 --- /dev/null +++ b/PLDroidShortVideoDemo/app/src/main/res/drawable/ic_settings_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/PLDroidShortVideoDemo/app/src/main/res/layout/activity_config.xml b/PLDroidShortVideoDemo/app/src/main/res/layout/activity_config.xml new file mode 100644 index 0000000..09731e5 --- /dev/null +++ b/PLDroidShortVideoDemo/app/src/main/res/layout/activity_config.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PLDroidShortVideoDemo/app/src/main/res/layout/activity_image_compose.xml b/PLDroidShortVideoDemo/app/src/main/res/layout/activity_image_compose.xml index 2aac958..0da5c82 100644 --- a/PLDroidShortVideoDemo/app/src/main/res/layout/activity_image_compose.xml +++ b/PLDroidShortVideoDemo/app/src/main/res/layout/activity_image_compose.xml @@ -4,29 +4,43 @@ android:layout_height="match_parent" android:orientation="vertical"> -