编译工程
This commit is contained in:
parent
24220e7f83
commit
1f82fc32b1
@ -106,11 +106,10 @@ dependencies {
|
||||
implementation "androidx.sqlite:sqlite:2.0.1"
|
||||
implementation "androidx.room:room-runtime:2.1.0"
|
||||
annotationProcessor "androidx.room:room-compiler:2.1.0"
|
||||
kapt 'android.arch.persistence.room:compiler:1.1.1' // compiler 需要用 room 的
|
||||
kapt "androidx.room:room-compiler:2.1.0"
|
||||
androidTestImplementation "android.arch.persistence.room:testing:1.1.1"
|
||||
implementation "android.arch.lifecycle:extensions:1.1.1"
|
||||
kapt "android.arch.lifecycle:compiler:1.1.1"
|
||||
androidTestImplementation 'androidx.room:room-testing:2.0.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
|
||||
kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
|
||||
implementation 'com.tencent.wcdb:wcdb-android:1.0.0'
|
||||
implementation "androidx.core:core-ktx:1.8.0"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
@ -1,117 +1,117 @@
|
||||
package com.navinfo.collect;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.PermissionChecker;
|
||||
|
||||
import com.baidu.ai.edge.core.base.Consts;
|
||||
|
||||
|
||||
/**
|
||||
* Created by linyiran on 6/16/22.
|
||||
*/
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
private static final int REQUEST_PERMISSION = 1;
|
||||
|
||||
protected boolean allPermissionsGranted;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setLayout();
|
||||
requestPermission();
|
||||
onActivityCreated(savedInstanceState);
|
||||
}
|
||||
|
||||
protected abstract void setLayout();
|
||||
|
||||
protected abstract void onActivityCreated(Bundle savedInstanceState);
|
||||
|
||||
private void requestPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
String[] permissions = new String[]{
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.INTERNET,
|
||||
Manifest.permission.ACCESS_NETWORK_STATE,
|
||||
Manifest.permission.READ_PHONE_STATE,
|
||||
Manifest.permission.CAMERA
|
||||
};
|
||||
allPermissionsGranted = true;
|
||||
for (String perm : permissions) {
|
||||
if ((PermissionChecker.checkSelfPermission(this, perm) != PermissionChecker.PERMISSION_GRANTED)) {
|
||||
allPermissionsGranted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allPermissionsGranted) {
|
||||
ActivityCompat.requestPermissions(BaseActivity.this, permissions, REQUEST_PERMISSION);
|
||||
} else {
|
||||
requestAllFilesAccess();
|
||||
}
|
||||
} else {
|
||||
allPermissionsGranted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
if (requestCode == REQUEST_PERMISSION) {
|
||||
allPermissionsGranted = true;
|
||||
for (int grantRes : grantResults) {
|
||||
if (grantRes != PackageManager.PERMISSION_GRANTED) {
|
||||
allPermissionsGranted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allPermissionsGranted) {
|
||||
requestAllFilesAccess();
|
||||
}
|
||||
}
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Android 11 跳转到设置获取SD卡根目录写入权限
|
||||
*/
|
||||
private void requestAllFilesAccess() {
|
||||
if (!Consts.AUTH_REQUIRE_SDCARD) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
|
||||
allPermissionsGranted = false;
|
||||
|
||||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(BaseActivity.this,
|
||||
androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog_Alert);
|
||||
alertBuilder.setMessage("需授权访问SD卡文件");
|
||||
alertBuilder.setCancelable(false);
|
||||
alertBuilder.setPositiveButton("去设置", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertBuilder.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.navinfo.collect;
|
||||
//
|
||||
//import android.Manifest;
|
||||
//import android.content.DialogInterface;
|
||||
//import android.content.Intent;
|
||||
//import android.content.pm.PackageManager;
|
||||
//import android.os.Build;
|
||||
//import android.os.Bundle;
|
||||
//import android.os.Environment;
|
||||
//import android.provider.Settings;
|
||||
//
|
||||
//import androidx.annotation.NonNull;
|
||||
//import androidx.annotation.Nullable;
|
||||
//import androidx.appcompat.app.AlertDialog;
|
||||
//import androidx.appcompat.app.AppCompatActivity;
|
||||
//import androidx.core.app.ActivityCompat;
|
||||
//import androidx.core.content.PermissionChecker;
|
||||
//
|
||||
//import com.baidu.ai.edge.core.base.Consts;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * Created by linyiran on 6/16/22.
|
||||
// */
|
||||
//public abstract class BaseActivity extends AppCompatActivity {
|
||||
// private static final int REQUEST_PERMISSION = 1;
|
||||
//
|
||||
// protected boolean allPermissionsGranted;
|
||||
//
|
||||
// @Override
|
||||
// protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// setLayout();
|
||||
// requestPermission();
|
||||
// onActivityCreated(savedInstanceState);
|
||||
// }
|
||||
//
|
||||
// protected abstract void setLayout();
|
||||
//
|
||||
// protected abstract void onActivityCreated(Bundle savedInstanceState);
|
||||
//
|
||||
// private void requestPermission() {
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// String[] permissions = new String[]{
|
||||
// Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
// Manifest.permission.INTERNET,
|
||||
// Manifest.permission.ACCESS_NETWORK_STATE,
|
||||
// Manifest.permission.READ_PHONE_STATE,
|
||||
// Manifest.permission.CAMERA
|
||||
// };
|
||||
// allPermissionsGranted = true;
|
||||
// for (String perm : permissions) {
|
||||
// if ((PermissionChecker.checkSelfPermission(this, perm) != PermissionChecker.PERMISSION_GRANTED)) {
|
||||
// allPermissionsGranted = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!allPermissionsGranted) {
|
||||
// ActivityCompat.requestPermissions(BaseActivity.this, permissions, REQUEST_PERMISSION);
|
||||
// } else {
|
||||
// requestAllFilesAccess();
|
||||
// }
|
||||
// } else {
|
||||
// allPermissionsGranted = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
// @NonNull int[] grantResults) {
|
||||
// if (requestCode == REQUEST_PERMISSION) {
|
||||
// allPermissionsGranted = true;
|
||||
// for (int grantRes : grantResults) {
|
||||
// if (grantRes != PackageManager.PERMISSION_GRANTED) {
|
||||
// allPermissionsGranted = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (allPermissionsGranted) {
|
||||
// requestAllFilesAccess();
|
||||
// }
|
||||
// }
|
||||
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Android 11 跳转到设置获取SD卡根目录写入权限
|
||||
// */
|
||||
// private void requestAllFilesAccess() {
|
||||
// if (!Consts.AUTH_REQUIRE_SDCARD) {
|
||||
// return;
|
||||
// }
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
|
||||
// allPermissionsGranted = false;
|
||||
//
|
||||
// AlertDialog.Builder alertBuilder = new AlertDialog.Builder(BaseActivity.this,
|
||||
// androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog_Alert);
|
||||
// alertBuilder.setMessage("需授权访问SD卡文件");
|
||||
// alertBuilder.setCancelable(false);
|
||||
// alertBuilder.setPositiveButton("去设置", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
// alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// dialog.dismiss();
|
||||
// }
|
||||
// });
|
||||
// alertBuilder.show();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,43 +1,43 @@
|
||||
package com.navinfo.collect
|
||||
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.baidu.ai.edge.ui.view.model.BasePolygonResultModel
|
||||
import com.navinfo.collect.library.map.flutter.plugin.FlutterMapViewFactory
|
||||
import com.navinfo.collect.library.map.flutter.plugin.FlutterMapViewFlutterPlugin
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
|
||||
abstract class FlutterBaseActivity : FlutterActivity(), CoroutineScope by MainScope() {
|
||||
lateinit var factory: FlutterMapViewFactory
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
factory = FlutterMapViewFlutterPlugin.registerWith(flutterEngine, this);
|
||||
// FlutterNiMapCopyViewFlutterPlugin.registerWith(flutterEngine, this);
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == 0x10 && data != null) {
|
||||
val path = data.getStringExtra("photo_path")
|
||||
val list = data.getParcelableArrayListExtra<BasePolygonResultModel>("result_list")
|
||||
Log.e("jingo","OCR java 返回的数据:"+ path + list.toString());
|
||||
if (path != null && list != null) {
|
||||
factory.dataController.flutterDataCameraHandler.sendOcrResults(
|
||||
path,
|
||||
list as List<BasePolygonResultModel>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
//协程销毁
|
||||
cancel()
|
||||
}
|
||||
|
||||
}
|
||||
//package com.navinfo.collect
|
||||
//
|
||||
//import android.content.Intent
|
||||
//import android.util.Log
|
||||
//import com.baidu.ai.edge.ui.view.model.BasePolygonResultModel
|
||||
//import com.navinfo.collect.library.map.flutter.plugin.FlutterMapViewFactory
|
||||
//import com.navinfo.collect.library.map.flutter.plugin.FlutterMapViewFlutterPlugin
|
||||
//import io.flutter.embedding.android.FlutterActivity
|
||||
//import io.flutter.embedding.engine.FlutterEngine
|
||||
//import kotlinx.coroutines.CoroutineScope
|
||||
//import kotlinx.coroutines.MainScope
|
||||
//import kotlinx.coroutines.cancel
|
||||
//
|
||||
//abstract class FlutterBaseActivity : FlutterActivity(), CoroutineScope by MainScope() {
|
||||
// lateinit var factory: FlutterMapViewFactory
|
||||
// override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
// super.configureFlutterEngine(flutterEngine)
|
||||
// factory = FlutterMapViewFlutterPlugin.registerWith(flutterEngine, this);
|
||||
//// FlutterNiMapCopyViewFlutterPlugin.registerWith(flutterEngine, this);
|
||||
// }
|
||||
//
|
||||
// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
// super.onActivityResult(requestCode, resultCode, data)
|
||||
// if (resultCode == 0x10 && data != null) {
|
||||
// val path = data.getStringExtra("photo_path")
|
||||
// val list = data.getParcelableArrayListExtra<BasePolygonResultModel>("result_list")
|
||||
// Log.e("jingo","OCR java 返回的数据:"+ path + list.toString());
|
||||
// if (path != null && list != null) {
|
||||
// factory.dataController.flutterDataCameraHandler.sendOcrResults(
|
||||
// path,
|
||||
// list as List<BasePolygonResultModel>
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onDestroy() {
|
||||
// super.onDestroy()
|
||||
// //协程销毁
|
||||
// cancel()
|
||||
// }
|
||||
//
|
||||
//}
|
@ -26,4 +26,5 @@ systemProp.http.proxyHost=127.0.0.1
|
||||
systemProp.http.proxyPort=1080
|
||||
systemProp.https.proxyHost=127.0.0.1
|
||||
systemProp.https.proxyPort=1080
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.configureondemand=true
|
||||
android.experimental.legacyTransform.forceNonIncremental=true
|
@ -5,7 +5,6 @@ pluginManagement {
|
||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://download.flutter.io' }
|
||||
maven { url 'https://storage.googleapis.com/download.flutter.io' }
|
||||
google()
|
||||
mavenCentral()
|
||||
@ -20,7 +19,6 @@ dependencyResolutionManagement {
|
||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://download.flutter.io' }
|
||||
maven { url 'https://storage.googleapis.com/download.flutter.io' }
|
||||
google()
|
||||
mavenCentral()
|
||||
|
Loading…
x
Reference in New Issue
Block a user