Skip to content

Commit

Permalink
Add sharp CameraSwitch icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgurg committed May 17, 2023
1 parent de9d027 commit 739d784
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 1 deletion.
Binary file added .github/preview/sharp/CameraSwitch.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ _All icons have the same duration (`@android:integer/config_shortAnimTime`) and
| ![](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` |
| ![](https://raw.githubusercontent.com/ozgurg/ToggleIconView/master/.github/preview/sharp/CameraSwitch.gif) | [Sharp] CameraSwitch<br />`og.android.lib.toggleiconview.sharp.CameraSwitch` |

## How do you create your custom icon?

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 CameraSwitch @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) :
ToggleIconView(
context, attrs, defStyleAttr,
R.drawable.camera_switch,
R.drawable.camera_switch
)
37 changes: 37 additions & 0 deletions lib/src/main/res/drawable/camera_switch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<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:fillColor="@android:color/black"
android:pathData="M 16 7 L 15 7 L 14 6 L 10 6 L 9 7 L 8 7 C 6.9 7 6 7.9 6 9 L 6 15 C 6 16.1 6.9 17 8 17 L 16 17 C 17.1 17 18 16.1 18 15 L 18 9 C 18 7.9 17.1 7 16 7 Z M 12 14 C 10.9 14 10 13.1 10 12 C 10 10.9 10.9 10 12 10 C 13.1 10 14 10.9 14 12 C 14 13.1 13.1 14 12 14 Z" />
<path
android:fillColor="@android:color/black"
android:pathData="M 8.57 0.51 L 13.05 4.99 L 13.05 2.04 C 17.77 2.51 21.53 6.27 22 10.99 C 22 10.99 24 10.99 24 10.99 C 23.34 3.02 15.49 -1.59 8.57 0.51 Z" />
<path
android:fillColor="@android:color/black"
android:pathData="M 10.95 21.96 C 6.23 21.49 2.47 17.73 2 13.01 C 2 13.01 0 13.01 0 13.01 C 0.66 20.98 8.51 25.59 15.43 23.49 L 10.95 19.01 L 10.95 21.96 Z" />
</group>
</vector>
</aapt:attr>

<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="360"
android:valueType="floatType" />
</aapt:attr>
</target>
</animated-vector>
34 changes: 33 additions & 1 deletion sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,37 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="24dp">

<TextView
style="@style/DemoPrimaryTitle"
android:text="Camera Switch" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">

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

<TextView
style="@style/DemoSecondaryTitle"
android:text="Sharp" />

<og.android.lib.toggleiconview.sharp.CameraSwitch style="@style/DemoIcon" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</ScrollView>
65 changes: 65 additions & 0 deletions shapeshifter/camera_switch.shapeshifter
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"version": 1,
"layers": {
"vectorLayer": {
"id": "123",
"name": "cameraswitch",
"type": "vector",
"width": 24,
"height": 24,
"children": [
{
"id": "124",
"name": "group",
"type": "group",
"pivotX": 12,
"pivotY": 12,
"children": [
{
"id": "851",
"name": "path1",
"type": "path",
"pathData": "M 16 7 L 15 7 L 14 6 L 10 6 L 9 7 L 8 7 C 6.9 7 6 7.9 6 9 L 6 15 C 6 16.1 6.9 17 8 17 L 16 17 C 17.1 17 18 16.1 18 15 L 18 9 C 18 7.9 17.1 7 16 7 Z M 12 14 C 10.9 14 10 13.1 10 12 C 10 10.9 10.9 10 12 10 C 13.1 10 14 10.9 14 12 C 14 13.1 13.1 14 12 14 Z",
"fillColor": "#000000"
},
{
"id": "876",
"name": "path2",
"type": "path",
"pathData": "M 8.57 0.51 L 13.05 4.99 L 13.05 2.04 C 17.77 2.51 21.53 6.27 22 10.99 C 22 10.99 24 10.99 24 10.99 C 23.34 3.02 15.49 -1.59 8.57 0.51 Z",
"fillColor": "#000000"
},
{
"id": "886",
"name": "path3",
"type": "path",
"pathData": "M 10.95 21.96 C 6.23 21.49 2.47 17.73 2 13.01 C 2 13.01 0 13.01 0 13.01 C 0.66 20.98 8.51 25.59 15.43 23.49 L 10.95 19.01 L 10.95 21.96 Z",
"fillColor": "#000000"
}
]
}
]
},
"hiddenLayerIds": []
},
"timeline": {
"animation": {
"id": "126",
"name": "anim",
"duration": 300,
"blocks": [
{
"id": "128",
"layerId": "124",
"propertyName": "rotation",
"startTime": 0,
"endTime": 300,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "number",
"fromValue": 0,
"toValue": 360
}
]
}
}
}

0 comments on commit 739d784

Please sign in to comment.