|
@@ -1695,21 +1695,21 @@ public class Config extends AppCompatActivity
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
String configString = "";
|
|
|
Uri uri = data.getData();
|
|
|
-
|
|
|
- if (requestCode == 1) {
|
|
|
+ String fileString = "";
|
|
|
+ if (requestCode == 1) { //U 盘 文 件
|
|
|
|
|
|
byte[] filebuffer;
|
|
|
int len;
|
|
|
try {
|
|
|
|
|
|
- String fileString = "";
|
|
|
+ //String fileString = "";
|
|
|
File storage = new File("/storage");
|
|
|
File[] files = storage.listFiles();
|
|
|
for (final File file : files) {
|
|
|
if (file.canRead()) {
|
|
|
if (!file.getName().equals(Environment.getExternalStorageDirectory().getName())) {
|
|
|
//满足该条件的文件夹就是u盘在手机上的目录
|
|
|
- fileString = (file.getPath()+"/GT9110H_wingcool_config.cfg");
|
|
|
+ fileString = (file.getPath()+"/GTxxxx_wingcool_config.cfg");
|
|
|
fileString = fileString.replaceAll(":", "/"); //将:改为/,以防某些系统文件目录读出是:
|
|
|
edit_search.setText(fileString);
|
|
|
}
|
|
@@ -1732,35 +1732,37 @@ public class Config extends AppCompatActivity
|
|
|
configString = buffer.toString();
|
|
|
|
|
|
} catch (IOException ex) {
|
|
|
-
|
|
|
- //edit_search.setText(getResources().getString(R.string.invalidfile));
|
|
|
edit_search.setText(uri.getPath() + "——" + getResources().getString(R.string.invalidfile));
|
|
|
return;
|
|
|
}
|
|
|
- }
|
|
|
- else if (requestCode == 2) {
|
|
|
+ } //end of if (requestCode == 1)
|
|
|
+ else if (requestCode == 2) { //本 地 文 件
|
|
|
|
|
|
try {
|
|
|
File dir = Environment.getExternalStorageDirectory();
|
|
|
//Uri uri = data.getData();
|
|
|
File dataFile;
|
|
|
- if (byProductType == GT9) { //GT9
|
|
|
- edit_search.setText(dir.getPath() + "/GT9110H_wingcool_config.cfg");
|
|
|
-
|
|
|
- //File dir = Environment.getExternalStorageDirectory();
|
|
|
- dataFile = new File(dir.getPath(), "GT9110H_wingcool_config.cfg");
|
|
|
- } else if (byProductType == GT7) { //GT7
|
|
|
- edit_search.setText(dir.getPath() + "/GT738x_wingcool_config.cfg");
|
|
|
|
|
|
- //File dir = Environment.getExternalStorageDirectory();
|
|
|
- dataFile = new File(dir.getPath(), "GT738x_wingcool_config.cfg");
|
|
|
- } else { //other
|
|
|
- edit_search.setText(dir.getPath() + "/GTxxxx_wingcool_config.cfg");
|
|
|
+ fileString = dir.getPath() + "/";
|
|
|
|
|
|
- //File dir = Environment.getExternalStorageDirectory();
|
|
|
- dataFile = new File(dir.getPath(), "GTxxxx_wingcool_config.cfg");
|
|
|
+ if (uri.getLastPathSegment().indexOf(":") > 0){
|
|
|
+ String[] stringFileNameArr = uri.getLastPathSegment().split(":");
|
|
|
+ fileString += stringFileNameArr[1];
|
|
|
+ }else{
|
|
|
+ fileString += uri.getLastPathSegment();
|
|
|
}
|
|
|
|
|
|
+ //fileString = dir.getPath() + "/" + uri.getLastPathSegment();
|
|
|
+ //edit_search.setText(dir.getPath() + "/GTxxxx_wingcool_config.cfg");
|
|
|
+
|
|
|
+
|
|
|
+ //fileString = fileString.replaceAll(":", "/"); //将:改为/,以防某些系统文件目录读出是:
|
|
|
+ edit_search.setText(fileString);
|
|
|
+
|
|
|
+ //File dir = Environment.getExternalStorageDirectory();
|
|
|
+ //dataFile = new File(dir.getPath(), "GTxxxx_wingcool_config.cfg");
|
|
|
+ dataFile = new File(fileString);
|
|
|
+
|
|
|
FileInputStream fis = new FileInputStream(dataFile);
|
|
|
//byte[] bytes = new byte[fis.available()];
|
|
|
//fis.read(bytes);
|
|
@@ -1780,12 +1782,10 @@ public class Config extends AppCompatActivity
|
|
|
configString = buffer.toString();
|
|
|
|
|
|
} catch (IOException c) {
|
|
|
-
|
|
|
edit_search.setText(uri.getPath() + "——" + getResources().getString(R.string.invalidfile));
|
|
|
-
|
|
|
return;
|
|
|
}
|
|
|
- }
|
|
|
+ } //end of else if (requestCode == 2)
|
|
|
|
|
|
/*
|
|
|
Uri uri = data.getData();
|
|
@@ -1856,7 +1856,7 @@ public class Config extends AppCompatActivity
|
|
|
}
|
|
|
|
|
|
ReadCfgRam(stringCfgArr);
|
|
|
- }
|
|
|
+ } //end of if (resultCode == Activity.RESULT_OK)
|
|
|
}
|
|
|
|
|
|
private void initListener() {
|