Merge branch 'android_branch' into android_translate

This commit is contained in:
Eric House 2017-04-26 19:18:50 -07:00
commit 6caff930e7
23 changed files with 217 additions and 126 deletions

View file

@ -2,3 +2,7 @@
/modules
XWords4-gcm/
/.gradle
**.iml
local.properties
.idea

View file

@ -238,7 +238,7 @@ task cleanNDK(type: Exec) {
}
gradle.taskGraph.whenReady { taskGraph ->
if ( taskGraph.hasTask(':app:validateReleaseSigning') ) {
if ( taskGraph.hasTask(':app:validateSigningXw4Release') ) {
def pass
if (System.getenv("ANDROID_RELEASE_PASSWORD")) {
pass = System.getenv("ANDROID_RELEASE_PASSWORD")

View file

@ -78,30 +78,24 @@
<activity android:name="DictsActivity"
android:label="@string/title_dicts_list"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="BTInviteActivity"
android:label="@string/bt_invite_title"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="SMSInviteActivity"
android:label="@string/sms_invite_title"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="sensor"
/>
<activity android:name="RelayInviteActivity"
android:label="@string/relay_invite_title"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="WiDirInviteActivity"
android:label="@string/p2p_invite_title"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="GameConfigActivity"
android:screenOrientation="sensor"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="stateAlwaysHidden"
>
<intent-filter>
@ -112,17 +106,14 @@
<activity android:name="PrefsActivity"
android:label="@string/title_prefs"
android:screenOrientation="sensor"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="BoardActivity"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
/>
<activity android:name="StudyListActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<receiver android:name="OnBootReceiver">
@ -170,7 +161,6 @@
<activity android:name=".DwnldActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog"
android:configChanges="keyboardHidden|orientation|screenSize"
>
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
@ -186,16 +176,12 @@
</activity>
<activity android:name="DictBrowseActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="ChatActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name=".loc.LocActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name=".loc.LocItemEditActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<service android:name="RelayService"/>

View file

@ -28,10 +28,10 @@
<h3>New with this release</h3>
<ul>
<li>Enable side-by-side display for tablets</li>
<li>In service of above, rewrite pretty much everything
dialog-related. :-) (Please report bugs!)</li>
<li>Capitalize the W in CrossWords: this is not a crossword
puzzle game</li>
<li>In service of above, rewrite pretty much everything
dialog-related. :-)</li>
<li>Fix game timers</li>
<li>Make blank-tile-picker dialog prettier</li>
<li>Remove pick-face-up option for networked games. (It didn't

View file

@ -37,6 +37,7 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.loc.LocUtils;
public class AboutAlert extends XWDialogFragment {
private static final String TAG = AboutAlert.class.getSimpleName();
public static AboutAlert newInstance()
{
@ -82,4 +83,7 @@ public class AboutAlert extends XWDialogFragment {
.setPositiveButton( android.R.string.ok, null )
.create();
}
@Override
protected String getFragTag() { return TAG; }
}

View file

@ -118,6 +118,7 @@ public class BoardDelegate extends DelegateBase
private int[] m_missingCounts;
private InviteMeans m_missingMeans = null;
private boolean m_progressShown = false;
private boolean m_isFirstLaunch;
private boolean m_firingPrefs;
private BoardUtilCtxt m_utils;
private boolean m_gameOver = false;
@ -309,9 +310,8 @@ public class BoardDelegate extends DelegateBase
int title = (Integer)params[0];
String msg = (String)params[1];
ab.setMessage( msg );
if ( 0 != title ) {
ab.setTitle( title );
}
Assert.assertTrue( 0 != title );
ab.setTitle( title );
ab.setPositiveButton( android.R.string.ok, null );
if ( DlgID.DLG_SCORES == dlgID ) {
if ( null != m_mySIS.words && m_mySIS.words.length > 0 ) {
@ -564,6 +564,7 @@ public class BoardDelegate extends DelegateBase
protected void init( Bundle savedInstanceState )
{
m_isFirstLaunch = null == savedInstanceState;
getBundledData( savedInstanceState );
m_pendingChats = new ArrayList<String>();
@ -1112,7 +1113,8 @@ public class BoardDelegate extends DelegateBase
break;
case DISABLE_DUALPANE:
XWPrefs.setPrefsBoolean( m_activity, R.string.key_disable_dualpane, true );
XWPrefs.setPrefsString( m_activity, R.string.key_force_tablet,
getString(R.string.force_tablet_phone) );
makeOkOnlyBuilder( R.string.after_restart ).show();
break;
@ -1183,7 +1185,7 @@ public class BoardDelegate extends DelegateBase
@Override
public void inviteChoiceMade( Action action, InviteMeans means,
Object[] params )
Object... params )
{
if ( action == Action.LAUNCH_INVITE_ACTION ) {
SentInvitesInfo info = params[0] instanceof SentInvitesInfo
@ -1748,11 +1750,17 @@ public class BoardDelegate extends DelegateBase
// This is supposed to be called from the jni thread
@Override
public void notifyPickTileBlank( int playerNum, int col, int row, String[] texts )
public void notifyPickTileBlank( int playerNum, int col, int row,
String[] texts )
{
TilePickAlert.TilePickState tps =
final TilePickAlert.TilePickState tps =
new TilePickAlert.TilePickState( playerNum, texts, col, row );
show( TilePickAlert.newInstance( Action.BLANK_PICKED, tps ) );
runOnUiThread( new Runnable() {
@Override
public void run() {
show( TilePickAlert.newInstance( Action.BLANK_PICKED, tps ) );
}
} );
}
@Override
@ -1760,10 +1768,15 @@ public class BoardDelegate extends DelegateBase
int playerNum, int nToPick,
String[] texts, int[] counts )
{
TilePickAlert.TilePickState tps
final TilePickAlert.TilePickState tps
= new TilePickAlert.TilePickState( isInitial, playerNum, nToPick,
texts, counts );
show( TilePickAlert.newInstance( Action.TRAY_PICKED, tps ) );
runOnUiThread( new Runnable() {
@Override
public void run() {
show( TilePickAlert.newInstance( Action.TRAY_PICKED, tps ) );
}
} );
}
@Override
@ -2082,8 +2095,10 @@ public class BoardDelegate extends DelegateBase
gi.dictLang );
break;
case JNIThread.GAME_OVER:
showDialogFragment( DlgID.GAME_OVER, m_summary, msg.arg1,
(String)msg.obj );
if ( m_isFirstLaunch ) {
showDialogFragment( DlgID.GAME_OVER, m_summary, msg.arg1,
(String)msg.obj );
}
break;
case JNIThread.MSGS_SENT:
int nSent = (Integer)msg.obj;
@ -2208,8 +2223,8 @@ public class BoardDelegate extends DelegateBase
m_relayMissing = false;
}
if ( 0 == nMissing || !m_relayMissing ) {
Log.d( TAG, "dismissing invite alert %H", m_inviteAlert );
if ( null != m_inviteAlert ) {
Log.d( TAG, "dismissing invite alert" );
m_inviteAlert.dismiss();
}
}
@ -2290,12 +2305,7 @@ public class BoardDelegate extends DelegateBase
Assert.fail();
}
final int fTitle = dlgTitle;
runOnUiThread( new Runnable() {
public void run() {
showDialogFragment( dlgID, fTitle, txt );
}
} );
showDialogFragment( dlgID, dlgTitle, txt );
}
private void showInviteAlertIf()
@ -2794,8 +2804,10 @@ public class BoardDelegate extends DelegateBase
DBUtils.recordInviteSent( m_activity, m_rowid, means, dev );
if ( !invitesSent ) {
m_inviteAlert.dismiss();
m_inviteAlert = null;
if ( null != m_inviteAlert ) {
m_inviteAlert.dismiss();
m_inviteAlert = null;
}
Log.d( TAG, "recordInviteSent(): redoing invite alert" );
showInviteAlertIf();
}
@ -2813,12 +2825,19 @@ public class BoardDelegate extends DelegateBase
// If I'm upgrading and running this for the first time show an
// explanation about the new dualpane feature
//
// TODO remove a few weeks after shipping a version that includes it
private static boolean s_dpShown = false;
private void checkAddDualpaneExpl()
{
if ( !s_dpShown ) {
s_dpShown = true;
// Am I a tablet AND is that because my size says so rather than
// my having overridden it
if ( XWPrefs.getIsTablet( m_activity )
&& getString(R.string.force_tablet_default)
.equals(XWPrefs.getPrefsString(m_activity,
R.string.key_force_tablet))
&& !Utils.onFirstVersion(m_activity ) ) {
makeNotAgainBuilder( R.string.invite_dualpane,
R.string.key_notagain_dualpane )

View file

@ -26,6 +26,9 @@ import android.os.Bundle;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.eehouse.android.xw4.loc.LocUtils;
@ -62,12 +65,30 @@ public class DBAlert extends XWDialogFragment {
public DBAlert() {}
public DlgID getDlgID() { return mDlgID; }
public DlgID getDlgID() {
if ( null == mDlgID ) {
mDlgID = DlgID.values()[getArguments().getInt(DLG_ID_KEY, -1)];
}
return mDlgID;
}
@Override
public boolean belongsOnBackStack()
{
boolean result = getDlgID().belongsOnBackStack();
return result;
}
@Override
public String getFragTag()
{
return getDlgID().toString();
}
@Override
public void onSaveInstanceState( Bundle bundle )
{
bundle.putInt( DLG_ID_KEY, mDlgID.ordinal() );
bundle.putInt( DLG_ID_KEY, getDlgID().ordinal() );
bundle.putSerializable( PARMS_KEY, mParams );
super.onSaveInstanceState( bundle );
}
@ -78,7 +99,6 @@ public class DBAlert extends XWDialogFragment {
if ( null == sis ) {
sis = getArguments();
}
mDlgID = DlgID.values()[sis.getInt(DLG_ID_KEY, -1)];
mParams = (Object[])sis.getSerializable(PARMS_KEY);
XWActivity activity = (XWActivity)getActivity();
@ -87,7 +107,8 @@ public class DBAlert extends XWDialogFragment {
if ( null == dialog ) {
dialog = LocUtils.makeAlertBuilder( getActivity() )
.setTitle( "Stub Alert" )
.setMessage( String.format( "Unable to create for %s", mDlgID.toString() ) )
.setMessage( String.format( "Unable to create for %s",
getDlgID().toString() ) )
.setPositiveButton( "Bummer", null )
// .setNegativeButton( "Try now", new OnClickListener() {
// @Override
@ -103,7 +124,7 @@ public class DBAlert extends XWDialogFragment {
public void run() {
MainActivity activity = (MainActivity)getActivity();
if ( null != activity ) {
DBAlert newMe = newInstance( mDlgID, mParams );
DBAlert newMe = newInstance( getDlgID(), mParams );
activity.show( newMe );
dismiss(); // kill myself...
} else {

View file

@ -436,10 +436,14 @@ public class DelegateBase implements DlgClickNotify,
return null;
}
protected void showDialogFragment( DlgID dlgID, Object... params )
protected void showDialogFragment( final DlgID dlgID, final Object... params )
{
DialogFragment fragment = DBAlert.newInstance( dlgID, params );
show( fragment );
runOnUiThread( new Runnable() {
@Override
public void run() {
show( DBAlert.newInstance( dlgID, params ) );
}
} );
}
protected void show( DlgState state )
@ -468,8 +472,9 @@ public class DelegateBase implements DlgClickNotify,
show( df );
}
protected void show( DialogFragment df )
protected void show( XWDialogFragment df )
{
DbgUtils.assertOnUIThread();
if ( m_activity instanceof XWActivity ) {
((XWActivity)m_activity).show( df );
} else if ( m_activity instanceof PrefsActivity ) {
@ -669,8 +674,7 @@ public class DelegateBase implements DlgClickNotify,
public boolean onPosButton( Action action, Object[] params )
{
boolean handled = true;
Log.d( TAG, "%s.posButtonClicked(%s)", getClass().getSimpleName(),
action.toString() );
Log.d( TAG, "%s.onPosButton(%s)", getClass().getSimpleName(), action );
switch( action ) {
case ENABLE_SMS_ASK:
showSMSEnableDialog( Action.ENABLE_SMS_DO );
@ -720,7 +724,7 @@ public class DelegateBase implements DlgClickNotify,
return false;
}
public void inviteChoiceMade( Action action, DlgClickNotify.InviteMeans means, Object[] params )
public void inviteChoiceMade( Action action, DlgClickNotify.InviteMeans means, Object... params )
{
// Assert.fail();
}

View file

@ -301,7 +301,7 @@ public class DlgDelegate {
boolean onNegButton( Action action, Object... params );
boolean onDismissed( Action action, Object... params );
void inviteChoiceMade( Action action, InviteMeans means, Object[] params );
void inviteChoiceMade( Action action, InviteMeans means, Object... params );
}
public interface HasDlgDelegate {
OkOnlyBuilder makeOkOnlyBuilder( int msgID );
@ -450,7 +450,7 @@ public class DlgDelegate {
public void run() {
DlgClickNotify.InviteMeans means
= DlgClickNotify.InviteMeans.EMAIL;
m_clickCallback.inviteChoiceMade( action, means, null );
m_clickCallback.inviteChoiceMade( action, means );
}
});
}

View file

@ -47,12 +47,14 @@ abstract class DlgDelegateAlert extends XWDialogFragment {
protected final DlgState getState( Bundle sis )
{
if ( null != sis ) {
m_state = (DlgState)sis.getParcelable( STATE_KEY );
} else {
Bundle args = getArguments();
Assert.assertNotNull( args );
m_state = DlgState.fromBundle( args );
if ( m_state == null ) {
if ( null != sis ) {
m_state = (DlgState)sis.getParcelable( STATE_KEY );
} else {
Bundle args = getArguments();
Assert.assertNotNull( args );
m_state = DlgState.fromBundle( args );
}
}
return m_state;
}
@ -72,12 +74,25 @@ abstract class DlgDelegateAlert extends XWDialogFragment {
@Override
public void onDismiss( DialogInterface dif )
{
super.onDismiss( dif );
Activity activity = getActivity();
if ( activity instanceof DlgClickNotify ) {
((DlgClickNotify)activity)
.onDismissed( m_state.m_action, m_state.m_params );
}
super.onDismiss( dif );
}
@Override
protected String getFragTag()
{
return getState(null).m_id.toString();
}
@Override
public boolean belongsOnBackStack()
{
boolean result = getState(null).m_id.belongsOnBackStack();
return result;
}
protected void checkNotAgainCheck( DlgState state, NotAgainView naView )
@ -100,7 +115,7 @@ abstract class DlgDelegateAlert extends XWDialogFragment {
@Override
public void onClick( DialogInterface dlg, int button ) {
checkNotAgainCheck( m_state, naView );
XWActivity xwact = (XWActivity)getActivity();
DlgClickNotify xwact = (DlgClickNotify)getActivity();
xwact.onPosButton( pair.action, m_state.m_params );
}
};

View file

@ -22,7 +22,6 @@ package org.eehouse.android.xw4;
public enum DlgID {
NONE
, LOOKUP
, CHANGE_GROUP
, CONFIRM_CHANGE
, CONFIRM_CHANGE_PLAY
@ -33,7 +32,7 @@ public enum DlgID {
, DICT_OR_DECLINE
, DLG_CONNSTAT
, DLG_DELETED
, DLG_INVITE
, DLG_INVITE(true)
, DLG_OKONLY
, ENABLE_NFC
, FORCE_REMOTE
@ -64,10 +63,15 @@ public enum DlgID {
, ASK_PASSWORD
, DLG_RETRY
, DLG_SCORES
, PICK_TILE_REQUESTTRAY
, DLG_USEDICT
, DLG_GETDICT
, GAMES_LIST_NEWGAME
, CHANGE_CONN
, GAMES_LIST_NAME_REMATCH
;
private boolean m_addToStack;
private DlgID(boolean addToStack) { m_addToStack = addToStack; }
private DlgID() { m_addToStack = false; }
boolean belongsOnBackStack() { return m_addToStack; }
}

View file

@ -82,7 +82,7 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
items.add( getString( R.string.invite_choice_relay ) );
means.add( InviteMeans.RELAY );
}
if ( WiDirService.enabled() ) {
if ( WiDirWrapper.enabled() ) {
items.add( getString( R.string.invite_choice_p2p ) );
means.add( InviteMeans.WIFIDIRECT );
}

View file

@ -31,6 +31,7 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.loc.LocUtils;
public class LookupAlert extends XWDialogFragment {
private static final String TAG = LookupAlert.class.getSimpleName();
private LookupAlertView m_view;
public static LookupAlert newInstance( String[] words, int lang, boolean noStudy )
@ -73,4 +74,7 @@ public class LookupAlert extends XWDialogFragment {
result.setOnKeyListener( m_view );
return result;
}
@Override
protected String getFragTag() { return TAG; }
}

View file

@ -65,7 +65,7 @@ public class MainActivity extends XWActivity
@Override
protected void onCreate( Bundle savedInstanceState )
{
m_dpEnabled = XWPrefs.dualpaneEnabled( this );
m_dpEnabled = XWPrefs.getIsTablet( this );
m_dlgt = m_dpEnabled ? new DualpaneDelegate( this, savedInstanceState )
: new GamesListDelegate( this, savedInstanceState );
@ -130,6 +130,7 @@ public class MainActivity extends XWActivity
if ( m_safeToCommit ) {
handled = dispatchNewIntentImpl( intent );
} else {
DbgUtils.assertOnUIThread();
m_runWhenSafe.add( new Runnable() {
@Override
public void run() {
@ -300,7 +301,7 @@ public class MainActivity extends XWActivity
protected void finishFragment()
{
// Assert.assertTrue( fragment instanceof XWFragment );
// DbgUtils.logf( "MainActivity.finishFragment(%s)", fragment.toString() );
// Log.d( TAG, "finishFragment()" );
getSupportFragmentManager().popBackStack/*Immediate*/();
}
@ -358,15 +359,28 @@ public class MainActivity extends XWActivity
private void logPaneFragments()
{
if ( BuildConfig.DEBUG ) {
List<String> pairs = new ArrayList<>();
int childCount = m_root.getChildCount();
for ( int ii = 0; ii < childCount; ++ii ) {
View child = m_root.getChildAt( ii );
String name = findFragment( child ).getClass().getSimpleName();
String pair = String.format("%d:%s", ii, name );
pairs.add( pair );
List<String> panePairs = new ArrayList<>();
if ( null != m_root ) {
int childCount = m_root.getChildCount();
for ( int ii = 0; ii < childCount; ++ii ) {
View child = m_root.getChildAt( ii );
String name = findFragment( child ).getClass().getSimpleName();
String pair = String.format("%d:%s", ii, name );
panePairs.add( pair );
}
}
Log.d( TAG, "logPaneFragments(): %s", TextUtils.join(", ", pairs) );
FragmentManager fm = getSupportFragmentManager();
List<String> fragPairs = new ArrayList<>();
int fragCount = fm.getBackStackEntryCount();
for ( int ii = 0; ii < fragCount; ++ii ) {
FragmentManager.BackStackEntry entry = fm.getBackStackEntryAt( ii );
String name = entry.getName();
String pair = String.format("%d:%s", ii, name );
fragPairs.add( pair );
}
Log.d( TAG, "panes: [%s]; frags: [%s]", TextUtils.join(",", panePairs),
TextUtils.join(",", fragPairs) );
}
}
@ -452,6 +466,7 @@ public class MainActivity extends XWActivity
if ( m_safeToCommit ) {
safeAddFragment( fragment, parentName );
} else {
DbgUtils.assertOnUIThread();
m_runWhenSafe.add( new Runnable() {
@Override
public void run() {
@ -503,6 +518,7 @@ public class MainActivity extends XWActivity
private void setSafeToRun()
{
DbgUtils.assertOnUIThread();
m_safeToCommit = true;
for ( Runnable proc : m_runWhenSafe ) {
proc.run();

View file

@ -62,7 +62,7 @@ public class PrefsDelegate extends DelegateBase
R.string.key_disable_nag,
R.string.key_disable_nag_solo,
R.string.key_disable_relay,
R.string.key_disable_dualpane,
R.string.key_force_tablet,
};
private static Map<String, Integer> s_keysHash = null;
@ -235,7 +235,7 @@ public class PrefsDelegate extends DelegateBase
case R.string.key_disable_relay:
RelayService.enabledChanged( m_activity );
break;
case R.string.key_disable_dualpane:
case R.string.key_force_tablet:
makeOkOnlyBuilder( R.string.after_restart ).show();
break;
default:
@ -367,7 +367,7 @@ public class PrefsDelegate extends DelegateBase
private void hideStuff()
{
if ( !Utils.isGSMPhone( m_activity ) ) {
if ( !Utils.isGSMPhone( m_activity ) || Perms23.haveNativePerms() ) {
hideOne( R.string.key_enable_sms, R.string.key_network_behavior );
}
@ -375,14 +375,6 @@ public class PrefsDelegate extends DelegateBase
hideOne( R.string.key_hide_title, R.string.prefs_appearance );
}
if ( !XWPrefs.getIsTablet( m_activity ) ) {
hideOne( R.string.key_disable_dualpane, R.string.prefs_appearance );
}
if ( Perms23.haveNativePerms() ) {
hideOne( R.string.key_enable_sms, R.string.key_network_behavior );
}
if ( ! BuildConfig.WIDIR_ENABLED ) {
hideOne( R.string.key_enable_p2p, R.string.key_network_behavior );
}

View file

@ -81,6 +81,7 @@ public class SMSInviteDelegate extends InviteDelegate {
m_activity = delegator.getActivity();
}
@Override
protected void init( Bundle savedInstanceState )
{
String msg = getString( R.string.button_invite );
@ -119,12 +120,17 @@ public class SMSInviteDelegate extends InviteDelegate {
@Override
protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data )
final Intent data )
{
if ( Activity.RESULT_CANCELED != resultCode && data != null ) {
switch ( requestCode ) {
case GET_CONTACT:
addPhoneNumbers( data );
post ( new Runnable() {
@Override
public void run() {
addPhoneNumbers( data );
}
} );
break;
}
}

View file

@ -1,4 +1,4 @@
/* -*- compile-command: "cd ../../../../../../../../ && ./gradlew installXw4Debug"; -*- */
/* -*- compile-command: "find-and-gradle.sh insXw4Deb"; -*- */
/*
* Copyright 2017 by Eric House (xwords@eehouse.org). All rights reserved.
*
@ -39,6 +39,7 @@ import org.eehouse.android.xw4.loc.LocUtils;
public class TilePickAlert extends XWDialogFragment
implements TilePickView.TilePickListener {
private static final String TAG = TilePickAlert.class.getSimpleName();
private static final String TPS = "TPS";
private static final String ACTION = "ACTION";
private TilePickView m_view;
@ -127,6 +128,8 @@ public class TilePickAlert extends XWDialogFragment
return m_dialog;
}
protected String getFragTag() { return TAG; }
// TilePickView.TilePickListener interface
@Override
public void onTilesChanged( int nToPick, int[] newTiles )

View file

@ -26,7 +26,10 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ContextMenu;
import android.view.Menu;
@ -48,7 +51,8 @@ public class XWActivity extends FragmentActivity
protected void onCreate( Bundle savedInstanceState, DelegateBase dlgt )
{
if ( XWApp.LOG_LIFECYLE ) {
Log.i( TAG, "onCreate(this=%H)", this );
Log.i( TAG, "%s.onCreate(this=%H,sis=%s)", getClass().getSimpleName(),
this, savedInstanceState );
}
super.onCreate( savedInstanceState );
m_dlgt = dlgt;
@ -108,7 +112,7 @@ public class XWActivity extends FragmentActivity
protected void onStart()
{
if ( XWApp.LOG_LIFECYLE ) {
Log.i( TAG, "%s.onStart(this=%H)", this );
Log.i( TAG, "%s.onStart(this=%H)", getClass().getSimpleName(), this );
}
super.onStart();
m_dlgt.onStart();
@ -118,7 +122,7 @@ public class XWActivity extends FragmentActivity
protected void onStop()
{
if ( XWApp.LOG_LIFECYLE ) {
Log.i( TAG, "%s.onStop(this=%H)", this );
Log.i( TAG, "%s.onStop(this=%H)", getClass().getSimpleName(), this );
}
m_dlgt.onStop();
super.onStop();
@ -278,9 +282,23 @@ public class XWActivity extends FragmentActivity
Assert.fail();
}
protected void show( DialogFragment df )
protected void show( XWDialogFragment df )
{
df.show( getSupportFragmentManager(), "dialog" );
FragmentManager fm = getSupportFragmentManager();
String tag = df.getFragTag();
// Log.d( TAG, "show(%s); tag: %s", df.getClass().getSimpleName(), tag );
if ( df.belongsOnBackStack() ) {
FragmentTransaction trans = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag( tag );
if ( null != prev && prev instanceof DialogFragment ) {
((DialogFragment)prev).dismiss();
}
trans.addToBackStack( tag );
df.show( trans, tag );
} else {
df.show( fm, tag );
}
}
protected Dialog makeDialog( DBAlert alert, Object[] params )
@ -310,7 +328,7 @@ public class XWActivity extends FragmentActivity
}
@Override
public void inviteChoiceMade( Action action, InviteMeans means, Object[] params )
public void inviteChoiceMade( Action action, InviteMeans means, Object... params )
{
m_dlgt.inviteChoiceMade( action, means, params );
}

View file

@ -32,7 +32,7 @@ import java.util.Map;
import junit.framework.Assert;
public class XWDialogFragment extends DialogFragment {
abstract class XWDialogFragment extends DialogFragment {
private static final String TAG = XWDialogFragment.class.getSimpleName();
private OnDismissListener m_onDismiss;
@ -46,6 +46,8 @@ public class XWDialogFragment extends DialogFragment {
void onCancelled( XWDialogFragment frag );
}
abstract String getFragTag();
@Override
public void onResume()
{
@ -72,21 +74,26 @@ public class XWDialogFragment extends DialogFragment {
@Override
public void onCancel( DialogInterface dialog )
{
super.onCancel( dialog );
// Log.d( TAG, "%s.onCancel() called", getClass().getSimpleName() );
if ( null != m_onCancel ) {
m_onCancel.onCancelled( this );
}
super.onCancel( dialog );
}
@Override
public void onDismiss( DialogInterface dif )
{
// Log.d( TAG, "%s.onDismiss() called", getClass().getSimpleName() );
super.onDismiss( dif );
if ( null != m_onDismiss ) {
m_onDismiss.onDismissed( this );
}
super.onDismiss( dif );
}
public boolean belongsOnBackStack() { return false; }
protected void setOnDismissListener( OnDismissListener lstnr )
{
Assert.assertTrue( null == lstnr || null == m_onDismiss || !BuildConfig.DEBUG );

View file

@ -473,7 +473,7 @@ public class XWPrefs {
{
boolean result = isTablet( context );
String setting = getPrefsString( context, R.string.key_force_tablet );
if ( setting.equals( context.getString(R.string.force_tablet_os) ) ) {
if ( setting.equals( context.getString(R.string.force_tablet_default) ) ) {
// Leave it alone
} else if ( setting.equals( context.getString(R.string.force_tablet_tablet) ) ) {
result = true;
@ -485,11 +485,6 @@ public class XWPrefs {
return result;
}
public static boolean dualpaneEnabled( Context context )
{
return ! getPrefsBoolean( context, R.string.key_disable_dualpane, false );
}
public static CommsConnTypeSet getAddrTypes( Context context )
{
CommsConnTypeSet result;

View file

@ -69,7 +69,6 @@
<string name="key_summary_field">key_summary_field</string>
<string name="key_default_loc">key_default_loc</string>
<string name="key_force_tablet">key_force_tablet2</string>
<string name="key_disable_dualpane">key_disable_dualpane2</string>
<string name="key_force_radio">key_force_radio</string>
<string name="key_addrs_pref">key_addrs_pref</string>
@ -316,7 +315,7 @@
</string-array>
<string-array name="force_tablet_names">
<item>@string/force_tablet_os</item>
<item>@string/force_tablet_default</item>
<item>@string/force_tablet_phone</item>
<item>@string/force_tablet_tablet</item>
</string-array>

View file

@ -2316,12 +2316,10 @@
what\'s available.</string>
<string name="force_tablet_title">Use tablet (side-by-side) layout?</string>
<string name="force_tablet_os">OS decides</string>
<string name="force_tablet_default">Use default for my device</string>
<string name="force_tablet_tablet">Force tablet layout</string>
<string name="force_tablet_phone">Force phone layout</string>
<string name="disable_dualpane_summary">Side-by-side views on tablets</string>
<!-- Nagging: title of notification reminder message -->
<string name="nag_title">Reminder: It\'s your turn</string>
<!-- body of warning notification reminder message. First three
@ -2612,12 +2610,12 @@
<string name="no_invites">This game has sent no invitations</string>
<string name="invite_dualpane">This new version of CrossWords lets
devices like yours view two panes (e.g. Games List and Board)
side-by-side. That\'s when your device is horizontal; when it\'s
vertical there\'s no change.\n\n
larger-screened devices like yours view two panes (e.g. Games List
and Board) side-by-side. You\'ll notice this when your device is
horizontal; when it\'s vertical there\'s no change.\n\n
I hope you like it. If you don\'t you can disable it below or in App
Settings.</string>
I hope you like it. If you don\'t you can disable it below or in the
Appearance section of App Settings.</string>
<string name="disable_dualpane">Disable side-by-side</string>
<string name="after_restart">This change will take effect after you

View file

@ -126,11 +126,15 @@
android:summary="@string/hide_title_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_disable_dualpane"
android:title="@string/disable_dualpane"
android:summary="@string/disable_dualpane_summary"
android:defaultValue="false"
/>
<org.eehouse.android.xw4.XWListPreference
android:key="@string/key_force_tablet"
android:title="@string/force_tablet_title"
android:entries="@array/force_tablet_names"
android:entryValues="@array/force_tablet_names"
android:defaultValue="@string/force_tablet_default"
/>
<CheckBoxPreference android:key="@string/key_show_arrow"
android:title="@string/show_arrow"
android:summary="@string/show_arrow_summary"
@ -429,14 +433,6 @@
/>
</PreferenceScreen>
<org.eehouse.android.xw4.XWListPreference
android:key="@string/key_force_tablet"
android:title="@string/force_tablet_title"
android:entries="@array/force_tablet_names"
android:entryValues="@array/force_tablet_names"
android:defaultValue="@string/force_tablet_os"
/>
<PreferenceScreen android:title="@string/pref_group_l10n_title"
android:summary="@string/pref_group_l10n_summary"
>