mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:24:24 +02:00
Add haptic feedback to back, view and mic buttons
This commit is contained in:
parent
8923c16b08
commit
103e9f92fa
10 changed files with 40 additions and 1 deletions
|
@ -155,6 +155,11 @@ JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCrea
|
||||||
QAndroidJniObject string = QAndroidJniObject::fromString(a);
|
QAndroidJniObject string = QAndroidJniObject::fromString(a);
|
||||||
__interfaceActivity.callMethod<void>("openGotoActivity", "(Ljava/lang/String;)V", string.object<jstring>());
|
__interfaceActivity.callMethod<void>("openGotoActivity", "(Ljava/lang/String;)V", string.object<jstring>());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QObject::connect(&AndroidHelper::instance(), &AndroidHelper::hapticFeedbackRequested, [](const QString &c) {
|
||||||
|
QAndroidJniObject string = QAndroidJniObject::fromString(c);
|
||||||
|
__interfaceActivity.callMethod<void>("performHapticFeedback", "(Ljava/lang/String;)V", string.object<jstring>());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnDestroy(JNIEnv* env, jobject obj) {
|
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnDestroy(JNIEnv* env, jobject obj) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.content.Intent;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.qtproject.qt5.android.bindings.QtActivity;
|
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||||
|
@ -218,4 +219,13 @@ public class InterfaceActivity extends QtActivity {
|
||||||
super.isLoading = false;
|
super.isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void performHapticFeedback(String feedbackConstant) {
|
||||||
|
switch (feedbackConstant) {
|
||||||
|
case "CONTEXT_CLICK":
|
||||||
|
default:
|
||||||
|
findViewById(android.R.id.content).performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -286,4 +286,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
int index = getFragmentManager().getBackStackEntryCount() - 1;
|
||||||
|
if (index > -1) {
|
||||||
|
super.onBackPressed();
|
||||||
|
} else {
|
||||||
|
finishAffinity();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,3 +48,7 @@ void AndroidHelper::notifyLoginComplete(bool success) {
|
||||||
emit loginComplete(success);
|
emit loginComplete(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidHelper::performHapticFeedback(const QString& feedbackConstant) {
|
||||||
|
emit hapticFeedbackRequested(feedbackConstant);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
void goBackFromAndroidActivity();
|
void goBackFromAndroidActivity();
|
||||||
|
|
||||||
void notifyLoginComplete(bool success);
|
void notifyLoginComplete(bool success);
|
||||||
|
void performHapticFeedback(const QString& feedbackConstant);
|
||||||
|
|
||||||
QSharedPointer<AccountManager> getAccountManager();
|
QSharedPointer<AccountManager> getAccountManager();
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ signals:
|
||||||
void backFromAndroidActivity();
|
void backFromAndroidActivity();
|
||||||
void qtAppLoadComplete();
|
void qtAppLoadComplete();
|
||||||
void loginComplete(bool success);
|
void loginComplete(bool success);
|
||||||
|
void hapticFeedbackRequested(const QString &feedbackConstant);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AndroidHelper();
|
AndroidHelper();
|
||||||
|
|
|
@ -7950,6 +7950,10 @@ void Application::restoreAfterAndroidActivity() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::performHapticFeedback(const QString& feedbackConstant) {
|
||||||
|
AndroidHelper::instance().performHapticFeedback(feedbackConstant);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
void Application::enterBackground() {
|
void Application::enterBackground() {
|
||||||
qDebug() << "[Background-HIFI] enterBackground begin";
|
qDebug() << "[Background-HIFI] enterBackground begin";
|
||||||
|
|
|
@ -408,6 +408,7 @@ public slots:
|
||||||
Q_INVOKABLE bool askBeforeSetAvatarUrl(const QString& avatarUrl) { return askToSetAvatarUrl(avatarUrl); }
|
Q_INVOKABLE bool askBeforeSetAvatarUrl(const QString& avatarUrl) { return askToSetAvatarUrl(avatarUrl); }
|
||||||
|
|
||||||
Q_INVOKABLE void openAndroidActivity(const QString& activityName);
|
Q_INVOKABLE void openAndroidActivity(const QString& activityName);
|
||||||
|
Q_INVOKABLE void performHapticFeedback(const QString& feedbackConstant);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDesktopRootItemCreated(QQuickItem* qmlContext);
|
void onDesktopRootItemCreated(QQuickItem* qmlContext);
|
||||||
|
|
|
@ -38,7 +38,8 @@ function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBackPressed() {
|
function onBackPressed() {
|
||||||
App.openAndroidActivity("Goto");
|
App.performHapticFeedback("CONTEXT_CLICK");
|
||||||
|
App.openAndroidActivity("Goto");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ function onMuteClicked() {
|
||||||
printd("On Mute Clicked");
|
printd("On Mute Clicked");
|
||||||
//Menu.setIsOptionChecked("Mute Microphone", !Menu.isOptionChecked("Mute Microphone"));
|
//Menu.setIsOptionChecked("Mute Microphone", !Menu.isOptionChecked("Mute Microphone"));
|
||||||
Audio.muted = !Audio.muted;
|
Audio.muted = !Audio.muted;
|
||||||
|
App.performHapticFeedback("CONTEXT_CLICK");
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMuteToggled() {
|
function onMuteToggled() {
|
||||||
|
|
|
@ -59,6 +59,7 @@ function init() {
|
||||||
switchToMode(getCurrentModeSetting());
|
switchToMode(getCurrentModeSetting());
|
||||||
|
|
||||||
modeButton.clicked.connect(function() {
|
modeButton.clicked.connect(function() {
|
||||||
|
App.performHapticFeedback("CONTEXT_CLICK");
|
||||||
switchToMode(nextMode[currentMode]);
|
switchToMode(nextMode[currentMode]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue