Make logs copyable
This commit is contained in:
committed by
Jannis Mattheis
parent
df71fc1820
commit
13a889e195
@@ -1,5 +1,8 @@
|
|||||||
package com.github.gotify.log;
|
package com.github.gotify.log;
|
||||||
|
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -31,7 +34,7 @@ public class LogsActivity extends AppCompatActivity {
|
|||||||
private void updateLogs() {
|
private void updateLogs() {
|
||||||
new RefreshLogs().execute();
|
new RefreshLogs().execute();
|
||||||
if (!isDestroyed()) {
|
if (!isDestroyed()) {
|
||||||
handler.postDelayed(this::updateLogs, 1000);
|
handler.postDelayed(this::updateLogs, 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +52,13 @@ public class LogsActivity extends AppCompatActivity {
|
|||||||
if (item.getItemId() == R.id.action_delete_logs) {
|
if (item.getItemId() == R.id.action_delete_logs) {
|
||||||
Log.clear();
|
Log.clear();
|
||||||
}
|
}
|
||||||
|
if (item.getItemId() == R.id.action_copy_logs) {
|
||||||
|
TextView content = findViewById(R.id.log_content);
|
||||||
|
ClipboardManager clipboardManager =
|
||||||
|
(ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
ClipData clipData = ClipData.newPlainText("GotifyLog", content.getText().toString());
|
||||||
|
clipboardManager.setPrimaryClip(clipData);
|
||||||
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,8 @@
|
|||||||
android:title="@string/delete_logs"
|
android:title="@string/delete_logs"
|
||||||
android:id="@+id/action_delete_logs"
|
android:id="@+id/action_delete_logs"
|
||||||
android:orderInCategory="100"/>
|
android:orderInCategory="100"/>
|
||||||
|
<item
|
||||||
|
android:title="@string/copy_logs"
|
||||||
|
android:id="@+id/action_copy_logs"
|
||||||
|
android:orderInCategory="100"/>
|
||||||
</menu>
|
</menu>
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
<string name="grouped_message">Received %d messages while being disconnected</string>
|
<string name="grouped_message">Received %d messages while being disconnected</string>
|
||||||
<string name="delete_all">Delete all</string>
|
<string name="delete_all">Delete all</string>
|
||||||
<string name="delete_logs">Delete logs</string>
|
<string name="delete_logs">Delete logs</string>
|
||||||
|
<string name="copy_logs">Copy logs</string>
|
||||||
<string name="snackbar_deleted">Message deleted</string>
|
<string name="snackbar_deleted">Message deleted</string>
|
||||||
<string name="snackbar_undo">Undo</string>
|
<string name="snackbar_undo">Undo</string>
|
||||||
<string name="all_messages">All Messages</string>
|
<string name="all_messages">All Messages</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user