Skip to content

Commit

Permalink
Merge pull request #10 from ozgurg/dev
Browse files Browse the repository at this point in the history
release: v2.3.0
  • Loading branch information
ozgurg authored Jul 16, 2022
2 parents 4a47421 + ffa99f5 commit 5438f5d
Show file tree
Hide file tree
Showing 25 changed files with 902 additions and 72 deletions.
Binary file added .github/preview/sharp/AirplaneModeOnOff.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 modified .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.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencyResolutionManagement {
```gradle
// App level build.gradle
dependencies {
implementation "com.github.ozgurg:ToggleIconView:2.2.0"
implementation "com.github.ozgurg:ToggleIconView:2.3.0"
}
```

Expand Down Expand Up @@ -73,21 +73,22 @@ anything you can with `AppCompatImageView`.

### Events

| Event | Description |
|------------------------------------------------------------------------|----------------------------------------------------|
| Event | Description |
|------------------------------------------------------------------------|-----------------------------------------------------|
| `onCheckedChanged(toggleIconView: ToggleIconView, isChecked: Boolean)` | Triggers when the checked state of the icon changed |

## Built-in icons

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

| 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/SoundOnOff.gif) | [Sharp] SoundOnOff<br />`og.android.lib.toggleiconview.sharp.SoundOnOff` |
| ![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/preview/sharp/FlashOnOff.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/SoundOnOff.gif) | [Sharp] SoundOnOff<br />`og.android.lib.toggleiconview.sharp.SoundOnOff` |
| ![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/preview/sharp/FlashOnOff.gif) | [Sharp] FlashOnOff<br />`og.android.lib.toggleiconview.sharp.FlashOnOff` |
| ![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/preview/sharp/AirplaneModeOnOff.gif) | [Sharp] AirplaneModeOnOff<br />`og.android.lib.toggleiconview.sharp.AirplaneModeOnOff` |

## How I create my own icon?

Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ afterEvaluate {

groupId = "com.github.ozgurg"
artifactId = "toggle-icon-view"
version = "2.2.0"
version = "2.3.0"
}
}
}
Expand Down
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 AirplaneModeOnOff @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) :
ToggleIconView(
context, attrs, defStyleAttr,
R.drawable.sharp_airplanemode_on_to_off,
R.drawable.sharp_airplanemode_off_to_on
)
4 changes: 2 additions & 2 deletions lib/src/main/res/drawable/rounded_sound_off_to_on.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="path"
android:name="strike"
android:fillColor="@android:color/black"
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z" />
<clip-path
Expand All @@ -19,7 +19,7 @@
</vector>
</aapt:attr>

<target android:name="path">
<target android:name="strike">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/res/drawable/rounded_sound_on_to_off.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="path"
android:name="strike"
android:fillColor="@android:color/black"
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z" />
<clip-path
Expand All @@ -19,7 +19,7 @@
</vector>
</aapt:attr>

<target android:name="path">
<target android:name="strike">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
Expand Down
45 changes: 45 additions & 0 deletions lib/src/main/res/drawable/sharp_airplanemode_off_to_on.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<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">
<path
android:name="strike"
android:fillColor="@android:color/black"
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z" />
<clip-path
android:name="mask"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z M 4.54 1.73 L 3.27 3 L 3.27 3 L 4.54 1.73 Z" />
<path
android:fillColor="@android:color/black"
android:pathData="M 22 16 L 22 14 L 13.5 9 L 13.5 3.5 C 13.5 2.67 12.83 2 12 2 C 11.17 2 10.5 2.67 10.5 3.5 L 10.5 9 L 2 14 L 2 16 L 10.5 13.5 L 10.5 19 L 8 20.5 L 8 22 L 12 21 L 16 22 L 16 20.5 L 13.5 19 L 13.5 13.5 L 22 16 Z" />
</vector>
</aapt:attr>

<target android:name="strike">
<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 19.73 22 L 21 20.73 L 3.27 3 L 2 4.27 Z"
android:valueTo="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z"
android:valueType="pathType" />
</aapt:attr>
</target>

<target android:name="mask">
<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 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z M 4.54 1.73 L 3.27 3 L 21 20.73 L 22.27 19.46 Z"
android:valueTo="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z M 4.54 1.73 L 3.27 3 L 3.27 3 L 4.54 1.73 Z"
android:valueType="pathType" />
</aapt:attr>
</target>
</animated-vector>
45 changes: 45 additions & 0 deletions lib/src/main/res/drawable/sharp_airplanemode_on_to_off.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<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">
<path
android:name="strike"
android:fillColor="@android:color/black"
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z" />
<clip-path
android:name="mask"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z M 4.54 1.73 L 3.27 3 L 3.27 3 L 4.54 1.73 Z" />
<path
android:fillColor="@android:color/black"
android:pathData="M 22 16 L 22 14 L 13.5 9 L 13.5 3.5 C 13.5 2.67 12.83 2 12 2 C 11.17 2 10.5 2.67 10.5 3.5 L 10.5 9 L 2 14 L 2 16 L 10.5 13.5 L 10.5 19 L 8 20.5 L 8 22 L 12 21 L 16 22 L 16 20.5 L 13.5 19 L 13.5 13.5 L 22 16 Z" />
</vector>
</aapt:attr>

<target android:name="strike">
<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 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z"
android:valueTo="M 19.73 22 L 21 20.73 L 3.27 3 L 2 4.27 Z"
android:valueType="pathType" />
</aapt:attr>
</target>

<target android:name="mask">
<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 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z M 4.54 1.73 L 3.27 3 L 3.27 3 L 4.54 1.73 Z"
android:valueTo="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z M 4.54 1.73 L 3.27 3 L 21 20.73 L 22.27 19.46 Z"
android:valueType="pathType" />
</aapt:attr>
</target>
</animated-vector>
8 changes: 3 additions & 5 deletions lib/src/main/res/drawable/sharp_flash_off_to_on.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
<path
android:name="strike"
android:fillColor="@android:color/black"
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z"
android:strokeWidth="1" />
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z" />
<clip-path
android:name="mask"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z M 4.54 1.73 L 3.27 3 L 3.27 3 L 4.54 1.73 Z" />
<path
android:fillColor="@android:color/black"
android:pathData="M 7 2 L 7 13 L 10 13 L 10 22 L 17 10 L 13 10 L 17 2 Z"
android:strokeWidth="1" />
android:pathData="M 7 2 L 7 13 L 10 13 L 10 22 L 17 10 L 13 10 L 17 2 Z" />
</vector>
</aapt:attr>

Expand All @@ -44,4 +42,4 @@
android:valueType="pathType" />
</aapt:attr>
</target>
</animated-vector>
</animated-vector>
8 changes: 3 additions & 5 deletions lib/src/main/res/drawable/sharp_flash_on_to_off.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
<path
android:name="strike"
android:fillColor="@android:color/black"
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z"
android:strokeWidth="1" />
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z" />
<clip-path
android:name="mask"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z M 4.54 1.73 L 3.27 3 L 3.27 3 L 4.54 1.73 Z" />
<path
android:fillColor="@android:color/black"
android:pathData="M 7 2 L 7 13 L 10 13 L 10 22 L 17 10 L 13 10 L 17 2 Z"
android:strokeWidth="1" />
android:pathData="M 7 2 L 7 13 L 10 13 L 10 22 L 17 10 L 13 10 L 17 2 Z" />
</vector>
</aapt:attr>

Expand All @@ -44,4 +42,4 @@
android:valueType="pathType" />
</aapt:attr>
</target>
</animated-vector>
</animated-vector>
4 changes: 2 additions & 2 deletions lib/src/main/res/drawable/sharp_sound_off_to_on.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="path"
android:name="strike"
android:fillColor="@android:color/black"
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z" />
<clip-path
Expand All @@ -19,7 +19,7 @@
</vector>
</aapt:attr>

<target android:name="path">
<target android:name="strike">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/res/drawable/sharp_sound_on_to_off.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="path"
android:name="strike"
android:fillColor="@android:color/black"
android:pathData="M 2 4.27 L 3.27 3 L 3.27 3 L 2 4.27 Z" />
<clip-path
Expand All @@ -19,7 +19,7 @@
</vector>
</aapt:attr>

<target android:name="path">
<target android:name="strike">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ class MainActivity : AppCompatActivity() {

for (i2 in 0 until depth2.childCount) {
val depth3 = depth2.getChildAt(i2)
if (depth3 !is ToggleIconView) continue
if (depth3 !is LinearLayout) continue

// We finally found ToggleIconView! (https://youtu.be/f_EiqPp-vBM)
toggleIconViews.add(depth3)
for (i3 in 0 until depth3.childCount) {
val depth4 = depth3.getChildAt(i3)
if (depth4 !is ToggleIconView) continue

// We finally found ToggleIconView! (https://youtu.be/f_EiqPp-vBM)
toggleIconViews.add(depth4)
}
}
}
}
Expand Down
Loading

0 comments on commit 5438f5d

Please sign in to comment.