Skip to content

Commit

Permalink
Merge branch 'release/v4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jun 7, 2019
2 parents b21939d + d1bbb97 commit c32cbca
Show file tree
Hide file tree
Showing 278 changed files with 12,104 additions and 12,614 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# Generated files
bin/
gen/
.idea/*
*.iml
.idea/*

# Gradle files
.gradle/
Expand Down
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ language: android
android:
components:
- tools
- build-tools-28.0.3
- android-28
- build-tools-29.0.0
- android-29
before_install:
- yes | sdkmanager "platforms;android-28"
- yes | sdkmanager "build-tools;28.0.3"
- yes | sdkmanager "platforms;android-29"
- yes | sdkmanager "build-tools;29.0.0"
jdk:
- oraclejdk8
- oraclejdk8
script:
- ./gradlew clean build
- ./gradlew clean build
branches:
except:
- gh-pages
notifications:
email: false
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- $HOME/.m2
Expand Down
21 changes: 21 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

### Library

### core v3.x.x -> 4.x.x
Now libraries is kotlin-first

* Font files
* Font's store now based on default way to store fonts. (moved from common assets to font-specific resource assets)
* `Iconics`
* No context from now required. We get the application context via ContentProvider
* `Iconics.IconicsBuilder`
* Renamed to `Iconics.Builder`
* Removed `ctx(Context)` method
* `IconicsDrawable`
* Replaced all `*Res(int)`, `*Px(int)`, `*Dp(int)` method to use `IconicsSize` and `IconicsColor` classes instead
* Constants `TOOLBAR_ICON_SIZE` and `TOOLBAR_ICON_PADDING` moved to `IconicsSize`
* All getters now have property-syntax
* All producer-provided methods from [Android-Iconics Kt](https://github.com/zTrap/Android-Iconics-Kt) are included in class and can return nullable value (value will be set only when not null)
* `enableShadowSupport(View)` moved to `IconicsUtils`
* All `utils` classes and typeface libraries now can not be instantiated
* `ITypeface`
* Method `getTypeface(Context)` replaced with field `rawTypeface`
* Automatically retrieves raw font from file by provided `fontRes` (see [GenericFont.kt](/library-core/src/main/java/com/mikepenz/iconics/typeface/GenericFont.kt) if You wont to use old scheme)

#### Community Material Icons > v2.7.94
* With the update of the community material icons, the amount of icons exceeded the allowed length of an enum. Thus it was split up in `CommunityMaterial.Icon` and `CommunityMaterial.Icon2` if you use the icons via code, please use the depending enum.
* The icons were split apart by the letter `h`. All icons starting from `a` to `g` are in the `CommunityMaterial.Icon` enum, all icons from `h` to `z` are in the `CommunityMaterial.Icon2` enum.
Expand Down
116 changes: 51 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,78 +62,66 @@ A awesome gradle plugin which can automatically fetch a font from Fontastic, and

## 1. Provide the gradle dependency
```gradle
//the core iconcis library (without any widgets)
implementation "com.mikepenz:iconics-core:3.2.5"
implementation "androidx.appcompat:appcompat:${androidXVersion}"
//the core iconics library (without any widgets)
implementation "com.mikepenz:iconics-core:4.0.0"
implementation "androidx.appcompat:appcompat:$versions.appCompat"
```

## 1b. (optional) Add the view's dependency
```gradle
//this adds all ui view widgets (IconicsButton, IconicsImageView, ...)
implementation "com.mikepenz:iconics-views:3.2.5"
implementation "com.mikepenz:iconics-views:4.0.0"
```

For the non kotlin variant please use a version smaller than 4.x.y (See the releases on GitHub)
To use appcompat please use a version smaller than 3.1.0. (See the releases on GitHub)

## 2. Choose your desired fonts
```gradle
implementation 'com.mikepenz:google-material-typeface:3.0.1.3.original@aar'
implementation 'com.mikepenz:material-design-iconic-typeface:2.2.0.5@aar'
implementation 'com.mikepenz:fontawesome-typeface:5.3.1.1@aar'
implementation 'com.mikepenz:octicons-typeface:3.2.0.5@aar'
implementation 'com.mikepenz:meteocons-typeface:1.1.0.5@aar'
implementation 'com.mikepenz:community-material-typeface:3.5.95.1@aar'
implementation 'com.mikepenz:weather-icons-typeface:2.0.10.5@aar'
implementation 'com.mikepenz:typeicons-typeface:2.0.7.5@aar'
implementation 'com.mikepenz:entypo-typeface:1.0.0.5@aar'
implementation 'com.mikepenz:devicon-typeface:2.0.0.5@aar'
implementation 'com.mikepenz:foundation-icons-typeface:3.0.0.5@aar'
implementation 'com.mikepenz:ionicons-typeface:2.0.1.5@aar'
implementation 'com.mikepenz:pixeden-7-stroke-typeface:1.2.0.3@aar'
implementation 'com.mikepenz:google-material-typeface:3.0.1.4.original-kotlin@aar'
implementation 'com.mikepenz:material-design-iconic-typeface:2.2.0.6-kotlin@aar'
implementation 'com.mikepenz:fontawesome-typeface:5.3.1.2-kotlin@aar'
implementation 'com.mikepenz:octicons-typeface:3.2.0.6-kotlin@aar'
implementation 'com.mikepenz:meteocons-typeface:1.1.0.5-kotlin@aar'
implementation 'com.mikepenz:community-material-typeface:3.5.95.1-kotlin@aar'
implementation 'com.mikepenz:weather-icons-typeface:2.0.10.5-kotlin@aar'
implementation 'com.mikepenz:typeicons-typeface:2.0.7.5-kotlin@aar'
implementation 'com.mikepenz:entypo-typeface:1.0.0.5-kotlin@aar'
implementation 'com.mikepenz:devicon-typeface:2.0.0.5-kotlin@aar'
implementation 'com.mikepenz:foundation-icons-typeface:3.0.0.5-kotlin@aar'
implementation 'com.mikepenz:ionicons-typeface:2.0.1.5-kotlin@aar'
implementation 'com.mikepenz:pixeden-7-stroke-typeface:1.2.0.3-kotlin@aar'
```

## 3. Define IconicsLayoutInflater to enable automatic xml icons detection (optional)
Set the `IconicsLayoutInflater` as new `LayoutInflaterFactory`. This will enable automatic icon detection for `TextViews`,`Buttons`, and allow you to set icons on `ImageView`'s via xml. This is compatible with libs which wrap the `baseContext` like [Calligraphy](https://github.com/chrisjenx/Calligraphy). This does not work on FAB's please use the `Context-Injection` instead.

If compileSdkVersion >= 26:
```java
@Override
protected void onCreate(Bundle savedInstanceState) {
LayoutInflaterCompat.setFactory2(getLayoutInflater(), new IconicsLayoutInflater2(getDelegate()));
```kotlin
override fun onCreate(savedInstanceState: Bundle?) {
layoutInflater.setIconicsFactory(delegate)
super.onCreate(savedInstanceState)
//...
super.onCreate(savedInstanceState);
//...
}
```
Else:
```java
@Override
protected void onCreate(Bundle savedInstanceState) {
LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
//...
super.onCreate(savedInstanceState);
//...
}
```

### 3. ALTERNATIVE: Inject into Context (optional)
Wrap the `Activity` context. This will enable the same features as Step 3.1., but is not compatible with other libs wrapping the `baseContext`.
```java
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(IconicsContextWrapper.wrap(newBase));
```kotlin
override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(newBase.wrapByIconics())
}
```


# Usage
## Use as drawable

```java
new IconicsDrawable(this)
```kotlin
IconicsDrawable(this)
.icon(FontAwesome.Icon.faw_android)
.color(Color.RED)
.sizeDp(24)
.color(Color.RED.toIconicsColor())
.size(24.toIconicsSizeDp())
```

## Use via XML
Expand Down Expand Up @@ -239,39 +227,45 @@ Licenses for all included fonts are linked inside the class or can be found on t
### Register fonts

If you want to add your own custom font, or a GenericFont you have to register this font (before using it). The best place to do this is the `Application`.
```java
public class CustomApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
You can manually provide `applicationContext` and trigger initialization, or you can use our `IconicsContentProvider` and do absolutely nothing.

If you want to use tha manual way - place this value into your resources
```xml
<bool name="is_iconics_content_provider_enabled">false</bool>
```
And initialize Iconics as you wish
```kotlin
class CustomApplication : Application() {
override fun onCreate() {
super.onCreate()

//only required if you add a custom or generic font on your own
Iconics.init(getApplicationContext());
Iconics.init(applicationContext)

//register custom fonts like this (or also provide a font definition file)
Iconics.registerFont(new CustomFont());
Iconics.registerFont(CustomFont())
}
}
```

### Advanced IconicsBuilder
Everything is easy and simple. Right? But now you got a single icon within your textview and you need additional styling?
Just define the style for all icons or only a specific one. You can find this in the PlaygroundActivity of the sample too.
```java
new Iconics.IconicsBuilder().ctx(this)
.style(new ForegroundColorSpan(Color.WHITE), new BackgroundColorSpan(Color.BLACK), new RelativeSizeSpan(2f))
.styleFor(FontAwesome.Icon.faw_adjust, new BackgroundColorSpan(Color.RED))
```kotlin
Iconics.Builder()
.style(ForegroundColorSpan(Color.WHITE), BackgroundColorSpan(Color.BLACK), RelativeSizeSpan(2f))
.styleFor(FontAwesome.Icon.faw_adjust, BackgroundColorSpan(Color.RED))
.on(tv1)
.build();
.build()
```

### String icon-key or typeface enum
Sometimes you won't like to use the icon-key ("faw-adjust") like this, but use the enum provided by a specific font. Both is valid:
```java
new IconicsDrawable(this, "faw-adjust").actionBar()
```kotlin
IconicsDrawable(this, "faw-adjust").actionBar()
```
```java
new IconicsDrawable(this, FontAwesome.Icon.faw_adjust).sizeDp(24).paddingDp(1)
```kotlin
IconicsDrawable(this, FontAwesome.Icon.faw_adjust).size(24.toIconicsSizeDp()).padding(1.toIconicsSizeDp())
```


Expand Down Expand Up @@ -299,17 +293,11 @@ Exclude `R` from ProGuard to enable the font addon auto detection
```
All other ProGuard rules are now bundled internally with each font.

# Kotlin support
Also we have some extensions for easy use on kotlin in the library below

[Android-Iconics Kt](https://github.com/zTrap/Android-Iconics-Kt)

# Demo
You can try the sample application out. It's on Google Play ;)
https://play.google.com/store/apps/details?id=com.mikepenz.iconics.sample

# Special Contributor
- [Peter Gulko](https://github.com/zTrap) Thanks for providing better XML support for compound Iconics drawables, and for doing the initial work of splitting up core and views library
- [Baptiste Lagache](https://github.com/ligol) Thanks for the gradle font module generator
- Also thanks for all the other contributors.

Expand Down Expand Up @@ -339,5 +327,3 @@ https://play.google.com/store/apps/details?id=com.mikepenz.iconics.sample
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


43 changes: 35 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
/*
* Copyright (c) 2019 Mike Penz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//wrap with try and catch so the build is working even if the signing stuff is missing
try {
apply from: '../../../signing.gradle'
Expand Down Expand Up @@ -49,6 +67,11 @@ android {
lintOptions {
abortOnError false
}

packagingOptions {
exclude 'META-INF/library-core_release.kotlin_module'
exclude 'META-INF/library_release.kotlin_module'
}
}

dependencies {
Expand All @@ -68,16 +91,18 @@ dependencies {
// used to fill the RecyclerView with the DrawerItems
// and provides single and multi selection, expandable items
// https://github.com/mikepenz/FastAdapter
implementation 'com.mikepenz:fastadapter:3.3.1'
implementation 'com.mikepenz:fastadapter-commons:3.3.1'
implementation 'com.mikepenz:fastadapter-extensions-expandable:3.3.1'
implementation 'com.mikepenz:fastadapter:4.0.0-rc03'
implementation 'com.mikepenz:fastadapter-extensions-utils:4.0.0-rc03'
implementation 'com.mikepenz:fastadapter-extensions-ui:4.0.0-rc03'
implementation 'com.mikepenz:fastadapter-extensions-expandable:4.0.0-rc03'

// used to generating string fields for icons (sample - test/java/StringFieldGenerator.java)
testImplementation 'ru.ztrap.iconics:string-generator:1.0.2'
// https://github.com/zTrap/Android-Iconics-String-Generator
testImplementation 'ru.ztrap.iconics:string-generator:1.0.4'

//used to generate the drawer on the left
//https://github.com/mikepenz/MaterialDrawer
implementation('com.mikepenz:materialdrawer:6.1.2') {
// used to generate the drawer on the left
// https://github.com/mikepenz/MaterialDrawer
implementation('com.mikepenz:materialdrawer:7.0.0-beta01') {
transitive = true
exclude module: "fastadapter"
exclude module: "fastadapter-extensions-expandable"
Expand All @@ -86,7 +111,7 @@ dependencies {

// used to generate the Open Source section
// https://github.com/mikepenz/AboutLibraries
implementation('com.mikepenz:aboutlibraries:6.2.1') {
implementation('com.mikepenz:aboutlibraries:7.0.0-rc1') {
transitive = true
exclude module: "fastadapter"
exclude module: "iconics-core"
Expand All @@ -109,4 +134,6 @@ dependencies {
implementation project(':pixeden-7-stroke-typeface-library')

testImplementation 'junit:junit:4.12'
implementation "androidx.core:core-ktx:$versions.ktx.core"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin"
}
23 changes: 21 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<!--
~ Copyright (c) 2019 Mike Penz
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mikepenz.iconics.sample">

<application
Expand All @@ -8,7 +26,8 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/MaterialDrawerTheme.Light.DarkToolbar">
android:theme="@style/MaterialDrawerTheme.Light.DarkToolbar"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Loading

0 comments on commit c32cbca

Please sign in to comment.