Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AndiovisualRecord
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yu_Tung
AndiovisualRecord
Commits
81163bf8
Commit
81163bf8
authored
Jun 29, 2020
by
Yu-Tung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test save name
parent
6789352e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
18 deletions
+59
-18
LoginActivity.java
...com/example/audiovisualrecord/ui/login/LoginActivity.java
+4
-1
LoginPresenter.java
...om/example/audiovisualrecord/ui/login/LoginPresenter.java
+2
-0
MainActivity.java
...a/com/example/audiovisualrecord/ui/main/MainActivity.java
+37
-7
MainPresenter.java
.../com/example/audiovisualrecord/ui/main/MainPresenter.java
+14
-10
login.xml
app/src/main/res/layout/login.xml
+2
-0
No files found.
app/src/main/java/com/example/audiovisualrecord/ui/login/LoginActivity.java
View file @
81163bf8
...
...
@@ -64,10 +64,12 @@ public class LoginActivity extends BaseActivity implements LoginContract.View, V
switch
(
v
.
getId
())
{
case
R
.
id
.
btn_login
:
btnLogin
.
setEnabled
(
false
);
if
(
onCheckUserisEmpty
())
{
showProgressDialog
(
"登入中"
);
if
(
onCheckUserisEmpty
())
{
presenter
.
onLogin
(
editAccount
.
getText
().
toString
(),
editPassword
.
getText
().
toString
());
}
else
{
dismissProgressDialog
();
btnLogin
.
setEnabled
(
true
);
}
break
;
...
...
@@ -88,6 +90,7 @@ public class LoginActivity extends BaseActivity implements LoginContract.View, V
@Override
public
void
onCompleteLogin
(
String
token
)
{
dismissProgressDialog
();
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
Bundle
bag
=
new
Bundle
();
bag
.
putString
(
"token"
,
token
);
...
...
app/src/main/java/com/example/audiovisualrecord/ui/login/LoginPresenter.java
View file @
81163bf8
...
...
@@ -45,6 +45,7 @@ public class LoginPresenter<V extends LoginContract.View> implements LoginContra
view
.
onCompleteLogin
(
loginResponse
.
getmMsg
());
}
else
{
view
.
dismissProgressDialog
();
view
.
showDialogCaveatMessage
(
"登入失敗"
);
}
}
...
...
@@ -52,6 +53,7 @@ public class LoginPresenter<V extends LoginContract.View> implements LoginContra
@Override
public
void
onError
(
Throwable
e
)
{
Log
.
e
(
"err"
,
e
.
getMessage
());
view
.
dismissProgressDialog
();
if
(
e
.
getMessage
().
contains
(
"No address associated with hostname"
))
{
view
.
showDialogCaveatMessage
(
"請檢查網路狀態"
);
...
...
app/src/main/java/com/example/audiovisualrecord/ui/main/MainActivity.java
View file @
81163bf8
...
...
@@ -40,6 +40,7 @@ import java.io.FileOutputStream;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
...
...
@@ -76,6 +77,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
String
token
,
imageFilePath
;
int
countFile
=
0
;
private
TextView
tvCompany
,
tvFactory
,
tvClass
,
tvUnit
,
tvShootType
;
private
TextView
textCompany
,
textFactory
,
textClass
,
textUnit
,
textShootType
;
private
MainPresenter
mPresenter
;
...
...
@@ -88,6 +90,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
String
sidData
=
""
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -192,10 +195,15 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
}
private
void
openRecordVideoIntent
()
{
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
,
Locale
.
getDefault
()).
format
(
new
Date
());
Intent
takeVideoIntent
=
new
Intent
(
MediaStore
.
ACTION_VIDEO_CAPTURE
);
PackageManager
packageManager
=
this
.
getPackageManager
();
List
<
ResolveInfo
>
listCam
=
packageManager
.
queryIntentActivities
(
takeVideoIntent
,
0
);
takeVideoIntent
.
setPackage
(
listCam
.
get
(
0
).
activityInfo
.
packageName
);
takeVideoIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
Environment
.
getExternalStorageDirectory
().
getPath
()+
timeStamp
+
".mp4"
);
// takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 10996480L); //限制影片大小
if
(
takeVideoIntent
.
resolveActivity
(
getPackageManager
())
!=
null
)
{
startActivityForResult
(
takeVideoIntent
,
REQUEST_VIDEO_CAPTURE
);
...
...
@@ -203,10 +211,14 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
}
private
File
createImageFile
()
throws
IOException
{
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
,
Locale
.
getDefault
()).
format
(
new
Date
());
String
imageFileName
=
"IMG_"
+
timeStamp
+
"_"
;
Date
c
=
Calendar
.
getInstance
(
Locale
.
TAIWAN
).
getTime
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyyMMdd_HH:mm:ss"
);
String
formattedDate
=
df
.
format
(
c
);
// String timeStamp =
// new SimpleDateFormat("yyyyMMdd_HHmmss",
// Locale.getDefault()).format(new Date());
String
imageFileName
=
formattedDate
;
Log
.
e
(
"time"
,
imageFileName
);
File
storageDir
=
getExternalFilesDir
(
Environment
.
DIRECTORY_PICTURES
);
File
image
=
File
.
createTempFile
(
...
...
@@ -231,10 +243,17 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
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
)
{
File
imgFile
=
new
File
(
imageFilePath
);
Log
.
e
(
"imagePath"
,
imageFilePath
);
File
newFile
=
new
File
(
imageFilePath
,
formattedDate
+
".jpg"
);
imgFile
.
renameTo
(
newFile
);
//照片的檔案
if
(
imgFile
.
exists
())
{
Bitmap
myBitmap
=
BitmapFactory
.
decodeFile
(
imgFile
.
getAbsolutePath
());
try
{
FileOutputStream
out
=
new
FileOutputStream
(
imgFile
);
...
...
@@ -242,8 +261,10 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
out
.
flush
();
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
()))));
Log
.
e
(
"picture"
,
Environment
.
getExternalStorageDirectory
().
getPath
());
// Intent it = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
// Uri uri = Uri.fromFile(imgFile);
// it.setData(uri);
...
...
@@ -483,10 +504,14 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
dismissProgressDialog
();
showProgressDialog
(
type
);
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
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
()
.
connectTimeout
(
60
,
TimeUnit
.
SECONDS
)
...
...
@@ -498,12 +523,17 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
.
setType
(
MultipartBody
.
FORM
)
.
addFormDataPart
(
"_sid"
,
sid
)
.
addFormDataPart
(
"path"
,
path1
);
Log
.
e
(
"file5555555"
,
uriList
.
size
()
+
""
);
File
uploadFile1
=
new
File
(
uriList
.
get
(
0
));
Log
.
e
(
"file555eer5555"
,
uploadFile1
.
length
()
+
""
);
for
(
String
path
:
uriList
)
{
File
uploadFile
=
new
File
(
path
);
Log
.
e
(
"file5555555"
,
uploadFile
.
length
()/
1024
/
1024
+
"mb"
);
Log
.
e
(
"file5555555"
,
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
();
...
...
app/src/main/java/com/example/audiovisualrecord/ui/main/MainPresenter.java
View file @
81163bf8
...
...
@@ -281,29 +281,33 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
public
void
run
()
{
File
video
=
new
File
(
path
);
int
videoSize
=
(
int
)
video
.
length
();
int
sizeLimit
=
50
*
1024
*
1024
;
Log
.
e
(
"size"
,
video
.
length
()
+
""
);
int
duration
=
(
int
)
(
FFprobe
.
getMediaInformation
(
path
).
getDuration
()
/
1000
);
//影片秒數
int
startTime
=
0
;
int
segTime
=
3
0
;
//分割秒數
int
segTime
=
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
)
{
loop
=
duration
/
segTime
+
1
;
}
else
{
loop
=
duration
/
segTime
;
}
if
(
video
.
length
()
>
sizeLimit
)
{
if
(
duration
<
30
)
{
segTime
=
segTime
/
2
;
}
//開始分割
for
(
int
i
=
0
;
i
<
loop
;
i
++)
{
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
());
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"
);
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."
);
}
else
if
(
rc
==
RETURN_CODE_CANCEL
)
{
Log
.
i
(
Config
.
TAG
,
"Command execution cancelled by user."
);
...
...
app/src/main/res/layout/login.xml
View file @
81163bf8
...
...
@@ -39,6 +39,7 @@
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:hint=
"@string/login_account_hint"
android:text=
"N000158385"
android:textColorHint=
"@color/white"
android:paddingStart=
"100dp"
app:layout_constraintWidth_percent=
"0.9"
...
...
@@ -54,6 +55,7 @@
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:hint=
"@string/login_password_hint"
android:text=
"781122222"
android:textColorHint=
"@color/white"
android:paddingStart=
"100dp"
android:background=
"@drawable/bg_login_password"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment