mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-15 08:47:56 +01:00
cleanup approved phonies UI
This commit is contained in:
parent
8be9d18287
commit
7d1636d65f
4 changed files with 48 additions and 57 deletions
|
@ -39,7 +39,6 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupMenu;
|
||||
|
@ -317,26 +316,30 @@ public class BoardDelegate extends DelegateBase
|
|||
break;
|
||||
|
||||
case ASK_BADWORDS: {
|
||||
LinearLayout rpLayout =
|
||||
(LinearLayout)inflate( R.layout.phonies_found );
|
||||
|
||||
TextView tv = (TextView)rpLayout.findViewById( R.id.message );
|
||||
tv.setText( (String)params[0] );
|
||||
|
||||
final int badWordsKey = (int)params[1];
|
||||
final int count = (Integer)params[1];
|
||||
final int badWordsKey = (Integer)params[2];
|
||||
lstnr = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg, int bx ) {
|
||||
CheckBox cb = (CheckBox)rpLayout
|
||||
.findViewById(R.id.remember_phonies_check);
|
||||
handleViaThread( JNICmd.CMD_COMMIT, true, false,
|
||||
cb.isChecked() ? badWordsKey : 0 );
|
||||
handleViaThread( JNICmd.CMD_COMMIT, true, false, 0 );
|
||||
}
|
||||
};
|
||||
OnClickListener lstnr2 = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg, int bx ) {
|
||||
handleViaThread( JNICmd.CMD_COMMIT, true, false, badWordsKey );
|
||||
}
|
||||
};
|
||||
|
||||
String buttonTxt = LocUtils.getString( m_activity, R.string.buttonYesAnd );
|
||||
String withSaveMsg = LocUtils.getQuantityString( m_activity, R.plurals.yesAndMsgFmt,
|
||||
count, buttonTxt );
|
||||
|
||||
dialog = ab.setTitle( R.string.phonies_found_title )
|
||||
.setView( rpLayout )
|
||||
.setMessage( (String)params[0] + "\n\n" + withSaveMsg )
|
||||
.setPositiveButton( R.string.button_yes, lstnr )
|
||||
.setNegativeButton( android.R.string.cancel, null )
|
||||
.setNeutralButton( buttonTxt, lstnr2 )
|
||||
.create();
|
||||
}
|
||||
break;
|
||||
|
@ -2209,7 +2212,8 @@ public class BoardDelegate extends DelegateBase
|
|||
message + getString( R.string.badwords_lost ) );
|
||||
} else {
|
||||
String msg = message + getString( R.string.badwords_accept );
|
||||
showDialogFragment( DlgID.ASK_BADWORDS, msg, badWordsKey );
|
||||
showDialogFragment( DlgID.ASK_BADWORDS, msg, words.length,
|
||||
badWordsKey );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
>
|
||||
<TextView android:id="@+id/message"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
||||
|
||||
<CheckBox android:id="@+id/remember_phonies_check"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/remember_phonies_label"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
||||
</LinearLayout>
|
|
@ -19,8 +19,17 @@
|
|||
<string name="gamel_menu_clearLPs">Clear all</string>
|
||||
<string name="gamel_menu_listLPs">Show all</string>
|
||||
|
||||
<string name="remember_phonies_label">Accept from now on</string>
|
||||
<string name="cleared_lps_fmt">Cleared %1$d legal phonies</string>
|
||||
|
||||
<string name="cleared_lps_fmt">Cleared %d legal phonies</string>
|
||||
<plurals name="yesAndMsgFmt">
|
||||
<item quantity="one">
|
||||
(If you choose the “%1$s” button you will not be asked about this word again.)
|
||||
</item>
|
||||
<item quantity="other">
|
||||
(If you choose the “%1$s” button you will not be asked about these words again.)
|
||||
</item>
|
||||
</plurals>
|
||||
|
||||
<string name="buttonYesAnd">Yes/Save</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -885,10 +885,17 @@ dvc_haveLegalPhonies( XW_DUtilCtxt* dutil, XWEnv xwe )
|
|||
return result;
|
||||
}
|
||||
|
||||
typedef struct _FreeState {
|
||||
XW_DUtilCtxt* dutil;
|
||||
XP_U16 count;
|
||||
} FreeState;
|
||||
|
||||
static void
|
||||
freeOnePhony( DLHead* elem, void* closure )
|
||||
{
|
||||
XW_DUtilCtxt* dutil = (XW_DUtilCtxt*)closure;
|
||||
FreeState* fs = (FreeState*)closure;
|
||||
XW_DUtilCtxt* dutil = fs->dutil;
|
||||
++fs->count;
|
||||
const PhoniesDataStrs* pds = (PhoniesDataStrs*)elem;
|
||||
XP_FREE( dutil->mpool, pds->phony );
|
||||
XP_FREE( dutil->mpool, elem );
|
||||
|
@ -897,20 +904,25 @@ freeOnePhony( DLHead* elem, void* closure )
|
|||
static void
|
||||
freeOneCode( DLHead* elem, void* closure)
|
||||
{
|
||||
XW_DUtilCtxt* dutil = (XW_DUtilCtxt*)closure;
|
||||
FreeState* fs = (FreeState*)closure;
|
||||
XW_DUtilCtxt* dutil = fs->dutil;
|
||||
const PhoniesDataCodes* pdc = (PhoniesDataCodes*)elem;
|
||||
|
||||
dll_removeAll( &pdc->head->links, freeOnePhony, dutil );
|
||||
dll_removeAll( &pdc->head->links, freeOnePhony, closure );
|
||||
|
||||
XP_FREE( dutil->mpool, pdc->isoCode );
|
||||
XP_FREE( dutil->mpool, elem );
|
||||
}
|
||||
|
||||
static DevCtxt*
|
||||
freePhonyState( XW_DUtilCtxt* dutil, XWEnv xwe )
|
||||
freePhonyState( XW_DUtilCtxt* dutil, XWEnv xwe, XP_U16* lenP )
|
||||
{
|
||||
FreeState fs = { .dutil = dutil, };
|
||||
DevCtxt* dc = load( dutil, xwe );
|
||||
dll_removeAll( &dc->pd->links, freeOneCode, dutil );
|
||||
dll_removeAll( &dc->pd->links, freeOneCode, &fs );
|
||||
if ( !!lenP ) {
|
||||
*lenP = fs.count;
|
||||
}
|
||||
dc->pd = NULL;
|
||||
return dc;
|
||||
}
|
||||
|
@ -920,7 +932,7 @@ dvc_clearLegalPhonies( XW_DUtilCtxt* dutil, XWEnv xwe )
|
|||
{
|
||||
DevCtxt* dc = load( dutil, xwe );
|
||||
XP_U16 len = dll_length( &dc->pd->links );
|
||||
freePhonyState( dutil, xwe );
|
||||
freePhonyState( dutil, xwe, &len );
|
||||
storePhoniesData( dutil, xwe, dc );
|
||||
return len;
|
||||
}
|
||||
|
@ -1085,7 +1097,7 @@ void
|
|||
dvc_cleanup( XW_DUtilCtxt* dutil, XWEnv xwe )
|
||||
{
|
||||
LOG_FUNC();
|
||||
DevCtxt* dc = freePhonyState( dutil, xwe );
|
||||
DevCtxt* dc = freePhonyState( dutil, xwe, NULL );
|
||||
|
||||
pthread_mutex_destroy( &dc->webSendMutex );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue