2 * Copyright (C) 2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 package org
.strongswan
.android
.ui
;
20 import org
.strongswan
.android
.R
;
21 import org
.strongswan
.android
.data
.LogContentProvider
;
22 import org
.strongswan
.android
.logic
.CharonVpnService
;
24 import android
.app
.Activity
;
25 import android
.content
.Intent
;
26 import android
.content
.pm
.PackageManager
.NameNotFoundException
;
27 import android
.os
.Bundle
;
28 import android
.view
.Menu
;
29 import android
.view
.MenuItem
;
30 import android
.widget
.Toast
;
32 public class LogActivity
extends Activity
35 public void onCreate(Bundle savedInstanceState
)
37 super.onCreate(savedInstanceState
);
38 setContentView(R
.layout
.log_activity
);
40 getActionBar().setDisplayHomeAsUpEnabled(true);
44 public boolean onCreateOptionsMenu(Menu menu
)
46 getMenuInflater().inflate(R
.menu
.log
, menu
);
51 public boolean onOptionsItemSelected(MenuItem item
)
53 switch (item
.getItemId())
55 case android
.R
.id
.home
:
58 case R
.id
.menu_send_log
:
59 File logfile
= new File(getFilesDir(), CharonVpnService
.LOG_FILE
);
60 if (!logfile
.exists() || logfile
.length() == 0)
62 Toast
.makeText(this, getString(R
.string
.empty_log
), Toast
.LENGTH_SHORT
).show();
69 version
= getPackageManager().getPackageInfo(getPackageName(), 0).versionName
;
71 catch (NameNotFoundException e
)
76 Intent intent
= new Intent(Intent
.ACTION_SEND
);
77 intent
.putExtra(Intent
.EXTRA_EMAIL
, new String
[] { MainActivity
.CONTACT_EMAIL
});
78 intent
.putExtra(Intent
.EXTRA_SUBJECT
, String
.format(getString(R
.string
.log_mail_subject
), version
));
79 intent
.setType("text/plain");
80 intent
.putExtra(Intent
.EXTRA_STREAM
, LogContentProvider
.createContentUri());
81 startActivity(Intent
.createChooser(intent
, getString(R
.string
.send_log
)));
84 return super.onOptionsItemSelected(item
);