Menu option added that allows users to send the log file
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012 Tobias Brunner
|
||||
Hochschule fuer Technik Rapperswil
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_send_log"
|
||||
android:title="@string/send_log"
|
||||
android:showAsAction="ifRoom|withText" />
|
||||
|
||||
</menu>
|
||||
@@ -25,6 +25,9 @@
|
||||
|
||||
<!-- Log view -->
|
||||
<string name="log_title">Log</string>
|
||||
<string name="send_log">Logdatei senden</string>
|
||||
<string name="empty_log">Logdatei ist leer</string>
|
||||
<string name="log_mail_subject">strongSwan %1$s Logdatei</string>
|
||||
|
||||
<!-- VPN profile list -->
|
||||
<string name="no_profiles">Keine VPN Profile vorhanden.</string>
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
|
||||
<!-- Log view -->
|
||||
<string name="log_title">Log</string>
|
||||
<string name="send_log">Send log file</string>
|
||||
<string name="empty_log">Log file is empty</string>
|
||||
<string name="log_mail_subject">strongSwan %1$s Log File</string>
|
||||
|
||||
<!-- VPN profile list -->
|
||||
<string name="no_profiles">No VPN profiles.</string>
|
||||
|
||||
@@ -15,11 +15,19 @@
|
||||
|
||||
package org.strongswan.android.ui;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.strongswan.android.R;
|
||||
import org.strongswan.android.data.LogContentProvider;
|
||||
import org.strongswan.android.logic.CharonVpnService;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class LogActivity extends Activity
|
||||
{
|
||||
@@ -32,6 +40,13 @@ public class LogActivity extends Activity
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
{
|
||||
getMenuInflater().inflate(R.menu.log, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
@@ -40,6 +55,31 @@ public class LogActivity extends Activity
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
case R.id.menu_send_log:
|
||||
File logfile = new File(getFilesDir(), CharonVpnService.LOG_FILE);
|
||||
if (!logfile.exists() || logfile.length() == 0)
|
||||
{
|
||||
Toast.makeText(this, getString(R.string.empty_log), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
String version = "";
|
||||
try
|
||||
{
|
||||
version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
||||
}
|
||||
catch (NameNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { MainActivity.CONTACT_EMAIL });
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, String.format(getString(R.string.log_mail_subject), version));
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_STREAM, LogContentProvider.createContentUri());
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.send_log)));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import android.widget.EditText;
|
||||
|
||||
public class MainActivity extends Activity implements OnVpnProfileSelectedListener
|
||||
{
|
||||
public static final String CONTACT_EMAIL = "[email protected]";
|
||||
private static final int PREPARE_VPN_SERVICE = 0;
|
||||
private VpnProfile activeProfile;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user