X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/18a715072c2c12d9779586ec171c7301207a53fd..5dc43aab3cc1243f9989dd6a0c7dd3350c3f709b:/src/com/owncloud/android/ui/activity/Preferences.java diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index 35638c5e..b49bcb68 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -3,9 +3,8 @@ * 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. + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,6 +17,7 @@ */ package com.owncloud.android.ui.activity; +import java.io.File; import java.util.Vector; import android.content.Intent; @@ -25,18 +25,19 @@ import android.content.SharedPreferences; 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; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceManager; -import android.util.Log; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockPreferenceActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; +import com.owncloud.android.Log_OC; import com.owncloud.android.OwnCloudSession; import com.owncloud.android.R; import com.owncloud.android.db.DbHandler; @@ -57,9 +58,12 @@ public class Preferences extends SherlockPreferenceActivity implements OnPrefere private ListPreference mTrackingUpdateInterval; private CheckBoxPreference mDeviceTracking; private CheckBoxPreference pCode; + private CheckBoxPreference pLogging; + private Preference pLoggingHistory; private Preference pAboutApp; private int mSelectedMenuItem; + @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { @@ -97,16 +101,51 @@ public class Preferences extends SherlockPreferenceActivity implements OnPrefere /* About App */ pAboutApp = (Preference) findPreference("about_app"); if (pAboutApp != null) { - pAboutApp.setTitle(getString(R.string.app_name)+" "+getString(R.string.about_android)); + pAboutApp.setTitle(String.format(getString(R.string.about_android), getString(R.string.app_name))); PackageInfo pkg; try { pkg = getPackageManager().getPackageInfo(getPackageName(), 0); - pAboutApp.setSummary(getString(R.string.about_version)+" "+pkg.versionName); + pAboutApp.setSummary(String.format(getString(R.string.about_version), pkg.versionName)); } catch (NameNotFoundException e) { - Log.e(TAG, "Error while showing about dialog", e); + Log_OC.e(TAG, "Error while showing about dialog", e); } - } - } + } + + pLogging = (CheckBoxPreference) findPreference("log_to_file"); + if (pLogging != null) { + pLogging.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + + String logpath = Environment.getExternalStorageDirectory()+File.separator+"owncloud"+File.separator+"log"; + + if(!pLogging.isChecked()) { + Log_OC.d("Debug", "start logging"); + Log_OC.v("PATH", logpath); + Log_OC.startLogging(logpath); + } + else { + Log_OC.d("Debug", "stop logging"); + Log_OC.stopLogging(); + } + 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; + } + }); + } + } } @Override @@ -150,7 +189,7 @@ public class Preferences extends SherlockPreferenceActivity implements OnPrefere startActivity(intent); break; default: - Log.w(TAG, "Unknown menu item triggered"); + Log_OC.w(TAG, "Unknown menu item triggered"); return false; } return true;