Commit 81163bf8 by Yu-Tung

test save name

parent 6789352e
...@@ -64,10 +64,12 @@ public class LoginActivity extends BaseActivity implements LoginContract.View, V ...@@ -64,10 +64,12 @@ public class LoginActivity extends BaseActivity implements LoginContract.View, V
switch (v.getId()) { switch (v.getId()) {
case R.id.btn_login: case R.id.btn_login:
btnLogin.setEnabled(false); btnLogin.setEnabled(false);
if (onCheckUserisEmpty()) {
showProgressDialog("登入中"); showProgressDialog("登入中");
if (onCheckUserisEmpty()) {
presenter.onLogin(editAccount.getText().toString(), editPassword.getText().toString()); presenter.onLogin(editAccount.getText().toString(), editPassword.getText().toString());
} else { } else {
dismissProgressDialog();
btnLogin.setEnabled(true); btnLogin.setEnabled(true);
} }
break; break;
...@@ -88,6 +90,7 @@ public class LoginActivity extends BaseActivity implements LoginContract.View, V ...@@ -88,6 +90,7 @@ public class LoginActivity extends BaseActivity implements LoginContract.View, V
@Override @Override
public void onCompleteLogin(String token) { public void onCompleteLogin(String token) {
dismissProgressDialog();
Intent intent = new Intent(this, MainActivity.class); Intent intent = new Intent(this, MainActivity.class);
Bundle bag = new Bundle(); Bundle bag = new Bundle();
bag.putString("token", token); bag.putString("token", token);
......
...@@ -45,6 +45,7 @@ public class LoginPresenter<V extends LoginContract.View> implements LoginContra ...@@ -45,6 +45,7 @@ public class LoginPresenter<V extends LoginContract.View> implements LoginContra
view.onCompleteLogin(loginResponse.getmMsg()); view.onCompleteLogin(loginResponse.getmMsg());
} else { } else {
view.dismissProgressDialog();
view.showDialogCaveatMessage("登入失敗"); view.showDialogCaveatMessage("登入失敗");
} }
} }
...@@ -52,6 +53,7 @@ public class LoginPresenter<V extends LoginContract.View> implements LoginContra ...@@ -52,6 +53,7 @@ public class LoginPresenter<V extends LoginContract.View> implements LoginContra
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
Log.e("err", e.getMessage()); Log.e("err", e.getMessage());
view.dismissProgressDialog();
if(e.getMessage().contains("No address associated with hostname")) if(e.getMessage().contains("No address associated with hostname"))
{ {
view.showDialogCaveatMessage("請檢查網路狀態"); view.showDialogCaveatMessage("請檢查網路狀態");
......
...@@ -40,6 +40,7 @@ import java.io.FileOutputStream; ...@@ -40,6 +40,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
...@@ -76,6 +77,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie ...@@ -76,6 +77,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
String token, imageFilePath; String token, imageFilePath;
int countFile = 0; int countFile = 0;
private TextView tvCompany, tvFactory, tvClass, tvUnit, tvShootType; private TextView tvCompany, tvFactory, tvClass, tvUnit, tvShootType;
private TextView textCompany, textFactory, textClass, textUnit, textShootType; private TextView textCompany, textFactory, textClass, textUnit, textShootType;
private MainPresenter mPresenter; private MainPresenter mPresenter;
...@@ -88,6 +90,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie ...@@ -88,6 +90,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
String sidData =""; String sidData ="";
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -192,10 +195,15 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie ...@@ -192,10 +195,15 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
} }
private void openRecordVideoIntent() { private void openRecordVideoIntent() {
String timeStamp =
new SimpleDateFormat("yyyyMMdd_HHmmss",
Locale.getDefault()).format(new Date());
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
PackageManager packageManager = this.getPackageManager(); PackageManager packageManager = this.getPackageManager();
List<ResolveInfo> listCam = packageManager.queryIntentActivities(takeVideoIntent, 0); List<ResolveInfo> listCam = packageManager.queryIntentActivities(takeVideoIntent, 0);
takeVideoIntent.setPackage(listCam.get(0).activityInfo.packageName); takeVideoIntent.setPackage(listCam.get(0).activityInfo.packageName);
takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Environment.getExternalStorageDirectory().getPath()+timeStamp+".mp4");
// takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 10996480L); //限制影片大小 // takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 10996480L); //限制影片大小
if (takeVideoIntent.resolveActivity(getPackageManager()) != null) { if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE); startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
...@@ -203,10 +211,14 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie ...@@ -203,10 +211,14 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
} }
private File createImageFile() throws IOException { private File createImageFile() throws IOException {
String timeStamp = Date c = Calendar.getInstance(Locale.TAIWAN).getTime();
new SimpleDateFormat("yyyyMMdd_HHmmss", SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HH:mm:ss");
Locale.getDefault()).format(new Date()); String formattedDate = df.format(c);
String imageFileName = "IMG_" + timeStamp + "_"; // String timeStamp =
// new SimpleDateFormat("yyyyMMdd_HHmmss",
// Locale.getDefault()).format(new Date());
String imageFileName =formattedDate;
Log.e("time",imageFileName);
File storageDir = File storageDir =
getExternalFilesDir(Environment.DIRECTORY_PICTURES); getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile( File image = File.createTempFile(
...@@ -231,10 +243,17 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie ...@@ -231,10 +243,17 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
Date c = Calendar.getInstance(Locale.TAIWAN).getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HH:mm:ss");
String formattedDate = df.format(c);
if (requestCode == REQUEST_CAPTURE_IMAGE && resultCode == RESULT_OK) { if (requestCode == REQUEST_CAPTURE_IMAGE && resultCode == RESULT_OK) {
File imgFile = new File(imageFilePath); File imgFile = new File(imageFilePath);
Log.e("imagePath", imageFilePath);
File newFile = new File(imageFilePath, formattedDate + ".jpg");
imgFile.renameTo(newFile);
//照片的檔案 //照片的檔案
if (imgFile.exists()) { if (imgFile.exists()) {
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
try { try {
FileOutputStream out = new FileOutputStream(imgFile); FileOutputStream out = new FileOutputStream(imgFile);
...@@ -242,8 +261,10 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie ...@@ -242,8 +261,10 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
out.flush(); out.flush();
out.close(); out.close();
MediaStore.Images.Media.insertImage(getContentResolver(), myBitmap, imgFile.getName(), "description"); MediaStore.Images.Media.insertImage(getContentResolver(), myBitmap, formattedDate, formattedDate);
Log.e("fileName", imgFile.getName());
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath())))); sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()))));
Log.e("picture", Environment.getExternalStorageDirectory().getPath());
// Intent it = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); // Intent it = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
// Uri uri = Uri.fromFile(imgFile); // Uri uri = Uri.fromFile(imgFile);
// it.setData(uri); // it.setData(uri);
...@@ -483,10 +504,14 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie ...@@ -483,10 +504,14 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
uploadPath = mPresenter.onJudgmentPath(pathCompany, pathFactoryArea,pathFactoryClass,pathClass,pathShootType); uploadPath = mPresenter.onJudgmentPath(pathCompany, pathFactoryArea,pathFactoryClass,pathClass,pathShootType);
dismissProgressDialog(); dismissProgressDialog();
showProgressDialog(type); showProgressDialog(type);
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
String path1 = uploadPath; String path1 = uploadPath;
Date c = Calendar.getInstance(Locale.TAIWAN).getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HH_mm_ss");
String formattedDate = df.format(c);
OkHttpClient client = new OkHttpClient().newBuilder() OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(60, TimeUnit.SECONDS) .connectTimeout(60, TimeUnit.SECONDS)
...@@ -498,12 +523,17 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie ...@@ -498,12 +523,17 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
.setType(MultipartBody.FORM) .setType(MultipartBody.FORM)
.addFormDataPart("_sid", sid) .addFormDataPart("_sid", sid)
.addFormDataPart("path",path1); .addFormDataPart("path",path1);
Log.e("file5555555", uriList.size() + "");
File uploadFile1 = new File(uriList.get(0));
Log.e("file555eer5555", uploadFile1.length() + "");
for (String path : uriList) { for (String path : uriList) {
File uploadFile = new File(path); File uploadFile = new File(path);
Log.e("file5555555", uploadFile.length()/1024/1024 + "mb");
Log.e("file5555555", uploadFile.getName());
buildernew.addFormDataPart("file", uploadFile.getName(), buildernew.addFormDataPart("file", uploadFile.getName(),
RequestBody.create(MediaType.parse("application/octet-stream"), path)); RequestBody.create(MediaType.parse("application/octet-stream"), uploadFile));
} }
RequestBody body = buildernew.build(); RequestBody body = buildernew.build();
......
...@@ -281,29 +281,33 @@ public class MainPresenter<V extends MainContract.View> implements MainContract. ...@@ -281,29 +281,33 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
public void run() { public void run() {
File video = new File(path); File video = new File(path);
int videoSize = (int) video.length();
int sizeLimit = 50 * 1024 * 1024; int sizeLimit = 50 * 1024 * 1024;
Log.e("size", video.length() + ""); Log.e("size", video.length() + "");
int duration = (int) (FFprobe.getMediaInformation(path).getDuration() / 1000); //影片秒數 int duration = (int) (FFprobe.getMediaInformation(path).getDuration() / 1000); //影片秒數
int startTime = 0; int startTime = 0;
int segTime = 30; //分割秒數 int segTime = 0; //分割秒數
int loop = 0; int loop = 0;
int sss = videoSize / sizeLimit;
int aaa = videoSize % sizeLimit;
if (videoSize > sizeLimit) {
//計算要分割的秒數
if (aaa != 0) {
segTime = duration / (sss + 1);
}
//迴圈次數
if (duration % segTime != 0) { if (duration % segTime != 0) {
loop = duration / segTime + 1; loop = duration / segTime + 1;
} else { } else {
loop = duration / segTime; loop = duration / segTime;
} }
if (video.length() > sizeLimit) { //開始分割
if (duration < 30) {
segTime = segTime / 2;
}
for (int i = 0; i < loop; i++) { for (int i = 0; i < loop; i++) {
int rc = FFmpeg.execute("-ss " + startTime + " -i " + path + " -t " + segTime + " -acodec copy -vcodec copy " + Environment.getExternalStorageDirectory().toString() + "/Seg_Video" + "/" + video.getName().replace(".mp4", "") + "_seg_" + i + ".mp4");
int rc = FFmpeg.execute("-ss " + startTime + " -i " + path + " -t " + segTime + " " + Environment.getExternalStorageDirectory().toString() + "/Seg_Video" + "/seg_" + i + "_" + video.getName().replace(".mp4", "") + ".mp4");
segVideoList.add(Environment.getExternalStorageDirectory().toString() + "/seg_" + i + "_" + video.getName());
if (rc == RETURN_CODE_SUCCESS) { if (rc == RETURN_CODE_SUCCESS) {
segVideoList.add(Environment.getExternalStorageDirectory().toString() + "/Seg_Video" + "/" + video.getName().replace(".mp4", "") + "_seg_" + i + ".mp4");
Log.i(Config.TAG, "Command execution completed successfully."); Log.i(Config.TAG, "Command execution completed successfully.");
} else if (rc == RETURN_CODE_CANCEL) { } else if (rc == RETURN_CODE_CANCEL) {
Log.i(Config.TAG, "Command execution cancelled by user."); Log.i(Config.TAG, "Command execution cancelled by user.");
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:hint="@string/login_account_hint" android:hint="@string/login_account_hint"
android:text="N000158385"
android:textColorHint="@color/white" android:textColorHint="@color/white"
android:paddingStart="100dp" android:paddingStart="100dp"
app:layout_constraintWidth_percent="0.9" app:layout_constraintWidth_percent="0.9"
...@@ -54,6 +55,7 @@ ...@@ -54,6 +55,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:hint="@string/login_password_hint" android:hint="@string/login_password_hint"
android:text="781122222"
android:textColorHint="@color/white" android:textColorHint="@color/white"
android:paddingStart="100dp" android:paddingStart="100dp"
android:background="@drawable/bg_login_password" android:background="@drawable/bg_login_password"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment