Merge branch 'r3.3'

This commit is contained in:
crimean 2019-04-16 17:05:50 +03:00
commit 47fef45401
6 changed files with 87 additions and 67 deletions

View file

@ -32,4 +32,20 @@
style="@style/Widget.AppCompat.Button.Borderless"
tools:drawableTop="@drawable/ic_action_message"/>
<View
android:id="@+id/sendLogButtonDiv"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/divider_color"/>
<Button
android:id="@+id/sendLogButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/send_log"
style="@style/Widget.AppCompat.Button.Borderless"
tools:drawableTop="@drawable/ic_crashlog"/>
</LinearLayout>

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<string name="send_log">Send log</string>
<string name="routing_attr_avoid_tram_name">Avoid trams</string>
<string name="routing_attr_avoid_tram_description">Avoid trams</string>
<string name="routing_attr_avoid_bus_name">Avoid buses</string>

View file

@ -23,6 +23,7 @@ import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.activities.HelpActivity;
import net.osmand.plus.activities.actions.AppModeDialog;
@ -31,6 +32,7 @@ import net.osmand.plus.dialogs.HelpArticleDialogFragment;
import org.apache.commons.logging.Log;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -208,6 +210,26 @@ public class ContextMenuAdapter {
}
}
});
File logFile = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
View sendLogButtonDiv = convertView.findViewById(R.id.sendLogButtonDiv);
TextView sendLogButton = (TextView) convertView.findViewById(R.id.sendLogButton);
if (logFile.exists()) {
Drawable sendLogIcon =
app.getUIUtilities().getThemedIcon(R.drawable.ic_crashlog);
sendLogButton.setCompoundDrawablesWithIntrinsicBounds(null, sendLogIcon, null, null);
sendLogButton.setCompoundDrawablePadding(AndroidUtils.dpToPx(app, 8f));
sendLogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.sendCrashLog();
}
});
sendLogButtonDiv.setVisibility(View.VISIBLE);
sendLogButton.setVisibility(View.VISIBLE);
} else {
sendLogButtonDiv.setVisibility(View.GONE);
sendLogButton.setVisibility(View.GONE);
}
return convertView;
}

View file

@ -9,6 +9,7 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.os.AsyncTask;
@ -26,6 +27,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
@ -45,6 +47,8 @@ import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.api.SQLiteAPI;
import net.osmand.plus.api.SQLiteAPIImpl;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashErrorFragment;
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
import net.osmand.plus.dialogs.RateUsBottomSheetDialog;
import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.helpers.AvoidSpecificRoads;
@ -82,7 +86,7 @@ import btools.routingapp.BRouterServiceConnection;
import btools.routingapp.IBRouterService;
public class OsmandApplication extends MultiDexApplication {
public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$
public static final String EXCEPTION_PATH = "exception.log";
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class);
private static final String SHOW_PLUS_VERSION_INAPP_PARAM = "show_plus_version_inapp";
@ -618,12 +622,12 @@ public class OsmandApplication extends MultiDexApplication {
StringBuilder msg = new StringBuilder();
msg.append("Version ")
.append(Version.getFullVersion(OsmandApplication.this))
.append("\n") //$NON-NLS-1$
.append("\n")
.append(DateFormat.format("dd.MM.yyyy h:mm:ss", System.currentTimeMillis()));
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
if (info != null) {
msg.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode); //$NON-NLS-1$ //$NON-NLS-2$
msg.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode);
}
} catch (Throwable e) {
}
@ -650,7 +654,7 @@ public class OsmandApplication extends MultiDexApplication {
defaultHandler.uncaughtException(thread, ex);
} catch (Exception e) {
// swallow all exceptions
android.util.Log.e(PlatformUtil.TAG, "Exception while handle other exception", e); //$NON-NLS-1$
android.util.Log.e(PlatformUtil.TAG, "Exception while handle other exception", e);
}
}
@ -1032,4 +1036,32 @@ public class OsmandApplication extends MultiDexApplication {
public MapViewTrackingUtilities getMapViewTrackingUtilities() {
return mapViewTrackingUtilities;
}
public void sendCrashLog() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"crash@osmand.net"});
File file = getAppPath(OsmandApplication.EXCEPTION_PATH);
intent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(this, file));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("vnd.android.cursor.dir/email");
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug");
StringBuilder text = new StringBuilder();
text.append("\nDevice : ").append(Build.DEVICE);
text.append("\nBrand : ").append(Build.BRAND);
text.append("\nModel : ").append(Build.MODEL);
text.append("\nProduct : ").append(Build.PRODUCT);
text.append("\nBuild : ").append(Build.DISPLAY);
text.append("\nVersion : ").append(Build.VERSION.RELEASE);
text.append("\nApp Version : ").append(Version.getAppName(this));
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
if (info != null) {
text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode);
}
} catch (PackageManager.NameNotFoundException e) {
PlatformUtil.getLog(ErrorBottomSheetDialog.class).error("", e);
}
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
}
}

View file

@ -58,32 +58,7 @@ public class DashErrorFragment extends DashBaseFragment {
errorBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"crash@osmand.net"}); //$NON-NLS-1$
File file = getMyApplication().getAppPath(OsmandApplication.EXCEPTION_PATH);
intent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMyApplication(),file));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$
StringBuilder text = new StringBuilder();
text.append("\nDevice : ").append(Build.DEVICE); //$NON-NLS-1$
text.append("\nBrand : ").append(Build.BRAND); //$NON-NLS-1$
text.append("\nModel : ").append(Build.MODEL); //$NON-NLS-1$
text.append("\nProduct : ").append(Build.PRODUCT); //$NON-NLS-1$
text.append("\nBuild : ").append(Build.DISPLAY); //$NON-NLS-1$
text.append("\nVersion : ").append(Build.VERSION.RELEASE); //$NON-NLS-1$
text.append("\nApp Version : ").append(Version.getAppName(getMyApplication())); //$NON-NLS-1$
try {
PackageInfo info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
0);
if (info != null) {
text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode); //$NON-NLS-1$ //$NON-NLS-2$
}
} catch (PackageManager.NameNotFoundException e) {
PlatformUtil.getLog(DashErrorFragment.class).error("", e);
}
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
getMyApplication().sendCrashLog();
}
});

View file

@ -1,12 +1,10 @@
package net.osmand.plus.dialogs;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -14,29 +12,27 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.FontCache;
import java.io.File;
import java.text.MessageFormat;
public class ErrorBottomSheetDialog extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_error_fragment, container, false);
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
FragmentActivity activity = requireActivity();
OsmandApplication app = (OsmandApplication) activity.getApplication();
View view = activity.getLayoutInflater().inflate(R.layout.dash_error_fragment, container, false);
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
Typeface typeface = FontCache.getRobotoMedium(activity);
ImageView iv = ((ImageView) view.findViewById(R.id.error_icon));
iv.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_crashlog));
iv.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_crashlog));
TextView message = ((TextView) view.findViewById(R.id.error_header));
message.setTypeface(typeface);
message.setText(msg);
@ -45,32 +41,10 @@ public class ErrorBottomSheetDialog extends BottomSheetDialogFragment {
errorBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"crash@osmand.net"}); //$NON-NLS-1$
File file = getMyApplication().getAppPath(OsmandApplication.EXCEPTION_PATH);
intent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMyApplication(), file));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$
StringBuilder text = new StringBuilder();
text.append("\nDevice : ").append(Build.DEVICE); //$NON-NLS-1$
text.append("\nBrand : ").append(Build.BRAND); //$NON-NLS-1$
text.append("\nModel : ").append(Build.MODEL); //$NON-NLS-1$
text.append("\nProduct : ").append(Build.PRODUCT); //$NON-NLS-1$
text.append("\nBuild : ").append(Build.DISPLAY); //$NON-NLS-1$
text.append("\nVersion : ").append(Build.VERSION.RELEASE); //$NON-NLS-1$
text.append("\nApp Version : ").append(Version.getAppName(getMyApplication())); //$NON-NLS-1$
try {
PackageInfo info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
0);
if (info != null) {
text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode); //$NON-NLS-1$ //$NON-NLS-2$
OsmandApplication app = getMyApplication();
if (app != null) {
app.sendCrashLog();
}
} catch (PackageManager.NameNotFoundException e) {
PlatformUtil.getLog(ErrorBottomSheetDialog.class).error("", e);
}
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
dismiss();
}
});