replace 'make default' with remembering last choice as default

Decided it's too difficult to unset the default and not bad to just
click "ok" a second time.
This commit is contained in:
Eric House 2023-12-19 20:52:15 -08:00
parent 3d8f2886f2
commit 0ba0dcff19
3 changed files with 10 additions and 21 deletions

View file

@ -1,6 +1,6 @@
/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */
/*
* Copyright 2020 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 2023 by Eric House (xwords@eehouse.org). All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@ -37,6 +37,9 @@ import org.eehouse.android.xw4.loc.LocUtils;
public class RematchConfigView extends LinearLayout
{
private static final String TAG = RematchConfigView.class.getSimpleName();
private static final String KEY_LAST_RO = TAG + "/key_last_ro";
private Context mContext;
private RadioGroup mGroup;
Map<Integer, RematchOrder> mRos = new HashMap<>();
@ -51,12 +54,16 @@ public class RematchConfigView extends LinearLayout
protected void onFinishInflate()
{
mGroup = (RadioGroup)findViewById( R.id.group );
int ordinal = DBUtils.getIntFor( mContext, KEY_LAST_RO, 0 );
RematchOrder lastSel = RematchOrder.values()[ordinal];
for ( RematchOrder ro : RematchOrder.values() ) {
RadioButton button = new RadioButton( mContext );
button.setText( LocUtils.getString( mContext, ro.getStrID() ) );
mGroup.addView( button );
mRos.put( button.getId(), ro );
if ( 1 == mRos.size() ) {
if ( lastSel == ro ) {
button.setChecked( true );
}
}
@ -67,11 +74,7 @@ public class RematchConfigView extends LinearLayout
int id = mGroup.getCheckedRadioButtonId();
RematchOrder ro = mRos.get(id);
// Save it if default button checked
CheckBox check = (CheckBox)findViewById( R.id.make_default );
if ( check.isChecked() ) {
XWPrefs.setDefaultRematchOrder( mContext, ro );
}
DBUtils.setIntFor( mContext, KEY_LAST_RO, ro.ordinal() );
return ro;
}

View file

@ -330,12 +330,6 @@ public class XWPrefs {
return groupID;
}
public static void setDefaultRematchOrder( Context context, RematchOrder ro )
{
String storedStr = null == ro ? "" : context.getString( ro.getStrID() );
setPrefsString( context, R.string.key_rematch_order, storedStr );
}
public static RematchOrder getDefaultRematchOrder( Context context )
{
String storedStr = getPrefsString( context, R.string.key_rematch_order );

View file

@ -21,12 +21,4 @@
android:layout_height="wrap_content"
/>
<CheckBox android:id="@+id/make_default"
android:text="@string/dicts_item_select"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="12dp"
/>
</org.eehouse.android.xw4.RematchConfigView>