├── .gitignore
├── ADD_FONT.md
├── AndroidBootstrap
├── build.gradle
├── proguard-project.txt
├── push.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ ├── MaterialIcons-Regular.ttf
│ ├── fontawesome-webfont-v470.ttf
│ └── typicons-v207.ttf
│ ├── java
│ └── com
│ │ └── beardedhen
│ │ └── androidbootstrap
│ │ ├── AwesomeTextView.java
│ │ ├── BetaApi.java
│ │ ├── BootstrapAlert.java
│ │ ├── BootstrapBadge.java
│ │ ├── BootstrapBaseThumbnail.java
│ │ ├── BootstrapButton.java
│ │ ├── BootstrapButtonGroup.java
│ │ ├── BootstrapCircleThumbnail.java
│ │ ├── BootstrapDrawableFactory.java
│ │ ├── BootstrapDropDown.java
│ │ ├── BootstrapEditText.java
│ │ ├── BootstrapGroup.java
│ │ ├── BootstrapLabel.java
│ │ ├── BootstrapProgressBar.java
│ │ ├── BootstrapProgressBarGroup.java
│ │ ├── BootstrapText.java
│ │ ├── BootstrapThumbnail.java
│ │ ├── BootstrapWell.java
│ │ ├── IconResolver.java
│ │ ├── TypefaceProvider.java
│ │ ├── api
│ │ ├── attributes
│ │ │ ├── BootstrapBrand.java
│ │ │ ├── BootstrapHeading.java
│ │ │ └── ViewGroupPosition.java
│ │ ├── defaults
│ │ │ ├── ButtonMode.java
│ │ │ ├── DefaultBootstrapBrand.java
│ │ │ ├── DefaultBootstrapHeading.java
│ │ │ ├── DefaultBootstrapSize.java
│ │ │ └── ExpandDirection.java
│ │ └── view
│ │ │ ├── BadgeContainerView.java
│ │ │ ├── BootstrapBadgeView.java
│ │ │ ├── BootstrapBrandView.java
│ │ │ ├── BootstrapHeadingView.java
│ │ │ ├── BootstrapSizeView.java
│ │ │ ├── BootstrapTextView.java
│ │ │ ├── BorderView.java
│ │ │ ├── ButtonModeView.java
│ │ │ ├── OutlineableView.java
│ │ │ ├── ProgressView.java
│ │ │ └── RoundableView.java
│ │ ├── font
│ │ ├── AwesomeTypefaceSpan.java
│ │ ├── FontAwesome.java
│ │ ├── IconSet.java
│ │ ├── MaterialIcons.java
│ │ └── Typicon.java
│ │ └── utils
│ │ ├── ColorUtils.java
│ │ ├── DimenUtils.java
│ │ ├── DrawableUtils.java
│ │ └── ViewUtils.java
│ └── res
│ └── values
│ ├── attrs.xml
│ ├── attrs_font_awesome.xml
│ ├── attrs_materialIcon.xml
│ ├── attrs_typicons.xml
│ ├── colors.xml
│ └── dimens.xml
├── LICENSE.txt
├── README.md
├── TODO.md
├── build.gradle
├── circle.yml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
├── awesome_text_view.png
├── bootstrap_button.png
├── bootstrap_button_group.png
├── bootstrap_circle_thumbnail.png
├── bootstrap_dropdown.png
├── bootstrap_edit_text.png
├── bootstrap_label.png
├── bootstrap_progress_bar.png
├── bootstrap_progress_bar_group.png
├── bootstrap_thumbnail.png
└── bootstrap_well.png
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── fractalwrench
│ │ └── androidbootstrap
│ │ └── sample
│ │ ├── AwesomeTextViewExample.java
│ │ ├── BaseActivity.java
│ │ ├── BootstrapAlertExample.java
│ │ ├── BootstrapBadgeExample.java
│ │ ├── BootstrapButtonExample.java
│ │ ├── BootstrapButtonGroupExample.java
│ │ ├── BootstrapCircleThumbnailExample.java
│ │ ├── BootstrapDropDownExample.java
│ │ ├── BootstrapEditTextExample.java
│ │ ├── BootstrapLabelExample.java
│ │ ├── BootstrapProgressBarExample.java
│ │ ├── BootstrapProgressBarGroupExample.java
│ │ ├── BootstrapThumbnailExample.java
│ │ ├── BootstrapWellExample.java
│ │ ├── CustomBootstrapStyle.java
│ │ ├── HomeActivity.java
│ │ └── SampleApplication.java
│ └── res
│ ├── drawable
│ ├── alpha.png
│ ├── author.jpeg
│ ├── author_small.jpeg
│ ├── caterpillar.jpg
│ ├── daffodil_large.jpg
│ ├── flower.jpg
│ ├── ladybird.jpg
│ ├── landscape_image.png
│ ├── perfect_square.png
│ ├── portrait_image.png
│ ├── small_daffodils.jpeg
│ └── stars.jpg
│ ├── layout
│ ├── activity_base.xml
│ ├── activity_main.xml
│ ├── example_awesome_text_view.xml
│ ├── example_bootstrap_alert.xml
│ ├── example_bootstrap_badge.xml
│ ├── example_bootstrap_button.xml
│ ├── example_bootstrap_button_group.xml
│ ├── example_bootstrap_circle_thumbnail.xml
│ ├── example_bootstrap_dropdown.xml
│ ├── example_bootstrap_edit_text_view.xml
│ ├── example_bootstrap_label.xml
│ ├── example_bootstrap_progress_bar.xml
│ ├── example_bootstrap_progress_bar_group.xml
│ ├── example_bootstrap_thumbnail.xml
│ └── example_bootstrap_well.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # generated files
2 | bin/
3 | gen/
4 |
5 | # Local configuration file (sdk path, etc)
6 | local.properties
7 |
8 | # IntelliJ files
9 | .idea
10 | *.iml
11 |
12 | # gradle directory
13 | .gradle
14 | build/
15 |
16 | # thumbnails
17 | .DS_STORE
18 |
19 | classes/
20 |
--------------------------------------------------------------------------------
/ADD_FONT.md:
--------------------------------------------------------------------------------
1 | Adding a Custom Font
2 | =================
3 |
4 | Android Bootstrap uses Typeface Icon Sets, which provide scalable graphics without the hassle of
5 | adding different drawable sizes for various screen densities. It should be possible to define your
6 | own icon sets by following the instructions below. Please send pull requests if you want an icon set
7 | added to the library by default.
8 |
9 | 1.
10 | Find the [reference sheet](https://fortawesome.github.io/Font-Awesome/cheatsheet/)
11 | for the typeface, and use a script to parse it.
12 | An example [parsing script](https://github.com/Bearded-Hen/AndroidBootstrapSample) is currently available
13 | for the FontAwesome and Typicon typefaces. If possible, please also send a pull request for the script itself!
14 |
15 | 2.
16 | Create a class which implements the IconSet interface. This describes the location of the typeface
17 | in the assets directory, and the icon codes which map to unicode characters. See the default icon sets
18 | for examples.
19 |
20 | 3.
21 | Copy the typeface TTF file to the assets directory.
22 |
23 | 4.
24 | Initialise the custom typeface by calling TypefaceProvider.registerCustomIconSet().
25 |
26 | 5.
27 | Add icons to text using the BootstrapTextBuilder.
28 |
29 | 6.
30 | Test out the new icon set, send a pull request, or raise an issue if something isn't working.
--------------------------------------------------------------------------------
/AndroidBootstrap/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply from: 'push.gradle'
3 |
4 | android {
5 | compileSdkVersion Integer.parseInt(TARGET_SDK_INT)
6 | buildToolsVersion "25.0.3"
7 |
8 | defaultConfig {
9 | minSdkVersion Integer.parseInt(MIN_SDK_INT)
10 | targetSdkVersion Integer.parseInt(TARGET_SDK_INT)
11 | versionCode = Integer.parseInt(VERSION_CODE)
12 | versionName = VERSION_NAME
13 | }
14 | }
15 |
16 | dependencies {
17 | compile 'com.android.support:support-annotations:25.3.1'
18 | compile 'com.android.support:support-v4:25.3.1'
19 | }
20 |
--------------------------------------------------------------------------------
/AndroidBootstrap/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/AndroidBootstrap/push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | apply plugin: 'maven'
17 | apply plugin: 'signing'
18 |
19 | def isReleaseBuild() {
20 | return VERSION_NAME.contains("SNAPSHOT") == false
21 | }
22 |
23 | def getReleaseRepositoryUrl() {
24 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
25 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
26 | }
27 |
28 | def getSnapshotRepositoryUrl() {
29 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
30 | : "https://oss.sonatype.org/content/repositories/snapshots/"
31 | }
32 |
33 | def getRepositoryUsername() {
34 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
35 | }
36 |
37 | def getRepositoryPassword() {
38 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
39 | }
40 |
41 | afterEvaluate { project ->
42 | uploadArchives {
43 | repositories {
44 | mavenDeployer {
45 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
46 |
47 | pom.groupId = GROUP
48 | pom.artifactId = POM_ARTIFACT_ID
49 | pom.version = VERSION_NAME
50 |
51 | repository(url: getReleaseRepositoryUrl()) {
52 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
53 | }
54 | snapshotRepository(url: getSnapshotRepositoryUrl()) {
55 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
56 | }
57 |
58 | pom.project {
59 | name POM_NAME
60 | packaging POM_PACKAGING
61 | description POM_DESCRIPTION
62 | url POM_URL
63 |
64 | scm {
65 | url POM_SCM_URL
66 | connection POM_SCM_CONNECTION
67 | developerConnection POM_SCM_DEV_CONNECTION
68 | }
69 |
70 | licenses {
71 | license {
72 | name POM_LICENCE_NAME
73 | url POM_LICENCE_URL
74 | distribution POM_LICENCE_DIST
75 | }
76 | }
77 |
78 | developers {
79 | developer {
80 | id POM_DEVELOPER_ID
81 | name POM_DEVELOPER_NAME
82 | }
83 | }
84 | }
85 | }
86 | }
87 | }
88 |
89 | signing {
90 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
91 | sign configurations.archives
92 | }
93 |
94 | task androidJavadocs(type: Javadoc) {
95 | source = android.sourceSets.main.java.srcDirs
96 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
97 | }
98 |
99 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
100 | classifier = 'javadoc'
101 | from androidJavadocs.destinationDir
102 | }
103 |
104 | task androidSourcesJar(type: Jar) {
105 | classifier = 'sources'
106 | from android.sourceSets.main.java.sourceFiles
107 | }
108 |
109 | artifacts {
110 | archives androidSourcesJar
111 | archives androidJavadocsJar
112 | }
113 | }
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/assets/MaterialIcons-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/AndroidBootstrap/src/main/assets/MaterialIcons-Regular.ttf
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/assets/fontawesome-webfont-v470.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/AndroidBootstrap/src/main/assets/fontawesome-webfont-v470.ttf
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/assets/typicons-v207.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/AndroidBootstrap/src/main/assets/typicons-v207.ttf
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BetaApi.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | /**
4 | * Any class marked with this annotation is subject to Major API changes which may cause client code
5 | * to break between releases. Use with caution!!!
6 | */
7 | public @interface BetaApi {}
8 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapBadge.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.annotation.NonNull;
7 | import android.util.AttributeSet;
8 | import android.widget.ImageView;
9 |
10 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapBrand;
11 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
12 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
13 | import com.beardedhen.androidbootstrap.api.view.BootstrapBadgeView;
14 | import com.beardedhen.androidbootstrap.api.view.BootstrapBrandView;
15 | import com.beardedhen.androidbootstrap.api.view.BootstrapSizeView;
16 | import com.beardedhen.androidbootstrap.utils.DimenUtils;
17 | import com.beardedhen.androidbootstrap.utils.ViewUtils;
18 |
19 | /**
20 | * See
21 | *
22 | * http://getbootstrap.com/components/#badges
23 | */
24 | @BetaApi
25 | public class BootstrapBadge extends ImageView implements BootstrapSizeView, BootstrapBrandView,
26 | BootstrapBadgeView {
27 |
28 | private String badgeText;
29 | private int size;
30 | private boolean insideContainer;
31 | private BootstrapBrand bootstrapBrand = DefaultBootstrapBrand.REGULAR;
32 | private float bootstrapSize;
33 | private Drawable badgeDrawable;
34 |
35 | public BootstrapBadge(Context context) {
36 | super(context);
37 | init(null);
38 | }
39 |
40 | public BootstrapBadge(Context context, AttributeSet attrs) {
41 | super(context, attrs);
42 | init(attrs);
43 | }
44 |
45 | public BootstrapBadge(Context context, AttributeSet attrs, int defStyleAttr) {
46 | super(context, attrs, defStyleAttr);
47 | init(attrs);
48 | }
49 |
50 | private void init(AttributeSet attrs) {
51 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapBadge);
52 |
53 | try {
54 | int sizeOrdinal = a.getInt(R.styleable.BootstrapBadge_bootstrapSize, -1);
55 |
56 | if (badgeText == null) {
57 | badgeText = a.getString(R.styleable.BootstrapBadge_badgeText);
58 | }
59 |
60 | bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal)
61 | .scaleFactor();
62 | }
63 | finally {
64 | a.recycle();
65 | }
66 |
67 | size = (int) DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_badge_default_size);
68 | updateBootstrapState();
69 | }
70 |
71 | private void updateBootstrapState() {
72 | badgeDrawable = BootstrapDrawableFactory.createBadgeDrawable(getContext(), bootstrapBrand,
73 | (int) (size * bootstrapSize),
74 | (int) (size * bootstrapSize),
75 | badgeText,
76 | insideContainer);
77 |
78 | ViewUtils.setBackgroundDrawable(this, badgeDrawable);
79 | }
80 |
81 | Drawable getBadgeDrawable() {
82 | return badgeDrawable;
83 | }
84 |
85 | @Override public String getBadgeText() {
86 | return badgeText;
87 | }
88 |
89 | @Override public void setBadgeText(String badgeText) {
90 | this.badgeText = badgeText;
91 | updateBootstrapState();
92 | }
93 |
94 | public void setBootstrapBrand(BootstrapBrand bootstrapBrand, boolean insideContainer) {
95 | this.insideContainer = insideContainer;
96 | setBootstrapBrand(bootstrapBrand);
97 | }
98 |
99 | @Override
100 | public void setBootstrapBrand(@NonNull BootstrapBrand bootstrapBrand) {
101 | this.bootstrapBrand = bootstrapBrand;
102 | updateBootstrapState();
103 | }
104 |
105 | @NonNull
106 | @Override
107 | public BootstrapBrand getBootstrapBrand() {
108 | return bootstrapBrand;
109 | }
110 |
111 | @Override
112 | public void setBootstrapSize(DefaultBootstrapSize bootstrapSize) {
113 | this.bootstrapSize = bootstrapSize.scaleFactor();
114 | updateBootstrapState();
115 | }
116 |
117 | @Override
118 | public void setBootstrapSize(float bootstrapSize) {
119 | this.bootstrapSize = bootstrapSize;
120 | updateBootstrapState();
121 | }
122 |
123 | @Override
124 | public float getBootstrapSize() {
125 | return bootstrapSize;
126 | }
127 | }
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapEditText.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.drawable.Drawable;
6 | import android.os.Bundle;
7 | import android.os.Parcelable;
8 | import android.support.annotation.NonNull;
9 | import android.util.AttributeSet;
10 | import android.view.Gravity;
11 | import android.widget.EditText;
12 |
13 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapBrand;
14 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
15 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
16 | import com.beardedhen.androidbootstrap.api.view.BootstrapBrandView;
17 | import com.beardedhen.androidbootstrap.api.view.BootstrapSizeView;
18 | import com.beardedhen.androidbootstrap.api.view.RoundableView;
19 | import com.beardedhen.androidbootstrap.utils.DimenUtils;
20 | import com.beardedhen.androidbootstrap.utils.ViewUtils;
21 |
22 | import java.io.Serializable;
23 |
24 | /**
25 | * BootstrapEditText allows users to enter values like a regular Android EditText, and allows coloring
26 | * via BootstrapBrand, and rounding of its background.
27 | */
28 | public class BootstrapEditText extends EditText implements BootstrapBrandView, RoundableView,
29 | BootstrapSizeView {
30 |
31 | private static final String TAG = "com.beardedhen.androidbootstrap.BootstrapEditText";
32 |
33 | private float baselineFontSize;
34 | private float baselineVertPadding;
35 | private float baselineHoriPadding;
36 | private float baselineStrokeWidth;
37 | private float baselineCornerRadius;
38 |
39 | private BootstrapBrand bootstrapBrand;
40 | private float bootstrapSize;
41 | private boolean rounded;
42 |
43 | public BootstrapEditText(Context context) {
44 | super(context);
45 | initialise(null);
46 | }
47 |
48 | public BootstrapEditText(Context context, AttributeSet attrs) {
49 | super(context, attrs);
50 | initialise(attrs);
51 | }
52 |
53 | public BootstrapEditText(Context context, AttributeSet attrs, int defStyle) {
54 | super(context, attrs, defStyle);
55 | initialise(attrs);
56 | }
57 |
58 | private void initialise(AttributeSet attrs) {
59 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapEditText);
60 |
61 | try {
62 | this.rounded = a.getBoolean(R.styleable.BootstrapEditText_roundedCorners, false);
63 |
64 | int typeOrdinal = a.getInt(R.styleable.BootstrapEditText_bootstrapBrand, -1);
65 | int sizeOrdinal = a.getInt(R.styleable.BootstrapEditText_bootstrapSize, -1);
66 |
67 | this.bootstrapBrand = DefaultBootstrapBrand.fromAttributeValue(typeOrdinal);
68 | this.bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal).scaleFactor();
69 | }
70 | finally {
71 | a.recycle();
72 | }
73 |
74 | baselineFontSize = DimenUtils.pixelsFromSpResource(getContext(), R.dimen.bootstrap_edit_text_default_font_size);
75 | baselineVertPadding = DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_edit_text_vert_padding);
76 | baselineHoriPadding = DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_edit_text_hori_padding);
77 | baselineStrokeWidth = DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_edit_text_edge_width);
78 | baselineCornerRadius = DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_edit_text_corner_radius);
79 |
80 | a = getContext().obtainStyledAttributes(attrs, new int[] {android.R.attr.gravity});
81 | try {
82 | setGravity(a.getInt(0, Gravity.CENTER_VERTICAL)); // center text vertically by default
83 | } finally {
84 | a.recycle();
85 | }
86 | updateBootstrapState();
87 | invalidate();
88 | }
89 |
90 | @Override public Parcelable onSaveInstanceState() {
91 | Bundle bundle = new Bundle();
92 | bundle.putParcelable(TAG, super.onSaveInstanceState());
93 | bundle.putBoolean(RoundableView.KEY, rounded);
94 | bundle.putFloat(BootstrapSizeView.KEY, bootstrapSize);
95 | bundle.putSerializable(BootstrapBrand.KEY, bootstrapBrand);
96 | return bundle;
97 | }
98 |
99 | @Override public void onRestoreInstanceState(Parcelable state) {
100 | if (state instanceof Bundle) {
101 | Bundle bundle = (Bundle) state;
102 | this.rounded = bundle.getBoolean(RoundableView.KEY);
103 | this.bootstrapSize = bundle.getFloat(BootstrapSizeView.KEY);
104 |
105 | Serializable brand = bundle.getSerializable(BootstrapBrand.KEY);
106 |
107 | if (brand instanceof BootstrapBrand) {
108 | bootstrapBrand = (BootstrapBrand) brand;
109 | }
110 | state = bundle.getParcelable(TAG);
111 | }
112 | super.onRestoreInstanceState(state);
113 | updateBootstrapState();
114 | }
115 |
116 | private void updateBootstrapState() {
117 | int vPadding = (int) (baselineVertPadding * bootstrapSize);
118 | int hPadding = (int) (baselineHoriPadding * bootstrapSize);
119 | setPadding(vPadding, hPadding, vPadding, hPadding);
120 |
121 | int strokeWidth = (int) (baselineStrokeWidth * bootstrapSize);
122 | float cornerRadius = baselineCornerRadius * bootstrapSize;
123 |
124 | final float fontSize = baselineFontSize * bootstrapSize;
125 | setTextSize(fontSize);
126 |
127 | Drawable bg = BootstrapDrawableFactory.bootstrapEditText(
128 | getContext(),
129 | bootstrapBrand,
130 | strokeWidth,
131 | cornerRadius,
132 | rounded);
133 |
134 | ViewUtils.setBackgroundDrawable(this, bg);
135 | }
136 |
137 | /*
138 | * Getters/Setters
139 | */
140 |
141 | @Override public void setBootstrapBrand(@NonNull BootstrapBrand bootstrapBrand) {
142 | this.bootstrapBrand = bootstrapBrand;
143 | updateBootstrapState();
144 | }
145 |
146 | @NonNull @Override public BootstrapBrand getBootstrapBrand() {
147 | return bootstrapBrand;
148 | }
149 |
150 | @Override public void setRounded(boolean rounded) {
151 | this.rounded = rounded;
152 | updateBootstrapState();
153 | }
154 |
155 | @Override public boolean isRounded() {
156 | return rounded;
157 | }
158 |
159 | @Override public float getBootstrapSize() {
160 | return bootstrapSize;
161 | }
162 |
163 | @Override public void setBootstrapSize(float bootstrapSize) {
164 | this.bootstrapSize = bootstrapSize;
165 | updateBootstrapState();
166 | }
167 |
168 | @Override public void setBootstrapSize(DefaultBootstrapSize bootstrapSize) {
169 | setBootstrapSize(bootstrapSize.scaleFactor());
170 | }
171 |
172 | }
173 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapGroup.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.LinearLayout;
9 |
10 | /**
11 | * This is a base class that provies methods to get updates when a view is removed or added or rotated and contains abstract methods for the set up of the class.
12 | * @see BootstrapProgressBarGroup
13 | * @see BootstrapButtonGroup
14 | */
15 | abstract class BootstrapGroup extends LinearLayout {
16 |
17 | public BootstrapGroup(Context context) {
18 | super(context);
19 | initialise(null);
20 | }
21 |
22 | public BootstrapGroup(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | initialise(attrs);
25 | }
26 |
27 | public BootstrapGroup(Context context, AttributeSet attrs, int defStyleAttr) {
28 | super(context, attrs, defStyleAttr);
29 | initialise(attrs);
30 | }
31 |
32 | protected abstract void initialise(AttributeSet attrs);
33 |
34 | @Override public void setOrientation(int orientation) {
35 | super.setOrientation(orientation);
36 | updateBootstrapGroup();
37 | }
38 |
39 | protected abstract void updateBootstrapGroup();
40 |
41 |
42 | protected abstract void onBootstrapViewAdded();
43 | protected abstract void onBootstrapViewRemoved();
44 |
45 | @Override
46 | public void addView(View child, int index, ViewGroup.LayoutParams params) {
47 | super.addView(child, index, params);
48 | onBootstrapViewAdded();
49 | }
50 |
51 | @Override
52 | public void removeAllViews() {
53 | super.removeAllViews();
54 | onBootstrapViewRemoved();
55 | }
56 |
57 | @Override
58 | public void removeView(View view) {
59 | super.removeView(view);
60 | onBootstrapViewRemoved();
61 | }
62 |
63 | @Override
64 | public void removeViewInLayout(View view) {
65 | super.removeViewInLayout(view);
66 | onBootstrapViewRemoved();
67 | }
68 |
69 | @Override
70 | public void removeViewsInLayout(int start, int count) {
71 | super.removeViewsInLayout(start, count);
72 | onBootstrapViewRemoved();
73 | }
74 |
75 | @Override
76 | public void removeViewAt(int index) {
77 | View child = getChildAt(index);
78 | super.removeViewAt(index);
79 | onBootstrapViewRemoved();
80 | }
81 |
82 | @Override
83 | public void removeViews(int start, int count) {
84 | super.removeViews(start, count);
85 | onBootstrapViewRemoved();
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapLabel.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Typeface;
6 | import android.graphics.drawable.Drawable;
7 | import android.os.Bundle;
8 | import android.os.Parcelable;
9 | import android.support.annotation.NonNull;
10 | import android.util.AttributeSet;
11 |
12 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapHeading;
13 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapHeading;
14 | import com.beardedhen.androidbootstrap.api.view.BootstrapHeadingView;
15 | import com.beardedhen.androidbootstrap.api.view.RoundableView;
16 | import com.beardedhen.androidbootstrap.utils.ViewUtils;
17 |
18 | import java.io.Serializable;
19 |
20 | /**
21 | * BootstrapLabels are designed for showing text styled with BootstrapBrands - they should be
22 | * considered similar to a BootstrapButton, but without the press functionality. It is possible to
23 | * set the size of BootstrapLabels using H1-H6 elements.
24 | */
25 | public class BootstrapLabel extends AwesomeTextView implements RoundableView, BootstrapHeadingView {
26 |
27 | private static final String TAG = "com.beardedhen.androidbootstrap.BootstrapLabel";
28 |
29 | private BootstrapHeading bootstrapHeading;
30 | private boolean roundable;
31 |
32 | public BootstrapLabel(Context context) {
33 | super(context);
34 | initialise(null);
35 | }
36 |
37 | public BootstrapLabel(Context context, AttributeSet attrs) {
38 | super(context, attrs);
39 | initialise(attrs);
40 | }
41 |
42 | public BootstrapLabel(Context context, AttributeSet attrs, int defStyle) {
43 | super(context, attrs, defStyle);
44 | initialise(attrs);
45 | }
46 |
47 | private void initialise(AttributeSet attrs) {
48 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapLabel);
49 |
50 | try {
51 | int attrValue = a.getInt(R.styleable.BootstrapLabel_bootstrapHeading, 5);
52 | this.roundable = a.getBoolean(R.styleable.BootstrapLabel_roundedCorners, false);
53 |
54 | this.bootstrapHeading = DefaultBootstrapHeading.fromAttributeValue(attrValue);
55 | }
56 | finally {
57 | a.recycle();
58 | }
59 | updateBootstrapState();
60 | }
61 |
62 | @Override public Parcelable onSaveInstanceState() {
63 | Bundle bundle = new Bundle();
64 | bundle.putParcelable(TAG, super.onSaveInstanceState());
65 | bundle.putBoolean(RoundableView.KEY, roundable);
66 | bundle.putSerializable(BootstrapHeading.KEY, bootstrapHeading);
67 | return bundle;
68 | }
69 |
70 | @Override public void onRestoreInstanceState(Parcelable state) {
71 | if (state instanceof Bundle) {
72 | Bundle bundle = (Bundle) state;
73 |
74 | this.roundable = bundle.getBoolean(RoundableView.KEY);
75 |
76 | Serializable heading = bundle.getSerializable(BootstrapHeading.KEY);
77 |
78 | if (heading instanceof BootstrapHeading) {
79 | bootstrapHeading = (BootstrapHeading) heading;
80 | }
81 | state = bundle.getParcelable(TAG);
82 | }
83 | super.onRestoreInstanceState(state);
84 | updateBootstrapState();
85 | }
86 |
87 | @Override public void updateBootstrapState() {
88 | super.updateBootstrapState();
89 | // set bg color etc
90 |
91 | if (bootstrapHeading != null) {
92 | int vert = (int) bootstrapHeading.verticalPadding(getContext());
93 | int hori = (int) bootstrapHeading.horizontalPadding(getContext());
94 |
95 | setPadding(hori, vert, hori, vert);
96 | setTextSize(bootstrapHeading.getTextSize(getContext()));
97 | }
98 |
99 | setTextColor(getBootstrapBrand().defaultTextColor(getContext()));
100 | setTypeface(Typeface.DEFAULT_BOLD);
101 |
102 | Drawable bg = BootstrapDrawableFactory.bootstrapLabel(
103 | getContext(),
104 | getBootstrapBrand(),
105 | roundable,
106 | getHeight());
107 |
108 | ViewUtils.setBackgroundDrawable(this, bg);
109 | }
110 |
111 | @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) {
112 | super.onSizeChanged(w, h, oldw, oldh);
113 |
114 | if (roundable && h != oldh) { // corner radius should always be h/2
115 | updateBootstrapState();
116 | }
117 | }
118 |
119 | /*
120 | * Getters/Setters
121 | */
122 |
123 | @Override public void setRounded(boolean rounded) {
124 | this.roundable = rounded;
125 | updateBootstrapState();
126 | }
127 |
128 | @Override public boolean isRounded() {
129 | return roundable;
130 | }
131 |
132 | @Override public void setBootstrapHeading(@NonNull BootstrapHeading bootstrapHeading) {
133 | this.bootstrapHeading = bootstrapHeading;
134 | updateBootstrapState();
135 | }
136 |
137 | @NonNull @Override public BootstrapHeading getBootstrapHeading() {
138 | return bootstrapHeading;
139 | }
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapText.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 | import android.text.SpannableString;
5 | import android.text.Spanned;
6 |
7 | import com.beardedhen.androidbootstrap.font.AwesomeTypefaceSpan;
8 | import com.beardedhen.androidbootstrap.font.FontAwesome;
9 | import com.beardedhen.androidbootstrap.font.IconSet;
10 | import com.beardedhen.androidbootstrap.font.MaterialIcons;
11 | import com.beardedhen.androidbootstrap.font.Typicon;
12 |
13 | import java.io.Serializable;
14 | import java.util.HashMap;
15 | import java.util.Map;
16 |
17 | /**
18 | * Bootstrap Text provides a Builder class, which allows convenient construction of SpannableStrings.
19 | * Currently regular text, FontAwesome icons, and Typicons can be added.
20 | */
21 | public class BootstrapText extends SpannableString implements Serializable {
22 |
23 | private BootstrapText(CharSequence source) {
24 | super(source);
25 | }
26 |
27 | /**
28 | * This class should be used to construct BootstrapText instances. Text is appended to itself
29 | * in the order in which it was added.
30 | */
31 | public static class Builder {
32 |
33 | private final StringBuilder sb;
34 | private final Context context;
35 | private final boolean editMode;
36 | private final Map fontIndicesMap;
37 |
38 | public Builder(Context context) {
39 | fontIndicesMap = new HashMap<>();
40 | sb = new StringBuilder();
41 | this.context = context.getApplicationContext();
42 | this.editMode = false;
43 | }
44 |
45 | public Builder(Context context, boolean editMode) {
46 | fontIndicesMap = new HashMap<>();
47 | sb = new StringBuilder();
48 | this.context = context.getApplicationContext();
49 | this.editMode = editMode;
50 | }
51 |
52 | /**
53 | * Appends a regular piece of text to the BootstrapText under construction.
54 | *
55 | * @param text a regular piece of text
56 | * @return the updated builder instance
57 | */
58 | public Builder addText(CharSequence text) {
59 | sb.append(text);
60 | return this;
61 | }
62 |
63 | /**
64 | * Appends a FontAwesomeIcon to the BootstrapText under construction
65 | *
66 | * @return the updated builder instance
67 | */
68 | public Builder addFontAwesomeIcon(@FontAwesome.Icon CharSequence iconCode) {
69 | IconSet iconSet = TypefaceProvider.retrieveRegisteredIconSet(FontAwesome.FONT_PATH, editMode);
70 | sb.append(iconSet.unicodeForKey(iconCode.toString().replaceAll("\\-", "_")));
71 | fontIndicesMap.put(sb.length(), iconSet);
72 | return this;
73 | }
74 |
75 | /**
76 | * Appends a Typicon to the BootstrapText under construction
77 | *
78 | * @return the updated builder instance
79 | */
80 | public Builder addTypicon(@Typicon.Icon CharSequence iconCode) {
81 | IconSet iconSet = TypefaceProvider.retrieveRegisteredIconSet(Typicon.FONT_PATH, editMode);
82 | sb.append(iconSet.unicodeForKey(iconCode.toString().replaceAll("\\-", "_")));
83 | fontIndicesMap.put(sb.length(), iconSet);
84 | return this;
85 | }
86 |
87 | /**
88 | * Appends a Typicon to the BootstrapText under construction
89 | *
90 | * @return the updated builder instance
91 | */
92 | public Builder addMaterialIcon( CharSequence iconCode) {
93 | IconSet iconSet = TypefaceProvider.retrieveRegisteredIconSet(MaterialIcons.FONT_PATH, editMode);
94 | sb.append(iconSet.unicodeForKey(iconCode.toString().replaceAll("\\-", "_")));
95 | fontIndicesMap.put(sb.length(), iconSet);
96 | return this;
97 | }
98 |
99 | /**
100 | * Appends a font icon to the BootstrapText under construction
101 | *
102 | * @param iconSet a font icon
103 | * @return the updated builder instance
104 | */
105 | public Builder addIcon(CharSequence iconCode, IconSet iconSet) {
106 | sb.append(iconSet.unicodeForKey(iconCode.toString().replaceAll("\\-", "_")));
107 | fontIndicesMap.put(sb.length(), iconSet);
108 | return this;
109 | }
110 |
111 | /**
112 | * @return a new instance of BootstrapText, constructed according to Builder arguments.
113 | */
114 | public BootstrapText build() {
115 | BootstrapText bootstrapText = new BootstrapText(sb.toString());
116 |
117 | for (Map.Entry entry : fontIndicesMap.entrySet()) {
118 | int index = entry.getKey();
119 |
120 | AwesomeTypefaceSpan span = new AwesomeTypefaceSpan(context, entry.getValue());
121 | bootstrapText.setSpan(span, index - 1, index, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
122 | }
123 | return bootstrapText;
124 | }
125 | }
126 |
127 | }
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapThumbnail.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.RectF;
8 | import android.graphics.drawable.Drawable;
9 | import android.os.Build;
10 | import android.os.Bundle;
11 | import android.os.Parcelable;
12 | import android.util.AttributeSet;
13 |
14 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
15 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
16 | import com.beardedhen.androidbootstrap.api.view.RoundableView;
17 | import com.beardedhen.androidbootstrap.utils.ColorUtils;
18 | import com.beardedhen.androidbootstrap.utils.ViewUtils;
19 |
20 | /**
21 | * BootstrapThumbnail displays a rectangular image with an optional border, that can be
22 | * themed. The view extends ImageView, and will automatically center crop and
23 | * scale images.
24 | */
25 | public class BootstrapThumbnail extends BootstrapBaseThumbnail implements RoundableView {
26 |
27 | private static final String TAG = "com.beardedhen.androidbootstrap.BootstrapThumbnail";
28 |
29 | private Paint placeholderPaint;
30 | private final RectF imageRect = new RectF();
31 |
32 | private boolean roundedCorners;
33 | private float baselineCornerRadius;
34 |
35 | public BootstrapThumbnail(Context context) {
36 | super(context);
37 | initialise(null);
38 | }
39 |
40 | public BootstrapThumbnail(Context context, AttributeSet attrs) {
41 | super(context, attrs);
42 | initialise(attrs);
43 | }
44 |
45 | public BootstrapThumbnail(Context context, AttributeSet attrs, int defStyle) {
46 | super(context, attrs, defStyle);
47 | initialise(attrs);
48 | }
49 |
50 | @Override public Parcelable onSaveInstanceState() {
51 | Bundle bundle = new Bundle();
52 | bundle.putParcelable(TAG, super.onSaveInstanceState());
53 | bundle.putBoolean(RoundableView.KEY, roundedCorners);
54 | return bundle;
55 | }
56 |
57 | @Override public void onRestoreInstanceState(Parcelable state) {
58 | if (state instanceof Bundle) {
59 | Bundle bundle = (Bundle) state;
60 | this.roundedCorners = bundle.getBoolean(RoundableView.KEY);
61 | state = bundle.getParcelable(TAG);
62 | }
63 | super.onRestoreInstanceState(state);
64 | }
65 |
66 | protected void initialise(AttributeSet attrs) {
67 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapThumbnail);
68 |
69 | try {
70 | int typeOrdinal = a.getInt(R.styleable.BootstrapThumbnail_bootstrapBrand, -1);
71 | int sizeOrdinal = a.getInt(R.styleable.BootstrapThumbnail_bootstrapSize, -1);
72 |
73 | this.hasBorder = a.getBoolean(R.styleable.BootstrapCircleThumbnail_hasBorder, true);
74 | this.bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal).scaleFactor();
75 |
76 | if (typeOrdinal == -1) { // override to use Primary for default border (looks nicer)
77 | this.bootstrapBrand = DefaultBootstrapBrand.PRIMARY;
78 | }
79 | else {
80 | this.bootstrapBrand = DefaultBootstrapBrand.fromAttributeValue(typeOrdinal);
81 | }
82 | }
83 | finally {
84 | a.recycle();
85 | }
86 |
87 | placeholderPaint = new Paint();
88 | placeholderPaint.setColor(ColorUtils.resolveColor(R.color.bootstrap_gray_light, getContext()));
89 | placeholderPaint.setStyle(Paint.Style.FILL);
90 | placeholderPaint.setAntiAlias(true);
91 |
92 | this.baselineCornerRadius = getResources().getDimension(R.dimen.bthumbnail_rounded_corner);
93 | this.baselineBorderWidth = getResources().getDimension(R.dimen.bthumbnail_default_border);
94 | setScaleType(ScaleType.CENTER_CROP);
95 |
96 | super.initialise(attrs);
97 | }
98 |
99 | protected void updateImageState() {
100 | updateBackground();
101 | updatePadding();
102 | invalidate();
103 | }
104 |
105 | private void updateBackground() {
106 | Drawable bg = null;
107 |
108 | if (hasBorder) {
109 | bg = BootstrapDrawableFactory.bootstrapThumbnail(
110 | getContext(),
111 | bootstrapBrand,
112 | (int) (baselineOuterBorderWidth * bootstrapSize),
113 | ColorUtils.resolveColor(R.color.bootstrap_thumbnail_background, getContext()),
114 | roundedCorners);
115 | }
116 | ViewUtils.setBackgroundDrawable(this, bg);
117 | }
118 |
119 | private void updatePadding() {
120 | if (Build.VERSION.SDK_INT >= 16) {
121 | int p = hasBorder ? (int) (baselineBorderWidth * bootstrapSize) : 0;
122 | setPadding(p, p, p, p);
123 | setCropToPadding(hasBorder);
124 | }
125 | }
126 |
127 | @Override protected void onDraw(Canvas canvas) {
128 | if (sourceBitmap == null) { // draw a placeholder
129 |
130 | float padding = hasBorder ? (baselineBorderWidth * bootstrapSize) : 0;
131 | imageRect.top = padding;
132 | imageRect.bottom = getHeight() - padding;
133 | imageRect.left = padding;
134 | imageRect.right = getWidth() - padding;
135 |
136 | if (roundedCorners) {
137 | canvas.drawRoundRect(
138 | imageRect,
139 | (baselineCornerRadius * bootstrapSize),
140 | (baselineCornerRadius * bootstrapSize),
141 | placeholderPaint);
142 | }
143 | else {
144 | canvas.drawRect(imageRect, placeholderPaint);
145 | }
146 | }
147 | else {
148 | super.onDraw(canvas);
149 | }
150 | }
151 |
152 | /*
153 | * Getters/setters
154 | */
155 |
156 | @Override public void setRounded(boolean rounded) {
157 | this.roundedCorners = rounded;
158 | updateImageState();
159 | }
160 |
161 | @Override public boolean isRounded() {
162 | return roundedCorners;
163 | }
164 |
165 | }
166 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.drawable.Drawable;
6 | import android.util.AttributeSet;
7 | import android.widget.FrameLayout;
8 |
9 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
10 | import com.beardedhen.androidbootstrap.utils.ColorUtils;
11 | import com.beardedhen.androidbootstrap.utils.DimenUtils;
12 | import com.beardedhen.androidbootstrap.utils.ViewUtils;
13 |
14 | /**
15 | * BootstrapWells are used as a container layout for other views, typically text.
16 | */
17 | public class BootstrapWell extends FrameLayout {
18 |
19 | private float bootstrapSize;
20 |
21 | public BootstrapWell(Context context) {
22 | super(context);
23 | initialise(null);
24 | }
25 |
26 | public BootstrapWell(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 | initialise(attrs);
29 | }
30 |
31 | public BootstrapWell(Context context, AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | initialise(attrs);
34 | }
35 |
36 | private void initialise(AttributeSet attrs) {
37 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapButton);
38 |
39 | try {
40 | int sizeOrdinal = a.getInt(R.styleable.BootstrapButton_bootstrapSize, -1);
41 | bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal).scaleFactor();
42 | }
43 | finally {
44 | a.recycle();
45 | }
46 | updateBootstrapState();
47 | }
48 |
49 | private void updateBootstrapState() {
50 | Drawable bg = BootstrapDrawableFactory.bootstrapWell(ColorUtils.resolveColor(R.color.bootstrap_well_background, getContext()),
51 | (int) (DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_well_corner_radius) * bootstrapSize / 2),
52 | (int) DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_well_stroke_width),
53 | ColorUtils.resolveColor(R.color.bootstrap_well_border_color, getContext()));
54 |
55 | ViewUtils.setBackgroundDrawable(this, bg);
56 |
57 | int padding = (int) (DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_well_default_padding) * bootstrapSize * 2.5);
58 | setPadding(padding, padding, padding, padding);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/IconResolver.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 |
5 | import com.beardedhen.androidbootstrap.font.FontAwesome;
6 | import com.beardedhen.androidbootstrap.font.IconSet;
7 | import com.beardedhen.androidbootstrap.font.MaterialIcons;
8 | import com.beardedhen.androidbootstrap.font.Typicon;
9 |
10 | import static com.beardedhen.androidbootstrap.TypefaceProvider.getRegisteredIconSets;
11 | import static com.beardedhen.androidbootstrap.TypefaceProvider.retrieveRegisteredIconSet;
12 |
13 | /**
14 | * Resolves markdown strings using FA codes and produces BootstrapText instances.
15 | */
16 | class IconResolver {
17 |
18 | private static final String REGEX_FONT_AWESOME = "(fa_|fa-)[a-z_0-9]+";
19 | private static final String REGEX_TYPICONS = "(ty_|ty-)[a-z_0-9]+";
20 | private static final String REGEX_MATERIAL_ICONS = "(md_)[a-z_0-9]+";
21 |
22 | /**
23 | * Resolves markdown to produce a BootstrapText instance. e.g. "{fa_android}" would be replaced
24 | * with the appropriate FontAwesome character and a SpannableString producec.
25 | *
26 | * @param context the current context
27 | * @param markdown the markdown string
28 | * @param editMode - whether the view requesting the icon set is displayed in the preview editor
29 | * @return a constructed BootstrapText
30 | */
31 | static BootstrapText resolveMarkdown(Context context, String markdown, boolean editMode) {
32 | if (markdown == null) {
33 | return null;
34 | }
35 | else { // detect {fa_*} and split into spannable, ignore escaped chars
36 | BootstrapText.Builder builder = new BootstrapText.Builder(context, editMode);
37 |
38 | int lastAddedIndex = 0;
39 | int startIndex = -1;
40 | int endIndex = -1;
41 |
42 | for (int i = 0; i < markdown.length(); i++) {
43 | char c = markdown.charAt(i);
44 |
45 | if (c == '\\') { // escape sequence, ignore next char
46 | i += 2;
47 | continue;
48 | }
49 |
50 | if (c == '{') {
51 | startIndex = i;
52 | }
53 | else if (c == '}') {
54 | endIndex = i;
55 | }
56 |
57 | if (startIndex != -1 && endIndex != -1) { // recognised markdown string
58 |
59 | if (startIndex >= 0 && endIndex < markdown.length()) {
60 | String iconCode = markdown.substring(startIndex + 1, endIndex).replaceAll("\\-", "_");
61 | builder.addText(markdown.substring(lastAddedIndex, startIndex));
62 |
63 | if (iconCode.matches(REGEX_FONT_AWESOME)) { // text is FontAwesome code
64 | if (editMode) {
65 | builder.addText("?");
66 | }
67 | else {
68 | builder.addIcon(iconCode, retrieveRegisteredIconSet(FontAwesome.FONT_PATH, false));
69 | }
70 | }
71 | else if (iconCode.matches(REGEX_TYPICONS)) {
72 | if (editMode) {
73 | builder.addText("?");
74 | }
75 | else {
76 | builder.addIcon(iconCode, retrieveRegisteredIconSet(Typicon.FONT_PATH, false));
77 | }
78 | }
79 | else if(iconCode.matches(REGEX_MATERIAL_ICONS)){
80 | if (editMode) {
81 | builder.addText("?");
82 | }
83 | else {
84 | builder.addIcon(iconCode, retrieveRegisteredIconSet(MaterialIcons.FONT_PATH, false));
85 | }
86 | }
87 | else {
88 | if (editMode) {
89 | builder.addText("?");
90 | }
91 | else {
92 | builder.addIcon(iconCode, resolveIconSet(iconCode));
93 | }
94 | }
95 | lastAddedIndex = endIndex + 1;
96 | }
97 | startIndex = -1;
98 | endIndex = -1;
99 | }
100 | }
101 | return builder.addText(markdown.substring(lastAddedIndex, markdown.length())).build();
102 | }
103 | }
104 |
105 | /**
106 | * Searches for the unicode character value for the Font Icon Code. This method searches all
107 | * active FontIcons in the application.
108 | *
109 | * @param iconCode the font icon code
110 | * @return the unicode character matching the icon, or null if none matches
111 | */
112 | private static IconSet resolveIconSet(String iconCode) {
113 | CharSequence unicode;
114 |
115 | for (IconSet set : getRegisteredIconSets()) {
116 |
117 | if (set.fontPath().equals(FontAwesome.FONT_PATH) || set.fontPath().equals(Typicon.FONT_PATH) || set.fontPath().equals(MaterialIcons.FONT_PATH)) {
118 | continue; // already checked previously, ignore
119 | }
120 |
121 | unicode = set.unicodeForKey(iconCode);
122 |
123 | if (unicode != null) {
124 | return set;
125 | }
126 | }
127 |
128 | String message = String.format("Could not find FontIcon value for '%s', " +
129 | "please ensure that it is mapped to a valid font", iconCode);
130 |
131 | throw new IllegalArgumentException(message);
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/TypefaceProvider.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 |
6 | import com.beardedhen.androidbootstrap.font.FontAwesome;
7 | import com.beardedhen.androidbootstrap.font.IconSet;
8 | import com.beardedhen.androidbootstrap.font.MaterialIcons;
9 | import com.beardedhen.androidbootstrap.font.Typicon;
10 |
11 | import java.util.Collection;
12 | import java.util.HashMap;
13 | import java.util.Map;
14 |
15 | /**
16 | * Holds static instances of Typefaces, and IconSets, allowing views to use them across the application
17 | * without expensive initialisation.
18 | */
19 | public class TypefaceProvider {
20 |
21 | private final static Map TYPEFACE_MAP = new HashMap<>();
22 | private final static Map REGISTERED_ICON_SETS = new HashMap<>();
23 |
24 | /**
25 | * Returns a reference to the requested typeface, creating a new instance if none already exists
26 | *
27 | * @param context the current context
28 | * @param iconSet the icon typeface
29 | * @return a reference to the typeface instance
30 | */
31 | public static Typeface getTypeface(Context context, IconSet iconSet) {
32 | String path = iconSet.fontPath().toString();
33 |
34 | if (TYPEFACE_MAP.get(path) == null) {
35 | final Typeface font = Typeface.createFromAsset(context.getAssets(), path);
36 | TYPEFACE_MAP.put(path, font);
37 | }
38 | return TYPEFACE_MAP.get(path);
39 | }
40 |
41 | /**
42 | * Registers instances of the Default IconSets so that they are available throughout the whole
43 | * application. Currently the default icon sets include FontAwesome and Typicon.
44 | */
45 | public static void registerDefaultIconSets() {
46 | final FontAwesome fontAwesome = new FontAwesome();
47 | final Typicon typicon = new Typicon();
48 | final MaterialIcons materialIcons = new MaterialIcons();
49 |
50 | REGISTERED_ICON_SETS.put(fontAwesome.fontPath(), fontAwesome);
51 | REGISTERED_ICON_SETS.put(typicon.fontPath(), typicon);
52 | REGISTERED_ICON_SETS.put(materialIcons.fontPath(), materialIcons);
53 | }
54 |
55 | /**
56 | * Registers a custom IconSet, so that it is available for use throughout the whole application.
57 | *
58 | * @param iconSet a custom IconSet
59 | */
60 | public static void registerCustomIconSet(IconSet iconSet) {
61 | REGISTERED_ICON_SETS.put(iconSet.fontPath(), iconSet);
62 | }
63 |
64 | /**
65 | * Retrieves a registered IconSet whose font can be found in the asset directory at the given path
66 | *
67 | * @param fontPath the given path
68 | * @param editMode - whether the view requesting the icon set is displayed in the preview editor
69 | * @return the registered IconSet instance
70 | */
71 | public static IconSet retrieveRegisteredIconSet(String fontPath, boolean editMode) {
72 | final IconSet iconSet = REGISTERED_ICON_SETS.get(fontPath);
73 |
74 | if (iconSet == null && !editMode) {
75 | throw new RuntimeException(String.format("Font '%s' not properly registered, please" +
76 | " see the README at https://github.com/Bearded-Hen/Android-Bootstrap", fontPath));
77 | }
78 | return iconSet;
79 | }
80 |
81 | /**
82 | * Retrieves a collection of all registered IconSets in the application
83 | *
84 | * @return a collection of registered IconSets.
85 | */
86 | public static Collection getRegisteredIconSets() {
87 | return REGISTERED_ICON_SETS.values();
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/attributes/BootstrapBrand.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.attributes;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.ColorInt;
5 |
6 | import java.io.Serializable;
7 |
8 | /**
9 | * A Bootstrap Brand is a color which is used universally across many Bootstrap Views. An example is
10 | * the 'Info' Brand which colors views light blue.
11 | */
12 | public interface BootstrapBrand extends Serializable {
13 |
14 | String KEY = "BootstrapBrand";
15 |
16 | /**
17 | * Retrieves the color that should be used for the default fill state
18 | *
19 | * @param context the current context
20 | * @return the color for the current brand
21 | */
22 | @ColorInt int defaultFill(Context context);
23 |
24 | /**
25 | * Retrieves the color that should be used for the default border state
26 | *
27 | * @param context the current context
28 | * @return the color for the current brand
29 | */
30 | @ColorInt int defaultEdge(Context context);
31 |
32 | /**
33 | * Retrieves the text color that should be used for the default state
34 | *
35 | * @param context the current context
36 | * @return the color for the current brand
37 | */
38 | @ColorInt int defaultTextColor(Context context);
39 |
40 | /**
41 | * Retrieves the color that should be used for the active fill state
42 | *
43 | * @param context the current context
44 | * @return the color for the current brand
45 | */
46 | @ColorInt int activeFill(Context context);
47 |
48 | /**
49 | * Retrieves the color that should be used for the active border state
50 | *
51 | * @param context the current context
52 | * @return the color for the current brand
53 | */
54 | @ColorInt int activeEdge(Context context);
55 |
56 | /**
57 | * Retrieves the text color that should be used for the active state
58 | *
59 | * @param context the current context
60 | * @return the color for the current brand
61 | */
62 | @ColorInt int activeTextColor(Context context);
63 |
64 | /**
65 | * Retrieves the color that should be used for the disabled fill state
66 | *
67 | * @param context the current context
68 | * @return the color for the current brand
69 | */
70 | @ColorInt int disabledFill(Context context);
71 |
72 | /**
73 | * Retrieves the color that should be used for the disabled border state
74 | *
75 | * @param context the current context
76 | * @return the color for the current brand
77 | */
78 | @ColorInt int disabledEdge(Context context);
79 |
80 | /**
81 | * Retrieves the text color that should be used for the disabled state
82 | *
83 | * @param context the current context
84 | * @return the color for the current brand
85 | */
86 | @ColorInt int disabledTextColor(Context context);
87 |
88 | @ColorInt int getColor();
89 | }
90 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/attributes/BootstrapHeading.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.attributes;
2 |
3 | import android.content.Context;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * A Heading defines the text size and padding of its view. Bootstrap supports styles for H1-H6
9 | * elements out of the box.
10 | */
11 | public interface BootstrapHeading extends Serializable {
12 |
13 | String KEY = "com.beardedhen.androidbootstrap.api.attributes.BootstrapHeading";
14 |
15 | /**
16 | * Retrieves the text size for the current BootstrapHeading.
17 | *
18 | * @param context the current context
19 | * @return the text size
20 | */
21 | float getTextSize(Context context);
22 |
23 | /**
24 | * Retrieves the vertical padding for the current BootstrapHeading
25 | *
26 | * @param context the current context
27 | * @return the vertical padding
28 | */
29 | float verticalPadding(Context context);
30 |
31 | /**
32 | * Retrieves the horizontal padding for the current BootstrapHeading
33 | *
34 | * @param context the current context
35 | * @return the horizontal padding
36 | */
37 | float horizontalPadding(Context context);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/attributes/ViewGroupPosition.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.attributes;
2 |
3 | public enum ViewGroupPosition {
4 | SOLO,
5 | MIDDLE_HORI,
6 | MIDDLE_VERT,
7 | TOP,
8 | BOTTOM,
9 | START,
10 | END
11 | }
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/defaults/ButtonMode.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.defaults;
2 |
3 | public enum ButtonMode {
4 | REGULAR,
5 | TOGGLE,
6 | CHECKBOX,
7 | RADIO;
8 |
9 | public static ButtonMode fromAttributeValue(int attrValue) {
10 | switch (attrValue) {
11 | case 0:
12 | return REGULAR;
13 | case 1:
14 | return TOGGLE;
15 | case 2:
16 | return CHECKBOX;
17 | case 3:
18 | return RADIO;
19 | default:
20 | return REGULAR;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/defaults/DefaultBootstrapBrand.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.defaults;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.ColorInt;
5 |
6 | import com.beardedhen.androidbootstrap.R;
7 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapBrand;
8 |
9 | import static com.beardedhen.androidbootstrap.utils.ColorUtils.ACTIVE_OPACITY_FACTOR_EDGE;
10 | import static com.beardedhen.androidbootstrap.utils.ColorUtils.ACTIVE_OPACITY_FACTOR_FILL;
11 | import static com.beardedhen.androidbootstrap.utils.ColorUtils.DISABLED_ALPHA_EDGE;
12 | import static com.beardedhen.androidbootstrap.utils.ColorUtils.DISABLED_ALPHA_FILL;
13 | import static com.beardedhen.androidbootstrap.utils.ColorUtils.decreaseRgbChannels;
14 | import static com.beardedhen.androidbootstrap.utils.ColorUtils.increaseOpacity;
15 | import static com.beardedhen.androidbootstrap.utils.ColorUtils.resolveColor;
16 |
17 | /**
18 | * Bootstrap provides 6 brands by default - Primary, Success, Info, Warning, Danger, and Default.
19 | * Brands are often supplemented by view-specific colors, which are not globally used.
20 | */
21 | public enum DefaultBootstrapBrand implements BootstrapBrand {
22 |
23 | PRIMARY(R.color.bootstrap_brand_primary),
24 | SUCCESS(R.color.bootstrap_brand_success),
25 | INFO(R.color.bootstrap_brand_info),
26 | WARNING(R.color.bootstrap_brand_warning),
27 | DANGER(R.color.bootstrap_brand_danger),
28 | SECONDARY(R.color.bootstrap_brand_secondary_fill, R.color.bootstrap_brand_secondary_text),
29 | REGULAR(R.color.bootstrap_gray_light);
30 |
31 | private final int textColor;
32 | private final int color;
33 |
34 | DefaultBootstrapBrand(int color) {
35 | this.color = color;
36 | this.textColor = android.R.color.white;
37 | }
38 |
39 | DefaultBootstrapBrand(int color, int textColor) {
40 | this.color = color;
41 | this.textColor = textColor;
42 | }
43 |
44 | public static DefaultBootstrapBrand fromAttributeValue(int attrValue) {
45 | switch (attrValue) {
46 | case 0:
47 | return PRIMARY;
48 | case 1:
49 | return SUCCESS;
50 | case 2:
51 | return INFO;
52 | case 3:
53 | return WARNING;
54 | case 4:
55 | return DANGER;
56 | case 5:
57 | return REGULAR;
58 | case 6:
59 | return SECONDARY;
60 | default:
61 | return REGULAR;
62 | }
63 | }
64 |
65 | @ColorInt public int defaultFill(Context context) {
66 | return resolveColor(color, context);
67 | }
68 |
69 | @ColorInt public int defaultEdge(Context context) {
70 | return decreaseRgbChannels(context, color, ACTIVE_OPACITY_FACTOR_EDGE);
71 | }
72 |
73 | @ColorInt public int activeFill(Context context) {
74 | return decreaseRgbChannels(context, color, ACTIVE_OPACITY_FACTOR_FILL);
75 | }
76 |
77 | @ColorInt public int activeEdge(Context context) {
78 | return decreaseRgbChannels(context, color, ACTIVE_OPACITY_FACTOR_FILL + ACTIVE_OPACITY_FACTOR_EDGE);
79 | }
80 |
81 | @ColorInt public int disabledFill(Context context) {
82 | return increaseOpacity(context, color, DISABLED_ALPHA_FILL);
83 | }
84 |
85 | @ColorInt public int disabledEdge(Context context) {
86 | return increaseOpacity(context, color, DISABLED_ALPHA_FILL - DISABLED_ALPHA_EDGE);
87 | }
88 |
89 | @ColorInt public int defaultTextColor(Context context) {
90 | return resolveColor(textColor, context);
91 | }
92 |
93 | @ColorInt public int activeTextColor(Context context) {
94 | return resolveColor(textColor, context);
95 | }
96 |
97 | @ColorInt public int disabledTextColor(Context context) {
98 | return resolveColor(textColor, context);
99 | }
100 |
101 | @ColorInt public int getColor() {
102 | return color;
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/defaults/DefaultBootstrapHeading.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.defaults;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.DimenRes;
5 |
6 | import com.beardedhen.androidbootstrap.R;
7 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapHeading;
8 | import com.beardedhen.androidbootstrap.utils.DimenUtils;
9 |
10 | /**
11 | * Bootstrap provides styling for elements H1-H6, and sets their text size and padding using the
12 | * values supplied here.
13 | */
14 | public enum DefaultBootstrapHeading implements BootstrapHeading {
15 |
16 | H1(R.dimen.bootstrap_h1_text_size,
17 | R.dimen.bootstrap_h1_vert_padding,
18 | R.dimen.bootstrap_h1_hori_padding),
19 |
20 | H2(R.dimen.bootstrap_h2_text_size,
21 | R.dimen.bootstrap_h2_vert_padding,
22 | R.dimen.bootstrap_h2_hori_padding),
23 |
24 | H3(R.dimen.bootstrap_h3_text_size,
25 | R.dimen.bootstrap_h3_vert_padding,
26 | R.dimen.bootstrap_h3_hori_padding),
27 |
28 | H4(R.dimen.bootstrap_h4_text_size,
29 | R.dimen.bootstrap_h4_vert_padding,
30 | R.dimen.bootstrap_h4_hori_padding),
31 |
32 | H5(R.dimen.bootstrap_h5_text_size,
33 | R.dimen.bootstrap_h5_vert_padding,
34 | R.dimen.bootstrap_h5_hori_padding),
35 |
36 | H6(R.dimen.bootstrap_h6_text_size,
37 | R.dimen.bootstrap_h6_vert_padding,
38 | R.dimen.bootstrap_h6_hori_padding);
39 |
40 | private final @DimenRes int textSize;
41 | private final @DimenRes int vertPadding;
42 | private final @DimenRes int horiPadding;
43 |
44 | DefaultBootstrapHeading(int textSize, int vertPadding, int horiPadding) {
45 | this.textSize = textSize;
46 | this.vertPadding = vertPadding;
47 | this.horiPadding = horiPadding;
48 | }
49 |
50 | public static DefaultBootstrapHeading fromAttributeValue(int attrValue) {
51 | switch (attrValue) {
52 | case 0:
53 | return H1;
54 | case 1:
55 | return H2;
56 | case 2:
57 | return H3;
58 | case 3:
59 | return H4;
60 | case 4:
61 | return H5;
62 | case 5:
63 | return H6;
64 | default:
65 | return H6;
66 | }
67 | }
68 |
69 | @Override public float getTextSize(Context context) {
70 | return DimenUtils.pixelsFromSpResource(context, textSize);
71 | }
72 |
73 | @Override public float verticalPadding(Context context) {
74 | return DimenUtils.pixelsFromDpResource(context, vertPadding);
75 | }
76 |
77 | @Override public float horizontalPadding(Context context) {
78 | return DimenUtils.pixelsFromDpResource(context, horiPadding);
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/defaults/DefaultBootstrapSize.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.defaults;
2 |
3 | /**
4 | * Bootstrap provides 5 sizes - XS, SM, MD, LG, and XL. In the Android implementation the scale
5 | * factors used are 0.70, 0.85, 1.00, 1.30, and 1.60 respectively.
6 | */
7 | public enum DefaultBootstrapSize {
8 |
9 | XS(),
10 | SM(),
11 | MD(),
12 | LG(),
13 | XL();
14 |
15 | public static DefaultBootstrapSize fromAttributeValue(int attrValue) {
16 | switch (attrValue) {
17 | case 0:
18 | return XS;
19 | case 1:
20 | return SM;
21 | case 2:
22 | return MD;
23 | case 3:
24 | return LG;
25 | case 4:
26 | return XL;
27 | default:
28 | return MD;
29 | }
30 | }
31 |
32 | public float scaleFactor() {
33 | switch (this) {
34 | case XS:
35 | return 0.70f;
36 | case SM:
37 | return 0.85f;
38 | case MD:
39 | return 1.00f;
40 | case LG:
41 | return 1.30f;
42 | case XL:
43 | return 1.60f;
44 | default:
45 | return 1.00f;
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/defaults/ExpandDirection.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.defaults;
2 |
3 |
4 | public enum ExpandDirection {
5 | UP,
6 | DOWN;
7 |
8 | public static ExpandDirection fromAttributeValue(int attrValue) {
9 | switch (attrValue) {
10 | case 0:
11 | return UP;
12 | case 1:
13 | return DOWN;
14 | default:
15 | return DOWN;
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/BadgeContainerView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | import com.beardedhen.androidbootstrap.BootstrapBadge;
4 |
5 | /**
6 | * Classes which implement this interface can be used as BootstrapBadge container.
7 | * For example, a Button can be set up with BootstrapBadge.
8 | */
9 | public interface BadgeContainerView extends BootstrapBadgeView {
10 |
11 | String KEY = "com.beardedhen.androidbootstrap.api.view.BadgeContainerView";
12 |
13 | /**
14 | * Sets the badge object to be used inside a container.
15 | *
16 | * @param badge BootstrapBadge to setup
17 | */
18 | void setBadge(BootstrapBadge badge);
19 |
20 | /**
21 | * Retrieves BootstrapBadge object from container view.
22 | *
23 | * @return BootstrapBadge if exist or null if not
24 | */
25 | BootstrapBadge getBootstrapBadge();
26 |
27 | /**
28 | * Method where badge display logic must be implemented
29 | *
30 | */
31 | void displayBadgeDrawable();
32 | }
33 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/BootstrapBadgeView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | public interface BootstrapBadgeView {
6 |
7 | /**
8 | * Retrieves the currently displayed badge text
9 | *
10 | * @return the badge text
11 | */
12 | @Nullable
13 | String getBadgeText();
14 |
15 | /**
16 | * Updates the badge to display a text string
17 | *
18 | * @param badgeText the badge text
19 | */
20 | void setBadgeText(@Nullable String badgeText);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/BootstrapBrandView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapBrand;
6 |
7 | /**
8 | * Views which implement this interface change their color according to the given Bootstrap Brand
9 | */
10 | public interface BootstrapBrandView {
11 |
12 | String KEY = "com.beardedhen.androidbootstrap.api.view.BootstrapBrandView";
13 |
14 | /**
15 | * Changes the color of the view to match the given Bootstrap Brand
16 | *
17 | * @param bootstrapBrand the Bootstrap Brand
18 | */
19 | void setBootstrapBrand(@NonNull BootstrapBrand bootstrapBrand);
20 |
21 | /**
22 | * @return the current Bootstrap Brand
23 | */
24 | @NonNull BootstrapBrand getBootstrapBrand();
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/BootstrapHeadingView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapHeading;
6 |
7 | /**
8 | * Views which implement this interface change their text size and padding according to the
9 | * given Bootstrap Heading
10 | */
11 | public interface BootstrapHeadingView {
12 |
13 | String KEY = "com.beardedhen.androidbootstrap.api.attributes.BootstrapHeading";
14 |
15 | /**
16 | * Sets this view to use the given Bootstrap Heading, changing its text size and padding
17 | *
18 | * @param bootstrapHeading the Bootstrap Heading
19 | */
20 | void setBootstrapHeading(@NonNull BootstrapHeading bootstrapHeading);
21 |
22 | /**
23 | * @return the Bootstrap Heading for the view
24 | */
25 | @NonNull BootstrapHeading getBootstrapHeading();
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/BootstrapSizeView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
4 |
5 | /**
6 | * Classes which implement this interface allow aspects of their view to be scaled by a float factor.
7 | * For example, a Button may double its padding from the baseline if a factor of 2.0 is provided.
8 | */
9 | public interface BootstrapSizeView {
10 |
11 | String KEY = "com.beardedhen.androidbootstrap.api.view.BootstrapSizeView";
12 |
13 | /**
14 | * Retrieves the scale factor that should be used to scale a view from its baseline size.
15 | * For example, specifying that a Button should use a scale factor of 2.0 may increase its
16 | * padding and font size by that factor.
17 | *
18 | * @return the scale factor
19 | */
20 | float getBootstrapSize();
21 |
22 | /**
23 | * Sets the scale factor that should be used to scale a view from its baseline size.
24 | * For example, specifying that a Button should use a scale factor of 2.0 may increase its
25 | * padding and font size by that factor.
26 | *
27 | * @param bootstrapSize the scale factor
28 | */
29 | void setBootstrapSize(float bootstrapSize);
30 |
31 | /**
32 | * Convenience method that sets the scale factor using a default bootstrap size enum value.
33 | *
34 | * @param bootstrapSize a default scale factor
35 | */
36 | void setBootstrapSize(DefaultBootstrapSize bootstrapSize);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/BootstrapTextView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.beardedhen.androidbootstrap.BootstrapText;
6 |
7 | /**
8 | * Views which implement this interface can set their text using BootstrapText
9 | */
10 | public interface BootstrapTextView {
11 |
12 | String KEY = "com.beardedhen.androidbootstrap.BootstrapText";
13 |
14 | /**
15 | * Sets the view to display the given BootstrapText
16 | *
17 | * @param bootstrapText the BootstrapText
18 | */
19 | void setBootstrapText(@Nullable BootstrapText bootstrapText);
20 |
21 | /**
22 | * @return the current BootstrapText, or null if none exists
23 | */
24 | @Nullable BootstrapText getBootstrapText();
25 |
26 | /**
27 | * Sets the view to display the given markdown text, by constructing a BootstrapText. e.g.
28 | * "This is a {fa-stop} button"
29 | *
30 | * @param text the markdown text
31 | */
32 | void setMarkdownText(@Nullable String text);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/BorderView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | /**
4 | * Views which implement this interface allow the border to be dynamically displayed
5 | */
6 | public interface BorderView {
7 |
8 | String KEY_DISPLAYED = "com.beardedhen.androidbootstrap.api.view.KEY_DISPLAYED";
9 |
10 | /**
11 | * Sets whether a border should be displayed or not
12 | *
13 | * @param displayed whether a border should be displayed or not
14 | */
15 | void setBorderDisplayed(boolean displayed);
16 |
17 | /**
18 | * @return whether the border is displayed or not
19 | */
20 | boolean isBorderDisplayed();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/ButtonModeView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import com.beardedhen.androidbootstrap.api.defaults.ButtonMode;
6 |
7 | /**
8 | * Views which implement this interface allow the selection mode of their buttons to be set
9 | */
10 | public interface ButtonModeView {
11 |
12 | /**
13 | * @return the selection mode currently used by the button
14 | */
15 | @NonNull ButtonMode getButtonMode();
16 |
17 | /**
18 | * Sets the selection mode the button should use
19 | *
20 | * @param buttonMode the selection mode
21 | */
22 | void setButtonMode(@NonNull ButtonMode buttonMode);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/OutlineableView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | /**
4 | * Views which implement this interface allow the user to specify whether the view should be
5 | * displayed as an outline or not.
6 | */
7 | public interface OutlineableView {
8 |
9 | String KEY = "Outlineable";
10 |
11 | /**
12 | * Sets whether the view should display itself as an outline or not.
13 | *
14 | * @param showOutline true to display as an outline, otherwise false
15 | */
16 | void setShowOutline(boolean showOutline);
17 |
18 | /**
19 | * @return true if the view is currently displaying itself as an outline
20 | */
21 | boolean isShowOutline();
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/ProgressView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | /**
4 | * Views which implement this interface visually display ongoing progress to users
5 | */
6 | public interface ProgressView {
7 |
8 | String KEY_USER_PROGRESS = "com.beardedhen.androidbootstrap.api.view.KEY_USER_PROGRESS";
9 | String KEY_DRAWN_PROGRESS = "com.beardedhen.androidbootstrap.api.view.KEY_DRAWN_PROGRESS";
10 | String KEY_STRIPED = "com.beardedhen.androidbootstrap.api.view.KEY_STRIPED";
11 | String KEY_ANIMATED = "com.beardedhen.androidbootstrap.api.view.KEY_ANIMATED";
12 |
13 | /**
14 | * Updates the amount of progress displayed to the user.
15 | *
16 | * @param progress a positive integer
17 | */
18 | void setProgress(int progress);
19 |
20 | /**
21 | * @return the amount of progress displayed to the user
22 | */
23 | int getProgress();
24 |
25 | /**
26 | * Sets whether the view should display a striped pattern.
27 | *
28 | * @param striped true for a striped pattern, false for a plain pattern
29 | */
30 | void setStriped(boolean striped);
31 |
32 | /**
33 | * @return true if the view is displaying a striped pattern, otherwise false
34 | */
35 | boolean isStriped();
36 |
37 | /**
38 | * Sets whether the view should animate itself. If the view is striped, the animation will run
39 | * in an infinite loop; if the view is not striped, the animation will only be visible when
40 | * setProgress() is called.
41 | *
42 | * @param animated whether the view should animate its updates or not.
43 | */
44 | void setAnimated(boolean animated);
45 |
46 | /**
47 | * @return true if the view should animate itself
48 | */
49 | boolean isAnimated();
50 |
51 | /**
52 | * @return int maxProgress. Returns the maxProgress value
53 | */
54 | int getMaxProgress();
55 |
56 |
57 | /**
58 | * Used for settings the maxprogress. Also check if Cumulative progress is smaller than the
59 | * max before asigning.
60 | * @param maxProgress the maxProgress value
61 | */
62 | void setMaxProgress(int maxProgress);
63 | }
64 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/api/view/RoundableView.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.api.view;
2 |
3 | /**
4 | * Views which implement this interface allow the user to specify whether the view should have
5 | * rounded corners or not. The interpretation of what a 'rounded corner' is will differ between views.
6 | */
7 | public interface RoundableView {
8 |
9 | String KEY = "com.beardedhen.androidbootstrap.api.view.Roundable";
10 |
11 | /**
12 | * Sets whether the view should display rounded corners or not
13 | *
14 | * @param rounded whether the view should be rounded
15 | */
16 | void setRounded(boolean rounded);
17 |
18 | /**
19 | * @return true if the view is displaying rounded corners, otherwise false
20 | */
21 | boolean isRounded();
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/font/AwesomeTypefaceSpan.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.font;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.text.TextPaint;
6 | import android.text.style.TypefaceSpan;
7 |
8 | import com.beardedhen.androidbootstrap.TypefaceProvider;
9 |
10 | /**
11 | * A custom span which paints text using the typeface specified by the IconSet passed to the constructor
12 | */
13 | public class AwesomeTypefaceSpan extends TypefaceSpan {
14 |
15 | private final Context context;
16 | private final IconSet iconSet;
17 |
18 | public AwesomeTypefaceSpan(Context context, IconSet iconSet) {
19 | super(iconSet.fontPath().toString());
20 | this.context = context.getApplicationContext();
21 | this.iconSet = iconSet;
22 | }
23 |
24 | @Override public void updateDrawState(@NonNull TextPaint ds) {
25 | ds.setTypeface(TypefaceProvider.getTypeface(context, iconSet));
26 | }
27 |
28 | @Override public void updateMeasureState(@NonNull TextPaint paint) {
29 | paint.setTypeface(TypefaceProvider.getTypeface(context, iconSet));
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/font/IconSet.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.font;
2 |
3 | /**
4 | * Specifies the icon codes for a Typeface, and provides the filename of the font so that it can be
5 | * initialised
6 | */
7 | public interface IconSet {
8 |
9 | /**
10 | * Returns the unicode character for the current Font Icon.
11 | *
12 | * @return the unicode character
13 | */
14 | CharSequence unicodeForKey(CharSequence key);
15 |
16 |
17 | /**
18 | * Returns the icon code for the current Font Icon.
19 | *
20 | * @return the icon code
21 | */
22 | CharSequence iconCodeForAttrIndex(int index);
23 |
24 | /**
25 | * Specifies the location that the font file resides in, starting from the assets directory
26 | * e.g."fontawesome-webfont.ttf"
27 | *
28 | * @return the font path
29 | */
30 | CharSequence fontPath();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/utils/ColorUtils.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.utils;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.os.Build;
6 | import android.support.annotation.ColorInt;
7 | import android.support.annotation.ColorRes;
8 |
9 | /**
10 | * Utils class for manipulating Bootstrap colors, and resolving colors from resource values.
11 | */
12 | public class ColorUtils {
13 |
14 | public static final int DISABLED_ALPHA_FILL = 165;
15 | public static final int DISABLED_ALPHA_EDGE = 190;
16 | public static final float ACTIVE_OPACITY_FACTOR_FILL = 0.125f;
17 | public static final float ACTIVE_OPACITY_FACTOR_EDGE = 0.025f;
18 |
19 | /**
20 | * Resolves a color resource.
21 | *
22 | * @param color the color resource
23 | * @param context the current context
24 | * @return a color int
25 | */
26 | @SuppressWarnings("deprecation")
27 | public static @ColorInt int resolveColor(@ColorRes int color, Context context) {
28 | if (Build.VERSION.SDK_INT >= 23) {
29 | return context.getResources().getColor(color, context.getTheme());
30 | }
31 | else {
32 | return context.getResources().getColor(color);
33 | }
34 | }
35 |
36 | /**
37 | * Darkens a color by reducing its RGB channel values.
38 | *
39 | * @param context the current context
40 | * @param res the color resource
41 | * @param percent the percent to decrease
42 | * @return a color int
43 | */
44 | @ColorInt public static int decreaseRgbChannels(Context context,
45 | @ColorRes int res, float percent) {
46 | int c = resolveColor(res, context);
47 |
48 | // reduce rgb channel values to produce box shadow effect
49 | int red = (Color.red(c));
50 | red -= (red * percent);
51 | red = red > 0 ? red : 0;
52 |
53 | int green = (Color.green(c));
54 | green -= (green * percent);
55 | green = green > 0 ? green : 0;
56 |
57 | int blue = (Color.blue(c));
58 | blue -= (blue * percent);
59 | blue = blue > 0 ? blue : 0;
60 |
61 | return Color.argb(Color.alpha(c), red, green, blue);
62 | }
63 |
64 | /**
65 | * Lightens a color by increasing its alpha channel value
66 | *
67 | * @param context the current context
68 | * @param res the color resource
69 | * @param alpha the alpha to set
70 | * @return a color int
71 | */
72 | @ColorInt public static int increaseOpacity(Context context, @ColorRes int res, int alpha) {
73 | int c = resolveColor(res, context);
74 | return increaseOpacityFromInt(context, resolveColor(res, context), alpha);
75 | }
76 |
77 | @ColorInt public static int increaseOpacityFromInt(Context context, @ColorInt int c, int
78 | alpha) {
79 | return Color.argb(alpha, Color.red(c), Color.green(c), Color.blue(c));
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/utils/DimenUtils.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.support.annotation.DimenRes;
6 |
7 | /**
8 | * Utils class for resolving color resource values.
9 | */
10 | public class DimenUtils {
11 |
12 | /**
13 | * Resolves a dimension resource that uses scaled pixels
14 | *
15 | * @param context the current context
16 | * @param sizeRes the dimension resource holding an SP value
17 | * @return the text size in pixels
18 | */
19 | public static float pixelsFromSpResource(Context context, @DimenRes int sizeRes) {
20 | final Resources res = context.getResources();
21 | return res.getDimension(sizeRes) / res.getDisplayMetrics().density;
22 | }
23 |
24 | /**
25 | * Resolves a dimension resource that uses density-independent pixels
26 | *
27 | * @param context the current context
28 | * @param res the dimension resource holding a DP value
29 | * @return the size in pixels
30 | */
31 | public static float pixelsFromDpResource(Context context, @DimenRes int res) {
32 | return context.getResources().getDimension(res);
33 | }
34 |
35 | /**
36 | * Converts density-independent pixels to pixels
37 | * @param dip the dips
38 | * @return size in pixels
39 | */
40 | public static int dpToPixels(float dip) {
41 | return (int) (dip * Resources.getSystem().getDisplayMetrics().density);
42 | }
43 |
44 | /**
45 | * Converts pixels to density-independent pixels
46 | * @param pixels the pixels
47 | * @return size in dp
48 | */
49 | public static int pixelsToDp(float pixels) {
50 | return (int) (pixels / Resources.getSystem().getDisplayMetrics().density);
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/utils/DrawableUtils.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.graphics.drawable.Drawable;
6 | import android.os.Build;
7 | import android.support.annotation.DrawableRes;
8 |
9 | public class DrawableUtils {
10 |
11 | @SuppressWarnings("deprecation")
12 | public static Drawable resolveDrawable(@DrawableRes int resId, Context context) {
13 | Resources resources = context.getResources();
14 | Resources.Theme theme = context.getTheme();
15 |
16 | if (Build.VERSION.SDK_INT >= 22) {
17 | return resources.getDrawable(resId, theme);
18 | }
19 | else {
20 | return resources.getDrawable(resId);
21 | }
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/utils/ViewUtils.java:
--------------------------------------------------------------------------------
1 | package com.beardedhen.androidbootstrap.utils;
2 |
3 | import android.graphics.drawable.Drawable;
4 | import android.os.Build;
5 | import android.view.View;
6 |
7 | public class ViewUtils {
8 |
9 | /**
10 | * Calls {@link View#setBackground(Drawable)} or {@link View#setBackgroundDrawable(Drawable)},
11 | * depending on API level
12 | *
13 | * @param view the view
14 | * @param drawable the drawable
15 | */
16 | @SuppressWarnings("deprecation")
17 | public static void setBackgroundDrawable(View view, Drawable drawable) {
18 | if (Build.VERSION.SDK_INT >= 16) {
19 | view.setBackground(drawable);
20 | }
21 | else {
22 | view.setBackgroundDrawable(drawable);
23 | }
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | #373a3c
8 | #55595c
9 | #818a91
10 | #eceeef
11 | #f7f7f9
12 |
13 |
14 | #0275d8
15 | #5cb85c
16 | #5bc0de
17 | #f0ad4e
18 | #d9534f
19 |
20 |
21 |
22 |
23 | #ffffff
24 | #cccccc
25 | #373a3c
26 |
27 |
28 | #ffe0e0e0
29 | #ffffffff
30 | #F5F5F5
31 | #e7e7e7
32 | #E7E7E7
33 | #64818a91
34 |
35 |
36 |
--------------------------------------------------------------------------------
/AndroidBootstrap/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14sp
5 | 5.75dp
6 | 14dp
7 | 4dp
8 | 1dp
9 |
10 |
11 | 14sp
12 | 8dp
13 | 5.75dp
14 | 6dp
15 | 1.5dp
16 |
17 |
18 | 8dp
19 | 1dp
20 | 14sp
21 |
22 |
23 | 8dp
24 | 8dp
25 | 2dp
26 |
27 |
28 | 8dp
29 | 1dp
30 | 6dp
31 |
32 | 14sp
33 | 14sp
34 | 8dp
35 | 8dp
36 | 3dp
37 | 1dp
38 | 4dp
39 | 8dp
40 | 48dp
41 |
42 |
43 | 31.5sp
44 | 7.875dp
45 | 12.6dp
46 |
47 | 28sp
48 | 7dp
49 | 11.2dp
50 |
51 | 24.5sp
52 | 6.125dp
53 | 9.8dp
54 |
55 | 21sp
56 | 5.25dp
57 | 8.4dp
58 |
59 | 17.5sp
60 | 4.375dp
61 | 7dp
62 |
63 | 14dp
64 | 3.5dp
65 | 5.6dp
66 |
67 |
68 | 3dp
69 | 20dp
70 | 16dp
71 | 17sp
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2016 Bearded Hen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | Feature (Wish)List
2 | =============
3 | * More Views in Bootstrap Spec
4 | * Add Bootstrap input groups
5 | * Add BootstrapCardView and BootstrapCardGroupView to replace BootstrapThumbnail
6 | * Generate gh-pages
7 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | jcenter()
5 |
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.2'
9 | }
10 | }
11 |
12 | allprojects {
13 | version = VERSION_NAME
14 | group = GROUP
15 | repositories {
16 | jcenter()
17 | maven {
18 | url "https://jitpack.io" // for snapshot debugging
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | dependencies:
2 | pre:
3 | # Android SDK Platform 25
4 | - if [ ! -d "/usr/local/android-sdk-linux/platforms/android-25" ]; then echo y | android update sdk --no-ui --all --filter "android-25"; fi
5 | # Android SDK Build-tools, revision 25.0.1
6 | - if [ ! -d "/usr/local/android-sdk-linux/build-tools/25.0.1" ]; then echo y | android update sdk --no-ui --all --filter "build-tools-25.0.1"; fi
7 | # Android Support Library, revision 25.0.1
8 | - if [ ! -d "/usr/local/android-sdk-linux/extras/android/m2repository/com/android/support/support-v4/25.0.1" ]; then echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"; fi
9 | # Android Support Annotations Library, revision 25.0.1
10 | - if [ ! -d "/usr/local/android-sdk-linux/extras/android/m2repository/com/android/support/support-annotations/25.0.1" ]; then echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"; fi
11 |
12 | cache_directories:
13 | - /usr/local/android-sdk-linux/platforms/android-25
14 | - /usr/local/android-sdk-linux/build-tools/25.0.1
15 | - /usr/local/android-sdk-linux/extras/android/m2repository/com/android/support/support-v4/25.0.1
16 | - /usr/local/android-sdk-linux/extras/android/m2repository/com/android/support/support-annotations/25.0.1
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | VERSION_NAME=2.3.2
2 | VERSION_CODE=232
3 | GROUP=com.beardedhen
4 |
5 | MIN_SDK_INT=14
6 | TARGET_SDK_INT=25
7 |
8 | POM_DESCRIPTION=Bootstrap style widgets for Android, with Glyph Icons
9 | POM_URL=https://github.com/Bearded-Hen/Android-Bootstrap
10 | POM_SCM_URL=https://github.com/Bearded-Hen/Android-Bootstrap
11 | POM_SCM_CONNECTION=scm:git@github.com:Bearded-Hen/Android-Bootstrap.git
12 | POM_SCM_DEV_CONNECTION=scm:git@github.com:Bearded-Hen/Android-Bootstrap.git
13 | POM_LICENCE_NAME=The MIT License (MIT)
14 | POM_LICENCE_URL=https://github.com/Bearded-Hen/Android-Bootstrap/blob/master/LICENSE
15 | POM_LICENCE_DIST=repo
16 | POM_DEVELOPER_ID=beardedhen
17 | POM_DEVELOPER_NAME=Bearded-Hen
18 |
19 | POM_NAME=Android-Bootstrap Library
20 | POM_ARTIFACT_ID=androidbootstrap
21 | POM_PACKAGING=aar
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jul 22 10:14:14 BST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/images/awesome_text_view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/awesome_text_view.png
--------------------------------------------------------------------------------
/images/bootstrap_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_button.png
--------------------------------------------------------------------------------
/images/bootstrap_button_group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_button_group.png
--------------------------------------------------------------------------------
/images/bootstrap_circle_thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_circle_thumbnail.png
--------------------------------------------------------------------------------
/images/bootstrap_dropdown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_dropdown.png
--------------------------------------------------------------------------------
/images/bootstrap_edit_text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_edit_text.png
--------------------------------------------------------------------------------
/images/bootstrap_label.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_label.png
--------------------------------------------------------------------------------
/images/bootstrap_progress_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_progress_bar.png
--------------------------------------------------------------------------------
/images/bootstrap_progress_bar_group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_progress_bar_group.png
--------------------------------------------------------------------------------
/images/bootstrap_thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_thumbnail.png
--------------------------------------------------------------------------------
/images/bootstrap_well.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/images/bootstrap_well.png
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion Integer.parseInt(TARGET_SDK_INT)
5 | buildToolsVersion "25.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.fractalwrench.androidbootstrap.sample"
9 | minSdkVersion Integer.parseInt(MIN_SDK_INT)
10 | targetSdkVersion Integer.parseInt(TARGET_SDK_INT)
11 | versionCode = Integer.parseInt(VERSION_CODE)
12 | versionName = VERSION_NAME
13 | }
14 | lintOptions {
15 | disable 'InvalidPackage'
16 | }
17 | packagingOptions {
18 | exclude 'META-INF/services/javax.annotation.processing.Processor'
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled true
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | compile project (':AndroidBootstrap') // replace with Maven dependency in your app
30 |
31 | compile 'com.jakewharton:butterknife:8.4.0'
32 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
33 |
34 | compile 'com.android.support:appcompat-v7:25.3.1'
35 | compile 'com.android.support:support-annotations:25.3.1'
36 | }
37 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Butterknife
2 |
3 | -keep class butterknife.** { *; }
4 | -dontwarn butterknife.internal.**
5 | -keep class **$$ViewBinder { *; }
6 |
7 | -keepclasseswithmembernames class * {
8 | @butterknife.* ;
9 | }
10 |
11 | -keepclasseswithmembernames class * {
12 | @butterknife.* ;
13 | }
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
18 |
19 |
20 |
21 |
22 |
23 |
27 |
31 |
35 |
39 |
43 |
47 |
51 |
55 |
59 |
63 |
67 |
71 |
72 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/AwesomeTextViewExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.beardedhen.androidbootstrap.AwesomeTextView;
6 | import com.beardedhen.androidbootstrap.BootstrapText;
7 | import com.beardedhen.androidbootstrap.font.MaterialIcons;
8 |
9 | import butterknife.BindView;
10 | import butterknife.OnClick;
11 |
12 | import static com.beardedhen.androidbootstrap.font.FontAwesome.FA_ANCHOR;
13 | import static com.beardedhen.androidbootstrap.font.FontAwesome.FA_ANDROID;
14 | import static com.beardedhen.androidbootstrap.font.FontAwesome.FA_APPLE;
15 | import static com.beardedhen.androidbootstrap.font.FontAwesome.FA_HEART;
16 | import static com.beardedhen.androidbootstrap.font.FontAwesome.FA_TWITTER;
17 | import static com.beardedhen.androidbootstrap.font.Typicon.TY_CODE;
18 |
19 | public class AwesomeTextViewExample extends BaseActivity {
20 |
21 | @Override protected int getContentLayoutId() {
22 | return R.layout.example_awesome_text_view;
23 | }
24 |
25 | @BindView(R.id.example_fa_text_change) AwesomeTextView exampleChange;
26 | @BindView(R.id.example_fa_text_flash) AwesomeTextView exampleFlash;
27 | @BindView(R.id.example_fa_text_rotate) AwesomeTextView exampleRotate;
28 | @BindView(R.id.example_fa_text_multi_change) AwesomeTextView exampleMultiChange;
29 | @BindView(R.id.example_fa_text_builder) AwesomeTextView exampleBuilder;
30 | @BindView(R.id.example_mix_and_match) AwesomeTextView mixAndMatch;
31 |
32 | private boolean android = true;
33 | private boolean wikipedia = true;
34 |
35 | @Override protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setupFontAwesomeText();
38 | }
39 |
40 | private void setupFontAwesomeText() {
41 | exampleFlash.startFlashing(true, AwesomeTextView.AnimationSpeed.FAST);
42 | exampleRotate.startRotate(true, AwesomeTextView.AnimationSpeed.SLOW);
43 |
44 | BootstrapText text = new BootstrapText.Builder(this)
45 | .addText("I ")
46 | .addFontAwesomeIcon(FA_HEART)
47 | .addText(" going on ")
48 | .addFontAwesomeIcon(FA_TWITTER)
49 | .build();
50 |
51 | exampleBuilder.setBootstrapText(text);
52 |
53 | mixAndMatch.setBootstrapText(new BootstrapText.Builder(this)
54 | .addFontAwesomeIcon(FA_ANCHOR)
55 | .addTypicon(TY_CODE)
56 | .addMaterialIcon(MaterialIcons.MD_PHOTO)
57 | .build());
58 | }
59 |
60 | @OnClick(R.id.example_fa_text_change) void onChangeClicked() {
61 | android = !android;
62 | exampleChange.setFontAwesomeIcon(android ? FA_ANDROID : FA_APPLE);
63 | }
64 |
65 | @OnClick(R.id.example_fa_text_multi_change) void onMultiChangeClicked() {
66 | wikipedia = !wikipedia;
67 | String text = wikipedia ? "{fa_image} is in the {fa_cloud}" : "{fa_bank} are on {fa_globe}";
68 | exampleMultiChange.setMarkdownText(text);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.LayoutRes;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.LayoutInflater;
7 | import android.widget.ScrollView;
8 |
9 | import butterknife.ButterKnife;
10 |
11 | /**
12 | * Performs ButterKnife binding after adding example views to the root ScrollView
13 | */
14 | abstract class BaseActivity extends AppCompatActivity {
15 |
16 | @LayoutRes protected abstract int getContentLayoutId();
17 |
18 | @Override protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_base);
21 |
22 | ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView);
23 |
24 | if (scrollView != null) {
25 | scrollView.addView(LayoutInflater.from(this).inflate(getContentLayoutId(), scrollView, false));
26 | }
27 |
28 | ButterKnife.bind(this);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapAlertExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 | import android.view.View;
6 |
7 | import com.beardedhen.androidbootstrap.BootstrapAlert;
8 |
9 | import butterknife.BindView;
10 | import butterknife.OnClick;
11 |
12 | public class BootstrapAlertExample extends BaseActivity {
13 |
14 | public static final String TAG = "BootstrapAlertExample";
15 |
16 | @BindView(R.id.dynamic_alert) BootstrapAlert alert;
17 |
18 | @Override
19 | protected int getContentLayoutId() {
20 | return R.layout.example_bootstrap_alert;
21 | }
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 |
27 | alert.setVisibilityChangeListener(new BootstrapAlert.VisibilityChangeListener() {
28 | @Override
29 | public void onAlertDismissStarted(BootstrapAlert alert) {
30 | Log.d(TAG, "Started dismissing alert!");
31 | }
32 |
33 | @Override
34 | public void onAlertDismissCompletion(BootstrapAlert alert) {
35 | Log.d(TAG, "Finished dismissing alert!");
36 | }
37 |
38 | @Override
39 | public void onAlertAppearStarted(BootstrapAlert alert) {
40 | Log.d(TAG, "Started appearing alert!");
41 | }
42 |
43 | @Override
44 | public void onAlertAppearCompletion(BootstrapAlert alert) {
45 | Log.d(TAG, "Finished appearing alert!");
46 | }
47 | });
48 | }
49 |
50 | @OnClick(R.id.interactive_button)
51 | void onInteractiveButtonClicked() {
52 | if (View.GONE == alert.getVisibility()) {
53 | alert.show(true);
54 | }
55 | else {
56 | alert.dismiss(true);
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapBadgeExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.beardedhen.androidbootstrap.BootstrapBadge;
6 | import com.beardedhen.androidbootstrap.BootstrapButton;
7 |
8 | import java.util.Random;
9 |
10 | import butterknife.BindView;
11 | import butterknife.OnClick;
12 |
13 | public class BootstrapBadgeExample extends BaseActivity {
14 |
15 | @BindView(R.id.xml_badge_button) BootstrapButton xmlBadgeButton;
16 | @BindView(R.id.java_badge_button) BootstrapButton javaBadgeButton;
17 | @BindView(R.id.lonely_badge) BootstrapBadge lonelyBadge;
18 |
19 | @Override
20 | protected int getContentLayoutId() {
21 | return R.layout.example_bootstrap_badge;
22 | }
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | BootstrapBadge badgeThird = new BootstrapBadge(this);
28 | badgeThird.setBadgeText("Hi!");
29 | javaBadgeButton.setBadge(badgeThird);
30 | }
31 |
32 | @OnClick(R.id.lonely_badge)
33 | void onLonelyButtonClicked() {
34 | lonelyBadge.setBadgeText(String.valueOf(new Random().nextInt()));
35 | }
36 |
37 | @OnClick(R.id.xml_badge_button)
38 | void onXmlButtonClicked() {
39 | xmlBadgeButton.setBadgeText(String.valueOf(new Random().nextInt()));
40 | }
41 |
42 | @OnClick(R.id.java_badge_button)
43 | void onJavaButtonClicked() {
44 | javaBadgeButton.setBadgeText(String.valueOf(new Random().nextInt()));
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapButtonExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import com.beardedhen.androidbootstrap.BootstrapButton;
7 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
8 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
9 |
10 | import butterknife.BindView;
11 | import butterknife.OnClick;
12 |
13 | public class BootstrapButtonExample extends BaseActivity {
14 |
15 | @Override protected int getContentLayoutId() {
16 | return R.layout.example_bootstrap_button;
17 | }
18 |
19 | private DefaultBootstrapSize size = DefaultBootstrapSize.LG;
20 |
21 | @BindView(R.id.bbutton_example_corners) BootstrapButton exampleCorners;
22 | @BindView(R.id.bbutton_example_outline) BootstrapButton exampleOutline;
23 | @BindView(R.id.bbutton_example_size) BootstrapButton exampleSize;
24 | @BindView(R.id.bbutton_example_theme) BootstrapButton exampleTheme;
25 | @BindView(R.id.example_bbutton_custom_style) BootstrapButton exampleCustomStyle;
26 |
27 | @Override protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setupCustomStyle();
30 | }
31 |
32 | @OnClick(R.id.bbutton_example_corners) void onCornersExampleClicked() {
33 | exampleCorners.setRounded(!exampleCorners.isRounded());
34 | }
35 |
36 | @OnClick(R.id.bbutton_example_outline) void onOutlineExampleClicked() {
37 | exampleOutline.setShowOutline(!exampleOutline.isShowOutline());
38 | }
39 |
40 | @OnClick(R.id.bbutton_example_size) void onSizeExampleClicked() {
41 | switch (size) {
42 | case XS:
43 | size = DefaultBootstrapSize.SM;
44 | break;
45 | case SM:
46 | size = DefaultBootstrapSize.MD;
47 | break;
48 | case MD:
49 | size = DefaultBootstrapSize.LG;
50 | break;
51 | case LG:
52 | size = DefaultBootstrapSize.XL;
53 | break;
54 | case XL:
55 | size = DefaultBootstrapSize.XS;
56 | break;
57 | }
58 | exampleSize.setBootstrapSize(size);
59 | }
60 |
61 | @OnClick(R.id.bbutton_example_theme) void onThemeExampleClicked() {
62 | switch ((DefaultBootstrapBrand) exampleTheme.getBootstrapBrand()) {
63 | case PRIMARY:
64 | exampleTheme.setBootstrapBrand(DefaultBootstrapBrand.SUCCESS);
65 | break;
66 | case SUCCESS:
67 | exampleTheme.setBootstrapBrand(DefaultBootstrapBrand.WARNING);
68 | break;
69 | case WARNING:
70 | exampleTheme.setBootstrapBrand(DefaultBootstrapBrand.DANGER);
71 | break;
72 | case DANGER:
73 | exampleTheme.setBootstrapBrand(DefaultBootstrapBrand.INFO);
74 | break;
75 | case INFO:
76 | exampleTheme.setBootstrapBrand(DefaultBootstrapBrand.SECONDARY);
77 | break;
78 | case SECONDARY:
79 | exampleTheme.setBootstrapBrand(DefaultBootstrapBrand.REGULAR);
80 | break;
81 | case REGULAR:
82 | exampleTheme.setBootstrapBrand(DefaultBootstrapBrand.PRIMARY);
83 | break;
84 | }
85 | }
86 |
87 | private void setupCustomStyle() {
88 | // create a custom bootstrap size
89 | exampleCustomStyle.setBootstrapSize(3.0f);
90 |
91 | // create a Bootstrap Theme with holo colors
92 | exampleCustomStyle.setBootstrapBrand(new CustomBootstrapStyle(this));
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapButtonGroupExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.os.Bundle;
4 | import android.widget.LinearLayout;
5 | import android.widget.TextView;
6 |
7 | import com.beardedhen.androidbootstrap.BootstrapButton;
8 | import com.beardedhen.androidbootstrap.BootstrapButtonGroup;
9 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
10 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
11 |
12 | import butterknife.BindView;
13 | import butterknife.OnClick;
14 |
15 | public class BootstrapButtonGroupExample extends BaseActivity {
16 |
17 | @Override protected int getContentLayoutId() {
18 | return R.layout.example_bootstrap_button_group;
19 | }
20 |
21 | private DefaultBootstrapSize size = DefaultBootstrapSize.MD;
22 |
23 | @BindView(R.id.bbutton_group_orientation_change) BootstrapButtonGroup orientationChange;
24 | @BindView(R.id.bbutton_group_size_change) BootstrapButtonGroup sizeChange;
25 | @BindView(R.id.bbutton_group_outline_change) BootstrapButtonGroup outlineChange;
26 | @BindView(R.id.bbutton_group_rounded_change) BootstrapButtonGroup roundedChange;
27 | @BindView(R.id.bbutton_group_brand_change) BootstrapButtonGroup brandChange;
28 | @BindView(R.id.bbutton_group_child_change) BootstrapButtonGroup childChange;
29 |
30 | @BindView(R.id.bbutton_group_checked_text) TextView checkedText;
31 |
32 | @BindView(R.id.bbutton_group_checked1) BootstrapButton radioButton1;
33 | @BindView(R.id.bbutton_group_checked2) BootstrapButton radioButton2;
34 | @BindView(R.id.bbutton_group_checked3) BootstrapButton radioButton3;
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | radioButton1.setOnCheckedChangedListener(new BootstrapButton.OnCheckedChangedListener() {
40 | @Override
41 | public void OnCheckedChanged(BootstrapButton bootstrapButton, boolean isChecked) {
42 | if (isChecked) {
43 | checkedText.setText("radio, button 1 checked");
44 | }
45 | }
46 | });
47 |
48 | radioButton2.setOnCheckedChangedListener(new BootstrapButton.OnCheckedChangedListener() {
49 | @Override
50 | public void OnCheckedChanged(BootstrapButton bootstrapButton, boolean isChecked) {
51 | if (isChecked) {
52 | checkedText.setText("radio, button 2 checked");
53 | }
54 | }
55 | });
56 |
57 | radioButton3.setOnCheckedChangedListener(new BootstrapButton.OnCheckedChangedListener() {
58 | @Override
59 | public void OnCheckedChanged(BootstrapButton bootstrapButton, boolean isChecked) {
60 | if (isChecked) {
61 | checkedText.setText("radio, button 3 checked");
62 | }
63 | }
64 | });
65 | }
66 |
67 | @OnClick(R.id.bbutton_group_orientation_change_btn) void onOrientationChangeExampleClicked() {
68 | boolean isHorizontal = orientationChange.getOrientation() == LinearLayout.HORIZONTAL;
69 | int newOrientation = isHorizontal ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL;
70 | orientationChange.setOrientation(newOrientation);
71 | }
72 |
73 | @OnClick(R.id.bbutton_group_outline_change_btn) void onOutlineChangeExampleClicked() {
74 | outlineChange.setShowOutline(!outlineChange.isShowOutline());
75 | }
76 |
77 | @OnClick(R.id.bbutton_group_rounded_change_btn) void onRoundedChangeExampleClicked() {
78 | roundedChange.setRounded(!roundedChange.isRounded());
79 | }
80 |
81 | @OnClick(R.id.bbutton_group_child_add_btn) void onChildAddExampleClicked() {
82 | int count = childChange.getChildCount();
83 |
84 | BootstrapButton button = new BootstrapButton(this);
85 | button.setText(String.format("%d", count + 1));
86 |
87 | childChange.addView(button);
88 | }
89 |
90 | @OnClick(R.id.bbutton_group_child_remove_btn) void onChildRemoveExampleClicked() {
91 | int count = childChange.getChildCount();
92 |
93 | if (count > 0) {
94 | childChange.removeViewAt(count - 1);
95 | }
96 | }
97 |
98 | @OnClick(R.id.bbutton_group_brand_change_btn) void onBrandChangeExampleClicked() {
99 | switch ((DefaultBootstrapBrand) brandChange.getBootstrapBrand()) {
100 |
101 | case PRIMARY:
102 | brandChange.setBootstrapBrand(DefaultBootstrapBrand.SUCCESS);
103 | break;
104 | case SUCCESS:
105 | brandChange.setBootstrapBrand(DefaultBootstrapBrand.INFO);
106 | break;
107 | case INFO:
108 | brandChange.setBootstrapBrand(DefaultBootstrapBrand.WARNING);
109 | break;
110 | case WARNING:
111 | brandChange.setBootstrapBrand(DefaultBootstrapBrand.DANGER);
112 | break;
113 | case DANGER:
114 | brandChange.setBootstrapBrand(DefaultBootstrapBrand.SECONDARY);
115 | break;
116 | case SECONDARY:
117 | brandChange.setBootstrapBrand(DefaultBootstrapBrand.REGULAR);
118 | break;
119 | case REGULAR:
120 | brandChange.setBootstrapBrand(DefaultBootstrapBrand.PRIMARY);
121 | break;
122 | }
123 | }
124 |
125 | @OnClick(R.id.bbutton_group_size_change_btn) void onSizeChangeExampleClicked() {
126 | switch (size) {
127 | case XS:
128 | size = DefaultBootstrapSize.SM;
129 | break;
130 | case SM:
131 | size = DefaultBootstrapSize.MD;
132 | break;
133 | case MD:
134 | size = DefaultBootstrapSize.LG;
135 | break;
136 | case LG:
137 | size = DefaultBootstrapSize.XL;
138 | break;
139 | case XL:
140 | size = DefaultBootstrapSize.XS;
141 | break;
142 | }
143 | sizeChange.setBootstrapSize(size);
144 | }
145 |
146 | }
147 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapCircleThumbnailExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.os.Bundle;
6 | import android.widget.LinearLayout;
7 |
8 | import com.beardedhen.androidbootstrap.BootstrapCircleThumbnail;
9 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
10 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
11 | import com.beardedhen.androidbootstrap.utils.DrawableUtils;
12 |
13 | import butterknife.BindView;
14 | import butterknife.OnClick;
15 |
16 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.DANGER;
17 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.INFO;
18 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.PRIMARY;
19 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.REGULAR;
20 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.SECONDARY;
21 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.SUCCESS;
22 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.WARNING;
23 |
24 | public class BootstrapCircleThumbnailExample extends BaseActivity {
25 |
26 | private static final float BASELINE_SIZE = 300;
27 |
28 | private int resId = R.drawable.ladybird;
29 | private DefaultBootstrapSize size = DefaultBootstrapSize.MD;
30 |
31 | @Override protected int getContentLayoutId() {
32 | return R.layout.example_bootstrap_circle_thumbnail;
33 | }
34 |
35 | @BindView(R.id.bcircle_image_change_example) BootstrapCircleThumbnail imageChange;
36 | @BindView(R.id.bcircle_theme_change_example) BootstrapCircleThumbnail themeChange;
37 | @BindView(R.id.bcircle_border_change_example) BootstrapCircleThumbnail borderChange;
38 | @BindView(R.id.bcircle_size_change_example) BootstrapCircleThumbnail sizeChange;
39 | @BindView(R.id.bcircle_set_image_bitmap_example) BootstrapCircleThumbnail setBitmapExample;
40 | @BindView(R.id.bcircle_set_image_drawable_example) BootstrapCircleThumbnail setDrawableExample;
41 | @BindView(R.id.bcircle_set_image_resource_example) BootstrapCircleThumbnail setResourceExample;
42 |
43 | @Override protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 |
46 | Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.small_daffodils);
47 | setBitmapExample.setImageBitmap(bm);
48 |
49 | setDrawableExample.setImageDrawable(DrawableUtils.resolveDrawable(R.drawable.ladybird, this));
50 | setResourceExample.setImageResource(R.drawable.caterpillar);
51 |
52 | sizeChange.setLayoutParams(getLayoutParams(size.scaleFactor()));
53 | }
54 |
55 | private LinearLayout.LayoutParams getLayoutParams(float factor) {
56 | float size = BASELINE_SIZE * factor;
57 | return new LinearLayout.LayoutParams((int)size, (int)size);
58 | }
59 |
60 | @OnClick(R.id.bcircle_theme_change_example) void onThemeChangeExampleClicked() {
61 | switch ((DefaultBootstrapBrand) themeChange.getBootstrapBrand()) {
62 | case PRIMARY:
63 | themeChange.setBootstrapBrand(SUCCESS);
64 | break;
65 | case SUCCESS:
66 | themeChange.setBootstrapBrand(INFO);
67 | break;
68 | case INFO:
69 | themeChange.setBootstrapBrand(WARNING);
70 | break;
71 | case WARNING:
72 | themeChange.setBootstrapBrand(DANGER);
73 | break;
74 | case DANGER:
75 | themeChange.setBootstrapBrand(SECONDARY);
76 | break;
77 | case SECONDARY:
78 | themeChange.setBootstrapBrand(REGULAR);
79 | break;
80 | case REGULAR:
81 | themeChange.setBootstrapBrand(PRIMARY);
82 | break;
83 | }
84 | }
85 |
86 | @OnClick(R.id.bcircle_image_change_example) void onImageChangeExampleClicked() {
87 | switch (resId) {
88 | case R.drawable.ladybird:
89 | resId = R.drawable.caterpillar;
90 | break;
91 | case R.drawable.caterpillar:
92 | resId = 0;
93 | break;
94 | case 0:
95 | resId = R.drawable.ladybird;
96 | break;
97 | }
98 | imageChange.setImageResource(resId);
99 | }
100 |
101 | @OnClick(R.id.bcircle_border_change_example) void onBorderChangeExampleClicked() {
102 | borderChange.setBorderDisplayed(!borderChange.isBorderDisplayed());
103 | }
104 |
105 | @OnClick(R.id.bcircle_size_change_example) void onSizeChangeExampleClicked() {
106 | switch (size) {
107 | case XS:
108 | size = DefaultBootstrapSize.SM;
109 | break;
110 | case SM:
111 | size = DefaultBootstrapSize.MD;
112 | break;
113 | case MD:
114 | size = DefaultBootstrapSize.LG;
115 | break;
116 | case LG:
117 | size = DefaultBootstrapSize.XL;
118 | break;
119 | case XL:
120 | size = DefaultBootstrapSize.XS;
121 | break;
122 | }
123 | sizeChange.setBootstrapSize(size);
124 | sizeChange.setLayoutParams(getLayoutParams(size.scaleFactor()));
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapDropDownExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | public class BootstrapDropDownExample extends Activity {
7 |
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | setContentView(R.layout.example_bootstrap_dropdown);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapEditTextExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import com.beardedhen.androidbootstrap.BootstrapEditText;
4 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
5 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
6 |
7 | import butterknife.BindView;
8 | import butterknife.OnClick;
9 |
10 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.DANGER;
11 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.INFO;
12 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.PRIMARY;
13 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.REGULAR;
14 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.SECONDARY;
15 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.SUCCESS;
16 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.WARNING;
17 |
18 | public class BootstrapEditTextExample extends BaseActivity {
19 |
20 | @Override protected int getContentLayoutId() {
21 | return R.layout.example_bootstrap_edit_text_view;
22 | }
23 |
24 | private DefaultBootstrapSize size = DefaultBootstrapSize.MD;
25 |
26 | @BindView(R.id.bedit_text_change_enabled) BootstrapEditText changeEnabled;
27 | @BindView(R.id.bedit_text_change_round) BootstrapEditText changeRound;
28 | @BindView(R.id.bedit_text_change_theme) BootstrapEditText changeTheme;
29 | @BindView(R.id.bedit_text_change_size) BootstrapEditText sizeExample;
30 |
31 | @OnClick(R.id.bedit_text_change_enabled_btn) void onChangeEnabledExampleClicked() {
32 | changeEnabled.setEnabled(!changeEnabled.isEnabled());
33 | }
34 |
35 | @OnClick(R.id.bedit_text_change_round_btn) void onChangeRoundExampleClicked() {
36 | changeRound.setRounded(!changeRound.isRounded());
37 | }
38 |
39 | @OnClick(R.id.bedit_text_change_theme_btn) void onChangeThemeExampleClicked() {
40 | switch((DefaultBootstrapBrand) changeTheme.getBootstrapBrand()) {
41 | case PRIMARY:
42 | changeTheme.setBootstrapBrand(SUCCESS);
43 | break;
44 | case SUCCESS:
45 | changeTheme.setBootstrapBrand(INFO);
46 | break;
47 | case INFO:
48 | changeTheme.setBootstrapBrand(WARNING);
49 | break;
50 | case WARNING:
51 | changeTheme.setBootstrapBrand(DANGER);
52 | break;
53 | case DANGER:
54 | changeTheme.setBootstrapBrand(SECONDARY);
55 | break;
56 | case SECONDARY:
57 | changeTheme.setBootstrapBrand(REGULAR);
58 | break;
59 | case REGULAR:
60 | changeTheme.setBootstrapBrand(PRIMARY);
61 | break;
62 | }
63 | }
64 |
65 | @OnClick(R.id.bedit_text_change_size_btn) void onSizeExampleClicked() {
66 | switch (size) {
67 | case XS:
68 | size = DefaultBootstrapSize.SM;
69 | break;
70 | case SM:
71 | size = DefaultBootstrapSize.MD;
72 | break;
73 | case MD:
74 | size = DefaultBootstrapSize.LG;
75 | break;
76 | case LG:
77 | size = DefaultBootstrapSize.XL;
78 | break;
79 | case XL:
80 | size = DefaultBootstrapSize.XS;
81 | break;
82 | }
83 | sizeExample.setBootstrapSize(size);
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapLabelExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import com.beardedhen.androidbootstrap.BootstrapLabel;
4 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
5 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapHeading;
6 |
7 | import butterknife.BindView;
8 | import butterknife.OnClick;
9 |
10 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapHeading.H1;
11 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapHeading.H2;
12 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapHeading.H3;
13 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapHeading.H4;
14 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapHeading.H5;
15 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapHeading.H6;
16 |
17 | public class BootstrapLabelExample extends BaseActivity {
18 |
19 | @Override protected int getContentLayoutId() {
20 | return R.layout.example_bootstrap_label;
21 | }
22 |
23 | @BindView(R.id.example_blabel_change_color) BootstrapLabel lblChangeColor;
24 | @BindView(R.id.example_blabel_change_heading) BootstrapLabel lblChangeHeading;
25 | @BindView(R.id.example_blabel_change_rounded) BootstrapLabel lblChangeRounded;
26 |
27 | @OnClick(R.id.example_blabel_change_heading) void onHeadingChangeClicked() {
28 | switch ((DefaultBootstrapHeading) lblChangeHeading.getBootstrapHeading()) {
29 | case H1:
30 | lblChangeHeading.setBootstrapHeading(H2);
31 | break;
32 | case H2:
33 | lblChangeHeading.setBootstrapHeading(H3);
34 | break;
35 | case H3:
36 | lblChangeHeading.setBootstrapHeading(H4);
37 | break;
38 | case H4:
39 | lblChangeHeading.setBootstrapHeading(H5);
40 | break;
41 | case H5:
42 | lblChangeHeading.setBootstrapHeading(H6);
43 | break;
44 | case H6:
45 | lblChangeHeading.setBootstrapHeading(H1);
46 | break;
47 | default:
48 | lblChangeHeading.setBootstrapHeading(H1);
49 | break;
50 | }
51 | }
52 |
53 | @OnClick(R.id.example_blabel_change_color) void onColorChangeClicked() {
54 | switch ((DefaultBootstrapBrand) lblChangeColor.getBootstrapBrand()) {
55 | case PRIMARY:
56 | lblChangeColor.setBootstrapBrand(DefaultBootstrapBrand.SUCCESS);
57 | break;
58 | case SUCCESS:
59 | lblChangeColor.setBootstrapBrand(DefaultBootstrapBrand.INFO);
60 | break;
61 | case INFO:
62 | lblChangeColor.setBootstrapBrand(DefaultBootstrapBrand.WARNING);
63 | break;
64 | case WARNING:
65 | lblChangeColor.setBootstrapBrand(DefaultBootstrapBrand.DANGER);
66 | break;
67 | case DANGER:
68 | lblChangeColor.setBootstrapBrand(DefaultBootstrapBrand.SECONDARY);
69 | break;
70 | case SECONDARY:
71 | lblChangeColor.setBootstrapBrand(DefaultBootstrapBrand.REGULAR);
72 | break;
73 | case REGULAR:
74 | lblChangeColor.setBootstrapBrand(DefaultBootstrapBrand.PRIMARY);
75 | break;
76 | default:
77 | lblChangeColor.setBootstrapBrand(DefaultBootstrapBrand.PRIMARY);
78 | break;
79 | }
80 | }
81 |
82 | @OnClick(R.id.example_blabel_change_rounded) void onRoundedChangeClicked() {
83 | lblChangeRounded.setRounded(!lblChangeRounded.isRounded());
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapProgressBarExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import com.beardedhen.androidbootstrap.BootstrapProgressBar;
4 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
5 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
6 |
7 | import java.util.Random;
8 |
9 | import butterknife.BindView;
10 | import butterknife.OnClick;
11 |
12 | public class BootstrapProgressBarExample extends BaseActivity {
13 |
14 | enum ChangeState {
15 | FIRST(false, false),
16 | SECOND(false, true),
17 | THIRD(true, false),
18 | FOURTH(true, true);
19 |
20 | private final boolean animated;
21 | private final boolean striped;
22 |
23 | ChangeState(boolean animated, boolean striped) {
24 | this.animated = animated;
25 | this.striped = striped;
26 | }
27 |
28 | public ChangeState next() {
29 | switch (this) {
30 | case FIRST:
31 | return SECOND;
32 | case SECOND:
33 | return THIRD;
34 | case THIRD:
35 | return FOURTH;
36 | case FOURTH:
37 | return FIRST;
38 | default:
39 | return FIRST;
40 | }
41 | }
42 | }
43 |
44 | private Random random;
45 | private ChangeState changeState = ChangeState.FIRST;
46 | private DefaultBootstrapSize size = DefaultBootstrapSize.MD;
47 |
48 | @Override protected int getContentLayoutId() {
49 | return R.layout.example_bootstrap_progress_bar;
50 | }
51 |
52 | @BindView(R.id.example_progress_default) BootstrapProgressBar defaultExample;
53 | @BindView(R.id.example_progress_animated) BootstrapProgressBar animatedExample;
54 | @BindView(R.id.example_progress_striped) BootstrapProgressBar stripedExample;
55 | @BindView(R.id.example_progress_striped_animated) BootstrapProgressBar stripedAnimExample;
56 | @BindView(R.id.example_progress_change) BootstrapProgressBar changeExample;
57 | @BindView(R.id.example_size_change) BootstrapProgressBar sizeExample;
58 |
59 | @OnClick(R.id.example_progress_default_btn) void onDefaultClicked() {
60 | defaultExample.setProgress(randomProgress(defaultExample.getProgress(), 100));
61 | }
62 |
63 | @OnClick(R.id.example_progress_animated_btn) void onAnimatedClicked() {
64 | animatedExample.setProgress(randomProgress(animatedExample.getProgress(), 100));
65 | }
66 |
67 | @OnClick(R.id.example_progress_striped_btn) void onStripedClicked() {
68 | stripedExample.setProgress(randomProgress(stripedExample.getProgress(), 200));
69 | }
70 |
71 | @OnClick(R.id.example_progress_striped_animated_btn) void onStripedAnimClicked() {
72 | stripedAnimExample.setProgress(randomProgress(stripedAnimExample.getProgress(), 100));
73 | }
74 |
75 | @OnClick(R.id.example_progress_change_type_btn) void onAlterProgressBarParameters() {
76 | changeState = changeState.next();
77 | changeExample.setStriped(changeState.striped);
78 | changeExample.setAnimated(changeState.animated);
79 | }
80 |
81 | @OnClick(R.id.example_progress_change_rounded_btn) void onChangeRoundedProgressBar() {
82 | changeExample.setRounded(!changeExample.isRounded());
83 | }
84 |
85 | @OnClick(R.id.example_progress_change_color_btn) void onAlterProgressBarColor() {
86 | switch ((DefaultBootstrapBrand) changeExample.getBootstrapBrand()) {
87 | case PRIMARY:
88 | changeExample.setBootstrapBrand(DefaultBootstrapBrand.SUCCESS);
89 | break;
90 | case SUCCESS:
91 | changeExample.setBootstrapBrand(DefaultBootstrapBrand.INFO);
92 | break;
93 | case INFO:
94 | changeExample.setBootstrapBrand(DefaultBootstrapBrand.WARNING);
95 | break;
96 | case WARNING:
97 | changeExample.setBootstrapBrand(DefaultBootstrapBrand.DANGER);
98 | break;
99 | case DANGER:
100 | changeExample.setBootstrapBrand(DefaultBootstrapBrand.SECONDARY);
101 | break;
102 | case SECONDARY:
103 | changeExample.setBootstrapBrand(DefaultBootstrapBrand.REGULAR);
104 | case REGULAR:
105 | changeExample.setBootstrapBrand(DefaultBootstrapBrand.PRIMARY);
106 | break;
107 | }
108 | }
109 |
110 | @OnClick(R.id.example_size_change_btn) void onSizeExampleChangeClicked() {
111 | switch (size) {
112 | case XS:
113 | size = DefaultBootstrapSize.SM;
114 | break;
115 | case SM:
116 | size = DefaultBootstrapSize.MD;
117 | break;
118 | case MD:
119 | size = DefaultBootstrapSize.LG;
120 | break;
121 | case LG:
122 | size = DefaultBootstrapSize.XL;
123 | break;
124 | case XL:
125 | size = DefaultBootstrapSize.XS;
126 | break;
127 | }
128 | sizeExample.setBootstrapSize(size);
129 | }
130 |
131 | private int randomProgress(int currentProgress, int maxProgress) {
132 | if (random == null) {
133 | random = new Random();
134 | }
135 |
136 | int prog = currentProgress + random.nextInt(20);
137 |
138 | if (prog > maxProgress) {
139 | prog -= maxProgress;
140 | }
141 |
142 | return prog;
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapProgressBarGroupExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import com.beardedhen.androidbootstrap.BootstrapProgressBar;
4 | import com.beardedhen.androidbootstrap.BootstrapProgressBarGroup;
5 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapBrand;
6 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
7 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
8 |
9 | import java.util.Random;
10 |
11 | import butterknife.BindView;
12 | import butterknife.OnClick;
13 |
14 | public class BootstrapProgressBarGroupExample extends BaseActivity {
15 |
16 | @BindView(R.id.example_progress_bar_group_add_group)
17 | BootstrapProgressBarGroup groupAdd;
18 |
19 | @BindView(R.id.example_progress_bar_group_round_group)
20 | BootstrapProgressBarGroup groupRound;
21 |
22 | @BindView(R.id.example_progress_bar_group_progress_1)
23 | BootstrapProgressBar bootstrapProgressBar1;
24 |
25 | @BindView(R.id.example_progress_bar_group_progress_2)
26 | BootstrapProgressBar bootstrapProgressBar2;
27 |
28 | boolean rounded = false;
29 |
30 | @Override
31 | protected int getContentLayoutId() {
32 | return R.layout.example_bootstrap_progress_bar_group;
33 | }
34 |
35 | @OnClick(R.id.example_progress_bar_group_add)
36 | void addToGroup(){
37 | Random rand = new Random();
38 | BootstrapProgressBar bar = new BootstrapProgressBar(this);
39 | bar.setProgress(10);
40 | int brand = 5;
41 | while (brand == 5) {
42 | brand = rand.nextInt(7);
43 | }
44 | bar.setBootstrapBrand(DefaultBootstrapBrand.fromAttributeValue(brand));
45 |
46 | if(groupAdd.getCumulativeProgress() + 10 <= 100) {
47 | groupAdd.addView(bar);
48 | }else{
49 | groupAdd.removeViews(2, groupAdd.getChildCount() - 3);
50 | }
51 | }
52 |
53 | @OnClick(R.id.example_progress_bar_group_round)
54 | void onRoundClick(){
55 | rounded = !rounded;
56 | groupRound.setRounded(rounded);
57 | }
58 |
59 | @OnClick(R.id.example_progress_bar_group_progress)
60 | void onClickProgressChange(){
61 | Random rand = new Random();
62 | int progress = rand.nextInt(30) + 10;
63 | switch(rand.nextInt(2)){
64 | case 0:
65 | bootstrapProgressBar1.setProgress(progress);
66 | break;
67 | case 1:
68 | bootstrapProgressBar2.setProgress(progress);
69 | break;
70 | }
71 |
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapThumbnailExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.os.Bundle;
6 | import android.widget.LinearLayout;
7 |
8 | import com.beardedhen.androidbootstrap.BootstrapThumbnail;
9 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
10 | import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapSize;
11 | import com.beardedhen.androidbootstrap.utils.DrawableUtils;
12 |
13 | import butterknife.BindView;
14 | import butterknife.OnClick;
15 |
16 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.DANGER;
17 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.INFO;
18 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.PRIMARY;
19 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.REGULAR;
20 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.SECONDARY;
21 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.SUCCESS;
22 | import static com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand.WARNING;
23 |
24 | public class BootstrapThumbnailExample extends BaseActivity {
25 |
26 | private int resId = R.drawable.ladybird;
27 | private DefaultBootstrapSize size = DefaultBootstrapSize.MD;
28 |
29 | @Override protected int getContentLayoutId() {
30 | return R.layout.example_bootstrap_thumbnail;
31 | }
32 |
33 | @BindView(R.id.bthumb_image_change_example) BootstrapThumbnail imageChange;
34 | @BindView(R.id.bthumb_theme_change_example) BootstrapThumbnail themeChange;
35 | @BindView(R.id.bthumb_border_change_example) BootstrapThumbnail borderChange;
36 | @BindView(R.id.bthumb_rounded_change_example) BootstrapThumbnail roundedChange;
37 | @BindView(R.id.bthumb_size_change_example) BootstrapThumbnail sizeChange;
38 | @BindView(R.id.bthumb_set_image_bitmap_example) BootstrapThumbnail setBitmapExample;
39 | @BindView(R.id.bthumb_set_image_drawable_example) BootstrapThumbnail setDrawableExample;
40 | @BindView(R.id.bthumb_set_image_resource_example) BootstrapThumbnail setResourceExample;
41 |
42 | @Override protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 |
45 | Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.small_daffodils);
46 | setBitmapExample.setImageBitmap(bm);
47 |
48 | setDrawableExample.setImageDrawable(DrawableUtils.resolveDrawable(R.drawable.ladybird,
49 | this));
50 | setResourceExample.setImageResource(R.drawable.caterpillar);
51 | sizeChange.setLayoutParams(getLayoutParams(size.scaleFactor()));
52 | }
53 |
54 | private LinearLayout.LayoutParams getLayoutParams(float factor) {
55 | float baselineSize = 300;
56 | float size = baselineSize * factor;
57 | return new LinearLayout.LayoutParams((int)size, (int)size);
58 | }
59 |
60 | @OnClick(R.id.bthumb_theme_change_example) void onThemeChangeExampleClicked() {
61 | switch ((DefaultBootstrapBrand) themeChange.getBootstrapBrand()) {
62 | case PRIMARY:
63 | themeChange.setBootstrapBrand(SUCCESS);
64 | break;
65 | case SUCCESS:
66 | themeChange.setBootstrapBrand(INFO);
67 | break;
68 | case INFO:
69 | themeChange.setBootstrapBrand(WARNING);
70 | break;
71 | case WARNING:
72 | themeChange.setBootstrapBrand(DANGER);
73 | break;
74 | case DANGER:
75 | themeChange.setBootstrapBrand(SECONDARY);
76 | break;
77 | case SECONDARY:
78 | themeChange.setBootstrapBrand(REGULAR);
79 | break;
80 | case REGULAR:
81 | themeChange.setBootstrapBrand(PRIMARY);
82 | break;
83 | }
84 | }
85 |
86 | @OnClick(R.id.bthumb_image_change_example) void onImageChangeExampleClicked() {
87 | switch (resId) {
88 | case R.drawable.ladybird:
89 | resId = R.drawable.caterpillar;
90 | break;
91 | case R.drawable.caterpillar:
92 | resId = 0;
93 | break;
94 | case 0:
95 | resId = R.drawable.ladybird;
96 | break;
97 | }
98 | imageChange.setImageResource(resId);
99 | }
100 |
101 | @OnClick(R.id.bthumb_rounded_change_example) void onRoundedChangeExampleClicked() {
102 | roundedChange.setRounded(!roundedChange.isRounded());
103 | }
104 |
105 | @OnClick(R.id.bthumb_border_change_example) void onBorderChangeExampleClicked() {
106 | borderChange.setBorderDisplayed(!borderChange.isBorderDisplayed());
107 | }
108 |
109 | @OnClick(R.id.bthumb_size_change_example) void onSizeChangeExampleClicked() {
110 | switch (size) {
111 | case XS:
112 | size = DefaultBootstrapSize.SM;
113 | break;
114 | case SM:
115 | size = DefaultBootstrapSize.MD;
116 | break;
117 | case MD:
118 | size = DefaultBootstrapSize.LG;
119 | break;
120 | case LG:
121 | size = DefaultBootstrapSize.XL;
122 | break;
123 | case XL:
124 | size = DefaultBootstrapSize.XS;
125 | break;
126 | }
127 | sizeChange.setBootstrapSize(size);
128 | sizeChange.setLayoutParams(getLayoutParams(size.scaleFactor()));
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/BootstrapWellExample.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | public class BootstrapWellExample extends Activity {
7 |
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | setContentView(R.layout.example_bootstrap_well);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/CustomBootstrapStyle.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.ColorInt;
5 |
6 | import com.beardedhen.androidbootstrap.api.attributes.BootstrapBrand;
7 |
8 | /**
9 | * A custom Bootstrap Style. Implement {@see BootstrapBrand} in your own classes to define styles.
10 | */
11 | public class CustomBootstrapStyle implements BootstrapBrand {
12 |
13 | @ColorInt private final int defaultFill;
14 | @ColorInt private final int defaultEdge;
15 | @ColorInt private final int defaultTextColor;
16 | @ColorInt private final int activeFill;
17 | @ColorInt private final int activeEdge;
18 | @ColorInt private final int activeTextColor;
19 | @ColorInt private final int disabledFill;
20 | @ColorInt private final int disabledEdge;
21 | @ColorInt private final int disabledTextColor;
22 |
23 | @SuppressWarnings("deprecation") public CustomBootstrapStyle(Context context) {
24 | defaultFill = context.getResources().getColor(R.color.custom_default_fill);
25 | defaultEdge = context.getResources().getColor(R.color.custom_default_edge);
26 | defaultTextColor = context.getResources().getColor(android.R.color.white);
27 | activeFill = context.getResources().getColor(R.color.custom_active_fill);
28 | activeEdge = context.getResources().getColor(R.color.custom_active_edge);
29 | activeTextColor = context.getResources().getColor(android.R.color.black);
30 | disabledFill = context.getResources().getColor(R.color.custom_disabled_fill);
31 | disabledEdge = context.getResources().getColor(R.color.custom_disabled_edge);
32 | disabledTextColor = context.getResources().getColor(R.color.bootstrap_gray);
33 | }
34 |
35 | @Override public int defaultFill(Context context) {
36 | return defaultFill;
37 | }
38 |
39 | @Override public int defaultEdge(Context context) {
40 | return defaultEdge;
41 | }
42 |
43 | @Override public int defaultTextColor(Context context) {
44 | return defaultTextColor;
45 | }
46 |
47 | @Override public int activeFill(Context context) {
48 | return activeFill;
49 | }
50 |
51 | @Override public int activeEdge(Context context) {
52 | return activeEdge;
53 | }
54 |
55 | @Override public int activeTextColor(Context context) {
56 | return activeTextColor;
57 | }
58 |
59 | @Override public int disabledFill(Context context) {
60 | return disabledFill;
61 | }
62 |
63 | @Override public int disabledEdge(Context context) {
64 | return disabledEdge;
65 | }
66 |
67 | @Override public int disabledTextColor(Context context) {
68 | return disabledTextColor;
69 | }
70 |
71 | @Override public int getColor() {
72 | return defaultFill;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/HomeActivity.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 |
8 | import butterknife.ButterKnife;
9 | import butterknife.OnClick;
10 |
11 | public class HomeActivity extends AppCompatActivity {
12 |
13 | @Override protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_main);
16 | ButterKnife.bind(this);
17 | }
18 |
19 | @OnClick(R.id.github_btn) void onGithubClicked() {
20 | Intent intent = new Intent(Intent.ACTION_VIEW); startActivity(intent);
21 | intent.setData(Uri.parse("https://github.com/Bearded-Hen/Android-Bootstrap"));
22 | startActivity(intent);
23 | }
24 |
25 | @OnClick(R.id.example_bootstrap_button) void onBootstrapButtonExampleClicked() {
26 | startActivity(new Intent(this, BootstrapButtonExample.class));
27 | }
28 |
29 | @OnClick(R.id.example_fontawesometext) void onFontAwesomeTextExampleClicked() {
30 | startActivity(new Intent(this, AwesomeTextViewExample.class));
31 | }
32 |
33 | @OnClick(R.id.example_bootstrap_label) void onBootstrapLabelExampleClicked() {
34 | startActivity(new Intent(this, BootstrapLabelExample.class));
35 | }
36 |
37 | @OnClick(R.id.example_bootstrap_progress) void onBootstrapProgressExampleClicked() {
38 | startActivity(new Intent(this, BootstrapProgressBarExample.class));
39 | }
40 |
41 | @OnClick(R.id.example_bootstrap_progress_group) void onBootstrapProgressGroupExampleClicked() {
42 | startActivity(new Intent(this, BootstrapProgressBarGroupExample.class));
43 | }
44 |
45 | @OnClick(R.id.example_bootstrap_btn_group) void onBootstrapButtonGroupExampleClicked() {
46 | startActivity(new Intent(this, BootstrapButtonGroupExample.class));
47 | }
48 |
49 | @OnClick(R.id.example_bootstrap_cricle_thumbnail) void onBootstrapCircleThumbnailExampleClicked() {
50 | startActivity(new Intent(this, BootstrapCircleThumbnailExample.class));
51 | }
52 |
53 | @OnClick(R.id.example_bootstrap_edit_text) void onBootstrapEditTextExampleClicked() {
54 | startActivity(new Intent(this, BootstrapEditTextExample.class));
55 | }
56 |
57 | @OnClick(R.id.example_bootstrap_thumbnail) void onBootstrapThumbnailExampleClicked() {
58 | startActivity(new Intent(this, BootstrapThumbnailExample.class));
59 | }
60 |
61 | @OnClick(R.id.example_bootstrap_well) void onBootstrapWellExampleClicked() {
62 | startActivity(new Intent(this, BootstrapWellExample.class));
63 | }
64 |
65 | @OnClick(R.id.example_bootstrap_dropdown) void onBootstrapDropdownExampleClicked() {
66 | startActivity(new Intent(this, BootstrapDropDownExample.class));
67 | }
68 | @OnClick(R.id.example_bootstrap_alert) void onBootstrapAlertExampleClicked() {
69 | startActivity(new Intent(this, BootstrapAlertExample.class));
70 | }
71 |
72 | @OnClick(R.id.example_bootstrap_badge) void onBootstrapBadgeExampleClicked() {
73 | startActivity(new Intent(this, BootstrapBadgeExample.class));
74 | }
75 |
76 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/fractalwrench/androidbootstrap/sample/SampleApplication.java:
--------------------------------------------------------------------------------
1 | package com.fractalwrench.androidbootstrap.sample;
2 |
3 | import android.app.Application;
4 |
5 | import com.beardedhen.androidbootstrap.TypefaceProvider;
6 |
7 | /**
8 | * A custom application class, which performs setup of the Typefaces used as Icon Sets.
9 | */
10 | public class SampleApplication extends Application {
11 |
12 | @Override public void onCreate() {
13 | super.onCreate();
14 |
15 | // setup default typefaces
16 | TypefaceProvider.registerDefaultIconSets();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/alpha.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/author.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/author.jpeg
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/author_small.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/author_small.jpeg
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/caterpillar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/caterpillar.jpg
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/daffodil_large.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/daffodil_large.jpg
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/flower.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/flower.jpg
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ladybird.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/ladybird.jpg
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/landscape_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/landscape_image.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/perfect_square.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/perfect_square.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/portrait_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/portrait_image.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/small_daffodils.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/small_daffodils.jpeg
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/stars.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/drawable/stars.jpg
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_base.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 |
17 |
25 |
26 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
49 |
54 |
55 |
60 |
61 |
66 |
67 |
72 |
73 |
78 |
79 |
84 |
85 |
90 |
91 |
96 |
97 |
102 |
103 |
108 |
109 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/example_awesome_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
19 |
20 |
25 |
26 |
32 |
33 |
39 |
40 |
46 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
69 |
70 |
74 |
75 |
80 |
81 |
86 |
87 |
93 |
94 |
99 |
100 |
105 |
106 |
107 |
108 |
109 |
113 |
114 |
122 |
123 |
130 |
131 |
138 |
139 |
147 |
148 |
152 |
153 |
158 |
159 |
164 |
165 |
166 |
170 |
171 |
176 |
177 |
181 |
182 |
186 |
187 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/example_bootstrap_alert.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
30 |
31 |
41 |
42 |
52 |
53 |
62 |
63 |
70 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/example_bootstrap_badge.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
33 |
34 |
35 |
44 |
45 |
54 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/example_bootstrap_edit_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
14 |
15 |
22 |
23 |
30 |
31 |
32 |
33 |
40 |
41 |
48 |
49 |
58 |
59 |
60 |
61 |
68 |
69 |
77 |
78 |
87 |
88 |
89 |
90 |
97 |
98 |
105 |
106 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/example_bootstrap_progress_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
11 |
12 |
19 |
20 |
26 |
27 |
28 |
30 |
31 |
38 |
39 |
46 |
47 |
48 |
50 |
51 |
58 |
59 |
67 |
68 |
69 |
71 |
72 |
79 |
80 |
88 |
89 |
90 |
92 |
93 |
100 |
101 |
109 |
110 |
111 |
113 |
114 |
120 |
121 |
127 |
128 |
134 |
135 |
141 |
142 |
143 |
149 |
150 |
151 |
153 |
154 |
160 |
161 |
166 |
167 |
175 |
176 |
177 |
184 |
185 |
193 |
194 |
195 |
196 |
197 |
198 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/example_bootstrap_progress_bar_group.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
25 |
32 |
33 |
34 |
35 |
40 |
41 |
46 |
47 |
54 |
55 |
63 |
64 |
71 |
72 |
73 |
74 |
75 |
80 |
81 |
88 |
89 |
96 |
97 |
103 |
104 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
121 |
122 |
129 |
130 |
137 |
138 |
145 |
146 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/example_bootstrap_well.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
21 |
22 |
23 |
28 |
29 |
34 |
35 |
36 |
42 |
43 |
48 |
49 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bearded-Hen/Android-Bootstrap/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #33bbaa
5 | #119999
6 | #119999
7 | #008888
8 | #8833bbaa
9 | #bb33bbaa
10 |
11 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 | 4dp
4 | 250dp
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android Bootstrap
3 |
4 | - First item
5 | - Second item
6 | - {dropdown_disabled}Disabled item
7 | - {dropdown_header}Dropdown header
8 | - Fourth item
9 | - Fifth item
10 | - {dropdown_separator}
11 | - Separated item
12 | - Item 9
13 | - Item 10
14 | - Item 11
15 | - Item 12
16 | - Item 13
17 | - Item 14
18 | - Item 15
19 | - Item 16
20 | - Item 17
21 | - Item 18
22 | - Item 19
23 | - Item 20
24 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
15 |
16 |
22 |
23 |
30 |
31 |
36 |
37 |
43 |
44 |
50 |
51 |
57 |
58 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':AndroidBootstrap', ':sample'
2 |
--------------------------------------------------------------------------------