Skip to content

Commit

Permalink
fix shortcut bar duplicating
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Martin committed Jan 18, 2015
1 parent dfb68ff commit 6383146
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions app/src/main/java/me/writeily/pro/NoteActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,27 @@ protected void onPause() {
}

private void setupKeyboardBar() {
for (String shortcut : Constants.KEYBOARD_SHORTCUTS) {
Button shortcutButton = new Button(this);
shortcutButton.setText(shortcut);
shortcutButton.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));

shortcutButton.setTextSize(18);
shortcutButton.setTypeface(null, Typeface.BOLD);
shortcutButton.setBackground(getResources().getDrawable(R.drawable.keyboard_shortcut_button));
shortcutButton.setOnClickListener(new KeyboardBarListener());

String theme = PreferenceManager.getDefaultSharedPreferences(this).getString(getString(R.string.pref_theme_key), "");

if (theme.equals(getString(R.string.theme_dark))) {
shortcutButton.setTextColor(getResources().getColor(android.R.color.white));
} else {
shortcutButton.setTextColor(getResources().getColor(R.color.grey));
}
if (keyboardBarView.getChildCount() == 0) {
for (String shortcut : Constants.KEYBOARD_SHORTCUTS) {
Button shortcutButton = new Button(this);
shortcutButton.setText(shortcut);
shortcutButton.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));

shortcutButton.setTextSize(18);
shortcutButton.setTypeface(null, Typeface.BOLD);
shortcutButton.setBackground(getResources().getDrawable(R.drawable.keyboard_shortcut_button));
shortcutButton.setOnClickListener(new KeyboardBarListener());

String theme = PreferenceManager.getDefaultSharedPreferences(this).getString(getString(R.string.pref_theme_key), "");

if (theme.equals(getString(R.string.theme_dark))) {
shortcutButton.setTextColor(getResources().getColor(android.R.color.white));
} else {
shortcutButton.setTextColor(getResources().getColor(R.color.grey));
}

keyboardBarView.addView(shortcutButton);
keyboardBarView.addView(shortcutButton);
}
}
}

Expand Down

0 comments on commit 6383146

Please sign in to comment.