1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-22 00:42:16 -05:00

Micro optimized full screen code. Made starvation mode leaner.

Conflicts:

	application/src/org/yaaic/activity/ConversationActivity.java
This commit is contained in:
Rey Rey 2011-07-02 18:05:46 +02:00 committed by Sebastian Kaspari
parent 5c48724425
commit 2e2aebf2c4
4 changed files with 65 additions and 36 deletions

View File

@ -26,6 +26,7 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:layout_height="fill_parent"
android:background="#ff181818">
<LinearLayout
android:id="@+id/status_layout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

View File

@ -252,16 +252,15 @@ public class ConversationActivity extends Activity implements ServiceConnection,
if (settings.autoCapSentences()) {
setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
}
if (isLandscape && !settings.imeExtract()) {
/* Replace the Enter key with a smiley instead of Send, to make it
more difficult to accidentally hit send
We'd like to do this in portrait too, but wouldn't have a Send
button in that case */
if (isLandscape && settings.imeExtract()) {
setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
input.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
} else {
input.setImeOptions(input.getImeOptions() & EditorInfo.IME_FLAG_NO_EXTRACT_UI);
}
if (!settings.imeExtract()) {
input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
}
input.setInputType(input.getInputType() | setInputTypeFlags);
// Create a new scrollback history

View File

@ -32,9 +32,7 @@ import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
* ConversationLayout: LinearLayout that resizes correctly when an IME
@ -45,10 +43,10 @@ import android.widget.TextView;
public class ConversationLayout extends LinearLayout
{
private Activity activity;
private TextView title;
private ImageView status;
int curHeight = 0;
boolean fullscreen = false, isLandscape = false;
boolean fullscreen = false;
boolean isLandscape = false;
boolean redoLayout = false;
/**
@ -94,38 +92,66 @@ public class ConversationLayout extends LinearLayout
return visible.height();
}
/**
* Check if starving the gui is necessary, and starves
* Starves when less then a vertical inch is available to us
* @return true if we are able to check, false if not.
* @author Reynaldo Cortorreal <reyncor@gmail.com>
*/
private boolean setStarvationMode(int height)
{
if (height == 0) {
return false;
} else if (height == curHeight){
return false;
}
LinearLayout status = (LinearLayout) findViewById(R.id.status_layout);
ConversationSwitcher dots = (ConversationSwitcher) findViewById(R.id.dots);
float scale = getResources().getDisplayMetrics().density;
//Give us at least an inch, or we'll have to make sacrifices.
if (height < 160*scale) {
status.setVisibility(GONE);
dots.setVisibility(GONE);
} else {
status.setVisibility(VISIBLE);
dots.setVisibility(VISIBLE);
}
return true;
}
/**
* onMeasure (ask the view how much space it wants)
* This is called when the window size changes, so we can hook into it to
* resize ourselves when the IME comes up
* @author Steven Luo <stevenandroid@steven676.net>
* @author Reynaldo Cortorreal <reyncor@gmail.com>
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if(!fullscreen && !isLandscape){
return;
}
int height = getWindowHeight();
if (curHeight != height) {
curHeight = height;
status = (ImageView) findViewById(R.id.status);
title = (TextView) findViewById(R.id.title);
final float scale = getResources().getDisplayMetrics().density;
//Give us at least an inch, or we'll have to make sacrifices.
if (height < 160*scale) {
status.setVisibility(GONE);
title.setVisibility(GONE);
} else if (status.getVisibility() == GONE || title.getVisibility() == GONE){
status.setVisibility(VISIBLE);
title.setVisibility(VISIBLE);
if(!fullscreen) {
if (setStarvationMode(height)){
curHeight = height;
redoLayout = true;
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
}
//here to forth the code applies only to full screen
if (isLandscape && !setStarvationMode(height)) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
} else if (curHeight != height && height != 0) {
curHeight = height;
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.FILL_PARENT,
@ -135,7 +161,10 @@ public class ConversationLayout extends LinearLayout
params.gravity = Gravity.BOTTOM | Gravity.CLIP_VERTICAL;
setLayoutParams(params);
redoLayout = true;
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
/**

View File

@ -42,8 +42,8 @@ public class MessageListView extends ListView
private final View parent;
private int parentWidth;
private int parentHeight;
private int padding;
private int paddingWide;
private final int padding;
private final int paddingWide;
/**
* Create a new MessageListView
@ -139,11 +139,11 @@ public class MessageListView extends ListView
if (switched) {
setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT, Gallery.LayoutParams.FILL_PARENT));
setTranscriptMode(TRANSCRIPT_MODE_NORMAL);
setPadding(paddingWide, padding, paddingWide, padding);
setPadding(paddingWide, padding, paddingWide, 0);
} else {
setLayoutParams(new Gallery.LayoutParams(parentWidth*85/100, parentHeight));
setTranscriptMode(TRANSCRIPT_MODE_ALWAYS_SCROLL);
setPadding(padding, padding, padding, padding);
setPadding(padding, padding, padding, 0);
}
}
}