Skip to content

Commit

Permalink
Merge pull request #7 from ozgurg/dev
Browse files Browse the repository at this point in the history
release: v2.1.0
  • Loading branch information
ozgurg authored Jul 13, 2022
2 parents c174ffe + 912ebc0 commit f4083b3
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 21 deletions.
Binary file added .github/preview/sharp/PlayPause.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/sample.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .github/sample.mp4
Binary file not shown.
44 changes: 34 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,42 @@

ToggleIconView is a collection library of animated two-stage toggle icons for Android.

https://user-images.githubusercontent.com/6717356/178526403-60881b61-90af-4e23-b731-1f349a3e9512.mp4
![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/sample.gif)

## Installation

### JitPack repository

```gradle
// build.gradle Project
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```

If the above doesn't work, try the following:

```gradle
// settings.gradle Project
...
dependencyResolutionManagement {
...
repositories {
...
maven { url "https://jitpack.io" }
}
}
...
```

### Implementation
```gradle
// build.gradle App
dependencies {
implementation "com.github.ozgurg:ToggleIconView:2.0.0"
implementation "com.github.ozgurg:ToggleIconView:2.1.0"
}
```

Expand All @@ -36,9 +59,9 @@ anything you can with `AppCompatImageView`.

### Attributes

| Attribute | Description | Type |
|---------------|------------------------------------|-----------|
| `app:checked` | Sets the initial state of the icon | `boolean` |
| Attribute | Description | Type | Default |
|---------------|------------------------------------|-----------|---------|
| `app:checked` | Sets the initial state of the icon | `boolean` | `false` |

### Methods

Expand All @@ -58,11 +81,12 @@ anything you can with `AppCompatImageView`.

_All icons have the same duration and interpolator, but I manually capture their previews; so timings may look different._

| Preview | Package |
|-----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| ![](https://user-images.githubusercontent.com/6717356/178586997-ec1f822d-0355-468c-8ea4-6122dd24a22b.gif) | [Rounded] PlayPause<br />`og.android.lib.toggleiconview.rounded.PlayPause` |
| ![](https://user-images.githubusercontent.com/6717356/178587007-a40486e7-11e3-43f1-bcb2-78a5afcedd05.gif) | [Rounded] SoundOnOff<br />`og.android.lib.toggleiconview.rounded.SoundOnOff` |
| ![](https://user-images.githubusercontent.com/6717356/178586969-c1270e15-76b7-4c68-83b7-c1f958aa5fb6.gif) | [Sharp] FlashOnOff<br />`og.android.lib.toggleiconview.sharp.FlashOnOff` |
| Preview | Package |
|------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| ![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/preview/rounded/PlayPause.gif) | [Rounded] PlayPause<br />`og.android.lib.toggleiconview.rounded.PlayPause` |
| ![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/preview/sharp/PlayPause.gif) | [Sharp] PlayPause<br />`og.android.lib.toggleiconview.sharp.PlayPause` |
| ![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/preview/rounded/SoundOnOff.gif) | [Rounded] SoundOnOff<br />`og.android.lib.toggleiconview.rounded.SoundOnOff` |
| ![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/preview/sharp/FlashOnOff.gif) | [Sharp] FlashOnOff<br />`og.android.lib.toggleiconview.sharp.FlashOnOff` |

## How I create my own icon?

Expand Down
5 changes: 1 addition & 4 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
viewBinding = true
}
}

dependencies {
Expand All @@ -42,7 +39,7 @@ afterEvaluate {

groupId = "com.github.ozgurg"
artifactId = "toggle-icon-view"
version = "2.0.0"
version = "2.1.0"
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions lib/src/main/java/og/android/lib/toggleiconview/sharp/PlayPause.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package og.android.lib.toggleiconview.sharp

import android.content.Context
import android.util.AttributeSet
import og.android.lib.toggleiconview.R
import og.android.lib.toggleiconview.ToggleIconView

class PlayPause @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) :
ToggleIconView(
context, attrs, defStyleAttr,
R.drawable.sharp_play_to_pause,
R.drawable.sharp_pause_to_play
)
44 changes: 44 additions & 0 deletions lib/src/main/res/drawable/sharp_pause_to_play.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="path"
android:fillColor="@android:color/black"
android:pathData="M 8 5 L 8 19 L 19 12 Z" />
</group>
</vector>
</aapt:attr>

<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:propertyName="pathData"
android:valueFrom="M 5 6 L 5 10 L 19 10 L 19 6 L 5 6 M 5 14 L 5 18 L 19 18 L 19 14 L 5 14"
android:valueTo="M 8 5 L 8 12 L 19 12 L 19 12 L 8 5 M 8 12 L 8 19 L 19 12 L 19 12 L 8 12"
android:valueType="pathType" />
</aapt:attr>
</target>

<target android:name="group">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:propertyName="rotation"
android:valueFrom="90"
android:valueTo="0"
android:valueType="floatType" />
</aapt:attr>
</target>
</animated-vector>
44 changes: 44 additions & 0 deletions lib/src/main/res/drawable/sharp_play_to_pause.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="path"
android:fillColor="@android:color/black"
android:pathData="M 8 5 L 8 19 L 19 12 Z" />
</group>
</vector>
</aapt:attr>

<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:propertyName="pathData"
android:valueFrom="M 8 5 L 8 12 L 19 12 L 19 12 L 8 5 M 8 12 L 8 19 L 19 12 L 19 12 L 8 12"
android:valueTo="M 5 6 L 5 10 L 19 10 L 19 6 L 5 6 M 5 14 L 5 18 L 19 18 L 19 14 L 5 14"
android:valueType="pathType" />
</aapt:attr>
</target>

<target android:name="group">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:propertyName="rotation"
android:valueFrom="0"
android:valueTo="90"
android:valueType="floatType" />
</aapt:attr>
</target>
</animated-vector>
18 changes: 14 additions & 4 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:orientation="vertical">

<include
layout="@layout/demo_play_pause"
layout="@layout/demo_rounded_play_pause"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
Expand All @@ -16,17 +16,27 @@
android:layout_height="1dp" />

<include
layout="@layout/demo_sound_on_off"
layout="@layout/demo_sharp_play_pause"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />

<com.google.android.material.divider.MaterialDivider
android:layout_width="match_parent"
android:layout_height="1dp" />
android:layout_height="4dp" />

<include
layout="@layout/demo_rounded_sound_on_off"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />

<com.google.android.material.divider.MaterialDivider
android:layout_width="match_parent"
android:layout_height="4dp" />

<include
layout="@layout/demo_flash_on_off"
layout="@layout/demo_sharp_flash_on_off"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Play/Pause"
android:text="Rounded: Play/Pause"
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textStyle="bold" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Sound On/Off"
android:text="Rounded: Sound On/Off"
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textStyle="bold" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Flash On/Off"
android:text="Sharp: Flash On/Off"
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textStyle="bold" />
Expand Down
57 changes: 57 additions & 0 deletions sample/src/main/res/layout/demo_sharp_play_pause.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Sharp: Play/Pause"
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textStyle="bold" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">

<og.android.lib.toggleiconview.sharp.PlayPause
android:id="@+id/playPause24"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:tint="#f00" />

<com.google.android.material.divider.MaterialDivider
android:layout_width="1dp"
android:layout_height="64dp"
android:layout_marginHorizontal="24dp" />

<og.android.lib.toggleiconview.sharp.PlayPause
android:id="@+id/playPause48"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:tint="#000" />

<com.google.android.material.divider.MaterialDivider
android:layout_width="1dp"
android:layout_height="64dp"
android:layout_marginHorizontal="24dp" />

<og.android.lib.toggleiconview.sharp.PlayPause
android:id="@+id/playPause96"
android:layout_width="96dp"
android:layout_height="96dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:tint="#00f"
app:checked="true" />
</LinearLayout>
</LinearLayout>

0 comments on commit f4083b3

Please sign in to comment.