Java Code Examples for com.pluscubed.logcat.helper.PreferenceHelper#getLogLinePeriodPreference()
The following examples show how to use
com.pluscubed.logcat.helper.PreferenceHelper#getLogLinePeriodPreference() .
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: LogcatRecordingService.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(getApplicationContext()); while ((line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }
Example 2
Source File: SettingsActivity.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
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 3
Source File: LogcatRecordingService.java From javaide with GNU General Public License v3.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(getApplicationContext()); while ((line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }
Example 4
Source File: SettingsActivity.java From javaide with GNU General Public License v3.0 | 4 votes |
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 5
Source File: LogcatRecordingService.java From matlog with GNU General Public License v3.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(this); String filterPattern = PreferenceHelper.getFilterPatternPreference(this); while (mReader != null && (line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit, filterPattern)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }
Example 6
Source File: SettingsActivity.java From matlog with GNU General Public License v3.0 | 4 votes |
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; }); }