Commit 06af5ba55a167f0acec524cdf442c13cfd0407c1
1 parent
ae27fcfd
Exists in
master
and in
5 other branches
Android: Iniciando implementação do diálogo de configuração
Showing
4 changed files
with
78 additions
and
6 deletions
Show diff stats
android/AndroidManifest.xml
| @@ -19,6 +19,8 @@ | @@ -19,6 +19,8 @@ | ||
| 19 | <category android:name="android.intent.category.LAUNCHER" /> | 19 | <category android:name="android.intent.category.LAUNCHER" /> |
| 20 | </intent-filter> | 20 | </intent-filter> |
| 21 | </activity> | 21 | </activity> |
| 22 | - </application> | 22 | + <activity android:name="SettingsActivity"></activity> |
| 23 | 23 | ||
| 24 | -</manifest> | ||
| 25 | \ No newline at end of file | 24 | \ No newline at end of file |
| 25 | + </application> | ||
| 26 | + | ||
| 27 | +</manifest> |
| @@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + | ||
| 5 | + <PreferenceCategory | ||
| 6 | + android:title="Host" | ||
| 7 | + android:key="host_category"> | ||
| 8 | + | ||
| 9 | + <EditTextPreference | ||
| 10 | + android:key="hostname" | ||
| 11 | + android:title="Endereço do host" | ||
| 12 | + android:summary="Define o endereço do host a conectar" | ||
| 13 | + android:dialogTitle="Endereço do servidor" | ||
| 14 | + android:dialogMessage="Informe nome do servidor" | ||
| 15 | + android:defaultValue="" /> | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + <EditTextPreference | ||
| 19 | + android:key="port" | ||
| 20 | + android:title="Porta a conectar" | ||
| 21 | + android:summary="Define a porta a conectar" | ||
| 22 | + android:dialogTitle="Porta de conexão" | ||
| 23 | + android:dialogMessage="Informe a porta para conexão" | ||
| 24 | + android:defaultValue="23" /> | ||
| 25 | + | ||
| 26 | + <CheckBoxPreference | ||
| 27 | + android:key="ssl" | ||
| 28 | + android:summary="Usar SSL nas conexões ao host" | ||
| 29 | + android:title="Conexão segura" | ||
| 30 | + android:defaultValue="false" | ||
| 31 | + /> | ||
| 32 | + | ||
| 33 | + </PreferenceCategory> | ||
| 34 | + | ||
| 35 | +</PreferenceScreen> | ||
| 36 | + |
android/src/br/com/bb/pw3270/PW3270Activity.java
| @@ -2,11 +2,8 @@ package br.com.bb.pw3270; | @@ -2,11 +2,8 @@ package br.com.bb.pw3270; | ||
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | -// import android.widget.TextView; | ||
| 6 | -// import android.widget.Button; | ||
| 7 | -// import android.widget.EditText; | ||
| 8 | import android.util.Log; | 5 | import android.util.Log; |
| 9 | -// import android.view.View; | 6 | +import android.content.Intent; |
| 10 | import android.content.SharedPreferences; | 7 | import android.content.SharedPreferences; |
| 11 | import android.content.res.*; | 8 | import android.content.res.*; |
| 12 | import android.app.AlertDialog; | 9 | import android.app.AlertDialog; |
| @@ -214,6 +211,8 @@ public class PW3270Activity extends Activity | @@ -214,6 +211,8 @@ public class PW3270Activity extends Activity | ||
| 214 | break; | 211 | break; |
| 215 | 212 | ||
| 216 | case R.id.settings: | 213 | case R.id.settings: |
| 214 | + Intent myIntent = new Intent(view.getContext(), SettingsActivity.class); | ||
| 215 | + startActivityForResult(myIntent, 0); | ||
| 217 | break; | 216 | break; |
| 218 | 217 | ||
| 219 | default: | 218 | default: |
| @@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
| 1 | +package br.com.bb.pw3270; | ||
| 2 | + | ||
| 3 | +import android.os.Bundle; | ||
| 4 | +import android.preference.PreferenceFragment; | ||
| 5 | +import android.app.Activity; | ||
| 6 | + | ||
| 7 | +public class SettingsActivity extends Activity | ||
| 8 | +{ | ||
| 9 | + public static class SettingsFragment extends PreferenceFragment | ||
| 10 | + { | ||
| 11 | + @Override | ||
| 12 | + public void onCreate(Bundle savedInstanceState) | ||
| 13 | + { | ||
| 14 | + super.onCreate(savedInstanceState); | ||
| 15 | + | ||
| 16 | + // Load the preferences from an XML resource | ||
| 17 | + addPreferencesFromResource(R.xml.preferences); | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + protected void onCreate(Bundle savedInstanceState) | ||
| 23 | + { | ||
| 24 | + super.onCreate(savedInstanceState); | ||
| 25 | + | ||
| 26 | + // Display the fragment as the main content. | ||
| 27 | + getFragmentManager().beginTransaction() | ||
| 28 | + .replace(android.R.id.content, new SettingsFragment()) | ||
| 29 | + .commit(); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + |