mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 03:22:27 +02:00
Set the current address as default in the Go To screen
This commit is contained in:
parent
6b1e22c226
commit
a073cba4d4
3 changed files with 48 additions and 0 deletions
|
@ -182,4 +182,26 @@ JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeGoBack
|
|||
AndroidHelper::instance().goBackFromAndroidActivity();
|
||||
}
|
||||
|
||||
// HifiUtils
|
||||
JNIEXPORT jstring JNICALL Java_io_highfidelity_hifiinterface_HifiUtils_getCurrentAddress(JNIEnv *env, jobject instance) {
|
||||
QSharedPointer<AddressManager> addressManager = DependencyManager::get<AddressManager>();
|
||||
if (!addressManager) {
|
||||
return env->NewString(nullptr, 0);
|
||||
}
|
||||
|
||||
QString str;
|
||||
if (!addressManager->getPlaceName().isEmpty()) {
|
||||
str = addressManager->getPlaceName();
|
||||
} else if (!addressManager->getHost().isEmpty()) {
|
||||
str = addressManager->getHost();
|
||||
}
|
||||
|
||||
QRegExp pathRegEx("(\\/[^\\/]+)");
|
||||
if (!addressManager->currentPath().isEmpty() && addressManager->currentPath().contains(pathRegEx) && pathRegEx.matchedLength() > 0) {
|
||||
str += pathRegEx.cap(0);
|
||||
}
|
||||
|
||||
return env->NewStringUTF(str.toLatin1().data());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ public class GotoActivity extends AppCompatActivity {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mUrlEditText.setText(HifiUtils.getInstance().getCurrentAddress());
|
||||
|
||||
mGoBtn = (AppCompatButton) findViewById(R.id.go_btn);
|
||||
|
||||
mGoBtn.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package io.highfidelity.hifiinterface;
|
||||
|
||||
/**
|
||||
* Created by Gabriel Calero & Cristian Duarte on 4/13/18.
|
||||
*/
|
||||
|
||||
public class HifiUtils {
|
||||
|
||||
private static HifiUtils instance;
|
||||
|
||||
private HifiUtils() {
|
||||
}
|
||||
|
||||
public static HifiUtils getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new HifiUtils();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public native String getCurrentAddress();
|
||||
|
||||
}
|
Loading…
Reference in a new issue