Krita Source Code Documentation
Loading...
Searching...
No Matches
KisAndroidDonations.cpp
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-3.0-or-later
3 */
5
6#include "KisApplication.h"
7
8#include <QtAndroid>
9
10// See DonationHelper.java for notes!
11
13{
14 KisApplication *app = qobject_cast<KisApplication *>(KisApplication::instance());
15 if (app) {
16 return app->androidDonations();
17 } else {
18 return nullptr;
19 }
20}
21
23{
24 // Normally, we'd want to show a donation link when the state is NoSupport.
25 // However, currently we only have the lifetime badge as a product and we
26 // don't want to continue offering that, so the link is disabled for now.
27 return false;
28}
29
34
36{
37 QAndroidJniObject::callStaticMethod<void>("org/krita/android/DonationHelper", "startBillingFlow", "()V");
38}
39
41{
42 if (int(m_state) != state) {
43 m_state = State(state);
44 Q_EMIT sigStateChanged();
45 }
46}
47
49 : QObject(parent)
50{
51 // The state update can come from a different thread, so we'll use a queued connection.
52 connect(this, SIGNAL(sigStateUpdateReceived(int)), this, SLOT(slotUpdateState(int)), Qt::QueuedConnection);
53}
54
56{
57 QAndroidJniObject::callStaticMethod<void>("org/krita/android/DonationHelper", "syncState", "()V");
58}
59
60extern "C" JNIEXPORT void JNICALL Java_org_krita_android_JNIWrappers_donationStateUpdated(JNIEnv * /*env*/,
61 jobject /*obj*/,
62 jint state)
63{
64 KisApplication *app = qobject_cast<KisApplication *>(KisApplication::instance());
65 if (app) {
66 KisAndroidDonations *androidDonations = app->androidDonations();
67 if (androidDonations) {
68 Q_EMIT androidDonations->sigStateUpdateReceived(state);
69 }
70 }
71}
JNIEXPORT void JNICALL Java_org_krita_android_JNIWrappers_donationStateUpdated(JNIEnv *, jobject, jint state)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
bool shouldShowDonationLink() const
void sigStateUpdateReceived(int state)
bool shouldShowSupporterBadge() const
void slotUpdateState(int state)
KisAndroidDonations(QObject *parent=nullptr)
static KisAndroidDonations * instance()
Base class for the Krita app.