1 |
package com.zoffcc.applications.zanavi;
|
2 |
|
3 |
import java.text.SimpleDateFormat;
|
4 |
import java.util.Date;
|
5 |
import java.util.Locale;
|
6 |
|
7 |
import mehdi.sakout.aboutpage.AboutPage;
|
8 |
import mehdi.sakout.aboutpage.Element;
|
9 |
import android.annotation.SuppressLint;
|
10 |
import android.annotation.TargetApi;
|
11 |
import android.app.ProgressDialog;
|
12 |
import android.content.DialogInterface;
|
13 |
import android.content.Intent;
|
14 |
import android.net.Uri;
|
15 |
import android.os.Build;
|
16 |
import android.os.Bundle;
|
17 |
import android.os.Handler;
|
18 |
import android.preference.PreferenceManager;
|
19 |
import android.support.v4.content.ContextCompat;
|
20 |
import android.support.v7.app.AppCompatActivity;
|
21 |
import android.view.Gravity;
|
22 |
import android.view.View;
|
23 |
import android.view.View.OnClickListener;
|
24 |
import android.widget.Toast;
|
25 |
|
26 |
import com.zoffcc.applications.logging.Logging;
|
27 |
import com.zoffcc.applications.logging.Logging.AsyncResponse;
|
28 |
|
29 |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
30 |
@SuppressLint("NewApi")
|
31 |
public class ZANaviAboutPage extends AppCompatActivity implements AsyncResponse
|
32 |
{
|
33 |
ProgressDialog progressDialog2;
|
34 |
|
35 |
@Override
|
36 |
protected void onCreate(Bundle savedInstanceState)
|
37 |
{
|
38 |
super.onCreate(savedInstanceState);
|
39 |
|
40 |
Element BugsElement = new Element();
|
41 |
BugsElement.setTitle(Navit.get_text("Report Bugs"));
|
42 |
String BugsUrls = "https://github.com/zoff99/zanavi/issues";
|
43 |
Intent i = new Intent(Intent.ACTION_VIEW);
|
44 |
i.setData(Uri.parse(BugsUrls));
|
45 |
BugsElement.setIntent(i);
|
46 |
|
47 |
Element fdroidElement = new Element();
|
48 |
fdroidElement.setTitle("F-Droid");
|
49 |
String froidUrls = "https://f-droid.org/repository/browse/?fdid=com.zoffcc.applications.zanavi";
|
50 |
Intent i2 = new Intent(Intent.ACTION_VIEW);
|
51 |
i2.setData(Uri.parse(froidUrls));
|
52 |
fdroidElement.setIntent(i2);
|
53 |
|
54 |
AboutPage ap = new AboutPage(this).isRTL(false).setImage(R.drawable.icon).setDescription(Navit.get_text("Welcome to ZANavi offline Navigation")).addItem(new Element().setTitle("Version " + Navit.ZANAVI_VERSION)).addItem(BugsElement).addEmail("feedback@zanavi.cc").addWebsite("http://zanavi.cc/")
|
55 |
// .addYoutube("UCoghiC-cOCZyq6PGehpm5wA")
|
56 |
.addPlayStore("com.zoffcc.applications.zanavi").addItem(fdroidElement).addGitHub("zoff99/zanavi");
|
57 |
|
58 |
Element e001 = new Element();
|
59 |
e001.setTitle("OpenStreetMap data is available under the Open Database Licence");
|
60 |
String url001 = "http://www.openstreetmap.org/copyright";
|
61 |
Intent i001 = new Intent(Intent.ACTION_VIEW);
|
62 |
i001.setData(Uri.parse(url001));
|
63 |
e001.setIntent(i001);
|
64 |
ap.addItem(e001);
|
65 |
|
66 |
e001 = new Element();
|
67 |
e001.setTitle(Navit.get_text("send Crash report via Email"));
|
68 |
e001.setOnClickListener(new OnClickListener()
|
69 |
{
|
70 |
public void onClick(View v)
|
71 |
{
|
72 |
try
|
73 |
{
|
74 |
progressDialog2 = ProgressDialog.show(ZANaviAboutPage.this, "", Navit.get_text("reading crash info ..."));
|
75 |
|
76 |
progressDialog2.setCanceledOnTouchOutside(false);
|
77 |
progressDialog2.setOnCancelListener(new DialogInterface.OnCancelListener()
|
78 |
{
|
79 |
@Override
|
80 |
public void onCancel(DialogInterface dialog)
|
81 |
{
|
82 |
}
|
83 |
});
|
84 |
|
85 |
// get logcat messages ----------------
|
86 |
Logging x = new Logging();
|
87 |
Logging.delegate = ZANaviAboutPage.this;
|
88 |
x.new PopulateLogcatAsyncTask(ZANaviAboutPage.this.getApplicationContext()).execute();
|
89 |
// get logcat messages ----------------
|
90 |
|
91 |
}
|
92 |
catch (Exception e)
|
93 |
{
|
94 |
}
|
95 |
}
|
96 |
});
|
97 |
ap.addItem(e001);
|
98 |
|
99 |
ap.addItem(getCopyRightsElement());
|
100 |
|
101 |
View aboutPage = ap.create();
|
102 |
setContentView(aboutPage);
|
103 |
}
|
104 |
|
105 |
@SuppressLint("DefaultLocale")
|
106 |
Element getCopyRightsElement()
|
107 |
{
|
108 |
Element copyRightsElement = new Element();
|
109 |
// final String copyrights = String.format("Copyright © %1$d", Calendar.getInstance().get(Calendar.YEAR));
|
110 |
final String copyrights = String.format("Copyright © 2016");
|
111 |
copyRightsElement.setTitle(copyrights);
|
112 |
copyRightsElement.setColor(ContextCompat.getColor(this, mehdi.sakout.aboutpage.R.color.about_item_icon_color));
|
113 |
copyRightsElement.setGravity(Gravity.CENTER);
|
114 |
copyRightsElement.setOnClickListener(new View.OnClickListener()
|
115 |
{
|
116 |
@Override
|
117 |
public void onClick(View v)
|
118 |
{
|
119 |
Toast.makeText(ZANaviAboutPage.this, copyrights, Toast.LENGTH_SHORT).show();
|
120 |
}
|
121 |
});
|
122 |
return copyRightsElement;
|
123 |
}
|
124 |
|
125 |
@Override
|
126 |
public void processFinish(String output_part1)
|
127 |
{
|
128 |
String output = output_part1 + System.getProperty("line.separator") + System.getProperty("line.separator") + "LastStackTrace:" + System.getProperty("line.separator") + ZANaviMainApplication.last_stack_trace_as_string;
|
129 |
ZANaviMainApplication.last_stack_trace_as_string = ""; // reset last stacktrace
|
130 |
|
131 |
System.out.println("ZANaviAboutPage:" + "processFinish");
|
132 |
|
133 |
String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
|
134 |
String full_file_name = Navit.NAVIT_DATA_DEBUG_DIR + "/crashlog_" + date + ".txt";
|
135 |
String full_file_name_suppl = Navit.NAVIT_DATA_DEBUG_DIR + "/crashlog_single.txt";
|
136 |
String feedback_text = Navit.get_text("Crashlog") + "\n" + Navit.get_text("You can use our PGP-Key") + ": " + Navit.PGP_KEY_ID;
|
137 |
|
138 |
System.out.println("crashlogfile=" + full_file_name);
|
139 |
|
140 |
ZANaviLogMessages.am(ZANaviLogMessages.STATUS_INFO, "ZANaviAboutPage:" + "crashlogfile=" + full_file_name);
|
141 |
|
142 |
Logging.writeToFile(output, ZANaviAboutPage.this, full_file_name);
|
143 |
|
144 |
String subject_d_version = "";
|
145 |
if (Navit.Navit_DonateVersion_Installed)
|
146 |
{
|
147 |
subject_d_version = subject_d_version + "D,";
|
148 |
}
|
149 |
|
150 |
if (Navit.Navit_Largemap_DonateVersion_Installed)
|
151 |
{
|
152 |
subject_d_version = subject_d_version + "L,";
|
153 |
}
|
154 |
|
155 |
try
|
156 |
{
|
157 |
int rl = Navit.get_reglevel();
|
158 |
|
159 |
if (rl > 0)
|
160 |
{
|
161 |
subject_d_version = "U" + rl + ",";
|
162 |
}
|
163 |
}
|
164 |
catch (Exception e)
|
165 |
{
|
166 |
e.printStackTrace();
|
167 |
}
|
168 |
|
169 |
String FD_addon = "";
|
170 |
if (Navit.FDBL)
|
171 |
{
|
172 |
FD_addon = ",FD";
|
173 |
}
|
174 |
|
175 |
try
|
176 |
{
|
177 |
new Handler().post(new Runnable()
|
178 |
{
|
179 |
@Override
|
180 |
public void run()
|
181 |
{
|
182 |
progressDialog2.dismiss();
|
183 |
System.out.println("ZANaviAboutPage:" + "progressDialog2.dismiss()");
|
184 |
}
|
185 |
});
|
186 |
}
|
187 |
catch (Exception ee)
|
188 |
{
|
189 |
}
|
190 |
|
191 |
Navit.Global_Navit_Object.sendEmailWithAttachment(this, "feedback@zanavi.cc", "ZANavi Crashlog (v:" + subject_d_version + FD_addon + Navit.NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text, full_file_name, full_file_name_suppl);
|
192 |
|
193 |
// reset message
|
194 |
ZANaviMainApplication.last_stack_trace_as_string = "";
|
195 |
PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).edit().putString("last_crash_text", ZANaviMainApplication.last_stack_trace_as_string).commit();
|
196 |
|
197 |
// reset flag
|
198 |
Navit.intro_flag_crash = false;
|
199 |
}
|
200 |
}
|