List of usage examples for android.graphics.drawable GradientDrawable GradientDrawable
private GradientDrawable(@NonNull GradientState state, @Nullable Resources res)
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeListBox() { this.listBox = new SkyLayout(this); listBox.setBackgroundColor(Color.TRANSPARENT); // listBox.setBackgroundColor(this.themes.get(this.themeIndex).backgroundColor | 0xD0000000); listTopButton = new Button(this); listTopButton.setId(9009);//ww w . j a v a 2s. co m listTopButton.setOnClickListener(listener); listTopButton.setBackgroundColor(Color.TRANSPARENT); GradientDrawable gradForChecked = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xff407ee6, 0xff6ca2f9 }); GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xfff4f4f4, 0xffcdcdcd }); this.contentListButton = new Button(this); this.contentListButton.setId(2700); this.contentListButton.setOnClickListener(listener); this.contentListButton.setText(getString(R.string.contents)); this.contentListButton.setTextSize(13); this.bookmarkListButton = new Button(this); this.bookmarkListButton.setId(2701); this.bookmarkListButton.setOnClickListener(listener); this.bookmarkListButton.setText(getString(R.string.bookmark)); this.bookmarkListButton.setTextSize(13); this.highlightListButton = new Button(this); this.highlightListButton.setId(2702); this.highlightListButton.setOnClickListener(listener); this.highlightListButton.setText(getString(R.string.highlight)); this.highlightListButton.setTextSize(13); this.listScrollView = new ScrollView(this); this.listView = new LinearLayout(this); listView.setOrientation(LinearLayout.VERTICAL); this.listBox.addView(listTopButton); this.listBox.addView(contentListButton); this.listBox.addView(bookmarkListButton); this.listBox.addView(highlightListButton); this.listBox.addView(listScrollView); this.listScrollView.addView(listView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.ePubView.addView(this.listBox); this.hideListBox(); }
From source file:com.skytree.epubtest.BookViewActivity.java
public void checkListButton(int index) { GradientDrawable gradChecked = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xff407ee6, 0xff6ca2f9 }); gradChecked.setStroke(ps(1), Color.BLUE); GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xfff4f4f4, 0xffcdcdcd }); grad.setStroke(ps(1), Color.LTGRAY); listSelectedIndex = index;// www . j a va 2 s .c om Button buttons[] = { contentListButton, bookmarkListButton, highlightListButton }; for (int i = 0; i < buttons.length; i++) { Button button = buttons[i]; button.setBackgroundDrawable(grad); } Button target = buttons[index]; target.setBackgroundDrawable(gradChecked); // show contents.. if (listSelectedIndex == 0) fillContentsList(); else if (listSelectedIndex == 1) fillBookmarkList(); else if (listSelectedIndex == 2) fillHighlightList(); }
From source file:com.skytree.epubtest.BookViewActivity.java
public void fillBookmarkList() { this.listView.removeAllViews(); ArrayList<PageInformation> pis = sd.fetchBookmarks(this.bookCode); for (int i = 0; i < pis.size(); i++) { int textColor = Color.BLACK; Theme theme = getCurrentTheme(); textColor = theme.foregroundColor; PageInformation pi = pis.get(i); SkyLayout item = new SkyLayout(this); setFrame(item, 0, 0, listBox.getWidth(), ps(80)); ImageButton mark = this.makeImageButton(9898, R.drawable.bookmarked2x, ps(50), ps(90)); item.addView(mark);//w w w . ja va 2 s. co m setFrame(mark, ps(10), ps(5), ps(60), ps(120)); int ci = pi.chapterIndex; if (rv.isRTL()) { ci = rv.getNumberOfChapters() - ci - 1; } String chapterTitle = rv.getChapterTitle(ci); if (chapterTitle == null || chapterTitle.isEmpty()) chapterTitle = "Chapter " + ci; TextView chapterLabel = this.makeLabel(9899, chapterTitle, Gravity.LEFT, 16, textColor); setFrame(chapterLabel, ps(80), ps(5), this.listBox.getWidth() - ps(80), ps(40)); item.addView(chapterLabel); TextView dateLabel = this.makeLabel(9899, pi.datetime, Gravity.LEFT, 12, textColor); setFrame(dateLabel, this.listBox.getWidth() - ps(50 + 250), ps(48), this.listBox.getWidth() - ps(40), ps(40)); View lineView = new View(this); lineView.setBackgroundColor(Color.LTGRAY); setFrame(lineView, 0, ps(79), this.listBox.getWidth(), ps(1)); item.addView(dateLabel); item.addView(lineView); item.setSkyLayoutListener(bookmarkListDelegate); item.setId(pi.code); item.data = pi; Button deleteButton = new Button(this); GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xffcf666e, 0xff671521 }); grad.setStroke(ps(2), 0xff282828); deleteButton.setBackgroundDrawable(grad); deleteButton.setText(getString(R.string.delete)); deleteButton.setTextSize(12); deleteButton.setTypeface(null, Typeface.BOLD); deleteButton.setTextColor(Color.WHITE); deleteButton.setId(pi.code); deleteButton.setVisibility(View.INVISIBLE); deleteButton.setVisibility(View.GONE); deleteButton.setOnClickListener(deleteBookmarkDelegate); int dw = ps(120); int dh = ps(50); setFrame(deleteButton, this.listView.getWidth() - dw, (ps(80) - dh) / 2, dw, dh); item.deleteControl = deleteButton; item.addView(deleteButton); this.listView.addView(item); } }
From source file:com.skytree.epubtest.BookViewActivity.java
public void fillHighlightList() { Theme theme = getCurrentTheme();//from www. jav a2 s . c o m int textColor = theme.foregroundColor; this.listView.removeAllViews(); Highlights highlights = sd.fetchAllHighlights(this.bookCode); for (int i = 0; i < highlights.getSize(); i++) { Highlight highlight = highlights.getHighlight(i); SkyLayout item = new SkyLayout(this); int ci = highlight.chapterIndex; if (rv.isRTL()) { ci = rv.getNumberOfChapters() - ci - 1; } String chapterTitle = rv.getChapterTitle(ci); if (chapterTitle == null || chapterTitle.isEmpty()) chapterTitle = "Chapter " + ci; TextView chapterLabel = this.makeLabel(9899, chapterTitle, Gravity.LEFT, 16, textColor); setFrame(chapterLabel, ps(20), ps(5), this.listView.getWidth() - ps(20), ps(40)); item.addView(chapterLabel); GradientDrawable textGrad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { getBrighterColor(highlight.color), getDarkerColor(highlight.color) }); TextView textLabel = this.makeLabel(9899, highlight.text, Gravity.LEFT, 16, Color.BLACK); setFrame(textLabel, ps(20), ps(5 + 40 + 5), this.listView.getWidth() - ps(20), ps(70)); textLabel.setBackgroundDrawable(textGrad); textLabel.getBackground().setAlpha(180); item.addView(textLabel); int noteHeight = 0; if (highlight.isNote && highlight.note != null && highlight.note.length() != 0 && !highlight.note.equalsIgnoreCase("null")) { TextView noteLabel = this.makeLabel(9899, highlight.note, Gravity.LEFT, 16, Color.BLACK); noteLabel.setTextColor(getDarkerColor(highlight.color)); noteHeight = 70; setFrame(noteLabel, ps(20), ps(5 + 40 + 5 + 70 + 5), this.listView.getWidth() - ps(20), ps(noteHeight)); item.addView(noteLabel); } TextView dateLabel = this.makeLabel(9899, highlight.datetime, Gravity.RIGHT, 12, textColor); int lw = this.listView.getWidth(); setFrame(dateLabel, 0, ps(5 + 40 + 5 + 70 + 5 + noteHeight + 5), lw, ps(40)); item.addView(dateLabel); int itemHeight = ps(5 + 40 + 5 + 90 + 5 + noteHeight + 5 + 15 + 5); View lineView = new View(this); lineView.setBackgroundColor(Color.LTGRAY); setFrame(lineView, 0, itemHeight - ps(1), this.listView.getWidth(), ps(1)); item.addView(lineView); setFrame(item, 0, 0, listView.getWidth(), itemHeight); item.setSkyLayoutListener(highlightListDelegate); item.setId(highlight.code); item.data = highlight; Button deleteButton = new Button(this); GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xffcf666e, 0xff671521 }); grad.setStroke(ps(2), 0xff282828); deleteButton.setBackgroundDrawable(grad); deleteButton.setText(getString(R.string.delete)); deleteButton.setTypeface(null, Typeface.BOLD); deleteButton.setTextColor(Color.WHITE); deleteButton.setTextSize(12); deleteButton.setId(highlight.code); deleteButton.setVisibility(View.INVISIBLE); deleteButton.setVisibility(View.GONE); deleteButton.setOnClickListener(deleteHighlightDelegate); int dw = ps(120); int dh = ps(50); setFrame(deleteButton, this.listView.getWidth() - dw, (itemHeight - dh) / 2, dw, dh); item.deleteControl = deleteButton; item.addView(deleteButton); this.listView.addView(item); } }