Overte C++ Documentation
AndroidHelper.h
1 //
2 // AndroidHelper.h
3 // interface/src
4 //
5 // Created by Gabriel Calero & Cristian Duarte on 3/30/18.
6 // Copyright 2018 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_Android_Helper_h
13 #define hifi_Android_Helper_h
14 
15 #include <QObject>
16 #include <QMap>
17 #include <QUrl>
18 
19 #include <QNetworkReply>
20 #include <QtCore/QEventLoop>
21 
22 class AndroidHelper : public QObject {
23  Q_OBJECT
24 public:
25  static AndroidHelper& instance() {
26  static AndroidHelper instance;
27  return instance;
28  }
29  void requestActivity(const QString &activityName, const bool backToScene, QMap<QString, QString> args = QMap<QString, QString>());
30  void notifyLoadComplete();
31  void notifyEnterForeground();
32  void notifyBeforeEnterBackground();
33  void notifyEnterBackground();
34  void notifyToggleAwayMode();
35 
36  void performHapticFeedback(int duration);
37  void processURL(const QString &url);
38  void notifyHeadsetOn(bool pluggedIn);
39  void muteMic();
40 
41  AndroidHelper(AndroidHelper const&) = delete;
42  void operator=(AndroidHelper const&) = delete;
43 
44  void signup(QString email, QString username, QString password);
45  QString getDisplayName();
46  void setDisplayName(const QString &displayName);
47  void setMyAvatarUrl(const QString &avatarUrl);
48 
49 public slots:
50  void showLoginDialog(QUrl url);
51  void signupCompleted(QNetworkReply* reply);
52  void signupFailed(QNetworkReply* reply);
53 signals:
54  void androidActivityRequested(const QString &activityName, const bool backToScene, QMap<QString, QString> args = QMap<QString, QString>());
55  void qtAppLoadComplete();
56  void enterForeground();
57  void beforeEnterBackground();
58  void enterBackground();
59  void toggleAwayMode();
60  void hapticFeedbackRequested(int duration);
61 
62  void handleSignupCompleted();
63  void handleSignupFailed(QString errorString);
64 
65 private:
66  AndroidHelper();
67  ~AndroidHelper();
68 
69  QString errorStringFromAPIObject(const QJsonValue& apiObject);
70 };
71 
72 #endif