use of net.osmand.plus.activities.OsmandActionBarActivity in project Osmand by osmandapp.
the class DashErrorFragment method initView.
@Override
public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = getActivity().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());
ImageView iv = ((ImageView) view.findViewById(R.id.error_icon));
iv.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_crashlog));
TextView message = ((TextView) view.findViewById(R.id.error_header));
message.setTypeface(typeface);
message.setText(msg);
Button errorBtn = ((Button) view.findViewById(R.id.error_btn));
errorBtn.setTypeface(typeface);
errorBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
// $NON-NLS-1$
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "crash@osmand.net" });
File file = getMyApplication().getAppPath(OsmandApplication.EXCEPTION_PATH);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// $NON-NLS-1$
intent.setType("vnd.android.cursor.dir/email");
// $NON-NLS-1$
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug");
StringBuilder text = new StringBuilder();
// $NON-NLS-1$
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()));
try {
PackageInfo info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
if (info != null) {
// $NON-NLS-1$ //$NON-NLS-2$
text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode);
}
} 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)));
}
});
Button cancelBtn = ((Button) view.findViewById(R.id.error_cancel));
cancelBtn.setTypeface(typeface);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
OsmandActionBarActivity dashboardActivity = ((OsmandActionBarActivity) getActivity());
if (dashboardActivity != null) {
dashboardActivity.getSupportFragmentManager().beginTransaction().remove(DashErrorFragment.this).commit();
}
}
});
dismissCallback = new ErrorDismissListener(getParentView(), dashboard, TAG, view);
return view;
}
use of net.osmand.plus.activities.OsmandActionBarActivity in project Osmand by osmandapp.
the class ErrorBottomSheetDialog method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = getActivity().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());
ImageView iv = ((ImageView) view.findViewById(R.id.error_icon));
iv.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_crashlog));
TextView message = ((TextView) view.findViewById(R.id.error_header));
message.setTypeface(typeface);
message.setText(msg);
Button errorBtn = ((Button) view.findViewById(R.id.error_btn));
errorBtn.setTypeface(typeface);
errorBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
// $NON-NLS-1$
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "crash@osmand.net" });
File file = getMyApplication().getAppPath(OsmandApplication.EXCEPTION_PATH);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// $NON-NLS-1$
intent.setType("vnd.android.cursor.dir/email");
// $NON-NLS-1$
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug");
StringBuilder text = new StringBuilder();
// $NON-NLS-1$
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()));
try {
PackageInfo info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
if (info != null) {
// $NON-NLS-1$ //$NON-NLS-2$
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)));
dismiss();
}
});
Button cancelBtn = ((Button) view.findViewById(R.id.error_cancel));
cancelBtn.setTypeface(typeface);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
OsmandActionBarActivity dashboardActivity = ((OsmandActionBarActivity) getActivity());
if (dashboardActivity != null) {
dismiss();
}
}
});
return view;
}
Aggregations