com.pluscubed.logcat.R Java Examples

The following examples show how to use com.pluscubed.logcat.R. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public static void startChooser(Context context, String subject, String body, SendLogDetails.AttachmentType attachmentType, File attachment) {

        Intent actionSendIntent = new Intent(Intent.ACTION_SEND);

        actionSendIntent.setType(attachmentType.getMimeType());
        actionSendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        if (!body.isEmpty()) {
            actionSendIntent.putExtra(Intent.EXTRA_TEXT, body);
        }
        if (attachment != null) {
            Uri uri = Uri.fromFile(attachment);
            log.d("uri is: %s", uri);
            actionSendIntent.putExtra(Intent.EXTRA_STREAM, uri);
        }

        context.startActivity(Intent.createChooser(actionSendIntent, context.getResources().getText(R.string.send_log_title)));
    }
 
Example #2
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item, LogLine logLine) {
    if (logLine != null) {
        switch (item.getItemId()) {
            case CONTEXT_MENU_COPY_ID:
                ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

                clipboard.setPrimaryClip(ClipData.newPlainText(null, logLine.getOriginalLine()));
                Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
                return true;
            case CONTEXT_MENU_FILTER_ID:

                if (logLine.getProcessId() == -1) {
                    // invalid line
                    return false;
                }

                showSearchByDialog(logLine);
                return true;
        }
    }
    return false;
}
 
Example #3
Source File: LogLineAdapterUtil.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public static int getForegroundColorForLogLevel(Context context, int logLevel) {
    int result = android.R.color.primary_text_dark;
    switch (logLevel) {
        case Log.DEBUG:
            result = R.color.foreground_debug;
            break;
        case Log.ERROR:
            result = R.color.foreground_error;
            break;
        case Log.INFO:
            result = R.color.foreground_info;
            break;
        case Log.VERBOSE:
            result = R.color.foreground_verbose;
            break;
        case Log.WARN:
            result = R.color.foreground_warn;
            break;
        case LOG_WTF:
            result = R.color.foreground_wtf;
            break;
    }
    return ContextCompat.getColor(context,result);
}
 
Example #4
Source File: LogLineAdapterUtil.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public static int getBackgroundColorForLogLevel(Context context, int logLevel) {
    int result = android.R.color.black;
    switch (logLevel) {
        case Log.DEBUG:
            result = R.color.background_debug;
            break;
        case Log.ERROR:
            result = R.color.background_error;
            break;
        case Log.INFO:
            result = R.color.background_info;
            break;
        case Log.VERBOSE:
            result = R.color.background_verbose;
            break;
        case Log.WARN:
            result = R.color.background_warn;
            break;
        case LOG_WTF:
            result = R.color.background_wtf;
            break;
    }

    return ContextCompat.getColor(context,result);
}
 
Example #5
Source File: SettingsActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void setBufferPreferenceSummary(String value) {

            String[] commaSeparated = StringUtil.split(StringUtil.nullToEmpty(value), MultipleChoicePreference.DELIMITER);

            List<CharSequence> checkedEntries = new ArrayList<CharSequence>();

            for (String entryValue : commaSeparated) {
                int idx = ArrayUtil.indexOf(bufferPreference.getEntryValues(), entryValue);
                checkedEntries.add(bufferPreference.getEntries()[idx]);
            }

            String summary = TextUtils.join(getString(R.string.delimiter), checkedEntries);

            // add the word "simultaneous" to make it clearer what's going on with 2+ buffers
            if (checkedEntries.size() > 1) {
                summary += getString(R.string.simultaneous);
            }
            bufferPreference.setSummary(summary);
        }
 
Example #6
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public static void startChooser(Context context, String subject, String body, SendLogDetails.AttachmentType attachmentType, File attachment) {

        Intent actionSendIntent = new Intent(Intent.ACTION_SEND);

        actionSendIntent.setType(attachmentType.getMimeType());
        actionSendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        if (!body.isEmpty()) {
            actionSendIntent.putExtra(Intent.EXTRA_TEXT, body);
        }
        if (attachment != null) {
            Uri uri = Uri.fromFile(attachment);
            log.d("uri is: %s", uri);
            actionSendIntent.putExtra(Intent.EXTRA_STREAM, uri);
        }

        context.startActivity(Intent.createChooser(actionSendIntent, context.getResources().getText(R.string.send_log_title)));
    }
 
Example #7
Source File: SettingsActivity.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(toolbar);

    FragmentManager fm = getFragmentManager();
    Fragment f = fm.findFragmentById(R.id.content);
    if (f == null) {
        fm.beginTransaction()
                .replace(R.id.content,
                        new SettingsFragment())
                .commit();
    }
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setTitle(R.string.settings);
}
 
Example #8
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void showLogLevelDialog() {
    String[] logLevels = getResources().getStringArray(R.array.log_levels);

    // put the word "default" after whatever the default log level is
    String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this));
    int index = ArrayUtil.indexOf(getResources().getStringArray(R.array.log_levels_values), defaultLogLevel);

    logLevels[index] = logLevels[index] + " " + getString(R.string.default_in_parens);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setTitle(R.string.log_level)
            .setCancelable(true)
            .setSingleChoiceItems(logLevels, mLogListAdapter.getLogLevelLimit(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mLogListAdapter.setLogLevelLimit(which);
                    logLevelChanged();
                    dialog.dismiss();

                }
            });

    builder.show();
}
 
Example #9
Source File: SettingsActivity.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void setBufferPreferenceSummary(String value) {

            String[] commaSeparated = StringUtil.split(StringUtil.nullToEmpty(value), MultipleChoicePreference.DELIMITER);

            List<CharSequence> checkedEntries = new ArrayList<CharSequence>();

            for (String entryValue : commaSeparated) {
                int idx = ArrayUtil.indexOf(bufferPreference.getEntryValues(), entryValue);
                checkedEntries.add(bufferPreference.getEntries()[idx]);
            }

            String summary = TextUtils.join(getString(R.string.delimiter), checkedEntries);

            // add the word "simultaneous" to make it clearer what's going on with 2+ buffers
            if (checkedEntries.size() > 1) {
                summary += getString(R.string.simultaneous);
            }
            bufferPreference.setSummary(summary);
        }
 
Example #10
Source File: PreferenceHelper.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public static float getTextSizePreference(Context context) {

        if (textSize == -1) {

            SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);

            String textSizePref = sharedPrefs.getString(
                    context.getText(R.string.pref_text_size).toString(),
                    context.getText(R.string.text_size_medium_value).toString());

            if (textSizePref.equals(context.getText(R.string.text_size_xsmall_value))) {
                cacheTextsize(context, R.dimen.text_size_xsmall);
            } else if (textSizePref.equals(context.getText(R.string.text_size_small_value))) {
                cacheTextsize(context, R.dimen.text_size_small);
            } else if (textSizePref.equals(context.getText(R.string.text_size_medium_value))) {
                cacheTextsize(context, R.dimen.text_size_medium);
            } else if (textSizePref.equals(context.getText(R.string.text_size_large_value))) {
                cacheTextsize(context, R.dimen.text_size_large);
            } else { // xlarge
                cacheTextsize(context, R.dimen.text_size_xlarge);
            }
        }

        return textSize;

    }
 
Example #11
Source File: DialogHelper.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public static void showFilenameSuggestingDialog(final Context context,
                                                final MaterialDialog.SingleButtonCallback callback,
                                                final MaterialDialog.InputCallback inputCallback, int titleResId) {


    MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
    builder.title(titleResId)
            .negativeText(android.R.string.cancel)
            .positiveText(android.R.string.ok)
            .content(R.string.enter_filename)
            .input("", "", inputCallback)
            .onAny(callback);

    MaterialDialog show = builder.show();
    initFilenameInputDialog(show);
}
 
Example #12
Source File: LogLineAdapterUtil.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public static int getBackgroundColorForLogLevel(Context context, int logLevel) {
    int result = android.R.color.black;
    switch (logLevel) {
        case Log.DEBUG:
            result = R.color.background_debug;
            break;
        case Log.ERROR:
            result = R.color.background_error;
            break;
        case Log.INFO:
            result = R.color.background_info;
            break;
        case Log.VERBOSE:
            result = R.color.background_verbose;
            break;
        case Log.WARN:
            result = R.color.background_warn;
            break;
        case LOG_WTF:
            result = R.color.background_wtf;
            break;
    }

    return ContextCompat.getColor(context,result);
}
 
Example #13
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void saveLog(final String filename) {

        // do in background to avoid jankiness

        final List<CharSequence> logLines = getCurrentLogAsListOfStrings();

        new Thread(new Runnable() {
            @Override
            public void run() {
                SaveLogHelper.deleteLogIfExists(filename);
                final boolean saved = SaveLogHelper.saveLog(logLines, filename);

                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        if (saved) {
                            Toast.makeText(getApplicationContext(), R.string.log_saved, Toast.LENGTH_SHORT).show();
                            openLogFile(filename);
                        } else {
                            Toast.makeText(getApplicationContext(), R.string.unable_to_save_log, Toast.LENGTH_LONG).show();
                        }
                    }
                });
            }
        }).start();

    }
 
Example #14
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void showSaveLogDialog() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                SAVE_LOG_REQUEST);
        return;
    }

    if (!SaveLogHelper.checkSdCard(this)) {
        return;
    }

    MaterialDialog.InputCallback onClickListener = new MaterialDialog.InputCallback() {
        @Override
        public void onInput(@NonNull MaterialDialog materialDialog, CharSequence charSequence) {
            if (DialogHelper.isInvalidFilename(charSequence)) {
                Toast.makeText(LogcatActivity.this, R.string.enter_good_filename, Toast.LENGTH_SHORT).show();
            } else {
                String filename = charSequence.toString();
                saveLog(filename);
            }
        }
    };

    DialogHelper.showFilenameSuggestingDialog(this, null, onClickListener, R.string.save_log);
}
 
Example #15
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private void runUpdatesIfNecessaryAndShowWelcomeMessage() {

        if (UpdateHelper.areUpdatesNecessary(this)) {
            // show progress dialog while updates are running

            final MaterialDialog dialog = new MaterialDialog.Builder(this)
                    .content(R.string.dialog_loading_updates)
                    .progress(true, 0)
                    .show();

            new AsyncTask<Void, Void, Void>() {

                @Override
                protected Void doInBackground(Void... params) {
                    UpdateHelper.runUpdatesIfNecessary(LogcatActivity.this);
                    return null;
                }

                @Override
                protected void onPostExecute(Void result) {
                    super.onPostExecute(result);
                    if (dialog.isShowing()) {
                        dialog.dismiss();
                    }
                    startLog();
                }


            }.execute((Void) null);

        } else {
            startLog();
        }

    }
 
Example #16
Source File: LogFileAdapter.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public LogFileAdapter(Context context, List<CharSequence> objects, int checked, boolean multiMode) {

        super(context, -1, objects);
        this.objects = objects;
        this.checked = checked;
        this.multiMode = multiMode;
        if (multiMode) {
            checkedItems = new boolean[objects.size()];
        }
        resId = multiMode ? R.layout.list_item_logfilename_multi : R.layout.list_item_logfilename_single;
    }
 
Example #17
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private void resetFilter() {
    String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this));
    CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values);
    int logLevelLimit = ArrayUtil.indexOf(logLevels, defaultLogLevel);
    mLogListAdapter.setLogLevelLimit(logLevelLimit);
    logLevelChanged();
}
 
Example #18
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void resetFilter() {
    String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this));
    CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values);
    int logLevelLimit = ArrayUtil.indexOf(logLevels, defaultLogLevel);
    mLogListAdapter.setLogLevelLimit(logLevelLimit);
    logLevelChanged();
}
 
Example #19
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void pauseOrUnpause(MenuItem item) {
    LogReaderAsyncTask currentTask = mTask;

    if (currentTask != null) {
        if (currentTask.isPaused()) {
            currentTask.unpause();
            item.setIcon(R.drawable.ic_pause_white_24dp);
        } else {
            currentTask.pause();
            item.setIcon(R.drawable.ic_play_arrow_white_24dp);
        }
    }
}
 
Example #20
Source File: LogFileAdapter.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public View getView(int position, View view, @NonNull ViewGroup parent) {

    Context context = parent.getContext();

    if (view == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(resId, parent, false);
    }

    CheckBox box = (CheckBox) view.findViewById(android.R.id.checkbox);
    RadioButton button = (RadioButton) view.findViewById(android.R.id.button1);
    TextView text1 = (TextView) view.findViewById(android.R.id.text1);
    TextView text2 = (TextView) view.findViewById(android.R.id.text2);

    CharSequence filename = objects.get(position);

    text1.setText(filename);


    if (multiMode) {
        box.setChecked(checkedItems[position]);
    } else {
        button.setChecked(checked == position);
    }

    Date lastModified = SaveLogHelper.getLastModifiedDate(filename.toString());
    DateFormat dateFormat = DateFormat.getDateTimeInstance();

    text2.setText(dateFormat.format(lastModified));

    return view;
}
 
Example #21
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void startPartialSelectMode() {

        boolean hideHelp = PreferenceHelper.getHidePartialSelectHelpPreference(this);

        if (hideHelp) {
            partialSelectMode = true;
            partiallySelectedLogLines.clear();
            Toast.makeText(this, R.string.toast_started_select_partial, Toast.LENGTH_SHORT).show();
        } else {

            LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            @SuppressLint("InflateParams") View helpView = inflater.inflate(R.layout.dialog_partial_save_help, null);
            // don't show the scroll bar
            helpView.setVerticalScrollBarEnabled(false);
            helpView.setHorizontalScrollBarEnabled(false);
            final CheckBox checkBox = (CheckBox) helpView.findViewById(android.R.id.checkbox);

            new MaterialDialog.Builder(this)
                    .title(R.string.menu_title_partial_select)
                    .customView(helpView, true)
                    .negativeText(android.R.string.cancel)
                    .positiveText(android.R.string.ok)
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                            partialSelectMode = true;
                            partiallySelectedLogLines.clear();
                            Toast.makeText(LogcatActivity.this, R.string.toast_started_select_partial, Toast.LENGTH_SHORT).show();

                            if (checkBox.isChecked()) {
                                // hide this help dialog in the future
                                PreferenceHelper.setHidePartialSelectHelpPreference(LogcatActivity.this, true);
                            }
                        }
                    })
                    .show();
        }
    }
 
Example #22
Source File: SaveLogHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public static boolean checkSdCard(Context context) {

        boolean result = SaveLogHelper.checkIfSdCardExists();

        if (!result) {
            Toast.makeText(context, R.string.sd_card_not_found, Toast.LENGTH_LONG).show();
        }
        return result;
    }
 
Example #23
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private void showSaveLogDialog() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                SAVE_LOG_REQUEST);
        return;
    }

    if (!SaveLogHelper.checkSdCard(this)) {
        return;
    }

    MaterialDialog.InputCallback onClickListener = new MaterialDialog.InputCallback() {
        @Override
        public void onInput(@NonNull MaterialDialog materialDialog, CharSequence charSequence) {
            if (DialogHelper.isInvalidFilename(charSequence)) {
                Toast.makeText(LogcatActivity.this, R.string.enter_good_filename, Toast.LENGTH_SHORT).show();
            } else {
                String filename = charSequence.toString();
                saveLog(filename);
            }
        }
    };

    DialogHelper.showFilenameSuggestingDialog(this, null, onClickListener, R.string.save_log);
}
 
Example #24
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
        Toast.makeText(this, R.string.permission_not_granted, Toast.LENGTH_LONG).show();
        return;
    }

    switch (requestCode) {
        case DELETE_SAVED_LOG_REQUEST:
            startDeleteSavedLogsDialog();
            break;
        case SEND_LOG_ID_REQUEST:
            showSendLogDialog();
            break;
        case SAVE_LOG_REQUEST:
            showSaveLogDialog();
            break;
        case OPEN_LOG_REQUEST:
            showOpenLogFileDialog();
            break;
        case COMPLETE_PARTIAL_SELECT_REQUEST:
            completePartialSelect();
            break;
        case SHOW_RECORD_LOG_REQUEST:
            showRecordLogDialog();
            break;
        case SHOW_RECORD_LOG_REQUEST_SHORTCUT:
            handleShortcuts("record");
            break;
    }
}
 
Example #25
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void doAfterInitialMessage(Intent intent) {

        // handle an intent that was sent from an external application

        if (intent != null && Intents.ACTION_LAUNCH.equals(intent.getAction())) {

            String filter = intent.getStringExtra(Intents.EXTRA_FILTER);
            String level = intent.getStringExtra(Intents.EXTRA_LEVEL);

            if (!TextUtils.isEmpty(filter)) {
                setSearchText(filter);
            }


            if (!TextUtils.isEmpty(level)) {
                CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values);
                int logLevelLimit = ArrayUtil.indexOf(logLevels, level.toUpperCase(Locale.US));

                if (logLevelLimit == -1) {
                    String invalidLevel = getString(R.string.toast_invalid_level, level);
                    Toast.makeText(this, invalidLevel, Toast.LENGTH_LONG).show();
                } else {
                    mLogListAdapter.setLogLevelLimit(logLevelLimit);
                    logLevelChanged();
                }

            }
        }
    }
 
Example #26
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void runUpdatesIfNecessaryAndShowWelcomeMessage() {

        if (UpdateHelper.areUpdatesNecessary(this)) {
            // show progress dialog while updates are running

            final MaterialDialog dialog = new MaterialDialog.Builder(this)
                    .content(R.string.dialog_loading_updates)
                    .progress(true, 0)
                    .show();

            new AsyncTask<Void, Void, Void>() {

                @Override
                protected Void doInBackground(Void... params) {
                    UpdateHelper.runUpdatesIfNecessary(LogcatActivity.this);
                    return null;
                }

                @Override
                protected void onPostExecute(Void result) {
                    super.onPostExecute(result);
                    if (dialog.isShowing()) {
                        dialog.dismiss();
                    }
                    startLog();
                }


            }.execute((Void) null);

        } else {
            startLog();
        }

    }
 
Example #27
Source File: DialogHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public static void startRecordingWithProgressDialog(final String filename,
                                                    final String filterQuery, final String logLevel, final Runnable onPostExecute, final Context context) {

    final MaterialDialog progressDialog = new MaterialDialog.Builder(context)
            .title(R.string.dialog_please_wait)
            .content(R.string.dialog_initializing_recorder)
            .progress(true, -1)
            .build();

    progressDialog.setCancelable(false);
    progressDialog.setCanceledOnTouchOutside(false);

    final Handler handler = new Handler(Looper.getMainLooper());
    progressDialog.show();
    new Thread(new Runnable() {
        @Override
        public void run() {
            ServiceHelper.startBackgroundServiceIfNotAlreadyRunning(context, filename, filterQuery, logLevel);
            handler.post(new Runnable() {
                @Override
                public void run() {
                    if (progressDialog.isShowing()) {
                        progressDialog.dismiss();
                    }
                    if (onPostExecute != null) {
                        onPostExecute.run();
                    }
                }
            });
        }
    }).start();

}
 
Example #28
Source File: PreferenceHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public static List<String> getBufferNames(Context context) {
    List<String> buffers = getBuffers(context);

    List<String> bufferNames = new ArrayList<>();

    // TODO: this is inefficient - O(n^2)
    for (String buffer : buffers) {
        int idx = Arrays.asList(context.getResources().getStringArray(
                R.array.pref_buffer_choice_values)).indexOf(buffer);
        bufferNames.add(context.getResources().getStringArray(R.array.pref_buffer_choices)[idx]);
    }
    return bufferNames;
}
 
Example #29
Source File: LogFileAdapter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public View getView(int position, View view, @NonNull ViewGroup parent) {

    Context context = parent.getContext();

    if (view == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(resId, parent, false);
    }

    CheckBox box = (CheckBox) view.findViewById(android.R.id.checkbox);
    RadioButton button = (RadioButton) view.findViewById(android.R.id.button1);
    TextView text1 = (TextView) view.findViewById(android.R.id.text1);
    TextView text2 = (TextView) view.findViewById(android.R.id.text2);

    CharSequence filename = objects.get(position);

    text1.setText(filename);


    if (multiMode) {
        box.setChecked(checkedItems[position]);
    } else {
        button.setChecked(checked == position);
    }

    Date lastModified = SaveLogHelper.getLastModifiedDate(filename.toString());
    DateFormat dateFormat = DateFormat.getDateTimeInstance();

    text2.setText(dateFormat.format(lastModified));

    return view;
}
 
Example #30
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void showSendLogDialog() {

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    SEND_LOG_ID_REQUEST);
            return;
        }

        String[] items = new String[]{(String) getText(R.string.as_attachment), (String) getText(R.string.as_text)};

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        @SuppressLint("InflateParams") View includeDeviceInfoView = inflater.inflate(R.layout.dialog_send_log, null, false);
        final CheckBox includeDeviceInfoCheckBox = (CheckBox) includeDeviceInfoView.findViewById(android.R.id.checkbox);

        // allow user to choose whether or not to include device info in report, use preferences for persistence
        includeDeviceInfoCheckBox.setChecked(PreferenceHelper.getIncludeDeviceInfoPreference(this));
        includeDeviceInfoCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                PreferenceHelper.setIncludeDeviceInfoPreference(LogcatActivity.this, isChecked);
            }
        });

        new android.app.AlertDialog.Builder(this)
                .setTitle(R.string.send_log_title)
                .setView(includeDeviceInfoView)
                .setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        sendLogToTargetApp(which == 1, includeDeviceInfoCheckBox.isChecked());
                        dialog.dismiss();
                    }
                })
                .show();

    }