mirror of
https://github.com/ZCShou/GoGoGo.git
synced 2026-06-05 21:00:50 +08:00
完善了问题反馈页面(使用Android 原生分享实现),现在可以直接将log 文件进行反馈
This commit is contained in:
parent
dc5c4bd278
commit
7a3d51be21
@ -14,8 +14,8 @@ android {
|
||||
applicationId "com.zcshou.gogogo"
|
||||
minSdkVersion 27
|
||||
targetSdkVersion 29
|
||||
versionCode 176
|
||||
versionName '1.7.6' // 语义化版本 https://semver.org/lang/zh-CN/
|
||||
versionCode 177
|
||||
versionName '1.7.7' // 语义化版本 https://semver.org/lang/zh-CN/
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
ndkVersion '23.0.7599858'
|
||||
|
||||
Binary file not shown.
@ -11,8 +11,8 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 176,
|
||||
"versionName": "1.7.6",
|
||||
"versionCode": 177,
|
||||
"versionName": "1.7.7",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
|
||||
@ -73,6 +73,16 @@
|
||||
|
||||
<service android:name="com.zcshou.service.ServiceGo" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileProvider"
|
||||
android:grantUriPermissions="true"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
<activity
|
||||
android:name=".WelcomeActivity"
|
||||
android:label="@string/app_name"
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.zcshou.gogogo;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.baidu.mapapi.SDKInitializer;
|
||||
|
||||
@ -17,16 +16,11 @@ import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy;
|
||||
import com.elvishew.xlog.printer.file.naming.ChangelessFileNameGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class GoApplication extends Application {
|
||||
private static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd", Locale.CHINA);
|
||||
private static final String timeStr = formatter.format(new Date(System.currentTimeMillis()));
|
||||
private static final String APP_NAME = "GoGoGo";
|
||||
private static final String LOG_FILE_NAME = APP_NAME + "_" + timeStr + ".log";
|
||||
private static final long MAX_TIME = 1000 * 60 * 60 * 24 * 5; // 5 days
|
||||
public static final String APP_NAME = "GoGoGo";
|
||||
public static final String LOG_FILE_NAME = APP_NAME + ".log";
|
||||
private static final long MAX_TIME = 1000 * 60 * 60 * 24 * 3; // 3 days
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@ -64,7 +58,7 @@ public class GoApplication extends Application {
|
||||
Printer androidPrinter = new AndroidPrinter(true); // 通过 android.util.Log 打印日志的打印器
|
||||
Printer consolePrinter = new ConsolePrinter(); // 通过 System.out 打印日志到控制台的打印器
|
||||
Printer filePrinter = new FilePrinter // 打印日志到文件的打印器
|
||||
.Builder(new File(Environment.getExternalStorageDirectory(),
|
||||
.Builder(new File(getExternalFilesDir(null),
|
||||
APP_NAME).getPath()) // 指定保存日志文件的路径
|
||||
.fileNameGenerator(new ChangelessFileNameGenerator(LOG_FILE_NAME)) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
|
||||
.backupStrategy(new NeverBackupStrategy()) // 指定日志文件备份策略,默认为 FileSizeBackupStrategy(1024 * 1024)
|
||||
|
||||
@ -78,6 +78,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -94,6 +95,7 @@ import com.zcshou.service.ServiceGo;
|
||||
import com.zcshou.database.DataBaseHistoryLocation;
|
||||
import com.zcshou.database.DataBaseHistorySearch;
|
||||
import com.zcshou.service.GoSntpClient;
|
||||
import com.zcshou.utils.ShareUtils;
|
||||
import com.zcshou.utils.GoUtils;
|
||||
import com.zcshou.utils.MapUtils;
|
||||
|
||||
@ -808,14 +810,12 @@ public class MainActivity extends BaseActivity
|
||||
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (id == R.id.nav_contact) {
|
||||
Intent i = new Intent(Intent.ACTION_SEND);
|
||||
// i.setType("text/plain"); //模拟器请使用这行
|
||||
i.setType("message/rfc822"); // 真机上使用这行
|
||||
i.putExtra(Intent.EXTRA_EMAIL,
|
||||
new String[] {"zcsexp@gmail.com"});
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, "SUGGESTION");
|
||||
startActivity(Intent.createChooser(i,
|
||||
"Select email application."));
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("android.intent.action.VIEW");
|
||||
Uri content_url = Uri.parse("https://gitee.com/zcshou/gogogo/issues");
|
||||
intent.setData(content_url);
|
||||
startActivity(intent);
|
||||
} else if (id == R.id.nav_dev) {
|
||||
try {
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
|
||||
@ -824,6 +824,9 @@ public class MainActivity extends BaseActivity
|
||||
DisplayToast("无法跳转到开发者选项,请先确保您的设备已处于开发者模式");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (id == R.id.nav_feedback) {
|
||||
File file = new File(getExternalFilesDir(null).toPath() + "/" + GoApplication.APP_NAME + "/" + GoApplication.LOG_FILE_NAME);
|
||||
ShareUtils.shareFile(this, file, item.getTitle().toString());
|
||||
}
|
||||
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.zcshou.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Criteria;
|
||||
@ -171,6 +172,31 @@ public class GoUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取App的名称
|
||||
*
|
||||
* @param context 上下文
|
||||
*
|
||||
* @return 名称
|
||||
*/
|
||||
public static String getAppName(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
//获取包信息
|
||||
try {
|
||||
PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
|
||||
//获取应用 信息
|
||||
ApplicationInfo applicationInfo = packageInfo.applicationInfo;
|
||||
//获取albelRes
|
||||
int labelRes = applicationInfo.labelRes;
|
||||
//返回App的名称
|
||||
return context.getResources().getString(labelRes);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String timeStamp2Date(String seconds) {
|
||||
if (seconds == null || seconds.isEmpty() || seconds.equals("null")) {
|
||||
return "";
|
||||
|
||||
28
app/src/main/java/com/zcshou/utils/ShareUtils.java
Normal file
28
app/src/main/java/com/zcshou/utils/ShareUtils.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.zcshou.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ShareUtils {
|
||||
/**
|
||||
* 返回uri
|
||||
*/
|
||||
private static Uri getUriForFile(Context context, File file) {
|
||||
String authority = context.getPackageName().concat(".fileProvider");
|
||||
return FileProvider.getUriForFile(context, authority, file);
|
||||
}
|
||||
|
||||
public static void shareFile(Context context, File file, String title) {
|
||||
Intent share = new Intent(Intent.ACTION_SEND);
|
||||
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
share.putExtra(Intent.EXTRA_STREAM, getUriForFile(context, file));
|
||||
share.setType("application/octet-stream");
|
||||
context.startActivity(Intent.createChooser(share, title));
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
<item android:title="@string/nav_menu_more">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/nav_bug_report"
|
||||
android:id="@+id/nav_feedback"
|
||||
android:icon="@drawable/ic_menu_feedback"
|
||||
android:title="@string/nav_menu_feedback" />
|
||||
<item
|
||||
|
||||
9
app/src/main/res/xml/provider_paths.xml
Normal file
9
app/src/main/res/xml/provider_paths.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<external-path
|
||||
name="external_files"
|
||||
path="GoGoGo/" />
|
||||
<external-path
|
||||
name="external_storage_root"
|
||||
path="." />
|
||||
</paths>
|
||||
Loading…
Reference in New Issue
Block a user