-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- \r
- ownCloud Android client application\r
-\r
- Copyright (C) 2012 Bartek Przybylski\r
- Copyright (C) 2012-2013 ownCloud Inc.\r
-\r
- This program is free software: you can redistribute it and/or modify\r
- it under the terms of the GNU General Public License as published by\r
- the Free Software Foundation, either version 2 of the License, or\r
- (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- -->\r
-<manifest package="com.owncloud.android"\r
- android:versionCode="103020"\r
- android:versionName="1.3.20" xmlns:android="http://schemas.android.com/apk/res/android">\r
-\r
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />\r
- <uses-permission android:name="android.permission.USE_CREDENTIALS" />\r
- <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />\r
- <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />\r
- <uses-permission android:name="android.permission.INTERNET" />\r
- <uses-permission android:name="android.permission.WRITE_SETTINGS" />\r
- <uses-permission android:name="android.permission.READ_SYNC_STATS" />\r
- <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />\r
- <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />\r
- <uses-permission android:name="android.permission.BROADCAST_STICKY" />\r
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />\r
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />\r
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>\r
-\r
- <uses-sdk\r
- android:minSdkVersion="8"\r
- android:targetSdkVersion="13" />\r
-\r
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >\r
- </uses-permission>\r
-\r
- <application\r
- android:icon="@drawable/icon"\r
- android:label="@string/app_name"\r
- android:theme="@style/Theme.ownCloud"> \r
- <activity\r
- android:name=".ui.activity.FileDisplayActivity"\r
- android:label="@string/app_name">\r
- <intent-filter>\r
- <action android:name="android.intent.action.MAIN" />\r
-\r
- <category android:name="android.intent.category.LAUNCHER" />\r
- </intent-filter>\r
- </activity>\r
- <activity android:name=".ui.activity.UploadFilesActivity">\r
- </activity>\r
- <activity android:name=".ui.activity.InstantUploadActivity">\r
- </activity>\r
- <activity android:name=".Uploader" >\r
- <intent-filter>\r
- <action android:name="android.intent.action.SEND" >\r
- </action>\r
-\r
- <category android:name="android.intent.category.DEFAULT" >\r
- </category>\r
-\r
- <data android:mimeType="*/*" >\r
- </data>\r
- </intent-filter>\r
- <intent-filter>\r
- <action android:name="android.intent.action.SEND_MULTIPLE" >\r
- </action>\r
-\r
- <category android:name="android.intent.category.DEFAULT" >\r
- </category>\r
-\r
- <data android:mimeType="*/*" >\r
- </data>\r
- </intent-filter>\r
- </activity>\r
- <activity\r
- android:name=".ui.activity.Preferences"\r
- android:theme="@style/Theme.ownCloud" >\r
- </activity>\r
- <activity android:name=".ui.activity.PreferencesNewSessionewSession" >\r
- </activity>\r
-\r
- <service\r
- android:name=".authenticator.AccountAuthenticatorService"\r
- android:exported="true">\r
- <intent-filter android:priority="100">\r
- <action android:name="android.accounts.AccountAuthenticator" />\r
- </intent-filter>\r
-\r
- <meta-data\r
- android:name="android.accounts.AccountAuthenticator"\r
- android:resource="@xml/authenticator" />\r
- </service>\r
- <service\r
- android:name=".syncadapter.FileSyncService"\r
- android:exported="true" >\r
- <intent-filter>\r
- <action android:name="android.content.SyncAdapter" />\r
- </intent-filter>\r
-\r
- <meta-data\r
- android:name="android.content.SyncAdapter"\r
- android:resource="@xml/syncadapter_files" />\r
- </service>\r
-\r
- <provider\r
- android:name=".providers.FileContentProvider"\r
- android:authorities="org.owncloud"\r
- android:enabled="true"\r
- android:exported="false"\r
- android:label="@string/sync_string_files"\r
- android:syncable="true" >\r
- </provider>\r
-\r
- <activity\r
- android:name=".ui.activity.AuthenticatorActivity"\r
- android:exported="true"\r
- android:theme="@style/Theme.ownCloud.noActionBar" >\r
- <intent-filter>\r
- <action android:name="com.owncloud.android.workaround.accounts.CREATE" />\r
- <category android:name="android.intent.category.DEFAULT" />\r
- </intent-filter>\r
- </activity>\r
-\r
- <service android:name=".files.services.FileDownloader" >\r
- </service>\r
-\r
- <activity android:name=".ui.activity.FileDetailActivity" />\r
- <activity android:name=".ui.activity.PinCodeActivity" />\r
- <activity android:name=".extensions.ExtensionsAvailableActivity"></activity>\r
- <activity android:name=".extensions.ExtensionsListActivity"></activity>\r
- <activity android:name=".ui.activity.AccountSelectActivity" android:uiOptions="none" android:label="@string/prefs_accounts"></activity>\r
- <activity android:name=".ui.activity.ConflictsResolveActivity"/>\r
- <activity android:name=".ui.activity.GenericExplanationActivity"/>\r
- <activity android:name=".ui.activity.ErrorsWhileCopyingHandlerActivity"/>\r
- \r
- <service android:name=".files.services.FileUploader" >\r
- </service>\r
- <service android:name=".files.services.InstantUploadService" />\r
- <receiver android:name=".files.InstantUploadBroadcastReceiver">\r
- <intent-filter>\r
- <action android:name="com.android.camera.NEW_PICTURE" />\r
- <data android:mimeType="image/*" />\r
- </intent-filter>\r
- <intent-filter>\r
- <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>\r
- </intent-filter>\r
- </receiver>\r
- <receiver android:name=".files.BootupBroadcastReceiver">\r
- <intent-filter>\r
- <action android:name="android.intent.action.BOOT_COMPLETED"/>\r
- </intent-filter>\r
- </receiver>\r
- <service android:name=".files.services.FileObserverService"/>\r
- </application>\r
-\r
-</manifest>\r
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ownCloud Android client application
+
+ Copyright (C) 2012 Bartek Przybylski
+ Copyright (C) 2012-2013 ownCloud Inc.
+
+ 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.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -->
+<manifest package="com.owncloud.android"
+ android:versionCode="103020"
+ android:versionName="1.3.20" xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+ <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+ <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+ <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+ <uses-permission android:name="android.permission.READ_SYNC_STATS" />
+ <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
+ <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+ <uses-permission android:name="android.permission.BROADCAST_STICKY" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="13" />
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
+ </uses-permission>
+
+ <application
+ android:icon="@drawable/icon"
+ android:label="@string/app_name"
+ android:theme="@style/Theme.ownCloud">
+ <activity
+ android:name=".ui.activity.FileDisplayActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".ui.activity.UploadFilesActivity">
+ </activity>
+ <activity android:name=".ui.activity.InstantUploadActivity">
+ </activity>
+ <activity android:name=".Uploader" >
+ <intent-filter>
+ <action android:name="android.intent.action.SEND" >
+ </action>
+
+ <category android:name="android.intent.category.DEFAULT" >
+ </category>
+
+ <data android:mimeType="*/*" >
+ </data>
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.SEND_MULTIPLE" >
+ </action>
+
+ <category android:name="android.intent.category.DEFAULT" >
+ </category>
+
+ <data android:mimeType="*/*" >
+ </data>
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".ui.activity.Preferences"
+ android:theme="@style/Theme.ownCloud" >
+ </activity>
+ <activity android:name=".ui.activity.PreferencesNewSessionewSession" >
+ </activity>
+
+ <service
+ android:name=".authenticator.AccountAuthenticatorService"
+ android:exported="true">
+ <intent-filter android:priority="100">
+ <action android:name="android.accounts.AccountAuthenticator" />
+ </intent-filter>
+
+ <meta-data
+ android:name="android.accounts.AccountAuthenticator"
+ android:resource="@xml/authenticator" />
+ </service>
+ <service
+ android:name=".syncadapter.FileSyncService"
+ android:exported="true" >
+ <intent-filter>
+ <action android:name="android.content.SyncAdapter" />
+ </intent-filter>
+
+ <meta-data
+ android:name="android.content.SyncAdapter"
+ android:resource="@xml/syncadapter_files" />
+ </service>
+
+ <provider
+ android:name=".providers.FileContentProvider"
+ android:authorities="org.owncloud"
+ android:enabled="true"
+ android:exported="false"
+ android:label="@string/sync_string_files"
+ android:syncable="true" >
+ </provider>
+
+ <activity
+ android:name=".ui.activity.AuthenticatorActivity"
+ android:exported="true"
+ android:theme="@style/Theme.ownCloud.noActionBar" >
+ <intent-filter>
+ <action android:name="com.owncloud.android.workaround.accounts.CREATE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
+ <service android:name=".files.services.FileDownloader" >
+ </service>
+
+ <activity android:name=".ui.activity.FileDetailActivity" />
+ <activity android:name=".ui.activity.PinCodeActivity" />
+ <activity android:name=".extensions.ExtensionsAvailableActivity"></activity>
+ <activity android:name=".extensions.ExtensionsListActivity"></activity>
+ <activity android:name=".ui.activity.AccountSelectActivity" android:uiOptions="none" android:label="@string/prefs_accounts"></activity>
+ <activity android:name=".ui.activity.ConflictsResolveActivity"/>
+ <activity android:name=".ui.activity.GenericExplanationActivity"/>
+ <activity android:name=".ui.activity.ErrorsWhileCopyingHandlerActivity"/>
+ <activity android:name=".ui.activity.LogHistoryActivity"/>
+
+ <service android:name=".files.services.FileUploader" >
+ </service>
+ <service android:name=".files.services.InstantUploadService" />
+ <receiver android:name=".files.InstantUploadBroadcastReceiver">
+ <intent-filter>
+ <action android:name="com.android.camera.NEW_PICTURE" />
+ <data android:mimeType="image/*" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
+ </intent-filter>
+ </receiver>
+ <receiver android:name=".files.BootupBroadcastReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED"/>
+ </intent-filter>
+ </receiver>
+ <service android:name=".files.services.FileObserverService"/>
+ </application>
+
+</manifest>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal" >
+
+ <TextView android:id="@+id/log_item_single"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="center_vertical"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
+ android:textStyle="bold"
+ android:textSize="22dp"
+ android:textColor="#000000"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp" />
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+ <LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="8dp"
+ android:paddingRight="8dp">
+
+
+ <ListView android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ />
+
+ <TextView android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#FF0000"
+ android:text="No data"/>
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="bottom">
+
+ <Button android:id="@+id/deleteLogHistoryButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/prefs_log_delete_history_button"/>
+
+ </LinearLayout>
+
+ </LinearLayout>
<string name="prefs_instant_upload_summary">Instantly upload photos taken by camera</string>
<string name="prefs_log_title">Enable Logging</string>
<string name="prefs_log_summary">This is used to log problems</string>
+ <string name="prefs_log_title_history">Logging History</string>
+ <string name="prefs_log_summary_history">This shows the recorded logs</string>
+ <string name="prefs_log_delete_history_button">Delete History</string>
+
<string name="auth_host_url">URL</string>
<string name="auth_username">Username</string>
<string name="auth_password">Password</string>
<item>60</item>
</string-array>
- <string name="auth_trying_to_login">Trying to login…</string>
+ <string name="auth_trying_to_login">Trying to login...</string>
<string name="auth_no_net_conn_title">No network connection</string>
<string name="auth_no_net_conn_message">No network connection has been detected, check your Internet connection and try again.</string>
<string name="auth_connect_anyway">Connect anyway</string>
<string name="auth_nossl_plain_ok_title">Secure connection unavailable.</string>
<string name="auth_nossl_plain_ok_message">The Application cannot establish a secure connection to the server. A non secure connection is available. You may continue or cancel.</string>
<string name="auth_connection_established">Connection established</string>
- <string name="auth_testing_connection">Testing connection…</string>
+ <string name="auth_testing_connection">Testing connection...</string>
<string name="auth_not_configured_title">Malformed server configuration</string>
<string name="auth_not_configured_message">It seems that your server instance is not correctly configured. Contact your administrator for more details.</string>
<string name="auth_unknown_error_title">Unknown error occurred!</string>
<CheckBoxPreference android:key="instant_uploading"
android:title="@string/prefs_instant_upload"
android:summary="@string/prefs_instant_upload_summary"/>
- <CheckBoxPreference android:dependency="instant_uploading" android:disableDependentsState="true" android:title="@string/instant_upload_on_wifi" android:key="instant_upload_on_wifi"/>
- <Preference android:id="@+id/about_app"
- android:title="@string/about_title"
- android:key="about_app" />
+ <CheckBoxPreference android:dependency="instant_uploading"
+ android:disableDependentsState="true"
+ android:title="@string/instant_upload_on_wifi"
+ android:key="instant_upload_on_wifi"/>
<CheckBoxPreference android:key="log_to_file"
android:title="@string/prefs_log_title"
android:summary="@string/prefs_log_summary"/>
+ <Preference android:key="log_history"
+ android:title="@string/prefs_log_title_history"
+ android:summary="@string/prefs_log_summary_history"/>
+ <Preference android:id="@+id/about_app"
+ android:title="@string/about_title"
+ android:key="about_app" />
</PreferenceCategory>
import android.util.Log;
+
public class Log_OC {
+
private static boolean isEnabled = false;
private static File logFile;
private static File folder;
}
public static void startLogging(String logPath) {
-
- folder = new File(logPath+File.separator+"log");
+ folder = new File(logPath);
logFile = new File(folder+File.separator+"log.txt");
if (!folder.exists()) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss",Locale.getDefault());
String currentDateandTime = sdf.format(new Date());
if (logFile != null) {
- logFile.renameTo(new File(folder+File.separator+"log_"+currentDateandTime));
+ logFile.renameTo(new File(folder+File.separator+"Owncloud_"+currentDateandTime+".log"));
+
isEnabled = false;
try {
buf.close();
buf.newLine();
} catch (IOException e) {
e.printStackTrace();
- }
- }
+ }
+ }
}
private SQLiteDatabase mDB;
private OpenerHelper mHelper;
private final String mDatabaseName = "ownCloud";
- private final int mDatabaseVersion = 2;
+ private final int mDatabaseVersion = 3;
private final String TABLE_INSTANT_UPLOAD = "instant_upload";
--- /dev/null
+/* ownCloud Android client application
+ * Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.ui.activity;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Environment;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.ListView;
+
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockPreferenceActivity;
+import com.actionbarsherlock.view.MenuItem;
+import com.owncloud.android.R;
+import com.owncloud.android.ui.adapter.LogListAdapter;
+
+
+
+public class LogHistoryActivity extends SherlockPreferenceActivity implements OnPreferenceChangeListener {
+ String logpath = Environment.getExternalStorageDirectory()+File.separator+"owncloud"+File.separator+"log";
+ File logDIR = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.log_send_file);
+ setTitle("Log History");
+ ActionBar actionBar = getSherlock().getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ ListView listView = (ListView) findViewById(android.R.id.list);
+ Button deleteHistoryButton = (Button) findViewById(R.id.deleteLogHistoryButton);
+ deleteHistoryButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ File dir = new File(logpath);
+ if (dir != null) {
+ File[] files = dir.listFiles();
+ if(files!=null) {
+ for(File f: files) {
+ f.delete();
+ }
+ }
+ dir.delete();
+ }
+ Intent intent = new Intent(getBaseContext(), Preferences.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+ }
+
+ });
+
+
+ if(logpath != null){
+ logDIR = new File(logpath);
+ }
+
+ if(logDIR != null && logDIR.isDirectory()) {
+ File[] files = logDIR.listFiles();
+
+ if (files != null && files.length != 0) {
+ ArrayList<String> logfiles_name = new ArrayList<String>();
+ for (File file : files) {
+ logfiles_name.add(file.getName());
+ }
+ String[] logFiles2Array = logfiles_name.toArray(new String[logfiles_name.size()]);
+ LogListAdapter listadapter = new LogListAdapter(this,logFiles2Array);
+ listView.setAdapter(listadapter);
+ }
+ }
+ }
+
+
+ @Override
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+ super.onMenuItemSelected(featureId, item);
+ Intent intent;
+
+ switch (item.getItemId()) {
+
+ case android.R.id.home:
+ intent = new Intent(getBaseContext(), Preferences.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+ @Override
+ public boolean onPreferenceChange(Preference arg0, Object arg1) {
+ return false;
+ }
+}
\ No newline at end of file
*/
package com.owncloud.android.ui.activity;
+import java.io.File;
import java.util.Vector;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
+import android.os.Environment;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
private CheckBoxPreference mDeviceTracking;
private CheckBoxPreference pCode;
private CheckBoxPreference pLogging;
+ private Preference pLoggingHistory;
private Preference pAboutApp;
private int mSelectedMenuItem;
Log_OC.e(TAG, "Error while showing about dialog", e);
}
}
- pLogging = (CheckBoxPreference) findPreference("log_to_file");
+ pLogging = (CheckBoxPreference) findPreference("log_to_file");
if (pLogging != null) {
pLogging.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- String logpath = getApplicationContext().getFilesDir().getAbsolutePath();
+ String logpath = Environment.getExternalStorageDirectory()+File.separator+"owncloud"+File.separator+"log";
if(!pLogging.isChecked()) {
Log_OC.d("Debug", "start logging");
return true;
}
});
+ }
+ pLoggingHistory = (Preference) findPreference("log_history");
+ if (pLoggingHistory != null) {
+ pLoggingHistory.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Intent intent = new Intent(getApplicationContext(),LogHistoryActivity.class);
+ startActivity(intent);
+ return true;
+ }
+ });
}
}
}
--- /dev/null
+package com.owncloud.android.ui.adapter;
+
+import java.io.File;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Environment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import com.owncloud.android.R;
+
+
+public class LogListAdapter extends ArrayAdapter<String> {
+ private Context context = null;
+ private String[] values;
+ private Uri fileUri = null;
+
+
+ public LogListAdapter(Context context, String[] values) {
+ super(context, R.layout.log_item, values);
+ this.context = context;
+ this.values = values;
+ }
+
+ @Override
+ public View getView(final int position, View convertView, ViewGroup parent) {
+ LayoutInflater inflater = (LayoutInflater) context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ View rowView = inflater.inflate(R.layout.log_item, parent, false);
+ TextView listText = (TextView) rowView.findViewById(R.id.log_item_single);
+ listText.setText(values[position]);
+ listText.setTextSize(15);
+ fileUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory()+File.separator+"owncloud"+File.separator+"log"+File.separator+values[position]));
+ listText.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
+ emailIntent.setType("text/rtf");
+ emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "OwnCloud Logfile");
+ emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is a automatic E-mail send by owncloud/android");
+ emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, fileUri);
+ emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
+ }
+ });
+ return rowView;
+ }
+}