1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

buttons layout in 2 rows in NetworkBookInfoActivity

git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1274 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
Vasiliy Bout 2010-04-22 10:50:33 +00:00
parent b896a54d5b
commit 182b9462fc
3 changed files with 56 additions and 21 deletions

View file

@ -1,5 +1,5 @@
DONE сделать activity с подробной информацией о книжке (увеличенная обложка, аннотация, и кнопки для скачивания/покупки/...) и показывать ее по нажатию на книжку в network library
** съезжает скобка на кнопке Buy
DONE съезжает скобка на кнопке Buy: кнопки в 2 ряда
** поставить процессу скачивания приоритет пониже, чтобы не тормозить UI (?)
** пополнение счета в litres с помощью sms
** убрать иконку сетевого поиска из библиотеки --> перенести в NetworkLibrary

View file

@ -5,19 +5,43 @@
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/network_book_button_panel"
android:id="@+id/network_book_button_panel1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:paddingTop="4dip"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:baselineAligned="false"
>
<Button
android:id="@+id/network_book_button2"
android:layout_width="0dip"
android:layout_weight="1"
android:maxLines="2"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/network_book_button3"
android:layout_width="0dip"
android:layout_weight="1"
android:maxLines="2"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/network_book_button_panel0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_above="@id/network_book_button_panel1"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:baselineAligned="false"
>
<LinearLayout
android:id="@+id/network_book_left_spacer"
android:layout_weight="0.5"
android:layout_weight="0.31"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:orientation="horizontal"
@ -37,17 +61,10 @@
android:maxLines="2"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/network_book_button2"
android:layout_width="0dip"
android:layout_weight="1"
android:maxLines="2"
android:layout_height="wrap_content"
/>
<LinearLayout
android:id="@+id/network_book_right_spacer"
android:layout_width="0dip"
android:layout_weight="0.5"
android:layout_weight="0.31"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone"
@ -57,7 +74,8 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/network_book_button_panel"
android:layout_above="@id/network_book_button_panel0"
android:layout_marginBottom="4dip"
>
<LinearLayout
android:layout_width="fill_parent"

View file

@ -130,19 +130,31 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibraryA
}
private final void setupButtons() {
final ZLResource resource = ZLResource.resource("networkView");
final int buttons[] = new int[] {
R.id.network_book_button0,
R.id.network_book_button1,
R.id.network_book_button2,
R.id.network_book_button0,
R.id.network_book_button1,
R.id.network_book_button2,
R.id.network_book_button3,
};
final Set<NetworkBookActions.Action> actions = NetworkBookActions.getContextMenuActions(myBook);
// debug code:
/*if (actions.size() == 2) {
actions.clear();
}*/
/*actions.add(new NetworkBookActions.Action(NetworkBookActions.TREE_NO_ACTION, "buy", "0z"));
actions.add(new NetworkBookActions.Action(NetworkBookActions.TREE_NO_ACTION, "buy", "1z"));
actions.add(new NetworkBookActions.Action(NetworkBookActions.TREE_NO_ACTION, "buy", "2z"));*/
final boolean skipSecondButton = actions.size() < buttons.length && (actions.size() % 2) == 1;
int buttonNumber = 0;
Set<NetworkBookActions.Action> actions = NetworkBookActions.getContextMenuActions(myBook);
for (final NetworkBookActions.Action a: actions) {
if (skipSecondButton && buttonNumber == 1) {
++buttonNumber;
}
if (buttonNumber >= buttons.length) {
break;
}
ZLResource resource = ZLResource.resource("networkView");
final String text;
if (a.Arg == null) {
text = resource.getResource(a.Key).getValue();
@ -162,9 +174,14 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibraryA
});
button.setEnabled(a.Id != NetworkTreeActions.TREE_NO_ACTION);
}
boolean showSpacers = buttonNumber == 1;
findViewById(R.id.network_book_left_spacer).setVisibility(showSpacers ? View.VISIBLE : View.GONE);
findViewById(R.id.network_book_right_spacer).setVisibility(showSpacers ? View.VISIBLE : View.GONE);
findViewById(R.id.network_book_left_spacer).setVisibility(skipSecondButton ? View.VISIBLE : View.GONE);
findViewById(R.id.network_book_right_spacer).setVisibility(skipSecondButton ? View.VISIBLE : View.GONE);
if (skipSecondButton) {
final int buttonId = buttons[1];
View button = findViewById(buttonId);
button.setVisibility(View.GONE);
button.setOnClickListener(null);
}
while (buttonNumber < buttons.length) {
final int buttonId = buttons[buttonNumber++];
View button = findViewById(buttonId);