зеркало из https://github.com/mozilla/gecko-dev.git
Bug 712526: Restrict tabs menu to occupy only 2/3 of the screen. [r=mfinkle]
This commit is contained in:
Родитель
dd08c68dab
Коммит
202c74d82d
|
@ -44,6 +44,8 @@ import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -58,7 +60,10 @@ import android.widget.TextView;
|
||||||
|
|
||||||
public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener {
|
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 TabsAdapter mTabsAdapter;
|
||||||
private boolean mWaitingForClose;
|
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);
|
GeckoApp.registerOnTabsChangedListener(this);
|
||||||
Tabs.getInstance().refreshThumbnails();
|
Tabs.getInstance().refreshThumbnails();
|
||||||
onTabsChanged(null);
|
onTabsChanged(null);
|
||||||
|
@ -143,6 +154,28 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
|
||||||
GeckoAppShell.sendEventToGecko(new GeckoEvent("Tab:Screenshot:Cancel",""));
|
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
|
// Adapter to bind tabs into a list
|
||||||
private class TabsAdapter extends BaseAdapter {
|
private class TabsAdapter extends BaseAdapter {
|
||||||
public TabsAdapter(Context context, ArrayList<Tab> tabs) {
|
public TabsAdapter(Context context, ArrayList<Tab> tabs) {
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<view class="org.mozilla.gecko.TabsTray$TabsListContainer"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/tabs_tray_bg_repeat">
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/tabs_tray_bg_repeat">
|
||||||
|
|
||||||
<ListView android:id="@+id/list"
|
<ListView android:id="@+id/list"
|
||||||
style="@style/TabsList"
|
style="@style/TabsList"
|
||||||
|
@ -32,6 +33,6 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</view>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче