Search in sources :

Example 1 with ColorScheme

use of com.nolanlawson.keepscore.helper.ColorScheme in project KeepScore by nolanlawson.

the class GameActivity method setOrUpdateColorScheme.

private void setOrUpdateColorScheme() {
    ColorScheme colorScheme = PreferenceHelper.getColorScheme(this);
    int foregroundColor = getResources().getColor(colorScheme.getForegroundColorResId());
    int backgroundColor = getResources().getColor(colorScheme.getBackgroundColorResId());
    int dividerColor = getResources().getColor(colorScheme.getDividerColorResId());
    rootLayout.setBackgroundColor(backgroundColor);
    for (PlayerView playerView : playerViews) {
        playerView.getNameTextView().setTextColor(foregroundColor);
        playerView.getNameTextView().setTypeface(colorScheme.getPlayerNameTypeface());
        playerView.getScoreTextView().setTextColor(foregroundColor);
        playerView.setNewColorScheme(colorScheme);
        playerView.getDivider1().setBackgroundColor(dividerColor);
        if (playerView.getDivider2() != null) {
            playerView.getDivider2().setBackgroundColor(dividerColor);
        }
        for (Button button : new Button[] { playerView.getPlusButton(), playerView.getMinusButton(), playerView.getDeltaButton1(), playerView.getDeltaButton2(), playerView.getDeltaButton3(), playerView.getDeltaButton4() }) {
            if (button != null) {
                button.setBackgroundDrawable(getResources().getDrawable(colorScheme.getButtonBackgroundDrawableResId()));
                button.setTextColor(getResources().getColor(colorScheme.getForegroundColorResId()));
            }
        }
        playerView.updateViews();
    }
    if (roundTotalTextView != null) {
        roundTotalTextView.setTextColor(getResources().getColor(colorScheme.getForegroundColorResId()));
    }
}
Also used : Button(android.widget.Button) ColorScheme(com.nolanlawson.keepscore.helper.ColorScheme) PlayerView(com.nolanlawson.keepscore.widget.PlayerView)

Example 2 with ColorScheme

use of com.nolanlawson.keepscore.helper.ColorScheme in project KeepScore by nolanlawson.

the class PlayerView method init.

private void init() {
    // enable or disable onscreen delta buttons based on whether we have
    // enough room onscreen or not
    deltaButtonsViewStub = view.findViewById(R.id.onscreen_delta_buttons_stub);
    if (deltaButtonsViewStub != null) {
        // they're null in portrait mode
        int versionInt = VersionHelper.getVersionSdkIntCompat();
        if (versionInt > VersionHelper.VERSION_DONUT && versionInt < VersionHelper.VERSION_FROYO) {
            // render correctly, so inflate the ViewStubs no matter what
            if (deltaButtonsViewStub instanceof ViewStub) {
                deltaButtonsViewStub = ((ViewStub) deltaButtonsViewStub).inflate();
            }
        }
        deltaButtonsViewStub.setVisibility(showOnscreenDeltaButtons ? View.VISIBLE : View.GONE);
        onscreenDeltaButtonsLayout = (LinearLayout) view.findViewById(R.id.onscreen_delta_buttons_table_layout);
    }
    playerColorView = (PlayerColorView) view.findViewById(R.id.player_color_image);
    tagImageView = (ImageView) view.findViewById(R.id.image_name_tag);
    divider1 = view.findViewById(R.id.player_score_divider_1);
    divider2 = view.findViewById(R.id.player_score_divider_2);
    nameTextView = (AutoResizeTextView) view.findViewById(R.id.text_name);
    scoreTextView = (AutoResizeTextView) view.findViewById(R.id.text_score);
    scoreTextView.resizeText();
    historyTextView = (TextView) view.findViewById(R.id.text_history);
    badgeTextView = (TextView) view.findViewById(R.id.text_badge);
    badgeLinearLayout = (LinearLayout) view.findViewById(R.id.linear_layout_badge);
    minusButton = (Button) view.findViewById(R.id.button_minus);
    plusButton = (Button) view.findViewById(R.id.button_plus);
    deltaButton1 = (Button) view.findViewById(android.R.id.button1);
    deltaButton2 = (Button) view.findViewById(android.R.id.button2);
    deltaButton3 = (Button) view.findViewById(android.R.id.button3);
    deltaButton4 = (Button) view.findViewById(R.id.button4);
    deltaButtons = new Button[] { deltaButton1, deltaButton2, deltaButton3, deltaButton4 };
    for (Button deltaButton : deltaButtons) {
        if (deltaButton != null) {
            deltaButton.setOnClickListener(this);
        }
    }
    minusButton.setOnClickListener(this);
    minusButton.setOnLongClickListener(this);
    plusButton.setOnClickListener(this);
    plusButton.setOnLongClickListener(this);
    historyTextView.setOnClickListener(this);
    historyTextView.setOnLongClickListener(this);
    badgeLinearLayout.setOnClickListener(this);
    ColorScheme colorScheme = PreferenceHelper.getColorScheme(context);
    setNewColorScheme(colorScheme);
    updateViews();
    log.d("history is: %s", playerScore.getHistory());
}
Also used : ViewStub(android.view.ViewStub) Button(android.widget.Button) ColorScheme(com.nolanlawson.keepscore.helper.ColorScheme)

Aggregations

Button (android.widget.Button)2 ColorScheme (com.nolanlawson.keepscore.helper.ColorScheme)2 ViewStub (android.view.ViewStub)1 PlayerView (com.nolanlawson.keepscore.widget.PlayerView)1