com.pluscubed.logcat.data.LogLine Java Examples

The following examples show how to use com.pluscubed.logcat.data.LogLine. 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
@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 #2
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(final View itemView, final LogLine logLine) {
    if (partialSelectMode) {
        logLine.setHighlighted(true);
        partiallySelectedLogLines.add(logLine);

        mHandler.post(new Runnable() {
            @Override
            public void run() {
                mLogListAdapter.notifyItemChanged(binding.list.getChildAdapterPosition(itemView));
            }
        });

        if (partiallySelectedLogLines.size() == 2) {
            // last line
            completePartialSelect();
        }
    } else {
        logLine.setExpanded(!logLine.isExpanded());
        mLogListAdapter.notifyItemChanged(binding.list.getChildAdapterPosition(itemView));
    }
}
 
Example #3
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.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 #4
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void cancelPartialSelect() {
    partialSelectMode = false;

    boolean changed = false;
    for (LogLine logLine : partiallySelectedLogLines) {
        if (logLine.isHighlighted()) {
            logLine.setHighlighted(false);
            changed = true;
        }
    }
    partiallySelectedLogLines.clear();
    if (changed) {
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                mLogListAdapter.notifyDataSetChanged();
            }
        });
    }
}
 
Example #5
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void cancelPartialSelect() {
    partialSelectMode = false;

    boolean changed = false;
    for (LogLine logLine : partiallySelectedLogLines) {
        if (logLine.isHighlighted()) {
            logLine.setHighlighted(false);
            changed = true;
        }
    }
    partiallySelectedLogLines.clear();
    if (changed) {
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                mLogListAdapter.notifyDataSetChanged();
            }
        });
    }
}
 
Example #6
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(final View itemView, final LogLine logLine) {
    if (partialSelectMode) {
        logLine.setHighlighted(true);
        partiallySelectedLogLines.add(logLine);

        mHandler.post(() -> mLogListAdapter.notifyItemChanged(((RecyclerView) findViewById(R.id.list)).getChildAdapterPosition(itemView)));

        if (partiallySelectedLogLines.size() == 2) {
            // last line
            completePartialSelect();
        }
    } else {
        logLine.setExpanded(!logLine.isExpanded());
        mLogListAdapter.notifyItemChanged(((RecyclerView) findViewById(R.id.list)).getChildAdapterPosition(itemView));
    }
}
 
Example #7
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(final View itemView, final LogLine logLine) {
    if (partialSelectMode) {
        logLine.setHighlighted(true);
        partiallySelectedLogLines.add(logLine);

        mHandler.post(new Runnable() {
            @Override
            public void run() {
                mLogListAdapter.notifyItemChanged(binding.list.getChildAdapterPosition(itemView));
            }
        });

        if (partiallySelectedLogLines.size() == 2) {
            // last line
            completePartialSelect();
        }
    } else {
        logLine.setExpanded(!logLine.isExpanded());
        mLogListAdapter.notifyItemChanged(binding.list.getChildAdapterPosition(itemView));
    }
}
 
Example #8
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.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 #9
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
private void cancelPartialSelect() {
    partialSelectMode = false;

    boolean changed = false;
    for (LogLine logLine : partiallySelectedLogLines) {
        if (logLine.isHighlighted()) {
            logLine.setHighlighted(false);
            changed = true;
        }
    }
    partiallySelectedLogLines.clear();
    if (changed) {
        mHandler.post(mLogListAdapter::notifyDataSetChanged);
    }
}
 
Example #10
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_logcat);

    LogLine.isScrubberEnabled = PreferenceHelper.isScrubberEnabled(this);

    handleShortcuts(getIntent().getStringExtra("shortcut_action"));

    mHandler = new Handler(Looper.getMainLooper());

    findViewById(R.id.fab).setOnClickListener(v -> DialogHelper.stopRecordingLog(LogcatActivity.this));

    ((RecyclerView) findViewById(R.id.list)).setLayoutManager(new LinearLayoutManager(this));

    ((RecyclerView) findViewById(R.id.list)).setItemAnimator(null);

    Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
    toolbar.setOverflowIcon(AppCompatResources.getDrawable(this, R.drawable.ic_more_vert_24dp));
    setSupportActionBar(toolbar);

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(this);

    mFilterPattern = PreferenceHelper.getFilterPatternPreference(this);

    log.d("initial collapsed mode is %s", mCollapsedMode);

    mSearchSuggestionsAdapter = new SimpleCursorAdapter(this,
            R.layout.list_item_dropdown,
            null,
            new String[]{"suggestion"},
            new int[]{android.R.id.text1},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setUpAdapter();
    updateBackgroundColor();
    runUpdatesIfNecessaryAndShowWelcomeMessage();
}
 
Example #11
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onProgressUpdate(LogLine... values) {
    super.onProgressUpdate(values);

    if (!mFirstLineReceived) {
        mFirstLineReceived = true;
        hideProgressBar();
    }
    for (LogLine logLine : values) {
        mLogListAdapter.addWithFilter(logLine, mSearchingString);

        addToAutocompleteSuggestions(logLine);
    }

    // how many logs to keep in memory?  this avoids OutOfMemoryErrors
    int maxNumLogLines = PreferenceHelper.getDisplayLimitPreference(LogcatActivity.this);

    // check to see if the list needs to be truncated to avoid out of memory errors
    if (++counter % UPDATE_CHECK_INTERVAL == 0
            && mLogListAdapter.getTrueValues().size() > maxNumLogLines) {
        int numItemsToRemove = mLogListAdapter.getTrueValues().size() - maxNumLogLines;
        mLogListAdapter.removeFirst(numItemsToRemove);
        log.d("truncating %d lines from log list to avoid out of memory errors", numItemsToRemove);
    }

    if (mAutoscrollToBottom) {
        scrollToBottom();
    }

}
 
Example #12
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private void addToAutocompleteSuggestions(LogLine logLine) {
    // add the tags to the autocompletetextview

    if (!StringUtil.isEmptyOrWhitespaceOnly(logLine.getTag())) {
        String trimmed = logLine.getTag().trim();
        addToAutocompleteSuggestions(trimmed);
    }
}
 
Example #13
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_logcat);

    LogLine.isScrubberEnabled = PreferenceHelper.isScrubberEnabled(this);

    handleShortcuts(getIntent().getStringExtra("shortcut_action"));

    mHandler = new Handler(Looper.getMainLooper());

    binding.fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogHelper.stopRecordingLog(LogcatActivity.this);
        }
    });

    binding.list.setLayoutManager(new LinearLayoutManager(this));

    binding.list.setItemAnimator(null);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_actionbar));
    setTitle(R.string.logcat);

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(this);

    log.d("initial collapsed mode is %s", mCollapsedMode);

    mSearchSuggestionsAdapter = new SimpleCursorAdapter(this,
            R.layout.list_item_dropdown,
            null,
            new String[]{"suggestion"},
            new int[]{android.R.id.text1},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setUpAdapter();
    updateBackgroundColor();
    runUpdatesIfNecessaryAndShowWelcomeMessage();
}
 
Example #14
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
private void addToAutocompleteSuggestions(LogLine logLine) {
    // add the tags to the autocompletetextview

    if (!StringUtil.isEmptyOrWhitespaceOnly(logLine.getTag())) {
        String trimmed = logLine.getTag().trim();
        addToAutocompleteSuggestions(trimmed);
    }
}
 
Example #15
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onProgressUpdate(LogLine... values) {
    super.onProgressUpdate(values);

    if (!mFirstLineReceived) {
        mFirstLineReceived = true;
        hideProgressBar();
    }
    for (LogLine logLine : values) {
        mLogListAdapter.addWithFilter(logLine, mSearchingString);

        addToAutocompleteSuggestions(logLine);
    }

    // how many logs to keep in memory?  this avoids OutOfMemoryErrors
    int maxNumLogLines = PreferenceHelper.getDisplayLimitPreference(LogcatActivity.this);

    // check to see if the list needs to be truncated to avoid out of memory errors
    if (++counter % UPDATE_CHECK_INTERVAL == 0
            && mLogListAdapter.getTrueValues().size() > maxNumLogLines) {
        int numItemsToRemove = mLogListAdapter.getTrueValues().size() - maxNumLogLines;
        mLogListAdapter.removeFirst(numItemsToRemove);
        log.d("truncating %d lines from log list to avoid out of memory errors", numItemsToRemove);
    }

    if (mAutoscrollToBottom) {
        scrollToBottom();
    }

}
 
Example #16
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void addToAutocompleteSuggestions(LogLine logLine) {
    // add the tags to the autocompletetextview

    if (!StringUtil.isEmptyOrWhitespaceOnly(logLine.getTag())) {
        String trimmed = logLine.getTag().trim();
        addToAutocompleteSuggestions(trimmed);
    }
}
 
Example #17
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onProgressUpdate(LogLine... values) {
    super.onProgressUpdate(values);

    if (!mFirstLineReceived) {
        mFirstLineReceived = true;
        hideProgressBar();
    }
    for (LogLine logLine : values) {
        mLogListAdapter.addWithFilter(logLine, mSearchingString, false);

        addToAutocompleteSuggestions(logLine);
    }
    mLogListAdapter.notifyDataSetChanged();

    // how many logs to keep in memory?  this avoids OutOfMemoryErrors
    int maxNumLogLines = PreferenceHelper.getDisplayLimitPreference(LogcatActivity.this);

    // check to see if the list needs to be truncated to avoid out of memory errors
    if (++counter % UPDATE_CHECK_INTERVAL == 0
            && mLogListAdapter.getTrueValues().size() > maxNumLogLines) {
        int numItemsToRemove = mLogListAdapter.getTrueValues().size() - maxNumLogLines;
        mLogListAdapter.removeFirst(numItemsToRemove);
        log.d("truncating %d lines from log list to avoid out of memory errors", numItemsToRemove);
    }

    if (mAutoscrollToBottom) {
        scrollToBottom();
    }

}
 
Example #18
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_logcat);

    LogLine.isScrubberEnabled = PreferenceHelper.isScrubberEnabled(this);

    handleShortcuts(getIntent().getStringExtra("shortcut_action"));

    mHandler = new Handler(Looper.getMainLooper());

    binding.fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogHelper.stopRecordingLog(LogcatActivity.this);
        }
    });

    binding.list.setLayoutManager(new LinearLayoutManager(this));

    binding.list.setItemAnimator(null);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_actionbar));
    setTitle(R.string.logcat);

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(this);

    log.d("initial collapsed mode is %s", mCollapsedMode);

    mSearchSuggestionsAdapter = new SimpleCursorAdapter(this,
            R.layout.list_item_dropdown,
            null,
            new String[]{"suggestion"},
            new int[]{android.R.id.text1},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setUpAdapter();
    updateBackgroundColor();
    runUpdatesIfNecessaryAndShowWelcomeMessage();
}
 
Example #19
Source File: SettingsActivity.java    From matlog with GNU General Public License v3.0 4 votes vote down vote up
private void setUpPreferences() {
    setCurrentValue("ui.theme");
    setCurrentValue("theme");

    displayLimitPreference = (EditTextPreference) findPreference(getString(R.string.pref_display_limit));

    int displayLimitValue = PreferenceHelper.getDisplayLimitPreference(getActivity());

    displayLimitPreference.setSummary(getString(R.string.pref_display_limit_summary,
            displayLimitValue, getString(R.string.pref_display_limit_default)));
    displayLimitPreference.setOnPreferenceChangeListener(this);

    filterPatternPreference = (EditTextPreference) findPreference(getString(R.string.pref_filter_pattern));
    filterPatternPreference.setSummary(getString(R.string.pref_filter_pattern_summary));
    filterPatternPreference.setOnPreferenceChangeListener(this);

    logLinePeriodPreference = (EditTextPreference) findPreference(getString(R.string.pref_log_line_period));

    int logLinePrefValue = PreferenceHelper.getLogLinePeriodPreference(getActivity());

    logLinePeriodPreference.setSummary(getString(R.string.pref_log_line_period_summary,
            logLinePrefValue, getString(R.string.pref_log_line_period_default)));

    logLinePeriodPreference.setOnPreferenceChangeListener(this);

    textSizePreference = (ListPreference) findPreference(getString(R.string.pref_text_size));
    textSizePreference.setSummary(textSizePreference.getEntry());
    textSizePreference.setOnPreferenceChangeListener(this);

    defaultLevelPreference = (ListPreference) findPreference(getString(R.string.pref_default_log_level));
    defaultLevelPreference.setOnPreferenceChangeListener(this);
    setDefaultLevelPreferenceSummary(defaultLevelPreference.getEntry());

    mThemePreference = findPreference("ui.theme");
    mThemePreference.setOnPreferenceChangeListener(this);

    bufferPreference = (MultipleChoicePreference) findPreference(getString(R.string.pref_buffer));
    bufferPreference.setOnPreferenceChangeListener(this);
    setBufferPreferenceSummary(bufferPreference.getValue());

    mThemePreference.setOnPreferenceChangeListener(this);

    mAboutPreference = findPreference(getString(R.string.pref_about));
    mAboutPreference.setOnPreferenceClickListener(preference -> {
        // launch about activity
        Intent intent = new Intent(getActivity(), AboutDialogActivity.class);
        startActivity(intent);
        return true;
    });
    mAboutPreference.setSummary(getString(R.string.version, PackageHelper.getVersionName(getActivity())));

    scrubberPreference = (SwitchPreference) getPreferenceScreen().findPreference("scrubber");
    scrubberPreference.setOnPreferenceChangeListener((preference, newValue) -> {
        LogLine.isScrubberEnabled = (boolean) newValue;
        return true;
    });
}
 
Example #20
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 4 votes vote down vote up
private void savePartialLog(final String filename, LogLine first, LogLine last) {

        final List<CharSequence> logLines = new ArrayList<>(mLogListAdapter.getItemCount());

        // filter based on first and last
        boolean started = false;
        boolean foundLast = false;
        for (int i = 0; i < mLogListAdapter.getItemCount(); i++) {
            LogLine logLine = mLogListAdapter.getItem(i);
            if (logLine == first) {
                started = true;
            }
            if (started) {
                logLines.add(logLine.getOriginalLine());
            }
            if (logLine == last) {
                foundLast = true;
                break;
            }
        }

        if (!foundLast || logLines.isEmpty()) {
            Toast.makeText(this, R.string.toast_invalid_selection, Toast.LENGTH_LONG).show();
            cancelPartialSelect();
            return;
        }

        new Thread(() -> {
            SaveLogHelper.deleteLogIfExists(filename);
            final boolean saved = SaveLogHelper.saveLog(logLines, filename);

            mHandler.post(() -> {
                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();
                }
                cancelPartialSelect();
            });
        }).start();
    }
 
Example #21
Source File: LogcatRecordingService.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private boolean checkLogLine(String line, SearchCriteria searchCriteria, int logLevelLimit) {
    LogLine logLine = LogLine.newLogLine(line, false);
    return searchCriteria.matches(logLine)
            && LogLineAdapterUtil.logLevelIsAcceptableGivenLogLevelLimit(logLine.getLogLevel(), logLevelLimit);
}
 
Example #22
Source File: LogcatRecordingService.java    From matlog with GNU General Public License v3.0 4 votes vote down vote up
private boolean checkLogLine(String line, SearchCriteria searchCriteria, int logLevelLimit, String filterPattern) {
    LogLine logLine = LogLine.newLogLine(line, false, filterPattern);
    return searchCriteria.matches(logLine)
            && LogLineAdapterUtil.logLevelIsAcceptableGivenLogLevelLimit(logLine.getLogLevel(), logLevelLimit);
}
 
Example #23
Source File: SettingsActivity.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
private void setUpPreferences() {

            displayLimitPreference = (EditTextPreference) findPreference(getString(R.string.pref_display_limit));

            int displayLimitValue = PreferenceHelper.getDisplayLimitPreference(getActivity());

            displayLimitPreference.setSummary(getString(R.string.pref_display_limit_summary,
                    displayLimitValue, getString(R.string.pref_display_limit_default)));

            displayLimitPreference.setOnPreferenceChangeListener(this);

            logLinePeriodPreference = (EditTextPreference) findPreference(getString(R.string.pref_log_line_period));

            int logLinePrefValue = PreferenceHelper.getLogLinePeriodPreference(getActivity());

            logLinePeriodPreference.setSummary(getString(R.string.pref_log_line_period_summary,
                    logLinePrefValue, getString(R.string.pref_log_line_period_default)));

            logLinePeriodPreference.setOnPreferenceChangeListener(this);

            textSizePreference = (ListPreference) findPreference(getString(R.string.pref_text_size));
            textSizePreference.setSummary(textSizePreference.getEntry());
            textSizePreference.setOnPreferenceChangeListener(this);

            defaultLevelPreference = (ListPreference) findPreference(getString(R.string.pref_default_log_level));
            defaultLevelPreference.setOnPreferenceChangeListener(this);
            setDefaultLevelPreferenceSummary(defaultLevelPreference.getEntry());


            bufferPreference = (MultipleChoicePreference) findPreference(getString(R.string.pref_buffer));
            bufferPreference.setOnPreferenceChangeListener(this);
            setBufferPreferenceSummary(bufferPreference.getValue());

            scrubberPreference = (SwitchPreference) getPreferenceScreen().findPreference("scrubber");
            scrubberPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    LogLine.isScrubberEnabled = (boolean) newValue;
                    return true;
                }
            });
        }
 
Example #24
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
private void savePartialLog(final String filename, LogLine first, LogLine last) {

        final List<CharSequence> logLines = new ArrayList<>(mLogListAdapter.getItemCount());

        // filter based on first and last
        boolean started = false;
        boolean foundLast = false;
        for (int i = 0; i < mLogListAdapter.getItemCount(); i++) {
            LogLine logLine = mLogListAdapter.getItem(i);
            if (logLine == first) {
                started = true;
            }
            if (started) {
                logLines.add(logLine.getOriginalLine());
            }
            if (logLine == last) {
                foundLast = true;
                break;
            }
        }

        if (!foundLast || logLines.isEmpty()) {
            Toast.makeText(this, R.string.toast_invalid_selection, Toast.LENGTH_LONG).show();
            cancelPartialSelect();
            return;
        }

        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();
                        }
                        cancelPartialSelect();
                    }
                });
            }
        }).start();
    }
 
Example #25
Source File: LogcatRecordingService.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
private boolean checkLogLine(String line, SearchCriteria searchCriteria, int logLevelLimit) {
    LogLine logLine = LogLine.newLogLine(line, false);
    return searchCriteria.matches(logLine)
            && LogLineAdapterUtil.logLevelIsAcceptableGivenLogLevelLimit(logLine.getLogLevel(), logLevelLimit);
}
 
Example #26
Source File: SettingsActivity.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private void setUpPreferences() {

            displayLimitPreference = (EditTextPreference) findPreference(getString(R.string.pref_display_limit));

            int displayLimitValue = PreferenceHelper.getDisplayLimitPreference(getActivity());

            displayLimitPreference.setSummary(getString(R.string.pref_display_limit_summary,
                    displayLimitValue, getString(R.string.pref_display_limit_default)));

            displayLimitPreference.setOnPreferenceChangeListener(this);

            logLinePeriodPreference = (EditTextPreference) findPreference(getString(R.string.pref_log_line_period));

            int logLinePrefValue = PreferenceHelper.getLogLinePeriodPreference(getActivity());

            logLinePeriodPreference.setSummary(getString(R.string.pref_log_line_period_summary,
                    logLinePrefValue, getString(R.string.pref_log_line_period_default)));

            logLinePeriodPreference.setOnPreferenceChangeListener(this);

            textSizePreference = (ListPreference) findPreference(getString(R.string.pref_text_size));
            textSizePreference.setSummary(textSizePreference.getEntry());
            textSizePreference.setOnPreferenceChangeListener(this);

            defaultLevelPreference = (ListPreference) findPreference(getString(R.string.pref_default_log_level));
            defaultLevelPreference.setOnPreferenceChangeListener(this);
            setDefaultLevelPreferenceSummary(defaultLevelPreference.getEntry());


            bufferPreference = (MultipleChoicePreference) findPreference(getString(R.string.pref_buffer));
            bufferPreference.setOnPreferenceChangeListener(this);
            setBufferPreferenceSummary(bufferPreference.getValue());

            scrubberPreference = (SwitchPreference) getPreferenceScreen().findPreference("scrubber");
            scrubberPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    LogLine.isScrubberEnabled = (boolean) newValue;
                    return true;
                }
            });
        }
 
Example #27
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private void savePartialLog(final String filename, LogLine first, LogLine last) {

        final List<CharSequence> logLines = new ArrayList<>(mLogListAdapter.getItemCount());

        // filter based on first and last
        boolean started = false;
        boolean foundLast = false;
        for (int i = 0; i < mLogListAdapter.getItemCount(); i++) {
            LogLine logLine = mLogListAdapter.getItem(i);
            if (logLine == first) {
                started = true;
            }
            if (started) {
                logLines.add(logLine.getOriginalLine());
            }
            if (logLine == last) {
                foundLast = true;
                break;
            }
        }

        if (!foundLast || logLines.isEmpty()) {
            Toast.makeText(this, R.string.toast_invalid_selection, Toast.LENGTH_LONG).show();
            cancelPartialSelect();
            return;
        }

        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();
                        }
                        cancelPartialSelect();
                    }
                });
            }
        }).start();
    }
 
Example #28
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 3 votes vote down vote up
private void expandOrCollapseAll(boolean change) {

        mCollapsedMode = change != mCollapsedMode;

        int oldFirstVisibleItem = ((LinearLayoutManager) ((RecyclerView) findViewById(R.id.list)).getLayoutManager()).findFirstVisibleItemPosition();

        for (LogLine logLine : mLogListAdapter.getTrueValues()) {
            if (logLine != null) {
                logLine.setExpanded(!mCollapsedMode);
            }
        }

        mLogListAdapter.notifyDataSetChanged();

        // ensure that we either stay autoscrolling at the bottom of the list...

        if (mAutoscrollToBottom) {

            scrollToBottom();

            // ... or that whatever was the previous first visible item is still the current first
            // visible item after expanding/collapsing

        } else if (oldFirstVisibleItem != -1) {

            ((RecyclerView) findViewById(R.id.list)).scrollToPosition(oldFirstVisibleItem);
        }

        supportInvalidateOptionsMenu();
    }
 
Example #29
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 3 votes vote down vote up
private void expandOrCollapseAll(boolean change) {

        mCollapsedMode = change != mCollapsedMode;

        int oldFirstVisibleItem = ((LinearLayoutManager) binding.list.getLayoutManager()).findFirstVisibleItemPosition();

        for (LogLine logLine : mLogListAdapter.getTrueValues()) {
            if (logLine != null) {
                logLine.setExpanded(!mCollapsedMode);
            }
        }

        mLogListAdapter.notifyDataSetChanged();

        // ensure that we either stay autoscrolling at the bottom of the list...

        if (mAutoscrollToBottom) {

            scrollToBottom();

            // ... or that whatever was the previous first visible item is still the current first
            // visible item after expanding/collapsing

        } else if (oldFirstVisibleItem != -1) {

            binding.list.scrollToPosition(oldFirstVisibleItem);
        }

        supportInvalidateOptionsMenu();
    }
 
Example #30
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 3 votes vote down vote up
private void expandOrCollapseAll(boolean change) {

        mCollapsedMode = change != mCollapsedMode;

        int oldFirstVisibleItem = ((LinearLayoutManager) binding.list.getLayoutManager()).findFirstVisibleItemPosition();

        for (LogLine logLine : mLogListAdapter.getTrueValues()) {
            if (logLine != null) {
                logLine.setExpanded(!mCollapsedMode);
            }
        }

        mLogListAdapter.notifyDataSetChanged();

        // ensure that we either stay autoscrolling at the bottom of the list...

        if (mAutoscrollToBottom) {

            scrollToBottom();

            // ... or that whatever was the previous first visible item is still the current first
            // visible item after expanding/collapsing

        } else if (oldFirstVisibleItem != -1) {

            binding.list.scrollToPosition(oldFirstVisibleItem);
        }

        supportInvalidateOptionsMenu();
    }