mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-06 20:45:54 +01:00
disable button when nothing checked
This commit is contained in:
parent
3c1acf28ac
commit
7a0b38d5cf
3 changed files with 47 additions and 5 deletions
|
@ -19,24 +19,28 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.view.ViewGroup;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.LinearLayout;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.ZipUtils.SaveWhat;
|
import org.eehouse.android.xw4.ZipUtils.SaveWhat;
|
||||||
|
|
||||||
public class BackupConfigView extends LinearLayout
|
public class BackupConfigView extends LinearLayout
|
||||||
|
implements OnCheckedChangeListener
|
||||||
{
|
{
|
||||||
private static final String TAG = BackupConfigView.class.getSimpleName();
|
private static final String TAG = BackupConfigView.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -44,6 +48,7 @@ public class BackupConfigView extends LinearLayout
|
||||||
private Uri mLoadFile;
|
private Uri mLoadFile;
|
||||||
private Map<SaveWhat, CheckBox> mCheckBoxes = new HashMap<>();
|
private Map<SaveWhat, CheckBox> mCheckBoxes = new HashMap<>();
|
||||||
private List<SaveWhat> mShowWhats;
|
private List<SaveWhat> mShowWhats;
|
||||||
|
private AlertDialog mDialog;
|
||||||
|
|
||||||
public BackupConfigView( Context cx, AttributeSet as )
|
public BackupConfigView( Context cx, AttributeSet as )
|
||||||
{
|
{
|
||||||
|
@ -60,6 +65,18 @@ public class BackupConfigView extends LinearLayout
|
||||||
initOnce();
|
initOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AlertDialog setDialog( AlertDialog dialog )
|
||||||
|
{
|
||||||
|
mDialog = dialog;
|
||||||
|
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
|
@Override
|
||||||
|
public void onShow( DialogInterface dialog ) {
|
||||||
|
countChecks();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
// Usually called before init(), but IIRC wasn't on older Android versions
|
// Usually called before init(), but IIRC wasn't on older Android versions
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate()
|
protected void onFinishInflate()
|
||||||
|
@ -67,6 +84,28 @@ public class BackupConfigView extends LinearLayout
|
||||||
initOnce();
|
initOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged( CompoundButton buttonView,
|
||||||
|
boolean isChecked )
|
||||||
|
{
|
||||||
|
countChecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void countChecks()
|
||||||
|
{
|
||||||
|
if ( null != mDialog ) {
|
||||||
|
boolean haveCheck = false;
|
||||||
|
for ( CheckBox box : mCheckBoxes.values() ) {
|
||||||
|
if ( box.isChecked() ) {
|
||||||
|
haveCheck = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Utils.enableAlertButton( mDialog, AlertDialog.BUTTON_POSITIVE,
|
||||||
|
haveCheck );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initOnce()
|
private void initOnce()
|
||||||
{
|
{
|
||||||
if ( null != mIsStore ) {
|
if ( null != mIsStore ) {
|
||||||
|
@ -87,11 +126,13 @@ public class BackupConfigView extends LinearLayout
|
||||||
box.setText( what.titleID() );
|
box.setText( what.titleID() );
|
||||||
mCheckBoxes.put( what, box );
|
mCheckBoxes.put( what, box );
|
||||||
box.setChecked( !mIsStore );
|
box.setChecked( !mIsStore );
|
||||||
|
box.setOnCheckedChangeListener( this );
|
||||||
((TextView)(item.findViewById(R.id.expl)))
|
((TextView)(item.findViewById(R.id.expl)))
|
||||||
.setText( what.explID() );
|
.setText( what.explID() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
countChecks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
|
|
||||||
final CommsConnType typf = typ;
|
final CommsConnType typf = typ;
|
||||||
box.setOnCheckedChangeListener( new OnCheckedChangeListener() {
|
box.setOnCheckedChangeListener( new OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
public void onCheckedChanged( CompoundButton buttonView,
|
public void onCheckedChanged( CompoundButton buttonView,
|
||||||
boolean isChecked ) {
|
boolean isChecked ) {
|
||||||
if ( isChecked ) {
|
if ( isChecked ) {
|
||||||
|
|
|
@ -1576,7 +1576,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
} )
|
} )
|
||||||
.setNegativeButton( android.R.string.cancel, null )
|
.setNegativeButton( android.R.string.cancel, null )
|
||||||
;
|
;
|
||||||
return ab.create();
|
return view.setDialog( ab.create() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is in liu of passing through the startActivityForResult call,
|
// This is in liu of passing through the startActivityForResult call,
|
||||||
|
|
Loading…
Add table
Reference in a new issue