Commit 38de48e0 by 羅偉育

capture

parents
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
AudiovisualRecord
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="resolveModulePerSourceSet" value="false" />
<option name="testRunner" value="PLATFORM" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<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" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.audiovisualrecord"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.0-alpha06'
implementation 'io.reactivex.rxjava2:rxjava:2.0.7'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.squareup.okhttp3:okhttp:3.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
// retrofit
implementation 'com.squareup.retrofit2:retrofit:2.2.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.github.bumptech.glide:glide:3.6.1'
// FFmpeg
implementation 'com.arthenica:mobile-ffmpeg-full:4.3.2'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.example.audiovisualrecord;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.audiovisualrecord", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.audiovisualrecord">
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/audiovisualrecord"
android:label="@string/app_name"
android:roundIcon="@mipmap/audiovisualrecord"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".ui.login.LoginActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.main.MainActivity"
android:screenOrientation="portrait"/>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
\ No newline at end of file
package com.example.audiovisualrecord;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import java.io.File;
import java.util.Locale;
public class FileUtil {
/**
* 根据Uri获取图片绝对路径
* @param context context
* @param uri uri
*/
public static String getFileAbsolutePath(Context context, Uri uri) {
if (context == null || uri == null) return null;
// DocumentProvider
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) {
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}else if ("home".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/documents/" + split[1];
}
} else if (isDownloadsDocument(uri)) {
// DownloadsProvider
final String id = DocumentsContract.getDocumentId(uri);
if (TextUtils.isEmpty(id)) {
return null;
}
if (id.startsWith("raw:")) {
return id.substring(4);
}
String[] contentUriPrefixesToTry = new String[]{
"content://downloads/public_downloads",
"content://downloads/my_downloads",
"content://downloads/all_downloads"
};
for (String contentUriPrefix : contentUriPrefixesToTry) {
try {
Uri contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.valueOf(id));
String path = getDataColumn(context, contentUri, null, null);
if (path != null) {
return path;
}
} catch (Exception ignore) {
}
}
try {
String path = getDataColumn(context, uri, null, null);
if (path != null) {
return path;
}
} catch (Exception ignore) {
}
// path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams
return null;
} else if (isMediaDocument(uri)) {
// MediaProvider
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri;
switch (type.toLowerCase(Locale.ENGLISH)) {
case "image":
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
break;
case "video":
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
break;
case "audio":
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
break;
default:
contentUri = MediaStore.Files.getContentUri("external");
break;
}
final String selection = MediaStore.MediaColumns._ID +"=?";
final String[] selectionArgs = new String[]{split[1]};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
} else if (ContentResolver.SCHEME_CONTENT.equalsIgnoreCase(uri.getScheme())) {
// MediaStore (and general)
// Return the remote address
if (isGooglePhotosUri(uri)) {
return uri.getLastPathSegment();
}
return getDataColumn(context, uri, null, null);
} else if (ContentResolver.SCHEME_FILE.equalsIgnoreCase(uri.getScheme())) {
// File
return uri.getPath();
}
return null;
}
/**
* 通过游标获取当前文件路径
* @param context context
* @param uri uri
* @param selection selection
* @param selectionArgs selectionArgs
* @return 路径,未找到返回null
*/
public static String getDataColumn(Context context, @NonNull Uri uri, String selection, String[] selectionArgs) {
Cursor cursor = null;
String column = MediaStore.Images.Media.DATA;
String[] projection = {column};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
} catch (Exception ignore) {
Log.e("error", ignore.getMessage());
} finally {
if (cursor != null)
cursor.close();
}
return null;
}
//檔案名
public static String fileName(String path){
if( path == null || path.isEmpty() ) return "";
File file = new File(path);
if( !file.exists() || !file.isFile() ) {
return "";
}
String filename = file.getName();
// String ext = FileKit.getFileExt(filename);
// if( !ext.equalsIgnoreCase(".csv") ){
// return "";
// }
return filename;
}
public static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
public static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
public static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
public static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
}
package com.example.audiovisualrecord;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Log;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import static android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
public class HDMediaStore {
public static String insertImage(ContentResolver cr, Bitmap source,
String title, String description) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_hhmm");
String timeName = dateFormat.format(calendar.getTime());
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, title);
values.put(MediaStore.MediaColumns.DISPLAY_NAME, timeName);
values.put(MediaStore.MediaColumns.BUCKET_DISPLAY_NAME, timeName);
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpg");
Uri url = null;
String stringUrl = null; /* value to be returned */
try {
url = cr.insert(EXTERNAL_CONTENT_URI, values);
if (source != null) {
OutputStream imageOut = cr.openOutputStream(url);
try {
source.compress(Bitmap.CompressFormat.JPEG, 100, imageOut);
} finally {
imageOut.close();
}
long id = ContentUris.parseId(url);
// Wait until MINI_KIND thumbnail is generated.
} else {
Log.e("kkk", "Failed to create thumbnail, removing original");
cr.delete(url, null, null);
url = null;
}
} catch (Exception e) {
Log.e("kkk", "Failed to insert image", e);
if (url != null) {
cr.delete(url, null, null);
url = null;
}
}
if (url != null) {
stringUrl = url.toString();
}
return stringUrl;
}
}
package com.example.audiovisualrecord;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ClipData;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class MagicFileChooser {
// TODO ------類別常數------
/**
* 檔案選取器的Activity Request Code。
*/
public static final int ACTIVITY_FILE_CHOOSER = 9973;
// TODO -----物件變數-----
/**
* 儲存使用這個檔案選取器的Activity。
*/
private final Activity activity;
// TODO -----物件變數-----
/**
* 儲存是否正在選取檔案。
*/
private boolean choosing = false;
/**
* 儲存被選到的檔案是否一定要可以讀取。
*/
private boolean mustCanRead;
/**
* 儲存被選到的檔案。
*/
private File[] chosenFiles;
// TODO -----建構子-----
/**
* 建構子,在Activity內使用檔案選取器。
*
* @param activity 傳入使用這個檔案選取器的Activity。
*/
public MagicFileChooser(final Activity activity) {
this.activity = activity;
}
// TODO -----類別方法-----
/**
* 從Uri取得絕對路徑。
*
* @param context 傳入Context
* @param uris 傳入Uri陣列
* @return 傳回絕對路徑字串陣列,若絕對路徑無法取得,則對應的陣列索引位置為null
*/
public static String[] getAbsolutePathsFromUris(final Context context, final Uri[] uris) {
return getAbsolutePathsFromUris(context, uris, false);
}
/**
* 從多個Uri取得絕對路徑。
*
* @param context 傳入Context
* @param uris 傳入Uri陣列
* @param mustCanRead 傳入Uri所指的路徑是否一定要可以讀取
* @return 傳回絕對路徑字串陣列,若絕對路徑無法取得或是無法讀取,則對應的陣列索引位置為null
*/
public static String[] getAbsolutePathsFromUris(final Context context, final Uri[] uris, final boolean mustCanRead) {
if (uris == null) {
return null;
}
final int urisLength = uris.length;
final String[] paths = new String[urisLength];
for (int i = 0; i < urisLength; ++i) {
final Uri uri = uris[i];
paths[i] = getAbsolutePathFromUri(context, uri, mustCanRead);
}
return paths;
}
/**
* 從多個Uri取得File物件。
*
* @param context 傳入Context
* @param uris 傳入Uri陣列
* @return 傳回File物件陣列,若File物件無法建立,則對應的陣列索引位置為null
*/
public static File[] getFilesFromUris(final Context context, final Uri[] uris) {
return getFilesFromUris(context, uris, false);
}
/**
* 從多個Uri取得File物件。
*
* @param context 傳入Context
* @param uris 傳入Uri陣列
* @param mustCanRead 傳入Uri所指的路徑是否一定要可以讀取
* @return 傳回File物件陣列,若File物件無法建立或是檔案路徑無法讀取,則對應的陣列索引位置為null
*/
public static File[] getFilesFromUris(final Context context, final Uri[] uris, final boolean mustCanRead) {
if (uris == null) {
return null;
}
final int urisLength = uris.length;
final File[] files = new File[urisLength];
for (int i = 0; i < urisLength; ++i) {
final Uri uri = uris[i];
files[i] = getFileFromUri(context, uri, mustCanRead);
}
return files;
}
/**
* 從Uri取得絕對路徑。
*
* @param context 傳入Context
* @param uri 傳入Uri物件
* @return 傳回絕對路徑,若絕對路徑無法取得,傳回null
*/
public static String getAbsolutePathFromUri(final Context context, final Uri uri) {
return getAbsolutePathFromUri(context, uri, false);
}
/**
* 從Uri取得絕對路徑。
*
* @param context 傳入Context
* @param uri 傳入Uri物件
* @param mustCanRead 傳入Uri所指的路徑是否一定要可以讀取
* @return 傳回絕對路徑,若絕對路徑無法取得或是無法讀取,傳回null
*/
public static String getAbsolutePathFromUri(final Context context, final Uri uri, final boolean mustCanRead) {
final File file = getFileFromUri(context, uri, mustCanRead);
if (file != null) {
return file.getAbsolutePath();
} else {
return null;
}
}
/**
* 從Uri取得File物件。
*
* @param context 傳入Context
* @param uri 傳入Uri物件
* @return 傳回File物件,若File物件無法建立,傳回null
*/
public static File getFileFromUri(final Context context, final Uri uri) {
return getFileFromUri(context, uri, false);
}
/**
* 從Uri取得File物件。
*
* @param context 傳入Context
* @param uri 傳入Uri物件
* @param mustCanRead 傳入Uri所指的路徑是否一定要可以讀取
* @return 傳回File物件,若File物件無法建立或是檔案路徑無法讀取,傳回null
*/
@SuppressLint("NewApi")
public static File getFileFromUri(final Context context, final Uri uri, final boolean mustCanRead) {
if (uri == null) {
return null;
}
// 判斷是否為Android 4.4之後的版本
final boolean after44 = Build.VERSION.SDK_INT >= 19;
if (after44 && DocumentsContract.isDocumentUri(context, uri)) {
// 如果是Android 4.4之後的版本,而且屬於文件URI
final String authority = uri.getAuthority();
// 判斷Authority是否為本地端檔案所使用的
if ("com.android.externalstorage.documents".equals(authority)) {
// 外部儲存空間
final String docId = DocumentsContract.getDocumentId(uri);
final String[] divide = docId.split(":");
final String type = divide[0];
if ("primary".equals(type)) {
String path = Environment.getExternalStorageDirectory().getAbsolutePath().concat("/").concat(divide[1]);
return createFileObjFromPath(path, mustCanRead);
} else {
String path = "/storage/".concat(type).concat("/").concat(divide[1]);
return createFileObjFromPath(path, mustCanRead);
}
} else if ("com.android.providers.downloads.documents".equals(authority)) {
// 下載目錄
final String docId = DocumentsContract.getDocumentId(uri);
if (docId.startsWith("raw:")) {
final String path = docId.replaceFirst("raw:", "");
return createFileObjFromPath(path, mustCanRead);
}
final Uri downloadUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.parseLong(docId));
String path = queryAbsolutePath(context, downloadUri);
return createFileObjFromPath(path, mustCanRead);
} else if ("com.android.providers.media.documents".equals(authority)) {
// 圖片、影音檔案
final String docId = DocumentsContract.getDocumentId(uri);
final String[] divide = docId.split(":");
final String type = divide[0];
Uri mediaUri = null;
if ("image".equals(type)) {
mediaUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
mediaUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
mediaUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
} else {
return null;
}
mediaUri = ContentUris.withAppendedId(mediaUri, Long.parseLong(divide[1]));
String path = queryAbsolutePath(context, mediaUri);
return createFileObjFromPath(path, mustCanRead);
}
} else {
// 如果是一般的URI
final String scheme = uri.getScheme();
String path = null;
if ("content".equals(scheme)) {
// 內容URI
path = queryAbsolutePath(context, uri);
} else if ("file".equals(scheme)) {
// 檔案URI
path = uri.getPath();
}
return createFileObjFromPath(path, mustCanRead);
}
return null;
}
/**
* 將路徑轉成File物件。
*
* @param path 傳入檔案路徑
* @return 傳回File物件,若File物件無法建立,傳回null。
*/
public static File createFileObjFromPath(final String path) {
return createFileObjFromPath(path, false);
}
/**
* 將路徑轉成File物件。
*
* @param path 傳入檔案路徑
* @param mustCanRead 傳入檔案路徑是否一定要可以讀取
* @return 傳回File物件,若File物件無法建立或是檔案路徑無法讀取,傳回null
*/
public static File createFileObjFromPath(final String path, final boolean mustCanRead) {
if (path != null) {
try {
File file = new File(path);
if (mustCanRead) {
file.setReadable(true);
if (!file.canRead()) {
return null;
}
}
return file.getAbsoluteFile();
} catch (Exception ex) {
ex.printStackTrace();
}
}
return null;
}
/**
* 查詢MediaStroe Uri對應的絕對路徑。
*
* @param context 傳入Context
* @param uri 傳入MediaStore Uri
* @return 傳回絕對路徑
*/
public static String queryAbsolutePath(final Context context, final Uri uri) {
final String[] projection = {MediaStore.MediaColumns.DATA};
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri, projection, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
return cursor.getString(index);
}
} catch (final Exception ex) {
ex.printStackTrace();
if (cursor != null) {
cursor.close();
}
}
return null;
}
// TODO -----物件方法-----
/**
* 顯示檔案選取器,選取所有檔案,不設定檔案選取器的標題,僅進行單獨選取,被選到的檔案不一定要可以讀取。
*
* @return 傳回檔案選取器是否開啟成功
*/
public boolean showFileChooser() {
return showFileChooser("*/*");
}
/**
* 顯示檔案選取器,不設定檔案選取器的標題,僅進行單獨選取,被選到的檔案不一定要可以讀取。
*
* @param mimeType 傳入篩選的MIME類型
* @return 傳回檔案選取器是否開啟成功
*/
public boolean showFileChooser(final String mimeType) {
return showFileChooser(mimeType, null);
}
/**
* 顯示檔案選取器,僅進行單獨選取,被選到的檔案不一定要可以讀取。
*
* @param mimeType 傳入篩選的MIME類型
* @param chooserTitle 傳入檔案選取器的標題,若為null則用預設值
* @return 傳回檔案選取器是否開啟成功
*/
public boolean showFileChooser(final String mimeType, final String chooserTitle) {
return showFileChooser(mimeType, chooserTitle, false);
}
/**
* 顯示檔案選取器,被選到的檔案不一定要可以讀取。
*
* @param mimeType 傳入篩選的MIME類型
* @param chooserTitle 傳入檔案選取器的標題,若為null則用預設值
* @param allowMultiple 傳入檔案選取器是否使用複選
* @return 傳回檔案選取器是否開啟成功
*/
public boolean showFileChooser(final String mimeType, final String chooserTitle, final boolean allowMultiple) {
return showFileChooser(mimeType, chooserTitle, allowMultiple, false);
}
/**
* 顯示檔案選取器。
*
* @param mimeType 傳入篩選的MIME類型
* @param chooserTitle 傳入檔案選取器的標題,若為null則用預設值
* @param allowMultiple 傳入檔案選取器是否使用複選
* @param mustCanRead 傳入被選到的檔案是否一定要可以讀取
* @return 傳回檔案選取器是否開啟成功
*/
public boolean showFileChooser(final String mimeType, final String chooserTitle, final boolean allowMultiple, final boolean mustCanRead) {
if (mimeType == null || choosing) {
return false;
}
choosing = true;
// 檢查是否有可用的Activity
final PackageManager packageManager = activity.getPackageManager();
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(mimeType);
final List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
this.mustCanRead = mustCanRead;
// 如果有可用的Activity
final Intent picker = new Intent(Intent.ACTION_GET_CONTENT);
picker.setType(mimeType);
picker.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, allowMultiple);
picker.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
// 使用Intent Chooser
final Intent destIntent = Intent.createChooser(picker, chooserTitle);
activity.startActivityForResult(destIntent, ACTIVITY_FILE_CHOOSER);
return true;
} else {
return false;
}
}
/**
* 當檔案選取器被關閉後,應該要呼叫這個方法,判斷檔案選取器是否有選取到檔案,接著再用getChosenFiles方法來取得選取結果。
*
* @param requestCode 傳入Activity的Request Code
* @param resultCode 傳入Activity的Request Code
* @param data 傳入Activity的data
* @return 傳回檔案選取器是否有選取結果。
*/
public boolean onActivityResult(final int requestCode, final int resultCode, final Intent data) {
if (requestCode == ACTIVITY_FILE_CHOOSER) {
choosing = false;
if (resultCode == Activity.RESULT_OK) {
final Uri uri = data.getData();
if (uri != null) {
// 單選
chosenFiles = getFilesFromUris(activity, new Uri[]{uri}, mustCanRead);
return true;
} else if (Build.VERSION.SDK_INT >= 16) {
// 複選
final ClipData clipData = data.getClipData();
if (clipData != null) {
int count = clipData.getItemCount();
if (count > 0) {
final Uri[] uris = new Uri[count];
for (int i = 0; i < count; ++i) {
uris[i] = clipData.getItemAt(i).getUri();
}
chosenFiles = getFilesFromUris(activity, uris, mustCanRead);
return true;
}
}
}
}
}
return false;
}
/**
* 取得被選取到的檔案。
*
* @return 傳回被選取到的檔案,過濾掉不成功的部份
*/
public File[] getChosenFiles(final boolean filter) {
if (chosenFiles == null) {
return new File[0];
} else {
final ArrayList<File> alFileList = new ArrayList<>();
for (final File chosenFile : chosenFiles) {
if (filter && chosenFile == null) {
continue;
}
alFileList.add(chosenFile);
}
final File[] files = new File[alFileList.size()];
alFileList.toArray(files);
return files;
}
}
/**
* 取得被選取到的檔案。
*
* @return 傳回被選取到的檔案,過濾掉不成功的部份
*/
public File[] getChosenFiles() {
return getChosenFiles(true);
}
}
package com.example.audiovisualrecord.base;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;
import com.example.audiovisualrecord.utils.ToastCreator;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
/**
* Created by 5*N on 2017/12/22
*/
public abstract class BaseActivity extends AppCompatActivity implements BaseView {
private ProgressDialog mProgressDialog;
private Calendar mCalendar = Calendar.getInstance();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void showProgressDialog(@StringRes int text) {
dismissProgressDialog();
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage(this.getResources().getString(text));
mProgressDialog.setCancelable(false);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
}
@Override
public void showItemDialog(List<String> list, DialogInterface.OnClickListener onClickListener) {
new AlertDialog.Builder(this)
.setItems(list.toArray(new String[list.size()]), onClickListener)
.create()
.show();
}
@Override
public void showProgressDialog(String text) {
dismissProgressDialog();
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage(text);
mProgressDialog.setCancelable(false);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
}
@Override
public void dismissProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.cancel();
}
}
@Override
public void showDialogCaveatMessage(String title, String message) {
new AlertDialog.Builder(this)
.setTitle(title)
.setMessage(message)
.setPositiveButton(android.R.string.yes, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
@Override
public void showDialogCaveatMessage(String message) {
new AlertDialog.Builder(this)
.setTitle(message)
.setPositiveButton(android.R.string.yes, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
@Override
public void showDialogMessage(String message) {
new AlertDialog.Builder(this)
.setTitle(message)
.setPositiveButton(android.R.string.yes, null)
.show();
}
@Override
public void showDialogMessage(String title, String message) {
new AlertDialog.Builder(this)
.setTitle(title)
.setMessage(message)
.setPositiveButton(android.R.string.yes, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
@Override
public void showDatePickerDialog(DatePickerDialog.OnDateSetListener onDateSetListener) {
DatePickerDialog dialog = new DatePickerDialog(this,
onDateSetListener,
mCalendar.get(Calendar.YEAR),
mCalendar.get(Calendar.MONTH),
mCalendar.get(Calendar.DAY_OF_MONTH));
dialog.show();
}
@Override
public void showSelectDialog(String text, DialogInterface.OnClickListener onClickListener) {
new AlertDialog.Builder(this)
.setMessage(text)
.setPositiveButton("確認", onClickListener)
.setCancelable(false)
.create()
.show();
}
@Override
public String getResourceString(@StringRes int text) {
return getResources().getString(text);
}
@Override
public String getTodayTime() {
String dateformat = "yyyyMMdd";
Calendar mCal = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(dateformat);
String today = df.format(mCal.getTime());
return today;
}
@Override
public void showToast(@StringRes int text) {
ToastCreator.makeText(this, text, Toast.LENGTH_SHORT);
}
@Override
public void showToast(String text) {
ToastCreator.makeText(this, text, Toast.LENGTH_SHORT);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public String getPath(Uri uri) {
// check here to KITKAT or new version
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(this, uri)) {
// ExternalStorageProvider
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/"
+ split[1];
}
}
// DownloadsProvider
else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"),
Long.valueOf(id));
return getDataColumn(this, contentUri, null, null);
}
// MediaProvider
else if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[]{split[1]};
return getDataColumn(this, contentUri, selection,
selectionArgs);
}
}
// MediaStore (and general)
else if ("content".equalsIgnoreCase(uri.getScheme())) {
// Return the remote address
if (isGooglePhotosUri(uri))
return uri.getLastPathSegment();
return getDataColumn(this, uri, null, null);
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
return null;
}
/**
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.
*
* @param context - The context.
* @param uri - The Uri to query.
* @param selection - (Optional) Filter used in the query.
* @param selectionArgs - (Optional) Selection arguments used in the query.
* @return - The value of the _data column, which is typically a file path.
*/
private static String getDataColumn(Context context, Uri uri,
String selection, String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {column};
try {
cursor = context.getContentResolver().query(uri, projection,
selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
}
/**
* @param uri - The Uri to check.
* @return - Whether the Uri authority is ExternalStorageProvider.
*/
private static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
/**
* @param uri - The Uri to check.
* @return - Whether the Uri authority is DownloadsProvider.
*/
private static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
/**
* @param uri - The Uri to check.
* @return - Whether the Uri authority is MediaProvider.
*/
private static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
/**
* @param uri - The Uri to check.
* @return - Whether the Uri authority is Google Photos.
*/
private static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
}
package com.example.audiovisualrecord.base;
/**
* Created by 5*N on 2017/12/22
*/
public interface BaseAttacher<V extends BaseView> {
void onAttached(V view);
void onDetached();
}
package com.example.audiovisualrecord.base;
import android.app.ProgressDialog;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import com.example.audiovisualrecord.utils.ToastCreator;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
/**
* Created by 5*N on 2018/1/12
*/
public abstract class BaseFragment extends Fragment implements BaseView {
private ProgressDialog mProgressDialog;
private Calendar mCalendar = Calendar.getInstance();
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void showProgressDialog(@StringRes int text) {
dismissProgressDialog();
mProgressDialog = new ProgressDialog(getActivity());
mProgressDialog.setMessage(getActivity().getResources().getString(text));
mProgressDialog.setCancelable(false);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
}
@Override
public void dismissProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.cancel();
}
}
@Override
public String getResourceString(@StringRes int text) {
return getResources().getString(text);
}
@Override
public String getTodayTime() {
String dateformat = "yyyyMMdd";
Calendar mCal = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(dateformat);
String today = df.format(mCal.getTime());
return today;
}
@Override
public void showToast(@StringRes int text) {
ToastCreator.makeText(getActivity(), text, Toast.LENGTH_SHORT);
}
@Override
public void showToast(String text) {
ToastCreator.makeText(getActivity(), text, Toast.LENGTH_SHORT);
}
@Override
public void showItemDialog(List<String> list, DialogInterface.OnClickListener onClickListener) {
new AlertDialog.Builder(getActivity())
.setItems(list.toArray(new String[list.size()]), onClickListener)
.create()
.show();
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public String getPath(Uri uri) {
// check here to KITKAT or new version
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(getActivity(), uri))
{
// ExternalStorageProvider
if (isExternalStorageDocument(uri))
{
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type))
{
return Environment.getExternalStorageDirectory() + "/"
+ split[1];
}
}
// DownloadsProvider
else if (isDownloadsDocument(uri))
{
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"),
Long.valueOf(id));
return getDataColumn(getActivity(), contentUri, null, null);
}
// MediaProvider
else if (isMediaDocument(uri))
{
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type))
{
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
}
else if ("video".equals(type))
{
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
}
else if ("audio".equals(type))
{
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[] { split[1] };
return getDataColumn(getActivity(), contentUri, selection,
selectionArgs);
}
}
// MediaStore (and general)
else if ("content".equalsIgnoreCase(uri.getScheme()))
{
// Return the remote address
if (isGooglePhotosUri(uri))
return uri.getLastPathSegment();
return getDataColumn(getActivity(), uri, null, null);
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme()))
{
return uri.getPath();
}
return null;
}
/**
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.
*
* @param context - The context.
* @param uri - The Uri to query.
* @param selection - (Optional) Filter used in the query.
* @param selectionArgs - (Optional) Selection arguments used in the query.
* @return - The value of the _data column, which is typically a file path.
*/
private static String getDataColumn(Context context, Uri uri,
String selection, String[] selectionArgs)
{
Cursor cursor = null;
final String column = "_data";
final String[] projection = { column };
try
{
cursor = context.getContentResolver().query(uri, projection,
selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst())
{
final int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
}
finally
{
if (cursor != null)
cursor.close();
}
return null;
}
/**
* @param uri - The Uri to check.
* @return - Whether the Uri authority is ExternalStorageProvider.
*/
private static boolean isExternalStorageDocument(Uri uri)
{
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
/**
* @param uri - The Uri to check.
* @return - Whether the Uri authority is DownloadsProvider.
*/
private static boolean isDownloadsDocument(Uri uri)
{
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
/**
* @param uri - The Uri to check.
* @return - Whether the Uri authority is MediaProvider.
*/
private static boolean isMediaDocument(Uri uri)
{
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
/**
* @param uri - The Uri to check.
* @return - Whether the Uri authority is Google Photos.
*/
private static boolean isGooglePhotosUri(Uri uri)
{
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
}
package com.example.audiovisualrecord.base;
import com.example.audiovisualrecord.utils.api.ApiService;
import com.example.audiovisualrecord.utils.api.ErpAPI;
import com.example.audiovisualrecord.utils.rxjava.SchedulerProvider;
import io.reactivex.disposables.CompositeDisposable;
public class BasePresenter<V extends BaseView> implements BaseAttacher<V> {
private V mView;
private ApiService api;
private ErpAPI erpAPI;
private SchedulerProvider schedulerProvider;
private CompositeDisposable compositeDisposable;
public BasePresenter(ApiService api,
ErpAPI erpAPI,
SchedulerProvider schedulerProvider,
CompositeDisposable compositeDisposable) {
this.api = api;
this.erpAPI=erpAPI;
this.schedulerProvider = schedulerProvider;
this.compositeDisposable = compositeDisposable;
}
public V getView() {
return mView;
}
@Override
public void onAttached(V view) {
mView = view;
}
@Override
public void onDetached() {
mView = null;
}
public ApiService getApiService() {
return api;
}
// public ErpAPI getErpAPI(){
// return erpAPI;
// }
public SchedulerProvider getSchedulerProvider() {
return schedulerProvider;
}
public CompositeDisposable getCompositeDisposable() {
return compositeDisposable;
}
}
package com.example.audiovisualrecord.base;
import android.app.DatePickerDialog;
import android.content.DialogInterface;
import android.net.Uri;
import androidx.annotation.StringRes;
import java.util.List;
/**
* Created by 5*N on 2017/12/22
*/
public interface BaseView {
void init();
void showItemDialog(List<String> list, DialogInterface.OnClickListener onClickListener);
void showProgressDialog(@StringRes int text);
void showProgressDialog(String text);
void dismissProgressDialog();
void showDialogCaveatMessage(String message);
void showDialogMessage(String message);
void showDialogMessage(String title, String message);
void showDialogCaveatMessage(String title, String message);
void showDatePickerDialog(DatePickerDialog.OnDateSetListener onDateSetListener);
void showSelectDialog(String text, DialogInterface.OnClickListener onClickListener);
String getResourceString(@StringRes int text);
String getTodayTime();
void showToast(String text);
void showToast(@StringRes int text);
String getPath(Uri uri);
}
package com.example.audiovisualrecord.ui.chooseitem;
import java.io.Serializable;
public class ChooseDeviceItemData implements Serializable {
private String recordDate="";
private String factoryAreaName ="";
// private String maintenancePlantCompanyId="";
private String factoryAreaId ="";
private String company="";
private String companyId="";
private String productionPlantId="";
private String factoryClassCode ="";
private String factoryClass ="";
private String deviceCategory="";
private String deviceCategryId="";
private String shootType ="";
private String deciceId="";
private String deciceName="";
private String keynote="";
private String filePath="";
private String uploadEmployees="";
private boolean backgroundChange=false;
private boolean checkEndItem=false;
// public String getMaintenancePlantCompanyId() {
// return maintenancePlantCompanyId;
// }
//
// public void setMaintenancePlantCompanyId(String maintenancePlantCompanyId) {
// this.maintenancePlantCompanyId = maintenancePlantCompanyId;
// }
public String getFactoryAreaId() {
return factoryAreaId;
}
public void setFactoryAreaId(String factoryAreaId) {
this.factoryAreaId = factoryAreaId;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public String getProductionPlantId() {
return productionPlantId;
}
public void setProductionPlantId(String productionPlantId) {
this.productionPlantId = productionPlantId;
}
public String getShootType() {
return shootType;
}
public void setShootType(String shootType) {
this.shootType = shootType;
}
public String getDeviceCategryId() {
return deviceCategryId;
}
public void setDeviceCategryId(String deviceCategryId) {
this.deviceCategryId = deviceCategryId;
}
public String getDeciceName() {
return deciceName;
}
public void setDeciceName(String deciceName) {
this.deciceName = deciceName;
}
public boolean isBackgroundChange() {
return backgroundChange;
}
public String getRecordDate() {
return recordDate;
}
public void setRecordDate(String recordDate) {
this.recordDate = recordDate;
}
public String getFactoryAreaName() {
return factoryAreaName;
}
public void setFactoryAreaName(String factoryAreaName) {
this.factoryAreaName = factoryAreaName;
}
public String getFactoryClassCode() {
return factoryClassCode;
}
public void setFactoryClassCode(String factoryClassCode) {
this.factoryClassCode = factoryClassCode;
}
public String getFactoryClass() {
return factoryClass;
}
public void setFactoryClass(String factoryClass) {
this.factoryClass = factoryClass;
}
public String getDeviceCategory() {
return deviceCategory;
}
public void setDeviceCategory(String deviceCategory) {
this.deviceCategory = deviceCategory;
}
public String getDeciceId() {
return deciceId;
}
public void setDeciceId(String deciceId) {
this.deciceId = deciceId;
}
public String getKeynote() {
return keynote;
}
public void setKeynote(String keynote) {
this.keynote = keynote;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getUploadEmployees() {
return uploadEmployees;
}
public void setUploadEmployees(String uploadEmployees) {
this.uploadEmployees = uploadEmployees;
}
public boolean getBackgroundChange() {
return backgroundChange;
}
public void setBackgroundChange(boolean backgroundChange) {
this.backgroundChange = backgroundChange;
}
public boolean isCheckEndItem() {
return checkEndItem;
}
public void setCheckEndItem(boolean checkEndItem) {
this.checkEndItem = checkEndItem;
}
}
package com.example.audiovisualrecord.ui.login;
import android.Manifest;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.example.audiovisualrecord.ui.main.MainActivity;
import com.example.audiovisualrecord.R;
import com.example.audiovisualrecord.base.BaseActivity;
public class LoginActivity extends BaseActivity implements LoginContract.View, View.OnClickListener {
EditText editAccount, editPassword;
Button btnLogin;
private LoginPresenter presenter;
// LoginContract.Presenter<LoginContract.View> mPresenter = new LoginContract.Presenter<LoginContract.View>;
private static final int REQUEST_PERMISSIONS_CODE = 20200410;
private String[] permissions = {
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.CAMERA};
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
init();
requestPermissions(permissions, REQUEST_PERMISSIONS_CODE);
presenter = new LoginPresenter(this);
}
@Override
protected void onPause() {
super.onPause();
btnLogin.setEnabled(true);
}
@Override
public void init() {
editAccount = findViewById(R.id.edit_account);
editPassword = findViewById(R.id.edit_password);
btnLogin = findViewById(R.id.btn_login);
btnLogin.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_login:
btnLogin.setEnabled(false);
showProgressDialog("登入中");
if (onCheckUserisEmpty()) {
presenter.onLogin(editAccount.getText().toString(), editPassword.getText().toString());
} else {
dismissProgressDialog();
btnLogin.setEnabled(true);
}
break;
}
}
private boolean onCheckUserisEmpty() {
if ("".equals(editAccount.getText().toString())) {
showDialogMessage(getResourceString(R.string.login_account_hint));
return false;
}
if ("".equals(editPassword.getText().toString())) {
showDialogMessage(getResourceString(R.string.login_password_hint));
return false;
}
return true;
}
@Override
public void onCompleteLogin(String token) {
dismissProgressDialog();
Intent intent = new Intent(this, MainActivity.class);
Bundle bag = new Bundle();
bag.putString("token", token);
intent.putExtras(bag);
startActivity(intent);
}
@Override
public void setButtonEnable(Boolean boo) {
btnLogin.setEnabled(boo);
}
}
\ No newline at end of file
package com.example.audiovisualrecord.ui.login;
import com.example.audiovisualrecord.base.BaseAttacher;
import com.example.audiovisualrecord.base.BaseView;
public interface LoginContract {
interface View extends BaseView {
void onCompleteLogin(String token);
void setButtonEnable(Boolean boo);
}
interface Presenter<V extends View> extends BaseAttacher<V> {
void onLogin(String account,String password);
}
}
package com.example.audiovisualrecord.ui.login;
import android.content.Context;
import android.util.Log;
import com.example.audiovisualrecord.R;
import com.example.audiovisualrecord.utils.api.ApiService;
import com.example.audiovisualrecord.utils.api.HttpMethods;
import com.example.audiovisualrecord.utils.api.apidata.login.LoginRequest;
import com.example.audiovisualrecord.utils.api.apidata.login.LoginResponse;
import com.example.audiovisualrecord.utils.rxjava.SchedulerProvider;
import com.example.audiovisualrecord.utils.rxjava.SchedulerProviderImp;
import com.example.audiovisualrecord.utils.sharepreferences.LoginPreferences;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableObserver;
public class LoginPresenter<V extends LoginContract.View> implements LoginContract.Presenter<V> {
// LoginPreferences loginPreferences;
private V view;
private String LOGIN_AUTHORIZED_ID = "06cdae9b-fa20-497d-8207-0eb73582623b";
private ApiService api;
SchedulerProviderImp schedulerProviderImp = new SchedulerProviderImp();
private CompositeDisposable compositeDisposable;
public LoginPresenter(V view) {
this.view = view;
api = HttpMethods.getInstance().getApi();
compositeDisposable = new CompositeDisposable();
}
@Override
public void onLogin(String account, String password) {
String url = view.getResourceString(R.string.api_on_Login);
// LoginRequest mLoginRequest = new LoginRequest(LOGIN_AUTHORIZED_ID, "N000158385", "781122222");
LoginRequest mLoginRequest = new LoginRequest(LOGIN_AUTHORIZED_ID, account, password);
compositeDisposable.add(api.onLogin(url, mLoginRequest)
.subscribeOn(schedulerProviderImp.io())
.observeOn(schedulerProviderImp.ui())
.subscribeWith(new DisposableObserver<LoginResponse>() {
@Override
public void onNext(LoginResponse loginResponse) {
if ("True".equals(loginResponse.getmResult())) {
view.onCompleteLogin(loginResponse.getmMsg());
} else {
view.dismissProgressDialog();
view.showDialogCaveatMessage("登入失敗");
}
}
@Override
public void onError(Throwable e) {
Log.e("err", e.getMessage());
view.dismissProgressDialog();
if(e.getMessage().contains("No address associated with hostname"))
{
view.showDialogCaveatMessage("請檢查網路狀態");
}
view.showDialogCaveatMessage("登入失敗");
view.setButtonEnable(true);
}
@Override
public void onComplete() {
}
})
);
}
@Override
public void onAttached(V view) {
}
@Override
public void onDetached() {
}
}
\ No newline at end of file
package com.example.audiovisualrecord.ui.main;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.FileProvider;
import androidx.core.os.EnvironmentCompat;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.example.audiovisualrecord.FileUtil;
import com.example.audiovisualrecord.HDMediaStore;
import com.example.audiovisualrecord.MagicFileChooser;
import com.example.audiovisualrecord.R;
import com.example.audiovisualrecord.base.BaseActivity;
import com.example.audiovisualrecord.ui.chooseitem.ChooseDeviceItemData;
import com.example.audiovisualrecord.utils.api.apidata.searchco.COResponse;
import com.example.audiovisualrecord.utils.api.apidata.searchtype.TYPEResponse;
import com.example.audiovisualrecord.utils.api.searchshift.SHIFTResponse;
import com.example.audiovisualrecord.utils.api.searchpz.PZResponse;
import com.example.audiovisualrecord.utils.api.searchdp.DPResponse;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.FileNotFoundException;
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;
import java.util.concurrent.TimeUnit;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class MainActivity extends BaseActivity implements MainContract.View, View.OnClickListener {
private static final int REQUEST_CAPTURE_IMAGE = 100;
private static final int REQUEST_VIDEO_CAPTURE = 200;
private static final int PICK_IMAGE_FROM_GALLERY_REQUEST_CODE = 300;
private static final int PICK_VIDEO_FROM_GALLERY_REQUEST_CODE = 400;
private static final int PICK_FILE_REQUEST_CODE = 500;
private Button btnCapturePicture, btnRecordVideo, btnGetImageFromGallery, btnGetVideoFromGallery, btnDeviceEdit, btnCentralCloud, btnChoseDevice, btnBasicInformation;
private String pathCompany = "";
private String pathFactoryArea = "";
private String pathFactoryClass = "";
private String pathClass = "";
private String pathShootType = "";
private String uploadPath = "";
/**
* 用于保存拍照图片的uri
*/
private Uri mCameraUri;
/**
* 用于保存图片的文件路径,Android 10以下使用图片路径访问图片
*/
private String mCameraImagePath;
/**
* 是否是Android 10以上手机
*/
private boolean isAndroidQ = Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q;
Bundle bag;
String token, imageFilePath;
int countFile = 0;
private TextView tvCompany, tvFactory, tvClass, tvUnit, tvShootType;
private TextView textCompany, textFactory, textClass, textUnit, textShootType;
private MainPresenter mPresenter;
private MainData mMainData;
private ChooseDeviceItemData mChooseDeviceItemData;
private ArrayList<String> dialogString = new ArrayList<>();
private List<String> filepath = new ArrayList<>();
private List<String> filename = new ArrayList<>();
String sidData = "";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dismissProgressDialog();
bag = getIntent().getExtras();
token = bag.getString("token");
init();
mPresenter = new MainPresenter(this, token);
mMainData = new MainData();
mChooseDeviceItemData = new ChooseDeviceItemData();
createSegVideoFolder();
}
private void createSegVideoFolder() {
File folder = new File(Environment.getExternalStorageDirectory() +
File.separator + "Seg_Video");
boolean success = true;
if (!folder.exists()) {
success = folder.mkdirs();
} else {
Log.e("wer", "folder exists");
}
}
@Override
public void init() {
btnCapturePicture = findViewById(R.id.btnCaptureImage);
btnGetImageFromGallery = findViewById(R.id.btnGetImageFromGallery);
btnGetVideoFromGallery = findViewById(R.id.btnGetVideoFromGallery);
btnRecordVideo = findViewById(R.id.btnRecordVideo);
btnCapturePicture.setOnClickListener(this);
btnGetImageFromGallery.setOnClickListener(this);
btnGetVideoFromGallery.setOnClickListener(this);
btnRecordVideo.setOnClickListener(this);
tvCompany = findViewById(R.id.tv_company);
tvFactory = findViewById(R.id.tv_factory);
tvUnit = findViewById(R.id.tv_unit);
tvClass = findViewById(R.id.tv_class);
tvShootType = findViewById(R.id.tv_shoottype);
tvCompany.setOnClickListener(this);
tvFactory.setOnClickListener(this);
tvUnit.setOnClickListener(this);
tvClass.setOnClickListener(this);
tvShootType.setOnClickListener(this);
textCompany = findViewById(R.id.text_company);
textUnit = findViewById(R.id.text_unit);
textShootType = findViewById(R.id.text_shoottype);
textFactory = findViewById(R.id.text_factory);
textClass = findViewById(R.id.text_class);
}
private void pickImageFromGallery() {
//Create an Intent with action as ACTION_PICK
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
// Sets the type as image/*. This ensures only components of type image are selected
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
//We pass an extra array with the accepted mime types. This will ensure only components with these MIME types as targeted.
String[] mimeTypes = {"image/jpeg", "image/png"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
// Launching the Intent
startActivityForResult(intent, PICK_IMAGE_FROM_GALLERY_REQUEST_CODE);
}
private void pickVideoFromGallery() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("video/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
String[] mimeTypes = {"video/mp4", "video/mov"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
startActivityForResult(intent, PICK_VIDEO_FROM_GALLERY_REQUEST_CODE);
}
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() {
Intent pictureIntent = new Intent(
MediaStore.ACTION_IMAGE_CAPTURE);
settingSystemCamera(pictureIntent);
if (pictureIntent.resolveActivity(getPackageManager()) != null) {
//Create a file to store the image
File photoFile = null;
Uri photoUri = null;
if (isAndroidQ) {
photoUri = createImageUri();
} else {
try {
photoFile = createImageFile();
} catch (IOException e) {
e.printStackTrace();
}
}
if (photoFile != null) {
mCameraImagePath = photoFile.getAbsolutePath();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
photoUri = FileProvider.getUriForFile(this, "com.example.audiovisualrecord.provider", photoFile);
} else {
photoUri = Uri.fromFile(photoFile);
}
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() {
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_SIZE_LIMIT, 10996480L); //限制影片大小
if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
}
}
private File createImageFile() throws IOException {
String imageName = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
if (!storageDir.exists()) {
storageDir.mkdir();
}
File tempFile = new File(storageDir, imageName);
if (!Environment.MEDIA_MOUNTED.equals(EnvironmentCompat.getStorageState(tempFile))) {
return null;
}
return tempFile;
}
private void settingSystemCamera(Intent intent) {
PackageManager packageManager = MainActivity.this.getPackageManager();
List<ResolveInfo> listCam = packageManager.queryIntentActivities(intent, 0);
intent.setPackage(listCam.get(0).activityInfo.packageName);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CAPTURE_IMAGE && resultCode == RESULT_OK) {
Bitmap myBitmap = BitmapFactory.decodeFile(mCameraImagePath);
String path1 = Environment.getExternalStorageDirectory().toString() + "/Pictures";
SavaImage(myBitmap, path1);
}
if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) {
//影片的uri
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) {
ArrayList<String> uriList = new ArrayList<String>();
if (data.getClipData() != null) {
for (int i = 0; i < data.getClipData().getItemCount(); i++) {
uriList.add(getPath(data.getClipData().getItemAt(i).getUri()));
// Log.e("gggg", "" + uriList.get(i));
}
} else if (Build.VERSION.SDK_INT >= 16 && data.getClipData() == null) {
uriList.add(getPath(data.getData()));
}
//照片的uri
mPresenter.onGetSid(uriList, getResourceString(R.string.on_upload_image));
}
if (requestCode == PICK_VIDEO_FROM_GALLERY_REQUEST_CODE && resultCode == RESULT_OK) {
ArrayList<String> uriList = new ArrayList<String>();
if (data.getClipData() != null) {
Uri selectedVideo = data.getClipData().getItemAt(0).getUri();
int count = data.getClipData().getItemCount();
//count 選取檔案的數量
for (int i = 0; i < count; i++) {
uriList.add(getPath(data.getClipData().getItemAt(i).getUri()));
filename.add(FileUtil.fileName(getPath(data.getClipData().getItemAt(i).getUri())));
// Log.e("gggg", "" + uriList.get(i));
// Log.e("dddd", "" + filename.get(i));
}
Log.e("aaa", count + "");
} else if (Build.VERSION.SDK_INT >= 16 && data.getClipData() == null) {
uriList.clear();
String path = FileUtil.getFileAbsolutePath(this, data.getData());
String name = FileUtil.fileName(path);
uriList.add(path);
mPresenter.segVideo(path, getResourceString(R.string.on_upload_vedio));
// TODO here====================
//影片的uri
}
}
if (requestCode == PICK_FILE_REQUEST_CODE && resultCode == RESULT_OK) {
Uri selectedFile = data.getData();
String filePath = MagicFileChooser.getAbsolutePathFromUri(this, selectedFile);
// Log.e("filePath", filePath + "");
// Log.e("ggggg", "" + selectedFile);
checkFileTypeAndOpen(filePath, selectedFile);
}
}
//根據副檔名判斷用什麼應用程式開啟
private void checkFileTypeAndOpen(String filePath, Uri selectedFile) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (filePath.contains(".doc")) {
intent.setDataAndType(selectedFile, "application/msword");
} else if (filePath.contains(".ppt")) {
intent.setDataAndType(selectedFile, "application/vnd.ms-powerpoint");
} else if ((filePath.contains(".csv")) || (filePath.contains(".xls"))) {
intent.setDataAndType(selectedFile, "application/vnd.ms-excel");
} else if (filePath.contains(".pdf")) {
intent.setDataAndType(selectedFile, "application/pdf");
} else if (filePath.contains(".txt")) {
intent.setDataAndType(selectedFile, "text/plain");
} else {
intent.setDataAndType(selectedFile, "application/*");
}
PackageManager pm = getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
if (list.size() > 0)
startActivity(intent);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnCaptureImage:
uploadPath = mPresenter.onJudgmentPath(pathCompany, pathFactoryArea, pathFactoryClass, pathClass, pathShootType);
if ("".equals(uploadPath)) {
showDialogCaveatMessage("請選擇路徑");
} else {
openCameraIntent();
}
break;
case R.id.btnGetImageFromGallery:
uploadPath = mPresenter.onJudgmentPath(pathCompany, pathFactoryArea, pathFactoryClass, pathClass, pathShootType);
if ("".equals(uploadPath)) {
showDialogCaveatMessage("請選擇路徑");
} else {
pickImageFromGallery();
}
break;
case R.id.btnGetVideoFromGallery:
uploadPath = mPresenter.onJudgmentPath(pathCompany, pathFactoryArea, pathFactoryClass, pathClass, pathShootType);
if ("".equals(uploadPath)) {
showDialogCaveatMessage("請選擇路徑");
} else {
pickVideoFromGallery();
}
break;
case R.id.btnRecordVideo:
uploadPath = mPresenter.onJudgmentPath(pathCompany, pathFactoryArea, pathFactoryClass, pathClass, pathShootType);
if ("".equals(uploadPath)) {
showDialogCaveatMessage("請選擇路徑");
} else {
openRecordVideoIntent();
}
break;
case R.id.tv_company:
mPresenter.onGetComData();
break;
case R.id.tv_factory:
mPresenter.onGetPZData();
break;
case R.id.tv_unit:
if (mChooseDeviceItemData.getFactoryAreaId().equals("")) {
showDialogCaveatMessage(getResourceString(R.string.add_device_no_maintenance_plant_error));
}
if (mChooseDeviceItemData.getCompanyId().equals("")) {
showDialogCaveatMessage(getResourceString(R.string.add_device_no_company_error));
}
mPresenter.onGetDPData(mChooseDeviceItemData.getCompanyId(), mChooseDeviceItemData.getFactoryAreaId());
break;
case R.id.tv_class:
if (mChooseDeviceItemData.getCompanyId().equals("")) {
showDialogCaveatMessage(getResourceString(R.string.add_device_no_company_error));
}
if (mChooseDeviceItemData.getProductionPlantId().equals("")) {
showDialogCaveatMessage(getResourceString(R.string.add_device_no_production_plant_error));
}
mPresenter.onGetSHIFTData(mChooseDeviceItemData.getCompanyId(), mChooseDeviceItemData.getProductionPlantId());
break;
case R.id.tv_shoottype:
if (mChooseDeviceItemData.getCompanyId().equals("")) {
showDialogCaveatMessage(getResourceString(R.string.add_device_no_company_error));
}
if (mChooseDeviceItemData.getProductionPlantId().equals("")) {
showDialogCaveatMessage(getResourceString(R.string.add_device_no_production_plant_error));
}
mPresenter.onGetTYPEData(mChooseDeviceItemData.getCompanyId(), mChooseDeviceItemData.getProductionPlantId()
);
break;
}
}
@Override
public void setCOData(List<COResponse> adapterData) {
dialogString.clear();
mMainData.setmCODataList(adapterData);
for (COResponse mCoResponse : adapterData) {
dialogString.add(mCoResponse.getcONM());
}
showItemDialog(dialogString, onCompanyDialogItemClick);
}
@Override
public void setPZData(List<PZResponse> adapterData) {
dialogString.clear();
mMainData.setmPZDataList(adapterData);
for (PZResponse mPZResponse : adapterData) {
dialogString.add(mPZResponse.getmPZNM());
}
showItemDialog(dialogString, onFavtoryAreaDialogItemClick);
}
@Override
public void setDPNMData(List<DPResponse> adapterData) {
dialogString.clear();
mMainData.setmDPDataList(adapterData);
for (DPResponse mDPResponse : adapterData) {
dialogString.add(mDPResponse.getmDPNM());
}
showItemDialog(dialogString, onFactoryClassDialogItemClick);
}
@Override
public void setEQKDData(List<SHIFTResponse> adapterData) {
dialogString.clear();
mMainData.setmSHIFTDataList(adapterData);
for (SHIFTResponse mSHIFTResponse : adapterData) {
dialogString.add(mSHIFTResponse.getmShift());
}
showItemDialog(dialogString, onClassUnitDialogItemClick);
}
@Override
public void setTYPEData(List<TYPEResponse> adapterData) {
dialogString.clear();
mMainData.setmTYPEDataList(adapterData);
for (TYPEResponse mTYPEResponse : adapterData) {
dialogString.add(mTYPEResponse.getmType());
}
showItemDialog(dialogString, onShootTypeCategoryDialogItemClick);
}
@Override
protected void onPause() {
super.onPause();
dismissProgressDialog();
}
//如果能改成用retrofit加rxjava最好,已經嘗試過,可能有缺什麼,不過緊急所以先求功能
@Override
public void onUploadFile(final ArrayList<String> uriList, String type, final String sid) {
uploadPath = mPresenter.onJudgmentPath(pathCompany, pathFactoryArea, pathFactoryClass, pathClass, pathShootType);
dismissProgressDialog();
showProgressDialog(type);
new Thread(new Runnable() {
@Override
public void run() {
String path1 = uploadPath;
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.build();
MultipartBody.Builder buildernew = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("_sid", sid)
.addFormDataPart("path", path1);
for (String path : uriList) {
File uploadFile = new File(path);
Log.e("file5555555", uploadFile.length() / 1024 / 1024 + "mb");
buildernew.addFormDataPart("file", uploadFile.getName(),
RequestBody.create(MediaType.parse("application/octet-stream"), uploadFile));
}
RequestBody body = buildernew.build();
Request request = new Request.Builder()
.addHeader("Accept", "*/*")
.url("https://webapp.fpcitc.com.tw/SOP/api/FileUpload/fileUpload")
.method("POST", body)
.build();
try {
Response response = client.newCall(request).execute();
final String responsemessage = response.message();
final String responsebody = response.body().string();
JSONObject json = null;
try {
json = new JSONObject(responsebody);
} catch (JSONException e) {
e.printStackTrace();
}
Log.e("response", responsebody);
// dismissProgressDialog();
if (json.get("success").equals("true")) {
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
dismissProgressDialog();
showDialogMessage("上傳完成");
}
});
} else {
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
dismissProgressDialog();
showDialogMessage("上傳失敗");
}
});
}
// Log.e("isSuccess",json.get("IsSuccess").toString());
mPresenter.onLogoutSid(sidData); //登出sid
} catch (final IOException | JSONException e) {
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
dismissProgressDialog();
e.printStackTrace();
showDialogMessage("上傳失敗");
Log.e("error", "" + e.getMessage());
}
});
}
}
}).start();
}
private DialogInterface.OnClickListener onCompanyDialogItemClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
textCompany.setText(mMainData.getmCODataList().get(which).getcONM());
pathCompany = mMainData.getmCODataList().get(which).getcONM();
mChooseDeviceItemData.setCompany(mMainData.getmCODataList().get(which).getcONM());
mChooseDeviceItemData.setCompanyId(mMainData.getmCODataList().get(which).getcO());
}
};
private DialogInterface.OnClickListener onFavtoryAreaDialogItemClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
textFactory.setText(mMainData.getmPZDataList().get(which).getmPZNM());
pathFactoryArea = mMainData.getmPZDataList().get(which).getmPZNM();
mChooseDeviceItemData.setFactoryAreaName(mMainData.getmPZDataList().get(which).getmPZNM());
mChooseDeviceItemData.setFactoryAreaId(mMainData.getmPZDataList().get(which).getmPZ());
}
};
private DialogInterface.OnClickListener onFactoryClassDialogItemClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
textUnit.setText(mMainData.getmDPDataList().get(which).getmDPNM());
pathFactoryClass = mMainData.getmDPDataList().get(which).getmDPNM();
mChooseDeviceItemData.setFactoryClassCode(mMainData.getmDPDataList().get(which).getmDP());
mChooseDeviceItemData.setFactoryClass(mMainData.getmDPDataList().get(which).getmDPNM());
mChooseDeviceItemData.setProductionPlantId(mMainData.getmDPDataList().get(which).getmPMFCT());
}
};
private DialogInterface.OnClickListener onClassUnitDialogItemClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
textClass.setText(mMainData.getmSHIFTDataList().get(which).getmShift());
pathClass = mMainData.getmSHIFTDataList().get(which).getmShift();
mChooseDeviceItemData.setDeviceCategory(mMainData.getmSHIFTDataList().get(which).getmShift());
}
};
private DialogInterface.OnClickListener onShootTypeCategoryDialogItemClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
textShootType.setText(mMainData.getmTYPEDataList().get(which).getmType());
pathShootType = mMainData.getmTYPEDataList().get(which).getmType();
mChooseDeviceItemData.setShootType(mMainData.getmTYPEDataList().get(which).getmType());
}
};
}
package com.example.audiovisualrecord.ui.main;
import com.example.audiovisualrecord.base.BaseView;
import com.example.audiovisualrecord.utils.api.apidata.searchco.COResponse;
import com.example.audiovisualrecord.utils.api.apidata.searchtype.TYPEResponse;
import com.example.audiovisualrecord.utils.api.searchshift.SHIFTResponse;
import com.example.audiovisualrecord.utils.api.searchpz.PZResponse;
import com.example.audiovisualrecord.utils.api.searchdp.DPResponse;
import java.util.ArrayList;
import java.util.List;
public interface MainContract {
interface View extends BaseView {
void setCOData(List<COResponse> adapterData);
void setPZData(List<PZResponse> adapterData);
void setDPNMData(List<DPResponse> adapterData);
void setEQKDData(List<SHIFTResponse> adapterData);
void setTYPEData(List<TYPEResponse> adapterData);
void onUploadFile(ArrayList<String> uriList, String type,String sid);
}
interface Presenter<V extends MainContract.View> {
void onGetComData();
void onGetPZData();
void onGetDPData(String CO, String PZ);
void onGetSHIFTData(String CO, String PMFCT);
void segVideo(String path,String name);
void onGetTYPEData(String CO,String PMFCT);
void onGetSid(ArrayList<String> uriList, String type);
void onLogoutSid(String sid);
String onJudgmentPath(String pathCompany,String pathFactoryArea,String pathFactoryClass,
String pathClass,String pathShootType);
}
}
\ No newline at end of file
package com.example.audiovisualrecord.ui.main;
import com.example.audiovisualrecord.utils.api.apidata.searchco.COResponse;
import com.example.audiovisualrecord.utils.api.apidata.searchtype.TYPEResponse;
import com.example.audiovisualrecord.utils.api.searchshift.SHIFTResponse;
import com.example.audiovisualrecord.utils.api.searchpz.PZResponse;
import com.example.audiovisualrecord.utils.api.searchdp.DPResponse;
import java.util.List;
public class MainData {
private List<COResponse> mCODataList; //公司代碼
private List<PZResponse> mPZDataList; //廠區代碼
private List<DPResponse> mDPDataList; //廠課代碼
private List<SHIFTResponse> mSHIFTDataList; //班別代碼
private List<TYPEResponse> mTYPEDataList; //錄影類型
private String MSidData;
public List<COResponse> getmCODataList() {
return mCODataList;
}
public List<PZResponse> getmPZDataList() {
return mPZDataList;
}
public void setmPZDataList(List<PZResponse> mPZDataList) {
this.mPZDataList = mPZDataList;
}
public void setmCODataList(List<COResponse> mCODataList) {
this.mCODataList = mCODataList;
}
public List<DPResponse> getmDPDataList() {
return mDPDataList;
}
public void setmDPDataList(List<DPResponse> mDPDataList) {
this.mDPDataList = mDPDataList;
}
public List<SHIFTResponse> getmSHIFTDataList() {
return mSHIFTDataList;
}
public void setmSHIFTDataList(List<SHIFTResponse> mSHIFTDataList) {
this.mSHIFTDataList = mSHIFTDataList;
}
public List<TYPEResponse> getmTYPEDataList() {
return mTYPEDataList;
}
public void setmTYPEDataList(List<TYPEResponse> mTYPEDataList) {
this.mTYPEDataList = mTYPEDataList;
}
public String getMSidData() {
return MSidData;
}
public void setMSidData(String MSidData) {
this.MSidData = MSidData;
}
}
package com.example.audiovisualrecord.ui.main;
import android.os.Environment;
import android.util.Log;
import com.arthenica.mobileffmpeg.Config;
import com.arthenica.mobileffmpeg.FFmpeg;
import com.arthenica.mobileffmpeg.FFprobe;
import com.example.audiovisualrecord.R;
import com.example.audiovisualrecord.utils.api.ApiService;
import com.example.audiovisualrecord.utils.api.HttpMethods;
import com.example.audiovisualrecord.utils.api.apidata.logoutsid.LogoutSidRequest;
import com.example.audiovisualrecord.utils.api.apidata.searchco.CORequest;
import com.example.audiovisualrecord.utils.api.apidata.searchco.COResultList;
import com.example.audiovisualrecord.utils.api.apidata.logoutsid.LogoutSidResponse;
import com.example.audiovisualrecord.utils.api.apidata.searchsid.SIDDataList;
import com.example.audiovisualrecord.utils.api.apidata.searchtype.TYPERequest;
import com.example.audiovisualrecord.utils.api.apidata.searchtype.TYPEResultList;
import com.example.audiovisualrecord.utils.api.searchshift.SHIFTRequest;
import com.example.audiovisualrecord.utils.api.searchshift.SHIFTResultList;
import com.example.audiovisualrecord.utils.api.searchpz.PZRequest;
import com.example.audiovisualrecord.utils.api.searchpz.PZResultList;
import com.example.audiovisualrecord.utils.api.searchdp.DPRequest;
import com.example.audiovisualrecord.utils.api.searchdp.DPResultList;
import com.example.audiovisualrecord.utils.rxjava.SchedulerProviderImp;
import java.io.File;
import java.util.ArrayList;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableObserver;
import static com.arthenica.mobileffmpeg.Config.RETURN_CODE_CANCEL;
import static com.arthenica.mobileffmpeg.Config.RETURN_CODE_SUCCESS;
public class MainPresenter<V extends MainContract.View> implements MainContract.Presenter<V> {
// private String KEY_SEARCH_CO = "6c66fcbd-6dfe-45a2-ad6b-cbcda09b25bd";
private String KEY_SEARCH_CO = "3b0f7c72-5479-46c1-b26d-224748e64d7a";
private String KEY_SEARCH_PZ = "78bc27f8-6c1b-4172-ba61-05798001671b";
private String KEY_SEARCH_DP = "1c76477f-1fb0-49fb-a5bd-e75311bbe691";
private String KEY_SEARCH_SHIFT = "3e161e49-30d5-44ce-bbc4-3bcff49f7c37";
private String KEY_SEARCH_TYPE = "145ce81d-7bae-4848-a38a-e0e738385681";
private String USER_ID = "";
private V view;
private String LOGIN_AUTHORIZED_ID = "acd9be92-46bf-4185-8721-5b60c67f0742";
private ApiService api;
SchedulerProviderImp schedulerProviderImp = new SchedulerProviderImp();
private CompositeDisposable compositeDisposable;
public MainPresenter(V view, String userId) {
this.view = view;
USER_ID = userId;
api = HttpMethods.getInstance().getApi();
compositeDisposable = new CompositeDisposable();
}
@Override
public void onGetComData() {
String url = view.getResourceString(R.string.api_on_getCO);
final CORequest mCORequest = new CORequest(KEY_SEARCH_CO, USER_ID);
compositeDisposable.add(api.getCO(url, mCORequest)
.subscribeOn(schedulerProviderImp.io())
.observeOn(schedulerProviderImp.ui())
.subscribeWith(new DisposableObserver<COResultList>() {
@Override
public void onNext(COResultList mCOResultList) {
view.setCOData(mCOResultList.getcOResponseList());
}
@Override
public void onError(Throwable e) {
view.showDialogCaveatMessage(view.getResourceString(R.string.add_device_error));
}
@Override
public void onComplete() {
}
})
);
}
@Override
public void onGetPZData() {
String url = view.getResourceString(R.string.api_on_getMNTFCT);
PZRequest mPZRequest = new PZRequest(KEY_SEARCH_PZ, USER_ID);
compositeDisposable.add(api.getPZ(url, mPZRequest)
.subscribeOn(schedulerProviderImp.io())
.observeOn(schedulerProviderImp.ui())
.subscribeWith(new DisposableObserver<PZResultList>() {
@Override
public void onNext(PZResultList mPZResultList) {
view.setPZData(mPZResultList.getmNTFCTResponse());
}
@Override
public void onError(Throwable e) {
view.showDialogCaveatMessage(view.getResourceString(R.string.add_device_error));
}
@Override
public void onComplete() {
}
})
);
}
@Override
public void onGetDPData(String CO, String PZ) {
final DPRequest mDPRequest = new DPRequest(KEY_SEARCH_DP, USER_ID, CO, PZ);
String url = view.getResourceString(R.string.api_on_getDP);
compositeDisposable.add(api.getDP(url, mDPRequest)
.subscribeOn(schedulerProviderImp.io())
.observeOn(schedulerProviderImp.ui())
.subscribeWith(new DisposableObserver<DPResultList>() {
@Override
public void onNext(DPResultList mDPResultList) {
if (mDPResultList.getmDPResponseList().size() < 1) {
view.showDialogCaveatMessage(view.getResourceString(R.string.get_pmfct_error_no_data));
} else {
view.setDPNMData(mDPResultList.getmDPResponseList());
}
}
@Override
public void onError(Throwable e) {
view.showDialogCaveatMessage(view.getResourceString(R.string.add_device_error));
}
@Override
public void onComplete() {
}
})
);
}
@Override
public void onGetSHIFTData(String CO, String PMFCT) {
SHIFTRequest mSHIFTRequest = new SHIFTRequest(KEY_SEARCH_SHIFT, USER_ID, CO, PMFCT);
String url = view.getResourceString(R.string.api_on_getSHIFT);
compositeDisposable.add(api.getSHIFT(url, mSHIFTRequest)
.subscribeOn(schedulerProviderImp.io())
.observeOn(schedulerProviderImp.ui())
.subscribeWith(new DisposableObserver<SHIFTResultList>() {
@Override
public void onNext(SHIFTResultList mSHIFTResultList) {
if (mSHIFTResultList.getmSHIFTResponseList().size() < 1) {
view.showDialogCaveatMessage(view.getResourceString(R.string.get_shift_error_no_data));
} else {
view.setEQKDData(mSHIFTResultList.getmSHIFTResponseList());
}
}
@Override
public void onError(Throwable e) {
view.showDialogCaveatMessage(view.getResourceString(R.string.add_device_error));
}
@Override
public void onComplete() {
}
})
);
}
@Override
public void onGetTYPEData(String CO, String PMFCT) {
final TYPERequest mTypeRequest = new TYPERequest(KEY_SEARCH_TYPE, USER_ID, CO, PMFCT);
String url = view.getResourceString(R.string.api_on_getTYPE);
compositeDisposable.add(api.getTYPE(url, mTypeRequest)
.subscribeOn(schedulerProviderImp.io())
.observeOn(schedulerProviderImp.ui())
.subscribeWith(new DisposableObserver<TYPEResultList>() {
@Override
public void onNext(TYPEResultList mTYPEResultList) {
if (mTYPEResultList.getmTYPEResponseList().size() < 1) {
view.showDialogCaveatMessage(view.getResourceString(R.string.get_type_error_no_data));
} else {
view.setTYPEData(mTYPEResultList.getmTYPEResponseList());
}
}
@Override
public void onError(Throwable e) {
view.showDialogCaveatMessage("請重試或檢查網路狀態");
}
@Override
public void onComplete() {
}
})
);
}
@Override
public void onGetSid(final ArrayList<String> uriList, final String type) {
String url = view.getResourceString(R.string.api_on_getSID);
compositeDisposable.add(api.getSID(url)
.subscribeOn(schedulerProviderImp.io())
.observeOn(schedulerProviderImp.ui())
.subscribeWith(new DisposableObserver<SIDDataList>() {
@Override
public void onNext(SIDDataList mSIDDataList) {
view.onUploadFile(uriList, type, mSIDDataList.getsIdDataList().getSid());
// Log.e("sss", mSIDDataList.getSuccess());
}
@Override
public void onError(Throwable e) {
view.showDialogCaveatMessage("請重試或檢查網路狀態");
Log.e("error", e.getMessage());
}
@Override
public void onComplete() {
}
})
);
}
@Override
public void onLogoutSid(String sid) {
String url = "https://webapp.fpcitc.com.tw/SOP/api/FileUpload/PostLogout";
LogoutSidRequest mLogoutSidRequest = new LogoutSidRequest(sid);
compositeDisposable.add(api.onLogoutSid(url, mLogoutSidRequest)
.subscribeOn(schedulerProviderImp.io())
.observeOn(schedulerProviderImp.ui())
.subscribeWith(new DisposableObserver<LogoutSidResponse>() {
@Override
public void onNext(LogoutSidResponse mLogoutSidResponse) {
Log.e("success", mLogoutSidResponse.getSuccess());
}
@Override
public void onError(Throwable e) {
if (e.getMessage().contains("No address associated with hostname")) {
view.showDialogCaveatMessage("請檢查網路狀態");
}
}
@Override
public void onComplete() {
}
}));
}
@Override
public void segVideo(final String path, final String name) {
view.showProgressDialog("影片分割中");
view.showProgressDialog("影片分割中");
view.showProgressDialog("影片分割中");
view.showProgressDialog("影片分割中");
view.showProgressDialog("影片分割中");
view.showProgressDialog("影片分割中");
view.showProgressDialog("影片分割中");
view.showProgressDialog("影片分割中");
view.showProgressDialog("影片分割中");
final ArrayList<String> segVideoList = new ArrayList<>();
new Thread(new Runnable() {
@Override
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 = 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;
}
//開始分割
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");
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.");
} else {
Log.i(Config.TAG, String.format("Command execution failed with rc=%d and the output below.", rc));
Config.printLastCommandOutput(Log.INFO);
}
startTime += segTime;
}
view.dismissProgressDialog();
onGetSid(segVideoList, name);
} else {
//沒超過
segVideoList.add(path);
view.dismissProgressDialog();
onGetSid(segVideoList, name);
}
}
}).start();
}
@Override
public String onJudgmentPath(String pathCompany, String pathFactoryArea, String pathFactoryClass, String pathClass, String pathShootType) {
String path = "";
if ("仁武氯乙烯廠製造一課".equals(pathFactoryClass) && "SOP導讀".equals(pathShootType)) {
path = "/仁武氯乙烯廠製造一課/1_SOP導讀";
} else if ("仁武氯乙烯廠製造一課".equals(pathFactoryClass) && "SOP審視會議".equals(pathShootType)) {
path = "/仁武氯乙烯廠製造一課/2_SOP審視修訂";
} else if ("仁武氯乙烯廠製造一課".equals(pathFactoryClass) && "落實度查核".equals(pathShootType) && "DA".equals(pathClass)) {
path = "/仁武氯乙烯廠製造一課/3_SOP落實度查核/DA";
} else if ("仁武氯乙烯廠製造一課".equals(pathFactoryClass) && "落實度查核".equals(pathShootType) && "DB".equals(pathClass)) {
path = "/仁武氯乙烯廠製造一課/3_SOP落實度查核/DB";
} else if ("仁武氯乙烯廠製造一課".equals(pathFactoryClass) && "落實度查核".equals(pathShootType) && "DC".equals(pathClass)) {
path = "/仁武氯乙烯廠製造一課/3_SOP落實度查核/DC";
} else if ("仁武氯乙烯廠製造一課".equals(pathFactoryClass) && "落實度查核".equals(pathShootType) && "DD".equals(pathClass)) {
path = "/仁武氯乙烯廠製造一課/3_SOP落實度查核/DD";
} else if ("仁武氯乙烯廠製造二課".equals(pathFactoryClass) && "SOP導讀".equals(pathShootType)) {
path = "/仁武氯乙烯廠製造二課/1_SOP導讀";
} else if ("仁武氯乙烯廠製造二課".equals(pathFactoryClass) && "SOP審視會議".equals(pathShootType)) {
path = "/仁武氯乙烯廠製造二課/2_SOP審視修訂";
} else if ("仁武氯乙烯廠製造二課".equals(pathFactoryClass) && "落實度查核".equals(pathShootType) && "DA".equals(pathClass)) {
path = "/仁武氯乙烯廠製造二課/3_SOP落實度查核/DA";
} else if ("仁武氯乙烯廠製造二課".equals(pathFactoryClass) && "落實度查核".equals(pathShootType) && "DB".equals(pathClass)) {
path = "/仁武氯乙烯廠製造二課/3_SOP落實度查核/DB";
} else if ("仁武氯乙烯廠製造二課".equals(pathFactoryClass) && "落實度查核".equals(pathShootType) && "DC".equals(pathClass)) {
path = "/仁武氯乙烯廠製造二課/3_SOP落實度查核/DC";
} else if ("仁武氯乙烯廠製造二課".equals(pathFactoryClass) && "落實度查核".equals(pathShootType) && "DD".equals(pathClass)) {
path = "/仁武氯乙烯廠製造二課/3_SOP落實度查核/DD";
}
return path;
}
}
\ No newline at end of file
package com.example.audiovisualrecord.utils;
import android.content.Context;
import android.widget.Toast;
public class ToastCreator {
private static Toast toast;
public static void makeText(final Context context,
final String text,
final int duration) {
if (toast == null) {
toast = Toast.makeText(context, text, duration);
} else {
toast.setText(text);
toast.setDuration(duration);
}
toast.show();
}
public static void makeText(final Context context,
final int resId,
final int duration) {
String text = context.getResources().getString(resId);
if (toast == null) {
toast = Toast.makeText(context, text, duration);
} else {
toast.setText(text);
toast.setDuration(duration);
}
toast.show();
}
}
package com.example.audiovisualrecord.utils.api;
import com.example.audiovisualrecord.utils.api.apidata.logoutsid.LogoutSidRequest;
import com.example.audiovisualrecord.utils.api.apidata.searchco.CORequest;
import com.example.audiovisualrecord.utils.api.apidata.searchco.COResultList;
import com.example.audiovisualrecord.utils.api.apidata.login.LoginRequest;
import com.example.audiovisualrecord.utils.api.apidata.login.LoginResponse;
import com.example.audiovisualrecord.utils.api.apidata.logoutsid.LogoutSidResponse;
import com.example.audiovisualrecord.utils.api.apidata.searchsid.SIDDataList;
import com.example.audiovisualrecord.utils.api.apidata.searchtype.TYPERequest;
import com.example.audiovisualrecord.utils.api.apidata.searchtype.TYPEResultList;
import com.example.audiovisualrecord.utils.api.searchshift.SHIFTRequest;
import com.example.audiovisualrecord.utils.api.searchshift.SHIFTResultList;
import com.example.audiovisualrecord.utils.api.searchpz.PZRequest;
import com.example.audiovisualrecord.utils.api.searchpz.PZResultList;
import com.example.audiovisualrecord.utils.api.searchdp.DPRequest;
import com.example.audiovisualrecord.utils.api.searchdp.DPResultList;
import io.reactivex.Observable;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Url;
public interface ApiService {
@POST
Observable<COResultList> getCO(@Url String url, @Body CORequest mCORequest);
@POST
Observable<PZResultList> getPZ(@Url String url, @Body PZRequest mPZRequest);
@POST
Observable<DPResultList> getDP(@Url String url, @Body DPRequest mDPRequest);
@POST
Observable<SHIFTResultList> getSHIFT(@Url String url, @Body SHIFTRequest mSHIFTRequest);
@POST
Observable<TYPEResultList>getTYPE(@Url String url, @Body TYPERequest mTypeRequest);
@POST
Observable<LoginResponse> onLogin(@Url String url, @Body LoginRequest mLoginRequest);
@GET
Observable<SIDDataList> getSID(@Url String url);
@POST
Observable<LogoutSidResponse> onLogoutSid(@Url String url , @Body LogoutSidRequest mLogoutSidRequest);
}
package com.example.audiovisualrecord.utils.api;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class DataResponse {
@SerializedName("title")
@Expose
private String titlewefwefew;
@SerializedName("content")
@Expose
private String content;
@SerializedName("poster")
@Expose
private String poster;
@SerializedName("url")
@Expose
private String url;
public String getTitle() {
return titlewefwefew;
}
public void setTitle(String title) {
this.titlewefwefew = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getPoster() {
return poster;
}
public void setPoster(String poster) {
this.poster = poster;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
package com.example.audiovisualrecord.utils.api;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.http.GET;
public interface ErpAPI {
@GET("xiaohua.json")
Observable<List<DataResponse>> getData();
}
package com.example.audiovisualrecord.utils.api;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
public class HttpMethods {
private static final String BASE_URL = "https://cloud.fpcetg.com.tw/FPC/API/MTN/API_MTN/MTN/";
private static final int TIME_OUT=4;
private Retrofit retrofit;
private ApiService apiService;
private HttpMethods() {
/**
* 构造函数私有化
* 并在构造函数中进行retrofit的初始化
*/
OkHttpClient client=new OkHttpClient();
client.newBuilder().connectTimeout(TIME_OUT, TimeUnit.SECONDS);
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
apiService=retrofit.create(ApiService.class);
}
private static class sinalInstance {
public static final HttpMethods instance = new HttpMethods();
}
public static HttpMethods getInstance(){
return sinalInstance.instance;
}
public ApiService getApi(){
return retrofit.create(ApiService.class);
}
}
package com.example.audiovisualrecord.utils.api.apidata.login;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class LoginRequest {
@SerializedName("AuthorizedId")
@Expose
private String authorizedId;
@SerializedName("IdNo")
@Expose
private String mIdNo;
@SerializedName("Password")
@Expose
private String mPassword;
public LoginRequest(String authorizedId, String account, String password) {
this.authorizedId=authorizedId;
this.mIdNo =account;
this.mPassword=password;
}
public String getAuthorizedId() {
return authorizedId;
}
public void setAuthorizedId(String authorizedId) {
this.authorizedId = authorizedId;
}
public String getmIdNo() {
return mIdNo;
}
public void setmIdNo(String mIdNo) {
this.mIdNo = mIdNo;
}
public String getmPassword() {
return mPassword;
}
public void setmPassword(String mPassword) {
this.mPassword = mPassword;
}
}
package com.example.audiovisualrecord.utils.api.apidata.login;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class LoginResponse {
@SerializedName("Result")
@Expose
private String mResult;
@SerializedName("Msg")
@Expose
private String mMsg;
// @SerializedName("Token")
// @Expose
// private String mToken;
// @SerializedName("ErrMsg")
// @Expose
// private String mErrMsg;
public String getmResult() {
return mResult;
}
public void setmResult(String mResult) {
this.mResult = mResult;
}
// public String getmToken() {
// return mToken;
// }
//
// public void setmToken(String mToken) {
// this.mToken = mToken;
// }
//
// public String getmErrMsg() {
// return mErrMsg;
// }
//
// public void setmErrMsg(String mErrMsg) {
// this.mErrMsg = mErrMsg;
// }
public String getmMsg() {
return mMsg;
}
public void setmMsg(String mMsg) {
this.mMsg = mMsg;
}
}
package com.example.audiovisualrecord.utils.api.apidata.logoutsid;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class LogoutSidRequest {
@SerializedName("sid")
@Expose
private String sid;
public LogoutSidRequest(String sid) {
this.sid = sid;
}
public String getSid() {
return sid;
}
public void setSid(String sid) {
this.sid = sid;
}
}
package com.example.audiovisualrecord.utils.api.apidata.logoutsid;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class LogoutSidResponse {
@SerializedName("success")
@Expose
private String success;
public String getSuccess() {
return success;
}
public void setSuccess(String success) {
this.success = success;
}
}
package com.example.audiovisualrecord.utils.api.apidata.searchco;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class CORequest {
@SerializedName("AuthorizedId")
@Expose
private String authorizedId;
@SerializedName("IdNo")
@Expose
private String idNo;
public CORequest(String authorizedId, String idNo) {
this.authorizedId=authorizedId;
this.idNo=idNo;
}
public String getAuthorizedId() {
return authorizedId;
}
public void setAuthorizedId(String authorizedId) {
this.authorizedId = authorizedId;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
}
package com.example.audiovisualrecord.utils.api.apidata.searchco;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class COResponse {
@SerializedName("CO")
@Expose
private String cO;
@SerializedName("CONM")
@Expose
private String cONM;
public String getcO() {
return cO;
}
public void setcO(String cO) {
this.cO = cO;
}
public String getcONM() {
return cONM;
}
public void setcONM(String cONM) {
this.cONM = cONM;
}
}
package com.example.audiovisualrecord.utils.api.apidata.searchco;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class COResultList {
@SerializedName("ResultList")
@Expose
private List<COResponse> cOResponseList;
public List<COResponse> getcOResponseList() {
return cOResponseList;
}
public void setcOResponseList(List<COResponse> cOResponseList) {
this.cOResponseList = cOResponseList;
}
}
package com.example.audiovisualrecord.utils.api.apidata.searchsid;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SIDDataList {
@SerializedName("data")
@Expose
private getSID sIdDataList;
@SerializedName("success")
@Expose
private java.lang.String success;
public getSID getsIdDataList() {
return sIdDataList;
}
public void setsIdDataList(getSID sIdDataList) {
this.sIdDataList = sIdDataList;
}
public java.lang.String getSuccess() {
return success;
}
public void setSuccess(java.lang.String success) {
this.success = success;
}
}
package com.example.audiovisualrecord.utils.api.apidata.searchsid;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class getSID {
@SerializedName("sid")
@Expose
private java.lang.String sid;
public java.lang.String getSid() {
return sid;
}
public void setSid(java.lang.String sid) {
this.sid = sid;
}
}
package com.example.audiovisualrecord.utils.api.apidata.searchtype;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class TYPERequest {
@SerializedName("AuthorizedId")
@Expose
private String authorizedId;
@SerializedName("IdNo")
@Expose
private String idNo;
@SerializedName("CO")
@Expose
private String mCO;
@SerializedName("PMFCT")
@Expose
private String mPMFCT;
public TYPERequest(String authorizedId, String idNo, String mCO, String mPMFCT) {
this.authorizedId=authorizedId;
this.idNo=idNo;
this.mCO=mCO;
this.mPMFCT=mPMFCT;
}
public String getAuthorizedId() {
return authorizedId;
}
public void setAuthorizedId(String authorizedId) {
this.authorizedId = authorizedId;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getmCO() {
return mCO;
}
public void setmCO(String mCO) {
this.mCO = mCO;
}
public String getmPMFCT() {
return mPMFCT;
}
public void setmPMFCT(String mPMFCT) {
this.mPMFCT = mPMFCT;
}
}
package com.example.audiovisualrecord.utils.api.apidata.searchtype;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class TYPEResponse {
@SerializedName("Type")
@Expose
private String mType;
public String getmType() {
return mType;
}
public void setmType(String mType) {
this.mType = mType;
}
}
package com.example.audiovisualrecord.utils.api.apidata.searchtype;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class TYPEResultList {
@SerializedName("ResultList")
@Expose
private List<TYPEResponse> mTYPEResponseList;
public List<TYPEResponse> getmTYPEResponseList() {
return mTYPEResponseList;
}
public void setmTYPEResponseList(List<TYPEResponse> mTYPEResponseList) {
this.mTYPEResponseList = mTYPEResponseList;
}
}
package com.example.audiovisualrecord.utils.api.searchdp;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class DPRequest {
@SerializedName("AuthorizedId")
@Expose
private String authorizedId;
@SerializedName("IdNo")
@Expose
private String idNo;
@SerializedName("CO")
@Expose
private String mCO;
@SerializedName("PZ")
@Expose
private String mPZ;
public DPRequest(String authorizedId, String idNo, String mCO, String mPZ) {
this.authorizedId=authorizedId;
this.idNo=idNo;
this.mCO = mCO;
this.mPZ = mPZ;
}
public String getAuthorizedId() {
return authorizedId;
}
public void setAuthorizedId(String authorizedId) {
this.authorizedId = authorizedId;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getmCO() {
return mCO;
}
public void setmCO(String mCO) {
this.mCO = mCO;
}
public String getmPZ() {
return mPZ;
}
public void setmPZ(String mPZ) {
this.mPZ = mPZ;
}
}
package com.example.audiovisualrecord.utils.api.searchdp;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class DPResponse {
@SerializedName("CO")
@Expose
private String mCO;
@SerializedName("PZ")
@Expose
private String mPZ;
@SerializedName("PMFCT")
@Expose
private String mPMFCT;
@SerializedName("DP")
@Expose
private String mDP;
@SerializedName("DPNM")
@Expose
private String mDPNM;
public String getmPZ() {
return mPZ;
}
public void setmPZ(String mPZ) {
this.mPZ = mPZ;
}
public String getmDP() {
return mDP;
}
public void setmDP(String mDP) {
this.mDP = mDP;
}
public String getmCO() {
return mCO;
}
public void setmCO(String mCO) {
this.mCO = mCO;
}
public String getmPMFCT() {
return mPMFCT;
}
public void setmPMFCT(String mPMFCT) {
this.mPMFCT = mPMFCT;
}
public String getmDPNM() {
return mDPNM;
}
public void setmDPNM(String mDPNM) {
this.mDPNM = mDPNM;
}
}
package com.example.audiovisualrecord.utils.api.searchdp;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class DPResultList {
@SerializedName("ResultList")
@Expose
private List<DPResponse> mDPResponseList;
public List<DPResponse> getmDPResponseList() {
return mDPResponseList;
}
public void setmDPResponseList(List<DPResponse> mDPResponseList) {
this.mDPResponseList = mDPResponseList;
}
}
package com.example.audiovisualrecord.utils.api.searchpz;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class PZRequest {
@SerializedName("AuthorizedId")
@Expose
private String authorizedId;
@SerializedName("IdNo")
@Expose
private String idNo;
public PZRequest(String authorizedId, String idNo) {
this.authorizedId=authorizedId;
this.idNo=idNo;
}
public String getAuthorizedId() {
return authorizedId;
}
public void setAuthorizedId(String authorizedId) {
this.authorizedId = authorizedId;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
}
package com.example.audiovisualrecord.utils.api.searchpz;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class PZResponse {
@SerializedName("PZ")
@Expose
private String mPZ;
@SerializedName("PZNM")
@Expose
private String mPZNM;
public String getmPZ() {
return mPZ;
}
public void setmPZ(String mPZ) {
this.mPZ = mPZ;
}
public String getmPZNM() {
return mPZNM;
}
public void setmPZNM(String mPZNM) {
this.mPZNM = mPZNM;
}
}
package com.example.audiovisualrecord.utils.api.searchpz;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class PZResultList {
@SerializedName("ResultList")
@Expose
private List<PZResponse> mNTFCTResponse;
public List<PZResponse> getmNTFCTResponse() {
return mNTFCTResponse;
}
public void setmNTFCTResponse(List<PZResponse> mNTFCTResponse) {
this.mNTFCTResponse = mNTFCTResponse;
}
}
package com.example.audiovisualrecord.utils.api.searchshift;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SHIFTRequest {
@SerializedName("AuthorizedId")
@Expose
private String authorizedId;
@SerializedName("IdNo")
@Expose
private String idNo;
@SerializedName("CO")
@Expose
private String mCO;
@SerializedName("PMFCT")
@Expose
private String mPMFCT;
public SHIFTRequest(String authorizedId, String idNo, String mCO, String mPMFCT) {
this.authorizedId=authorizedId;
this.idNo=idNo;
this.mCO=mCO;
this.mPMFCT=mPMFCT;
}
public String getAuthorizedId() {
return authorizedId;
}
public void setAuthorizedId(String authorizedId) {
this.authorizedId = authorizedId;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getmCO() {
return mCO;
}
public void setmCO(String mCO) {
this.mCO = mCO;
}
public String getmPMFCT() {
return mPMFCT;
}
public void setmPMFCT(String mPMFCT) {
this.mPMFCT = mPMFCT;
}
}
package com.example.audiovisualrecord.utils.api.searchshift;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SHIFTResponse {
@SerializedName("Shift")
@Expose
private String mShift;
public String getmShift() {
return mShift;
}
public void setmShift(String mShift) {
this.mShift = mShift;
}
}
package com.example.audiovisualrecord.utils.api.searchshift;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class SHIFTResultList {
@SerializedName("ResultList")
@Expose
private List<SHIFTResponse> mSHIFTResponseList;
public List<SHIFTResponse> getmSHIFTResponseList() {
return mSHIFTResponseList;
}
public void setmSHIFTResponseList(List<SHIFTResponse> mSHIFTResponseList) {
this.mSHIFTResponseList = mSHIFTResponseList;
}
}
package com.example.audiovisualrecord.utils.rxjava;
import io.reactivex.Scheduler;
/**
* Created by 5*N on 2017/12/31
*/
public interface SchedulerProvider {
Scheduler ui();
Scheduler computation();
Scheduler io();
Scheduler newThread();
}
package com.example.audiovisualrecord.utils.rxjava;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by 5*N on 2017/12/31
*/
public class SchedulerProviderImp implements SchedulerProvider {
public SchedulerProviderImp() {
}
@Override
public Scheduler ui() {
return AndroidSchedulers.mainThread();
}
@Override
public Scheduler computation() {
return Schedulers.computation();
}
@Override
public Scheduler io() {
return Schedulers.io();
}
@Override
public Scheduler newThread() {
return Schedulers.newThread();
}
}
package com.example.audiovisualrecord.utils.sharepreferences;
import android.content.Context;
/**
* Created by 5*N on 2018/1/1.
*/
public class LoginPreferences extends PreferencesHelper implements LoginPreferencesProvider {
private final String SP_FiLE_NAME = LoginPreferences.class.getName();
private final String PERSON_ID = "PERSON_ID";
private final String PERSON_NAME = "PERSON_NAME";
private final String FACTORY_NUMBER="FACTORY_NUMBER";
private final String PERSON_PASSWORD="PERSON_PASSWORD";
private final String TOKEN="TOKEN";
public LoginPreferences(Context context) {
super(context);
}
@Override
public String getClassName() {
return SP_FiLE_NAME;
}
@Override
public void setPersonPassword(String mPassword) {
save(Type.STRING, PERSON_PASSWORD, mPassword);
}
@Override
public void setToken(String token) {
save(Type.STRING, TOKEN, token);
}
@Override
public void setPersonId(String mPersonId) {
save(Type.STRING, PERSON_ID, mPersonId);
}
@Override
public void setPersonName(String mName) {
save(Type.STRING, PERSON_NAME, mName);
}
@Override
public void setFactoryNumber(String mNumber) {
save(Type.STRING, FACTORY_NUMBER, mNumber);
}
@Override
public String getPersonId() {
return (String) get(Type.STRING, PERSON_ID);
}
@Override
public String getPersonName() {
return (String) get(Type.STRING, PERSON_NAME);
}
@Override
public String getFactoryNumber() {
return (String) get(Type.STRING, FACTORY_NUMBER);
}
@Override
public String getPersonPassword() {
return (String) get(Type.STRING, PERSON_PASSWORD); }
@Override
public String getToken() {
return (String) get(Type.STRING, TOKEN); }
}
package com.example.audiovisualrecord.utils.sharepreferences;
/**
* Created by 5*N on 2018/1/1.
*/
public interface LoginPreferencesProvider {
void setPersonPassword(String mPassword);
void setToken(String token);
void setPersonId(String mPersonId);
void setPersonName(String mName);
void setFactoryNumber(String mNumber);
String getPersonId();
String getPersonName();
String getFactoryNumber();
String getPersonPassword();
String getToken();
}
package com.example.audiovisualrecord.utils.sharepreferences;
import android.content.Context;
import android.content.SharedPreferences;
import java.util.HashSet;
/**
* Created by ameng on 2016/6/20.
*/
public abstract class PreferencesHelper {
private Context context;
public PreferencesHelper(Context context) {
this.context = context;
}
public abstract String getClassName();
public Context getContext() {
return context;
}
public void save(Type type, String key, Object vale) {
SharedPreferences store = context.getSharedPreferences(getClassName(), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = store.edit();
if (type == Type.STRING) {
editor.putString(key, (String) vale);
} else if (type == Type.FLOAT) {
editor.putFloat(key, (Float) vale);
} else if (type == Type.INT) {
editor.putInt(key, (Integer) vale);
} else if (type == Type.LONG) {
editor.putLong(key, (Long) vale);
} else if (type == type.BOOLEAN) {
editor.putBoolean(key, (Boolean) vale);
} else if (type == type.STRING_SET) {
editor.putStringSet(key, (HashSet<String>) vale);
} else {
throw new RuntimeException("Must use base type(String, Float, Double, Integer, Long), type from input is " + type.getClass().getName() + ".");
}
editor.commit();
}
public Object get(Type type, String key) {
SharedPreferences store = context.getSharedPreferences(getClassName(), Context.MODE_PRIVATE);
if (type == Type.STRING) {
return store.getString(String.valueOf(key), "");
} else if (type == Type.FLOAT) {
return store.getFloat(String.valueOf(key), 0);
} else if (type == Type.DOUBLE) {
return Double.valueOf(store.getString(String.valueOf(key), String.valueOf(0.0)));
} else if (type == Type.INT) {
return store.getInt(String.valueOf(key), 0);
} else if (type == Type.LONG) {
return store.getLong(String.valueOf(key), 0);
} else if (type == type.BOOLEAN) {
return store.getBoolean(key, false);
} else if (type == type.STRING_SET) {
return store.getStringSet(key, new HashSet<String>());
} else {
throw new RuntimeException("Must use base type(String, Float, Double, Integer, Long), type from input is " + type.getClass().getName() + ".");
}
}
public static class Type {
public static final Type STRING = new Type();
public static final Type FLOAT = new Type();
public static final Type DOUBLE = new Type();
public static final Type INT = new Type();
public static final Type LONG = new Type();
public static final Type BOOLEAN = new Type();
public static final Type STRING_SET = new Type();
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/greenhulk"/>
<stroke
android:width="5.0dip"
android:color="@color/linearlayoutFrame" />
</shape>
\ No newline at end of file
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/grey" />
</shape>
\ No newline at end of file
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="2dp"
android:color="@android:color/black" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:id="@+id/mConstrainLayout"
>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.12" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.20" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.28" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.36" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.44" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_78"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.78" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_vertical_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.05" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_vertical_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.1" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_vertical_40"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.4" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_vertical_45"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.45" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_vertical_90"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.9" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_vertical_95"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.95" />
<!-- 選擇區域 -->
<TextView
android:id="@+id/tv_company"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/p2_conpany"
app:layout_constraintHeight_percent="0.07"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_10"
app:layout_constraintTop_toBottomOf="@+id/guide_line_horizontal_12"
app:layout_constraintWidth_percent="0.84" />
<TextView
android:id="@+id/text_company"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="@id/tv_company"
app:layout_constraintHeight_percent="0.05"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_40"
app:layout_constraintTop_toTopOf="@id/tv_company"
app:layout_constraintWidth_percent="0.45" />
<TextView
android:id="@+id/tv_factory"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/p2_factory"
app:layout_constraintHeight_percent="0.07"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_10"
app:layout_constraintTop_toBottomOf="@+id/guide_line_horizontal_20"
app:layout_constraintWidth_percent="0.84" />
<TextView
android:id="@+id/text_factory"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="@id/tv_factory"
app:layout_constraintHeight_percent="0.05"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_40"
app:layout_constraintTop_toTopOf="@+id/tv_factory"
app:layout_constraintWidth_percent="0.45" />
<TextView
android:id="@+id/tv_unit"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/p2_unit"
app:layout_constraintHeight_percent="0.07"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_10"
app:layout_constraintTop_toBottomOf="@+id/guide_line_horizontal_28"
app:layout_constraintWidth_percent="0.84" />
<TextView
android:id="@+id/text_unit"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="@id/tv_unit"
app:layout_constraintHeight_percent="0.05"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_40"
app:layout_constraintTop_toTopOf="@+id/tv_unit"
app:layout_constraintWidth_percent="0.46" />
<TextView
android:id="@+id/tv_class"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/p2_class"
android:gravity="center_horizontal"
app:layout_constraintHeight_percent="0.07"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_10"
app:layout_constraintTop_toBottomOf="@+id/guide_line_horizontal_36"
app:layout_constraintWidth_percent="0.84" />
<TextView
android:id="@+id/text_class"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="@id/tv_class"
app:layout_constraintHeight_percent="0.05"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_40"
app:layout_constraintTop_toTopOf="@+id/tv_class"
app:layout_constraintWidth_percent="0.45" />
<TextView
android:id="@+id/tv_shoottype"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/p2_shoottype"
app:layout_constraintHeight_percent="0.07"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_10"
app:layout_constraintTop_toBottomOf="@+id/guide_line_horizontal_44"
app:layout_constraintWidth_percent="0.84" />
<TextView
android:id="@+id/text_shoottype"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="@id/tv_shoottype"
app:layout_constraintHeight_percent="0.05"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_40"
app:layout_constraintTop_toTopOf="@+id/tv_shoottype"
app:layout_constraintWidth_percent="0.45" />
<!-- 建立現場資料 -->
<View
android:id="@+id/view_create_live_data"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_create_field_data"
app:layout_constraintEnd_toStartOf="@id/guide_line_vertical_95"
app:layout_constraintHeight_percent="0.17"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_5"
app:layout_constraintTop_toBottomOf="@id/guide_line_horizontal_55" />
<TextView
android:id="@+id/text_create"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/create"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="23sp"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintStart_toStartOf="@id/view_create_live_data"
app:layout_constraintEnd_toEndOf="@id/view_create_live_data"
app:layout_constraintTop_toTopOf="@id/view_create_live_data"
app:layout_constraintBottom_toTopOf="@id/text_live_data"/>
<TextView
android:id="@+id/text_live_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/live_data"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="23sp"
app:layout_constraintTop_toBottomOf="@id/text_create"
app:layout_constraintStart_toStartOf="@id/view_create_live_data"
app:layout_constraintEnd_toEndOf="@id/view_create_live_data"
app:layout_constraintBottom_toBottomOf="@id/view_create_live_data"/>
<Button
android:id="@+id/btnCaptureImage"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_photo_button"
app:layout_constraintBottom_toBottomOf="@id/view_create_live_data"
app:layout_constraintHeight_percent="0.12"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_10"
app:layout_constraintTop_toTopOf="@id/view_create_live_data"
app:layout_constraintWidth_percent="0.2" />
<Button
android:id="@+id/btnRecordVideo"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_record_button"
app:layout_constraintBottom_toBottomOf="@id/view_create_live_data"
app:layout_constraintEnd_toStartOf="@id/guide_line_vertical_90"
app:layout_constraintHeight_percent="0.12"
app:layout_constraintTop_toTopOf="@id/view_create_live_data"
app:layout_constraintWidth_percent="0.2" />
<!-- 資料上傳 -->
<View
android:id="@+id/view_data_upload"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_data_upload"
app:layout_constraintEnd_toStartOf="@id/guide_line_vertical_95"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_5"
app:layout_constraintTop_toBottomOf="@id/guide_line_horizontal_78" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/data_upload"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="23sp"
app:layout_constraintTop_toTopOf="@id/view_data_upload"
app:layout_constraintBottom_toBottomOf="@id/view_data_upload"
app:layout_constraintStart_toStartOf="@id/view_data_upload"
app:layout_constraintEnd_toEndOf="@id/view_data_upload"/>
<Button
android:id="@+id/btnGetImageFromGallery"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_upload_photo_button"
app:layout_constraintBottom_toBottomOf="@id/view_data_upload"
app:layout_constraintHeight_percent="0.12"
app:layout_constraintStart_toEndOf="@id/guide_line_vertical_10"
app:layout_constraintTop_toTopOf="@id/view_data_upload"
app:layout_constraintWidth_percent="0.2" />
<Button
android:id="@+id/btnGetVideoFromGallery"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_upload_video_button"
app:layout_constraintBottom_toBottomOf="@id/view_data_upload"
app:layout_constraintEnd_toStartOf="@id/guide_line_vertical_90"
app:layout_constraintHeight_percent="0.12"
app:layout_constraintTop_toTopOf="@id/view_data_upload"
app:layout_constraintVertical_bias="0.509"
app:layout_constraintWidth_percent="0.2" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_login">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.12"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_45"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.45"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_56"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.56"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_line_horizontal_68"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.68"/>
<EditText
android:id="@+id/edit_account"
android:layout_width="0dp"
android:layout_height="0dp"
android:hint="@string/login_account_hint"
android:textColorHint="@color/white"
android:paddingStart="100dp"
android:text="N000158385"
app:layout_constraintWidth_percent="0.9"
app:layout_constraintHeight_percent="0.08"
android:background="@drawable/bg_login_account"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/guide_line_horizontal_45"
android:paddingLeft="100dp" />
<EditText
android:id="@+id/edit_password"
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:inputType="textPassword"
android:background="@drawable/bg_login_password"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintWidth_percent="0.9"
app:layout_constraintHeight_percent="0.08"
app:layout_constraintTop_toBottomOf="@id/guide_line_horizontal_56"
android:paddingLeft="100dp" />
<Button
android:id="@+id/btn_login"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintWidth_percent="0.3"
app:layout_constraintHeight_percent="0.16"
app:layout_constraintTop_toBottomOf="@id/guide_line_horizontal_68"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@drawable/bg_login_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="white">#ffffff</color><!--白色 -->
<color name="ivory">#fffff0</color><!--象牙色 -->
<color name="lightyellow">#ffffe0</color><!--亮黄色 -->
<color name="yellow">#ffff00</color><!--黄色 -->
<color name="snow">#fffafa</color><!--雪白色 -->
<color name="floralwhite">#fffaf0</color><!--花白色 -->
<color name="lemonchiffon">#fffacd</color><!--柠檬绸色 -->
<color name="cornsilk">#fff8dc</color><!--米绸色 -->
<color name="seaShell">#fff5ee</color><!--海贝色 -->
<color name="lavenderblush">#fff0f5</color><!--淡紫红 -->
<color name="papayawhip">#ffefd5</color><!--番木色 -->
<color name="blanchedalmond">#ffebcd</color><!--白杏色 -->
<color name="mistyrose">#ffe4e1</color><!--浅玫瑰色 -->
<color name="bisque">#ffe4c4</color><!--桔黄色 -->
<color name="moccasin">#ffe4b5</color><!--鹿皮色 -->
<color name="navajowhite">#ffdead</color><!--纳瓦白 -->
<color name="peachpuff">#ffdab9</color><!--桃色 -->
<color name="gold">#ffd700</color><!--金色 -->
<color name="pink">#ffc0cb</color><!--粉红色 -->
<color name="lightpink">#ffb6c1</color><!--亮粉红色 -->
<color name="orange">#ffa500</color><!--橙色 -->
<color name="lightsalmon">#ffa07a</color><!--亮肉色 -->
<color name="darkorange">#ff8c00</color><!--暗桔黄色 -->
<color name="coral">#ff7f50</color><!--珊瑚色 -->
<color name="hotpink">#ff69b4</color><!--热粉红色 -->
<color name="tomato">#ff6347</color><!--西红柿色 -->
<color name="orangered">#ff4500</color><!--红橙色 -->
<color name="deeppink">#ff1493</color><!--深粉红色 -->
<color name="fuchsia">#ff00ff</color><!--紫红色 -->
<color name="magenta">#ff00ff</color><!--红紫色 -->
<color name="red">#ff0000</color><!--红色 -->
<color name="oldlace">#fdf5e6</color><!--老花色 -->
<color name="lightgoldenrodyellow">#fafad2</color><!--亮金黄色 -->
<color name="linen">#faf0e6</color><!--亚麻色 -->
<color name="antiquewhite">#faebd7</color><!--古董白 -->
<color name="salmon">#fa8072</color><!--鲜肉色 -->
<color name="ghostwhite">#f8f8ff</color><!--幽灵白 -->
<color name="mintcream">#f5fffa</color><!--薄荷色 -->
<color name="whitesmoke">#f5f5f5</color><!--烟白色 -->
<color name="beige">#f5f5dc</color><!--米色 -->
<color name="wheat">#f5deb3</color><!--浅黄色 -->
<color name="sandybrown">#f4a460</color><!--沙褐色 -->
<color name="azure">#f0ffff</color><!--天蓝色 -->
<color name="honeydew">#f0fff0</color><!--蜜色 -->
<color name="aliceblue">#f0f8ff</color><!--艾利斯兰 -->
<color name="khaki">#f0e68c</color><!--黄褐色 -->
<color name="lightcoral">#f08080</color><!--亮珊瑚色 -->
<color name="palegoldenrod">#eee8aa</color><!--苍麒麟色 -->
<color name="violet">#ee82ee</color><!--紫罗兰色 -->
<color name="darksalmon">#e9967a</color><!--暗肉色 -->
<color name="lavender">#e6e6fa</color><!--淡紫色 -->
<color name="lightcyan">#e0ffff</color><!--亮青色 -->
<color name="burlywood">#deb887</color><!--实木色 -->
<color name="plum">#dda0dd</color><!--洋李色 -->
<color name="gainsboro">#dcdcdc</color><!--淡灰色 -->
<color name="crimson">#dc143c</color><!--暗深红色 -->
<color name="palevioletred">#db7093</color><!--苍紫罗兰色 -->
<color name="goldenrod">#daa520</color><!--金麒麟色 -->
<color name="orchid">#da70d6</color><!--淡紫色 -->
<color name="thistle">#d8bfd8</color><!--蓟色 -->
<color name="lightgray">#d3d3d3</color><!--亮灰色 -->
<color name="lightgrey">#d3d3d3</color><!--亮灰色 -->
<color name="tan">#d2b48c</color><!--茶色 -->
<color name="chocolate">#d2691e</color><!--巧可力色 -->
<color name="peru">#cd853f</color><!--秘鲁色 -->
<color name="indianred">#cd5c5c</color><!--印第安红 -->
<color name="mediumvioletred">#c71585</color><!--中紫罗兰色 -->
<color name="silver">#c0c0c0</color><!--银色 -->
<color name="darkkhaki">#bdb76b</color><!--暗黄褐色 -->
<color name="rosybrown">#bc8f8f</color><!--褐玫瑰红 -->
<color name="mediumorchid">#ba55d3</color><!--中粉紫色 -->
<color name="darkgoldenrod">#b8860b</color><!--暗金黄色 -->
<color name="firebrick">#b22222</color><!--火砖色 -->
<color name="powderblue">#b0e0e6</color><!--粉蓝色 -->
<color name="lightsteelblue">#b0c4de</color><!--亮钢兰色 -->
<color name="paleturquoise">#afeeee</color><!--苍宝石绿 -->
<color name="greenyellow">#adff2f</color><!--黄绿色 -->
<color name="lightblue">#add8e6</color><!--亮蓝色 -->
<color name="darkgray">#a9a9a9</color><!--暗灰色 -->
<color name="darkgrey">#a9a9a9</color><!--暗灰色 -->
<color name="brown">#a52a2a</color><!--褐色 -->
<color name="sienna">#a0522d</color><!--赭色 -->
<color name="darkorchid">#9932cc</color><!--暗紫色 -->
<color name="palegreen">#98fb98</color><!--苍绿色 -->
<color name="darkviolet">#9400d3</color><!--暗紫罗兰色 -->
<color name="mediumpurple">#9370db</color><!--中紫色 -->
<color name="lightgreen">#90ee90</color><!--亮绿色 -->
<color name="darkseagreen">#8fbc8f</color><!--暗海兰色 -->
<color name="saddlebrown">#8b4513</color><!--重褐色 -->
<color name="darkmagenta">#8b008b</color><!--暗洋红 -->
<color name="darkred">#8b0000</color><!--暗红色 -->
<color name="blueviolet">#8a2be2</color><!--紫罗兰蓝色 -->
<color name="lightskyblue">#87cefa</color><!--亮天蓝色 -->
<color name="skyblue">#87ceeb</color><!--天蓝色 -->
<color name="gray">#808080</color><!--灰色 -->
<color name="grey">#808080</color><!--灰色 -->
<color name="olive">#808000</color><!--橄榄色 -->
<color name="purple">#800080</color><!--紫色 -->
<color name="maroon">#800000</color><!--粟色 -->
<color name="aquamarine">#7fffd4</color><!--碧绿色 -->
<color name="chartreuse">#7fff00</color><!--黄绿色 -->
<color name="lawngreen">#7cfc00</color><!--草绿色 -->
<color name="mediumslateblue">#7b68ee</color><!--中暗蓝色 -->
<color name="lightslategray">#778899</color><!--亮蓝灰 -->
<color name="lightslategrey">#778899</color><!--亮蓝灰 -->
<color name="slategray">#708090</color><!--灰石色 -->
<color name="slategrey">#708090</color><!--灰石色 -->
<color name="olivedrab">#6b8e23</color><!--深绿褐色 -->
<color name="slateblue">#6a5acd</color><!--石蓝色 -->
<color name="dimgray">#696969</color><!--暗灰色 -->
<color name="dimgrey">#696969</color><!--暗灰色 -->
<color name="mediumaquamarine">#66cdaa</color><!--中绿色 -->
<color name="cornflowerblue">#6495ed</color><!--菊兰色 -->
<color name="cadetblue">#5f9ea0</color><!--军兰色 -->
<color name="darkolivegreen">#556b2f</color><!--暗橄榄绿 -->
<color name="indigo">#4b0082</color><!--靛青色 -->
<color name="mediumturquoise">#48d1cc</color><!--中绿宝石 -->
<color name="darkslateblue">#483d8b</color><!--暗灰蓝色 -->
<color name="steelblue">#4682b4</color><!--钢兰色 -->
<color name="royalblue">#4169e1</color><!--皇家蓝 -->
<color name="turquoise">#40e0d0</color><!--青绿色 -->
<color name="mediumseagreen">#3cb371</color><!--中海蓝 -->
<color name="limegreen">#32cd32</color><!--橙绿色 -->
<color name="darkslategray">#2f4f4f</color><!--暗瓦灰色 -->
<color name="darkslategrey">#2f4f4f</color><!--暗瓦灰色 -->
<color name="seagreen">#2e8b57</color><!--海绿色 -->
<color name="forestgreen">#228b22</color><!--森林绿 -->
<color name="lightseagreen">#20b2aa</color><!--亮海蓝色 -->
<color name="dodgerblue">#1e90ff</color><!--闪兰色 -->
<color name="midnightblue">#191970</color><!--中灰兰色 -->
<color name="aqua">#00ffff</color><!--浅绿色 -->
<color name="cyan">#00ffff</color><!--青色 -->
<color name="springgreen">#00ff7f</color><!--春绿色 -->
<color name="lime">#00ff00</color><!--酸橙色 -->
<color name="mediumspringgreen">#00fa9a</color><!--中春绿色 -->
<color name="darkturquoise">#00ced1</color><!--暗宝石绿 -->
<color name="deepskyblue">#00bfff</color><!--深天蓝色 -->
<color name="darkcyan">#008b8b</color><!--暗青色 -->
<color name="teal">#008080</color><!--水鸭色 -->
<color name="green">#008000</color><!--绿色 -->
<color name="darkgreen">#006400</color><!--暗绿色 -->
<color name="blue">#0000ff</color><!--蓝色 -->
<color name="mediumblue">#0000cd</color><!--中兰色 -->
<color name="darkblue">#00008b</color><!--暗蓝色 -->
<color name="navy">#000080</color><!--海军色 -->
<color name="black">#000000</color><!--黑色 -->
<color name="greenhulk">#FFCBA0</color>
<color name="titleblue">#4472C4</color>
<color name="linearlayoutFrame">#2F528F</color>
</resources>
<resources>
<string name="app_name">影音紀錄APP</string>
<string name="select_file">設備文件檢視</string>
<string name="login_account">帳號</string>
<string name="login_password">密碼</string>
<string name="login_btn_login">登入</string>
<string name="login_account_hint">請輸入帳號</string>
<string name="login_password_hint">請輸入密碼</string>
<string name="open_camera_for_capture">拍照</string>
<string name="open_camera_for_video">錄影</string>
<string name="updata_video">錄影上傳</string>
<string name="updata_picture">拍照上傳</string>
<string name="device">設備ID:</string>
<string name="fetch">擷取</string>
<string name="device_company">&#160;&#160;&#160;&#160;&#160;&#160;&#160;司:&#160;</string>
<string name="job_site">作業廠處:&#160;</string>
<string name="production_plant">&#160;&#160;廠:&#160;</string>
<string name="route_code">路線代號:&#160;</string>
<string name="route_name">路線名稱:&#160;</string>
<string name="device_category">設備類別:&#160;</string>
<string name="device_number">設備編號:&#160;</string>
<string name="device_name">設備名稱:&#160;</string>
<string name="create">建立</string>
<string name="live_data">現場資料</string>
<string name="data_upload">資料上傳</string>
<string name="record_date">紀錄日期:&#160;</string>
<string name="maintenance_plant">&#160;&#160;廠:&#160;</string>
<string name="file">&#160;&#160;&#160;&#160;&#160;&#160;&#160;案:&#160;</string>
<string name="browse">瀏覽</string>
<string name="upload">上傳</string>
<string name="upload_person">上傳人員:&#160;</string>
<string name="on_upload_image">照片上傳中</string>
<string name="on_upload_vedio">影片上傳中</string>
<!--chooseDevice部分-->
<string name="add_device_error_on_choose_device_activity">新增失敗</string>
<!--api使用部分-->
<string name="api_base_url">https://cloud.fpcetg.com.tw/FPC/API/MTN/API_MTN/MTN/</string>
<string name="api_erp_url">http://api.laifudao.com/open/</string>
<string name="api_on_getCO">https://cloud.fpcetg.com.tw/FPC/API/FM/SopRecord_API/INFO/SearchCO</string>
<string name="api_on_getMNTFCT">https://cloud.fpcetg.com.tw/FPC/API/FM/SopRecord_API/INFO/SearchPZ</string>
<string name="api_on_getDP">https://cloud.fpcetg.com.tw/FPC/API/FM/SopRecord_API/INFO/SearchDP</string>
<string name="api_on_getSHIFT">https://cloud.fpcetg.com.tw/FPC/API/FM/SopRecord_API/INFO/SearchSHIFT</string>
<string name="api_on_getTYPE">https://cloud.fpcetg.com.tw/FPC/API/FM/SopRecord_API/INFO/SearchTYPE</string>
<string name="api_on_getEQNO">SearchEQNO</string>
<string name="api_on_Login">https://cloud.fpcetg.com.tw/FPC/API/FM/SopRecord_API/INFO/Access</string>
<string name="api_on_DisposableToken">DisposableToken</string>
<string name="api_on_getSID">https://webapp.fpcitc.com.tw/SOP/api/FileUpload/GetLogin</string>
<!--addDevice部分-->
<string name="get_pmfct_error_no_data">廠課無資料</string>
<string name="get_shift_error_no_data">班別查無資料</string>
<string name="get_type_error_no_data">錄影類型查無資料</string>
<string name="get_eqno_error_no_data">設備編號查無資料</string>
<string name="add_device_no_maintenance_plant_error">請選擇廠區</string>
<string name="add_device_no_company_error">請選擇公司</string>
<string name="add_device_no_production_plant_error">請選擇廠課</string>
<string name="add_device_no_device_categry_error">請選擇設備類別</string>
<string name="add_device_no_data_maintenance_plant">保養廠還未填寫</string>
<string name="add_device_no_data_company">公司還未填寫</string>
<string name="add_device_no_data_production_plant">生產廠還未填寫</string>
<string name="add_device_no_data_device_categry">設備類別還未填寫</string>
<string name="add_device_no_data_device_id">設備編號還未填寫</string>
<string name="add_device_no_data_keynote">主旨說明還未填寫</string>
<string name="add_device_no_data_file">檔案還未選擇</string>
<string name="add_device_error">查詢資料失敗,請重試或檢查網路狀態,或檢查資料是否正確</string>
<!-- getsid-->
<string name="get_sid_error_no_data">sid無資料</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<paths>
<root-path
name="/"
path="/" />
</paths>
\ No newline at end of file
package com.example.audiovisualrecord;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
#Tue May 19 16:31:39 GMT+08:00 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1048576 bytes for AllocateHeap
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
# placed in the first 32GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (memory/allocation.inline.hpp:61), pid=20320, tid=0x0000000000003a8c
#
# JRE version: (8.0_202-b03) (build )
# Java VM: OpenJDK 64-Bit Server VM (25.202-b03 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
--------------- T H R E A D ---------------
Current thread (0x000000000312e800): JavaThread "Unknown thread" [_thread_in_vm, id=14988, stack(0x0000000003130000,0x0000000003230000)]
Stack: [0x0000000003130000,0x0000000003230000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
Other Threads:
=>0x000000000312e800 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=14988, stack(0x0000000003130000,0x0000000003230000)]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
heap address: 0x00000006c1200000, size: 4078 MB, Compressed Oops mode: Zero based, Oop shift amount: 3
Narrow klass base: 0x0000000000000000, Narrow klass shift: 3
Compressed class space size: 1073741824 Address: 0x00000007c0000000
Heap:
PSYoungGen total 76288K, used 1310K [0x000000076b100000, 0x0000000770600000, 0x00000007c0000000)
eden space 65536K, 2% used [0x000000076b100000,0x000000076b247af0,0x000000076f100000)
from space 10752K, 0% used [0x000000076fb80000,0x000000076fb80000,0x0000000770600000)
to space 10752K, 0% used [0x000000076f100000,0x000000076f100000,0x000000076fb80000)
ParOldGen total 175104K, used 0K [0x00000006c1200000, 0x00000006cbd00000, 0x000000076b100000)
object space 175104K, 0% used [0x00000006c1200000,0x00000006c1200000,0x00000006cbd00000)
Metaspace used 778K, capacity 4480K, committed 4480K, reserved 1056768K
class space used 74K, capacity 384K, committed 384K, reserved 1048576K
Card table byte_map: [0x00000000126f0000,0x0000000012ef0000] byte_map_base: 0x000000000f0e7000
Marking Bits: (ParMarkBitMap*) 0x0000000069869f30
Begin Bits: [0x0000000013c40000, 0x0000000017bf8000)
End Bits: [0x0000000017bf8000, 0x000000001bbb0000)
Polling page: 0x00000000014d0000
CodeCache: size=245760Kb used=328Kb max_used=328Kb free=245431Kb
bounds [0x0000000003330000, 0x00000000035a0000, 0x0000000012330000]
total_blobs=57 nmethods=0 adapters=38
compilation: enabled
Compilation events (0 events):
No events
GC Heap History (0 events):
No events
Deoptimization events (0 events):
No events
Classes redefined (0 events):
No events
Internal exceptions (0 events):
No events
Events (10 events):
Event: 0.021 loading class java/lang/Short
Event: 0.021 loading class java/lang/Short done
Event: 0.021 loading class java/lang/Integer
Event: 0.022 loading class java/lang/Integer done
Event: 0.022 loading class java/lang/Long
Event: 0.022 loading class java/lang/Long done
Event: 0.022 loading class java/lang/NullPointerException
Event: 0.022 loading class java/lang/NullPointerException done
Event: 0.022 loading class java/lang/ArithmeticException
Event: 0.022 loading class java/lang/ArithmeticException done
Dynamic libraries:
0x00007ff69da30000 - 0x00007ff69da61000 E:\Program Files\Android\Android Studio\jre\jre\bin\java.exe
0x00007ffb317a0000 - 0x00007ffb31990000 C:\WINDOWS\SYSTEM32\ntdll.dll
0x00007ffb2fc30000 - 0x00007ffb2fce2000 C:\WINDOWS\System32\KERNEL32.DLL
0x00007ffb2e730000 - 0x00007ffb2e9d4000 C:\WINDOWS\System32\KERNELBASE.dll
0x00007ffb316b0000 - 0x00007ffb31753000 C:\WINDOWS\System32\ADVAPI32.dll
0x00007ffb2fb90000 - 0x00007ffb2fc2e000 C:\WINDOWS\System32\msvcrt.dll
0x00007ffb30de0000 - 0x00007ffb30e77000 C:\WINDOWS\System32\sechost.dll
0x00007ffb2fe20000 - 0x00007ffb2ff40000 C:\WINDOWS\System32\RPCRT4.dll
0x00007ffb31440000 - 0x00007ffb315d4000 C:\WINDOWS\System32\USER32.dll
0x00007ffb2f160000 - 0x00007ffb2f181000 C:\WINDOWS\System32\win32u.dll
0x00007ffb30050000 - 0x00007ffb30076000 C:\WINDOWS\System32\GDI32.dll
0x00007ffb2f400000 - 0x00007ffb2f595000 C:\WINDOWS\System32\gdi32full.dll
0x00007ffb2f7b0000 - 0x00007ffb2f84e000 C:\WINDOWS\System32\msvcp_win.dll
0x00007ffb2f190000 - 0x00007ffb2f28a000 C:\WINDOWS\System32\ucrtbase.dll
0x00007ffb22d60000 - 0x00007ffb22fe4000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.18362.900_none_e6beb9d913147d17\COMCTL32.dll
0x00007ffb2f850000 - 0x00007ffb2fb85000 C:\WINDOWS\System32\combase.dll
0x00007ffb2f6d0000 - 0x00007ffb2f750000 C:\WINDOWS\System32\bcryptPrimitives.dll
0x00007ffb2ffa0000 - 0x00007ffb2ffce000 C:\WINDOWS\System32\IMM32.DLL
0x0000000068d40000 - 0x0000000068e12000 E:\Program Files\Android\Android Studio\jre\jre\bin\msvcr100.dll
0x00000000690a0000 - 0x00000000698e6000 E:\Program Files\Android\Android Studio\jre\jre\bin\server\jvm.dll
0x00007ffb2ffd0000 - 0x00007ffb2ffd8000 C:\WINDOWS\System32\PSAPI.DLL
0x00007ffb2ada0000 - 0x00007ffb2adc4000 C:\WINDOWS\SYSTEM32\WINMM.dll
0x00007ffb28ca0000 - 0x00007ffb28caa000 C:\WINDOWS\SYSTEM32\VERSION.dll
0x00007ffb1a040000 - 0x00007ffb1a049000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
0x00007ffb31220000 - 0x00007ffb3128f000 C:\WINDOWS\System32\WS2_32.dll
0x00007ffb2ad20000 - 0x00007ffb2ad4d000 C:\WINDOWS\SYSTEM32\WINMMBASE.dll
0x00007ffb2f5a0000 - 0x00007ffb2f5ea000 C:\WINDOWS\System32\cfgmgr32.dll
0x00007ffb00a30000 - 0x00007ffb00a3f000 E:\Program Files\Android\Android Studio\jre\jre\bin\verify.dll
0x00007ffaf7530000 - 0x00007ffaf7559000 E:\Program Files\Android\Android Studio\jre\jre\bin\java.dll
0x00007ffaf2330000 - 0x00007ffaf2346000 E:\Program Files\Android\Android Studio\jre\jre\bin\zip.dll
VM Arguments:
java_command: org.jetbrains.git4idea.http.GitAskPassApp Password for 'https://github.com':
java_class_path (initial): E:/Program Files/Android/Android Studio/plugins/git4idea/lib/git4idea-rt.jar;E:/Program Files/Android/Android Studio/lib/xmlrpc-2.0.1.jar;E:/Program Files/Android/Android Studio/lib/commons-codec-1.10.jar;E:/Program Files/Android/Android Studio/lib/util.jar
Launcher Type: SUN_STANDARD
Environment Variables:
PATH=E:/Program Files/Git/mingw64/libexec/git-core;E:/Program Files/Git/mingw64/libexec/git-core;E:\Program Files\Git\mingw64\bin;E:\Program Files\Git\usr\bin;C:\Users\PCKing\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_144\bin;D:\wamp64\bin\php\php5.6.31;C:\ProgramData\ComposerSetup\bin;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\Crucial\Crucial Storage Executive;E:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Users\PCKing\AppData\Local\Microsoft\WindowsApps;C:\Users\PCKing\AppData\Roaming\Composer\vendor\bin;C:\Users\PCKing\AppData\Local\GitHubDesktop\bin
USERNAME=PCKing
DISPLAY=:0.0
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 10.0 , 64 bit Build 18362 (10.0.18362.900)
CPU:total 8 (initial active 8) (4 cores per cpu, 2 threads per core) family 6 model 158 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx
Memory: 4k page, physical 16695424k(3741100k free), swap 16695424k(5892k free)
vm_info: OpenJDK 64-Bit Server VM (25.202-b03) for windows-amd64 JRE (1.8.0_202-release-1483-b03), built by "builder" with MS VC++ 10.0 (VS2010)
time: Sat Jun 20 17:35:03 2020
timezone: x_зǮɶ
elapsed time: 0 seconds (0d 0h 0m 0s)
include ':app'
rootProject.name='AudiovisualRecord'
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