Repository: navasmdc/MaterialDesignLibrary Branch: master Commit: 7271050ff486 Files: 91 Total size: 251.8 KB Directory structure: gitextract_cquzdhju/ ├── .gitignore ├── LICENSE ├── MaterialDesignLibrary/ │ ├── .gitignore │ ├── MaterialDesign/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── proguard-rules.pro │ │ └── src/ │ │ ├── androidTest/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── gc/ │ │ │ └── materialdesign/ │ │ │ └── ApplicationTest.java │ │ └── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── gc/ │ │ │ └── materialdesign/ │ │ │ ├── utils/ │ │ │ │ └── Utils.java │ │ │ ├── views/ │ │ │ │ ├── AutoHideButtonFloat.java │ │ │ │ ├── Button.java │ │ │ │ ├── ButtonFlat.java │ │ │ │ ├── ButtonFloat.java │ │ │ │ ├── ButtonFloatSmall.java │ │ │ │ ├── ButtonIcon.java │ │ │ │ ├── ButtonRectangle.java │ │ │ │ ├── Card.java │ │ │ │ ├── CheckBox.java │ │ │ │ ├── CustomView.java │ │ │ │ ├── LayoutRipple.java │ │ │ │ ├── ProgressBarCircularIndeterminate.java │ │ │ │ ├── ProgressBarDeterminate.java │ │ │ │ ├── ProgressBarIndeterminate.java │ │ │ │ ├── ProgressBarIndeterminateDeterminate.java │ │ │ │ ├── ScrollView.java │ │ │ │ ├── Slider.java │ │ │ │ └── Switch.java │ │ │ └── widgets/ │ │ │ ├── ColorSelector.java │ │ │ ├── Dialog.java │ │ │ ├── ProgressDialog.java │ │ │ └── SnackBar.java │ │ └── res/ │ │ ├── anim/ │ │ │ ├── dialog_main_hide_amination.xml │ │ │ ├── dialog_main_show_amination.xml │ │ │ ├── dialog_root_hide_amin.xml │ │ │ ├── dialog_root_show_amin.xml │ │ │ ├── progress_indeterminate_animation.xml │ │ │ ├── snackbar_hide_animation.xml │ │ │ └── snackbar_show_animation.xml │ │ ├── drawable/ │ │ │ ├── background_button_float.xml │ │ │ ├── background_button_rectangle.xml │ │ │ ├── background_checkbox.xml │ │ │ ├── background_checkbox_check.xml │ │ │ ├── background_checkbox_uncheck.xml │ │ │ ├── background_progress.xml │ │ │ ├── background_switch_ball_uncheck.xml │ │ │ ├── background_transparent.xml │ │ │ ├── shadow_down.xml │ │ │ └── shadow_right.xml │ │ ├── layout/ │ │ │ ├── color_selector.xml │ │ │ ├── dialog.xml │ │ │ ├── number_indicator_spinner.xml │ │ │ ├── progress_dialog.xml │ │ │ └── snackbar.xml │ │ └── values/ │ │ ├── attributes.xml │ │ ├── colors.xml │ │ └── strings.xml │ ├── MaterialDesignDemo/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src/ │ │ ├── androidTest/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── gc/ │ │ │ └── materialdesigndemo/ │ │ │ └── ApplicationTest.java │ │ └── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── gc/ │ │ │ └── materialdesigndemo/ │ │ │ └── ui/ │ │ │ ├── ButtonsActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── ProgressActivity.java │ │ │ ├── SwitchActivity.java │ │ │ └── WidgetActivity.java │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── blue_background.xml │ │ │ ├── selector_list.xml │ │ │ └── transparent_backgrouns.xml │ │ ├── layout/ │ │ │ ├── activity_buttons.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_progress.xml │ │ │ ├── activity_switchs.xml │ │ │ └── activity_widgets.xml │ │ └── values/ │ │ ├── strings.xml │ │ └── styles.xml │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── README.md ├── index.html ├── javascripts/ │ └── main.js ├── params.json └── stylesheets/ ├── github-light.css ├── print.css └── stylesheet.css ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Built application files *.apk *.ap_ # Files for the Dalvik VM *.dex # Java class files *.class # Generated files bin/ gen/ # Gradle files .gradle/ build/ # Local configuration file (sdk path, etc) local.properties # Proguard folder generated by Eclipse proguard/ # Log Files *.log .idea/ *.iml ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: MaterialDesignLibrary/.gitignore ================================================ .gradle /local.properties /.idea/workspace.xml /.idea/libraries .DS_Store /build /captures ================================================ FILE: MaterialDesignLibrary/MaterialDesign/.gitignore ================================================ /build ================================================ FILE: MaterialDesignLibrary/MaterialDesign/build.gradle ================================================ apply plugin: 'com.android.library' // COMMENT TO DEVELOPER MODE / UNCOMMENT TO UPLOAD TO BINTARRAY //apply plugin: 'com.github.dcendents.android-maven' //apply plugin: 'com.jfrog.bintray' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 16 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile 'com.nineoldandroids:library:2.4.+' compile 'com.android.support:support-v4:22.+' compile fileTree(dir: 'libs', include: '*.jar') } // COMMENT TO DEVELOPER MODE / UNCOMMENT TO UPLOAD TO BINTARRAY //ext.siteUrl = 'https://github.com/navasmdc/MaterialDesignLibrary' //ext.issueUrl = 'https://github.com/navasmdc/MaterialDesignLibrary/issues' //ext.gitUrl = 'https://github.com/navasmdc/MaterialDesignLibrary.git' // //bintray { // user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : "navasmdc" // key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : "" // // configurations = ["archives"] // pkg { // repo = 'maven' // name = 'MaterialDesignLibrary' // desc = 'This is a library with components of Android L to you use in android 2.2' // websiteUrl = siteUrl // issueTrackerUrl = issueUrl // vcsUrl = gitUrl // licenses = ['Apache-2.0'] // labels = [] // publicDownloadNumbers = true // } //} //install { // repositories.mavenInstaller { // pom { // project { // packaging 'aar' // name 'MaterialDesignLibrary' // url siteUrl // licenses { // license { // name 'The Apache Software License, Version 2.0' // url 'http://www.apache.org/licenses/LICENSE-2.0.txt' // } // } // developers { // developer { // id 'navasmdc' // name 'Iván Navas' // email 'i.navas.mdc@gmail.com' // } // } // scm { // connection gitUrl // developerConnection gitUrl // url siteUrl // } // } // } // } //} // //task sourcesJar(type: Jar) { // from android.sourceSets.main.java.srcDirs // classifier = 'sources' //} // //task javadoc(type: Javadoc) { // source = android.sourceSets.main.java.srcDirs // classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) //} // //task javadocJar(type: Jar, dependsOn: javadoc) { // classifier = 'javadoc' // from javadoc.destinationDir //} // //artifacts { // archives javadocJar // archives sourcesJar //} // //task findConventions << { // println project.getConvention() //} ================================================ FILE: MaterialDesignLibrary/MaterialDesign/gradle.properties ================================================ POM_NAME=MaterialDesignLibrary POM_ARTIFACT_ID=material-design-library POM_PACKAGING=aar ================================================ FILE: MaterialDesignLibrary/MaterialDesign/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Applications/adt-bundle-mac-x86_64-20140321/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/androidTest/java/com/gc/materialdesign/ApplicationTest.java ================================================ package com.gc.materialdesign; import android.app.Application; import android.test.ApplicationTestCase; /** * Testing Fundamentals */ public class ApplicationTest extends ApplicationTestCase { public ApplicationTest() { super(Application.class); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/AndroidManifest.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/utils/Utils.java ================================================ package com.gc.materialdesign.utils; import android.content.res.Resources; import android.util.TypedValue; import android.view.View; public class Utils { /** * Convert Dp to Pixel */ public static int dpToPx(float dp, Resources resources){ float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics()); return (int) px; } public static int getRelativeTop(View myView) { // if (myView.getParent() == myView.getRootView()) if(myView.getId() == android.R.id.content) return myView.getTop(); else return myView.getTop() + getRelativeTop((View) myView.getParent()); } public static int getRelativeLeft(View myView) { // if (myView.getParent() == myView.getRootView()) if(myView.getId() == android.R.id.content) return myView.getLeft(); else return myView.getLeft() + getRelativeLeft((View) myView.getParent()); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/AutoHideButtonFloat.java ================================================ package com.gc.materialdesign.views; import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.widget.AbsListView; import android.widget.ListView; import com.gc.materialdesign.views.ButtonFloat; import com.nineoldandroids.view.ViewPropertyAnimator; /** * Created by hamedpc on 4/25/2015. * This widget uses NineOldAndroid to animate the view so you're gonna need to include it in your project */ public class AutoHideButtonFloat extends ButtonFloat implements AbsListView.OnScrollListener { ListView listView; private boolean floatHiding = false, floatShowing = false; private int mLastFirstVisibleItem; private View view = this; private AbsListView.OnScrollListener onScrollListener; public AutoHideButtonFloat(Context context, AttributeSet attrs) { super(context, attrs); } public void setOnScrollListener(AbsListView.OnScrollListener onScrollListener) { this.onScrollListener = onScrollListener; } public void setListView(ListView listView) { this.listView = listView; this.listView.setOnScrollListener(this); } @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { switch (scrollState) { case AbsListView.SCROLL_AXIS_NONE: floatHiding = false; floatShowing = false; ViewPropertyAnimator.animate(view).translationY(0).setDuration(300); break; } if (onScrollListener != null) onScrollListener.onScrollStateChanged(absListView, scrollState); } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mLastFirstVisibleItem < firstVisibleItem) { if (floatShowing) floatShowing = false; if (!floatHiding) { ViewPropertyAnimator.animate(view).translationY(500).setDuration(300); floatHiding = true; } } if (mLastFirstVisibleItem > firstVisibleItem) { if (floatHiding) { floatHiding = false; } if (!floatShowing) { ViewPropertyAnimator.animate(view).translationY(0).setDuration(300); floatShowing = true; } } mLastFirstVisibleItem = firstVisibleItem; if (onScrollListener != null) onScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/Button.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Bitmap.Config; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.TextView; public abstract class Button extends CustomView { final static String ANDROIDXML = "http://schemas.android.com/apk/res/android"; // Complete in child class int minWidth; int minHeight; int background; float rippleSpeed = 12f; int rippleSize = 3; Integer rippleColor; OnClickListener onClickListener; boolean clickAfterRipple = true; int backgroundColor = Color.parseColor("#1E88E5"); TextView textButton; public Button(Context context, AttributeSet attrs) { super(context, attrs); setDefaultProperties(); clickAfterRipple = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "animate", true); setAttributes(attrs); beforeBackground = backgroundColor; if (rippleColor == null) rippleColor = makePressColor(); } protected void setDefaultProperties() { // Min size setMinimumHeight(Utils.dpToPx(minHeight, getResources())); setMinimumWidth(Utils.dpToPx(minWidth, getResources())); // Background shape setBackgroundResource(background); setBackgroundColor(backgroundColor); } // Set atributtes of XML to View abstract protected void setAttributes(AttributeSet attrs); // ### RIPPLE EFFECT ### float x = -1, y = -1; float radius = -1; @Override public boolean onTouchEvent(MotionEvent event) { invalidate(); if (isEnabled()) { isLastTouch = true; if (event.getAction() == MotionEvent.ACTION_DOWN) { radius = getHeight() / rippleSize; x = event.getX(); y = event.getY(); } else if (event.getAction() == MotionEvent.ACTION_MOVE) { radius = getHeight() / rippleSize; x = event.getX(); y = event.getY(); if (!((event.getX() <= getWidth() && event.getX() >= 0) && (event .getY() <= getHeight() && event.getY() >= 0))) { isLastTouch = false; x = -1; y = -1; } } else if (event.getAction() == MotionEvent.ACTION_UP) { if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) { radius++; if (!clickAfterRipple && onClickListener != null) { onClickListener.onClick(this); } } else { isLastTouch = false; x = -1; y = -1; } } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { isLastTouch = false; x = -1; y = -1; } } return true; } @Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { if (!gainFocus) { x = -1; y = -1; } } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { // super.onInterceptTouchEvent(ev); return true; } public Bitmap makeCircle() { Bitmap output = Bitmap.createBitmap( getWidth() - Utils.dpToPx(6, getResources()), getHeight() - Utils.dpToPx(7, getResources()), Config.ARGB_8888); Canvas canvas = new Canvas(output); canvas.drawARGB(0, 0, 0, 0); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(rippleColor); canvas.drawCircle(x, y, radius, paint); if (radius > getHeight() / rippleSize) radius += rippleSpeed; if (radius >= getWidth()) { x = -1; y = -1; radius = getHeight() / rippleSize; if (onClickListener != null && clickAfterRipple) onClickListener.onClick(this); } return output; } /** * Make a dark color to ripple effect * * @return */ protected int makePressColor() { int r = (this.backgroundColor >> 16) & 0xFF; int g = (this.backgroundColor >> 8) & 0xFF; int b = (this.backgroundColor >> 0) & 0xFF; r = (r - 30 < 0) ? 0 : r - 30; g = (g - 30 < 0) ? 0 : g - 30; b = (b - 30 < 0) ? 0 : b - 30; return Color.rgb(r, g, b); } @Override public void setOnClickListener(OnClickListener l) { onClickListener = l; } // Set color of background public void setBackgroundColor(int color) { this.backgroundColor = color; if (isEnabled()) beforeBackground = backgroundColor; try { LayerDrawable layer = (LayerDrawable) getBackground(); GradientDrawable shape = (GradientDrawable) layer .findDrawableByLayerId(R.id.shape_bacground); shape.setColor(backgroundColor); rippleColor = makePressColor(); } catch (Exception ex) { // Without bacground } } public void setRippleSpeed(float rippleSpeed) { this.rippleSpeed = rippleSpeed; } public float getRippleSpeed() { return this.rippleSpeed; } public void setText(String text) { textButton.setText(text); } public void setTextColor(int color) { textButton.setTextColor(color); } public TextView getTextView() { return textButton; } public String getText() { return textButton.getText().toString(); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ButtonFlat.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Typeface; import android.util.AttributeSet; import android.widget.RelativeLayout; import android.widget.TextView; public class ButtonFlat extends Button { TextView textButton; public ButtonFlat(Context context, AttributeSet attrs) { super(context, attrs); } protected void setDefaultProperties(){ minHeight = 36; minWidth = 88; rippleSize = 3; // Min size setMinimumHeight(Utils.dpToPx(minHeight, getResources())); setMinimumWidth(Utils.dpToPx(minWidth, getResources())); setBackgroundResource(R.drawable.background_transparent); } @Override protected void setAttributes(AttributeSet attrs) { // Set text button String text = null; int textResource = attrs.getAttributeResourceValue(ANDROIDXML,"text",-1); if(textResource != -1){ text = getResources().getString(textResource); }else{ text = attrs.getAttributeValue(ANDROIDXML,"text"); } if(text != null){ textButton = new TextView(getContext()); textButton.setText(text.toUpperCase()); textButton.setTextColor(backgroundColor); textButton.setTypeface(null, Typeface.BOLD); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); textButton.setLayoutParams(params); addView(textButton); } int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal // Color by hexadecimal background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (x != -1) { Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(makePressColor()); canvas.drawCircle(x, y, radius, paint); if(radius > getHeight()/rippleSize) radius += rippleSpeed; if(radius >= getWidth()){ x = -1; y = -1; radius = getHeight()/rippleSize; if(onClickListener != null&& clickAfterRipple) onClickListener.onClick(this); } invalidate(); } } /** * Make a dark color to ripple effect * @return */ @Override protected int makePressColor(){ return Color.parseColor("#88DDDDDD"); } public void setText(String text){ textButton.setText(text.toUpperCase()); } // Set color of background public void setBackgroundColor(int color){ backgroundColor = color; if(isEnabled()) beforeBackground = backgroundColor; textButton.setTextColor(color); } @Override public TextView getTextView() { return textButton; } public String getText(){ return textButton.getText().toString(); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ButtonFloat.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.view.ViewHelper; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.Bitmap.Config; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.view.animation.BounceInterpolator; import android.widget.ImageView; import android.widget.ImageView.ScaleType; import android.widget.RelativeLayout; import android.widget.TextView; public class ButtonFloat extends Button{ int sizeIcon = 24; int sizeRadius = 28; ImageView icon; // Icon of float button Drawable drawableIcon; public boolean isShow = false; float showPosition; float hidePosition; public ButtonFloat(Context context, AttributeSet attrs) { super(context, attrs); setBackgroundResource(R.drawable.background_button_float); setBackgroundColor(backgroundColor); sizeRadius = 28; setDefaultProperties(); icon = new ImageView(context); icon.setAdjustViewBounds(true); icon.setScaleType(ScaleType.CENTER_CROP); if(drawableIcon != null) { icon.setImageDrawable(drawableIcon); } LayoutParams params = new LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources())); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); icon.setLayoutParams(params); addView(icon); } protected void setDefaultProperties(){ rippleSpeed = Utils.dpToPx(2, getResources()); rippleSize = Utils.dpToPx(5, getResources()); setMinimumWidth(Utils.dpToPx(sizeRadius*2, getResources())); setMinimumHeight(Utils.dpToPx(sizeRadius*2, getResources())); super.background = R.drawable.background_button_float; // super.setDefaultProperties(); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs){ //Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } // Set Ripple Color // Color by resource int rippleColor = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "rippleColor", -1); if (rippleColor != -1) { setRippleColor(getResources().getColor(rippleColor)); } else { // Color by hexadecimal int background = attrs.getAttributeIntValue(MATERIALDESIGNXML, "rippleColor", -1); if (background != -1) setRippleColor(background); else setRippleColor(makePressColor()); } // Icon of button int iconResource = attrs.getAttributeResourceValue(MATERIALDESIGNXML,"iconDrawable",-1); if(iconResource != -1) drawableIcon = getResources().getDrawable(iconResource); final boolean animate = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"animate", false); post(new Runnable() { @Override public void run() { showPosition = ViewHelper.getY(ButtonFloat.this) - Utils.dpToPx(24, getResources()); hidePosition = ViewHelper.getY(ButtonFloat.this) + getHeight() * 3; if(animate){ ViewHelper.setY(ButtonFloat.this, hidePosition); show(); } } }); } Integer height; Integer width; @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (x != -1) { Rect src = new Rect(0, 0, getWidth(), getHeight()); Rect dst = new Rect(Utils.dpToPx(1, getResources()), Utils.dpToPx(2, getResources()), getWidth()-Utils.dpToPx(1, getResources()), getHeight()-Utils.dpToPx(2, getResources())); canvas.drawBitmap(cropCircle(makeCircle()), src, dst, null); invalidate(); } } public ImageView getIcon() { return icon; } public void setIcon(ImageView icon) { this.icon = icon; } public Drawable getDrawableIcon() { return drawableIcon; } public void setDrawableIcon(Drawable drawableIcon) { this.drawableIcon = drawableIcon; try { icon.setBackground(drawableIcon); } catch (NoSuchMethodError e) { icon.setBackgroundDrawable(drawableIcon); } } public Bitmap cropCircle(Bitmap bitmap) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, bitmap.getWidth()/2, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; } @Override public TextView getTextView() { return null; } public void setRippleColor(int rippleColor) { this.rippleColor = rippleColor; } public void show(){ ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", showPosition); animator.setInterpolator(new BounceInterpolator()); animator.setDuration(1500); animator.start(); isShow = true; } public void hide(){ ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", hidePosition); animator.setInterpolator(new BounceInterpolator()); animator.setDuration(1500); animator.start(); isShow = false; } public boolean isShow(){ return isShow; } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ButtonFloatSmall.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import android.content.Context; import android.util.AttributeSet; import android.widget.RelativeLayout; public class ButtonFloatSmall extends ButtonFloat { public ButtonFloatSmall(Context context, AttributeSet attrs) { super(context, attrs); sizeRadius = 20; sizeIcon = 20; setDefaultProperties(); LayoutParams params = new LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources())); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); icon.setLayoutParams(params); } protected void setDefaultProperties(){ rippleSpeed = Utils.dpToPx(2, getResources()); rippleSize = 10; // Min size setMinimumHeight(Utils.dpToPx(sizeRadius*2, getResources())); setMinimumWidth(Utils.dpToPx(sizeRadius*2, getResources())); // Background shape setBackgroundResource(R.drawable.background_button_float); // setBackgroundColor(backgroundColor); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ButtonIcon.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.utils.Utils; import android.R; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.util.AttributeSet; import android.view.MotionEvent; public class ButtonIcon extends ButtonFloat { public ButtonIcon(Context context, AttributeSet attrs) { super(context, attrs); try { setBackground(new ColorDrawable(getResources().getColor(R.color.transparent))); } catch (NoSuchMethodError e) { setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparent))); } rippleSpeed = Utils.dpToPx(2, getResources()); rippleSize = Utils.dpToPx(5, getResources()); } @Override public boolean onTouchEvent(MotionEvent event) { boolean returnBool = super.onTouchEvent(event); if(x != -1){ x = getWidth() / 2; y = getHeight() / 2; } return returnBool; } @Override protected void onDraw(Canvas canvas) { if (x != -1) { Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(makePressColor()); canvas.drawCircle(x, y, radius, paint); if(radius > getHeight()/rippleSize) radius += rippleSpeed; if(radius >= getWidth() / 2 - rippleSpeed){ x = -1; y = -1; radius = getHeight()/rippleSize; if(onClickListener != null && clickAfterRipple) onClickListener.onClick(this); } invalidate(); } } @Override protected int makePressColor() { return backgroundColor; } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ButtonRectangle.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Rect; import android.graphics.Typeface; import android.util.AttributeSet; import android.widget.RelativeLayout; import android.widget.TextView; public class ButtonRectangle extends Button { TextView textButton; int paddingTop,paddingBottom, paddingLeft, paddingRight; public ButtonRectangle(Context context, AttributeSet attrs) { super(context, attrs); setDefaultProperties(); } @Override protected void setDefaultProperties(){ // paddingBottom = Utils.dpToPx(16, getResources()); // paddingLeft = Utils.dpToPx(16, getResources()); // paddingRight = Utils.dpToPx(16, getResources()); // paddingTop = Utils.dpToPx(16, getResources()); super.minWidth = 80; super.minHeight = 36; super.background = R.drawable.background_button_rectangle; super.setDefaultProperties(); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs){ //Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal // Color by hexadecimal background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } // Set Padding String value = attrs.getAttributeValue(ANDROIDXML,"padding"); // if(value != null){ // float padding = Float.parseFloat(value.replace("dip", "")); // paddingBottom = Utils.dpToPx(padding, getResources()); // paddingLeft = Utils.dpToPx(padding, getResources()); // paddingRight = Utils.dpToPx(padding, getResources()); // paddingTop = Utils.dpToPx(padding, getResources()); // }else{ // value = attrs.getAttributeValue(ANDROIDXML,"paddingLeft"); // paddingLeft = (value == null) ? paddingLeft : (int) Float.parseFloat(value.replace("dip", "")); // value = attrs.getAttributeValue(ANDROIDXML,"paddingTop"); // paddingTop = (value == null) ? paddingTop : (int) Float.parseFloat(value.replace("dip", "")); // value = attrs.getAttributeValue(ANDROIDXML,"paddingRight"); // paddingRight = (value == null) ? paddingRight : (int) Float.parseFloat(value.replace("dip", "")); // value = attrs.getAttributeValue(ANDROIDXML,"paddingBottom"); // paddingBottom = (value == null) ? paddingBottom : (int) Float.parseFloat(value.replace("dip", "")); // } // Set text button String text = null; int textResource = attrs.getAttributeResourceValue(ANDROIDXML,"text",-1); if(textResource != -1){ text = getResources().getString(textResource); }else{ text = attrs.getAttributeValue(ANDROIDXML,"text"); } if(text != null){ textButton = new TextView(getContext()); textButton.setText(text); textButton.setTextColor(Color.WHITE); textButton.setTypeface(null, Typeface.BOLD); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); params.setMargins(Utils.dpToPx(5, getResources()), Utils.dpToPx(5, getResources()), Utils.dpToPx(5, getResources()), Utils.dpToPx(5, getResources())); textButton.setLayoutParams(params); addView(textButton); // FrameLayout.LayoutParams params = (LayoutParams) textView.getLayoutParams(); // params.width = getWidth(); // params.gravity = Gravity.CENTER_HORIZONTAL; //// params.setMargins(paddingLeft, paddingTop, paddingRight, paddingRight); // textView.setLayoutParams(params);textColor int textColor = attrs.getAttributeResourceValue(ANDROIDXML,"textColor",-1); if(textColor != -1){ textButton.setTextColor(textColor); }else{ // Color by hexadecimal // Color by hexadecimal textColor = attrs.getAttributeIntValue(ANDROIDXML, "textColor", -1); if (textColor != -1) textButton.setTextColor(textColor); } int[] array = {android.R.attr.textSize}; TypedArray values = getContext().obtainStyledAttributes(attrs, array); float textSize = values.getDimension(0, -1); values.recycle(); if(textSize != -1) textButton.setTextSize(textSize); } rippleSpeed = attrs.getAttributeFloatValue(MATERIALDESIGNXML, "rippleSpeed", Utils.dpToPx(6, getResources())); } // /** // * Center text in button // */ // boolean txtCenter = false; // private void centrarTexto(){ // if((textButton.getWidth()+paddingLeft+paddingRight)>Utils.dpToPx(80, getResources())) // setMinimumWidth(textButton.getWidth()+paddingLeft+paddingRight); // setMinimumHeight(textButton.getHeight()+paddingBottom+paddingTop); // textButton.setX(getWidth()/2-textButton.getWidth()/2 - paddingTop + paddingBottom); // textButton.setY(getHeight()/2-textButton.getHeight()/2 - paddingLeft + paddingRight); // txtCenter = true; // } Integer height; Integer width; @Override protected void onDraw(Canvas canvas) { // if(!txtCenter) // centrarTexto(); super.onDraw(canvas); if (x != -1) { Rect src = new Rect(0, 0, getWidth()-Utils.dpToPx(6, getResources()), getHeight()-Utils.dpToPx(7, getResources())); Rect dst = new Rect(Utils.dpToPx(6, getResources()), Utils.dpToPx(6, getResources()), getWidth()-Utils.dpToPx(6, getResources()), getHeight()-Utils.dpToPx(7, getResources())); canvas.drawBitmap(makeCircle(), src, dst, null); invalidate(); } } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/Card.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.util.Log; import android.view.Gravity; import android.view.MotionEvent; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import android.widget.RelativeLayout.LayoutParams; public class Card extends CustomView { TextView textButton; int paddingTop,paddingBottom, paddingLeft, paddingRight; int backgroundColor = Color.parseColor("#FFFFFF"); public Card(Context context, AttributeSet attrs) { super(context, attrs); setAttributes(attrs); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs){ setBackgroundResource(R.drawable.background_button_rectangle); //Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal String background = attrs.getAttributeValue(ANDROIDXML,"background"); if(background != null) setBackgroundColor(Color.parseColor(background)); else setBackgroundColor(this.backgroundColor); } } // Set color of background public void setBackgroundColor(int color){ this.backgroundColor = color; if(isEnabled()) beforeBackground = backgroundColor; LayerDrawable layer = (LayerDrawable) getBackground(); GradientDrawable shape = (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground); shape.setColor(backgroundColor); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/CheckBox.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.RelativeLayout; import android.widget.TextView; public class CheckBox extends CustomView { int backgroundColor = Color.parseColor("#4CAF50"); Check checkView; boolean press = false; boolean check = false; OnCheckListener onCheckListener; public CheckBox(Context context, AttributeSet attrs) { super(context, attrs); setAttributes(attrs); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs) { setBackgroundResource(R.drawable.background_checkbox); // Set size of view setMinimumHeight(Utils.dpToPx(48, getResources())); setMinimumWidth(Utils.dpToPx(48, getResources())); // Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1); if (bacgroundColor != -1) { setBackgroundColor(getResources().getColor(bacgroundColor)); } else { // Color by hexadecimal // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } final boolean check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "check", false); post(new Runnable() { @Override public void run() { setChecked(check); setPressed(false); changeBackgroundColor(getResources().getColor( android.R.color.transparent)); } }); checkView = new Check(getContext()); checkView.setId(View.generateViewId()); RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20, getResources()), Utils.dpToPx(20, getResources())); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); checkView.setLayoutParams(params); addView(checkView); // Adding text view to checkbox int textResource = attrs.getAttributeResourceValue(ANDROIDXML, "text", -1); String text = null; if(textResource != -1) { text = getResources().getString(textResource); } else { text = attrs.getAttributeValue(ANDROIDXML, "text"); } if(text != null) { params.removeRule(RelativeLayout.CENTER_IN_PARENT); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); TextView textView = new TextView(getContext()); RelativeLayout.LayoutParams textViewLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); textViewLayoutParams.addRule(RelativeLayout.RIGHT_OF, checkView.getId()); textViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); textViewLayoutParams.setMargins(10, 0, 0, 0); textView.setLayoutParams(textViewLayoutParams); textView.setText(text); addView(textView); } } @Override public void invalidate() { checkView.invalidate(); super.invalidate(); } @Override public boolean onTouchEvent(MotionEvent event) { invalidate(); if (isEnabled()) { isLastTouch = true; if (event.getAction() == MotionEvent.ACTION_DOWN) { changeBackgroundColor((check) ? makePressColor() : Color .parseColor("#446D6D6D")); } else if (event.getAction() == MotionEvent.ACTION_UP) { changeBackgroundColor(getResources().getColor( android.R.color.transparent)); press = false; if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) { isLastTouch = false; check = !check; if (onCheckListener != null) onCheckListener.onCheck(CheckBox.this, check); if (check) { step = 0; } if (check) checkView.changeBackground(); } } } return true; } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (press) { Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor((check) ? makePressColor() : Color .parseColor("#446D6D6D")); canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 2, paint); invalidate(); } } private void changeBackgroundColor(int color) { LayerDrawable layer = (LayerDrawable) getBackground(); GradientDrawable shape = (GradientDrawable) layer .findDrawableByLayerId(R.id.shape_bacground); shape.setColor(color); } /** * Make a dark color to press effect * * @return */ protected int makePressColor() { int r = (this.backgroundColor >> 16) & 0xFF; int g = (this.backgroundColor >> 8) & 0xFF; int b = (this.backgroundColor >> 0) & 0xFF; r = (r - 30 < 0) ? 0 : r - 30; g = (g - 30 < 0) ? 0 : g - 30; b = (b - 30 < 0) ? 0 : b - 30; return Color.argb(70, r, g, b); } @Override public void setBackgroundColor(int color) { backgroundColor = color; if (isEnabled()) beforeBackground = backgroundColor; changeBackgroundColor(color); } public void setChecked(boolean check) { invalidate(); this.check = check; setPressed(false); changeBackgroundColor(getResources().getColor( android.R.color.transparent)); if (check) { step = 0; } if (check) checkView.changeBackground(); } public boolean isCheck() { return check; } // Indicate step in check animation int step = 0; // View that contains checkbox class Check extends View { Bitmap sprite; public Check(Context context) { super(context); setBackgroundResource(R.drawable.background_checkbox_uncheck); sprite = BitmapFactory.decodeResource(context.getResources(), R.drawable.sprite_check); } public void changeBackground() { if (check) { setBackgroundResource(R.drawable.background_checkbox_check); LayerDrawable layer = (LayerDrawable) getBackground(); GradientDrawable shape = (GradientDrawable) layer .findDrawableByLayerId(R.id.shape_bacground); shape.setColor(backgroundColor); } else { setBackgroundResource(R.drawable.background_checkbox_uncheck); } } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (check) { if (step < 11){ step++; invalidate(); } } else { if (step >= 0){ step--; invalidate(); } if (step == -1){ invalidate(); changeBackground(); } } Rect src = new Rect(40 * step, 0, (40 * step) + 40, 40); Rect dst = new Rect(0, 0, this.getWidth() - 2, this.getHeight()); canvas.drawBitmap(sprite, src, dst, null); } } public void setOncheckListener(OnCheckListener onCheckListener) { this.onCheckListener = onCheckListener; } public interface OnCheckListener { public void onCheck(CheckBox view, boolean check); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/CustomView.java ================================================ package com.gc.materialdesign.views; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.util.AttributeSet; import android.widget.RelativeLayout; public class CustomView extends RelativeLayout{ final static String MATERIALDESIGNXML = "http://schemas.android.com/apk/res-auto"; final static String ANDROIDXML = "http://schemas.android.com/apk/res/android"; final int disabledBackgroundColor = Color.parseColor("#E2E2E2"); int beforeBackground; // Indicate if user touched this view the last time public boolean isLastTouch = false; public CustomView(Context context, AttributeSet attrs) { super(context, attrs); } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); if(enabled) setBackgroundColor(beforeBackground); else setBackgroundColor(disabledBackgroundColor); invalidate(); } boolean animation = false; @Override protected void onAnimationStart() { super.onAnimationStart(); animation = true; } @Override protected void onAnimationEnd() { super.onAnimationEnd(); animation = false; } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(animation) invalidate(); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/LayoutRipple.java ================================================ package com.gc.materialdesign.views; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; public class LayoutRipple extends CustomView { int background; float rippleSpeed = 10f; int rippleSize = 3; OnClickListener onClickListener; int backgroundColor = Color.parseColor("#FFFFFF"); Integer rippleColor; Float xRippleOrigin; Float yRippleOrigin; public LayoutRipple(Context context, AttributeSet attrs) { super(context, attrs); setAttributes(attrs); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs) { // Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1); if (bacgroundColor != -1) { setBackgroundColor(getResources().getColor(bacgroundColor)); } else { // Color by hexadecimal background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); else setBackgroundColor(this.backgroundColor); } // Set Ripple Color // Color by resource int rippleColor = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "rippleColor", -1); if (rippleColor != -1) { setRippleColor(getResources().getColor(rippleColor)); } else { // Color by hexadecimal int background = attrs.getAttributeIntValue(MATERIALDESIGNXML, "rippleColor", -1); if (background != -1) setRippleColor(background); else setRippleColor(makePressColor()); } rippleSpeed = attrs.getAttributeFloatValue(MATERIALDESIGNXML, "rippleSpeed", 20f); } // Set color of background public void setBackgroundColor(int color) { this.backgroundColor = color; if (isEnabled()) beforeBackground = backgroundColor; super.setBackgroundColor(color); } public void setRippleSpeed(int rippleSpeed) { this.rippleSpeed = rippleSpeed; } // ### RIPPLE EFFECT ### float x = -1, y = -1; float radius = -1; @Override public boolean onTouchEvent(MotionEvent event) { invalidate(); if (isEnabled()) { isLastTouch = true; if (event.getAction() == MotionEvent.ACTION_DOWN) { radius = getHeight() / rippleSize; x = event.getX(); y = event.getY(); } else if (event.getAction() == MotionEvent.ACTION_MOVE) { radius = getHeight() / rippleSize; x = event.getX(); y = event.getY(); if (!((event.getX() <= getWidth() && event.getX() >= 0) && (event .getY() <= getHeight() && event.getY() >= 0))) { isLastTouch = false; x = -1; y = -1; } } else if (event.getAction() == MotionEvent.ACTION_UP) { if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) { radius++; } else { isLastTouch = false; x = -1; y = -1; } }if (event.getAction() == MotionEvent.ACTION_CANCEL) { isLastTouch = false; x = -1; y = -1; } } return true; } @Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { if (!gainFocus) { x = -1; y = -1; } } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { // super.onInterceptTouchEvent(ev); return true; } public Bitmap makeCircle() { Bitmap output = Bitmap.createBitmap(getWidth(), getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); canvas.drawARGB(0, 0, 0, 0); Paint paint = new Paint(); paint.setAntiAlias(true); if (rippleColor == null) rippleColor = makePressColor(); paint.setColor(rippleColor); x = (xRippleOrigin == null) ? x : xRippleOrigin; y = (yRippleOrigin == null) ? y : yRippleOrigin; canvas.drawCircle(x, y, radius, paint); if (radius > getHeight() / rippleSize) radius += rippleSpeed; if (radius >= getWidth()) { x = -1; y = -1; radius = getHeight() / rippleSize; if (onClickListener != null) onClickListener.onClick(this); } return output; } protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (x != -1) { Rect src = new Rect(0, 0, getWidth(), getHeight()); Rect dst = new Rect(0, 0, getWidth(), getHeight()); canvas.drawBitmap(makeCircle(), src, dst, null); invalidate(); } } /** * Make a dark color to ripple effect * * @return */ protected int makePressColor() { int r = (this.backgroundColor >> 16) & 0xFF; int g = (this.backgroundColor >> 8) & 0xFF; int b = (this.backgroundColor >> 0) & 0xFF; r = (r - 30 < 0) ? 0 : r - 30; g = (g - 30 < 0) ? 0 : g - 30; b = (b - 30 < 0) ? 0 : b - 30; return Color.rgb(r, g, b); } @Override public void setOnClickListener(OnClickListener l) { onClickListener = l; } public void setRippleColor(int rippleColor) { this.rippleColor = rippleColor; } public void setxRippleOrigin(Float xRippleOrigin) { this.xRippleOrigin = xRippleOrigin; } public void setyRippleOrigin(Float yRippleOrigin) { this.yRippleOrigin = yRippleOrigin; } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ProgressBarCircularIndeterminate.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.utils.Utils; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.AttributeSet; public class ProgressBarCircularIndeterminate extends CustomView { final static String ANDROIDXML = "http://schemas.android.com/apk/res/android"; int backgroundColor = Color.parseColor("#1E88E5"); public ProgressBarCircularIndeterminate(Context context, AttributeSet attrs) { super(context, attrs); setAttributes(attrs); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs){ setMinimumHeight(Utils.dpToPx(32, getResources())); setMinimumWidth(Utils.dpToPx(32, getResources())); //Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); else setBackgroundColor(Color.parseColor("#1E88E5")); } setMinimumHeight(Utils.dpToPx(3, getResources())); } /** * Make a dark color to ripple effect * @return */ protected int makePressColor(){ int r = (this.backgroundColor >> 16) & 0xFF; int g = (this.backgroundColor >> 8) & 0xFF; int b = (this.backgroundColor >> 0) & 0xFF; // r = (r+90 > 245) ? 245 : r+90; // g = (g+90 > 245) ? 245 : g+90; // b = (b+90 > 245) ? 245 : b+90; return Color.argb(128,r, g, b); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(firstAnimationOver == false) drawFirstAnimation(canvas); if(cont > 0) drawSecondAnimation(canvas); invalidate(); } float radius1 = 0; float radius2 = 0; int cont = 0; boolean firstAnimationOver = false; /** * Draw first animation of view * @param canvas */ private void drawFirstAnimation(Canvas canvas){ if(radius1 < getWidth()/2){ Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(makePressColor()); radius1 = (radius1 >= getWidth()/2)? (float)getWidth()/2 : radius1+1; canvas.drawCircle(getWidth()/2, getHeight()/2, radius1, paint); }else{ Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); Canvas temp = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(makePressColor()); temp.drawCircle(getWidth()/2, getHeight()/2, getHeight()/2, paint); Paint transparentPaint = new Paint(); transparentPaint.setAntiAlias(true); transparentPaint.setColor(getResources().getColor(android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); if(cont >= 50){ radius2 = (radius2 >= getWidth()/2)? (float)getWidth()/2 : radius2+1; }else{ radius2 = (radius2 >= getWidth()/2-Utils.dpToPx(4, getResources()))? (float)getWidth()/2-Utils.dpToPx(4, getResources()) : radius2+1; } temp.drawCircle(getWidth()/2, getHeight()/2, radius2, transparentPaint); canvas.drawBitmap(bitmap, 0, 0, new Paint()); if(radius2 >= getWidth()/2-Utils.dpToPx(4, getResources())) cont++; if(radius2 >= getWidth()/2) firstAnimationOver = true; } } int arcD = 1; int arcO = 0; float rotateAngle = 0; int limite = 0; /** * Draw second animation of view * @param canvas */ private void drawSecondAnimation(Canvas canvas){ if(arcO == limite) arcD+=6; if(arcD >= 290 || arcO > limite){ arcO+=6; arcD-=6; } if(arcO > limite + 290){ limite = arcO; arcO = limite; arcD = 1; } rotateAngle += 4; canvas.rotate(rotateAngle,getWidth()/2, getHeight()/2); Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); Canvas temp = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(backgroundColor); // temp.drawARGB(0, 0, 0, 255); temp.drawArc(new RectF(0, 0, getWidth(), getHeight()), arcO, arcD, true, paint); Paint transparentPaint = new Paint(); transparentPaint.setAntiAlias(true); transparentPaint.setColor(getResources().getColor(android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); temp.drawCircle(getWidth()/2, getHeight()/2, (getWidth()/2)-Utils.dpToPx(4, getResources()), transparentPaint); canvas.drawBitmap(bitmap, 0, 0, new Paint()); } // Set color of background public void setBackgroundColor(int color){ super.setBackgroundColor(getResources().getColor(android.R.color.transparent)); if(isEnabled()) beforeBackground = backgroundColor; this.backgroundColor = color; } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ProgressBarDeterminate.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.view.View; import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; public class ProgressBarDeterminate extends CustomView { int max = 100; int min = 0; int progress = 0; int backgroundColor = Color.parseColor("#1E88E5"); View progressView; public ProgressBarDeterminate(Context context, AttributeSet attrs) { super(context, attrs); setAttributes(attrs); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs){ progressView = new View(getContext()); LayoutParams params = new LayoutParams(1,1); progressView.setLayoutParams(params); progressView.setBackgroundResource(R.drawable.background_progress); addView(progressView); //Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); else setBackgroundColor(Color.parseColor("#1E88E5")); } min = attrs.getAttributeIntValue(MATERIALDESIGNXML,"min", 0); max = attrs.getAttributeIntValue(MATERIALDESIGNXML,"max", 100); progress = attrs.getAttributeIntValue(MATERIALDESIGNXML,"progress", min); setMinimumHeight(Utils.dpToPx(3, getResources())); post(new Runnable() { @Override public void run() { LayoutParams params = (LayoutParams) progressView.getLayoutParams(); params.height = getHeight(); progressView.setLayoutParams(params); } }); } /** * Make a dark color to ripple effect * @return */ protected int makePressColor(){ int r = (this.backgroundColor >> 16) & 0xFF; int g = (this.backgroundColor >> 8) & 0xFF; int b = (this.backgroundColor >> 0) & 0xFF; return Color.argb(128,r, g, b); } // SETTERS @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(pendindProgress!=-1) setProgress(pendindProgress); } public void setMax(int max){ this.max = max; } public void setMin(int min){ this.min = min; } int pendindProgress = -1; public void setProgress(int progress){ if(getWidth() == 0){ pendindProgress = progress; }else{ this.progress = progress; if(progress > max) progress = max; if(progress < min) progress = min; int totalWidth = max-min; double progressPercent = (double)progress/(double)totalWidth; int progressWidth =(int) (getWidth()*progressPercent); LayoutParams params = (LayoutParams) progressView.getLayoutParams(); params.width = progressWidth; params.height = getHeight(); progressView.setLayoutParams(params); pendindProgress = -1; } } public int getProgress(){ return progress; } // Set color of background public void setBackgroundColor(int color){ this.backgroundColor = color; if(isEnabled()) beforeBackground = backgroundColor; LayerDrawable layer = (LayerDrawable) progressView.getBackground(); GradientDrawable shape = (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground); shape.setColor(color); super.setBackgroundColor(makePressColor()); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ProgressBarIndeterminate.java ================================================ package com.gc.materialdesign.views; import com.gc.materialdesign.R; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.view.ViewHelper; import android.content.Context; import android.util.AttributeSet; import android.view.animation.Animation; import android.view.animation.AnimationUtils; public class ProgressBarIndeterminate extends ProgressBarDeterminate { public ProgressBarIndeterminate(Context context, AttributeSet attrs) { super(context, attrs); post(new Runnable() { @Override public void run() { // Make progress animation setProgress(60); Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.progress_indeterminate_animation); progressView.startAnimation(anim); final ObjectAnimator anim2 = ObjectAnimator.ofFloat(progressView, "x", getWidth()); anim2.setDuration(1200); anim2.addListener(new AnimatorListener() { int cont = 1; int suma = 1; int duration = 1200; public void onAnimationEnd(Animator arg0) { // Repeat animation ViewHelper.setX(progressView,-progressView.getWidth()/2); cont += suma; try { ObjectAnimator anim2Repeat = ObjectAnimator.ofFloat(progressView, "x", getWidth()); anim2Repeat.setDuration(duration/cont); anim2Repeat.addListener(this); anim2Repeat.start(); } catch (ArrayIndexOutOfBoundsException e) { // ignore this error that sometimes comes from the NineOldAndroids 2.4 library } if(cont == 3 || cont == 1) suma *=-1; } public void onAnimationStart(Animator arg0) {} public void onAnimationRepeat(Animator arg0) {} public void onAnimationCancel(Animator arg0) {} }); anim2.start(); } }); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ProgressBarIndeterminateDeterminate.java ================================================ package com.gc.materialdesign.views; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.view.ViewHelper; import android.content.Context; import android.util.AttributeSet; public class ProgressBarIndeterminateDeterminate extends ProgressBarDeterminate { boolean firstProgress = true; boolean runAnimation = true; ObjectAnimator animation; public ProgressBarIndeterminateDeterminate(Context context, AttributeSet attrs) { super(context, attrs); post(new Runnable() { @Override public void run() { // Make progress animation setProgress(60); ViewHelper.setX(progressView,getWidth()+progressView.getWidth()/2); animation = ObjectAnimator.ofFloat(progressView, "x", -progressView.getWidth()/2); animation.setDuration(1200); animation.addListener(new AnimatorListener() { int cont = 1; int suma = 1; int duration = 1200; public void onAnimationEnd(Animator arg0) { // Repeat animation if(runAnimation){ ViewHelper.setX(progressView,getWidth()+progressView.getWidth()/2); cont += suma; animation = ObjectAnimator.ofFloat(progressView, "x", -progressView.getWidth()/2); animation.setDuration(duration/cont); animation.addListener(this); animation.start(); if(cont == 3 || cont == 1) suma *=-1; } } public void onAnimationStart(Animator arg0) {} public void onAnimationRepeat(Animator arg0) {} public void onAnimationCancel(Animator arg0) {} }); animation.start(); } }); } @Override public void setProgress(int progress) { if(firstProgress){ firstProgress = false; }else{ stopIndeterminate(); } super.setProgress(progress); } /** * Stop indeterminate animation to convert view in determinate progress bar */ private void stopIndeterminate(){ animation.cancel(); ViewHelper.setX(progressView,0); runAnimation = false; } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/ScrollView.java ================================================ package com.gc.materialdesign.views; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; public class ScrollView extends android.widget.ScrollView { /* * This class avoid problems in scrollviews with elements in library * Use it if you want use a ScrollView in your App */ public ScrollView(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onTouchEvent(MotionEvent ev) { // if(!onInterceptTouchEvent(ev)){ for(int i = 0; i < ((ViewGroup)getChildAt(0)).getChildCount(); i++){ try { CustomView child =(CustomView) ((ViewGroup)getChildAt(0)).getChildAt(i); if(child.isLastTouch){ child.onTouchEvent(ev); return true; } } catch (ClassCastException e) { } } // } return super.onTouchEvent(ev); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/Slider.java ================================================ package com.gc.materialdesign.views; import android.app.Dialog; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.os.Bundle; import android.util.AttributeSet; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.widget.RelativeLayout; import android.widget.TextView; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import com.nineoldandroids.view.ViewHelper; public class Slider extends CustomView { private int backgroundColor = Color.parseColor("#4CAF50"); private Ball ball; private Bitmap bitmap; private int max = 100; private int min = 0; private NumberIndicator numberIndicator; private OnValueChangedListener onValueChangedListener; private boolean placedBall = false; private boolean press = false; private boolean showNumberIndicator = false; private int value = 0; public Slider(Context context, AttributeSet attrs) { super(context, attrs); setAttributes(attrs); } public int getMax() { return max; } public void setMax(int max) { this.max = max; } public int getMin() { return min; } public void setMin(int min) { this.min = min; } public OnValueChangedListener getOnValueChangedListener() { return onValueChangedListener; } public void setOnValueChangedListener( OnValueChangedListener onValueChangedListener) { this.onValueChangedListener = onValueChangedListener; } // GETERS & SETTERS public int getValue() { return value; } public void setValue(final int value) { if (placedBall == false) post(new Runnable() { @Override public void run() { setValue(value); } }); else { this.value = value; float division = (ball.xFin - ball.xIni) / max; ViewHelper.setX(ball, value * division + getHeight() / 2 - ball.getWidth() / 2); ball.changeBackground(); } } @Override public void invalidate() { ball.invalidate(); super.invalidate(); } public boolean isShowNumberIndicator() { return showNumberIndicator; } public void setShowNumberIndicator(boolean showNumberIndicator) { this.showNumberIndicator = showNumberIndicator; numberIndicator = (showNumberIndicator) ? new NumberIndicator( getContext()) : null; } @Override public boolean onTouchEvent(MotionEvent event) { isLastTouch = true; if (isEnabled()) { if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { if (numberIndicator != null && numberIndicator.isShowing() == false) numberIndicator.show(); if ((event.getX() <= getWidth() && event.getX() >= 0)) { press = true; // calculate value int newValue = 0; float division = (ball.xFin - ball.xIni) / (max - min); if (event.getX() > ball.xFin) { newValue = max; } else if (event.getX() < ball.xIni) { newValue = min; } else { newValue = min + (int) ((event.getX() - ball.xIni) / division); } if (value != newValue) { value = newValue; if (onValueChangedListener != null) onValueChangedListener.onValueChanged(newValue); } // move ball indicator float x = event.getX(); x = (x < ball.xIni) ? ball.xIni : x; x = (x > ball.xFin) ? ball.xFin : x; ViewHelper.setX(ball, x); ball.changeBackground(); // If slider has number indicator if (numberIndicator != null) { // move number indicator numberIndicator.indicator.x = x; numberIndicator.indicator.finalY = Utils .getRelativeTop(this) - getHeight() / 2; numberIndicator.indicator.finalSize = getHeight() / 2; numberIndicator.numberIndicator.setText(""); } } else { press = false; isLastTouch = false; if (numberIndicator != null) numberIndicator.dismiss(); } } else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { if (numberIndicator != null) numberIndicator.dismiss(); isLastTouch = false; press = false; } } return true; } @Override public void setBackgroundColor(int color) { backgroundColor = color; if (isEnabled()) beforeBackground = backgroundColor; } /** * Make a dark color to press effect * * @return */ protected int makePressColor() { int r = (this.backgroundColor >> 16) & 0xFF; int g = (this.backgroundColor >> 8) & 0xFF; int b = (this.backgroundColor >> 0) & 0xFF; r = (r - 30 < 0) ? 0 : r - 30; g = (g - 30 < 0) ? 0 : g - 30; b = (b - 30 < 0) ? 0 : b - 30; return Color.argb(70, r, g, b); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (!placedBall) { placeBall(); } Paint paint = new Paint(); if (value == min) { // Crop line to transparent effect if (bitmap == null) { bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); } Canvas temp = new Canvas(bitmap); paint.setColor(Color.parseColor("#B0B0B0")); paint.setStrokeWidth(Utils.dpToPx(2, getResources())); temp.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint); Paint transparentPaint = new Paint(); transparentPaint.setColor(getResources().getColor( android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode( PorterDuff.Mode.CLEAR)); temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, ViewHelper.getY(ball) + ball.getHeight() / 2, ball.getWidth() / 2, transparentPaint); canvas.drawBitmap(bitmap, 0, 0, new Paint()); } else { paint.setColor(Color.parseColor("#B0B0B0")); paint.setStrokeWidth(Utils.dpToPx(2, getResources())); canvas.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint); paint.setColor(backgroundColor); float division = (ball.xFin - ball.xIni) / (max - min); int value = this.value - min; canvas.drawLine(getHeight() / 2, getHeight() / 2, value * division + getHeight() / 2, getHeight() / 2, paint); } if (press && !showNumberIndicator) { paint.setColor(backgroundColor); paint.setAntiAlias(true); canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, getHeight() / 2, getHeight() / 3, paint); } invalidate(); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs) { setBackgroundResource(R.drawable.background_transparent); // Set size of view setMinimumHeight(Utils.dpToPx(48, getResources())); setMinimumWidth(Utils.dpToPx(80, getResources())); // Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1); if (bacgroundColor != -1) { setBackgroundColor(getResources().getColor(bacgroundColor)); } else { // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } showNumberIndicator = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "showNumberIndicator", false); min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0); max = attrs.getAttributeIntValue(MATERIALDESIGNXML, "max", 0); value = attrs.getAttributeIntValue(MATERIALDESIGNXML, "value", min); ball = new Ball(getContext()); RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20, getResources()), Utils.dpToPx(20, getResources())); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); ball.setLayoutParams(params); addView(ball); // Set if slider content number indicator // TODO if (showNumberIndicator) { numberIndicator = new NumberIndicator(getContext()); } } private void placeBall() { ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2); ball.xIni = ViewHelper.getX(ball); ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2; ball.xCen = getWidth() / 2 - ball.getWidth() / 2; placedBall = true; } // Event when slider change value public interface OnValueChangedListener { public void onValueChanged(int value); } class Ball extends View { float xIni, xFin, xCen; public Ball(Context context) { super(context); setBackgroundResource(R.drawable.background_switch_ball_uncheck); } public void changeBackground() { if (value != min) { setBackgroundResource(R.drawable.background_checkbox); LayerDrawable layer = (LayerDrawable) getBackground(); GradientDrawable shape = (GradientDrawable) layer .findDrawableByLayerId(R.id.shape_bacground); shape.setColor(backgroundColor); } else { setBackgroundResource(R.drawable.background_switch_ball_uncheck); } } } // Slider Number Indicator class Indicator extends RelativeLayout { boolean animate = true; // Final size after animation float finalSize = 0; // Final y position after animation float finalY = 0; boolean numberIndicatorResize = false; // Size of number indicator float size = 0; // Position of number indicator float x = 0; float y = 0; public Indicator(Context context) { super(context); setBackgroundColor(getResources().getColor( android.R.color.transparent)); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (numberIndicatorResize == false) { LayoutParams params = (LayoutParams) numberIndicator.numberIndicator .getLayoutParams(); params.height = (int) finalSize * 2; params.width = (int) finalSize * 2; numberIndicator.numberIndicator.setLayoutParams(params); } Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(backgroundColor); if (animate) { if (y == 0) y = finalY + finalSize * 2; y -= Utils.dpToPx(6, getResources()); size += Utils.dpToPx(2, getResources()); } canvas.drawCircle( ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent()) + ball.getWidth() / 2, y, size, paint); if (animate && size >= finalSize) animate = false; if (animate == false) { ViewHelper .setX(numberIndicator.numberIndicator, (ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball .getParent()) + ball.getWidth() / 2) - size); ViewHelper.setY(numberIndicator.numberIndicator, y - size); numberIndicator.numberIndicator.setText(value + ""); } invalidate(); } } class NumberIndicator extends Dialog { Indicator indicator; TextView numberIndicator; public NumberIndicator(Context context) { super(context, android.R.style.Theme_Translucent); } @Override public void dismiss() { super.dismiss(); indicator.y = 0; indicator.size = 0; indicator.animate = true; } @Override public void onBackPressed() { } @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.number_indicator_spinner); setCanceledOnTouchOutside(false); RelativeLayout content = (RelativeLayout) this .findViewById(R.id.number_indicator_spinner_content); indicator = new Indicator(this.getContext()); content.addView(indicator); numberIndicator = new TextView(getContext()); numberIndicator.setTextColor(Color.WHITE); numberIndicator.setGravity(Gravity.CENTER); content.addView(numberIndicator); indicator.setLayoutParams(new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT)); } } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/views/Switch.java ================================================ package com.gc.materialdesign.views; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.RelativeLayout; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.view.ViewHelper; public class Switch extends CustomView { private int backgroundColor = Color.parseColor("#4CAF50"); private Ball ball; private boolean check = false; private boolean eventCheck = false; private boolean press = false; private OnCheckListener onCheckListener; private Bitmap bitmap; public Switch(Context context, AttributeSet attrs) { super(context, attrs); setAttributes(attrs); setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (check) setChecked(false); else setChecked(true); } }); } // Set atributtes of XML to View protected void setAttributes(AttributeSet attrs) { setBackgroundResource(R.drawable.background_transparent); // Set size of view setMinimumHeight(Utils.dpToPx(48, getResources())); setMinimumWidth(Utils.dpToPx(80, getResources())); // Set background Color // Color by resource int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1); if (bacgroundColor != -1) { setBackgroundColor(getResources().getColor(bacgroundColor)); } else { // Color by hexadecimal int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "check", false); eventCheck = check; ball = new Ball(getContext()); RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20, getResources()), Utils.dpToPx(20, getResources())); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); ball.setLayoutParams(params); addView(ball); } @Override public boolean onTouchEvent(MotionEvent event) { if (isEnabled()) { isLastTouch = true; if (event.getAction() == MotionEvent.ACTION_DOWN) { press = true; } else if (event.getAction() == MotionEvent.ACTION_MOVE) { float x = event.getX(); x = (x < ball.xIni) ? ball.xIni : x; x = (x > ball.xFin) ? ball.xFin : x; if (x > ball.xCen) { eventCheck = true; } else { eventCheck = false; } ViewHelper.setX(ball, x); ball.changeBackground(); if ((event.getX() <= getWidth() && event.getX() >= 0)) { isLastTouch = false; press = false; } } else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { press = false; isLastTouch = false; if (eventCheck != check) { check = eventCheck; if (onCheckListener != null) onCheckListener.onCheck(Switch.this,check); } if ((event.getX() <= getWidth() && event.getX() >= 0)) { ball.animateCheck(); } } } return true; } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (!placedBall) { placeBall(); } // Crop line to transparent effect if(null == bitmap) { bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); } Canvas temp = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor((eventCheck) ? backgroundColor : Color.parseColor("#B0B0B0")); paint.setStrokeWidth(Utils.dpToPx(2, getResources())); temp.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint); Paint transparentPaint = new Paint(); transparentPaint.setAntiAlias(true); transparentPaint.setColor(getResources().getColor( android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode( PorterDuff.Mode.CLEAR)); temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, ViewHelper.getY(ball) + ball.getHeight() / 2, ball.getWidth() / 2, transparentPaint); canvas.drawBitmap(bitmap, 0, 0, new Paint()); if (press) { paint.setColor((check) ? makePressColor() : Color .parseColor("#446D6D6D")); canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, getHeight() / 2, getHeight() / 2, paint); } invalidate(); } /** * Make a dark color to press effect * * @return */ protected int makePressColor() { int r = (this.backgroundColor >> 16) & 0xFF; int g = (this.backgroundColor >> 8) & 0xFF; int b = (this.backgroundColor >> 0) & 0xFF; r = (r - 30 < 0) ? 0 : r - 30; g = (g - 30 < 0) ? 0 : g - 30; b = (b - 30 < 0) ? 0 : b - 30; return Color.argb(70, r, g, b); } // Move ball to first position in view boolean placedBall = false; private void placeBall() { ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2); ball.xIni = ViewHelper.getX(ball); ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2; ball.xCen = getWidth() / 2 - ball.getWidth() / 2; placedBall = true; ball.animateCheck(); } // SETTERS @Override public void setBackgroundColor(int color) { backgroundColor = color; if (isEnabled()) beforeBackground = backgroundColor; } public void setChecked(boolean check) { invalidate(); this.check = check; this.eventCheck = check; ball.animateCheck(); } public boolean isCheck() { return check; } class Ball extends View { float xIni, xFin, xCen; public Ball(Context context) { super(context); setBackgroundResource(R.drawable.background_switch_ball_uncheck); } public void changeBackground() { if (eventCheck) { setBackgroundResource(R.drawable.background_checkbox); LayerDrawable layer = (LayerDrawable) getBackground(); GradientDrawable shape = (GradientDrawable) layer .findDrawableByLayerId(R.id.shape_bacground); shape.setColor(backgroundColor); } else { setBackgroundResource(R.drawable.background_switch_ball_uncheck); } } public void animateCheck() { changeBackground(); ObjectAnimator objectAnimator; if (eventCheck) { objectAnimator = ObjectAnimator.ofFloat(this, "x", ball.xFin); } else { objectAnimator = ObjectAnimator.ofFloat(this, "x", ball.xIni); } objectAnimator.setDuration(300); objectAnimator.start(); } } public void setOncheckListener(OnCheckListener onCheckListener) { this.onCheckListener = onCheckListener; } public interface OnCheckListener { public void onCheck(Switch view, boolean check); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/widgets/ColorSelector.java ================================================ package com.gc.materialdesign.widgets; import com.gc.materialdesign.R; import com.gc.materialdesign.views.Slider; import com.gc.materialdesign.views.Slider.OnValueChangedListener; import android.content.Context; import android.content.DialogInterface; import android.graphics.Color; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.view.View.OnTouchListener; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.Animation.AnimationListener; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.RelativeLayout; public class ColorSelector extends android.app.Dialog implements OnValueChangedListener{ int color = Color.BLACK; Context context; View colorView; View view, backView;//background OnColorSelectedListener onColorSelectedListener; Slider red, green, blue; public ColorSelector(Context context,Integer color, OnColorSelectedListener onColorSelectedListener) { super(context, android.R.style.Theme_Translucent); this.context = context; this.onColorSelectedListener = onColorSelectedListener; if(color != null) this.color = color; setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if(ColorSelector.this.onColorSelectedListener != null) ColorSelector.this.onColorSelectedListener.onColorSelected(ColorSelector.this.color); } }); } @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.color_selector); view = (LinearLayout)findViewById(R.id.contentSelector); backView = (RelativeLayout)findViewById(R.id.rootSelector); backView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getX() < view.getLeft() || event.getX() >view.getRight() || event.getY() > view.getBottom() || event.getY() < view.getTop()) { dismiss(); } return false; } }); colorView = findViewById(R.id.viewColor); colorView.setBackgroundColor(color); // Resize ColorView colorView.post(new Runnable() { @Override public void run() { LayoutParams params = (LayoutParams) colorView.getLayoutParams(); params.height = colorView.getWidth(); colorView.setLayoutParams(params); } }); // Configure Sliders red = (Slider) findViewById(R.id.red); green = (Slider) findViewById(R.id.green); blue = (Slider) findViewById(R.id.blue); int r = (this.color >> 16) & 0xFF; int g = (this.color >> 8) & 0xFF; int b = (this.color >> 0) & 0xFF; red.setValue(r); green.setValue(g); blue.setValue(b); red.setOnValueChangedListener(this); green.setOnValueChangedListener(this); blue.setOnValueChangedListener(this); } @Override public void show() { super.show(); view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination)); backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin)); } @Override public void onValueChanged(int value) { color = Color.rgb(red.getValue(), green.getValue(), blue.getValue()); colorView.setBackgroundColor(color); } // Event that execute when color selector is closed public interface OnColorSelectedListener{ public void onColorSelected(int color); } @Override public void dismiss() { Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.post(new Runnable() { @Override public void run() { ColorSelector.super.dismiss(); } }); } }); Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin); view.startAnimation(anim); backView.startAnimation(backAnim); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/widgets/Dialog.java ================================================ package com.gc.materialdesign.widgets; import android.content.Context; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.Window; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.RelativeLayout; import android.widget.TextView; import com.gc.materialdesign.R; import com.gc.materialdesign.views.ButtonFlat; public class Dialog extends android.app.Dialog{ Context context; View view; View backView; String message; TextView messageTextView; String title; TextView titleTextView; ButtonFlat buttonAccept; ButtonFlat buttonCancel; String buttonCancelText; View.OnClickListener onAcceptButtonClickListener; View.OnClickListener onCancelButtonClickListener; public Dialog(Context context,String title, String message) { super(context, android.R.style.Theme_Translucent); this.context = context;// init Context this.message = message; this.title = title; } public void addCancelButton(String buttonCancelText){ this.buttonCancelText = buttonCancelText; } public void addCancelButton(String buttonCancelText, View.OnClickListener onCancelButtonClickListener){ this.buttonCancelText = buttonCancelText; this.onCancelButtonClickListener = onCancelButtonClickListener; } @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.dialog); view = (RelativeLayout)findViewById(R.id.contentDialog); backView = (RelativeLayout)findViewById(R.id.dialog_rootView); backView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getX() < view.getLeft() || event.getX() >view.getRight() || event.getY() > view.getBottom() || event.getY() < view.getTop()) { dismiss(); } return false; } }); this.titleTextView = (TextView) findViewById(R.id.title); setTitle(title); this.messageTextView = (TextView) findViewById(R.id.message); setMessage(message); this.buttonAccept = (ButtonFlat) findViewById(R.id.button_accept); buttonAccept.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); if(onAcceptButtonClickListener != null) onAcceptButtonClickListener.onClick(v); } }); if(buttonCancelText != null){ this.buttonCancel = (ButtonFlat) findViewById(R.id.button_cancel); this.buttonCancel.setVisibility(View.VISIBLE); this.buttonCancel.setText(buttonCancelText); buttonCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); if(onCancelButtonClickListener != null) onCancelButtonClickListener.onClick(v); } }); } } @Override public void show() { // TODO 自动生成的方法存根 super.show(); // set dialog enter animations view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination)); backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin)); } // GETERS & SETTERS public String getMessage() { return message; } public void setMessage(String message) { this.message = message; messageTextView.setText(message); } public TextView getMessageTextView() { return messageTextView; } public void setMessageTextView(TextView messageTextView) { this.messageTextView = messageTextView; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; if(title == null) titleTextView.setVisibility(View.GONE); else{ titleTextView.setVisibility(View.VISIBLE); titleTextView.setText(title); } } public TextView getTitleTextView() { return titleTextView; } public void setTitleTextView(TextView titleTextView) { this.titleTextView = titleTextView; } public ButtonFlat getButtonAccept() { return buttonAccept; } public void setButtonAccept(ButtonFlat buttonAccept) { this.buttonAccept = buttonAccept; } public ButtonFlat getButtonCancel() { return buttonCancel; } public void setButtonCancel(ButtonFlat buttonCancel) { this.buttonCancel = buttonCancel; } public void setOnAcceptButtonClickListener( View.OnClickListener onAcceptButtonClickListener) { this.onAcceptButtonClickListener = onAcceptButtonClickListener; if(buttonAccept != null) buttonAccept.setOnClickListener(onAcceptButtonClickListener); } public void setOnCancelButtonClickListener( View.OnClickListener onCancelButtonClickListener) { this.onCancelButtonClickListener = onCancelButtonClickListener; if(buttonCancel != null) buttonCancel.setOnClickListener(onCancelButtonClickListener); } @Override public void dismiss() { Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.post(new Runnable() { @Override public void run() { Dialog.super.dismiss(); } }); } }); Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin); view.startAnimation(anim); backView.startAnimation(backAnim); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/widgets/ProgressDialog.java ================================================ package com.gc.materialdesign.widgets; import android.content.Context; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.Window; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.RelativeLayout; import android.widget.TextView; import com.gc.materialdesign.R; import com.gc.materialdesign.views.ButtonFlat; import com.gc.materialdesign.views.ProgressBarCircularIndeterminate; public class ProgressDialog extends android.app.Dialog{ Context context; View view; View backView; String title; TextView titleTextView; int progressColor = -1; public ProgressDialog(Context context,String title) { super(context, android.R.style.Theme_Translucent); this.title = title; this.context = context; } public ProgressDialog(Context context,String title, int progressColor) { super(context, android.R.style.Theme_Translucent); this.title = title; this.progressColor = progressColor; this.context = context; } @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.progress_dialog); view = (RelativeLayout)findViewById(R.id.contentDialog); backView = (RelativeLayout)findViewById(R.id.dialog_rootView); backView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getX() < view.getLeft() || event.getX() >view.getRight() || event.getY() > view.getBottom() || event.getY() < view.getTop()) { dismiss(); } return false; } }); this.titleTextView = (TextView) findViewById(R.id.title); setTitle(title); if(progressColor != -1){ ProgressBarCircularIndeterminate progressBarCircularIndeterminate = (ProgressBarCircularIndeterminate) findViewById(R.id.progressBarCircularIndetermininate); progressBarCircularIndeterminate.setBackgroundColor(progressColor); } } @Override public void show() { // TODO 自动生成的方法存根 super.show(); // set dialog enter animations view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination)); backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin)); } // GETERS & SETTERS public String getTitle() { return title; } public void setTitle(String title) { this.title = title; if(title == null) titleTextView.setVisibility(View.GONE); else{ titleTextView.setVisibility(View.VISIBLE); titleTextView.setText(title); } } public TextView getTitleTextView() { return titleTextView; } public void setTitleTextView(TextView titleTextView) { this.titleTextView = titleTextView; } @Override public void dismiss() { Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.post(new Runnable() { @Override public void run() { ProgressDialog.super.dismiss(); } }); } }); Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin); view.startAnimation(anim); backView.startAnimation(backAnim); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/java/com/gc/materialdesign/widgets/SnackBar.java ================================================ package com.gc.materialdesign.widgets; import android.app.Activity; import android.app.Dialog; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.TextView; import com.gc.materialdesign.R; import com.gc.materialdesign.views.ButtonFlat; public class SnackBar extends Dialog{ String text; float textSize = 14;//Roboto Regular 14sp String buttonText; View.OnClickListener onClickListener; Activity activity; View view; ButtonFlat button; int backgroundSnackBar = Color.parseColor("#333333"); int backgroundButton = Color.parseColor("#1E88E5"); OnHideListener onHideListener; // Timer private boolean mIndeterminate = false; private int mTimer = 3 * 1000; // With action button public SnackBar(Activity activity, String text, String buttonText, View.OnClickListener onClickListener) { super(activity, android.R.style.Theme_Translucent); this.activity = activity; this.text = text; this.buttonText = buttonText; this.onClickListener = onClickListener; } // Only text public SnackBar(Activity activity, String text) { super(activity, android.R.style.Theme_Translucent); this.activity = activity; this.text = text; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.snackbar); setCanceledOnTouchOutside(false); ((TextView)findViewById(R.id.text)).setText(text); ((TextView)findViewById(R.id.text)).setTextSize(textSize); //set textSize button = (ButtonFlat) findViewById(R.id.buttonflat); if(text == null || onClickListener == null){ button.setVisibility(View.GONE); }else{ button.setText(buttonText); button.setBackgroundColor(backgroundButton); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); onClickListener.onClick(v); } }); } view = findViewById(R.id.snackbar); view.setBackgroundColor(backgroundSnackBar); } @Override public boolean onTouchEvent(MotionEvent event) { return activity.dispatchTouchEvent(event); } @Override public void onBackPressed() { } @Override public void show() { super.show(); view.setVisibility(View.VISIBLE); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.snackbar_show_animation)); if (!mIndeterminate) { dismissTimer.start(); } } // Dismiss timer Thread dismissTimer = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(mTimer); } catch (InterruptedException e) { e.printStackTrace(); } handler.sendMessage(new Message()); } }); Handler handler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { if(onHideListener != null) { onHideListener.onHide(); } dismiss(); return false; } }); /** * @author Jack Tony */ @Override public void dismiss() { Animation anim = AnimationUtils.loadAnimation(activity, R.anim.snackbar_hide_animation); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { SnackBar.super.dismiss(); } }); view.startAnimation(anim); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO 自动生成的方法存根 if (keyCode == KeyEvent.KEYCODE_BACK ) { dismiss(); } return super.onKeyDown(keyCode, event); } public void setMessageTextSize(float size) { textSize = size; } public void setIndeterminate(boolean indeterminate) { mIndeterminate = indeterminate; } public boolean isIndeterminate() { return mIndeterminate; } public void setDismissTimer(int time) { mTimer = time; } public int getDismissTimer() { return mTimer; } /** * Change background color of SnackBar * @param color */ public void setBackgroundSnackBar(int color){ backgroundSnackBar = color; if(view != null) view.setBackgroundColor(color); } /** * Chage color of FlatButton in Snackbar * @param color */ public void setColorButton(int color){ backgroundButton = color; if(button != null) button.setBackgroundColor(color); } /** * This event start when snackbar dismish without push the button * @author Navas * */ public interface OnHideListener{ public void onHide(); } public void setOnhideListener(OnHideListener onHideListener){ this.onHideListener = onHideListener; } } ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/anim/dialog_main_hide_amination.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/anim/dialog_main_show_amination.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/anim/dialog_root_hide_amin.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/anim/dialog_root_show_amin.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/anim/progress_indeterminate_animation.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/anim/snackbar_hide_animation.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/anim/snackbar_show_animation.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/background_button_float.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/background_button_rectangle.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/background_checkbox.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/background_checkbox_check.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/background_checkbox_uncheck.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/background_progress.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/background_switch_ball_uncheck.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/background_transparent.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/shadow_down.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/drawable/shadow_right.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/layout/color_selector.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/layout/dialog.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/layout/number_indicator_spinner.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/layout/progress_dialog.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/layout/snackbar.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/values/attributes.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/values/colors.xml ================================================ #00FF00 #66aaaaaa ================================================ FILE: MaterialDesignLibrary/MaterialDesign/src/main/res/values/strings.xml ================================================ MaterialDesign ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/.gitignore ================================================ /build ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/build.gradle ================================================ apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "com.gc.materialdesigndemo" minSdkVersion 16 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile project(':MaterialDesign') } ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Applications/adt-bundle-mac-x86_64-20140321/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/androidTest/java/com/gc/materialdesigndemo/ApplicationTest.java ================================================ package com.gc.materialdesigndemo; import android.app.Application; import android.test.ApplicationTestCase; /** * Testing Fundamentals */ public class ApplicationTest extends ApplicationTestCase { public ApplicationTest() { super(Application.class); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/AndroidManifest.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/java/com/gc/materialdesigndemo/ui/ButtonsActivity.java ================================================ package com.gc.materialdesigndemo.ui; import android.annotation.SuppressLint; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.Window; import com.gc.materialdesigndemo.R; public class ButtonsActivity extends Activity { int backgroundColor = Color.parseColor("#1E88E5"); @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_buttons); int color = getIntent().getIntExtra("BACKGROUND", Color.BLACK); findViewById(R.id.buttonflat).setBackgroundColor(color); findViewById(R.id.button).setBackgroundColor(color); findViewById(R.id.buttonFloatSmall).setBackgroundColor(color); findViewById(R.id.buttonIcon).setBackgroundColor(color); findViewById(R.id.buttonFloat).setBackgroundColor(color); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/java/com/gc/materialdesigndemo/ui/MainActivity.java ================================================ package com.gc.materialdesigndemo.ui; import com.gc.materialdesign.views.ButtonFloatSmall; import com.gc.materialdesign.views.LayoutRipple; import com.gc.materialdesign.widgets.ColorSelector; import com.gc.materialdesign.widgets.ColorSelector.OnColorSelectedListener; import com.gc.materialdesigndemo.R; import com.nineoldandroids.view.ViewHelper; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.View.OnClickListener; public class MainActivity extends Activity implements OnColorSelectedListener{ int backgroundColor = Color.parseColor("#1E88E5"); ButtonFloatSmall buttonSelectColor; @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonSelectColor = (ButtonFloatSmall) findViewById(R.id.buttonColorSelector); buttonSelectColor.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { ColorSelector colorSelector = new ColorSelector(MainActivity.this, backgroundColor, MainActivity.this); colorSelector.show(); } }); LayoutRipple layoutRipple = (LayoutRipple) findViewById(R.id.itemButtons); setOriginRiple(layoutRipple); layoutRipple.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(MainActivity.this,ButtonsActivity.class); intent.putExtra("BACKGROUND", backgroundColor); startActivity(intent); } }); layoutRipple = (LayoutRipple) findViewById(R.id.itemSwitches); setOriginRiple(layoutRipple); layoutRipple.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(MainActivity.this,SwitchActivity.class); intent.putExtra("BACKGROUND", backgroundColor); startActivity(intent); } }); layoutRipple = (LayoutRipple) findViewById(R.id.itemProgress); setOriginRiple(layoutRipple); layoutRipple.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(MainActivity.this,ProgressActivity.class); intent.putExtra("BACKGROUND", backgroundColor); startActivity(intent); } }); layoutRipple = (LayoutRipple) findViewById(R.id.itemWidgets); setOriginRiple(layoutRipple); layoutRipple.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(MainActivity.this,WidgetActivity.class); intent.putExtra("BACKGROUND", backgroundColor); startActivity(intent); } }); } private void setOriginRiple(final LayoutRipple layoutRipple){ layoutRipple.post(new Runnable() { @Override public void run() { View v = layoutRipple.getChildAt(0); layoutRipple.setxRippleOrigin(ViewHelper.getX(v)+v.getWidth()/2); layoutRipple.setyRippleOrigin(ViewHelper.getY(v)+v.getHeight()/2); layoutRipple.setRippleColor(Color.parseColor("#1E88E5")); layoutRipple.setRippleSpeed(30); } }); } @Override public void onColorSelected(int color) { backgroundColor = color; buttonSelectColor.setBackgroundColor(color); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/java/com/gc/materialdesigndemo/ui/ProgressActivity.java ================================================ package com.gc.materialdesigndemo.ui; import android.annotation.SuppressLint; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.Window; import com.gc.materialdesign.views.ProgressBarDeterminate; import com.gc.materialdesign.views.ProgressBarIndeterminateDeterminate; import com.gc.materialdesigndemo.R; public class ProgressActivity extends Activity { int backgroundColor = Color.parseColor("#1E88E5"); @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_progress); int color = getIntent().getIntExtra("BACKGROUND", Color.BLACK); findViewById(R.id.progressBarCircularIndetermininate).setBackgroundColor(color); findViewById(R.id.progressBarIndeterminate).setBackgroundColor(color); findViewById(R.id.progressBarIndeterminateDeterminate).setBackgroundColor(color); findViewById(R.id.progressDeterminate).setBackgroundColor(color); findViewById(R.id.slider).setBackgroundColor(color); findViewById(R.id.sliderNumber).setBackgroundColor(color); progreesBarDeterminate = (ProgressBarDeterminate) findViewById(R.id.progressDeterminate); progressTimer.start(); progressBarIndeterminateDeterminate = (ProgressBarIndeterminateDeterminate) findViewById(R.id.progressBarIndeterminateDeterminate); progressTimer2.start(); } ProgressBarDeterminate progreesBarDeterminate; Thread progressTimer = new Thread(new Runnable() { @Override public void run() { for(int i = 0; i <= 100; i++){ try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } handler.sendMessage(new Message()); } } }); Handler handler = new Handler(new Handler.Callback() { int progress = 0; @Override public boolean handleMessage(Message msg) { progreesBarDeterminate.setProgress(progress++); return false; } }); ProgressBarIndeterminateDeterminate progressBarIndeterminateDeterminate; Thread progressTimer2 = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(4000); for(int i = 0; i <= 100; i++){ Thread.sleep(100); handler2.sendMessage(new Message()); } } catch (InterruptedException e) { e.printStackTrace(); } } }); Handler handler2 = new Handler(new Handler.Callback() { int progress = 0; @Override public boolean handleMessage(Message msg) { progressBarIndeterminateDeterminate.setProgress(progress++); return false; } }); } ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/java/com/gc/materialdesigndemo/ui/SwitchActivity.java ================================================ package com.gc.materialdesigndemo.ui; import android.annotation.SuppressLint; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.Window; import com.gc.materialdesigndemo.R; public class SwitchActivity extends Activity { int backgroundColor = Color.parseColor("#1E88E5"); @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_switchs); int color = getIntent().getIntExtra("BACKGROUND", Color.BLACK); findViewById(R.id.checkBox).setBackgroundColor(color); findViewById(R.id.switchView).setBackgroundColor(color); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/java/com/gc/materialdesigndemo/ui/WidgetActivity.java ================================================ package com.gc.materialdesigndemo.ui; import com.gc.materialdesign.views.ButtonFlat; import com.gc.materialdesign.widgets.ColorSelector; import com.gc.materialdesign.widgets.Dialog; import com.gc.materialdesign.widgets.SnackBar; import com.gc.materialdesigndemo.R; import android.annotation.SuppressLint; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.View.OnClickListener; import android.widget.Toast; public class WidgetActivity extends Activity { private int backgroundColor = Color.parseColor("#1E88E5"); @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_widgets); // SHOW SNACKBAR findViewById(R.id.buttonSnackBar).setOnClickListener(new OnClickListener() { @Override public void onClick(final View flatButton) { new SnackBar(WidgetActivity.this, "Do you want change color of this button to red?", "yes", new OnClickListener() { @Override public void onClick(View v) { ButtonFlat btn = (ButtonFlat) findViewById(R.id.buttonSnackBar); btn.setTextColor(Color.RED); } }).show(); } }); // SHOW DiALOG findViewById(R.id.buttonDialog).setOnClickListener(new OnClickListener() { @Override public void onClick(final View flatButton) { Dialog dialog = new Dialog(WidgetActivity.this, "Title", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam"); dialog.setOnAcceptButtonClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(WidgetActivity.this, "Click accept button", 1).show(); } }); dialog.setOnCancelButtonClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(WidgetActivity.this, "Click cancel button", 1).show(); } }); dialog.show(); } }); // SHOW COLOR SEECTOR findViewById(R.id.buttonColorSelector).setOnClickListener(new OnClickListener() { @Override public void onClick(final View flatButton) { new ColorSelector(WidgetActivity.this, Color.RED, null).show(); } }); } } ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/drawable/blue_background.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/drawable/selector_list.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/drawable/transparent_backgrouns.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/layout/activity_buttons.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/layout/activity_main.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/layout/activity_progress.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/layout/activity_switchs.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/layout/activity_widgets.xml ================================================ ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/values/strings.xml ================================================ MaterialDesignDemo ================================================ FILE: MaterialDesignLibrary/MaterialDesignDemo/src/main/res/values/styles.xml ================================================ ================================================ FILE: MaterialDesignLibrary/build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.+' // COMMENT TO DEVELOPER MODE / UNCOMMENT TO UPLOAD TO BINTARRAY // classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5' // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' // classpath 'com.github.dcendents:android-maven-plugin:1.2' } } allprojects { repositories { jcenter() mavenCentral() } group = "com.github.navasmdc" version = "1.5" } ================================================ FILE: MaterialDesignLibrary/gradle/wrapper/gradle-wrapper.properties ================================================ #Sat Aug 22 18:02:59 CEST 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip ================================================ FILE: MaterialDesignLibrary/gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Settings specified in this file will override any Gradle settings # configured through the IDE. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true VERSION_NAME=1.4 VERSION_CODE=6 GROUP=com.github.navasmdc POM_DESCRIPTION=This is a library with components of Android L to you use in android 2.2 POM_URL=https://github.com/navasmdc/MaterialDesignLibrary POM_SCM_URL=https://github.com/navasmdc/MaterialDesignLibrary POM_SCM_CONNECTION=scm:git@github.com:navasmdc/MaterialDesignLibrary.git POM_SCM_DEV_CONNECTION=scm:git@github.com:navasmdc/MaterialDesignLibrary.git POM_LICENCE_NAME=The Apache Software License, Version 2.0 POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo POM_DEVELOPER_ID=navasmdc POM_DEVELOPER_NAME=Ivan Navas ================================================ FILE: MaterialDesignLibrary/gradlew ================================================ #!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn ( ) { echo "$*" } die ( ) { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # For Cygwin, ensure paths are in UNIX format before anything is touched. if $cygwin ; then [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` fi # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >&- APP_HOME="`pwd -P`" cd "$SAVED" >&- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" ================================================ FILE: MaterialDesignLibrary/gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windowz variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* goto execute :4NT_args @rem Get arguments from the 4NT Shell from JP Software set CMD_LINE_ARGS=%$ :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: MaterialDesignLibrary/settings.gradle ================================================ // DEVELOPER MODE include ':MaterialDesignDemo', ':MaterialDesign' // UPLOAd LIBRARY TO BINTARRAY //include ':MaterialDesign' ================================================ FILE: README.md ================================================ ![Material design library logo](images/logo.png) # Material Design Android Library Android app on Google Play [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Material%20Design%20Android%20Library-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1156) * [How to use](#howtouse) * [Components](#components) * [Buttons](#buttons) * [Flat Button](#flat-button) * [Rectangle Button](#rectangle-button) * [Float Button](#float-button) * [Float small button](#float-small-button) * [Switches](#switches) * [CheckBox](#checkbox) * [Switch](#switch) * [Progress indicators](#progress-indicators) * [Progress bar circular indeterminate](#progress-bar-circula-rindeterminate) * [Progress bar indeterminate](#progress-bar-indeterminate) * [Progress bar indeterminate determinate](#progress-bar-indeterminate-determinate) * [Progress bar determinate](#progress-bar-determinate) * [Slider](#slider) * [Slider with number indicator](#slider-with-number-indicator) * [Widgets](#widgets) * [SnackBar](#snackbar) * [Dialog](#dialog) * [Color selector](#color-selector) ## How to use If you want use this library, you only have to download MaterialDesign project, import it into your workspace and add the project as a library in your android project settings. If you prefer it, you can use the gradle dependency, you have to add these lines in your build.gradle file: ```xml repositories { jcenter() } dependencies { compile 'com.github.navasmdc:MaterialDesign:1.5@aar' } ``` Some components have custom attributes, if you want use them, you must add this line in your xml file in the first component: ```xml ``` >If you are going to use a ScrollView, it is recommended that you use the CustomScrollView provided in this library to avoid problems with the custom components. >To use this component: >```xml > xmlns:android="http://schemas.android.com/apk/res/android" > xmlns:materialdesign="http://schemas.android.com/apk/res-auto" > android:id="@+id/scroll" > android:layout_width="match_parent" > android:layout_height="match_parent"> > >``` ##Components ####Buttons ######Flat Button ![flat button](images/flat_button.png) ```xml ``` ######Rectangle Button ![rectangle button](images/rectangle_button.png) ```xml ``` ######Float Button ![float button](images/float_button.png) >It is recommended to put this component in the right-bottom of the screen. To use this component write this code in your xml file. >If you don`t want to start this component with animation set the animate attribute to false. >Put your icon in the icon attribute to set the drawable icon for this component. ```xml ``` ######Float small button ![float small button](images/float_small_button.png) ```xml ``` ####Switches ######CheckBox ![checkbox](images/checkbox.png) ```xml ``` ######Switch ![switch](images/switch.png) ```xml ``` ####Progress indicators ######Progress bar circular indeterminate ![progress bar circular indeterminate](images/progress_bar_circular_indeterminate.png) ```xml ``` ######Progress bar indeterminate ![progress bar indeterminate](images/progress_bar_indeterminate.png) ```xml ``` ######Progress bar indeterminate determinate ![Progress bar indeterminate determinate](images/progress_bar_indeterminate_determinate.png) ```xml ``` >If you begin progrees, you only have to set progress it > >```java >progressBarIndeterminateDeterminate.setProgress(progress); >``` ######Progress bar determinate ![Progress bar determinate](images/progress_bar_determinate.png) ```xml ``` >You can custom max and min progress values with `materialdesign:max="50"` and `materialdesign:min="25"` attributes. ######Slider ![Slider](images/slider.png) ```xml ``` ######Slider with number indicator ![Slider with number indicator](images/slider_with_number_indicator.png) ```xml ``` ##Widgets ####SnackBar ![Snackbar](images/snackbar.png) ```java SnackBar snackbar = new SnackBar(Activity activity, String text, String buttonText, View.OnClickListener onClickListener); snackbar.show(); ``` > If you don't want to show the button, put `null` in `buttonText` attribute ####Dialog ![Dialog](images/dialog.png) ```java Dialog dialog = new Dialog(Context context,String title, String message); dialog.show(); ``` >You can set the accept and cancel button on the event listener or change it's text >```java > // Set accept click listenner >dialog.setOnAcceptButtonClickListener(View.OnClickListener onAcceptButtonClickListener); > // Set cancel click listenner >dialog.setOnCancelButtonClickListener(View.OnClickListener onCancelButtonClickListener); > // Acces to accept button >ButtonFlat acceptButton = dialog.getButtonAccept(); > // Acces to cancel button >ButtonFlat cancelButton = dialog.getButtonCancel(); >``` ####Color selector ![Color selector](images/color_selector.png) ```java ColorSelector colorSelector = new ColorSelector(Context context,int intialColor, OnColorSelectedListener onColorSelectedListener); colorSelector.show(); ``` ================================================ FILE: index.html ================================================ Materialdesignlibrary by navasmdc

Materialdesignlibrary

This is a library with components of Android L to you use in android 2.2

View project on GitHub

Material design library logo

Material Design Android Library

Android app on Google Play

Android Arsenal

How to use

If you want use this library, you only have to download MaterialDesign project, import it into your workspace and add the project as a library in your android project settings.

If you prefer it, you can use the gradle dependency, you have to add these lines in your build.gradle file:

repositories {
    jcenter()
}

dependencies {
    compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
}

Some components have custom attributes, if you want use them, you must add this line in your xml file in the first component:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
</RelativeLayout>

If you are going to use a ScrollView, it is recommended that you use the CustomScrollView provided in this library to avoid problems with the custom components. To use this component:

<com.gc.materialdesign.views.ScrollView 
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
   android:id="@+id/scroll"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
</com.gc.materialdesign.views.ScrollView>

Components

Buttons

Flat Button

flat button

<com.gc.materialdesign.views.ButtonFlat
                android:id="@+id/buttonflat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                android:text="Button" />
Rectangle Button

rectangle button

<com.gc.materialdesign.views.ButtonRectangle
                android:id="@+id/button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                android:text="Button" />
Float Button

float button

It is recommended to put this component in the right-bottom of the screen. To use this component write this code in your xml file. If you don`t want to start this component with animation set the animate attribute to false. Put your icon in the icon attribute to set the drawable icon for this component.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <!-- ... XML CODE -->
    <com.gc.materialdesign.views.ButtonFloat
                android:id="@+id/buttonFloat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentBottom="true"
                android:layout_marginRight="24dp"
                android:background="#1E88E5"
                materialdesign:animate="true"
                materialdesign:iconDrawable="@drawable/ic_action_new" />
</RelativeLayout>
Float small button

float small button

<com.gc.materialdesign.views.ButtonFloatSmall
                android:id="@+id/buttonFloatSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:iconDrawable="@drawable/ic_action_new" />

Switches

CheckBox

checkbox

<com.gc.materialdesign.views.CheckBox
                android:id="@+id/checkBox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:check="true" />
Switch

switch

<com.gc.materialdesign.views.Switch
                android:id="@+id/switchView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:check="true" />

Progress indicators

Progress bar circular indeterminate

progress bar circular indeterminate

<com.gc.materialdesign.views.ProgressBarCircularIndeterminate
                android:id="@+id/progressBarCircularIndeterminate"
                android:layout_width="32dp"
                android:layout_height="32dp"
                android:background="#1E88E5" />
Progress bar indeterminate

progress bar indeterminate

<com.gc.materialdesign.views.ProgressBarIndeterminate
                android:id="@+id/progressBarIndeterminate"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#1E88E5" />
Progress bar indeterminate determinate

Progress bar indeterminate determinate

<com.gc.materialdesign.views.ProgressBarIndeterminateDeterminate
                android:id="@+id/progressBarIndeterminateDeterminate"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#1E88E5" />

If you begin progrees, you only have to set progress it

progressBarIndeterminateDeterminate.setProgress(progress);
Progress bar determinate

Progress bar determinate

<com.gc.materialdesign.views.ProgressBarDeterminate
                android:id="@+id/progressDeterminate"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#1E88E5" />

You can custom max and min progress values with materialdesign:max="50" and materialdesign:min="25" attributes.

Slider

Slider

<com.gc.materialdesign.views.Slider
                android:id="@+id/slider"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:max="50"
                materialdesign:min="0"
                 />
Slider with number indicator

Slider with number indicator

<com.gc.materialdesign.views.Slider
                android:id="@+id/slider"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:max="50"
                materialdesign:min="0"
                materialdesign:showNumberIndicator="true"/>

Widgets

SnackBar

Snackbar

SnackBar snackbar = new SnackBar(Activity activity, String text, String buttonText, View.OnClickListener onClickListener);
snackbar.show();

If you don't want to show the button, put null in buttonText attribute

Dialog

Dialog

Dialog dialog = new Dialog(Context context,String title, String message);
dialog.show();

You can set the accept and cancel button on the event listener or change it's text

// Set accept click listenner
dialog.setOnAcceptButtonClickListener(View.OnClickListener onAcceptButtonClickListener);
// Set cancel click listenner
dialog.setOnCancelButtonClickListener(View.OnClickListener onCancelButtonClickListener);
// Acces to accept button
ButtonFlat acceptButton = dialog.getButtonAccept();
// Acces to cancel button
ButtonFlat cancelButton = dialog.getButtonCancel();

Color selector

Color selector

ColorSelector colorSelector = new ColorSelector(Context context,int intialColor, OnColorSelectedListener onColorSelectedListener);
colorSelector.show();
================================================ FILE: javascripts/main.js ================================================ console.log('This would be the main JS file.'); ================================================ FILE: params.json ================================================ { "name": "Materialdesignlibrary", "tagline": "This is a library with components of Android L to you use in android 2.2", "body": "![Material design library logo](images/logo.png)\r\n\r\n# Material Design Android Library\r\n\r\n\r\n \"Android\r\n\r\n\r\n\r\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Material%20Design%20Android%20Library-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1156)\r\n\r\n* [How to use](#howtouse)\r\n* [Components](#components)\r\n * [Buttons](#buttons)\r\n * [Flat Button](#flat-button)\r\n * [Rectangle Button](#rectangle-button)\r\n * [Float Button](#float-button)\r\n * [Float small button](#float-small-button)\r\n * [Switches](#switches)\r\n * [CheckBox](#checkbox)\r\n * [Switch](#switch)\r\n * [Progress indicators](#progress-indicators)\r\n * [Progress bar circular indeterminate](#progress-bar-circula-rindeterminate)\r\n * [Progress bar indeterminate](#progress-bar-indeterminate)\r\n * [Progress bar indeterminate determinate](#progress-bar-indeterminate-determinate)\r\n * [Progress bar determinate](#progress-bar-determinate)\r\n * [Slider](#slider)\r\n * [Slider with number indicator](#slider-with-number-indicator)\r\n* [Widgets](#widgets)\r\n * [SnackBar](#snackbar)\r\n * [Dialog](#dialog)\r\n * [Color selector](#color-selector)\r\n\r\n## How to use\r\n\r\nIf you want use this library, you only have to download MaterialDesign project, import it into your workspace and add the project as a library in your android project settings.\r\n\r\nIf you prefer it, you can use the gradle dependency, you have to add these lines in your build.gradle file:\r\n\r\n```xml\r\nrepositories {\r\n jcenter()\r\n}\r\n\r\ndependencies {\r\n compile 'com.github.navasmdc:MaterialDesign:1.5@aar'\r\n}\r\n```\r\n\r\nSome components have custom attributes, if you want use them, you must add this line in your xml file in the first component:\r\n\r\n```xml\r\n\r\n\r\n```\r\n\r\n>If you are going to use a ScrollView, it is recommended that you use the CustomScrollView provided in this library to avoid problems with the custom components.\r\n>To use this component:\r\n>```xml\r\n> xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n> xmlns:materialdesign=\"http://schemas.android.com/apk/res-auto\"\r\n> android:id=\"@+id/scroll\"\r\n> android:layout_width=\"match_parent\"\r\n> android:layout_height=\"match_parent\">\r\n>\r\n>```\r\n\r\n##Components\r\n\r\n####Buttons\r\n\r\n######Flat Button\r\n\r\n![flat button](images/flat_button.png)\r\n```xml\r\n\r\n```\r\n\r\n######Rectangle Button\r\n\r\n![rectangle button](images/rectangle_button.png)\r\n```xml\r\n\r\n```\r\n\r\n######Float Button\r\n\r\n![float button](images/float_button.png)\r\n\r\n>It is recommended to put this component in the right-bottom of the screen. To use this component write this code in your xml file.\r\n>If you don`t want to start this component with animation set the animate attribute to false.\r\n>Put your icon in the icon attribute to set the drawable icon for this component.\r\n\r\n```xml\r\n\r\n \r\n \r\n\r\n```\r\n\r\n######Float small button\r\n\r\n![float small button](images/float_small_button.png)\r\n\r\n```xml\r\n\r\n```\r\n\r\n####Switches\r\n\r\n######CheckBox\r\n![checkbox](images/checkbox.png)\r\n\r\n```xml\r\n\r\n```\r\n\r\n######Switch\r\n![switch](images/switch.png)\r\n\r\n```xml\r\n\r\n```\r\n\r\n####Progress indicators\r\n\r\n######Progress bar circular indeterminate\r\n![progress bar circular indeterminate](images/progress_bar_circular_indeterminate.png)\r\n\r\n```xml\r\n\r\n```\r\n\r\n######Progress bar indeterminate\r\n![progress bar indeterminate](images/progress_bar_indeterminate.png)\r\n\r\n```xml\r\n\r\n```\r\n\r\n######Progress bar indeterminate determinate\r\n![Progress bar indeterminate determinate](images/progress_bar_indeterminate_determinate.png)\r\n\r\n\r\n```xml\r\n\r\n```\r\n\r\n>If you begin progrees, you only have to set progress it\r\n>\r\n>```java\r\n>progressBarIndeterminateDeterminate.setProgress(progress);\r\n>```\r\n\r\n######Progress bar determinate\r\n![Progress bar determinate](images/progress_bar_determinate.png)\r\n\r\n\r\n```xml\r\n\r\n```\r\n\r\n>You can custom max and min progress values with `materialdesign:max=\"50\"` and `materialdesign:min=\"25\"` attributes.\r\n\r\n######Slider\r\n![Slider](images/slider.png)\r\n\r\n\r\n```xml\r\n\r\n```\r\n\r\n######Slider with number indicator\r\n![Slider with number indicator](images/slider_with_number_indicator.png)\r\n\r\n\r\n```xml\r\n\r\n```\r\n\r\n##Widgets\r\n\r\n####SnackBar\r\n\r\n![Snackbar](images/snackbar.png)\r\n\r\n\r\n```java\r\nSnackBar snackbar = new SnackBar(Activity activity, String text, String buttonText, View.OnClickListener onClickListener);\r\nsnackbar.show();\r\n```\r\n\r\n> If you don't want to show the button, put `null` in `buttonText` attribute\r\n\r\n####Dialog\r\n\r\n![Dialog](images/dialog.png)\r\n\r\n```java\r\nDialog dialog = new Dialog(Context context,String title, String message);\r\ndialog.show();\r\n```\r\n\r\n>You can set the accept and cancel button on the event listener or change it's text\r\n>```java\r\n> // Set accept click listenner\r\n>dialog.setOnAcceptButtonClickListener(View.OnClickListener onAcceptButtonClickListener);\r\n> // Set cancel click listenner\r\n>dialog.setOnCancelButtonClickListener(View.OnClickListener onCancelButtonClickListener);\r\n> // Acces to accept button\r\n>ButtonFlat acceptButton = dialog.getButtonAccept();\r\n> // Acces to cancel button\r\n>ButtonFlat cancelButton = dialog.getButtonCancel();\r\n>```\r\n\r\n####Color selector\r\n\r\n![Color selector](images/color_selector.png)\r\n\r\n```java\r\nColorSelector colorSelector = new ColorSelector(Context context,int intialColor, OnColorSelectedListener onColorSelectedListener);\r\ncolorSelector.show();\r\n```\r\n\r\n\r\n\r\n\r\n\r\n", "note": "Don't delete this file! It's used internally to help with page regeneration." } ================================================ FILE: stylesheets/github-light.css ================================================ /* The MIT License (MIT) Copyright (c) 2016 GitHub, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ .pl-c /* comment */ { color: #969896; } .pl-c1 /* constant, variable.other.constant, support, meta.property-name, support.constant, support.variable, meta.module-reference, markup.raw, meta.diff.header */, .pl-s .pl-v /* string variable */ { color: #0086b3; } .pl-e /* entity */, .pl-en /* entity.name */ { color: #795da3; } .pl-smi /* variable.parameter.function, storage.modifier.package, storage.modifier.import, storage.type.java, variable.other */, .pl-s .pl-s1 /* string source */ { color: #333; } .pl-ent /* entity.name.tag */ { color: #63a35c; } .pl-k /* keyword, storage, storage.type */ { color: #a71d5d; } .pl-s /* string */, .pl-pds /* punctuation.definition.string, string.regexp.character-class */, .pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */, .pl-sr /* string.regexp */, .pl-sr .pl-cce /* string.regexp constant.character.escape */, .pl-sr .pl-sre /* string.regexp source.ruby.embedded */, .pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */ { color: #183691; } .pl-v /* variable */ { color: #ed6a43; } .pl-id /* invalid.deprecated */ { color: #b52a1d; } .pl-ii /* invalid.illegal */ { color: #f8f8f8; background-color: #b52a1d; } .pl-sr .pl-cce /* string.regexp constant.character.escape */ { font-weight: bold; color: #63a35c; } .pl-ml /* markup.list */ { color: #693a17; } .pl-mh /* markup.heading */, .pl-mh .pl-en /* markup.heading entity.name */, .pl-ms /* meta.separator */ { font-weight: bold; color: #1d3e81; } .pl-mq /* markup.quote */ { color: #008080; } .pl-mi /* markup.italic */ { font-style: italic; color: #333; } .pl-mb /* markup.bold */ { font-weight: bold; color: #333; } .pl-md /* markup.deleted, meta.diff.header.from-file */ { color: #bd2c00; background-color: #ffecec; } .pl-mi1 /* markup.inserted, meta.diff.header.to-file */ { color: #55a532; background-color: #eaffea; } .pl-mdr /* meta.diff.range */ { font-weight: bold; color: #795da3; } .pl-mo /* meta.output */ { color: #1d3e81; } ================================================ FILE: stylesheets/print.css ================================================ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { padding: 0; margin: 0; font: inherit; font-size: 100%; vertical-align: baseline; border: 0; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-spacing: 0; border-collapse: collapse; } body { font-family: 'Helvetica Neue', Helvetica, Arial, serif; font-size: 13px; line-height: 1.5; color: #000; } a { font-weight: bold; color: #d5000d; } header { padding-top: 35px; padding-bottom: 10px; } header h1 { font-size: 48px; font-weight: bold; line-height: 1.2; color: #303030; letter-spacing: -1px; } header h2 { font-size: 24px; font-weight: normal; line-height: 1.3; color: #aaa; letter-spacing: -1px; } #downloads { display: none; } #main_content { padding-top: 20px; } code, pre { margin-bottom: 30px; font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal; font-size: 12px; color: #222; } code { padding: 0 3px; } pre { padding: 20px; overflow: auto; border: solid 1px #ddd; } pre code { padding: 0; } ul, ol, dl { margin-bottom: 20px; } /* COMMON STYLES */ table { width: 100%; border: 1px solid #ebebeb; } th { font-weight: 500; } td { font-weight: 300; text-align: center; border: 1px solid #ebebeb; } form { padding: 20px; background: #f2f2f2; } /* GENERAL ELEMENT TYPE STYLES */ h1 { font-size: 2.8em; } h2 { margin-bottom: 8px; font-size: 22px; font-weight: bold; color: #303030; } h3 { margin-bottom: 8px; font-size: 18px; font-weight: bold; color: #d5000d; } h4 { font-size: 16px; font-weight: bold; color: #303030; } h5 { font-size: 1em; color: #303030; } h6 { font-size: .8em; color: #303030; } p { margin-bottom: 20px; font-weight: 300; } a { text-decoration: none; } p a { font-weight: 400; } blockquote { padding: 0 0 0 30px; margin-bottom: 20px; font-size: 1.6em; border-left: 10px solid #e9e9e9; } ul li { padding-left: 20px; list-style-position: inside; list-style: disc; } ol li { padding-left: 3px; list-style-position: inside; list-style: decimal; } dl dd { font-style: italic; font-weight: 100; } footer { padding-top: 20px; padding-bottom: 30px; margin-top: 40px; font-size: 13px; color: #aaa; } footer a { color: #666; } /* MISC */ .clearfix:after { display: block; height: 0; clear: both; visibility: hidden; content: '.'; } .clearfix {display: inline-block;} * html .clearfix {height: 1%;} .clearfix {display: block;} ================================================ FILE: stylesheets/stylesheet.css ================================================ /*! normalize.css v3.0.2 | MIT License | git.io/normalize */ /** * 1. Set default font family to sans-serif. * 2. Prevent iOS text size adjust after orientation change, without disabling * user zoom. */ html { font-family: sans-serif; /* 1 */ -webkit-text-size-adjust: 100%; /* 2 */ -ms-text-size-adjust: 100%; /* 2 */ } /** * Remove default margin. */ body { margin: 0; } /* HTML5 display definitions ========================================================================== */ /** * Correct `block` display not defined for any HTML5 element in IE 8/9. * Correct `block` display not defined for `details` or `summary` in IE 10/11 * and Firefox. * Correct `block` display not defined for `main` in IE 11. */ article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; } /** * 1. Correct `inline-block` display not defined in IE 8/9. * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. */ audio, canvas, progress, video { display: inline-block; /* 1 */ vertical-align: baseline; /* 2 */ } /** * Prevent modern browsers from displaying `audio` without controls. * Remove excess height in iOS 5 devices. */ audio:not([controls]) { display: none; height: 0; } /** * Address `[hidden]` styling not present in IE 8/9/10. * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. */ [hidden], template { display: none; } /* Links ========================================================================== */ /** * Remove the gray background color from active links in IE 10. */ a { background-color: transparent; } /** * Improve readability when focused and also mouse hovered in all browsers. */ a:active, a:hover { outline: 0; } /* Text-level semantics ========================================================================== */ /** * Address styling not present in IE 8/9/10/11, Safari, and Chrome. */ abbr[title] { border-bottom: 1px dotted; } /** * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. */ b, strong { font-weight: bold; } /** * Address styling not present in Safari and Chrome. */ dfn { font-style: italic; } /** * Address variable `h1` font-size and margin within `section` and `article` * contexts in Firefox 4+, Safari, and Chrome. */ h1 { margin: 0.67em 0; font-size: 2em; } /** * Address styling not present in IE 8/9. */ mark { color: #000; background: #ff0; } /** * Address inconsistent and variable font size in all browsers. */ small { font-size: 80%; } /** * Prevent `sub` and `sup` affecting `line-height` in all browsers. */ sub, sup { position: relative; font-size: 75%; line-height: 0; vertical-align: baseline; } sup { top: -0.5em; } sub { bottom: -0.25em; } /* Embedded content ========================================================================== */ /** * Remove border when inside `a` element in IE 8/9/10. */ img { border: 0; } /** * Correct overflow not hidden in IE 9/10/11. */ svg:not(:root) { overflow: hidden; } /* Grouping content ========================================================================== */ /** * Address margin not present in IE 8/9 and Safari. */ figure { margin: 1em 40px; } /** * Address differences between Firefox and other browsers. */ hr { height: 0; -moz-box-sizing: content-box; box-sizing: content-box; } /** * Contain overflow in all browsers. */ pre { overflow: auto; } /** * Address odd `em`-unit font size rendering in all browsers. */ code, kbd, pre, samp { font-family: monospace, monospace; font-size: 1em; } /* Forms ========================================================================== */ /** * Known limitation: by default, Chrome and Safari on OS X allow very limited * styling of `select`, unless a `border` property is set. */ /** * 1. Correct color not being inherited. * Known issue: affects color of disabled elements. * 2. Correct font properties not being inherited. * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. */ button, input, optgroup, select, textarea { margin: 0; /* 3 */ font: inherit; /* 2 */ color: inherit; /* 1 */ } /** * Address `overflow` set to `hidden` in IE 8/9/10/11. */ button { overflow: visible; } /** * Address inconsistent `text-transform` inheritance for `button` and `select`. * All other form control elements do not inherit `text-transform` values. * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. * Correct `select` style inheritance in Firefox. */ button, select { text-transform: none; } /** * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` * and `video` controls. * 2. Correct inability to style clickable `input` types in iOS. * 3. Improve usability and consistency of cursor style between image-type * `input` and others. */ button, html input[type="button"], /* 1 */ input[type="reset"], input[type="submit"] { -webkit-appearance: button; /* 2 */ cursor: pointer; /* 3 */ } /** * Re-set default cursor for disabled elements. */ button[disabled], html input[disabled] { cursor: default; } /** * Remove inner padding and border in Firefox 4+. */ button::-moz-focus-inner, input::-moz-focus-inner { padding: 0; border: 0; } /** * Address Firefox 4+ setting `line-height` on `input` using `!important` in * the UA stylesheet. */ input { line-height: normal; } /** * It's recommended that you don't attempt to style these elements. * Firefox's implementation doesn't respect box-sizing, padding, or width. * * 1. Address box sizing set to `content-box` in IE 8/9/10. * 2. Remove excess padding in IE 8/9/10. */ input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ } /** * Fix the cursor style for Chrome's increment/decrement buttons. For certain * `font-size` values of the `input`, it causes the cursor style of the * decrement button to change from `default` to `text`. */ input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; } /** * 1. Address `appearance` set to `searchfield` in Safari and Chrome. * 2. Address `box-sizing` set to `border-box` in Safari and Chrome * (include `-moz` to future-proof). */ input[type="search"] { -webkit-box-sizing: content-box; /* 2 */ -moz-box-sizing: content-box; box-sizing: content-box; -webkit-appearance: textfield; /* 1 */ } /** * Remove inner padding and search cancel button in Safari and Chrome on OS X. * Safari (but not Chrome) clips the cancel button when the search input has * padding (and `textfield` appearance). */ input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } /** * Define consistent border, margin, and padding. */ fieldset { padding: 0.35em 0.625em 0.75em; margin: 0 2px; border: 1px solid #c0c0c0; } /** * 1. Correct `color` not being inherited in IE 8/9/10/11. * 2. Remove padding so people aren't caught out if they zero out fieldsets. */ legend { padding: 0; /* 2 */ border: 0; /* 1 */ } /** * Remove default vertical scrollbar in IE 8/9/10/11. */ textarea { overflow: auto; } /** * Don't inherit the `font-weight` (applied by a rule above). * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. */ optgroup { font-weight: bold; } /* Tables ========================================================================== */ /** * Remove most spacing between table cells. */ table { border-spacing: 0; border-collapse: collapse; } td, th { padding: 0; } /* LAYOUT STYLES */ body { font-family: 'Helvetica Neue', Helvetica, Arial, serif; font-size: 15px; font-weight: 400; line-height: 1.5; color: #666; background: #fafafa url(../images/body-bg.jpg) 0 0 repeat; } p { margin-top: 0; } a { color: #2879d0; } a:hover { color: #2268b2; } header { padding-top: 40px; padding-bottom: 40px; font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; background: #2e7bcf url(../images/header-bg.jpg) 0 0 repeat-x; border-bottom: solid 1px #275da1; } header h1 { width: 540px; margin-top: 0; margin-bottom: 0.2em; font-size: 72px; font-weight: normal; line-height: 1; color: #fff; letter-spacing: -1px; } header h2 { width: 540px; margin-top: 0; margin-bottom: 0; font-size: 26px; font-weight: normal; line-height: 1.3; color: #9ddcff; letter-spacing: 0; } .inner { position: relative; width: 940px; margin: 0 auto; } #content-wrapper { padding-top: 30px; border-top: solid 1px #fff; } #main-content { float: left; width: 690px; } #main-content img { max-width: 100%; } aside#sidebar { float: right; width: 200px; min-height: 504px; padding-left: 20px; font-size: 12px; line-height: 1.3; background: transparent url(../images/sidebar-bg.jpg) 0 0 no-repeat; } aside#sidebar p.repo-owner, aside#sidebar p.repo-owner a { font-weight: bold; } #downloads { margin-bottom: 40px; } a.button { width: 134px; height: 58px; padding-top: 22px; padding-left: 68px; font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 23px; line-height: 1.2; color: #fff; } a.button small { display: block; font-size: 11px; } header a.button { position: absolute; top: 0; right: 0; background: transparent url(../images/github-button.png) 0 0 no-repeat; } aside a.button { display: block; width: 138px; padding-left: 64px; margin-bottom: 20px; font-size: 21px; background: transparent url(../images/download-button.png) 0 0 no-repeat; } code, pre { margin-bottom: 30px; font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; font-size: 13px; color: #222; } code { padding: 0 3px; background-color: #f2f8fc; border: solid 1px #dbe7f3; } pre { padding: 20px; overflow: auto; text-shadow: none; background: #fff; border: solid 1px #f2f2f2; } pre code { padding: 0; color: #2879d0; background-color: #fff; border: none; } ul, ol, dl { margin-bottom: 20px; } /* COMMON STYLES */ hr { height: 0; margin-top: 1em; margin-bottom: 1em; border: 0; border-top: solid 1px #ddd; } table { width: 100%; border: 1px solid #ebebeb; } th { font-weight: 500; } td { font-weight: 300; text-align: center; border: 1px solid #ebebeb; } form { padding: 20px; background: #f2f2f2; } /* GENERAL ELEMENT TYPE STYLES */ #main-content h1 { margin-top: 0; margin-bottom: 0; font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 2.8em; font-weight: normal; color: #474747; text-indent: 6px; letter-spacing: -1px; } #main-content h1:before { padding-right: 0.3em; margin-left: -0.9em; color: #9ddcff; content: "/"; } #main-content h2 { margin-bottom: 8px; font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 22px; font-weight: bold; color: #474747; text-indent: 4px; } #main-content h2:before { padding-right: 0.3em; margin-left: -1.5em; content: "//"; color: #9ddcff; } #main-content h3 { margin-top: 24px; margin-bottom: 8px; font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 18px; font-weight: bold; color: #474747; text-indent: 3px; } #main-content h3:before { padding-right: 0.3em; margin-left: -2em; content: "///"; color: #9ddcff; } #main-content h4 { margin-bottom: 8px; font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 15px; font-weight: bold; color: #474747; text-indent: 3px; } h4:before { padding-right: 0.3em; margin-left: -2.8em; content: "////"; color: #9ddcff; } #main-content h5 { margin-bottom: 8px; font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 14px; color: #474747; text-indent: 3px; } h5:before { padding-right: 0.3em; margin-left: -3.2em; content: "/////"; color: #9ddcff; } #main-content h6 { margin-bottom: 8px; font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: .8em; color: #474747; text-indent: 3px; } h6:before { padding-right: 0.3em; margin-left: -3.7em; content: "//////"; color: #9ddcff; } p { margin-bottom: 20px; } a { text-decoration: none; } p a { font-weight: 400; } blockquote { padding: 0 0 0 30px; margin-bottom: 20px; font-size: 1.6em; border-left: 10px solid #e9e9e9; } ul { list-style-position: inside; list-style: disc; padding-left: 20px; } ol { list-style-position: inside; list-style: decimal; padding-left: 3px; } dl dd { font-style: italic; font-weight: 100; } footer { padding-top: 20px; padding-bottom: 30px; margin-top: 40px; font-size: 13px; color: #aaa; background: transparent url('../images/hr.png') 0 0 no-repeat; } footer a { color: #666; } footer a:hover { color: #444; } /* MISC */ .clearfix:after { display: block; height: 0; clear: both; visibility: hidden; content: '.'; } .clearfix {display: inline-block;} * html .clearfix {height: 1%;} .clearfix {display: block;} /* #Media Queries ================================================== */ /* Smaller than standard 960 (devices and browsers) */ @media only screen and (max-width: 959px) { } /* Tablet Portrait size to standard 960 (devices and browsers) */ @media only screen and (min-width: 768px) and (max-width: 959px) { .inner { width: 740px; } header h1, header h2 { width: 340px; } header h1 { font-size: 60px; } header h2 { font-size: 30px; } #main-content { width: 490px; } #main-content h1:before, #main-content h2:before, #main-content h3:before, #main-content h4:before, #main-content h5:before, #main-content h6:before { padding-right: 0; margin-left: 0; content: none; } } /* All Mobile Sizes (devices and browser) */ @media only screen and (max-width: 767px) { .inner { width: 93%; } header { padding: 20px 0; } header .inner { position: relative; } header h1, header h2 { width: 100%; } header h1 { font-size: 48px; } header h2 { font-size: 24px; } header a.button { position: relative; display: inline-block; width: auto; height: auto; padding: 5px 10px; margin-top: 15px; font-size: 13px; line-height: 1; color: #2879d0; text-align: center; background-color: #9ddcff; background-image: none; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; } header a.button small { display: inline; font-size: 13px; } #main-content, aside#sidebar { float: none; width: 100% ! important; } aside#sidebar { min-height: 0; padding: 20px 0; margin-top: 20px; background-image: none; border-top: solid 1px #ddd; } aside#sidebar a.button { display: none; } #main-content h1:before, #main-content h2:before, #main-content h3:before, #main-content h4:before, #main-content h5:before, #main-content h6:before { padding-right: 0; margin-left: 0; content: none; } } /* Mobile Landscape Size to Tablet Portrait (devices and browsers) */ @media only screen and (min-width: 480px) and (max-width: 767px) { } /* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */ @media only screen and (max-width: 479px) { }