com.pluscubed.logcat.helper.PreferenceHelper Java Examples

The following examples show how to use com.pluscubed.logcat.helper.PreferenceHelper. 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: ThemeWrapper.java    From matlog with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Apply theme to an Activity
 */
public static void applyTheme(Activity ctx) {
    int theme;
    switch (Theme.values()[getThemeIndex()]) {
        case LIGHT:
            theme = R.style.Theme_MatLog_Light;
            if (isDarkScheme(ctx)){
                PreferenceHelper.setColorScheme(ctx, ColorScheme.Light);
            }
            break;
        case DARK:
            theme = R.style.Theme_MatLog;
            if (isLightScheme(ctx)) {
                PreferenceHelper.setColorScheme(ctx, ColorScheme.Dark);
            }
            break;
        default:
            // Force use the light theme
            theme = R.style.Theme_MatLog_Light;
            break;
    }
    ctx.setTheme(theme);
}
 
Example #2
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    log.d("onActivityResult()");

    // preferences may have changed
    PreferenceHelper.clearCache();

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(getApplicationContext());


    if (requestCode == REQUEST_CODE_SETTINGS && resultCode == RESULT_OK) {
        onSettingsActivityResult(data);
    }
    mLogListAdapter.notifyDataSetChanged();
    updateBackgroundColor();
    updateUiForFilename();
}
 
Example #3
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void handleShortcuts(String action) {
    if (action == null) return;

    switch (action) {
        case "record":
            if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                        SHOW_RECORD_LOG_REQUEST_SHORTCUT);
                return;
            }

            String logFilename = DialogHelper.createLogFilename();
            String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this));

            DialogHelper.startRecordingWithProgressDialog(logFilename, "", defaultLogLevel, new Runnable() {
                @Override
                public void run() {
                    finish();
                }
            }, this);

            break;
    }
}
 
Example #4
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.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 #5
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void updateBackgroundColor() {
    ColorScheme colorScheme = PreferenceHelper.getColorScheme(this);

    final int color = colorScheme.getBackgroundColor(LogcatActivity.this);

    mHandler.post(new Runnable() {
        public void run() {
            binding.mainBackground.setBackgroundColor(color);
        }
    });

    //TODO:
    //mListView.setCacheColorHint(color);
    //mListView.setDivider(new ColorDrawable(color));

}
 
Example #6
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 6 votes vote down vote up
private void handleShortcuts(String action) {
    if (action == null) return;

    switch (action) {
        case "record":
            if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                        SHOW_RECORD_LOG_REQUEST_SHORTCUT);
                return;
            }

            String logFilename = DialogHelper.createLogFilename();
            String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this));

            DialogHelper.startRecordingWithProgressDialog(logFilename, "", defaultLogLevel, this::finish, this);

            break;
    }
}
 
Example #7
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    log.d("onActivityResult()");

    // preferences may have changed
    PreferenceHelper.clearCache();

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(getApplicationContext());


    if (requestCode == REQUEST_CODE_SETTINGS && resultCode == RESULT_OK) {
        onSettingsActivityResult(data);
    }
    mLogListAdapter.notifyDataSetChanged();
    updateBackgroundColor();
    updateUiForFilename();
}
 
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 updateBackgroundColor() {
    ColorScheme colorScheme = PreferenceHelper.getColorScheme(this);

    final int color = colorScheme.getBackgroundColor(LogcatActivity.this);

    mHandler.post(new Runnable() {
        public void run() {
            binding.mainBackground.setBackgroundColor(color);
        }
    });

    //TODO:
    //mListView.setCacheColorHint(color);
    //mListView.setDivider(new ColorDrawable(color));

}
 
Example #9
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 #10
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    log.d("onActivityResult()");

    // preferences may have changed
    PreferenceHelper.clearCache();

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(getApplicationContext());


    if (requestCode == REQUEST_CODE_SETTINGS && resultCode == RESULT_OK) {
        onSettingsActivityResult(data);
    }
    mLogListAdapter.notifyDataSetChanged();
    updateBackgroundColor();
    updateUiForFilename();
}
 
Example #11
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void handleShortcuts(String action) {
    if (action == null) return;

    switch (action) {
        case "record":
            if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                        SHOW_RECORD_LOG_REQUEST_SHORTCUT);
                return;
            }

            String logFilename = DialogHelper.createLogFilename();
            String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this));

            DialogHelper.startRecordingWithProgressDialog(logFilename, "", defaultLogLevel, new Runnable() {
                @Override
                public void run() {
                    finish();
                }
            }, this);

            break;
    }
}
 
Example #12
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.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(), (dialog, which) -> {
                mLogListAdapter.setLogLevelLimit(which);
                logLevelChanged();
                dialog.dismiss();

            });

    builder.show();
}
 
Example #13
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.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;
        }

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        @SuppressLint("InflateParams") View includeDeviceInfoView = inflater.inflate(R.layout.dialog_send_log, null, false);
        final CheckBox includeDeviceInfoCheckBox = 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((buttonView, isChecked) -> PreferenceHelper.setIncludeDeviceInfoPreference(LogcatActivity.this, isChecked));

        final CheckBox includeDmesgCheckBox = includeDeviceInfoView.findViewById(R.id.checkbox_dmesg);

        // allow user to choose whether or not to include device info in report, use preferences for persistence
        includeDmesgCheckBox.setChecked(PreferenceHelper.getIncludeDmesgPreference(this));
        includeDmesgCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> PreferenceHelper.setIncludeDmesgPreference(LogcatActivity.this, isChecked));

        new MaterialDialog.Builder(LogcatActivity.this)
                .title(R.string.share_log)
                .customView(includeDeviceInfoView, false)
                .negativeText(android.R.string.cancel)
                .positiveText(android.R.string.ok)
                .onPositive((materialDialog, dialogAction) -> {
                    sendLogToTargetApp(false, includeDeviceInfoCheckBox.isChecked(), includeDmesgCheckBox.isChecked());
                    materialDialog.dismiss();
                }).show();
    }
 
Example #14
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.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 = 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((dialog, 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 #15
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
private void showSaveLogZipDialog() {

        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;
        }

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        @SuppressLint("InflateParams") View includeDeviceInfoView = inflater.inflate(R.layout.dialog_send_log, null, false);
        final CheckBox includeDeviceInfoCheckBox = 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((buttonView, isChecked) -> PreferenceHelper.setIncludeDeviceInfoPreference(LogcatActivity.this, isChecked));

        final CheckBox includeDmesgCheckBox = includeDeviceInfoView.findViewById(R.id.checkbox_dmesg);

        // allow user to choose whether or not to include device info in report, use preferences for persistence
        includeDmesgCheckBox.setChecked(PreferenceHelper.getIncludeDmesgPreference(this));
        includeDmesgCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> PreferenceHelper.setIncludeDmesgPreference(LogcatActivity.this, isChecked));

        new MaterialDialog.Builder(LogcatActivity.this)
                .title(R.string.save_log_zip)
                .customView(includeDeviceInfoView, false)
                .negativeText(android.R.string.cancel)
                .positiveText(android.R.string.ok)
                .onPositive((materialDialog, dialogAction) -> {
                    saveLogToTargetApp(includeDeviceInfoCheckBox.isChecked(), includeDmesgCheckBox.isChecked());
                    materialDialog.dismiss();
                }).show();
    }
 
Example #16
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
public void resetDisplayedLog(String filename) {
    mLogListAdapter.clear();
    mCurrentlyOpenLog = filename;
    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(getApplicationContext());
    addFiltersToSuggestions(); // filters are what initial populate the suggestions
    updateUiForFilename();
    resetFilter();
}
 
Example #17
Source File: LogcatActivity.java    From matlog 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 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 #19
Source File: RecordingWidgetProvider.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    log.d("onUpdate() for appWidgetIds %s", Arrays.toString(appWidgetIds));
    log.d("appWidgetIds are %s", Arrays.toString(appWidgetIds));

    // track which widgets were created, since there's a bug in the android system that lets
    // stale app widget ids stick around
    PreferenceHelper.setWidgetExistsPreference(context, appWidgetIds);

    WidgetHelper.updateWidgets(context, appWidgetIds);
}
 
Example #20
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 #21
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 #22
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 #23
Source File: RecordingWidgetProvider.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    log.d("onUpdate() for appWidgetIds %s", Arrays.toString(appWidgetIds));
    log.d("appWidgetIds are %s", Arrays.toString(appWidgetIds));

    // track which widgets were created, since there's a bug in the android system that lets
    // stale app widget ids stick around
    PreferenceHelper.setWidgetExistsPreference(context, appWidgetIds);

    WidgetHelper.updateWidgets(context, appWidgetIds);
}
 
Example #24
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public void resetDisplayedLog(String filename) {
    mLogListAdapter.clear();
    mCurrentlyOpenLog = filename;
    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(getApplicationContext());
    addFiltersToSuggestions(); // filters are what initial populate the suggestions
    updateUiForFilename();
    resetFilter();
}
 
Example #25
Source File: RecordingWidgetProvider.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    log.d("onUpdate() for appWidgetIds %s", Arrays.toString(appWidgetIds));
    log.d("appWidgetIds are %s", Arrays.toString(appWidgetIds));

    // track which widgets were created, since there's a bug in the android system that lets
    // stale app widget ids stick around
    PreferenceHelper.setWidgetExistsPreference(context, appWidgetIds);

    WidgetHelper.updateWidgets(context, appWidgetIds);
}
 
Example #26
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void resetDisplayedLog(String filename) {
    mLogListAdapter.clear();
    mCurrentlyOpenLog = filename;
    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(getApplicationContext());
    addFiltersToSuggestions(); // filters are what initial populate the suggestions
    updateUiForFilename();
    resetFilter();
}
 
Example #27
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 #28
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 #29
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();

    }
 
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 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();
        }
    }