From 15256ac2ad7c35a74086acc529f673b13860f95a Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 14 Jul 2016 07:01:02 -0700 Subject: [PATCH] cleanup --- .../org/eehouse/android/xw4/ChatDelegate.java | 110 +++++++++--------- .../org/eehouse/android/xw4/MainActivity.java | 17 +-- 2 files changed, 58 insertions(+), 69 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java index 1d9dde73f..668976723 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java @@ -65,67 +65,63 @@ public class ChatDelegate extends DelegateBase { } @Override - protected void init( Bundle savedInstanceState ) + protected void init( Bundle savedInstanceState ) { - if ( BuildConstants.CHAT_SUPPORTED ) { - m_edit = (EditText)findViewById( R.id.chat_edit ); - m_edit.addTextChangedListener( new TextWatcher() { - public void afterTextChanged( Editable s ) { - invalidateOptionsMenuIf(); - } - public void beforeTextChanged( CharSequence s, int st, - int cnt, int a ) {} - public void onTextChanged( CharSequence s, int start, - int before, int count ) {} - } ); - - Bundle args = getArguments(); - m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 ); - m_curPlayer = args.getInt( INTENT_KEY_PLAYER, -1 ); - m_names = args.getStringArray( INTENT_KEY_NAMES ); - boolean[] locals = args.getBooleanArray( INTENT_KEY_LOCS ); - - m_scroll = (ScrollView)findViewById( R.id.scroll ); - m_layout = (TableLayout)findViewById( R.id.chat_history ); - - // OnLayoutChangeListener added in API 11 - if ( 11 <= Integer.valueOf( android.os.Build.VERSION.SDK ) ) { - m_layout.addOnLayoutChangeListener( new OnLayoutChangeListener() { - @Override - public void onLayoutChange( View vv, int ll, int tt, int rr, - int bb, int ol, int ot, - int or, int ob ) { - scrollDown(); - } - }); - } - - Button sendButton = (Button)findViewById( R.id.chat_send ); - if ( ABUtils.haveActionBar() ) { - sendButton.setVisibility( View.GONE ); - } else { - sendButton.setOnClickListener( new View.OnClickListener() { - public void onClick( View view ) { - handleSend(); - } - } ); - } - - DBUtils.HistoryPair[] pairs - = DBUtils.getChatHistory( m_activity, m_rowid, locals ); - if ( null != pairs ) { - for ( DBUtils.HistoryPair pair : pairs ) { - addRow( pair.msg, pair.playerIndx ); + DbgUtils.logf( "ChatDelegate.init()" ); + m_edit = (EditText)findViewById( R.id.chat_edit ); + m_edit.addTextChangedListener( new TextWatcher() { + public void afterTextChanged( Editable s ) { + invalidateOptionsMenuIf(); } - } + public void beforeTextChanged( CharSequence s, int st, + int cnt, int a ) {} + public void onTextChanged( CharSequence s, int start, + int before, int count ) {} + } ); - String title = getString( R.string.chat_title_fmt, - GameUtils.getName( m_activity, m_rowid ) ); - setTitle( title ); - } else { - // Should really assert.... - finish(); + Bundle args = getArguments(); + m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 ); + m_curPlayer = args.getInt( INTENT_KEY_PLAYER, -1 ); + m_names = args.getStringArray( INTENT_KEY_NAMES ); + boolean[] locals = args.getBooleanArray( INTENT_KEY_LOCS ); + + m_scroll = (ScrollView)findViewById( R.id.scroll ); + m_layout = (TableLayout)findViewById( R.id.chat_history ); + + // OnLayoutChangeListener added in API 11 + if ( 11 <= Integer.valueOf( android.os.Build.VERSION.SDK ) ) { + m_layout.addOnLayoutChangeListener( new OnLayoutChangeListener() { + @Override + public void onLayoutChange( View vv, int ll, int tt, int rr, + int bb, int ol, int ot, + int or, int ob ) { + scrollDown(); + } + }); } + + Button sendButton = (Button)findViewById( R.id.chat_send ); + if ( ABUtils.haveActionBar() ) { + sendButton.setVisibility( View.GONE ); + } else { + sendButton.setOnClickListener( new View.OnClickListener() { + public void onClick( View view ) { + handleSend(); + } + } ); + } + + DBUtils.HistoryPair[] pairs + = DBUtils.getChatHistory( m_activity, m_rowid, locals ); + if ( null != pairs ) { + for ( DBUtils.HistoryPair pair : pairs ) { + addRow( pair.msg, pair.playerIndx ); + } + } + + String title = getString( R.string.chat_title_fmt, + GameUtils.getName( m_activity, m_rowid ) ); + setTitle( title ); } // init @Override diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java index 4c99f3fd2..f270ea8c1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java @@ -60,12 +60,12 @@ public class MainActivity extends XWActivity protected void onCreate( Bundle savedInstanceState ) { m_dpEnabled = XWPrefs.dualpaneEnabled( this ); - if ( m_dpEnabled ) { - m_dlgt = new DualpaneDelegate( this, savedInstanceState ); - Utils.showToast( this, "dualpane mode" ); - } else { - m_dlgt = new GamesListDelegate( this, savedInstanceState ); + if ( BuildConfig.DEBUG ) { + Utils.showToast( this, "dualpane mode: " + m_dpEnabled ); } + + m_dlgt = m_dpEnabled ? new DualpaneDelegate( this, savedInstanceState ) + : new GamesListDelegate( this, savedInstanceState ); super.onCreate( savedInstanceState, m_dlgt ); if ( m_dpEnabled ) { @@ -81,13 +81,6 @@ public class MainActivity extends XWActivity addFragmentImpl( new GamesListFrag(), getIntent().getExtras(), null ); } } - - // Trying to debug situation where two of this activity are running at - // once. finish()ing when Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT is - // passed is not the fix, but perhaps there's another - // int flags = getIntent().getFlags(); - // DbgUtils.logf( "MainActivity.onCreate(this=%H): flags=0x%x", - // this, flags ); } // onCreate // called when we're brought to the front (probably as a result of