1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package com
.owncloud
.android
.ui
.activity
;
21 import java
.util
.ArrayList
;
23 import android
.content
.Intent
;
24 import android
.os
.Bundle
;
25 import android
.preference
.Preference
;
26 import android
.preference
.Preference
.OnPreferenceChangeListener
;
27 import android
.view
.View
;
28 import android
.view
.View
.OnClickListener
;
29 import android
.widget
.Button
;
30 import android
.widget
.ListView
;
32 import com
.actionbarsherlock
.app
.ActionBar
;
33 import com
.actionbarsherlock
.app
.SherlockPreferenceActivity
;
34 import com
.actionbarsherlock
.view
.MenuItem
;
35 import com
.owncloud
.android
.R
;
36 import com
.owncloud
.android
.ui
.adapter
.LogListAdapter
;
37 import com
.owncloud
.android
.utils
.FileStorageUtils
;
41 public class LogHistoryActivity
extends SherlockPreferenceActivity
implements OnPreferenceChangeListener
{
42 String logpath
= FileStorageUtils
.getLogPath();
46 protected void onCreate(Bundle savedInstanceState
) {
47 super.onCreate(savedInstanceState
);
49 setContentView(R
.layout
.log_send_file
);
50 setTitle("Log History");
51 ActionBar actionBar
= getSherlock().getActionBar();
52 actionBar
.setDisplayHomeAsUpEnabled(true
);
53 ListView listView
= (ListView
) findViewById(android
.R
.id
.list
);
54 Button deleteHistoryButton
= (Button
) findViewById(R
.id
.deleteLogHistoryButton
);
55 deleteHistoryButton
.setOnClickListener(new OnClickListener() {
58 public void onClick(View v
) {
59 File dir
= new File(logpath
);
61 File
[] files
= dir
.listFiles();
69 Intent intent
= new Intent(getBaseContext(), Preferences
.class);
70 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
71 startActivity(intent
);
78 logDIR
= new File(logpath
);
81 if(logDIR
!= null
&& logDIR
.isDirectory()) {
82 File
[] files
= logDIR
.listFiles();
84 if (files
!= null
&& files
.length
!= 0) {
85 ArrayList
<String
> logfiles_name
= new ArrayList
<String
>();
86 for (File file
: files
) {
87 logfiles_name
.add(file
.getName());
89 String
[] logFiles2Array
= logfiles_name
.toArray(new String
[logfiles_name
.size()]);
90 LogListAdapter listadapter
= new LogListAdapter(this,logFiles2Array
);
91 listView
.setAdapter(listadapter
);
98 public boolean onMenuItemSelected(int featureId
, MenuItem item
) {
99 super.onMenuItemSelected(featureId
, item
);
102 switch (item
.getItemId()) {
104 case android
.R
.id
.home
:
105 intent
= new Intent(getBaseContext(), Preferences
.class);
106 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
107 startActivity(intent
);
115 public boolean onPreferenceChange(Preference arg0
, Object arg1
) {