mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 712526: Restrict tabs menu to occupy only 2/3 of the screen. [r=mfinkle]
This commit is contained in:
parent
dd08c68dab
commit
202c74d82d
@ -44,6 +44,8 @@ import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -58,7 +60,10 @@ import android.widget.TextView;
|
||||
|
||||
public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener {
|
||||
|
||||
private ListView mList;
|
||||
private static int sPreferredHeight;
|
||||
private static int sMaxHeight;
|
||||
private static int sListItemHeight;
|
||||
private static ListView mList;
|
||||
private TabsAdapter mTabsAdapter;
|
||||
private boolean mWaitingForClose;
|
||||
|
||||
@ -91,6 +96,12 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
|
||||
}
|
||||
});
|
||||
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
sPreferredHeight = (int) (0.67 * metrics.heightPixels);
|
||||
sListItemHeight = (int) (100 * metrics.density);
|
||||
sMaxHeight = (int) (sPreferredHeight + (0.33 * sListItemHeight));
|
||||
|
||||
GeckoApp.registerOnTabsChangedListener(this);
|
||||
Tabs.getInstance().refreshThumbnails();
|
||||
onTabsChanged(null);
|
||||
@ -143,6 +154,28 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent("Tab:Screenshot:Cancel",""));
|
||||
}
|
||||
|
||||
// Tabs List Container holds the ListView and the New Tab button
|
||||
public static class TabsListContainer extends LinearLayout {
|
||||
public TabsListContainer(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
|
||||
super.onSizeChanged(width, height, oldWidth, oldHeight);
|
||||
|
||||
if ((height > sPreferredHeight) && (height != sMaxHeight)) {
|
||||
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
sPreferredHeight));
|
||||
|
||||
// If the list ends perfectly on an item, increase the height of the container
|
||||
if (mList.getHeight() % sListItemHeight == 0)
|
||||
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
sMaxHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adapter to bind tabs into a list
|
||||
private class TabsAdapter extends BaseAdapter {
|
||||
public TabsAdapter(Context context, ArrayList<Tab> tabs) {
|
||||
|
@ -5,10 +5,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
<view class="org.mozilla.gecko.TabsTray$TabsListContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
|
||||
<ListView android:id="@+id/list"
|
||||
style="@style/TabsList"
|
||||
@ -32,6 +33,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</view>
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user