[Android] Revert "remove dump_logcat (use log console instead)"
Edward Wang
git at videolan.org
Wed Aug 26 07:27:29 CEST 2015
vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sat Feb 21 01:05:43 2015 -0800| [54a656f934fa3141cc684cd170d6b069e9c26f99] | committer: Edward Wang
Revert "remove dump_logcat (use log console instead)"
This reverts commit f0ee101ba49e2810aa4017fb9ea1f273de7de283.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=54a656f934fa3141cc684cd170d6b069e9c26f99
---
vlc-android/res/xml/preferences.xml | 7 +++-
.../org/videolan/vlc/gui/PreferencesActivity.java | 37 ++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index f2f86be..b605617 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -192,8 +192,13 @@
<PreferenceScreen
android:key="debug_logs"
android:title="@string/debug_logs" />
+
+ <Preference
+ android:enabled="true"
+ android:key="dump_logcat"
+ android:title="@string/dump_logcat" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
-</PreferenceScreen>
+</PreferenceScreen>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index 01a2648..cba2efa 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -28,6 +28,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.graphics.drawable.Drawable.ConstantState;
import android.os.Build;
import android.os.Bundle;
+import android.os.Environment;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
@@ -40,6 +41,7 @@ import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
+import android.text.format.DateFormat;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
@@ -47,14 +49,17 @@ import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.ListView;
+import android.widget.Toast;
import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
+import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.audio.AudioUtil;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.BitmapCache;
+import org.videolan.vlc.util.Logcat;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.VLCOptions;
@@ -226,6 +231,38 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
} else
quitAppPref.setEnabled(false);
+ Preference dumpLogcatLog = findPreference("dump_logcat");
+ dumpLogcatLog.setOnPreferenceClickListener(
+ new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+ Toast.makeText(PreferencesActivity.this,
+ R.string.dump_logcat_failure,
+ Toast.LENGTH_LONG).show();
+ return true;
+ }
+
+ CharSequence timestamp = DateFormat.format(
+ "yyyyMMdd_kkmmss", System.currentTimeMillis());
+ String filename = Environment.getExternalStorageDirectory().getPath() + "/vlc_logcat_" + timestamp + ".log";
+ try {
+ Logcat.writeLogcat(filename);
+ Toast.makeText(
+ PreferencesActivity.this,
+ String.format(
+ VLCApplication.getAppResources().getString(R.string.dump_logcat_success),
+ filename), Toast.LENGTH_LONG)
+ .show();
+ } catch (Exception e) {
+ Toast.makeText(PreferencesActivity.this,
+ R.string.dump_logcat_failure,
+ Toast.LENGTH_LONG).show();
+ }
+ return true;
+ }
+ });
+
// Audio output
ListPreference aoutPref = (ListPreference) findPreference("aout");
final HWDecoderUtil.AudioOutput aout = HWDecoderUtil.getAudioOutputFromDevice();
More information about the Android
mailing list