1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-12-22 19:08:03 +01:00

Added long click action to Debug Log. User can copy log to clipboard using long click

This commit is contained in:
vanitasvitae 2016-09-09 19:50:11 +02:00
parent 83ea03ab60
commit 1b06e20c84
4 changed files with 30 additions and 8 deletions

View file

@ -18,6 +18,8 @@
*/
package com.github.dfa.diaspora_android.activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@ -36,6 +38,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R;
@ -204,7 +207,20 @@ public class AboutActivity extends AppCompatActivity {
TextView deviceName = (TextView) rootView.findViewById(R.id.fragment_debug__device_name);
TextView podDomain = (TextView) rootView.findViewById(R.id.fragment_debug__pod_domain);
logBox = (TextView) rootView.findViewById(R.id.fragment_debug__log_box);
logBox.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Log.d(App.TAG, "Long click registered");
if(isAdded()) {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("DEBUG_LOG", Log.getLogBuffer());
clipboard.setPrimaryClip(clip);
Toast.makeText(DebugFragment.this.getActivity(), R.string.fragment_debug__toast_log_copied, Toast.LENGTH_SHORT).show();
}
else Log.d(App.TAG, "Not Added!");
return true;
}
});
Log.addLogObserver(this);
update(Log.getInstance(), null);
@ -237,12 +253,7 @@ public class AboutActivity extends AppCompatActivity {
@Override
public void update(Observable observable, Object o) {
if(logBox != null) {
ArrayList<String> logs = Log.getLogBuffer();
String log = "";
for(String s : logs) {
log = log + s+"\n";
}
logBox.setText(log);
logBox.setText(Log.getLogBuffer());
}
}
}

View file

@ -76,10 +76,18 @@ public class Log extends Observable{
l.notifyLogBufferChanged();
}
public static ArrayList<String> getLogBuffer() {
public static ArrayList<String> getLogBufferArray() {
return getInstance().logBuffer;
}
public static String getLogBuffer() {
String out = "";
for(String s : getInstance().logBuffer) {
out = out + s + "\n";
}
return out;
}
private void notifyLogBufferChanged() {
if(observers == null) return;
for(Observer o : observers) {

View file

@ -85,6 +85,8 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:longClickable="true"
android:id="@+id/fragment_debug__log_box" />
</HorizontalScrollView>
</ScrollView>

View file

@ -19,6 +19,7 @@
<string name="fragment_debug__android_version">Android Version: %1$s</string>
<string name="fragment_debug__device_name">Device Name: %1$s</string>
<string name="fragment_debug__pod_domain">Pod Domain: %1$s</string>
<string name="fragment_debug__toast_log_copied">Debug log copied to clipboard</string>
<string name="fragment_license__3rd_party_libs_title">Used 3rd Party Libraries</string>