mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
fix delete dicts warning to catch case of nuking all the lists for a
language at once. To simplify (coding and user experience), don't bother with case where user will have to switch to another list before opening a game. May want to reconsider this.
This commit is contained in:
parent
38b37643f4
commit
5c5ddd5ecd
5 changed files with 585 additions and 588 deletions
File diff suppressed because it is too large
Load diff
|
@ -234,16 +234,9 @@
|
||||||
wordlist delete confiration dialog in the case where the
|
wordlist delete confiration dialog in the case where the
|
||||||
wordlist to be deleted is the last in its language. The name
|
wordlist to be deleted is the last in its language. The name
|
||||||
of the language is substituted for %1$s. -->
|
of the language is substituted for %1$s. -->
|
||||||
<string name="confirm_deleteonly_dict_fmt">%1$s is the only %2$s
|
<string name="confirm_deleteonly_dicts_fmt">Deleting %1$s will
|
||||||
wordlist installed. One or more games will be unopenable
|
leave you without any %2$s wordlists. One or more games will be
|
||||||
without it.</string>
|
unopenable (until you download a replacement list.)</string>
|
||||||
<!-- Additional text appended to text confirm_delete_dictf in the
|
|
||||||
wordlist delete confiration dialog in the case where the
|
|
||||||
wordlist to be deleted is NOT the last in its language. The
|
|
||||||
name of the language is substituted for %1$s. -->
|
|
||||||
<string name="confirm_deletemore_dict_fmt">\u0020One game (at least)
|
|
||||||
is using it, but there is another %1$s wordlist installed that can
|
|
||||||
replace it.</string>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
############################################################
|
############################################################
|
||||||
|
|
|
@ -202,16 +202,9 @@
|
||||||
wordlist delete confiration dialog in the case where the
|
wordlist delete confiration dialog in the case where the
|
||||||
wordlist to be deleted is the last in its language. The name
|
wordlist to be deleted is the last in its language. The name
|
||||||
of the language is substituted for %1$s. -->
|
of the language is substituted for %1$s. -->
|
||||||
<string name="confirm_deleteonly_dict_fmt">%1$s si eht ylno %2$s
|
<string name="confirm_deleteonly_dicts_fmt">Gniteled %1$s lliw
|
||||||
tsildrow dellatsni. Eno ro erom semag lliw eb elbaneponu
|
evael uoy tuohtiw yna %2$s stsildrow. Eno ro erom semag lliw eb
|
||||||
tuohtiw ti.</string>
|
elbaneponu litnu( uoy daolnwod a tnemecalper tsil.)</string>
|
||||||
<!-- Additional text appended to text confirm_delete_dictf in the
|
|
||||||
wordlist delete confiration dialog in the case where the
|
|
||||||
wordlist to be deleted is NOT the last in its language. The
|
|
||||||
name of the language is substituted for %1$s. -->
|
|
||||||
<string name="confirm_deletemore_dict_fmt">\u0020Eno emag ta( )tsael
|
|
||||||
si gnisu ,ti tub ereht si rehtona %1$s tsildrow dellatsni taht nac
|
|
||||||
ecalper ti.</string>
|
|
||||||
<!--
|
<!--
|
||||||
############################################################
|
############################################################
|
||||||
# :Dialogs:
|
# :Dialogs:
|
||||||
|
|
|
@ -202,16 +202,9 @@
|
||||||
wordlist delete confiration dialog in the case where the
|
wordlist delete confiration dialog in the case where the
|
||||||
wordlist to be deleted is the last in its language. The name
|
wordlist to be deleted is the last in its language. The name
|
||||||
of the language is substituted for %1$s. -->
|
of the language is substituted for %1$s. -->
|
||||||
<string name="confirm_deleteonly_dict_fmt">%1$s IS THE ONLY %2$s
|
<string name="confirm_deleteonly_dicts_fmt">DELETING %1$s WILL
|
||||||
WORDLIST INSTALLED. ONE OR MORE GAMES WILL BE UNOPENABLE
|
LEAVE YOU WITHOUT ANY %2$s WORDLISTS. ONE OR MORE GAMES WILL BE
|
||||||
WITHOUT IT.</string>
|
UNOPENABLE (UNTIL YOU DOWNLOAD A REPLACEMENT LIST.)</string>
|
||||||
<!-- Additional text appended to text confirm_delete_dictf in the
|
|
||||||
wordlist delete confiration dialog in the case where the
|
|
||||||
wordlist to be deleted is NOT the last in its language. The
|
|
||||||
name of the language is substituted for %1$s. -->
|
|
||||||
<string name="confirm_deletemore_dict_fmt">\u0020ONE GAME (AT LEAST)
|
|
||||||
IS USING IT, BUT THERE IS ANOTHER %1$s WORDLIST INSTALLED THAT CAN
|
|
||||||
REPLACE IT.</string>
|
|
||||||
<!--
|
<!--
|
||||||
############################################################
|
############################################################
|
||||||
# :Dialogs:
|
# :Dialogs:
|
||||||
|
|
|
@ -725,37 +725,61 @@ public class DictsDelegate extends ListDelegateBase
|
||||||
String msg = getString( R.string.confirm_delete_dict_fmt,
|
String msg = getString( R.string.confirm_delete_dict_fmt,
|
||||||
getJoinedNames( items ) );
|
getJoinedNames( items ) );
|
||||||
|
|
||||||
// When and what to warn about. First off, if there's another
|
// Confirm. And for each dict, warn if (after ALL are deleted) any
|
||||||
// identical dict, simply confirm. Or if nobody's using this
|
// game will no longer be openable without downloading. For now
|
||||||
// dict *and* it's not the last of a language that somebody's
|
// anyway skip warning for the case where user will have to switch to
|
||||||
// using, simply confirm. If somebody is using it, then we
|
// a different same-lang wordlist to open a game.
|
||||||
// want different warnings depending on whether it's the last
|
|
||||||
// available dict in its language.
|
|
||||||
|
|
||||||
|
class LangDelData {
|
||||||
|
public LangDelData( int langCode ) {
|
||||||
|
delDicts = new HashSet<String>();
|
||||||
|
langName = DictLangCache.getLangName( m_activity, langCode );
|
||||||
|
nDicts = DictLangCache.getDALsHaveLang( m_activity, langCode ).length;
|
||||||
|
}
|
||||||
|
public String dictsStr()
|
||||||
|
{
|
||||||
|
if ( null == m_asArray ) {
|
||||||
|
String[] arr = delDicts.toArray(new String[delDicts.size()]);
|
||||||
|
m_asArray = TextUtils.join( ", ", arr );
|
||||||
|
}
|
||||||
|
return m_asArray;
|
||||||
|
}
|
||||||
|
Set<String> delDicts;
|
||||||
|
private String m_asArray;
|
||||||
|
String langName;
|
||||||
|
int nDicts;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, LangDelData> dels = new HashMap<Integer, LangDelData>();
|
||||||
|
Set<Integer> skipLangs = new HashSet<Integer>();
|
||||||
for ( XWListItem item : items ) {
|
for ( XWListItem item : items ) {
|
||||||
String dict = item.getText();
|
String dict = item.getText();
|
||||||
if ( 1 < DictLangCache.getDictCount( m_activity, dict ) ) {
|
int langCode = DictLangCache.getDictLangCode( m_activity, dict );
|
||||||
// there's another; do nothing
|
if ( skipLangs.contains( langCode ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int nUsingLang = DBUtils.countGamesUsingLang( m_activity, langCode );
|
||||||
|
if ( 0 == nUsingLang ) {
|
||||||
|
// remember, since countGamesUsingLang is expensive
|
||||||
|
skipLangs.add( langCode );
|
||||||
} else {
|
} else {
|
||||||
String newMsg = null;
|
LangDelData data = dels.get( langCode );
|
||||||
int langcode = DictLangCache.getDictLangCode( m_activity, dict );
|
if ( null == data ) {
|
||||||
String langName = DictLangCache.getLangName( m_activity, langcode );
|
data = new LangDelData( langCode );
|
||||||
DictAndLoc[] langDals = DictLangCache.getDALsHaveLang( m_activity,
|
dels.put( langCode, data );
|
||||||
langcode );
|
}
|
||||||
int nUsingLang = DBUtils.countGamesUsingLang( m_activity, langcode );
|
data.delDicts.add( dict );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 1 == langDals.length ) { // last in this language?
|
for ( Iterator<LangDelData> iter = dels.values().iterator(); iter.hasNext(); ) {
|
||||||
if ( 0 < nUsingLang ) {
|
LangDelData data = iter.next();
|
||||||
newMsg = getString( R.string.confirm_deleteonly_dict_fmt,
|
int nLeftAfter = data.nDicts - data.delDicts.size();
|
||||||
dict, langName );
|
|
||||||
}
|
if ( 0 == nLeftAfter ) { // last in this language?
|
||||||
} else if ( 0 < DBUtils.countGamesUsingDict( m_activity, dict ) ) {
|
String newMsg = getString( R.string.confirm_deleteonly_dicts_fmt,
|
||||||
newMsg = getString( R.string.confirm_deletemore_dict_fmt,
|
data.dictsStr(), data.langName );
|
||||||
langName );
|
msg += "\n\n" + newMsg;
|
||||||
}
|
|
||||||
if ( null != newMsg ) {
|
|
||||||
msg += "\n\n" + newMsg;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue