mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 12:51:17 +02:00
First Android Go To implementation (from the Home screen)
This commit is contained in:
parent
fe3c6cf8d6
commit
20acfdfb82
3 changed files with 62 additions and 1 deletions
|
@ -1,14 +1,22 @@
|
||||||
package io.highfidelity.hifiinterface;
|
package io.highfidelity.hifiinterface;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.NavUtils;
|
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.AppCompatButton;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
public class GotoActivity extends AppCompatActivity {
|
public class GotoActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private EditText mUrlEditText;
|
||||||
|
private AppCompatButton mGoBtn;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -20,6 +28,41 @@ public class GotoActivity extends AppCompatActivity {
|
||||||
|
|
||||||
ActionBar actionbar = getSupportActionBar();
|
ActionBar actionbar = getSupportActionBar();
|
||||||
actionbar.setDisplayHomeAsUpEnabled(true);
|
actionbar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
mUrlEditText = (EditText) findViewById(R.id.url_text);
|
||||||
|
mUrlEditText.setOnKeyListener(new View.OnKeyListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onKey(View view, int i, KeyEvent keyEvent) {
|
||||||
|
if (i == KeyEvent.KEYCODE_ENTER) {
|
||||||
|
actionGo();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mGoBtn = (AppCompatButton) findViewById(R.id.go_btn);
|
||||||
|
|
||||||
|
mGoBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
actionGo();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void actionGo() {
|
||||||
|
String urlString = mUrlEditText.getText().toString();
|
||||||
|
if (!urlString.trim().isEmpty()) {
|
||||||
|
Intent intent = new Intent(this, InterfaceActivity.class);
|
||||||
|
intent.putExtra(InterfaceActivity.DOMAIN_URL, urlString);
|
||||||
|
finish();
|
||||||
|
if (getIntent() != null &&
|
||||||
|
getIntent().hasExtra(HomeActivity.PARAM_NOT_START_INTERFACE_ACTIVITY) &&
|
||||||
|
getIntent().getBooleanExtra(HomeActivity.PARAM_NOT_START_INTERFACE_ACTIVITY, false)) {
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
}
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,4 +15,20 @@
|
||||||
app:layout_constraintTop_toTopOf="@id/root_activity_goto"
|
app:layout_constraintTop_toTopOf="@id/root_activity_goto"
|
||||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/url_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/goto_url_hint"
|
||||||
|
android:inputType="text"
|
||||||
|
android:imeOptions="actionGo"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||||
|
/>
|
||||||
|
<android.support.v7.widget.AppCompatButton
|
||||||
|
android:id="@+id/go_btn"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/go"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/url_text"/>
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
|
@ -11,5 +11,7 @@
|
||||||
<string name="bookmarks">BOOKMARKS</string>
|
<string name="bookmarks">BOOKMARKS</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="action_goto">Go To</string>
|
<string name="action_goto">Go To</string>
|
||||||
|
<string name="goto_url_hint">Type a domain url</string>
|
||||||
|
<string name="go">Go</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue