Android Back button like home button (#212)
the build was successful Details

This commit is contained in:
Dan Ballard 2019-09-13 16:24:58 -07:00 committed by Gogs
父節點 fb0e5117c1
當前提交 6af91b71c1
共有 4 個文件被更改,包括 41 次插入4 次删除

查看文件

@ -124,4 +124,11 @@ public class CwtchActivity extends org.qtproject.qt5.android.bindings.QtActivity
}
}
// handle root level back button push as a home button push: don't exit, just go to home screen
public static void rootHomeHandle() {
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
m_instance.startActivity(i);
}
}

查看文件

@ -1,6 +1,7 @@
package android
import (
"git.openprivacy.ca/openprivacy/libricochet-go/log"
"github.com/therecipe/qt/androidextras"
"github.com/therecipe/qt/core"
)
@ -13,10 +14,12 @@ type CwtchActivity struct {
_ string `property:"notification"`
_ func(string) `slot:"updateAndroidNotification"`
_ func() `signal:"rootHomeButtonHandle,auto"`
}
func (c *CwtchActivity) init() {
log.Debugln("CwtchActivity.init()")
c.createOngoingNotification()
c.ConnectNotificationChanged(c.updateAndroidNotification)
}
@ -31,7 +34,7 @@ func (c *CwtchActivity) updateAndroidNotification(n string) {
)
if err != nil {
println(err.Error())
log.Errorf("Error calling Java CwtchActivity.notify(): %v\n", err.Error())
}
}
@ -45,6 +48,19 @@ func (c *CwtchActivity) createOngoingNotification() {
)
if err != nil {
println(err.Error())
log.Errorf("Error calling Java CwtchActivity.ongoingNotify(): %v\n", err.Error())
}
}
func (c *CwtchActivity) rootHomeButtonHandle() {
log.Infoln("CwtchActivity.rootHomeButtonHandle()!")
var err = androidextras.QAndroidJniObject_CallStaticMethodVoid2Caught(
"ca/openprivacy/cwtch/ui/CwtchActivity",
"rootHomeHandle",
"()V",
)
if err != nil {
log.Errorf("Error calling Java CwtchActivity.rootHomeButtonHandle(): %v\n", err.Error())
}
}

查看文件

@ -75,7 +75,7 @@ type GrandCentralDispatcher struct {
_ func(onion, nick string) `signal:"savePeerSettings,auto"`
_ func(onion, groupID string) `signal:"inviteToGroup,auto"`
_ func(onion, key, nick string) `signal:"setAttribute,auto"`
_ func(onion string) `signal:"deleteContact,auto""`
_ func(onion string) `signal:"deleteContact,auto"`
_ func(locale string) `signal:"setLocale,auto"`
_ func() `signal:"allowUnknownPeers,auto"`
_ func() `signal:"blockUnknownPeers,auto"`

查看文件

@ -195,6 +195,20 @@ ApplicationWindow {
}
}
}
focus: true
Keys.onPressed: {
if (event.key == Qt.Key_Back) {
event.accepted = true
if (theStack.currentIndex == theStack.emptyPane) {
androidCwtchActivity.rootHomeButtonHandle()
} else if (theStack.currentIndex == theStack.userProfilePane || theStack.currentIndex == theStack.groupProfilePane) {
theStack.currentIndex = theStack.messagePane
} else {
theStack.currentIndex = theStack.emptyPane
}
}
}
}
PropertyAnimation { id: anmPopup; easing.type: Easing.InQuart; duration: 7000; target: popup; property: "opacity"; to: 0; }