-
Notifications
You must be signed in to change notification settings - Fork 935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
introducing confetti animation using konfetti library #1743
Changes from 1 commit
a2ae1fd
2fd7b44
6901968
d643397
48c0b39
83328b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,15 @@ import android.view.KeyEvent | |
import android.view.LayoutInflater | ||
import android.view.MotionEvent | ||
import android.view.View | ||
import android.widget.LinearLayout | ||
import androidx.appcompat.app.AppCompatDialogFragment | ||
import org.isoron.uhabits.HabitsApplication | ||
import org.isoron.uhabits.R | ||
import org.isoron.uhabits.core.models.Entry | ||
import org.isoron.uhabits.databinding.CheckmarkPopupBinding | ||
import org.isoron.uhabits.utils.InterfaceUtils | ||
import org.isoron.uhabits.utils.requestFocusWithKeyboard | ||
import org.isoron.uhabits.utils.showConfetti | ||
import org.isoron.uhabits.utils.sres | ||
import java.text.DecimalFormat | ||
import java.text.DecimalFormatSymbols | ||
|
@@ -100,5 +102,11 @@ class NumberDialog : AppCompatDialogFragment() { | |
val notes = view.notes.text.toString() | ||
onToggle(value, notes) | ||
requireDialog().dismiss() | ||
val v = requireActivity().findViewById<LinearLayout>(R.id.konfettiLayout) | ||
|
||
if (value > 0.0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it should be on completion rather than for any value? Not sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a code comment. Reason: I thought it would be motivating for users to at least add some value rather than not doing the habit. 😸 |
||
showConfetti(v) | ||
|
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ import org.isoron.uhabits.core.preferences.Preferences | |
import org.isoron.uhabits.inject.ActivityContext | ||
import org.isoron.uhabits.utils.drawNotesIndicator | ||
import org.isoron.uhabits.utils.getFontAwesome | ||
import org.isoron.uhabits.utils.showConfetti | ||
import org.isoron.uhabits.utils.sp | ||
import org.isoron.uhabits.utils.sres | ||
import org.isoron.uhabits.utils.toMeasureSpec | ||
|
@@ -88,25 +89,28 @@ class CheckmarkButtonView( | |
setOnLongClickListener(this) | ||
} | ||
|
||
fun performToggle() { | ||
fun performToggle(v: View) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark about this |
||
value = Entry.nextToggleValue( | ||
value = value, | ||
isSkipEnabled = preferences.isSkipEnabled, | ||
areQuestionMarksEnabled = preferences.areQuestionMarksEnabled | ||
) | ||
onToggle(value, notes) | ||
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) | ||
when (value) { | ||
YES_MANUAL -> showConfetti(v.rootView) | ||
} | ||
invalidate() | ||
} | ||
|
||
override fun onClick(v: View) { | ||
if (preferences.isShortToggleEnabled) performToggle() | ||
if (preferences.isShortToggleEnabled) performToggle(v) | ||
else onEdit() | ||
} | ||
|
||
override fun onLongClick(v: View): Boolean { | ||
if (preferences.isShortToggleEnabled) onEdit() | ||
else performToggle() | ||
else performToggle(v) | ||
return true | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ Copyright (C) 2013 The Android Open Source Project | ||
~ | ||
~ 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 | ||
--> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/konfettiLayout" | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:focusable="false" | ||
android:orientation="vertical" > | ||
|
||
<nl.dionsegijn.konfetti.xml.KonfettiView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:id="@+id/konfettttiView"/> | ||
|
||
</LinearLayout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v
is calledkonfettiView
above, consistency?