mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
replace restore menus in prefs activity with buttons at bottom of
screen. The trick involves getting the OS to insert the prefs xml layout as a ListView, and seems like a hack, but it works so far. Ought to be tested on several OS versions before next release.
This commit is contained in:
parent
cd23022cde
commit
1575279cd8
4 changed files with 57 additions and 49 deletions
35
xwords4/android/XWords4/res/layout/prefs_w_buttons.xml
Normal file
35
xwords4/android/XWords4/res/layout/prefs_w_buttons.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
>
|
||||
|
||||
<ListView android:id="@id/android:list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:drawSelectorOnTop="false"
|
||||
/>
|
||||
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
>
|
||||
<Button android:id="@+id/revert_colors"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_revert_colors"
|
||||
/>
|
||||
<Button android:id="@+id/revert_all"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_revert_all"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_revert_colors"
|
||||
android:title="@string/menu_revert_colors"
|
||||
/>
|
||||
<item android:id="@+id/menu_revert_all"
|
||||
android:title="@string/menu_revert_all"
|
||||
/>
|
||||
</menu>
|
|
@ -797,13 +797,13 @@
|
|||
-->
|
||||
<!-- text of first menu item. Will revert all preferences to
|
||||
their default/original values -->
|
||||
<string name="menu_revert_all">Restore all</string>
|
||||
<string name="button_revert_all">Restore all</string>
|
||||
<!-- Text of confirmation dialog for above -->
|
||||
<string name="confirm_revert_colors">Are you sure you want to
|
||||
restore all color settings to their original values?</string>
|
||||
<!-- Second menu item. Reverts only the colors to their
|
||||
default/original values -->
|
||||
<string name="menu_revert_colors">Restore colors</string>
|
||||
<string name="button_revert_colors">Restore colors</string>
|
||||
<!-- Text of confirmation dialog for above -->
|
||||
<string name="confirm_revert_all">Are you sure you want to restore
|
||||
all settings to their original values?</string>
|
||||
|
|
|
@ -19,19 +19,16 @@
|
|||
*/
|
||||
|
||||
package org.eehouse.android.xw4;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.app.Dialog;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.app.Dialog;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.Preference;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MenuInflater;
|
||||
import java.util.HashSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class PrefsActivity extends PreferenceActivity
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
@ -112,8 +109,22 @@ public class PrefsActivity extends PreferenceActivity
|
|||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource( R.xml.xwprefs );
|
||||
setContentView( R.layout.prefs_w_buttons );
|
||||
|
||||
m_keyLogging = getString( R.string.key_logging_on );
|
||||
|
||||
Button button = (Button)findViewById( R.id.revert_colors );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
public void onClick( View v ) {
|
||||
showDialog( REVERT_COLORS );
|
||||
}
|
||||
} );
|
||||
button = (Button)findViewById( R.id.revert_all );
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick( View v ) {
|
||||
showDialog( REVERT_ALL );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,34 +150,6 @@ public class PrefsActivity extends PreferenceActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate( R.menu.prefs_menu, menu );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected( MenuItem item )
|
||||
{
|
||||
int dlgID = 0;
|
||||
switch ( item.getItemId() ) {
|
||||
case R.id.menu_revert_all:
|
||||
dlgID = REVERT_ALL;
|
||||
break;
|
||||
case R.id.menu_revert_colors:
|
||||
dlgID = REVERT_COLORS;
|
||||
break;
|
||||
}
|
||||
|
||||
boolean handled = 0 != dlgID;
|
||||
if ( handled ) {
|
||||
showDialog( dlgID );
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
private void relaunch()
|
||||
{
|
||||
PreferenceManager.setDefaultValues( this, R.xml.xwprefs,
|
||||
|
|
Loading…
Add table
Reference in a new issue