Commit dcad4823 authored by Edward Wang's avatar Edward Wang

Add logcat dumping option

Since Android 4.2 or so apps like Term.apk no longer work as each app unless rooted can only access its own logcat.

Hence, this commit provides an easier way to dump the logcat log than enabling developer options and connecting to a computer.
parent e3e65358
......@@ -237,6 +237,9 @@
<string name="set_locale_detail">Leave blank to reset</string>
<string name="set_locale_popup">Quit and reset VLC for changes to take effect.</string>
<string name="quit">Quit and restart application</string>
<string name="dump_logcat">Dump logcat log</string>
<string name="dump_logcat_success">Logcat successfully dumped to %1$s!</string>
<string name="dump_logcat_failure">Failed to dump logcat.</string>
<string-array name="hardware_acceleration_list">
<item>@string/automatic</item>
......
......@@ -126,6 +126,11 @@
android:enabled="true"
android:key="quit_app"
android:title="@string/quit" />
<Preference
android:enabled="true"
android:key="dump_logcat"
android:title="@string/dump_logcat" />
</PreferenceScreen>
</PreferenceCategory>
......
......@@ -27,6 +27,7 @@ import org.videolan.vlc.BitmapCache;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.R;
import org.videolan.vlc.Util;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.audio.AudioUtil;
import android.app.AlertDialog;
......@@ -36,6 +37,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.os.Environment;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
......@@ -45,6 +47,7 @@ import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.text.format.DateFormat;
import android.widget.Toast;
@SuppressWarnings("deprecation")
......@@ -174,6 +177,39 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
return true;
}
});
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 {
Util.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");
int aoutEntriesId = Util.isGingerbreadOrLater() ? R.array.aouts : R.array.aouts_froyo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment