mirror of
https://github.com/QuasarApp/QtAndroidTools.git
synced 2025-04-29 06:24:32 +00:00
Start adding tool for signin on Google account and manage Google Drive
This commit is contained in:
parent
46c9cb6ddd
commit
b872cc3acc
104
QtAndroidTools/QAndroidGoogleAccount.cpp
Normal file
104
QtAndroidTools/QAndroidGoogleAccount.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 Fabio Falsini <falsinsoft@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include "QAndroidGoogleAccount.h"
|
||||
|
||||
QAndroidGoogleAccount *QAndroidGoogleAccount::m_pInstance = nullptr;
|
||||
|
||||
QAndroidGoogleAccount::QAndroidGoogleAccount() : m_JavaGoogleAccount("com/falsinsoft/qtandroidtools/AndroidGoogleAccount",
|
||||
"(Landroid/app/Activity;)V",
|
||||
QtAndroid::androidActivity().object<jobject>())
|
||||
{
|
||||
m_pInstance = this;
|
||||
|
||||
LoadLastSignedInAccountInfo();
|
||||
}
|
||||
|
||||
QObject* QAndroidGoogleAccount::qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine);
|
||||
Q_UNUSED(scriptEngine);
|
||||
|
||||
return new QAndroidGoogleAccount();
|
||||
}
|
||||
|
||||
QAndroidGoogleAccount* QAndroidGoogleAccount::instance()
|
||||
{
|
||||
return m_pInstance;
|
||||
}
|
||||
|
||||
bool QAndroidGoogleAccount::signIn()
|
||||
{
|
||||
if(m_JavaGoogleAccount.isValid())
|
||||
{
|
||||
const std::function<void (int, int, const QAndroidJniObject &)> ActivityResultFunc = std::bind(&QAndroidGoogleAccount::ActivityResult, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
|
||||
QtAndroid::startActivity(m_JavaGoogleAccount.callObjectMethod("getSignInIntent", "()Landroid/content/Intent;"),
|
||||
m_SignInId,
|
||||
ActivityResultFunc
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QAndroidGoogleAccount::LoadLastSignedInAccountInfo()
|
||||
{
|
||||
if(m_JavaGoogleAccount.isValid())
|
||||
{
|
||||
const QAndroidJniObject AccountInfoObj = m_JavaGoogleAccount.callObjectMethod("getLastSignedInAccountInfo",
|
||||
"()Lcom/falsinsoft/qtandroidtools/AndroidGoogleAccount$AccountInfo;"
|
||||
);
|
||||
if(AccountInfoObj.isValid())
|
||||
{
|
||||
m_LastSignedInAccountInfo.Id = AccountInfoObj.getObjectField<jstring>("id").toString();
|
||||
m_LastSignedInAccountInfo.DisplayName = AccountInfoObj.getObjectField<jstring>("displayName").toString();
|
||||
m_LastSignedInAccountInfo.Email = AccountInfoObj.getObjectField<jstring>("email").toString();
|
||||
m_LastSignedInAccountInfo.FamilyName = AccountInfoObj.getObjectField<jstring>("familyName").toString();
|
||||
m_LastSignedInAccountInfo.GivenName = AccountInfoObj.getObjectField<jstring>("givenName").toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QAndroidGoogleLastSignedInAccountInfo& QAndroidGoogleAccount::getLastSignedInAccountInfo() const
|
||||
{
|
||||
return m_LastSignedInAccountInfo;
|
||||
}
|
||||
|
||||
void QAndroidGoogleAccount::ActivityResult(int RequestCode, int ResultCode, const QAndroidJniObject &Data)
|
||||
{
|
||||
Q_UNUSED(ResultCode);
|
||||
|
||||
if(RequestCode == m_SignInId)
|
||||
{
|
||||
if(m_JavaGoogleAccount.isValid())
|
||||
{
|
||||
m_JavaGoogleAccount.callMethod<void>("signInIntentDataResult",
|
||||
"(Landroid/content/Intent;)V",
|
||||
Data.object()
|
||||
);
|
||||
LoadLastSignedInAccountInfo();
|
||||
}
|
||||
}
|
||||
}
|
73
QtAndroidTools/QAndroidGoogleAccount.h
Normal file
73
QtAndroidTools/QAndroidGoogleAccount.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 Fabio Falsini <falsinsoft@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtAndroidExtras>
|
||||
#include <QQmlEngine>
|
||||
#include <QImage>
|
||||
|
||||
struct QAndroidGoogleLastSignedInAccountInfo
|
||||
{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString id MEMBER Id)
|
||||
Q_PROPERTY(QString displayName MEMBER DisplayName)
|
||||
Q_PROPERTY(QString email MEMBER Email)
|
||||
Q_PROPERTY(QString familyName MEMBER FamilyName)
|
||||
Q_PROPERTY(QString givenName MEMBER GivenName)
|
||||
Q_PROPERTY(QImage photo MEMBER Photo)
|
||||
public:
|
||||
QString Id;
|
||||
QString DisplayName;
|
||||
QString Email;
|
||||
QString FamilyName;
|
||||
QString GivenName;
|
||||
QImage Photo;
|
||||
};
|
||||
Q_DECLARE_METATYPE(QAndroidGoogleLastSignedInAccountInfo)
|
||||
|
||||
class QAndroidGoogleAccount : public QObject
|
||||
{
|
||||
Q_PROPERTY(QAndroidGoogleLastSignedInAccountInfo lastSignedInAccount READ getLastSignedInAccountInfo)
|
||||
Q_DISABLE_COPY(QAndroidGoogleAccount)
|
||||
Q_OBJECT
|
||||
|
||||
QAndroidGoogleAccount();
|
||||
|
||||
public:
|
||||
|
||||
static QObject* qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine);
|
||||
static QAndroidGoogleAccount* instance();
|
||||
|
||||
Q_INVOKABLE bool signIn();
|
||||
const QAndroidGoogleLastSignedInAccountInfo& getLastSignedInAccountInfo() const;
|
||||
|
||||
private:
|
||||
const QAndroidJniObject m_JavaGoogleAccount;
|
||||
static QAndroidGoogleAccount *m_pInstance;
|
||||
const int m_SignInId = 9001;
|
||||
QAndroidGoogleLastSignedInAccountInfo m_LastSignedInAccountInfo;
|
||||
|
||||
void ActivityResult(int RequestCode, int ResultCode, const QAndroidJniObject &Data);
|
||||
void LoadLastSignedInAccountInfo();
|
||||
};
|
47
QtAndroidTools/QAndroidGoogleDrive.cpp
Normal file
47
QtAndroidTools/QAndroidGoogleDrive.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 Fabio Falsini <falsinsoft@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include "QAndroidGoogleDrive.h"
|
||||
|
||||
QAndroidGoogleDrive *QAndroidGoogleDrive::m_pInstance = nullptr;
|
||||
|
||||
QAndroidGoogleDrive::QAndroidGoogleDrive() : m_JavaGoogleDrive("com/falsinsoft/qtandroidtools/AndroidGoogleDrive",
|
||||
"(Landroid/app/Activity;)V",
|
||||
QtAndroid::androidActivity().object<jobject>())
|
||||
{
|
||||
m_pInstance = this;
|
||||
}
|
||||
|
||||
QObject* QAndroidGoogleDrive::qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine);
|
||||
Q_UNUSED(scriptEngine);
|
||||
|
||||
return new QAndroidGoogleDrive();
|
||||
}
|
||||
|
||||
QAndroidGoogleDrive* QAndroidGoogleDrive::instance()
|
||||
{
|
||||
return m_pInstance;
|
||||
}
|
||||
|
44
QtAndroidTools/QAndroidGoogleDrive.h
Normal file
44
QtAndroidTools/QAndroidGoogleDrive.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 Fabio Falsini <falsinsoft@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtAndroidExtras>
|
||||
#include <QQmlEngine>
|
||||
|
||||
class QAndroidGoogleDrive : public QObject
|
||||
{
|
||||
Q_DISABLE_COPY(QAndroidGoogleDrive)
|
||||
Q_OBJECT
|
||||
|
||||
QAndroidGoogleDrive();
|
||||
|
||||
public:
|
||||
|
||||
static QObject* qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine);
|
||||
static QAndroidGoogleDrive* instance();
|
||||
|
||||
private:
|
||||
const QAndroidJniObject m_JavaGoogleDrive;
|
||||
static QAndroidGoogleDrive *m_pInstance;
|
||||
};
|
@ -58,6 +58,12 @@
|
||||
#ifdef QTAT_PLAY_STORE
|
||||
#include "QAndroidPlayStore.h"
|
||||
#endif
|
||||
#ifdef QTAT_GOOGLE_ACCOUNT
|
||||
#include "QAndroidGoogleAccount.h"
|
||||
#endif
|
||||
#ifdef QTAT_GOOGLE_DRIVE
|
||||
#include "QAndroidGoogleDrive.h"
|
||||
#endif
|
||||
#include "QtAndroidTools.h"
|
||||
|
||||
QtAndroidTools::QtAndroidTools()
|
||||
@ -102,4 +108,10 @@ void QtAndroidTools::InitializeQmlTools()
|
||||
#ifdef QTAT_PLAY_STORE
|
||||
qmlRegisterSingletonType<QAndroidPlayStore>("QtAndroidTools", 1, 0, "QtAndroidPlayStore", &QAndroidPlayStore::qmlInstance);
|
||||
#endif
|
||||
#ifdef QTAT_GOOGLE_ACCOUNT
|
||||
qmlRegisterSingletonType<QAndroidGoogleAccount>("QtAndroidTools", 1, 0, "QtAndroidGoogleAccount", &QAndroidGoogleAccount::qmlInstance);
|
||||
#endif
|
||||
#ifdef QTAT_GOOGLE_DRIVE
|
||||
qmlRegisterSingletonType<QAndroidGoogleDrive>("QtAndroidTools", 1, 0, "QtAndroidGoogleDrive", &QAndroidGoogleDrive::qmlInstance);
|
||||
#endif
|
||||
}
|
||||
|
@ -121,3 +121,20 @@ contains(DEFINES, QTAT_PLAY_STORE) {
|
||||
QMAKE_EXTRA_TARGETS += copy_play_store
|
||||
}
|
||||
|
||||
contains(DEFINES, QTAT_GOOGLE_ACCOUNT) {
|
||||
HEADERS += $$PWD/QAndroidGoogleAccount.h
|
||||
SOURCES += $$PWD/QAndroidGoogleAccount.cpp
|
||||
OTHER_FILES += $$PWD/src/com/falsinsoft/qtandroidtools/AndroidGoogleAccount.java
|
||||
copy_google_account.commands = $(COPY_FILE) $$shell_path($$PWD/src/com/falsinsoft/qtandroidtools/AndroidGoogleAccount.java) $$shell_path($$ANDROID_PACKAGE_SOURCE_DIR/src/com/falsinsoft/qtandroidtools/)
|
||||
PRE_TARGETDEPS += copy_google_account
|
||||
QMAKE_EXTRA_TARGETS += copy_google_account
|
||||
}
|
||||
|
||||
contains(DEFINES, QTAT_GOOGLE_DRIVE) {
|
||||
HEADERS += $$PWD/QAndroidGoogleDrive.h
|
||||
SOURCES += $$PWD/QAndroidGoogleDrive.cpp
|
||||
OTHER_FILES += $$PWD/src/com/falsinsoft/qtandroidtools/AndroidGoogleDrive.java
|
||||
copy_google_drive.commands = $(COPY_FILE) $$shell_path($$PWD/src/com/falsinsoft/qtandroidtools/AndroidGoogleDrive.java) $$shell_path($$ANDROID_PACKAGE_SOURCE_DIR/src/com/falsinsoft/qtandroidtools/)
|
||||
PRE_TARGETDEPS += copy_google_drive
|
||||
QMAKE_EXTRA_TARGETS += copy_google_drive
|
||||
}
|
||||
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 Fabio Falsini <falsinsoft@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.falsinsoft.qtandroidtools;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.ComponentName;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
|
||||
import com.google.android.gms.common.Scopes;
|
||||
import com.google.android.gms.common.SignInButton;
|
||||
import com.google.android.gms.common.api.ApiException;
|
||||
import com.google.android.gms.common.api.Scope;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AndroidGoogleAccount
|
||||
{
|
||||
private final Activity mActivityInstance;
|
||||
private GoogleSignInClient mGoogleSignInClient;
|
||||
private GoogleSignInAccount mLastSignedInAccount;
|
||||
|
||||
public AndroidGoogleAccount(Activity ActivityInstance)
|
||||
{
|
||||
mLastSignedInAccount = GoogleSignIn.getLastSignedInAccount(ActivityInstance);
|
||||
mActivityInstance = ActivityInstance;
|
||||
getSignInClient(ActivityInstance);
|
||||
}
|
||||
|
||||
private void getSignInClient(Activity ActivityInstance)
|
||||
{
|
||||
GoogleSignInOptions SignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
||||
.requestProfile()
|
||||
.requestEmail()
|
||||
.build();
|
||||
|
||||
mGoogleSignInClient = GoogleSignIn.getClient(ActivityInstance, SignInOptions);
|
||||
}
|
||||
|
||||
public AccountInfo getLastSignedInAccountInfo()
|
||||
{
|
||||
AccountInfo Account = null;
|
||||
|
||||
if(mLastSignedInAccount != null)
|
||||
{
|
||||
final Uri PhotoUrl = mLastSignedInAccount.getPhotoUrl();
|
||||
Account = new AccountInfo();
|
||||
|
||||
Account.id = mLastSignedInAccount.getId();
|
||||
Account.displayName = mLastSignedInAccount.getDisplayName();
|
||||
Account.email = mLastSignedInAccount.getEmail();
|
||||
Account.familyName = mLastSignedInAccount.getFamilyName();
|
||||
Account.givenName = mLastSignedInAccount.getGivenName();
|
||||
}
|
||||
|
||||
return Account;
|
||||
}
|
||||
|
||||
public Intent getSignInIntent()
|
||||
{
|
||||
return mGoogleSignInClient.getSignInIntent();
|
||||
}
|
||||
|
||||
public void signInIntentDataResult(Intent Data)
|
||||
{
|
||||
Task<GoogleSignInAccount> SignInTask = GoogleSignIn.getSignedInAccountFromIntent(Data);
|
||||
|
||||
if(SignInTask.isSuccessful())
|
||||
{
|
||||
try
|
||||
{
|
||||
mLastSignedInAccount = SignInTask.getResult(ApiException.class);
|
||||
}
|
||||
catch(ApiException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class AccountInfo
|
||||
{
|
||||
public String id;
|
||||
public String displayName;
|
||||
public String email;
|
||||
public String familyName;
|
||||
public String givenName;
|
||||
public String photoUrl;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 Fabio Falsini <falsinsoft@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.falsinsoft.qtandroidtools;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.graphics.Bitmap;
|
||||
import android.provider.MediaStore;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.ComponentName;
|
||||
|
||||
public class AndroidGoogleDrive
|
||||
{
|
||||
private final Activity mActivityInstance;
|
||||
|
||||
public AndroidGoogleDrive(Activity ActivityInstance)
|
||||
{
|
||||
mActivityInstance = ActivityInstance;
|
||||
}
|
||||
}
|
@ -95,6 +95,7 @@ ApplicationWindow {
|
||||
ListElement { title: "AdMobInterstitial"; source: "qrc:/tools/AndroidAdMobInterstitial.qml" }
|
||||
ListElement { title: "AdMobRewardedVideo"; source: "qrc:/tools/AndroidAdMobRewardedVideo.qml" }
|
||||
ListElement { title: "PlayStore"; source: "qrc:/tools/AndroidPlayStore.qml" }
|
||||
ListElement { title: "GoogleAccount"; source: "qrc:/tools/AndroidGoogleAccount.qml" }
|
||||
}
|
||||
|
||||
ScrollIndicator.vertical: ScrollIndicator { }
|
||||
|
@ -33,7 +33,9 @@ DEFINES += \
|
||||
QTAT_ADMOB_BANNER \
|
||||
QTAT_ADMOB_INTERSTITIAL \
|
||||
QTAT_ADMOB_REWARDED_VIDEO \
|
||||
QTAT_PLAY_STORE
|
||||
QTAT_PLAY_STORE \
|
||||
QTAT_GOOGLE_ACCOUNT \
|
||||
QTAT_GOOGLE_DRIVE
|
||||
include(../QtAndroidTools/QtAndroidTools.pri)
|
||||
}
|
||||
|
||||
|
@ -14,5 +14,6 @@
|
||||
<file>tools/AndroidNotification.qml</file>
|
||||
<file>tools/AndroidPlayStore.qml</file>
|
||||
<file>tools/AndroidAdMobRewardedVideo.qml</file>
|
||||
<file>tools/AndroidGoogleAccount.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -69,16 +69,16 @@
|
||||
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26"/>
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
|
||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default permissions. -->
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default features. -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="com.android.vending.CHECK_LICENSE"/>
|
||||
@ -90,4 +90,5 @@
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR"/>
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
|
||||
</manifest>
|
||||
|
@ -20,6 +20,7 @@ dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:support-v4:26.+'
|
||||
implementation 'com.google.android.gms:play-services-ads:16.+'
|
||||
implementation 'com.google.android.gms:play-services-auth:16.+'
|
||||
}
|
||||
|
||||
android {
|
||||
|
71
QtAndroidToolsDemo/tools/AndroidGoogleAccount.qml
Normal file
71
QtAndroidToolsDemo/tools/AndroidGoogleAccount.qml
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Dialogs 1.3
|
||||
import QtAndroidTools 1.0
|
||||
|
||||
Page {
|
||||
id: page
|
||||
padding: 0
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: 5
|
||||
|
||||
Label {
|
||||
font.bold: true
|
||||
font.pixelSize: 15
|
||||
text: "Id:"
|
||||
}
|
||||
Label {
|
||||
font.pixelSize: 15
|
||||
text: QtAndroidGoogleAccount.lastSignedInAccount.id
|
||||
}
|
||||
|
||||
Label {
|
||||
font.bold: true
|
||||
font.pixelSize: 15
|
||||
text: "DisplayName:"
|
||||
}
|
||||
Label {
|
||||
font.pixelSize: 15
|
||||
text: QtAndroidGoogleAccount.lastSignedInAccount.displayName
|
||||
}
|
||||
|
||||
Label {
|
||||
font.bold: true
|
||||
font.pixelSize: 15
|
||||
text: "Email:"
|
||||
}
|
||||
Label {
|
||||
font.pixelSize: 15
|
||||
text: QtAndroidGoogleAccount.lastSignedInAccount.email
|
||||
}
|
||||
|
||||
Label {
|
||||
font.bold: true
|
||||
font.pixelSize: 15
|
||||
text: "FamilyName:"
|
||||
}
|
||||
Label {
|
||||
font.pixelSize: 15
|
||||
text: QtAndroidGoogleAccount.lastSignedInAccount.familyName
|
||||
}
|
||||
|
||||
Label {
|
||||
font.bold: true
|
||||
font.pixelSize: 15
|
||||
text: "GivenName:"
|
||||
}
|
||||
Label {
|
||||
font.pixelSize: 15
|
||||
text: QtAndroidGoogleAccount.lastSignedInAccount.givenName
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "sigIn"
|
||||
onClicked: QtAndroidGoogleAccount.signIn()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user