diff options
author | Arne Schwabe <arne@rfc2549.org> | 2015-06-23 12:05:39 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2015-06-23 12:06:28 +0200 |
commit | 6bd8414d8bea8166d7b00a65de1e7a06f5a1f58e (patch) | |
tree | c5d3896d740560446a08ff6e7fcdefd2a8470c91 /main/src | |
parent | 767c10de1f6d241b7d47050e50529f4af9806286 (diff) |
Reenable break pad support by default and display last dump date in crash fragment.
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/fragments/SendDumpFragment.java | 40 | ||||
-rw-r--r-- | main/src/main/res/layout/fragment_senddump.xml | 11 | ||||
-rwxr-xr-x | main/src/main/res/values/strings.xml | 1 |
3 files changed, 44 insertions, 8 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/SendDumpFragment.java b/main/src/main/java/de/blinkt/openvpn/fragments/SendDumpFragment.java index 831e3c5e..1838eeb3 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/SendDumpFragment.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/SendDumpFragment.java @@ -7,6 +7,7 @@ package de.blinkt.openvpn.fragments; import java.io.File; import java.util.ArrayList; +import java.util.Date; import android.app.Fragment; import android.content.Context; @@ -15,10 +16,13 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; import android.os.Bundle; +import android.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.TextView; + import de.blinkt.openvpn.R; import de.blinkt.openvpn.core.VpnStatus; @@ -28,7 +32,7 @@ public class SendDumpFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.fragment_senddump, container, false); + final View v = inflater.inflate(R.layout.fragment_senddump, container, false); v.findViewById(R.id.senddump).setOnClickListener(new OnClickListener() { @Override @@ -36,6 +40,28 @@ public class SendDumpFragment extends Fragment { emailMiniDumps(); } }); + + new Thread(new Runnable() { + @Override + public void run() { + final Pair<File, Long> ldump = getLastestDump(getActivity()); + if (ldump==null) + return; + // Do in background since it does I/O + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + TextView dumpDateText = (TextView) v.findViewById(R.id.dumpdate); + String datestr = (new Date(ldump.second)).toString(); + long timediff = System.currentTimeMillis() - ldump.second; + long minutes = timediff / 1000 / 60 % 60; + long hours = timediff / 1000 / 60 / 60; + dumpDateText.setText(getString(R.string.lastdumpdate, hours, minutes, datestr)); + + } + }); + } + }).start(); return v; } @@ -62,22 +88,22 @@ public class SendDumpFragment extends Fragment { emailIntent.putExtra(Intent.EXTRA_TEXT, "Please describe the issue you have experienced"); - ArrayList<Uri> uris = new ArrayList<Uri>(); + ArrayList<Uri> uris = new ArrayList<>(); - File ldump = getLastestDump(getActivity()); + Pair<File, Long> ldump = getLastestDump(getActivity()); if(ldump==null) { VpnStatus.logError("No Minidump found!"); } - uris.add(Uri.parse("content://de.blinkt.openvpn.FileProvider/" + ldump.getName())); - uris.add(Uri.parse("content://de.blinkt.openvpn.FileProvider/" + ldump.getName() + ".log")); + uris.add(Uri.parse("content://de.blinkt.openvpn.FileProvider/" + ldump.first.getName())); + uris.add(Uri.parse("content://de.blinkt.openvpn.FileProvider/" + ldump.first.getName() + ".log")); emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); startActivity(emailIntent); } - static public File getLastestDump(Context c) { + static public Pair<File,Long> getLastestDump(Context c) { long newestDumpTime=0; File newestDumpFile=null; @@ -97,6 +123,6 @@ public class SendDumpFragment extends Fragment { if(System.currentTimeMillis() - 48 * 60 * 1000 > newestDumpTime ) return null; - return newestDumpFile; + return Pair.create(newestDumpFile, newestDumpTime); } } diff --git a/main/src/main/res/layout/fragment_senddump.xml b/main/src/main/res/layout/fragment_senddump.xml index c9352a85..ff138e1d 100644 --- a/main/src/main/res/layout/fragment_senddump.xml +++ b/main/src/main/res/layout/fragment_senddump.xml @@ -5,11 +5,12 @@ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" android:id="@+id/RelativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" - android:orientation="vertical" > + android:orientation="vertical"> <Button android:id="@+id/senddump" @@ -22,8 +23,16 @@ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:id="@+id/send_minidump_summary" android:layout_below="@id/senddump" android:layout_centerHorizontal="true" android:text="@string/send_minidump_summary" /> + <TextView + android:id="@+id/dumpdate" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/send_minidump_summary" + android:layout_centerHorizontal="true" + tools:text="Last dump is 8237283892" /> </RelativeLayout>
\ No newline at end of file diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml index 1c474145..7db7fb94 100755 --- a/main/src/main/res/values/strings.xml +++ b/main/src/main/res/values/strings.xml @@ -383,5 +383,6 @@ <string name="service_restarted">Restarting OpenVPN Service (App crashed probably crashed or killed for memory pressure)</string> <string name="import_config_error">Importing the config yielded an error, cannot save it</string> <string name="Search">Search</string> + <string name="lastdumpdate">(Last dump is %1$d:%2$dh old (%3$s))</string> </resources> |