diff options
Diffstat (limited to 'src/main/java/de/thedevstack/android/logcat/ui')
-rw-r--r-- | src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java | 27 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java | 42 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java new file mode 100644 index 00000000..bb49c54d --- /dev/null +++ b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputActivity.java @@ -0,0 +1,27 @@ +package de.thedevstack.android.logcat.ui; + +import android.app.Activity; +import android.os.Bundle; +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.R; + +/** + * Created by tzur on 07.10.2015. + */ +public class LogCatOutputActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_logcatoutput); + ListView lv = (ListView)findViewById(R.id.actLogInfoOutput); + LogCatArrayAdapter logCatOutputAdapter = new LogCatArrayAdapter(this, R.layout.list_item_logcatoutput); + lv.setAdapter(logCatOutputAdapter); + new ReadLogCatAsyncTask(logCatOutputAdapter).execute(); + Button copyButton = (Button) findViewById(R.id.actLogOutputCopyButton); + copyButton.setOnClickListener(new LogCatOutputCopyOnClickListener(this, logCatOutputAdapter)); + } +} diff --git a/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java new file mode 100644 index 00000000..da82fc7f --- /dev/null +++ b/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java @@ -0,0 +1,42 @@ +package de.thedevstack.android.logcat.ui; + +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.view.View; +import android.widget.Toast; + +import java.util.ArrayList; + +import de.thedevstack.android.logcat.adapters.LogCatArrayAdapter; +import de.thedevstack.conversationsplus.ConversationsPlusApplication; +import de.thedevstack.conversationsplus.R; + +/** + * Created by tzur on 20.11.2015. + */ +public class LogCatOutputCopyOnClickListener implements View.OnClickListener { + private final LogCatArrayAdapter logCatOutputAdapter; + private final Context context; + + public LogCatOutputCopyOnClickListener(Context context, LogCatArrayAdapter logCatOutputAdapter) { + this.logCatOutputAdapter = logCatOutputAdapter; + this.context = context; + } + + @Override + public void onClick(View v) { + ArrayList<String> items = this.logCatOutputAdapter.getItems(); + if (null != items && !items.isEmpty()) { + StringBuilder sb = new StringBuilder(); + for (String item : items) { + sb.append(item); + sb.append("\n"); + } + ClipboardManager clipboard = (ClipboardManager) ConversationsPlusApplication.getInstance().getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("c+logcat", sb.toString()); + clipboard.setPrimaryClip(clip); + Toast.makeText(this.context, R.string.cplus_copied_to_clipboard, Toast.LENGTH_LONG).show(); + } + } +} |