|  |  | @ -9,6 +9,7 @@ import android.graphics.Rect | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.graphics.Typeface |  |  |  | import android.graphics.Typeface | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.os.AsyncTask |  |  |  | import android.os.AsyncTask | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.os.Bundle |  |  |  | import android.os.Bundle | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import android.util.Log | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.util.TypedValue |  |  |  | import android.util.TypedValue | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.view.* |  |  |  | import android.view.* | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.widget.RelativeLayout |  |  |  | import android.widget.RelativeLayout | 
			
		
	
	
		
		
			
				
					|  |  | @ -17,6 +18,7 @@ import androidx.lifecycle.ViewModelProviders | 
			
		
	
		
		
			
				
					
					|  |  |  | import androidx.loader.app.LoaderManager |  |  |  | import androidx.loader.app.LoaderManager | 
			
		
	
		
		
			
				
					
					|  |  |  | import androidx.loader.content.Loader |  |  |  | import androidx.loader.content.Loader | 
			
		
	
		
		
			
				
					
					|  |  |  | import androidx.recyclerview.widget.LinearLayoutManager |  |  |  | import androidx.recyclerview.widget.LinearLayoutManager | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import androidx.recyclerview.widget.RecyclerView | 
			
		
	
		
		
			
				
					
					|  |  |  | import kotlinx.android.synthetic.main.activity_conversation_v2.* |  |  |  | import kotlinx.android.synthetic.main.activity_conversation_v2.* | 
			
		
	
		
		
			
				
					
					|  |  |  | import kotlinx.android.synthetic.main.activity_conversation_v2.view.* |  |  |  | import kotlinx.android.synthetic.main.activity_conversation_v2.view.* | 
			
		
	
		
		
			
				
					
					|  |  |  | import kotlinx.android.synthetic.main.activity_conversation_v2_action_bar.* |  |  |  | import kotlinx.android.synthetic.main.activity_conversation_v2_action_bar.* | 
			
		
	
	
		
		
			
				
					|  |  | @ -62,9 +64,7 @@ import kotlin.math.* | 
			
		
	
		
		
			
				
					
					|  |  |  | // price we pay is a bit of back and forth between the input bar and the conversation activity. |  |  |  | // price we pay is a bit of back and forth between the input bar and the conversation activity. | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDelegate, |  |  |  | class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDelegate, | 
			
		
	
		
		
			
				
					
					|  |  |  |     InputBarRecordingViewDelegate, ConversationRecyclerViewDelegate { |  |  |  |     InputBarRecordingViewDelegate { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     private val scrollButtonFullVisibilityThreshold by lazy { toPx(120.0f, resources) } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     private val scrollButtonNoVisibilityThreshold by lazy { toPx(20.0f, resources) } |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     private val screenWidth = Resources.getSystem().displayMetrics.widthPixels |  |  |  |     private val screenWidth = Resources.getSystem().displayMetrics.widthPixels | 
			
		
	
		
		
			
				
					
					|  |  |  |     private var linkPreviewViewModel: LinkPreviewViewModel? = null |  |  |  |     private var linkPreviewViewModel: LinkPreviewViewModel? = null | 
			
		
	
		
		
			
				
					
					|  |  |  |     private var threadID: Long = -1 |  |  |  |     private var threadID: Long = -1 | 
			
		
	
	
		
		
			
				
					|  |  | @ -142,7 +142,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe | 
			
		
	
		
		
			
				
					
					|  |  |  |         conversationRecyclerView.adapter = adapter |  |  |  |         conversationRecyclerView.adapter = adapter | 
			
		
	
		
		
			
				
					
					|  |  |  |         val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true) |  |  |  |         val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true) | 
			
		
	
		
		
			
				
					
					|  |  |  |         conversationRecyclerView.layoutManager = layoutManager |  |  |  |         conversationRecyclerView.layoutManager = layoutManager | 
			
		
	
		
		
			
				
					
					|  |  |  |         conversationRecyclerView.delegate = this |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         // Workaround for the fact that CursorRecyclerViewAdapter doesn't auto-update automatically (even though it says it will) |  |  |  |         // Workaround for the fact that CursorRecyclerViewAdapter doesn't auto-update automatically (even though it says it will) | 
			
		
	
		
		
			
				
					
					|  |  |  |         LoaderManager.getInstance(this).restartLoader(0, null, object : LoaderManager.LoaderCallbacks<Cursor> { |  |  |  |         LoaderManager.getInstance(this).restartLoader(0, null, object : LoaderManager.LoaderCallbacks<Cursor> { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -158,6 +157,12 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe | 
			
		
	
		
		
			
				
					
					|  |  |  |                 adapter.changeCursor(null) |  |  |  |                 adapter.changeCursor(null) | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         }) |  |  |  |         }) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         conversationRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 handleRecyclerViewScrolled() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private fun setUpToolBar() { |  |  |  |     private fun setUpToolBar() { | 
			
		
	
	
		
		
			
				
					|  |  | @ -417,12 +422,11 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe | 
			
		
	
		
		
			
				
					
					|  |  |  |         animation.start() |  |  |  |         animation.start() | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     override fun handleConversationRecyclerViewBottomOffsetChanged(bottomOffset: Int) { |  |  |  |     private fun handleRecyclerViewScrolled() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         val rawAlpha = (bottomOffset.toFloat() - scrollButtonNoVisibilityThreshold) / |  |  |  |         val position = layoutManager.findFirstCompletelyVisibleItemPosition() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             (scrollButtonFullVisibilityThreshold - scrollButtonNoVisibilityThreshold) |  |  |  |         val alpha = if (position > 0) 1.0f else 0.0f | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         val alpha = max(min(rawAlpha, 1.0f), 0.0f) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         scrollToBottomButton.alpha = alpha |  |  |  |         scrollToBottomButton.alpha = alpha | 
			
		
	
		
		
			
				
					
					|  |  |  |         unreadCount = layoutManager.findFirstVisibleItemPosition() |  |  |  |         unreadCount = min(unreadCount, layoutManager.findFirstVisibleItemPosition()) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         updateUnreadCountIndicator() |  |  |  |         updateUnreadCountIndicator() | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |