mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
offer to hide new-game buttons immediately
Don't wait for user to tap one of the buttons. Instead notice when scrolling becomes possible, and offer once per launch until user says "hide" or clicks the don't-ask-again box.
This commit is contained in:
parent
b6955696eb
commit
fa3a33f133
2 changed files with 25 additions and 36 deletions
|
@ -46,7 +46,6 @@ public class DlgDelegate {
|
|||
OPEN_GAME,
|
||||
CLEAR_SELS,
|
||||
NEW_NET_GAME,
|
||||
NEW_GAME_PRESSED,
|
||||
SET_HIDE_NEWGAME_BUTTONS,
|
||||
DWNLD_LOC_DICT,
|
||||
NEW_GAME_DFLT_NAME,
|
||||
|
|
|
@ -997,8 +997,12 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
mCurScrollState = OnScrollListener.SCROLL_STATE_IDLE;
|
||||
lv.setOnScrollListener( new OnScrollListener() {
|
||||
@Override
|
||||
public void onScroll( AbsListView absListView, int ii, int i1, int i2 )
|
||||
public void onScroll( AbsListView absListView, int firstVis,
|
||||
int visCount, int totalCount )
|
||||
{
|
||||
if ( 0 < visCount && visCount < totalCount ) {
|
||||
checkOfferHideButtons();
|
||||
}
|
||||
if ( mCurScrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL ) {
|
||||
lv.setFastScrollEnabled( true );
|
||||
}
|
||||
|
@ -1105,6 +1109,24 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
super.onSaveInstanceState( outState );
|
||||
}
|
||||
|
||||
// Only called when scrolling's necessary
|
||||
private boolean m_offeredHideButtons = false;
|
||||
private void checkOfferHideButtons()
|
||||
{
|
||||
if ( !m_offeredHideButtons ) {
|
||||
if ( XWPrefs.getHideNewgameButtons( m_activity ) ) {
|
||||
m_offeredHideButtons = true; // don't do expensive check again
|
||||
} else {
|
||||
m_offeredHideButtons = true;
|
||||
makeNotAgainBuilder( R.string.not_again_hidenewgamebuttons,
|
||||
R.string.key_notagain_hidenewgamebuttons )
|
||||
.setActionPair( Action.SET_HIDE_NEWGAME_BUTTONS,
|
||||
R.string.set_pref )
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getBundledData( Bundle bundle )
|
||||
{
|
||||
if ( null != bundle ) {
|
||||
|
@ -1399,11 +1421,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
break;
|
||||
|
||||
case SET_HIDE_NEWGAME_BUTTONS:
|
||||
XWPrefs.setHideNewgameButtons(m_activity, true);
|
||||
XWPrefs.setHideNewgameButtons( m_activity, true );
|
||||
setupButtons();
|
||||
// FALLTHRU
|
||||
case NEW_GAME_PRESSED:
|
||||
handleNewGame( m_mySIS.nextIsSolo );
|
||||
break;
|
||||
|
||||
case DELETE_GROUPS:
|
||||
|
@ -2147,39 +2166,10 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
}
|
||||
}
|
||||
|
||||
private void handleNewGame( boolean solo )
|
||||
{
|
||||
m_mySIS.nextIsSolo = solo;
|
||||
showDialogFragment( DlgID.GAMES_LIST_NEWGAME, solo );
|
||||
}
|
||||
|
||||
private void handleNewGameButton( boolean solo )
|
||||
{
|
||||
m_mySIS.nextIsSolo = solo;
|
||||
|
||||
boolean skipOffer = XWPrefs.getHideNewgameButtons( m_activity );
|
||||
if ( ! skipOffer ) {
|
||||
// If the API's availble, offer to hide buttons as soon as there
|
||||
// are enough games that the list is scrollable. Otherwise fall
|
||||
// back to there being at least four games.
|
||||
if ( Build.VERSION.SDK_INT >= 19 ) {
|
||||
ListView list = getListView();
|
||||
skipOffer = !list.canScrollList( 1 ) && !list.canScrollList( -1 );
|
||||
} else {
|
||||
skipOffer = 4 > m_adapter.getCount();
|
||||
}
|
||||
}
|
||||
|
||||
if ( skipOffer ) {
|
||||
handleNewGame( solo );
|
||||
} else {
|
||||
makeNotAgainBuilder( R.string.not_again_hidenewgamebuttons,
|
||||
R.string.key_notagain_hidenewgamebuttons,
|
||||
Action.NEW_GAME_PRESSED )
|
||||
.setActionPair( Action.SET_HIDE_NEWGAME_BUTTONS,
|
||||
R.string.set_pref )
|
||||
.show();
|
||||
}
|
||||
showDialogFragment( DlgID.GAMES_LIST_NEWGAME, solo );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue