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 de
.mobilcom
.debitel
.cloud
.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
; 
  36 import de
.mobilcom
.debitel
.cloud
.android
.R
; 
  37 import de
.mobilcom
.debitel
.cloud
.android
.ui
.adapter
.LogListAdapter
; 
  38 import de
.mobilcom
.debitel
.cloud
.android
.utils
.FileStorageUtils
; 
  42 public class LogHistoryActivity 
extends SherlockPreferenceActivity 
implements OnPreferenceChangeListener 
{ 
  43     String logpath 
= FileStorageUtils
.getLogPath(); 
  47     protected void onCreate(Bundle savedInstanceState
) { 
  48         super.onCreate(savedInstanceState
); 
  50         setContentView(R
.layout
.log_send_file
); 
  51         setTitle("Log History"); 
  52         ActionBar actionBar 
= getSherlock().getActionBar(); 
  53         actionBar
.setDisplayHomeAsUpEnabled(true
); 
  54         ListView listView 
= (ListView
) findViewById(android
.R
.id
.list
); 
  55         Button deleteHistoryButton 
= (Button
) findViewById(R
.id
.deleteLogHistoryButton
); 
  57         // Set background of 'deleteHistory' button 
  58         boolean customButtons 
= getResources().getBoolean(R
.bool
.custom_buttons
); 
  60             deleteHistoryButton
.setBackgroundResource(R
.drawable
.btn_default
); 
  62         deleteHistoryButton
.setOnClickListener(new OnClickListener() { 
  65             public void onClick(View v
) { 
  66                 File dir 
= new File(logpath
); 
  68                     File
[] files 
= dir
.listFiles(); 
  76                 Intent intent 
= new Intent(getBaseContext(), Preferences
.class); 
  77                 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
); 
  78                 startActivity(intent
); 
  85         logDIR 
= new File(logpath
); 
  88         if(logDIR 
!= null 
&& logDIR
.isDirectory()) { 
  89             File
[] files 
= logDIR
.listFiles(); 
  91             if (files 
!= null 
&& files
.length 
!= 0) { 
  92                 ArrayList
<String
> logfiles_name 
= new ArrayList
<String
>(); 
  93                 for (File file 
: files
) { 
  94                     logfiles_name
.add(file
.getName()); 
  96                     String
[] logFiles2Array 
= logfiles_name
.toArray(new String
[logfiles_name
.size()]); 
  97                     LogListAdapter listadapter 
= new LogListAdapter(this,logFiles2Array
); 
  98                     listView
.setAdapter(listadapter
); 
 105     public boolean onMenuItemSelected(int featureId
, MenuItem item
) { 
 106         super.onMenuItemSelected(featureId
, item
); 
 109         switch (item
.getItemId()) { 
 111         case android
.R
.id
.home
: 
 112             intent 
= new Intent(getBaseContext(), Preferences
.class); 
 113             intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
); 
 114             startActivity(intent
); 
 122     public boolean onPreferenceChange(Preference arg0
, Object arg1
) {