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
4b1c599e
Commit
4b1c599e
authored
Jun 30, 2020
by
Yu_Tung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
version_1.0.1
parent
f8c10c4f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
107 deletions
+150
-107
misc.xml
.idea/misc.xml
+1
-1
build.gradle
app/build.gradle
+1
-1
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-2
LoginActivity.java
...com/example/audiovisualrecord/ui/login/LoginActivity.java
+1
-1
MainActivity.java
...a/com/example/audiovisualrecord/ui/main/MainActivity.java
+144
-100
login.xml
app/src/main/res/layout/login.xml
+2
-2
No files found.
.idea/misc.xml
View file @
4b1c599e
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
</component>
<component
name=
"ProjectType"
>
<component
name=
"ProjectType"
>
...
...
app/build.gradle
View file @
4b1c599e
...
@@ -9,7 +9,7 @@ android {
...
@@ -9,7 +9,7 @@ android {
targetSdkVersion
29
targetSdkVersion
29
versionCode
1
versionCode
1
versionName
"1.0"
versionName
"1.0
.1
"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
}
}
buildTypes
{
buildTypes
{
...
...
app/src/main/AndroidManifest.xml
View file @
4b1c599e
...
@@ -27,8 +27,7 @@
...
@@ -27,8 +27,7 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".ui.main.MainActivity"
<activity
android:name=
".ui.main.MainActivity"
/>
android:screenOrientation=
"portrait"
/>
<provider
<provider
android:name=
"androidx.core.content.FileProvider"
android:name=
"androidx.core.content.FileProvider"
...
...
app/src/main/java/com/example/audiovisualrecord/ui/login/LoginActivity.java
View file @
4b1c599e
...
@@ -11,9 +11,9 @@ import android.widget.EditText;
...
@@ -11,9 +11,9 @@ import android.widget.EditText;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
com.example.audiovisualrecord.ui.main.MainActivity
;
import
com.example.audiovisualrecord.R
;
import
com.example.audiovisualrecord.R
;
import
com.example.audiovisualrecord.base.BaseActivity
;
import
com.example.audiovisualrecord.base.BaseActivity
;
import
com.example.audiovisualrecord.ui.main.MainActivity
;
public
class
LoginActivity
extends
BaseActivity
implements
LoginContract
.
View
,
View
.
OnClickListener
{
public
class
LoginActivity
extends
BaseActivity
implements
LoginContract
.
View
,
View
.
OnClickListener
{
EditText
editAccount
,
editPassword
;
EditText
editAccount
,
editPassword
;
...
...
app/src/main/java/com/example/audiovisualrecord/ui/main/MainActivity.java
View file @
4b1c599e
...
@@ -5,6 +5,8 @@ import androidx.annotation.RequiresApi;
...
@@ -5,6 +5,8 @@ import androidx.annotation.RequiresApi;
import
androidx.core.content.FileProvider
;
import
androidx.core.content.FileProvider
;
import
androidx.core.os.EnvironmentCompat
;
import
androidx.core.os.EnvironmentCompat
;
import
android.content.ContentResolver
;
import
android.content.ContentValues
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
...
@@ -15,11 +17,13 @@ import android.net.Uri;
...
@@ -15,11 +17,13 @@ import android.net.Uri;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.provider.DocumentsContract
;
import
android.provider.MediaStore
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.example.audiovisualrecord.FileUtil
;
import
com.example.audiovisualrecord.FileUtil
;
import
com.example.audiovisualrecord.MagicFileChooser
;
import
com.example.audiovisualrecord.MagicFileChooser
;
...
@@ -37,6 +41,7 @@ import org.json.JSONException;
...
@@ -37,6 +41,7 @@ import org.json.JSONException;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -65,20 +70,33 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -65,20 +70,33 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
private
static
final
int
PICK_FILE_REQUEST_CODE
=
500
;
private
static
final
int
PICK_FILE_REQUEST_CODE
=
500
;
private
Button
btnCapturePicture
,
btnRecordVideo
,
btnGetImageFromGallery
,
btnGetVideoFromGallery
,
btnDeviceEdit
,
btnCentralCloud
,
btnChoseDevice
,
btnBasicInformation
;
private
Button
btnCapturePicture
,
btnRecordVideo
,
btnGetImageFromGallery
,
btnGetVideoFromGallery
,
btnDeviceEdit
,
btnCentralCloud
,
btnChoseDevice
,
btnBasicInformation
;
private
File
photoFile
;
private
String
pathCompany
=
""
;
private
String
pathCompany
=
""
;
private
String
pathFactoryArea
=
""
;
private
String
pathFactoryArea
=
""
;
private
String
pathFactoryClass
=
""
;
private
String
pathFactoryClass
=
""
;
private
String
pathClass
=
""
;
private
String
pathClass
=
""
;
private
String
pathShootType
=
""
;
private
String
pathShootType
=
""
;
private
String
uploadPath
=
""
;
private
String
uploadPath
=
""
;
/**
* 用于保存拍照图片的uri
*/
private
Uri
mCameraUri
;
/**
* 用于保存图片的文件路径,Android 10以下使用图片路径访问图片
*/
private
String
mCameraImagePath
;
/**
* 是否是Android 10以上手机
*/
private
boolean
isAndroidQ
=
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
;
Bundle
bag
;
Bundle
bag
;
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
;
...
@@ -89,8 +107,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -89,8 +107,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
private
List
<
String
>
filepath
=
new
ArrayList
<>();
private
List
<
String
>
filepath
=
new
ArrayList
<>();
private
List
<
String
>
filename
=
new
ArrayList
<>();
private
List
<
String
>
filename
=
new
ArrayList
<>();
String
sidData
=
""
;
String
sidData
=
""
;
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
@@ -104,18 +121,18 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -104,18 +121,18 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
mMainData
=
new
MainData
();
mMainData
=
new
MainData
();
mChooseDeviceItemData
=
new
ChooseDeviceItemData
();
mChooseDeviceItemData
=
new
ChooseDeviceItemData
();
createSegVideoFolder
();
createSegVideoFolder
();
}
}
private
void
createSegVideoFolder
()
{
private
void
createSegVideoFolder
()
{
File
folder
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
File
folder
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
File
.
separator
+
"Seg_Video"
);
File
.
separator
+
"Seg_Video"
);
boolean
success
=
true
;
boolean
success
=
true
;
if
(!
folder
.
exists
())
{
if
(!
folder
.
exists
())
{
success
=
folder
.
mkdirs
();
success
=
folder
.
mkdirs
();
}
else
{
}
else
{
Log
.
e
(
"wer"
,
"folder exists"
);
Log
.
e
(
"wer"
,
"folder exists"
);
}
}
}
}
...
@@ -172,47 +189,109 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -172,47 +189,109 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
}
}
private
Uri
createImageUri
()
{
String
status
=
Environment
.
getExternalStorageState
();
// 判断是否有SD卡,优先使用SD卡存储,当没有SD卡时使用手机存储
if
(
status
.
equals
(
Environment
.
MEDIA_MOUNTED
))
{
return
getContentResolver
().
insert
(
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
,
new
ContentValues
());
}
else
{
return
getContentResolver
().
insert
(
MediaStore
.
Images
.
Media
.
INTERNAL_CONTENT_URI
,
new
ContentValues
());
}
}
private
void
openCameraIntent
()
{
private
void
openCameraIntent
()
{
Intent
pictureIntent
=
new
Intent
(
Intent
pictureIntent
=
new
Intent
(
MediaStore
.
ACTION_IMAGE_CAPTURE
);
MediaStore
.
ACTION_IMAGE_CAPTURE
);
settingSystemCamera
(
pictureIntent
);
settingSystemCamera
(
pictureIntent
);
if
(
pictureIntent
.
resolveActivity
(
getPackageManager
())
!=
null
)
{
if
(
pictureIntent
.
resolveActivity
(
getPackageManager
())
!=
null
)
{
//Create a file to store the image
//Create a file to store the image
photoFile
=
null
;
File
photoFile
=
null
;
try
{
Uri
photoUri
=
null
;
photoFile
=
createImageFile
();
if
(
isAndroidQ
)
{
}
catch
(
IOException
ex
)
{
photoUri
=
createImageUri
();
// Error occurred while creating the File
}
else
{
try
{
photoFile
=
createImageFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
if
(
photoFile
!=
null
)
{
if
(
photoFile
!=
null
)
{
Uri
photoURI
=
FileProvider
.
getUriForFile
(
this
,
"com.example.audiovisualrecord.provider"
,
photoFile
);
mCameraImagePath
=
photoFile
.
getAbsolutePath
();
// Uri photoURI = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", photoFile);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
// pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
photoUri
=
FileProvider
.
getUriForFile
(
this
,
"com.example.audiovisualrecord.provider"
,
photoFile
);
// photoURI);
// startActivityForResult(pictureIntent,
}
else
{
// REQUEST_CAPTURE_IMAGE);
photoUri
=
Uri
.
fromFile
(
photoFile
);
pictureIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
photoURI
);
}
pictureIntent
.
addFlags
(
Intent
.
FLAG_GRANT_WRITE_URI_PERMISSION
);
startActivityForResult
(
pictureIntent
,
REQUEST_CAPTURE_IMAGE
);
}
mCameraUri
=
photoUri
;
if
(
photoUri
!=
null
)
{
pictureIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
photoUri
);
pictureIntent
.
addFlags
(
Intent
.
FLAG_GRANT_WRITE_URI_PERMISSION
);
startActivityForResult
(
pictureIntent
,
REQUEST_CAPTURE_IMAGE
);
}
}
}
}
}
}
/**
* 保存位图到本地
*
* @param bitmap
* @param path 本地路径
* @return void
*/
public
void
SavaImage
(
Bitmap
bitmap
,
String
path
)
{
File
file
=
new
File
(
path
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
);
Uri
uri
=
Uri
.
fromFile
(
file
);
intent
.
setData
(
uri
);
this
.
sendBroadcast
(
intent
);
FileOutputStream
fileOutputStream
=
null
;
String
filePhth
;
String
fileName
;
//文件夹不存在,则创建它
if
(!
file
.
exists
())
{
file
.
mkdir
();
}
try
{
Date
c
=
Calendar
.
getInstance
(
Locale
.
TAIWAN
).
getTime
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyyMMdd_HH_mm_ss"
);
String
formattedDate
=
df
.
format
(
c
);
filePhth
=
path
+
"/"
+
formattedDate
+
".png"
;
fileName
=
System
.
currentTimeMillis
()
+
""
;
Log
.
e
(
"filepath"
,
filePhth
);
File
file1
=
new
File
(
filePhth
);
fileOutputStream
=
new
FileOutputStream
(
file1
.
getPath
());
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
fileOutputStream
);
fileOutputStream
.
close
();
//图片路径
// MediaStore.Images.Media.insertImage(context.getContentResolver(),
// filePhth,fileName , null);
MediaStore
.
Images
.
Media
.
insertImage
(
this
.
getContentResolver
(),
bitmap
,
""
,
""
);
this
.
sendBroadcast
(
new
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
,
Uri
.
parse
(
"file://"
+
file1
.
getAbsolutePath
())));
Log
.
d
(
"aaa"
,
file1
.
getAbsolutePath
()
+
"-----"
+
path
);
// context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
}
catch
(
Exception
e
)
{
// ToastUtil.showToast("保存失败");
Log
.
e
(
"error"
,
e
.
getMessage
());
e
.
printStackTrace
();
}
}
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
);
...
@@ -220,21 +299,8 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -220,21 +299,8 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
}
}
private
File
createImageFile
()
throws
IOException
{
private
File
createImageFile
()
throws
IOException
{
Date
c
=
Calendar
.
getInstance
(
Locale
.
TAIWAN
).
getTime
();
String
imageName
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
,
Locale
.
getDefault
()).
format
(
new
Date
());
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyyMMdd_HH:mm"
);
String
formattedDate
=
df
.
format
(
c
);
// String imageFileName =formattedDate;
String
imageName
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
,
Locale
.
getDefault
()).
format
(
new
Date
());
Log
.
e
(
"time"
,
imageName
);
File
storageDir
=
getExternalFilesDir
(
Environment
.
DIRECTORY_PICTURES
);
File
storageDir
=
getExternalFilesDir
(
Environment
.
DIRECTORY_PICTURES
);
Log
.
e
(
"storageDir"
,
getExternalFilesDir
(
Environment
.
DIRECTORY_PICTURES
).
toString
());
// File image = File.createTempFile(
// imageFileName, /* prefix */
// ".jpg", /* suffix */
// storageDir /* directory */
// );
// imageFilePath = image.getAbsolutePath();
// return image;
if
(!
storageDir
.
exists
())
{
if
(!
storageDir
.
exists
())
{
storageDir
.
mkdir
();
storageDir
.
mkdir
();
}
}
...
@@ -242,8 +308,6 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -242,8 +308,6 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
if
(!
Environment
.
MEDIA_MOUNTED
.
equals
(
EnvironmentCompat
.
getStorageState
(
tempFile
)))
{
if
(!
Environment
.
MEDIA_MOUNTED
.
equals
(
EnvironmentCompat
.
getStorageState
(
tempFile
)))
{
return
null
;
return
null
;
}
}
imageFilePath
=
tempFile
.
getAbsolutePath
();
return
tempFile
;
return
tempFile
;
}
}
...
@@ -258,39 +322,28 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -258,39 +322,28 @@ 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
);
Log
.
e
(
"imagePath"
,
imageFilePath
);
//照片的檔案
if
(
imgFile
.
exists
())
{
Bitmap
myBitmap
=
BitmapFactory
.
decodeFile
(
imgFile
.
getAbsolutePath
());
Bitmap
myBitmap
=
BitmapFactory
.
decodeFile
(
mCameraImagePath
);
try
{
String
path1
=
Environment
.
getExternalStorageDirectory
().
toString
()
+
"/Pictures"
;
FileOutputStream
out
=
new
FileOutputStream
(
imgFile
);
SavaImage
(
myBitmap
,
path1
);
myBitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
out
);
out
.
flush
();
out
.
close
();
MediaStore
.
Images
.
Media
.
insertImage
(
getContentResolver
(),
myBitmap
,
""
,
""
);
// Log.e("fileName", imgFile.getName());
sendBroadcast
(
new
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
,
Uri
.
fromFile
(
new
File
(
imageFilePath
))));
// Log.e("picture", Environment.getExternalStorageDirectory().getPath());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
if
(
requestCode
==
REQUEST_VIDEO_CAPTURE
&&
resultCode
==
RESULT_OK
)
{
if
(
requestCode
==
REQUEST_VIDEO_CAPTURE
&&
resultCode
==
RESULT_OK
)
{
//影片的uri
//影片的uri
Uri
videoUri
=
data
.
getData
();
Uri
videoUri
=
data
.
getData
();
Date
c
=
Calendar
.
getInstance
(
Locale
.
TAIWAN
).
getTime
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyyMMdd_HH_mm_ss"
);
String
formattedDate
=
df
.
format
(
c
);
try
{
DocumentsContract
.
renameDocument
(
getContentResolver
(),
videoUri
,
formattedDate
+
".mp4"
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
}
}
if
(
requestCode
==
PICK_IMAGE_FROM_GALLERY_REQUEST_CODE
&&
resultCode
==
RESULT_OK
)
{
if
(
requestCode
==
PICK_IMAGE_FROM_GALLERY_REQUEST_CODE
&&
resultCode
==
RESULT_OK
)
{
...
@@ -305,7 +358,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -305,7 +358,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
uriList
.
add
(
getPath
(
data
.
getData
()));
uriList
.
add
(
getPath
(
data
.
getData
()));
}
}
//照片的uri
//照片的uri
mPresenter
.
onGetSid
(
uriList
,
getResourceString
(
R
.
string
.
on_upload_image
));
mPresenter
.
onGetSid
(
uriList
,
getResourceString
(
R
.
string
.
on_upload_image
));
}
}
if
(
requestCode
==
PICK_VIDEO_FROM_GALLERY_REQUEST_CODE
&&
resultCode
==
RESULT_OK
)
{
if
(
requestCode
==
PICK_VIDEO_FROM_GALLERY_REQUEST_CODE
&&
resultCode
==
RESULT_OK
)
{
...
@@ -373,20 +426,20 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -373,20 +426,20 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
switch
(
v
.
getId
())
{
switch
(
v
.
getId
())
{
case
R
.
id
.
btnCaptureImage
:
case
R
.
id
.
btnCaptureImage
:
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
if
(
""
.
equals
(
uploadPath
)){
if
(
""
.
equals
(
uploadPath
))
{
showDialogCaveatMessage
(
"請選擇路徑"
);
showDialogCaveatMessage
(
"請選擇路徑"
);
}
else
{
}
else
{
openCameraIntent
();
openCameraIntent
();
}
}
break
;
break
;
case
R
.
id
.
btnGetImageFromGallery
:
case
R
.
id
.
btnGetImageFromGallery
:
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
if
(
""
.
equals
(
uploadPath
)){
if
(
""
.
equals
(
uploadPath
))
{
showDialogCaveatMessage
(
"請選擇路徑"
);
showDialogCaveatMessage
(
"請選擇路徑"
);
}
else
{
}
else
{
pickImageFromGallery
();
pickImageFromGallery
();
}
}
...
@@ -394,20 +447,20 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -394,20 +447,20 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
break
;
break
;
case
R
.
id
.
btnGetVideoFromGallery
:
case
R
.
id
.
btnGetVideoFromGallery
:
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
if
(
""
.
equals
(
uploadPath
)){
if
(
""
.
equals
(
uploadPath
))
{
showDialogCaveatMessage
(
"請選擇路徑"
);
showDialogCaveatMessage
(
"請選擇路徑"
);
}
else
{
}
else
{
pickVideoFromGallery
();
pickVideoFromGallery
();
}
}
break
;
break
;
case
R
.
id
.
btnRecordVideo
:
case
R
.
id
.
btnRecordVideo
:
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
if
(
""
.
equals
(
uploadPath
)){
if
(
""
.
equals
(
uploadPath
))
{
showDialogCaveatMessage
(
"請選擇路徑"
);
showDialogCaveatMessage
(
"請選擇路徑"
);
}
else
{
}
else
{
openRecordVideoIntent
();
openRecordVideoIntent
();
}
}
...
@@ -514,17 +567,13 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -514,17 +567,13 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
//如果能改成用retrofit加rxjava最好,已經嘗試過,可能有缺什麼,不過緊急所以先求功能
//如果能改成用retrofit加rxjava最好,已經嘗試過,可能有缺什麼,不過緊急所以先求功能
@Override
@Override
public
void
onUploadFile
(
final
ArrayList
<
String
>
uriList
,
String
type
,
final
String
sid
)
{
public
void
onUploadFile
(
final
ArrayList
<
String
>
uriList
,
String
type
,
final
String
sid
)
{
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
)
...
@@ -535,23 +584,18 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -535,23 +584,18 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
MultipartBody
.
Builder
buildernew
=
new
MultipartBody
.
Builder
()
MultipartBody
.
Builder
buildernew
=
new
MultipartBody
.
Builder
()
.
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"
),
uploadFile
));
RequestBody
.
create
(
MediaType
.
parse
(
"application/octet-stream"
),
uploadFile
));
}
}
RequestBody
body
=
buildernew
.
build
();
RequestBody
body
=
buildernew
.
build
();
Request
request
=
new
Request
.
Builder
()
Request
request
=
new
Request
.
Builder
()
.
addHeader
(
"Accept"
,
"*/*"
)
.
addHeader
(
"Accept"
,
"*/*"
)
.
url
(
"https://webapp.fpcitc.com.tw/SOP/api/FileUpload/fileUpload"
)
.
url
(
"https://webapp.fpcitc.com.tw/SOP/api/FileUpload/fileUpload"
)
.
method
(
"POST"
,
body
)
.
method
(
"POST"
,
body
)
.
build
();
.
build
();
...
@@ -569,7 +613,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -569,7 +613,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
Log
.
e
(
"response"
,
responsebody
);
Log
.
e
(
"response"
,
responsebody
);
// dismissProgressDialog();
// dismissProgressDialog();
if
(
json
.
get
(
"success"
).
equals
(
"true"
)){
if
(
json
.
get
(
"success"
).
equals
(
"true"
))
{
MainActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
MainActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -577,7 +621,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
...
@@ -577,7 +621,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
showDialogMessage
(
"上傳完成"
);
showDialogMessage
(
"上傳完成"
);
}
}
});
});
}
else
{
}
else
{
MainActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
MainActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
...
app/src/main/res/layout/login.xml
View file @
4b1c599e
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +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"
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +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"
...
...
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