From 4db2fd229bd48ae697f25d6cc2ed668e0b765ada Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 5 Apr 2019 13:26:49 -0700 Subject: [PATCH] add hint explaining new tap-on-pending-words feature And bring back another BoardCanvas hint that had been commented out. --- .../org/eehouse/android/xw4/BoardCanvas.java | 48 ++++++++++++------- .../app/src/main/res/values/common_rsrc.xml | 1 + .../app/src/main/res/values/strings.xml | 6 +++ 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardCanvas.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardCanvas.java index 7bd27b88d..4aa6fc2ee 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardCanvas.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardCanvas.java @@ -1,7 +1,7 @@ /* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */ /* - * Copyright 2009 - 2013 by Eric House (xwords@eehouse.org). All - * rights reserved. + * Copyright 2009 - 2019 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 @@ -31,6 +31,8 @@ import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import java.util.HashSet; +import java.util.Set; import org.eehouse.android.xw4.jni.BoardDims; import org.eehouse.android.xw4.jni.CommonPrefs; @@ -88,6 +90,7 @@ public class BoardCanvas extends Canvas implements DrawCtx { protected String[] m_dictChars; private boolean m_hasSmallScreen; private int m_backgroundUsed = 0x00000000; + private int mPendingCount; // FontDims: exists to translate space available to the largest // font we can draw within that space taking advantage of our use @@ -382,6 +385,7 @@ public class BoardCanvas extends Canvas implements DrawCtx { bonusStr = m_bonusSummaries[bonus]; } } else if ( pending ) { + ++mPendingCount; if ( darkOnLight() ) { foreColor = WHITE; backColor = BLACK; @@ -425,7 +429,6 @@ public class BoardCanvas extends Canvas implements DrawCtx { return canDraw; } // drawCell - private boolean m_arrowHintShown = false; public void drawBoardArrow( Rect rect, int bonus, boolean vert, int hintAtts, int flags ) { @@ -452,19 +455,7 @@ public class BoardCanvas extends Canvas implements DrawCtx { arrow.setBounds( rect ); arrow.draw( BoardCanvas.this ); - if ( !m_arrowHintShown ) { - m_arrowHintShown = true; - // Handler handler = getHandler(); - // if ( null != handler ) { - // handler.post( new Runnable() { - // public void run() { - // m_parent. - // showNotAgainDlgThen( R.string.not_again_arrow, - // R.string. - // key_notagain_arrow ); - // } } ); - // } - } + postNAHint( R.string.not_again_arrow, R.string.key_notagain_arrow ); } public boolean trayBegin( Rect rect, int owner, int score ) @@ -543,6 +534,12 @@ public class BoardCanvas extends Canvas implements DrawCtx { int xx = rect.left + rect.width() - 1; drawLine( xx, rect.top, xx, rect.top + rect.height(), m_strokePaint ); + + if ( mPendingCount > 0 ) { + mPendingCount = 0; + postNAHint( R.string.not_again_longtap_lookup, + R.string.key_na_longtap_lookup ); + } } } @@ -886,4 +883,23 @@ public class BoardCanvas extends Canvas implements DrawCtx { return m_tileStrokePaint; } + private static Set sShown = new HashSet<>(); + private void postNAHint( final int msgID, final int keyID ) + { + if ( !sShown.contains( keyID ) ) { + sShown.add( keyID ); + + if ( m_activity instanceof XWActivity ) { + final XWActivity activity = (XWActivity)m_activity; + + activity.runOnUiThread( new Runnable() { + @Override + public void run() { + activity.makeNotAgainBuilder( msgID, keyID ) + .show(); + } + } ); + } + } + } } diff --git a/xwords4/android/app/src/main/res/values/common_rsrc.xml b/xwords4/android/app/src/main/res/values/common_rsrc.xml index d30b0b4bc..7dffb4b05 100644 --- a/xwords4/android/app/src/main/res/values/common_rsrc.xml +++ b/xwords4/android/app/src/main/res/values/common_rsrc.xml @@ -145,6 +145,7 @@ key_na_comms_relay key_na_bt_badproto key_na_sms_banned + key_na_longtap_lookup xwords@eehouse.org diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index 1d5612d44..4d2a83527 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2850,4 +2850,10 @@ FCM only: no polling Default: mix polling and FCM + You can look up words BEFORE + they\'re committed as moves -- by long-tapping, same as committed + words.\n\nUse this feature to check the validity of words you\'re + thinking of playing, or to look up an unfamiliar word provided as a + hint. +