Skip to content

Commit

Permalink
Merge pull request #15 from TheCodeMonks/Dev
Browse files Browse the repository at this point in the history
Update Dark/Light Icons switch & Bookmarks Icon
  • Loading branch information
Spikeysanju authored Oct 2, 2020
2 parents 00db563 + c7e29ba commit ca5fa66
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 8 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ArticlesFragment : Fragment(R.layout.fragment_articles) {
val isChecked = viewModel.readDataStore.first()
val item = menu.findItem(R.id.action_night_mode)
item.isChecked = isChecked
setUIMode(isChecked)
setUIMode(item, isChecked)
}
}

Expand All @@ -156,20 +156,24 @@ class ArticlesFragment : Fragment(R.layout.fragment_articles) {

R.id.action_night_mode -> {
item.isChecked = !item.isChecked
setUIMode(item.isChecked)
setUIMode(item, item.isChecked)
true
}
else -> super.onOptionsItemSelected(item)
}
}

private fun setUIMode(isChecked: Boolean) {
private fun setUIMode(item: MenuItem, isChecked: Boolean) {
if (isChecked) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
viewModel.saveToDataStore(true)
item.setIcon(R.drawable.ic_night)

} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
viewModel.saveToDataStore(false)
item.setIcon(R.drawable.ic_day)

}
}

Expand Down
46 changes: 46 additions & 0 deletions app/src/main/res/drawable/ic_bookmarks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
~ /*
~ * MIT License
~ *
~ * Copyright (c) 2020 Spikey Sanju
~ *
~ * Permission is hereby granted, free of charge, to any person obtaining a copy
~ * of this software and associated documentation files (the "Software"), to deal
~ * in the Software without restriction, including without limitation the rights
~ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ * copies of the Software, and to permit persons to whom the Software is
~ * furnished to do so, subject to the following conditions:
~ *
~ * The above copyright notice and this permission notice shall be included in all
~ * copies or substantial portions of the Software.
~ *
~ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ * SOFTWARE.
~ */
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:fillColor="#00000000"
android:pathData="M10.8337,5.8333C11.2757,5.8333 11.6996,6.0089 12.0122,6.3215C12.3247,6.634 12.5003,7.058 12.5003,7.5V17.5L8.3337,15L4.167,17.5V7.5C4.167,7.058 4.3426,6.634 4.6551,6.3215C4.9677,6.0089 5.3916,5.8333 5.8337,5.8333H10.8337Z"
android:strokeWidth="1.25"
android:strokeColor="@color/colorOnSecondary"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:fillColor="#00000000"
android:pathData="M7.7207,3.3333C7.8672,3.0796 8.078,2.869 8.3318,2.7227C8.5856,2.5764 8.8736,2.4996 9.1665,2.5H14.1665C14.6086,2.5 15.0325,2.6756 15.345,2.9882C15.6576,3.3007 15.8332,3.7246 15.8332,4.1667V14.1667L14.9999,13.6667"
android:strokeWidth="1.25"
android:strokeColor="@color/colorOnSecondary"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
53 changes: 53 additions & 0 deletions app/src/main/res/drawable/ic_day.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--
~ /*
~ * MIT License
~ *
~ * Copyright (c) 2020 Spikey Sanju
~ *
~ * Permission is hereby granted, free of charge, to any person obtaining a copy
~ * of this software and associated documentation files (the "Software"), to deal
~ * in the Software without restriction, including without limitation the rights
~ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ * copies of the Software, and to permit persons to whom the Software is
~ * furnished to do so, subject to the following conditions:
~ *
~ * The above copyright notice and this permission notice shall be included in all
~ * copies or substantial portions of the Software.
~ *
~ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ * SOFTWARE.
~ */
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:fillColor="#00000000"
android:pathData="M15.3333,4.6667L14.75,5.25M2.5,10H3.3333H2.5ZM10,2.5V3.3333V2.5ZM16.6667,10H17.5H16.6667ZM4.6667,4.6667L5.25,5.25L4.6667,4.6667Z"
android:strokeWidth="1.25"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:fillColor="#00000000"
android:pathData="M7.5,13.3333C6.8004,12.8086 6.2836,12.0771 6.0229,11.2424C5.7621,10.4076 5.7706,9.512 6.0472,8.6824C6.3237,7.8528 6.8543,7.1312 7.5637,6.6198C8.2731,6.1085 9.1255,5.8333 10,5.8333C10.8745,5.8333 11.7268,6.1085 12.4363,6.6198C13.1457,7.1312 13.6763,7.8528 13.9528,8.6824C14.2294,9.512 14.2379,10.4076 13.9771,11.2424C13.7164,12.0771 13.1996,12.8086 12.5,13.3333C12.1746,13.6554 11.9297,14.0495 11.7849,14.4839C11.6401,14.9182 11.5996,15.3805 11.6667,15.8333C11.6667,16.2754 11.4911,16.6993 11.1785,17.0119C10.8659,17.3244 10.442,17.5 10,17.5C9.558,17.5 9.134,17.3244 8.8215,17.0119C8.5089,16.6993 8.3333,16.2754 8.3333,15.8333C8.4004,15.3805 8.3599,14.9182 8.2151,14.4839C8.0703,14.0495 7.8253,13.6554 7.5,13.3333"
android:strokeWidth="1.25"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:fillColor="#00000000"
android:pathData="M8.0833,14.1667H11.9167"
android:strokeWidth="1.25"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
46 changes: 46 additions & 0 deletions app/src/main/res/drawable/ic_night.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
~ /*
~ * MIT License
~ *
~ * Copyright (c) 2020 Spikey Sanju
~ *
~ * Permission is hereby granted, free of charge, to any person obtaining a copy
~ * of this software and associated documentation files (the "Software"), to deal
~ * in the Software without restriction, including without limitation the rights
~ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ * copies of the Software, and to permit persons to whom the Software is
~ * furnished to do so, subject to the following conditions:
~ *
~ * The above copyright notice and this permission notice shall be included in all
~ * copies or substantial portions of the Software.
~ *
~ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ * SOFTWARE.
~ */
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:fillColor="#00000000"
android:pathData="M7.5,13.3333C6.8004,12.8086 6.2836,12.0771 6.0229,11.2423C5.7621,10.4076 5.7706,9.512 6.0472,8.6824C6.3237,7.8527 6.8543,7.1311 7.5637,6.6198C8.2731,6.1085 9.1255,5.8333 10,5.8333C10.8745,5.8333 11.7268,6.1085 12.4363,6.6198C13.1457,7.1311 13.6763,7.8527 13.9528,8.6824C14.2294,9.512 14.2379,10.4076 13.9771,11.2423C13.7164,12.0771 13.1996,12.8086 12.5,13.3333C12.1746,13.6554 11.9297,14.0495 11.7849,14.4838C11.6401,14.9181 11.5996,15.3804 11.6667,15.8333C11.6667,16.2753 11.4911,16.6993 11.1785,17.0118C10.8659,17.3244 10.442,17.5 10,17.5C9.558,17.5 9.134,17.3244 8.8215,17.0118C8.5089,16.6993 8.3333,16.2753 8.3333,15.8333C8.4004,15.3804 8.3599,14.9181 8.2151,14.4838C8.0703,14.0495 7.8253,13.6554 7.5,13.3333"
android:strokeWidth="1.25"
android:strokeColor="#ffffff"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:fillColor="#00000000"
android:pathData="M8.0833,14.1667H11.9167"
android:strokeWidth="1.25"
android:strokeColor="#ffffff"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
30 changes: 28 additions & 2 deletions app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ /*
~ * MIT License
~ *
~ * Copyright (c) 2020 Spikey Sanju
~ *
~ * Permission is hereby granted, free of charge, to any person obtaining a copy
~ * of this software and associated documentation files (the "Software"), to deal
~ * in the Software without restriction, including without limitation the rights
~ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ * copies of the Software, and to permit persons to whom the Software is
~ * furnished to do so, subject to the following conditions:
~ *
~ * The above copyright notice and this permission notice shall be included in all
~ * copies or substantial portions of the Software.
~ *
~ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ * SOFTWARE.
~ */
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_bookmark"
android:icon="@drawable/ic_baseline_bookmark"
android:icon="@drawable/ic_bookmarks"
android:title="@string/bookmark"
app:showAsAction="always" />
<item
android:id="@+id/action_night_mode"
android:checkable="true"
android:icon="@drawable/ic_outline_dark"
android:icon="@drawable/ic_day"
android:title="@string/night_mode"
app:showAsAction="ifRoom" />

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0-alpha12'
classpath 'com.android.tools.build:gradle:4.2.0-alpha13'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0"

Expand Down

0 comments on commit ca5fa66

Please sign in to comment.