blob: a1f99a48511b91c79984ac2a172a1e2771ee4bb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package de.thedevstack.conversationsplus.ui;
import android.app.Activity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import de.thedevstack.android.logcat.adapters.LogCatArrayAdapter;
import de.thedevstack.android.logcat.tasks.ReadLogCatAsyncTask;
import de.thedevstack.conversationsplus.ui.listeners.LogCatOutputCopyOnClickListener;
import de.thedevstack.conversationsplus.utils.ClipboardUtil;
import eu.siacs.conversations.R;
/**
* Activity to display the logcat output.
*/
public class LogCatOutputActivity extends Activity {
/**
* List adapter containing the logcat entries.
*/
private LogCatArrayAdapter logCatArrayAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_logcatoutput);
ListView lv = (ListView)findViewById(R.id.actLogInfoOutput);
this.logCatArrayAdapter = new LogCatArrayAdapter(this, R.layout.list_item_logcatoutput);
lv.setAdapter(this.logCatArrayAdapter);
new ReadLogCatAsyncTask(this.logCatArrayAdapter).execute();
Button copyButton = (Button) findViewById(R.id.actLogOutputCopyButton);
copyButton.setOnClickListener(new LogCatOutputCopyOnClickListener(this.logCatArrayAdapter));
registerForContextMenu(lv);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, 123456789, 0, R.string.cplus_copy_item);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if (123456789 == item.getItemId()) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
String itemText = this.logCatArrayAdapter.getItems().get(info.position);
ClipboardUtil.copyToClipboard(itemText);
return true;
}
return super.onContextItemSelected(item);
}
}
|