// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void doVibrate(Vibrator v, int time) {
//     if (Build.VERSION.SDK_INT >= 26) {
//         v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
//     } else {
//         v.vibrate(time);
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String joinStr(List<String> list, String delim) {
//     String resultStr = "";
//     if (list.size() > 0) {
//         int i;
//         for (i = 0; i < list.size() - 1; i++) {
//             resultStr = resultStr.concat(list.get(i));
//             resultStr = resultStr.concat(delim);
//         }
//         resultStr = resultStr.concat(list.get(i));
//     }
//     return resultStr;
// }


import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Vibrator;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaUtils.doVibrate;
import static com.antest1.kcanotify.KcaUtils.joinStr;
        setContentView(R.layout.activity_errorlog);

        toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setTitle(R.string.action_errorlog);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);

        text = findViewById(R.id.errorlogview);
        text.setText("");
        text.setLongClickable(true);
        text.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                clip.setPrimaryClip(ClipData.newPlainText("text", ((TextView) v).getText()));
                doVibrate(vibrator, 100);
                Toast.makeText(getApplicationContext(), getStringWithLocale(R.string.copied_to_clipboard), Toast.LENGTH_LONG).show();
                return false;
            }
        });

        loadbtn = findViewById(R.id.error_load);
        loadbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                List<String> loglist = dbHelper.getErrorLog(SHOW_LIMIT, false);
                if (loglist.size() > 0) {
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void doVibrate(Vibrator v, int time) {
//     if (Build.VERSION.SDK_INT >= 26) {
//         v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
//     } else {
//         v.vibrate(time);
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String joinStr(List<String> list, String delim) {
//     String resultStr = "";
//     if (list.size() > 0) {
//         int i;
//         for (i = 0; i < list.size() - 1; i++) {
//             resultStr = resultStr.concat(list.get(i));
//             resultStr = resultStr.concat(delim);
//         }
//         resultStr = resultStr.concat(list.get(i));
//     }
//     return resultStr;
// }


// Path: app/src/main/java/com/antest1/kcanotify/ErrorlogActivity.java
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Vibrator;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaUtils.doVibrate;
import static com.antest1.kcanotify.KcaUtils.joinStr;

        setContentView(R.layout.activity_errorlog);

        toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setTitle(R.string.action_errorlog);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);

        text = findViewById(R.id.errorlogview);
        text.setText("");
        text.setLongClickable(true);
        text.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                clip.setPrimaryClip(ClipData.newPlainText("text", ((TextView) v).getText()));
                doVibrate(vibrator, 100);
                Toast.makeText(getApplicationContext(), getStringWithLocale(R.string.copied_to_clipboard), Toast.LENGTH_LONG).show();
                return false;
            }
        });

        loadbtn = findViewById(R.id.error_load);
        loadbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                List<String> loglist = dbHelper.getErrorLog(SHOW_LIMIT, false);
                if (loglist.size() > 0) {
                    text.setText(joinStr(loglist, "\n"));