mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
add AndroidBootstrap lib
This commit is contained in:
parent
14a8738933
commit
11ed8d7e16
@ -25,6 +25,7 @@ dependencies {
|
||||
compile project(':libraries:HtmlTextView')
|
||||
compile project(':libraries:StickyListHeaders:library')
|
||||
compile project(':libraries:zxing')
|
||||
compile project(':libraries:AndroidBootstrap')
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -13,3 +13,4 @@ android.library.reference.1=../libraries/ActionBarSherlock
|
||||
android.library.reference.2=../libraries/HtmlTextView
|
||||
android.library.reference.3=../libraries/StickyListHeaders/library
|
||||
android.library.reference.4=../libraries/zxing
|
||||
android.library.reference.5=../libraries/AndroidBootstrap
|
||||
|
@ -14,6 +14,8 @@ And don't add newlines before or after p tags because of transifex -->
|
||||
<li>Dominik Schürmann (Lead developer)</li>
|
||||
<li>Ash Hughes</li>
|
||||
<li>Brian C. Barnes</li>
|
||||
<li>Bahtiar 'kalkin' Gadimov</li>
|
||||
|
||||
</ul>
|
||||
<h2>Developers APG 1.x</h2>
|
||||
<ul>
|
||||
@ -26,7 +28,9 @@ And don't add newlines before or after p tags because of transifex -->
|
||||
<h2>Libraries</h2>
|
||||
<ul>
|
||||
<li><a href="http://actionbarsherlock.com">ActionBarSherlock</a> (Apache License v2)</li>
|
||||
<li><a href="http://code.google.com/p/zxing/">ZXing QRCode Integration</a> (Apache License v2)</li>
|
||||
<li><a href="https://github.com/emilsjolander/StickyListHeaders">StickyListHeaders</a> (Apache License v2)</li>
|
||||
<li><a href="https://github.com/Bearded-Hen/Android-Bootstrap">Android-Bootstrap</a> (MIT License)</li>
|
||||
<li><a href="http://code.google.com/p/zxing/">ZXing</a> (Apache License v2)</li>
|
||||
<li><a href="http://rtyley.github.com/spongycastle/">SpongyCastle</a> (MIT X11 License)</li>
|
||||
<li><a href="https://github.com/dschuermann/html-textview">HtmlTextView</a> (Apache License v2)</li>
|
||||
<li>Icons from <a href="http://rrze-icon-set.berlios.de/">RRZE Icon Set</a> (Creative Commons Attribution Share-Alike licence 3.0)</li>
|
||||
|
11
README.md
11
README.md
@ -29,8 +29,9 @@ Android Studio is currently not supported or recommended!
|
||||
2. File -> Import -> Android -> Existing Android Code Into Workspace, choose "libraries/HtmlTextView"
|
||||
3. File -> Import -> Android -> Existing Android Code Into Workspace, choose "libraries/StickyListHeaders/library"
|
||||
4. File -> Import -> Android -> Existing Android Code Into Workspace, choose "libraries/zxing"
|
||||
5. File -> Import -> Android -> Existing Android Code Into Workspace, choose "OpenPGP-Keychain"
|
||||
6. OpenPGP-Kechain can now be build
|
||||
5. File -> Import -> Android -> Existing Android Code Into Workspace, choose "libraries/AndroidBootstrap"
|
||||
6. File -> Import -> Android -> Existing Android Code Into Workspace, choose "OpenPGP-Keychain"
|
||||
7. OpenPGP-Kechain can now be build
|
||||
|
||||
# Keychain API
|
||||
|
||||
@ -206,7 +207,7 @@ Some parts (older parts and some libraries are Apache License v2, MIT X11 Licens
|
||||
https://github.com/dschuermann/html-textview
|
||||
Apache License v2
|
||||
|
||||
* ZXing QRCode Integration
|
||||
* ZXing
|
||||
http://code.google.com/p/zxing/
|
||||
Apache License v2
|
||||
|
||||
@ -214,6 +215,10 @@ Some parts (older parts and some libraries are Apache License v2, MIT X11 Licens
|
||||
https://github.com/emilsjolander/StickyListHeaders
|
||||
Apache License v2
|
||||
|
||||
* Android-Bootstrap
|
||||
https://github.com/Bearded-Hen/Android-Bootstrap
|
||||
MIT License
|
||||
|
||||
|
||||
## Images
|
||||
* icon.svg
|
||||
|
26
libraries/AndroidBootstrap/AndroidManifest.xml
Normal file
26
libraries/AndroidBootstrap/AndroidManifest.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.beardedhen.androidbootstrap"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="7"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name" >
|
||||
<activity
|
||||
android:name="com.beardedhen.androidbootstrap.MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
17
libraries/AndroidBootstrap/build.gradle
Normal file
17
libraries/AndroidBootstrap/build.gradle
Normal file
@ -0,0 +1,17 @@
|
||||
apply plugin: 'android-library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "19.0.0"
|
||||
defaultConfig {
|
||||
minSdkVersion 7
|
||||
targetSdkVersion 17
|
||||
}
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
java.srcDirs = ['src']
|
||||
res.srcDirs = ['res']
|
||||
}
|
||||
}
|
||||
}
|
BIN
libraries/AndroidBootstrap/libs/android-support-v4.jar
Normal file
BIN
libraries/AndroidBootstrap/libs/android-support-v4.jar
Normal file
Binary file not shown.
20
libraries/AndroidBootstrap/proguard-project.txt
Normal file
20
libraries/AndroidBootstrap/proguard-project.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# 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 *;
|
||||
#}
|
15
libraries/AndroidBootstrap/project.properties
Normal file
15
libraries/AndroidBootstrap/project.properties
Normal file
@ -0,0 +1,15 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-18
|
||||
android.library=true
|
BIN
libraries/AndroidBootstrap/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
libraries/AndroidBootstrap/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
BIN
libraries/AndroidBootstrap/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
libraries/AndroidBootstrap/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
libraries/AndroidBootstrap/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
libraries/AndroidBootstrap/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
20
libraries/AndroidBootstrap/res/drawable/bbuton_danger.xml
Normal file
20
libraries/AndroidBootstrap/res/drawable/bbuton_danger.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_danger_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_danger_edge" />
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_danger_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_danger_disabled_edge" />
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_danger" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_danger_edge" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_danger_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_danger_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_danger_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_danger_disabled_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_danger" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_danger_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
</selector>
|
20
libraries/AndroidBootstrap/res/drawable/bbuton_default.xml
Normal file
20
libraries/AndroidBootstrap/res/drawable/bbuton_default.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_default_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_default_edge" />
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_default_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_default_disabled_edge" />
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_default" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_default_edge" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_default_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_default_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_default_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_default_disabled_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_default" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_default_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
20
libraries/AndroidBootstrap/res/drawable/bbuton_info.xml
Normal file
20
libraries/AndroidBootstrap/res/drawable/bbuton_info.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_info_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_info_edge" />
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_info_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_info_disabled_edge" />
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_info" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_info_edge" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_info_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_info_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_info_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_info_disabled_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_info" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_info_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
20
libraries/AndroidBootstrap/res/drawable/bbuton_inverse.xml
Normal file
20
libraries/AndroidBootstrap/res/drawable/bbuton_inverse.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_inverse_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_inverse_edge" />
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_inverse_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_inverse_disabled_edge" />
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_inverse" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_inverse_edge" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_inverse_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_inverse_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_inverse_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_inverse_disabled_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_inverse" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_inverse_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
20
libraries/AndroidBootstrap/res/drawable/bbuton_primary.xml
Normal file
20
libraries/AndroidBootstrap/res/drawable/bbuton_primary.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_primary_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_primary_edge" />
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_primary_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_primary_disabled_edge" />
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_primary" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_primary_edge" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_primary_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_primary_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_primary_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_primary_disabled_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_primary" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_primary_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
20
libraries/AndroidBootstrap/res/drawable/bbuton_success.xml
Normal file
20
libraries/AndroidBootstrap/res/drawable/bbuton_success.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_success_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_success_edge" />
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_success_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_success_disabled_edge" />
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_success" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_success_edge" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_success_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_success_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_success_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_success_disabled_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_success" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_success_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
20
libraries/AndroidBootstrap/res/drawable/bbuton_warning.xml
Normal file
20
libraries/AndroidBootstrap/res/drawable/bbuton_warning.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_warning_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_warning_edge" />
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_warning_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_warning_disabled_edge" />
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_warning" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_warning_edge" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape>
|
||||
<solid android:color="@color/bbutton_warning_pressed" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_warning_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_warning_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_warning_disabled_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bbutton_warning" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_warning_edge" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bthumbnail_background" />
|
||||
<stroke android:width="1dp" android:color="@color/bthumbnail_border" />
|
||||
<corners android:radius="@dimen/bthumbnail_rounded_corner_radius"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item><shape>
|
||||
<solid android:color="@color/bthumbnail_background" />
|
||||
<stroke android:width="1dp" android:color="@color/bthumbnail_border" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/bthumbnail_placeholder" />
|
||||
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_focused="true"><shape>
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="2dp" android:color="@color/bbutton_primary" />
|
||||
</shape></item>
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_edittext_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_edittext_border" />
|
||||
</shape></item>
|
||||
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_edittext_border" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"><shape>
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="2dp" android:color="@color/bbutton_danger" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_danger" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_focused="true"><shape>
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="2dp" android:color="@color/bbutton_primary" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
<item android:state_enabled="false"><shape>
|
||||
<solid android:color="@color/bbutton_edittext_disabled" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_edittext_border" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_edittext_border" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"><shape>
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="2dp" android:color="@color/bbutton_danger" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_danger" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
|
||||
|
||||
|
||||
</selector>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"><shape>
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="2dp" android:color="@color/bbutton_success" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_success" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"><shape>
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="2dp" android:color="@color/bbutton_warning" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_warning" />
|
||||
<corners android:radius="@dimen/bbuton_rounded_corner_radius" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"><shape>
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="2dp" android:color="@color/bbutton_success" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_success" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"><shape>
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="2dp" android:color="@color/bbutton_warning" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:width="1dp" android:color="@color/bbutton_warning" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/bthumbnail_placeholder"/>
|
||||
</shape>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item>
|
||||
<shape
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/bthumbnail_background" />
|
||||
<stroke android:width="1dp" android:color="@color/bthumbnail_border" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item>
|
||||
<shape
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/bthumbnail_background" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
40
libraries/AndroidBootstrap/res/layout/bootstrap_button.xml
Normal file
40
libraries/AndroidBootstrap/res/layout/bootstrap_button.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/layout"
|
||||
android:duplicateParentState="true"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblLeft"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:paddingLeft="15dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblMiddle"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_horizontal"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblRight"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:paddingRight="15dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/layout"
|
||||
android:duplicateParentState="true"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblLeft"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:paddingLeft="15dp"
|
||||
android:visibility="gone"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_alignParentLeft="true"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblRight"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:paddingRight="15dp"
|
||||
android:visibility="gone"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_alignParentRight="true"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblMiddle"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="fill_parent"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:visibility="gone"
|
||||
android:gravity="left|center_vertical"
|
||||
android:layout_toLeftOf="@id/lblRight"
|
||||
android:layout_toRightOf="@id/lblLeft"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/layout"
|
||||
android:orientation="horizontal">
|
||||
<EditText
|
||||
android:id="@+id/txtText"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_gravity="center"
|
||||
android:hint=""
|
||||
/>
|
||||
</LinearLayout>
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/container"
|
||||
android:duplicateParentState="true"
|
||||
android:padding="@dimen/padding_small"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/placeholder"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="16dp">
|
||||
|
||||
<com.beardedhen.androidbootstrap.utils.AutoResizeTextView
|
||||
android:id="@+id/dimensionsLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:ellipsize="none"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:textSize="100sp"
|
||||
android:textColor="@color/bthumbnail_font"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/container"
|
||||
android:duplicateParentState="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/placeholder"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/image"/>
|
||||
|
||||
<com.beardedhen.androidbootstrap.utils.AutoResizeTextView
|
||||
android:id="@+id/dimensionsLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:ellipsize="none"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:textSize="100sp"
|
||||
android:textColor="@color/bthumbnail_font"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
14
libraries/AndroidBootstrap/res/layout/font_awesome_text.xml
Normal file
14
libraries/AndroidBootstrap/res/layout/font_awesome_text.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/layout"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/lblText"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="3dp"
|
||||
/>
|
||||
</LinearLayout>
|
16
libraries/AndroidBootstrap/res/layout/row_title.xml
Normal file
16
libraries/AndroidBootstrap/res/layout/row_title.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/lblTitle"
|
||||
android:gravity="left"
|
||||
/>
|
||||
</LinearLayout>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/lblTitle"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/lblSubTitle"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
28
libraries/AndroidBootstrap/res/layout/row_two_columns.xml
Normal file
28
libraries/AndroidBootstrap/res/layout/row_two_columns.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/lblColA"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/lblColB"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
9
libraries/AndroidBootstrap/res/menu/main.xml
Normal file
9
libraries/AndroidBootstrap/res/menu/main.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
|
||||
</menu>
|
8
libraries/AndroidBootstrap/res/values-sw600dp/dimens.xml
Normal file
8
libraries/AndroidBootstrap/res/values-sw600dp/dimens.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw600dp devices (e.g. 7" tablets) here.
|
||||
-->
|
||||
|
||||
</resources>
|
@ -0,0 +1,9 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
|
||||
-->
|
||||
<dimen name="activity_horizontal_margin">128dp</dimen>
|
||||
|
||||
</resources>
|
11
libraries/AndroidBootstrap/res/values-v11/styles.xml
Normal file
11
libraries/AndroidBootstrap/res/values-v11/styles.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
|
||||
<!-- API 11 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
12
libraries/AndroidBootstrap/res/values-v14/styles.xml
Normal file
12
libraries/AndroidBootstrap/res/values-v14/styles.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<!-- API 14 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
50
libraries/AndroidBootstrap/res/values/attrs.xml
Normal file
50
libraries/AndroidBootstrap/res/values/attrs.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="BootstrapButton">
|
||||
<attr name="bb_type" format="string"/>
|
||||
<attr name="bb_icon_left" format="string"/>
|
||||
<attr name="bb_icon_right" format="string"/>
|
||||
<attr name="bb_roundedCorners" format="boolean"/>
|
||||
<attr name="bb_text_alignment" format="string"/>
|
||||
<attr name="bb_size" format="string"/>
|
||||
<attr name="bb_text_gravity" format="string"/>
|
||||
<attr name="android:textSize"/>
|
||||
<attr name="android:text"/>
|
||||
<attr name="android:enabled"/>
|
||||
<attr name="android:layout_width"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="FontAwesomeText">
|
||||
<attr name="fa_icon" format="string"/>
|
||||
<attr name="android:textSize"/>
|
||||
<attr name="android:textColor"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="BootstrapEditText">
|
||||
<attr name="be_roundedCorners" format="boolean"/>
|
||||
<attr name="be_state" format="string"/>
|
||||
<attr name="android:textSize"/>
|
||||
<attr name="android:text"/>
|
||||
<attr name="android:hint"/>
|
||||
<attr name="android:enabled"/>
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="BootstrapThumbnail">
|
||||
<attr name="bt_roundedCorners" format="boolean"/>
|
||||
<attr name="bt_image" format="integer"/>
|
||||
<attr name="bt_width" format="dimension"/>
|
||||
<attr name="bt_height" format="dimension"/>
|
||||
<attr name="bt_inside_padding" format="dimension"/>
|
||||
<attr name="android:text"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="BootstrapCircleThumbnail">
|
||||
<attr name="bct_image" format="integer"/>
|
||||
<attr name="bct_size" format="string" />
|
||||
<attr name="bct_minimal" format="boolean" />
|
||||
<attr name="android:text"/>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
65
libraries/AndroidBootstrap/res/values/colors.xml
Normal file
65
libraries/AndroidBootstrap/res/values/colors.xml
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="white">#ffffffff</color>
|
||||
<color name="black">#ff000000</color>
|
||||
<color name="bbutton_edittext_border">#ccc</color>
|
||||
<color name="bbutton_edittext_disabled">#ffe0e0e0</color>
|
||||
|
||||
<color name="bbutton_primary">#ff428bca</color>
|
||||
<color name="bbutton_primary_edge">#ff357ebd</color>
|
||||
<color name="bbutton_primary_pressed">#ff3276b1</color>
|
||||
<color name="bbutton_primary_pressed_edge">#ff285e8e</color>
|
||||
<color name="bbutton_primary_disabled">#a5428bca</color>
|
||||
<color name="bbutton_primary_disabled_edge">#a5357ebd</color>
|
||||
|
||||
<color name="bbutton_danger">#ffd9534f</color>
|
||||
<color name="bbutton_danger_edge">#ffd43f3a</color>
|
||||
<color name="bbutton_danger_pressed">#ffd2322d</color>
|
||||
<color name="bbutton_danger_pressed_edge">#ffac2925</color>
|
||||
<color name="bbutton_danger_disabled">#a5d9534f</color>
|
||||
<color name="bbutton_danger_disabled_edge">#a5d43f3a</color>
|
||||
|
||||
|
||||
<color name="bbutton_success">#ff5cb85c</color>
|
||||
<color name="bbutton_success_edge">#ff4cae4c</color>
|
||||
<color name="bbutton_success_pressed">#ff47a447</color>
|
||||
<color name="bbutton_success_pressed_edge">#ff398439</color>
|
||||
<color name="bbutton_success_disabled">#a55cb85c</color>
|
||||
<color name="bbutton_success_disabled_edge">#a54cae4c</color>
|
||||
|
||||
|
||||
<color name="bbutton_warning">#fff0ad4e</color>
|
||||
<color name="bbutton_warning_edge">#ffeea236</color>
|
||||
<color name="bbutton_warning_pressed">#ffed9c28</color>
|
||||
<color name="bbutton_warning_pressed_edge">#ffd58512</color>
|
||||
<color name="bbutton_warning_disabled">#a5f0ad4e</color>
|
||||
<color name="bbutton_warning_disabled_edge">#a5eea236</color>
|
||||
|
||||
<color name="bbutton_info">#ff5bc0de</color>
|
||||
<color name="bbutton_info_edge">#ff46b8da</color>
|
||||
<color name="bbutton_info_pressed">#ff39b3d7</color>
|
||||
<color name="bbutton_info_pressed_edge">#ff269abc</color>
|
||||
<color name="bbutton_info_disabled">#a55bc0de</color>
|
||||
<color name="bbutton_info_disabled_edge">#a546b8da</color>
|
||||
|
||||
<color name="bbutton_default">#ffffffff</color>
|
||||
<color name="bbutton_default_edge">#ffcccccc</color>
|
||||
<color name="bbutton_default_pressed">#ffebebeb</color>
|
||||
<color name="bbutton_default_pressed_edge">#ffadadad</color>
|
||||
<color name="bbutton_default_disabled">#a5ffffff</color>
|
||||
<color name="bbutton_default_disabled_edge">#a5cccccc</color>
|
||||
|
||||
<color name="bbutton_inverse">#ff0a0a0a</color>
|
||||
<color name="bbutton_inverse_edge">#ff141414</color>
|
||||
<color name="bbutton_inverse_pressed">#ff1f1f1f</color>
|
||||
<color name="bbutton_inverse_pressed_edge">#ff292929</color>
|
||||
<color name="bbutton_inverse_disabled">#a50a0a0a</color>
|
||||
<color name="bbutton_inverse_disabled_edge">#a5141414</color>
|
||||
|
||||
<color name="bthumbnail_background">#ffffffff</color>
|
||||
<color name="bthumbnail_placeholder">#e9e9e9</color>
|
||||
<color name="bthumbnail_border">#dbdbdb</color>
|
||||
<color name="bthumbnail_font">#7e7e7e</color>
|
||||
|
||||
|
||||
</resources>
|
14
libraries/AndroidBootstrap/res/values/dimens.xml
Normal file
14
libraries/AndroidBootstrap/res/values/dimens.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<resources>
|
||||
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="bbuton_rounded_corner_radius">5dp</dimen>
|
||||
|
||||
<dimen name="bthumbnail_rounded_corner_radius">3dp</dimen>
|
||||
|
||||
<dimen name="padding_micro">4dp</dimen>
|
||||
<dimen name="padding_small">8dp</dimen>
|
||||
<dimen name="padding_medium">12dp</dimen>
|
||||
<dimen name="padding_large">16dp</dimen>
|
||||
</resources>
|
8
libraries/AndroidBootstrap/res/values/strings.xml
Normal file
8
libraries/AndroidBootstrap/res/values/strings.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">BButton</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
|
||||
</resources>
|
16
libraries/AndroidBootstrap/res/values/styles.xml
Normal file
16
libraries/AndroidBootstrap/res/values/styles.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Light">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
-->
|
||||
</style>
|
||||
|
||||
|
||||
</resources>
|
@ -0,0 +1,445 @@
|
||||
package com.beardedhen.androidbootstrap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.beardedhen.androidbootstrap.R;
|
||||
|
||||
|
||||
public class BootstrapButton extends FrameLayout {
|
||||
|
||||
private static Map<String, BootstrapTypes> bbuttonTypeMap;
|
||||
private static Map<String, BootstrapTypes> bbuttonTypeMapRounded;
|
||||
private static Typeface font;
|
||||
|
||||
private static Map<String, String> faMap;
|
||||
|
||||
private TextView lblMiddle;
|
||||
private TextView lblRight;
|
||||
private TextView lblLeft;
|
||||
private ViewGroup layout;
|
||||
private boolean roundedCorners = false;
|
||||
private boolean fillparent = false;
|
||||
|
||||
private static final String FA_ICON_QUESTION = "fa-question";
|
||||
|
||||
static{
|
||||
|
||||
bbuttonTypeMap = new HashMap<String, BootstrapTypes>();
|
||||
|
||||
bbuttonTypeMap.put("default", BootstrapTypes.DEFAULT);
|
||||
bbuttonTypeMap.put("primary", BootstrapTypes.PRIMARY);
|
||||
bbuttonTypeMap.put("success", BootstrapTypes.SUCCESS);
|
||||
bbuttonTypeMap.put("info", BootstrapTypes.INFO);
|
||||
bbuttonTypeMap.put("warning", BootstrapTypes.WARNING);
|
||||
bbuttonTypeMap.put("danger", BootstrapTypes.DANGER);
|
||||
bbuttonTypeMap.put("inverse", BootstrapTypes.INVERSE);
|
||||
|
||||
bbuttonTypeMapRounded = new HashMap<String, BootstrapTypes>();
|
||||
|
||||
bbuttonTypeMapRounded.put("default", BootstrapTypes.DEFAULT_ROUNDED);
|
||||
bbuttonTypeMapRounded.put("primary", BootstrapTypes.PRIMARY_ROUNDED);
|
||||
bbuttonTypeMapRounded.put("success", BootstrapTypes.SUCCESS_ROUNDED);
|
||||
bbuttonTypeMapRounded.put("info", BootstrapTypes.INFO_ROUNDED);
|
||||
bbuttonTypeMapRounded.put("warning", BootstrapTypes.WARNING_ROUNDED);
|
||||
bbuttonTypeMapRounded.put("danger", BootstrapTypes.DANGER_ROUNDED);
|
||||
bbuttonTypeMapRounded.put("inverse", BootstrapTypes.INVERSE_ROUNDED);
|
||||
|
||||
|
||||
faMap = FontAwesome.getFaMap();
|
||||
|
||||
}
|
||||
|
||||
public BootstrapButton(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public BootstrapButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public BootstrapButton(Context context) {
|
||||
super(context);
|
||||
initialise(null);
|
||||
}
|
||||
|
||||
//set up the bootstrap types
|
||||
private enum BootstrapTypes
|
||||
{
|
||||
DEFAULT(R.drawable.bbuton_default, R.color.black),
|
||||
PRIMARY(R.drawable.bbuton_primary, R.color.white),
|
||||
SUCCESS(R.drawable.bbuton_success, R.color.white),
|
||||
INFO(R.drawable.bbuton_info, R.color.white),
|
||||
WARNING(R.drawable.bbuton_warning, R.color.white),
|
||||
DANGER(R.drawable.bbuton_danger, R.color.white),
|
||||
INVERSE(R.drawable.bbuton_inverse, R.color.white),
|
||||
|
||||
DEFAULT_ROUNDED(R.drawable.bbuton_default_rounded, R.color.black),
|
||||
PRIMARY_ROUNDED(R.drawable.bbuton_primary_rounded, R.color.white),
|
||||
SUCCESS_ROUNDED(R.drawable.bbuton_success_rounded, R.color.white),
|
||||
INFO_ROUNDED(R.drawable.bbuton_info_rounded, R.color.white),
|
||||
WARNING_ROUNDED(R.drawable.bbuton_warning_rounded, R.color.white),
|
||||
DANGER_ROUNDED(R.drawable.bbuton_danger_rounded, R.color.white),
|
||||
INVERSE_ROUNDED(R.drawable.bbuton_inverse_rounded, R.color.white);
|
||||
|
||||
private int backgroundDrawable;
|
||||
private int textColour;
|
||||
|
||||
BootstrapTypes(int backgroundDrawable, int textColour)
|
||||
{
|
||||
this.backgroundDrawable = backgroundDrawable;
|
||||
this.textColour = textColour;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initialise( AttributeSet attrs )
|
||||
{
|
||||
LayoutInflater inflator = (LayoutInflater)getContext().getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
//get font
|
||||
readFont(getContext());
|
||||
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs,
|
||||
R.styleable.BootstrapButton);
|
||||
|
||||
//defaults
|
||||
BootstrapTypes type = null;
|
||||
String bootstrapType = "default";
|
||||
String iconLeft = "";
|
||||
String iconRight = "";
|
||||
String text = "";
|
||||
//boolean roundedCorners = false;
|
||||
float fontSize = 14.0f;
|
||||
float scale = getResources().getDisplayMetrics().density; //for padding
|
||||
String size = "default";
|
||||
int paddingA = (int) (10 *scale + 0.5f);
|
||||
int paddingB = (int) (15 *scale + 0.5f);
|
||||
|
||||
|
||||
//attribute values
|
||||
|
||||
if (a.getString(R.styleable.BootstrapButton_bb_type) != null) {
|
||||
bootstrapType = a.getString(R.styleable.BootstrapButton_bb_type);
|
||||
}
|
||||
|
||||
if (a.getString(R.styleable.BootstrapButton_bb_roundedCorners) != null) {
|
||||
roundedCorners = a.getBoolean(R.styleable.BootstrapButton_bb_roundedCorners, false) ;
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapButton_bb_size) != null) {
|
||||
size = a.getString(R.styleable.BootstrapButton_bb_size);
|
||||
}
|
||||
|
||||
if ( a.getString(R.styleable.BootstrapButton_bb_icon_left) != null) {
|
||||
iconLeft = a.getString(R.styleable.BootstrapButton_bb_icon_left );
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapButton_bb_icon_right) != null) {
|
||||
iconRight = a.getString(R.styleable.BootstrapButton_bb_icon_right );
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapButton_android_text) != null) {
|
||||
text = a.getString(R.styleable.BootstrapButton_android_text);
|
||||
}
|
||||
String gravity = "";
|
||||
if(a.getString(R.styleable.BootstrapButton_bb_text_gravity) != null) {
|
||||
gravity = a.getString(R.styleable.BootstrapButton_bb_text_gravity);
|
||||
}
|
||||
|
||||
boolean enabled = true;
|
||||
if(a.getString(R.styleable.BootstrapButton_android_enabled) != null) {
|
||||
enabled = a.getBoolean(R.styleable.BootstrapButton_android_enabled, true);
|
||||
}
|
||||
|
||||
int layoutWidth = 0;
|
||||
if(a.getString(R.styleable.BootstrapButton_android_layout_width) != null) {
|
||||
layoutWidth = a.getInt(R.styleable.BootstrapButton_android_layout_width, 0);
|
||||
}
|
||||
|
||||
//works even if it's fill_parent or match_parent
|
||||
if( (layoutWidth == LayoutParams.MATCH_PARENT)) {
|
||||
fillparent = true;
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapButton_android_textSize) != null) {
|
||||
|
||||
//font sizes
|
||||
String xmlProvidedSize = attrs.getAttributeValue(
|
||||
"http://schemas.android.com/apk/res/android", "textSize");
|
||||
final Pattern PATTERN_FONT_SIZE = Pattern
|
||||
.compile("([0-9]+[.]?[0-9]*)sp");
|
||||
Matcher m = PATTERN_FONT_SIZE.matcher(xmlProvidedSize);
|
||||
|
||||
if (m.find()) {
|
||||
|
||||
if (m.groupCount() == 1) {
|
||||
|
||||
fontSize = Float.valueOf(m.group(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
View v = null;
|
||||
if(fillparent){
|
||||
v = inflator.inflate(R.layout.bootstrap_button_fill, null, false);
|
||||
} else {
|
||||
v = inflator.inflate(R.layout.bootstrap_button, null, false);
|
||||
}
|
||||
|
||||
|
||||
//set up font sizes and padding for different button sizes
|
||||
if(size.equals("large")){
|
||||
fontSize = 20.0f;
|
||||
paddingA = (int) (15 *scale + 0.5f);;
|
||||
paddingB = (int) (20 *scale + 0.5f);;
|
||||
}
|
||||
|
||||
if(size.equals("small")){
|
||||
fontSize = 12.0f;
|
||||
paddingA = (int) (5 *scale + 0.5f);;
|
||||
paddingB = (int) (10 *scale + 0.5f);;
|
||||
}
|
||||
|
||||
if(size.equals("xsmall")){
|
||||
fontSize = 10.0f;
|
||||
paddingA = (int) (2 *scale + 0.5f);;
|
||||
paddingB = (int) (5 *scale + 0.5f);;
|
||||
}
|
||||
|
||||
//get layout items
|
||||
layout = (ViewGroup) v.findViewById(R.id.layout);
|
||||
lblLeft = (TextView) v.findViewById(R.id.lblLeft);
|
||||
lblMiddle = (TextView) v.findViewById(R.id.lblMiddle);
|
||||
lblRight = (TextView) v.findViewById(R.id.lblRight);
|
||||
|
||||
//set the background
|
||||
//setBootstrapType(bootstrapType);
|
||||
|
||||
//get the correct background type
|
||||
if(roundedCorners == true)
|
||||
{
|
||||
type = bbuttonTypeMapRounded.get(bootstrapType);
|
||||
} else {
|
||||
type = bbuttonTypeMap.get(bootstrapType);
|
||||
}
|
||||
|
||||
//set up as default
|
||||
if (type == null)
|
||||
{
|
||||
type = BootstrapTypes.DEFAULT;
|
||||
}
|
||||
|
||||
//apply the background type
|
||||
layout.setBackgroundResource(type.backgroundDrawable);
|
||||
lblLeft.setTextColor(getResources().getColor(type.textColour));
|
||||
lblMiddle.setTextColor(getResources().getColor(type.textColour));
|
||||
lblRight.setTextColor(getResources().getColor(type.textColour));
|
||||
|
||||
//set the font awesome icon typeface
|
||||
lblLeft.setTypeface(font);
|
||||
lblRight.setTypeface(font);
|
||||
|
||||
//set up the font size
|
||||
lblLeft.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
|
||||
lblMiddle.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
|
||||
lblRight.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
|
||||
|
||||
//deal with gravity
|
||||
|
||||
if(gravity.length() > 0) {
|
||||
setTextGravity(gravity);
|
||||
}
|
||||
|
||||
|
||||
boolean onlyIcon = true;
|
||||
|
||||
//set the text
|
||||
if(text.length() > 0){
|
||||
lblMiddle.setText(text );
|
||||
lblMiddle.setVisibility(View.VISIBLE);
|
||||
onlyIcon = false;
|
||||
}
|
||||
|
||||
//set up the padding
|
||||
|
||||
if (iconLeft.length() > 0) {
|
||||
//lblLeft.setText(iconLeft);
|
||||
setLeftIcon(iconLeft);
|
||||
lblLeft.setVisibility(View.VISIBLE);
|
||||
|
||||
if (onlyIcon == false){
|
||||
lblLeft.setPadding(paddingB, 0, 0, 0);
|
||||
} else {
|
||||
lblLeft.setPadding(paddingB, 0, paddingB, 0);
|
||||
}
|
||||
|
||||
//padding for symmetry
|
||||
if ( ( iconRight.length() == 0) && onlyIcon == false ) {
|
||||
lblMiddle.setPadding(paddingA, 0, (int) paddingB, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (iconRight.length() > 0) {
|
||||
//lblRight.setText(iconRight);
|
||||
setRightIcon(iconRight);
|
||||
lblRight.setVisibility(View.VISIBLE);
|
||||
|
||||
if (onlyIcon == false){
|
||||
lblRight.setPadding(0, 0, paddingB, 0);
|
||||
}else {
|
||||
lblRight.setPadding(paddingB, 0, paddingB, 0);
|
||||
}
|
||||
|
||||
//padding for symmetry
|
||||
if ( (iconLeft.length() == 0) && onlyIcon == false ) {
|
||||
lblMiddle.setPadding(paddingB, 0, (int) paddingA, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(iconLeft.length() > 0 && iconRight.length() > 0 )
|
||||
{
|
||||
lblMiddle.setPadding(paddingA, 0, paddingA, 0);
|
||||
}
|
||||
this.setClickable(true);
|
||||
|
||||
this.setEnabled(enabled);
|
||||
|
||||
layout.setPadding(0, paddingB, 0, paddingB);
|
||||
|
||||
addView(v);
|
||||
}
|
||||
|
||||
//static class to read in font
|
||||
private static void readFont(Context context)
|
||||
{
|
||||
|
||||
if(font == null){
|
||||
try {
|
||||
font = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
|
||||
} catch (Exception e) {
|
||||
Log.e("BootstrapButton", "Could not get typeface because " + e.getMessage());
|
||||
font = Typeface.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes the button text
|
||||
* @param text - String value for what is displayed on the button
|
||||
*/
|
||||
public void setText(String text) {
|
||||
lblMiddle.setText(text);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes the left icon on a BootstrapButton
|
||||
* @param leftIcon- String value for the icon as per http://fortawesome.github.io/Font-Awesome/cheatsheet/
|
||||
*/
|
||||
public void setLeftIcon(String leftIcon) {
|
||||
|
||||
String icon = faMap.get(leftIcon);
|
||||
|
||||
if (icon == null)
|
||||
{
|
||||
icon = faMap.get(FA_ICON_QUESTION);
|
||||
}
|
||||
|
||||
lblLeft.setText(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the right icon on a BootstrapButton
|
||||
* @param rightIcon - String value for the icon as per http://fortawesome.github.io/Font-Awesome/cheatsheet/
|
||||
*/
|
||||
public void setRightIcon(String rightIcon) {
|
||||
|
||||
String icon = faMap.get(rightIcon);
|
||||
|
||||
if (icon == null)
|
||||
{
|
||||
icon = faMap.get(FA_ICON_QUESTION);
|
||||
}
|
||||
|
||||
lblRight.setText(icon);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the type of BootstrapButton
|
||||
* @param bootstrapType - String value for the type of button e.g. "primary"
|
||||
*/
|
||||
public void setBootstrapType(String bootstrapType) {
|
||||
|
||||
BootstrapTypes type = null;
|
||||
|
||||
//get the correct background type
|
||||
if (roundedCorners == true) {
|
||||
type = bbuttonTypeMapRounded.get(bootstrapType);
|
||||
} else {
|
||||
type = bbuttonTypeMap.get(bootstrapType);
|
||||
}
|
||||
|
||||
//set up as default
|
||||
if (type == null) {
|
||||
type = BootstrapTypes.DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
layout.setBackgroundResource(type.backgroundDrawable);
|
||||
lblLeft.setTextColor(getResources().getColor(type.textColour));
|
||||
lblMiddle.setTextColor(getResources().getColor(type.textColour));
|
||||
lblRight.setTextColor(getResources().getColor(type.textColour));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether the BootstrapButton is enabled or disabled
|
||||
* @param enabled - boolean state for either enabled or disabled
|
||||
*/
|
||||
public void setBootstrapButtonEnabled(boolean enabled)
|
||||
{
|
||||
this.setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes the gravity for the text on a bootstrap button that is not wrap_content
|
||||
* @param gravity - string for either center, right, or left.
|
||||
*/
|
||||
public void setTextGravity(String gravity) {
|
||||
if(gravity.equals("left")) {
|
||||
lblMiddle.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||
} else if (gravity.equals("center")) {
|
||||
lblMiddle.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
|
||||
} else if (gravity.equals("right")) {
|
||||
lblMiddle.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,215 @@
|
||||
package com.beardedhen.androidbootstrap;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.beardedhen.androidbootstrap.utils.ImageUtils;
|
||||
|
||||
public class BootstrapCircleThumbnail extends FrameLayout
|
||||
{
|
||||
private static final int PADDING_SMALL = 4;
|
||||
private static final int PADDING_MEDIUM = 4;
|
||||
private static final int PADDING_LARGE = 6;
|
||||
private static final int PADDING_XLARGE = 8;
|
||||
|
||||
private static final int SIZE_SMALL = 48; //dp total size (outer circle)
|
||||
private static final int SIZE_MEDIUM = 80;//dp
|
||||
private static final int SIZE_LARGE = 112;//dp
|
||||
private static final int SIZE_XLARGE = 176;//dp
|
||||
private static final int SIZE_DEFAULT = SIZE_MEDIUM;
|
||||
|
||||
private static final String SMALL = "small";
|
||||
private static final String MEDIUM = "medium";
|
||||
private static final String LARGE = "large";
|
||||
private static final String XLARGE = "xlarge";
|
||||
|
||||
private LinearLayout container;
|
||||
private LinearLayout placeholder;
|
||||
private ImageView image;
|
||||
private TextView dimensionsLabel;
|
||||
private String size = MEDIUM;
|
||||
private boolean minimal = false;//minimal means display just the image, no padding
|
||||
private String text = "";
|
||||
private int imageWidth = SIZE_DEFAULT;
|
||||
private int imageHeight = SIZE_DEFAULT;
|
||||
private int padding = 0;
|
||||
|
||||
public BootstrapCircleThumbnail(Context context, AttributeSet attrs, int defStyle)
|
||||
{
|
||||
super(context, attrs, defStyle);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public BootstrapCircleThumbnail(Context context, AttributeSet attrs)
|
||||
{
|
||||
super(context, attrs);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public BootstrapCircleThumbnail(Context context)
|
||||
{
|
||||
super(context);
|
||||
initialise(null);
|
||||
}
|
||||
|
||||
private void initialise( AttributeSet attrs )
|
||||
{
|
||||
LayoutInflater inflator = (LayoutInflater)getContext().getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs,
|
||||
R.styleable.BootstrapCircleThumbnail);
|
||||
|
||||
|
||||
int imageDrawable = 0;
|
||||
|
||||
if(a.getString(R.styleable.BootstrapCircleThumbnail_bct_image) != null)
|
||||
{
|
||||
imageDrawable = a.getResourceId(R.styleable.BootstrapCircleThumbnail_bct_image, 0);
|
||||
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapCircleThumbnail_android_text) != null)
|
||||
{
|
||||
text = a.getString(R.styleable.BootstrapCircleThumbnail_android_text);
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapCircleThumbnail_bct_size) != null)
|
||||
{
|
||||
this.size = a.getString(R.styleable.BootstrapCircleThumbnail_bct_size);
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapCircleThumbnail_bct_minimal) != null)
|
||||
{
|
||||
this.minimal = a.getBoolean(R.styleable.BootstrapCircleThumbnail_bct_minimal, false);
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
|
||||
View v = inflator.inflate(R.layout.bootstrap_thumbnail_circle, null, false);
|
||||
dimensionsLabel = (TextView) v.findViewById(R.id.dimensionsLabel);
|
||||
container = (LinearLayout) v.findViewById(R.id.container);
|
||||
placeholder = (LinearLayout) v.findViewById(R.id.placeholder);
|
||||
image = (ImageView) v.findViewById(R.id.image);
|
||||
float scale = getResources().getDisplayMetrics().density;
|
||||
|
||||
|
||||
|
||||
//small image
|
||||
if(this.size.equals(SMALL))
|
||||
{
|
||||
padding = PADDING_SMALL;
|
||||
imageWidth = SIZE_SMALL;
|
||||
imageHeight = SIZE_SMALL;
|
||||
|
||||
}
|
||||
else if(this.size.equals(MEDIUM))
|
||||
{
|
||||
padding = PADDING_MEDIUM;
|
||||
imageWidth = SIZE_MEDIUM;
|
||||
imageHeight = SIZE_MEDIUM;
|
||||
}
|
||||
else if(this.size.equals(LARGE))
|
||||
{
|
||||
padding = PADDING_LARGE;
|
||||
imageWidth = SIZE_LARGE;
|
||||
imageHeight = SIZE_LARGE;
|
||||
}
|
||||
else if(this.size.equals(XLARGE))
|
||||
{
|
||||
padding = PADDING_XLARGE;
|
||||
imageWidth = SIZE_XLARGE;
|
||||
imageHeight = SIZE_XLARGE;
|
||||
}
|
||||
//no valid size is given, set image to default size
|
||||
else
|
||||
{
|
||||
padding = PADDING_MEDIUM;
|
||||
imageWidth = SIZE_DEFAULT;
|
||||
imageHeight = SIZE_DEFAULT;
|
||||
}
|
||||
|
||||
//convert padding to pixels
|
||||
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
||||
int paddingPX = (int)((padding * scale) + 0.5);
|
||||
|
||||
//convert image size to pixels
|
||||
int imageSizeWidthPX = (int)((imageWidth * scale) + 0.5);
|
||||
int imageSizeHeightPX = (int)((imageHeight * scale) + 0.5);
|
||||
|
||||
//make inner image smaller to compensate for the padding so that entire circle including padding equals the size
|
||||
//ex. small image = 48dp, small padding = 4dp, inner image = 48 - (4 * 2) = 40
|
||||
if(this.minimal == false)
|
||||
{
|
||||
imageSizeWidthPX = imageSizeWidthPX - (paddingPX * 2);
|
||||
imageSizeHeightPX = imageSizeHeightPX - (paddingPX * 2);
|
||||
|
||||
this.container.setPadding(paddingPX, paddingPX, paddingPX, paddingPX);
|
||||
container.setBackgroundResource(R.drawable.thumbnail_circle_container);
|
||||
}
|
||||
else
|
||||
{
|
||||
container.setBackgroundResource(R.drawable.thumbnail_circle_minimal);
|
||||
}
|
||||
|
||||
//if no image is given
|
||||
if(imageDrawable == 0)
|
||||
{
|
||||
this.image.setVisibility(View.GONE);
|
||||
placeholder.setLayoutParams(new LinearLayout.LayoutParams(imageSizeWidthPX, imageSizeHeightPX));
|
||||
placeholder.setPadding(paddingPX, paddingPX, paddingPX, paddingPX);
|
||||
|
||||
//set placeholder image
|
||||
placeholder.setBackgroundResource(R.drawable.thumbnail_circle);
|
||||
|
||||
this.dimensionsLabel.setText(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
placeholder.setPadding(0, 0, 0, 0);
|
||||
this.dimensionsLabel.setVisibility(View.GONE);
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(), imageDrawable);
|
||||
|
||||
Bitmap roundBitmap = ImageUtils.getCircleBitmap(bitmap, imageSizeWidthPX, imageSizeHeightPX);
|
||||
image.setImageBitmap(roundBitmap);
|
||||
}
|
||||
|
||||
this.addView(v);
|
||||
}
|
||||
|
||||
public void setImage(int drawable)
|
||||
{
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(), drawable);
|
||||
|
||||
float scale = getResources().getDisplayMetrics().density;
|
||||
|
||||
//convert image size to pixels
|
||||
int widthPX = (int)((this.imageWidth * scale) + 0.5);
|
||||
int heightPX = (int)((this.imageHeight * scale) + 0.5);
|
||||
|
||||
int paddingPX = (int)((this.padding * scale) + 0.5);
|
||||
|
||||
if(this.minimal == false)
|
||||
{
|
||||
widthPX = widthPX - (paddingPX * 2);
|
||||
heightPX = heightPX - (paddingPX * 2);
|
||||
}
|
||||
|
||||
Bitmap roundBitmap = ImageUtils.getCircleBitmap(bitmap, widthPX, heightPX);
|
||||
image.setImageBitmap(roundBitmap);
|
||||
|
||||
invalidate();
|
||||
requestLayout();
|
||||
}
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
package com.beardedhen.androidbootstrap;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class BootstrapEditText extends EditText {
|
||||
|
||||
private boolean roundedCorners = false;
|
||||
|
||||
public BootstrapEditText(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public BootstrapEditText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public BootstrapEditText(Context context) {
|
||||
super(context);
|
||||
initialise(null);
|
||||
}
|
||||
|
||||
public static final String BOOTSTRAP_EDIT_TEXT_DEFAULT = "default";
|
||||
public static final String BOOTSTRAP_EDIT_TEXT_SUCCESS = "success";
|
||||
public static final String BOOTSTRAP_EDIT_TEXT_WARNING = "warning";
|
||||
public static final String BOOTSTRAP_EDIT_TEXT_DANGER = "danger";
|
||||
|
||||
|
||||
private void initialise( AttributeSet attrs )
|
||||
{
|
||||
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapEditText);
|
||||
|
||||
//get defaults
|
||||
float fontSize = 14.0f;
|
||||
String state = "default";
|
||||
String text = "";
|
||||
String hint = "";
|
||||
boolean enabled = true;
|
||||
|
||||
//font size
|
||||
if (a.getString(R.styleable.BootstrapEditText_android_textSize) != null) {
|
||||
|
||||
String xmlProvidedSize = attrs.getAttributeValue( "http://schemas.android.com/apk/res/android", "textSize");
|
||||
final Pattern PATTERN_FONT_SIZE = Pattern
|
||||
.compile("([0-9]+[.]?[0-9]*)sp");
|
||||
Matcher m = PATTERN_FONT_SIZE.matcher(xmlProvidedSize);
|
||||
|
||||
if (m.find()) {
|
||||
if (m.groupCount() == 1) {
|
||||
fontSize = Float.valueOf(m.group(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//rounded corners
|
||||
if(a.getString(R.styleable.BootstrapEditText_be_roundedCorners) != null) {
|
||||
roundedCorners = a.getBoolean(R.styleable.BootstrapEditText_be_roundedCorners, false);
|
||||
}
|
||||
|
||||
//state
|
||||
if(a.getString(R.styleable.BootstrapEditText_be_state) != null) {
|
||||
state = a.getString(R.styleable.BootstrapEditText_be_state);
|
||||
}
|
||||
|
||||
//text
|
||||
if(a.getString(R.styleable.BootstrapEditText_android_text) != null) {
|
||||
text = a.getString(R.styleable.BootstrapEditText_android_text);
|
||||
}
|
||||
|
||||
//hint
|
||||
if(a.getString(R.styleable.BootstrapEditText_android_hint) != null) {
|
||||
hint = a.getString(R.styleable.BootstrapEditText_android_hint);
|
||||
}
|
||||
|
||||
//enabled
|
||||
if(a.getString(R.styleable.BootstrapEditText_android_enabled) != null) {
|
||||
enabled = a.getBoolean(R.styleable.BootstrapEditText_android_enabled, true);
|
||||
}
|
||||
|
||||
//set values
|
||||
this.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
|
||||
this.setText(text);
|
||||
this.setHint(hint);
|
||||
this.setEnabled(enabled);
|
||||
|
||||
if (enabled){
|
||||
//work out the right background
|
||||
setBackgroundDrawable(state);
|
||||
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
|
||||
//addView(editTextView);
|
||||
}
|
||||
|
||||
|
||||
private void setBackgroundDrawable(String state)
|
||||
{
|
||||
if(roundedCorners){
|
||||
this.setBackgroundResource(R.drawable.edittext_background_rounded);
|
||||
} else {
|
||||
this.setBackgroundResource(R.drawable.edittext_background);
|
||||
}
|
||||
|
||||
if(roundedCorners){
|
||||
|
||||
if (state.equals(BOOTSTRAP_EDIT_TEXT_SUCCESS)){
|
||||
this.setBackgroundResource(R.drawable.edittext_background_rounded_success);
|
||||
} else if (state.equals(BOOTSTRAP_EDIT_TEXT_WARNING)){
|
||||
this.setBackgroundResource(R.drawable.edittext_background_rounded_warning);
|
||||
} else if (state.equals(BOOTSTRAP_EDIT_TEXT_DANGER)){
|
||||
this.setBackgroundResource(R.drawable.edittext_background_rounded_danger);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (state.equals(BOOTSTRAP_EDIT_TEXT_SUCCESS)){
|
||||
this.setBackgroundResource(R.drawable.edittext_background_success);
|
||||
} else if (state.equals(BOOTSTRAP_EDIT_TEXT_WARNING)){
|
||||
this.setBackgroundResource(R.drawable.edittext_background_warning);
|
||||
} else if (state.equals(BOOTSTRAP_EDIT_TEXT_DANGER)){
|
||||
this.setBackgroundResource(R.drawable.edittext_background_danger);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the BootstrapEditTextState
|
||||
* @param state
|
||||
*/
|
||||
public void setState(String state){
|
||||
setBackgroundDrawable(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BootstrapEditText to a successful state
|
||||
*/
|
||||
public void setSuccess()
|
||||
{
|
||||
setBackgroundDrawable(BOOTSTRAP_EDIT_TEXT_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BootstrapEditText to a warning state
|
||||
*/
|
||||
public void setWarning()
|
||||
{
|
||||
setBackgroundDrawable(BOOTSTRAP_EDIT_TEXT_WARNING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BootstrapEditText to a danger state
|
||||
*/
|
||||
public void setDanger()
|
||||
{
|
||||
setBackgroundDrawable(BOOTSTRAP_EDIT_TEXT_DANGER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BootstrapEditText to a default state
|
||||
*/
|
||||
public void setDefault()
|
||||
{
|
||||
setBackgroundDrawable(BOOTSTRAP_EDIT_TEXT_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether the BootstrapEditText is enabled or disabled
|
||||
* @param enabled - boolean state for either enabled or disabled
|
||||
*/
|
||||
public void setBootstrapEditTextEnabled(boolean enabled)
|
||||
{
|
||||
this.setEnabled(enabled);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,209 @@
|
||||
package com.beardedhen.androidbootstrap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class BootstrapThumbnail extends FrameLayout
|
||||
{
|
||||
private static final int DEFAULT_WIDTH = 150; //width of thumbnail when no width is given
|
||||
private static final int DEFAULT_HEIGHT = 150;//height of thumbnail when no height is given
|
||||
private static final int DEFAULT_MAX_PADDING = 8; //8dp is max padding size when padding isn't specified by user
|
||||
private static final int DEFAULT_MIN_PADDING = 4; //4dp
|
||||
private static final String DEFAULT_TYPE = "rounded";
|
||||
|
||||
private static Map<String, ThumbnailTypes> bThumbnailTypeMap;
|
||||
private static Typeface font;
|
||||
private ViewGroup container;
|
||||
private LinearLayout placeholder;
|
||||
private TextView dimensionsLabel;
|
||||
private boolean roundedCorners = true;
|
||||
|
||||
static{
|
||||
bThumbnailTypeMap = new HashMap<String, ThumbnailTypes>();
|
||||
|
||||
bThumbnailTypeMap.put("rounded", ThumbnailTypes.ROUNDED);//default is rounded if user doesn't specify to use square
|
||||
bThumbnailTypeMap.put("square", ThumbnailTypes.SQUARE);
|
||||
}
|
||||
|
||||
public BootstrapThumbnail(Context context, AttributeSet attrs, int defStyle)
|
||||
{
|
||||
super(context, attrs, defStyle);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public BootstrapThumbnail(Context context, AttributeSet attrs)
|
||||
{
|
||||
super(context, attrs);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public BootstrapThumbnail(Context context)
|
||||
{
|
||||
super(context);
|
||||
initialise(null);
|
||||
}
|
||||
|
||||
public void setImage(int drawable)
|
||||
{
|
||||
this.placeholder.setBackgroundResource(drawable);
|
||||
invalidate();
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
//set up the bootstrap types
|
||||
private enum ThumbnailTypes
|
||||
{
|
||||
ROUNDED(R.drawable.bthumbnail_container_rounded, R.drawable.bthumbnail_placeholder_default),
|
||||
SQUARE(R.drawable.bthumbnail_container_square, R.drawable.bthumbnail_placeholder_default);
|
||||
|
||||
private int containerDrawable;
|
||||
private int placeholderDrawable;
|
||||
|
||||
ThumbnailTypes(int containerDrawable, int placeholderDrawable)
|
||||
{
|
||||
this.containerDrawable = containerDrawable;
|
||||
this.placeholderDrawable = placeholderDrawable;
|
||||
}
|
||||
}
|
||||
|
||||
private void initialise( AttributeSet attrs )
|
||||
{
|
||||
LayoutInflater inflator = (LayoutInflater)getContext().getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
readFont(getContext());
|
||||
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs,
|
||||
R.styleable.BootstrapThumbnail);
|
||||
|
||||
//defaults
|
||||
ThumbnailTypes type = null;
|
||||
String thumbnailType = DEFAULT_TYPE;
|
||||
String text = "";
|
||||
int imageDrawable = 0;
|
||||
float scale = getResources().getDisplayMetrics().density; //for padding
|
||||
int width = DEFAULT_WIDTH;
|
||||
int height = DEFAULT_HEIGHT;
|
||||
int padding = 0;
|
||||
int paddingDP = 0;
|
||||
|
||||
//attribute values
|
||||
if(a.getString(R.styleable.BootstrapThumbnail_bt_width) != null) {
|
||||
width = (int) a.getDimension(R.styleable.BootstrapThumbnail_bt_width, 0);
|
||||
Log.v("width", Integer.toString(width));
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapThumbnail_bt_height) != null) {
|
||||
height = (int) a.getDimension(R.styleable.BootstrapThumbnail_bt_height, 0);
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapThumbnail_bt_inside_padding) != null) {
|
||||
paddingDP = (int) a.getDimension(R.styleable.BootstrapThumbnail_bt_inside_padding, 0);
|
||||
}
|
||||
else{
|
||||
padding = (int) (((Math.sqrt(width * height)) / 100) * 2);
|
||||
if(padding > DEFAULT_MAX_PADDING)
|
||||
padding = DEFAULT_MAX_PADDING;
|
||||
if(padding < DEFAULT_MIN_PADDING)
|
||||
padding = DEFAULT_MIN_PADDING;
|
||||
|
||||
paddingDP = (int) (padding * scale + 0.5f);//container padding in DP
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapThumbnail_bt_roundedCorners) != null){
|
||||
roundedCorners = a.getBoolean(R.styleable.BootstrapThumbnail_bt_roundedCorners, false) ;
|
||||
}
|
||||
|
||||
if(a.getString(R.styleable.BootstrapThumbnail_bt_image) != null){
|
||||
imageDrawable = a.getResourceId(R.styleable.BootstrapThumbnail_bt_image, 0);
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
|
||||
text = (int)(width/scale) + "x" + (int)(height/scale);
|
||||
View v = inflator.inflate(R.layout.bootstrap_thumbnail, null, false);
|
||||
|
||||
//get layout items
|
||||
container = (ViewGroup) v.findViewById(R.id.container);
|
||||
placeholder = (LinearLayout) v.findViewById(R.id.placeholder);
|
||||
dimensionsLabel = (TextView) v.findViewById(R.id.dimensionsLabel);
|
||||
|
||||
Log.v("size", "width:" + width + " height:" + height);
|
||||
|
||||
|
||||
type = bThumbnailTypeMap.get(thumbnailType);
|
||||
|
||||
//get the correct background type
|
||||
if(roundedCorners == true)
|
||||
{
|
||||
type = bThumbnailTypeMap.get("rounded");
|
||||
} else {
|
||||
type = bThumbnailTypeMap.get("square");
|
||||
}
|
||||
|
||||
//apply the background type
|
||||
container.setBackgroundResource(type.containerDrawable);
|
||||
|
||||
//if no image is provided by user
|
||||
if(imageDrawable == 0){
|
||||
//set default grey placeholder background
|
||||
placeholder.setBackgroundResource(type.placeholderDrawable);
|
||||
|
||||
//set the text
|
||||
if(text.length() > 0){
|
||||
dimensionsLabel.setText(text);
|
||||
dimensionsLabel.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//set background to user's provided image
|
||||
placeholder.setBackgroundResource(imageDrawable);
|
||||
|
||||
//remove textview dimensions
|
||||
dimensionsLabel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//placeholder padding
|
||||
int paddingP = (int) (((Math.sqrt(width * height)) / 100) * 4);
|
||||
|
||||
//convert to DP
|
||||
int paddingDPP = (int) (paddingP * scale + 0.5f);//placeholder padding in DP
|
||||
|
||||
container.setPadding(paddingDP, paddingDP, paddingDP, paddingDP);
|
||||
placeholder.setPadding(paddingDPP, paddingDPP, paddingDPP, paddingDPP);
|
||||
|
||||
placeholder.setLayoutParams(new LinearLayout.LayoutParams(width,height));
|
||||
|
||||
//set the font awesome icon typeface
|
||||
dimensionsLabel.setTypeface(font);
|
||||
|
||||
this.setClickable(true);
|
||||
|
||||
addView(v);
|
||||
}
|
||||
|
||||
//static class to read in font
|
||||
private static void readFont(Context context)
|
||||
{
|
||||
if(font == null){
|
||||
try {
|
||||
font = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
|
||||
} catch (Exception e) {
|
||||
Log.e("BootstrapButton", "Could not get typeface because " + e.getMessage());
|
||||
font = Typeface.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,390 @@
|
||||
package com.beardedhen.androidbootstrap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FontAwesome {
|
||||
|
||||
private static Map<String, String> faMap = new HashMap<String, String>();
|
||||
|
||||
//font awesome map as per
|
||||
//http://fortawesome.github.io/Font-Awesome/cheatsheet/
|
||||
|
||||
static {
|
||||
faMap.put("fa-glass", "\uf000");
|
||||
faMap.put("fa-music", "\uf001");
|
||||
faMap.put("fa-search", "\uf002");
|
||||
faMap.put("fa-envelope-o", "\uf003");
|
||||
faMap.put("fa-heart", "\uf004");
|
||||
faMap.put("fa-star", "\uf005");
|
||||
faMap.put("fa-star-o", "\uf006");
|
||||
faMap.put("fa-user", "\uf007");
|
||||
faMap.put("fa-film", "\uf008");
|
||||
faMap.put("fa-th-large", "\uf009");
|
||||
faMap.put("fa-th", "\uf00a");
|
||||
faMap.put("fa-th-list", "\uf00b");
|
||||
faMap.put("fa-check", "\uf00c");
|
||||
faMap.put("fa-times", "\uf00d");
|
||||
faMap.put("fa-search-plus", "\uf00e");
|
||||
faMap.put("fa-search-minus", "\uf010");
|
||||
faMap.put("fa-power-off", "\uf011");
|
||||
faMap.put("fa-signal", "\uf012");
|
||||
faMap.put("fa-cog", "\uf013");
|
||||
faMap.put("fa-trash-o", "\uf014");
|
||||
faMap.put("fa-home", "\uf015");
|
||||
faMap.put("fa-file-o", "\uf016");
|
||||
faMap.put("fa-clock-o", "\uf017");
|
||||
faMap.put("fa-road", "\uf018");
|
||||
faMap.put("fa-download", "\uf019");
|
||||
faMap.put("fa-arrow-circle-o-down", "\uf01a");
|
||||
faMap.put("fa-arrow-circle-o-up", "\uf01b");
|
||||
faMap.put("fa-inbox", "\uf01c");
|
||||
faMap.put("fa-play-circle-o", "\uf01d");
|
||||
faMap.put("fa-repeat", "\uf01e");
|
||||
faMap.put("fa-refresh", "\uf021");
|
||||
faMap.put("fa-list-alt", "\uf022");
|
||||
faMap.put("fa-lock", "\uf023");
|
||||
faMap.put("fa-flag", "\uf024");
|
||||
faMap.put("fa-headphones", "\uf025");
|
||||
faMap.put("fa-volume-off", "\uf026");
|
||||
faMap.put("fa-volume-down", "\uf027");
|
||||
faMap.put("fa-volume-up", "\uf028");
|
||||
faMap.put("fa-qrcode", "\uf029");
|
||||
faMap.put("fa-barcode", "\uf02a");
|
||||
faMap.put("fa-tag", "\uf02b");
|
||||
faMap.put("fa-tags", "\uf02c");
|
||||
faMap.put("fa-book", "\uf02d");
|
||||
faMap.put("fa-bookmark", "\uf02e");
|
||||
faMap.put("fa-print", "\uf02f");
|
||||
faMap.put("fa-camera", "\uf030");
|
||||
faMap.put("fa-font", "\uf031");
|
||||
faMap.put("fa-bold", "\uf032");
|
||||
faMap.put("fa-italic", "\uf033");
|
||||
faMap.put("fa-text-height", "\uf034");
|
||||
faMap.put("fa-text-width", "\uf035");
|
||||
faMap.put("fa-align-left", "\uf036");
|
||||
faMap.put("fa-align-center", "\uf037");
|
||||
faMap.put("fa-align-right", "\uf038");
|
||||
faMap.put("fa-align-justify", "\uf039");
|
||||
faMap.put("fa-list", "\uf03a");
|
||||
faMap.put("fa-outdent", "\uf03b");
|
||||
faMap.put("fa-indent", "\uf03c");
|
||||
faMap.put("fa-video-camera", "\uf03d");
|
||||
faMap.put("fa-picture-o", "\uf03e");
|
||||
faMap.put("fa-pencil", "\uf040");
|
||||
faMap.put("fa-map-marker", "\uf041");
|
||||
faMap.put("fa-adjust", "\uf042");
|
||||
faMap.put("fa-tint", "\uf043");
|
||||
faMap.put("fa-pencil-square-o", "\uf044");
|
||||
faMap.put("fa-share-square-o", "\uf045");
|
||||
faMap.put("fa-check-square-o", "\uf046");
|
||||
faMap.put("fa-move", "\uf047");
|
||||
faMap.put("fa-step-backward", "\uf048");
|
||||
faMap.put("fa-fast-backward", "\uf049");
|
||||
faMap.put("fa-backward", "\uf04a");
|
||||
faMap.put("fa-play", "\uf04b");
|
||||
faMap.put("fa-pause", "\uf04c");
|
||||
faMap.put("fa-stop", "\uf04d");
|
||||
faMap.put("fa-forward", "\uf04e");
|
||||
faMap.put("fa-fast-forward", "\uf050");
|
||||
faMap.put("fa-step-forward", "\uf051");
|
||||
faMap.put("fa-eject", "\uf052");
|
||||
faMap.put("fa-chevron-left", "\uf053");
|
||||
faMap.put("fa-chevron-right", "\uf054");
|
||||
faMap.put("fa-plus-circle", "\uf055");
|
||||
faMap.put("fa-minus-circle", "\uf056");
|
||||
faMap.put("fa-times-circle", "\uf057");
|
||||
faMap.put("fa-check-circle", "\uf058");
|
||||
faMap.put("fa-question-circle", "\uf059");
|
||||
faMap.put("fa-info-circle", "\uf05a");
|
||||
faMap.put("fa-crosshairs", "\uf05b");
|
||||
faMap.put("fa-times-circle-o", "\uf05c");
|
||||
faMap.put("fa-check-circle-o", "\uf05d");
|
||||
faMap.put("fa-ban", "\uf05e");
|
||||
faMap.put("fa-arrow-left", "\uf060");
|
||||
faMap.put("fa-arrow-right", "\uf061");
|
||||
faMap.put("fa-arrow-up", "\uf062");
|
||||
faMap.put("fa-arrow-down", "\uf063");
|
||||
faMap.put("fa-share", "\uf064");
|
||||
faMap.put("fa-resize-full", "\uf065");
|
||||
faMap.put("fa-resize-small", "\uf066");
|
||||
faMap.put("fa-plus", "\uf067");
|
||||
faMap.put("fa-minus", "\uf068");
|
||||
faMap.put("fa-asterisk", "\uf069");
|
||||
faMap.put("fa-exclamation-circle", "\uf06a");
|
||||
faMap.put("fa-gift", "\uf06b");
|
||||
faMap.put("fa-leaf", "\uf06c");
|
||||
faMap.put("fa-fire", "\uf06d");
|
||||
faMap.put("fa-eye", "\uf06e");
|
||||
faMap.put("fa-eye-slash", "\uf070");
|
||||
faMap.put("fa-exclamation-triangle", "\uf071");
|
||||
faMap.put("fa-plane", "\uf072");
|
||||
faMap.put("fa-calendar", "\uf073");
|
||||
faMap.put("fa-random", "\uf074");
|
||||
faMap.put("fa-comment", "\uf075");
|
||||
faMap.put("fa-magnet", "\uf076");
|
||||
faMap.put("fa-chevron-up", "\uf077");
|
||||
faMap.put("fa-chevron-down", "\uf078");
|
||||
faMap.put("fa-retweet", "\uf079");
|
||||
faMap.put("fa-shopping-cart", "\uf07a");
|
||||
faMap.put("fa-folder", "\uf07b");
|
||||
faMap.put("fa-folder-open", "\uf07c");
|
||||
faMap.put("fa-resize-vertical", "\uf07d");
|
||||
faMap.put("fa-resize-horizontal", "\uf07e");
|
||||
faMap.put("fa-bar-chart-o", "\uf080");
|
||||
faMap.put("fa-twitter-square", "\uf081");
|
||||
faMap.put("fa-facebook-square", "\uf082");
|
||||
faMap.put("fa-camera-retro", "\uf083");
|
||||
faMap.put("fa-key", "\uf084");
|
||||
faMap.put("fa-cogs", "\uf085");
|
||||
faMap.put("fa-comments", "\uf086");
|
||||
faMap.put("fa-thumbs-o-up", "\uf087");
|
||||
faMap.put("fa-thumbs-o-down", "\uf088");
|
||||
faMap.put("fa-star-half", "\uf089");
|
||||
faMap.put("fa-heart-o", "\uf08a");
|
||||
faMap.put("fa-sign-out", "\uf08b");
|
||||
faMap.put("fa-linkedin-square", "\uf08c");
|
||||
faMap.put("fa-thumb-tack", "\uf08d");
|
||||
faMap.put("fa-external-link", "\uf08e");
|
||||
faMap.put("fa-sign-in", "\uf090");
|
||||
faMap.put("fa-trophy", "\uf091");
|
||||
faMap.put("fa-github-square", "\uf092");
|
||||
faMap.put("fa-upload", "\uf093");
|
||||
faMap.put("fa-lemon-o", "\uf094");
|
||||
faMap.put("fa-phone", "\uf095");
|
||||
faMap.put("fa-square-o", "\uf096");
|
||||
faMap.put("fa-bookmark-o", "\uf097");
|
||||
faMap.put("fa-phone-square", "\uf098");
|
||||
faMap.put("fa-twitter", "\uf099");
|
||||
faMap.put("fa-facebook", "\uf09a");
|
||||
faMap.put("fa-github", "\uf09b");
|
||||
faMap.put("fa-unlock", "\uf09c");
|
||||
faMap.put("fa-credit-card", "\uf09d");
|
||||
faMap.put("fa-rss", "\uf09e");
|
||||
faMap.put("fa-hdd", "\uf0a0");
|
||||
faMap.put("fa-bullhorn", "\uf0a1");
|
||||
faMap.put("fa-bell", "\uf0f3");
|
||||
faMap.put("fa-certificate", "\uf0a3");
|
||||
faMap.put("fa-hand-o-right", "\uf0a4");
|
||||
faMap.put("fa-hand-o-left", "\uf0a5");
|
||||
faMap.put("fa-hand-o-up", "\uf0a6");
|
||||
faMap.put("fa-hand-o-down", "\uf0a7");
|
||||
faMap.put("fa-arrow-circle-left", "\uf0a8");
|
||||
faMap.put("fa-arrow-circle-right", "\uf0a9");
|
||||
faMap.put("fa-arrow-circle-up", "\uf0aa");
|
||||
faMap.put("fa-arrow-circle-down", "\uf0ab");
|
||||
faMap.put("fa-globe", "\uf0ac");
|
||||
faMap.put("fa-wrench", "\uf0ad");
|
||||
faMap.put("fa-tasks", "\uf0ae");
|
||||
faMap.put("fa-filter", "\uf0b0");
|
||||
faMap.put("fa-briefcase", "\uf0b1");
|
||||
faMap.put("fa-fullscreen", "\uf0b2");
|
||||
faMap.put("fa-group", "\uf0c0");
|
||||
faMap.put("fa-link", "\uf0c1");
|
||||
faMap.put("fa-cloud", "\uf0c2");
|
||||
faMap.put("fa-flask", "\uf0c3");
|
||||
faMap.put("fa-scissors", "\uf0c4");
|
||||
faMap.put("fa-files-o", "\uf0c5");
|
||||
faMap.put("fa-paperclip", "\uf0c6");
|
||||
faMap.put("fa-floppy-o", "\uf0c7");
|
||||
faMap.put("fa-square", "\uf0c8");
|
||||
faMap.put("fa-reorder", "\uf0c9");
|
||||
faMap.put("fa-list-ul", "\uf0ca");
|
||||
faMap.put("fa-list-ol", "\uf0cb");
|
||||
faMap.put("fa-strikethrough", "\uf0cc");
|
||||
faMap.put("fa-underline", "\uf0cd");
|
||||
faMap.put("fa-table", "\uf0ce");
|
||||
faMap.put("fa-magic", "\uf0d0");
|
||||
faMap.put("fa-truck", "\uf0d1");
|
||||
faMap.put("fa-pinterest", "\uf0d2");
|
||||
faMap.put("fa-pinterest-square", "\uf0d3");
|
||||
faMap.put("fa-google-plus-square", "\uf0d4");
|
||||
faMap.put("fa-google-plus", "\uf0d5");
|
||||
faMap.put("fa-money", "\uf0d6");
|
||||
faMap.put("fa-caret-down", "\uf0d7");
|
||||
faMap.put("fa-caret-up", "\uf0d8");
|
||||
faMap.put("fa-caret-left", "\uf0d9");
|
||||
faMap.put("fa-caret-right", "\uf0da");
|
||||
faMap.put("fa-columns", "\uf0db");
|
||||
faMap.put("fa-sort", "\uf0dc");
|
||||
faMap.put("fa-sort-asc", "\uf0dd");
|
||||
faMap.put("fa-sort-desc", "\uf0de");
|
||||
faMap.put("fa-envelope", "\uf0e0");
|
||||
faMap.put("fa-linkedin", "\uf0e1");
|
||||
faMap.put("fa-undo", "\uf0e2");
|
||||
faMap.put("fa-gavel", "\uf0e3");
|
||||
faMap.put("fa-tachometer", "\uf0e4");
|
||||
faMap.put("fa-comment-o", "\uf0e5");
|
||||
faMap.put("fa-comments-o", "\uf0e6");
|
||||
faMap.put("fa-bolt", "\uf0e7");
|
||||
faMap.put("fa-sitemap", "\uf0e8");
|
||||
faMap.put("fa-umbrella", "\uf0e9");
|
||||
faMap.put("fa-clipboard", "\uf0ea");
|
||||
faMap.put("fa-lightbulb-o", "\uf0eb");
|
||||
faMap.put("fa-exchange", "\uf0ec");
|
||||
faMap.put("fa-cloud-download", "\uf0ed");
|
||||
faMap.put("fa-cloud-upload", "\uf0ee");
|
||||
faMap.put("fa-user-md", "\uf0f0");
|
||||
faMap.put("fa-stethoscope", "\uf0f1");
|
||||
faMap.put("fa-suitcase", "\uf0f2");
|
||||
faMap.put("fa-bell-o", "\uf0a2");
|
||||
faMap.put("fa-coffee", "\uf0f4");
|
||||
faMap.put("fa-cutlery", "\uf0f5");
|
||||
faMap.put("fa-file-text-o", "\uf0f6");
|
||||
faMap.put("fa-building", "\uf0f7");
|
||||
faMap.put("fa-hospital", "\uf0f8");
|
||||
faMap.put("fa-ambulance", "\uf0f9");
|
||||
faMap.put("fa-medkit", "\uf0fa");
|
||||
faMap.put("fa-fighter-jet", "\uf0fb");
|
||||
faMap.put("fa-beer", "\uf0fc");
|
||||
faMap.put("fa-h-square", "\uf0fd");
|
||||
faMap.put("fa-plus-square", "\uf0fe");
|
||||
faMap.put("fa-angle-double-left", "\uf100");
|
||||
faMap.put("fa-angle-double-right", "\uf101");
|
||||
faMap.put("fa-angle-double-up", "\uf102");
|
||||
faMap.put("fa-angle-double-down", "\uf103");
|
||||
faMap.put("fa-angle-left", "\uf104");
|
||||
faMap.put("fa-angle-right", "\uf105");
|
||||
faMap.put("fa-angle-up", "\uf106");
|
||||
faMap.put("fa-angle-down", "\uf107");
|
||||
faMap.put("fa-desktop", "\uf108");
|
||||
faMap.put("fa-laptop", "\uf109");
|
||||
faMap.put("fa-tablet", "\uf10a");
|
||||
faMap.put("fa-mobile", "\uf10b");
|
||||
faMap.put("fa-circle-o", "\uf10c");
|
||||
faMap.put("fa-quote-left", "\uf10d");
|
||||
faMap.put("fa-quote-right", "\uf10e");
|
||||
faMap.put("fa-spinner", "\uf110");
|
||||
faMap.put("fa-circle", "\uf111");
|
||||
faMap.put("fa-reply", "\uf112");
|
||||
faMap.put("fa-github-alt", "\uf113");
|
||||
faMap.put("fa-folder-o", "\uf114");
|
||||
faMap.put("fa-folder-open-o", "\uf115");
|
||||
faMap.put("fa-expand-o", "\uf116");
|
||||
faMap.put("fa-collapse-o", "\uf117");
|
||||
faMap.put("fa-smile-o", "\uf118");
|
||||
faMap.put("fa-frown-o", "\uf119");
|
||||
faMap.put("fa-meh-o", "\uf11a");
|
||||
faMap.put("fa-gamepad", "\uf11b");
|
||||
faMap.put("fa-keyboard-o", "\uf11c");
|
||||
faMap.put("fa-flag-o", "\uf11d");
|
||||
faMap.put("fa-flag-checkered", "\uf11e");
|
||||
faMap.put("fa-terminal", "\uf120");
|
||||
faMap.put("fa-code", "\uf121");
|
||||
faMap.put("fa-reply-all", "\uf122");
|
||||
faMap.put("fa-mail-reply-all", "\uf122");
|
||||
faMap.put("fa-star-half-o", "\uf123");
|
||||
faMap.put("fa-location-arrow", "\uf124");
|
||||
faMap.put("fa-crop", "\uf125");
|
||||
faMap.put("fa-code-fork", "\uf126");
|
||||
faMap.put("fa-chain-broken", "\uf127");
|
||||
faMap.put("fa-question", "\uf128");
|
||||
faMap.put("fa-info", "\uf129");
|
||||
faMap.put("fa-exclamation", "\uf12a");
|
||||
faMap.put("fa-superscript", "\uf12b");
|
||||
faMap.put("fa-subscript", "\uf12c");
|
||||
faMap.put("fa-eraser", "\uf12d");
|
||||
faMap.put("fa-puzzle-piece", "\uf12e");
|
||||
faMap.put("fa-microphone", "\uf130");
|
||||
faMap.put("fa-microphone-slash", "\uf131");
|
||||
faMap.put("fa-shield", "\uf132");
|
||||
faMap.put("fa-calendar-o", "\uf133");
|
||||
faMap.put("fa-fire-extinguisher", "\uf134");
|
||||
faMap.put("fa-rocket", "\uf135");
|
||||
faMap.put("fa-maxcdn", "\uf136");
|
||||
faMap.put("fa-chevron-circle-left", "\uf137");
|
||||
faMap.put("fa-chevron-circle-right", "\uf138");
|
||||
faMap.put("fa-chevron-circle-up", "\uf139");
|
||||
faMap.put("fa-chevron-circle-down", "\uf13a");
|
||||
faMap.put("fa-html5", "\uf13b");
|
||||
faMap.put("fa-css3", "\uf13c");
|
||||
faMap.put("fa-anchor", "\uf13d");
|
||||
faMap.put("fa-unlock-o", "\uf13e");
|
||||
faMap.put("fa-bullseye", "\uf140");
|
||||
faMap.put("fa-ellipsis-horizontal", "\uf141");
|
||||
faMap.put("fa-ellipsis-vertical", "\uf142");
|
||||
faMap.put("fa-rss-square", "\uf143");
|
||||
faMap.put("fa-play-circle", "\uf144");
|
||||
faMap.put("fa-ticket", "\uf145");
|
||||
faMap.put("fa-minus-square", "\uf146");
|
||||
faMap.put("fa-minus-square-o", "\uf147");
|
||||
faMap.put("fa-level-up", "\uf148");
|
||||
faMap.put("fa-level-down", "\uf149");
|
||||
faMap.put("fa-check-square", "\uf14a");
|
||||
faMap.put("fa-pencil-square", "\uf14b");
|
||||
faMap.put("fa-external-link-square", "\uf14c");
|
||||
faMap.put("fa-share-square", "\uf14d");
|
||||
faMap.put("fa-compass", "\uf14e");
|
||||
faMap.put("fa-caret-square-o-down", "\uf150");
|
||||
faMap.put("fa-caret-square-o-up", "\uf151");
|
||||
faMap.put("fa-caret-square-o-right", "\uf152");
|
||||
faMap.put("fa-eur", "\uf153");
|
||||
faMap.put("fa-gbp", "\uf154");
|
||||
faMap.put("fa-usd", "\uf155");
|
||||
faMap.put("fa-inr", "\uf156");
|
||||
faMap.put("fa-jpy", "\uf157");
|
||||
faMap.put("fa-rub", "\uf158");
|
||||
faMap.put("fa-krw", "\uf159");
|
||||
faMap.put("fa-btc", "\uf15a");
|
||||
faMap.put("fa-file", "\uf15b");
|
||||
faMap.put("fa-file-text", "\uf15c");
|
||||
faMap.put("fa-sort-alpha-asc", "\uf15d");
|
||||
faMap.put("fa-sort-alpha-desc", "\uf15e");
|
||||
faMap.put("fa-sort-amount-asc", "\uf160");
|
||||
faMap.put("fa-sort-amount-desc", "\uf161");
|
||||
faMap.put("fa-sort-numeric-asc", "\uf162");
|
||||
faMap.put("fa-sort-numeric-desc", "\uf163");
|
||||
faMap.put("fa-thumbs-up", "\uf164");
|
||||
faMap.put("fa-thumbs-down", "\uf165");
|
||||
faMap.put("fa-youtube-square", "\uf166");
|
||||
faMap.put("fa-youtube", "\uf167");
|
||||
faMap.put("fa-xing", "\uf168");
|
||||
faMap.put("fa-xing-square", "\uf169");
|
||||
faMap.put("fa-youtube-play", "\uf16a");
|
||||
faMap.put("fa-dropbox", "\uf16b");
|
||||
faMap.put("fa-stack-overflow", "\uf16c");
|
||||
faMap.put("fa-instagram", "\uf16d");
|
||||
faMap.put("fa-flickr", "\uf16e");
|
||||
faMap.put("fa-adn", "\uf170");
|
||||
faMap.put("fa-bitbucket", "\uf171");
|
||||
faMap.put("fa-bitbucket-square", "\uf172");
|
||||
faMap.put("fa-tumblr", "\uf173");
|
||||
faMap.put("fa-tumblr-square", "\uf174");
|
||||
faMap.put("fa-long-arrow-down", "\uf175");
|
||||
faMap.put("fa-long-arrow-up", "\uf176");
|
||||
faMap.put("fa-long-arrow-left", "\uf177");
|
||||
faMap.put("fa-long-arrow-right", "\uf178");
|
||||
faMap.put("fa-apple", "\uf179");
|
||||
faMap.put("fa-windows", "\uf17a");
|
||||
faMap.put("fa-android", "\uf17b");
|
||||
faMap.put("fa-linux", "\uf17c");
|
||||
faMap.put("fa-dribbble", "\uf17d");
|
||||
faMap.put("fa-skype", "\uf17e");
|
||||
faMap.put("fa-foursquare", "\uf180");
|
||||
faMap.put("fa-trello", "\uf181");
|
||||
faMap.put("fa-female", "\uf182");
|
||||
faMap.put("fa-male", "\uf183");
|
||||
faMap.put("fa-gittip", "\uf184");
|
||||
faMap.put("fa-sun-o", "\uf185");
|
||||
faMap.put("fa-moon-o", "\uf186");
|
||||
faMap.put("fa-archive", "\uf187");
|
||||
faMap.put("fa-bug", "\uf188");
|
||||
faMap.put("fa-vk", "\uf189");
|
||||
faMap.put("fa-weibo", "\uf18a");
|
||||
faMap.put("fa-renren", "\uf18b");
|
||||
faMap.put("fa-pagelines", "\uf18c");
|
||||
faMap.put("fa-stack-exchange", "\uf18d");
|
||||
faMap.put("fa-arrow-circle-o-right", "\uf18e");
|
||||
faMap.put("fa-arrow-circle-o-left", "\uf190");
|
||||
faMap.put("fa-caret-square-o-left", "\uf191");
|
||||
faMap.put("fa-dot-circle-o", "\uf192");
|
||||
faMap.put("fa-wheelchair", "\uf193");
|
||||
faMap.put("fa-vimeo-square", "\uf194");
|
||||
}
|
||||
|
||||
public static Map<String, String> getFaMap()
|
||||
{
|
||||
return faMap;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,274 @@
|
||||
package com.beardedhen.androidbootstrap;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.beardedhen.androidbootstrap.R;
|
||||
|
||||
public class FontAwesomeText extends FrameLayout {
|
||||
|
||||
private static Typeface font;
|
||||
private static Map<String, String> faMap;
|
||||
|
||||
private TextView tv;
|
||||
|
||||
private static final String FA_ICON_QUESTION = "fa-question";
|
||||
|
||||
public enum AnimationSpeed
|
||||
{
|
||||
FAST,
|
||||
MEDIUM,
|
||||
SLOW;
|
||||
}
|
||||
|
||||
static{
|
||||
faMap = FontAwesome.getFaMap();
|
||||
}
|
||||
|
||||
public FontAwesomeText(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public FontAwesomeText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialise(attrs);
|
||||
}
|
||||
|
||||
public FontAwesomeText(Context context) {
|
||||
super(context);
|
||||
initialise(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void initialise( AttributeSet attrs )
|
||||
{
|
||||
LayoutInflater inflator = (LayoutInflater)getContext().getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
//get font
|
||||
readFont(getContext());
|
||||
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FontAwesomeText);
|
||||
|
||||
//inflate the view
|
||||
View fontAwesomeTextView = inflator.inflate(R.layout.font_awesome_text, null, false);
|
||||
tv = (TextView)fontAwesomeTextView.findViewById(R.id.lblText);
|
||||
|
||||
String icon = "";
|
||||
float fontSize = 14.0f;
|
||||
|
||||
//icon
|
||||
if (a.getString(R.styleable.FontAwesomeText_fa_icon) != null) {
|
||||
icon = a.getString(R.styleable.FontAwesomeText_fa_icon);
|
||||
}
|
||||
|
||||
//font size
|
||||
if (a.getString(R.styleable.FontAwesomeText_android_textSize) != null) {
|
||||
|
||||
String xmlProvidedSize = attrs.getAttributeValue(
|
||||
"http://schemas.android.com/apk/res/android", "textSize");
|
||||
final Pattern PATTERN_FONT_SIZE = Pattern
|
||||
.compile("([0-9]+[.]?[0-9]*)sp");
|
||||
Matcher m = PATTERN_FONT_SIZE.matcher(xmlProvidedSize);
|
||||
|
||||
if (m.find()) {
|
||||
if (m.groupCount() == 1) {
|
||||
fontSize = Float.valueOf(m.group(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//text colour
|
||||
if(a.getString(R.styleable.FontAwesomeText_android_textColor) != null){
|
||||
tv.setTextColor(a.getColor(R.styleable.FontAwesomeText_android_textColor, R.color.bbutton_inverse));
|
||||
}
|
||||
|
||||
setIcon(icon);
|
||||
|
||||
tv.setTypeface(font);
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
|
||||
|
||||
a.recycle();
|
||||
addView(fontAwesomeTextView);
|
||||
}
|
||||
|
||||
private static void readFont(Context context)
|
||||
{
|
||||
|
||||
if(font == null){
|
||||
try {
|
||||
font = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
|
||||
} catch (Exception e) {
|
||||
Log.e("BButton", "Could not get typeface because " + e.getMessage());
|
||||
font = Typeface.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to start flashing a FontAwesomeText item
|
||||
* @param context the current applications context
|
||||
* @param forever whether the item should flash repeatedly or just once
|
||||
* @param speed how fast the item should flash, chose between FontAwesomeText.AnimationSpeed.SLOW /
|
||||
* FontAwesomeText.AnimationSpeed.MEDIUM / FontAwesomeText.AnimationSpeed.FAST
|
||||
*/
|
||||
public void startFlashing(Context context, boolean forever, AnimationSpeed speed)
|
||||
{
|
||||
|
||||
Animation fadeIn = new AlphaAnimation(0, 1);
|
||||
|
||||
//set up extra variables
|
||||
fadeIn.setDuration(50);
|
||||
fadeIn.setRepeatMode(Animation.REVERSE);
|
||||
|
||||
//default repeat count is 0, however if user wants, set it up to be infinite
|
||||
fadeIn.setRepeatCount(0);
|
||||
if (forever){
|
||||
fadeIn.setRepeatCount(Animation.INFINITE);
|
||||
}
|
||||
|
||||
//default speed
|
||||
fadeIn.setStartOffset(1000);
|
||||
|
||||
//fast
|
||||
if (speed.equals(AnimationSpeed.FAST))
|
||||
{
|
||||
fadeIn.setStartOffset(200);
|
||||
}
|
||||
|
||||
//medium
|
||||
if (speed.equals(AnimationSpeed.MEDIUM))
|
||||
{
|
||||
fadeIn.setStartOffset(500);
|
||||
}
|
||||
|
||||
//set the new animation to a final animation
|
||||
final Animation animation = fadeIn;
|
||||
|
||||
//run the animation - used to work correctly on older devices
|
||||
tv.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tv.startAnimation(animation);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to start rotating a FontAwesomeText item
|
||||
* @param context the current applications context
|
||||
* @param clockwise true for clockwise, false for anti clockwise spinning
|
||||
* @param speed how fast the item should flash, chose between FontAwesomeText.AnimationSpeed.SLOW /
|
||||
* FontAwesomeText.AnimationSpeed.MEDIUM / FontAwesomeText.AnimationSpeed.FAST
|
||||
*/
|
||||
public void startRotate(Context context, boolean clockwise, AnimationSpeed speed)
|
||||
{
|
||||
Animation rotate;
|
||||
|
||||
//set up the rotation animation
|
||||
if (clockwise){
|
||||
rotate = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
|
||||
} else {
|
||||
rotate = new RotateAnimation(360, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
|
||||
}
|
||||
|
||||
//set up some extra variables
|
||||
rotate.setRepeatCount(Animation.INFINITE);
|
||||
rotate.setInterpolator(new LinearInterpolator());
|
||||
rotate.setStartOffset(0);
|
||||
rotate.setRepeatMode(Animation.RESTART);
|
||||
|
||||
//defaults
|
||||
rotate.setDuration(2000);
|
||||
|
||||
//fast
|
||||
if (speed.equals(AnimationSpeed.FAST))
|
||||
{
|
||||
rotate.setDuration(500);
|
||||
}
|
||||
|
||||
//medium
|
||||
if (speed.equals(AnimationSpeed.MEDIUM))
|
||||
{
|
||||
rotate.setDuration(1000);
|
||||
}
|
||||
|
||||
//send the new animation to a final animation
|
||||
final Animation animation = rotate;
|
||||
|
||||
//run the animation - used to work correctly on older devices
|
||||
tv.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tv.startAnimation(animation);
|
||||
}
|
||||
}, 100);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to stop animating any FontAwesomeText item
|
||||
*/
|
||||
public void stopAnimation(){
|
||||
//stop the animation
|
||||
tv.clearAnimation();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to set the icon for a FontAwesomeText item
|
||||
* @param faIcon - String value for the icon as per http://fortawesome.github.io/Font-Awesome/cheatsheet/
|
||||
*/
|
||||
public void setIcon(String faIcon) {
|
||||
|
||||
String icon = faMap.get(faIcon);
|
||||
|
||||
if (icon == null)
|
||||
{
|
||||
icon = faMap.get(FA_ICON_QUESTION);
|
||||
}
|
||||
|
||||
tv.setText(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the text color of the underlying text view.
|
||||
* @param color - Integer value representing a color resource.
|
||||
*/
|
||||
public void setTextColor(int color) {
|
||||
tv.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the text size of the underlying text view.
|
||||
* @param unit - Integer value representing a unit size
|
||||
* @param size - Float value representing text size
|
||||
*/
|
||||
public void setTextSize(int unit, float size) {
|
||||
tv.setTextSize(unit, size);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,303 @@
|
||||
package com.beardedhen.androidbootstrap.utils;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.text.Layout.Alignment;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.SparseIntArray;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
*
|
||||
* Code from user M-WaJeEh on StackOverflow at
|
||||
* http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds/17782522#17782522
|
||||
*
|
||||
*/
|
||||
|
||||
public class AutoResizeTextView extends TextView {
|
||||
private interface SizeTester {
|
||||
/**
|
||||
*
|
||||
* @param suggestedSize
|
||||
* Size of text to be tested
|
||||
* @param availableSpace
|
||||
* available space in which text must fit
|
||||
* @return an integer < 0 if after applying {@code suggestedSize} to
|
||||
* text, it takes less space than {@code availableSpace}, > 0
|
||||
* otherwise
|
||||
*/
|
||||
public int onTestSize(int suggestedSize, RectF availableSpace);
|
||||
}
|
||||
|
||||
private RectF mTextRect = new RectF();
|
||||
|
||||
private RectF mAvailableSpaceRect;
|
||||
|
||||
private SparseIntArray mTextCachedSizes;
|
||||
|
||||
private TextPaint mPaint;
|
||||
|
||||
private float mMaxTextSize;
|
||||
|
||||
private float mSpacingMult = 1.0f;
|
||||
|
||||
private float mSpacingAdd = 0.0f;
|
||||
|
||||
private float mMinTextSize = 20;
|
||||
|
||||
private int mWidthLimit;
|
||||
|
||||
private static final int NO_LINE_LIMIT = -1;
|
||||
private int mMaxLines;
|
||||
|
||||
private boolean mEnableSizeCache = true;
|
||||
private boolean mInitiallized;
|
||||
|
||||
public AutoResizeTextView(Context context) {
|
||||
super(context);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public AutoResizeTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public AutoResizeTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
mPaint = new TextPaint(getPaint());
|
||||
mMaxTextSize = getTextSize();
|
||||
mAvailableSpaceRect = new RectF();
|
||||
mTextCachedSizes = new SparseIntArray();
|
||||
if (mMaxLines == 0) {
|
||||
// no value was assigned during construction
|
||||
mMaxLines = NO_LINE_LIMIT;
|
||||
}
|
||||
mInitiallized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(final CharSequence text, BufferType type) {
|
||||
super.setText(text, type);
|
||||
adjustTextSize(text.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(float size) {
|
||||
mMaxTextSize = size;
|
||||
mTextCachedSizes.clear();
|
||||
adjustTextSize(getText().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLines(int maxlines) {
|
||||
super.setMaxLines(maxlines);
|
||||
mMaxLines = maxlines;
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
public int getMaxLines() {
|
||||
return mMaxLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSingleLine() {
|
||||
super.setSingleLine();
|
||||
mMaxLines = 1;
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSingleLine(boolean singleLine) {
|
||||
super.setSingleLine(singleLine);
|
||||
if (singleLine) {
|
||||
mMaxLines = 1;
|
||||
} else {
|
||||
mMaxLines = NO_LINE_LIMIT;
|
||||
}
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLines(int lines) {
|
||||
super.setLines(lines);
|
||||
mMaxLines = lines;
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(int unit, float size) {
|
||||
Context c = getContext();
|
||||
Resources r;
|
||||
|
||||
if (c == null)
|
||||
r = Resources.getSystem();
|
||||
else
|
||||
r = c.getResources();
|
||||
mMaxTextSize = TypedValue.applyDimension(unit, size,
|
||||
r.getDisplayMetrics());
|
||||
mTextCachedSizes.clear();
|
||||
adjustTextSize(getText().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineSpacing(float add, float mult) {
|
||||
super.setLineSpacing(add, mult);
|
||||
mSpacingMult = mult;
|
||||
mSpacingAdd = add;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the lower text size limit and invalidate the view
|
||||
*
|
||||
* @param minTextSize
|
||||
*/
|
||||
public void setMinTextSize(float minTextSize) {
|
||||
mMinTextSize = minTextSize;
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
private void reAdjust() {
|
||||
adjustTextSize(getText().toString());
|
||||
}
|
||||
|
||||
private void adjustTextSize(String string) {
|
||||
if (!mInitiallized) {
|
||||
return;
|
||||
}
|
||||
int startSize = (int) mMinTextSize;
|
||||
int heightLimit = getMeasuredHeight() - getCompoundPaddingBottom()
|
||||
- getCompoundPaddingTop();
|
||||
mWidthLimit = getMeasuredWidth() - getCompoundPaddingLeft()
|
||||
- getCompoundPaddingRight();
|
||||
mAvailableSpaceRect.right = mWidthLimit;
|
||||
mAvailableSpaceRect.bottom = heightLimit;
|
||||
super.setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_PX,
|
||||
efficientTextSizeSearch(startSize, (int) mMaxTextSize,
|
||||
mSizeTester, mAvailableSpaceRect));
|
||||
}
|
||||
|
||||
private final SizeTester mSizeTester = new SizeTester() {
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
@Override
|
||||
public int onTestSize(int suggestedSize, RectF availableSPace) {
|
||||
mPaint.setTextSize(suggestedSize);
|
||||
String text = getText().toString();
|
||||
boolean singleline = getMaxLines() == 1;
|
||||
if (singleline) {
|
||||
mTextRect.bottom = mPaint.getFontSpacing();
|
||||
mTextRect.right = mPaint.measureText(text);
|
||||
} else {
|
||||
StaticLayout layout = new StaticLayout(text, mPaint,
|
||||
mWidthLimit, Alignment.ALIGN_NORMAL, mSpacingMult,
|
||||
mSpacingAdd, true);
|
||||
// return early if we have more lines
|
||||
if (getMaxLines() != NO_LINE_LIMIT
|
||||
&& layout.getLineCount() > getMaxLines()) {
|
||||
return 1;
|
||||
}
|
||||
mTextRect.bottom = layout.getHeight();
|
||||
int maxWidth = -1;
|
||||
for (int i = 0; i < layout.getLineCount(); i++) {
|
||||
if (maxWidth < layout.getLineWidth(i)) {
|
||||
maxWidth = (int) layout.getLineWidth(i);
|
||||
}
|
||||
}
|
||||
mTextRect.right = maxWidth;
|
||||
}
|
||||
|
||||
mTextRect.offsetTo(0, 0);
|
||||
if (availableSPace.contains(mTextRect)) {
|
||||
// may be too small, don't worry we will find the best match
|
||||
return -1;
|
||||
} else {
|
||||
// too big
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Enables or disables size caching, enabling it will improve performance
|
||||
* where you are animating a value inside TextView. This stores the font
|
||||
* size against getText().length() Be careful though while enabling it as 0
|
||||
* takes more space than 1 on some fonts and so on.
|
||||
*
|
||||
* @param enable
|
||||
* enable font size caching
|
||||
*/
|
||||
public void enableSizeCache(boolean enable) {
|
||||
mEnableSizeCache = enable;
|
||||
mTextCachedSizes.clear();
|
||||
adjustTextSize(getText().toString());
|
||||
}
|
||||
|
||||
private int efficientTextSizeSearch(int start, int end,
|
||||
SizeTester sizeTester, RectF availableSpace) {
|
||||
if (!mEnableSizeCache) {
|
||||
return binarySearch(start, end, sizeTester, availableSpace);
|
||||
}
|
||||
String text = getText().toString();
|
||||
int key = text == null ? 0 : text.length();
|
||||
int size = mTextCachedSizes.get(key);
|
||||
if (size != 0) {
|
||||
return size;
|
||||
}
|
||||
size = binarySearch(start, end, sizeTester, availableSpace);
|
||||
mTextCachedSizes.put(key, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
private static int binarySearch(int start, int end, SizeTester sizeTester,
|
||||
RectF availableSpace) {
|
||||
int lastBest = start;
|
||||
int lo = start;
|
||||
int hi = end - 1;
|
||||
int mid = 0;
|
||||
while (lo <= hi) {
|
||||
mid = (lo + hi) >>> 1;
|
||||
int midValCmp = sizeTester.onTestSize(mid, availableSpace);
|
||||
if (midValCmp < 0) {
|
||||
lastBest = lo;
|
||||
lo = mid + 1;
|
||||
} else if (midValCmp > 0) {
|
||||
hi = mid - 1;
|
||||
lastBest = hi;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
// make sure to return last best
|
||||
// this is what should always be returned
|
||||
return lastBest;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTextChanged(final CharSequence text, final int start,
|
||||
final int before, final int after) {
|
||||
super.onTextChanged(text, start, before, after);
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int width, int height, int oldwidth,
|
||||
int oldheight) {
|
||||
mTextCachedSizes.clear();
|
||||
super.onSizeChanged(width, height, oldwidth, oldheight);
|
||||
if (width != oldwidth || height != oldheight) {
|
||||
reAdjust();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.beardedhen.androidbootstrap.utils;
|
||||
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
|
||||
public class ImageUtils
|
||||
{
|
||||
|
||||
public static Bitmap getCircleBitmap(Bitmap bitmap)
|
||||
{
|
||||
return getCircleBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight());
|
||||
}
|
||||
|
||||
public static Bitmap getCircleBitmap(Bitmap bitmap, int width, int height)
|
||||
{
|
||||
Bitmap croppedBitmap = scaleCenterCrop(bitmap, width, height);
|
||||
Bitmap output = Bitmap.createBitmap(width, height, Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(output);
|
||||
|
||||
final int color = 0xff424242;
|
||||
final Paint paint = new Paint();
|
||||
|
||||
final Rect rect = new Rect(0, 0, width, height);
|
||||
final RectF rectF = new RectF(rect);
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawARGB(0, 0, 0, 0);
|
||||
paint.setColor(color);
|
||||
|
||||
int radius = 0;
|
||||
if(width > height)
|
||||
{
|
||||
radius = height / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
radius = width / 2;
|
||||
}
|
||||
|
||||
canvas.drawCircle(width / 2, height / 2, radius, paint);
|
||||
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
|
||||
canvas.drawBitmap(croppedBitmap, rect, rect, paint);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public static Bitmap scaleCenterCrop(Bitmap source, int newHeight, int newWidth)
|
||||
{
|
||||
int sourceWidth = source.getWidth();
|
||||
int sourceHeight = source.getHeight();
|
||||
|
||||
float xScale = (float) newWidth / sourceWidth;
|
||||
float yScale = (float) newHeight / sourceHeight;
|
||||
float scale = Math.max(xScale, yScale);
|
||||
|
||||
float scaledWidth = scale * sourceWidth;
|
||||
float scaledHeight = scale * sourceHeight;
|
||||
|
||||
float left = (newWidth - scaledWidth) / 2;
|
||||
float top = (newHeight - scaledHeight) / 2;
|
||||
|
||||
RectF targetRect = new RectF(left, top, left + scaledWidth, top + scaledHeight);
|
||||
|
||||
Bitmap dest = Bitmap.createBitmap(newWidth, newHeight, source.getConfig());
|
||||
Canvas canvas = new Canvas(dest);
|
||||
canvas.drawBitmap(source, null, targetRect, null);
|
||||
|
||||
return dest;
|
||||
}
|
||||
}
|
@ -3,3 +3,4 @@ include ':libraries:ActionBarSherlock'
|
||||
include ':libraries:HtmlTextView'
|
||||
include ':libraries:StickyListHeaders:library'
|
||||
include ':libraries:zxing'
|
||||
include ':libraries:AndroidBootstap'
|
||||
|
Loading…
Reference in New Issue
Block a user