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
.DisplayUtils
;
38 import com
.owncloud
.android
.utils
.FileStorageUtils
;
43 public class LogHistoryActivity
extends SherlockPreferenceActivity
implements OnPreferenceChangeListener
{
44 String logpath
= FileStorageUtils
.getLogPath();
48 protected void onCreate(Bundle savedInstanceState
) {
49 super.onCreate(savedInstanceState
);
51 setContentView(R
.layout
.log_send_file
);
52 setTitle("Log History");
53 ActionBar actionBar
= getSherlock().getActionBar();
54 actionBar
.setIcon(DisplayUtils
.getSeasonalIconId());
55 actionBar
.setDisplayHomeAsUpEnabled(true
);
56 ListView listView
= (ListView
) findViewById(android
.R
.id
.list
);
57 Button deleteHistoryButton
= (Button
) findViewById(R
.id
.deleteLogHistoryButton
);
59 deleteHistoryButton
.setOnClickListener(new OnClickListener() {
62 public void onClick(View v
) {
63 File dir
= new File(logpath
);
65 File
[] files
= dir
.listFiles();
73 Intent intent
= new Intent(getBaseContext(), Preferences
.class);
74 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
75 startActivity(intent
);
82 logDIR
= new File(logpath
);
85 if(logDIR
!= null
&& logDIR
.isDirectory()) {
86 File
[] files
= logDIR
.listFiles();
88 if (files
!= null
&& files
.length
!= 0) {
89 ArrayList
<String
> logfiles_name
= new ArrayList
<String
>();
90 for (File file
: files
) {
91 logfiles_name
.add(file
.getName());
93 String
[] logFiles2Array
= logfiles_name
.toArray(new String
[logfiles_name
.size()]);
94 LogListAdapter listadapter
= new LogListAdapter(this,logFiles2Array
);
95 listView
.setAdapter(listadapter
);
102 public boolean onMenuItemSelected(int featureId
, MenuItem item
) {
103 super.onMenuItemSelected(featureId
, item
);
106 switch (item
.getItemId()) {
108 case android
.R
.id
.home
:
109 intent
= new Intent(getBaseContext(), Preferences
.class);
110 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
111 startActivity(intent
);
119 public boolean onPreferenceChange(Preference arg0
, Object arg1
) {