Skip to content

Commit b13eec4

Browse files
committed
shortcuts
1 parent f7de4d6 commit b13eec4

4 files changed

Lines changed: 250 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:orientation="vertical"
5+
android:layout_width="fill_parent"
6+
android:layout_height="wrap_content"
7+
android:minWidth="1200dip"
8+
android:layout_marginTop="20dip"
9+
android:layout_marginBottom="20dip"
10+
android:layout_marginLeft="20dip"
11+
android:layout_marginRight="20dip"
12+
>
13+
<TextView
14+
android:id="@+id/lbl_prompt"
15+
style="@style/TextAppearance.Medium"
16+
android:singleLine="false"
17+
android:maxLines="3"
18+
android:layout_margin="5dip"
19+
android:text="Page 34/1024 (25%) Chapter 1"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"/>
22+
<EditText
23+
android:id="@+id/input_field"
24+
android:layout_width="fill_parent"
25+
android:layout_height="wrap_content"
26+
android:layout_marginTop="10dip"
27+
android:layout_marginBottom="10dip"
28+
android:layout_marginLeft="10dip"
29+
android:layout_marginRight="10dip"
30+
style="@style/TextAppearance.Widget.EditText"
31+
android:singleLine="true"
32+
/>
33+
<SeekBar android:id="@+id/goto_position_seek_bar"
34+
android:layout_width="fill_parent"
35+
android:layout_height="wrap_content"
36+
android:layout_marginTop="8dip"
37+
android:layout_marginBottom="8dip"
38+
android:layout_marginLeft="2dip"
39+
android:layout_marginRight="8dip"
40+
android:padding="10dip"
41+
android:max="100"
42+
android:progress="50"
43+
/>
44+
</LinearLayout>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:orientation="vertical"
5+
android:layout_width="fill_parent"
6+
android:layout_height="wrap_content"
7+
android:minWidth="1200dip"
8+
android:layout_marginTop="5dip"
9+
android:layout_marginBottom="5dip"
10+
android:layout_marginLeft="5dip"
11+
android:layout_marginRight="5dip"
12+
>
13+
<TextView
14+
android:id="@+id/lbl_prompt"
15+
style="@style/TextAppearance.Medium"
16+
android:singleLine="false"
17+
android:maxLines="3"
18+
android:layout_margin="3dip"
19+
android:text="Page 34/1024 (25%) Chapter 1"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"/>
22+
<EditText
23+
android:id="@+id/input_field"
24+
android:layout_width="fill_parent"
25+
android:layout_height="wrap_content"
26+
android:layout_marginTop="3dip"
27+
android:layout_marginBottom="3dip"
28+
android:layout_marginLeft="3dip"
29+
android:layout_marginRight="3dip"
30+
style="@style/TextAppearance.Widget.EditText"
31+
android:singleLine="true"
32+
/>
33+
<SeekBar android:id="@+id/goto_position_seek_bar"
34+
android:layout_width="fill_parent"
35+
android:layout_height="wrap_content"
36+
android:layout_marginTop="2dip"
37+
android:layout_marginBottom="2dip"
38+
android:layout_marginLeft="2dip"
39+
android:layout_marginRight="2dip"
40+
android:padding="10dip"
41+
android:max="100"
42+
android:progress="50"
43+
/>
44+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
45+
android:id="@+id/pages_list"
46+
android:orientation="vertical"
47+
android:layout_weight="8"
48+
android:layout_width="fill_parent"
49+
android:layout_height="fill_parent"
50+
android:baselineAligned="false"
51+
android:layout_marginTop="8dip"
52+
android:layout_marginBottom="8dip"
53+
android:layout_marginLeft="4dip"
54+
android:layout_marginRight="4dip"
55+
>
56+
57+
</LinearLayout>
58+
</LinearLayout>

android/res/layout/page_item.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Book item layout for CR3 file browser
4+
-->
5+
6+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
7+
android:id="@+id/dict_item_body"
8+
android:orientation="horizontal"
9+
android:layout_width="fill_parent"
10+
android:layout_height="wrap_content"
11+
android:baselineAligned="false"
12+
android:layout_marginTop="3dip"
13+
android:layout_marginBottom="3dip"
14+
android:layout_marginLeft="2dip"
15+
android:layout_marginRight="2dip"
16+
>
17+
18+
<LinearLayout android:id="@+id/shortcut_dict_item_sc_layout"
19+
android:orientation="vertical"
20+
android:layout_marginTop="3dip"
21+
android:layout_marginBottom="3dip"
22+
android:layout_marginLeft="8dip"
23+
android:layout_marginRight="8dip"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:layout_gravity="center_vertical|left"
27+
android:baselineAligned="false">
28+
29+
30+
<TextView android:id="@+id/dict_item_shortcut"
31+
style="@style/TextAppearance.Medium"
32+
android:text="1"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:singleLine="true"
36+
android:layout_gravity="left" />
37+
</LinearLayout>
38+
39+
<LinearLayout android:id="@+id/dict_item_text"
40+
android:orientation="vertical"
41+
android:layout_width="fill_parent"
42+
android:layout_height="wrap_content"
43+
android:layout_gravity="center_vertical|fill_horizontal"
44+
android:baselineAligned="false">
45+
46+
47+
<TextView android:id="@+id/dict_item_title"
48+
style="@style/TextAppearance.Large"
49+
android:text="10% Title Text"
50+
android:layout_width="wrap_content"
51+
android:layout_height="wrap_content"
52+
android:singleLine="true"
53+
android:ellipsize="end"
54+
android:layout_gravity="left" />
55+
</LinearLayout>
56+
</LinearLayout>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package org.coolreader.crengine;
2+
3+
import org.coolreader.R;
4+
5+
import android.text.method.DigitsKeyListener;
6+
import android.view.LayoutInflater;
7+
import android.view.ViewGroup;
8+
import android.widget.EditText;
9+
import android.widget.SeekBar;
10+
import android.widget.SeekBar.OnSeekBarChangeListener;
11+
import android.widget.TextView;
12+
13+
public class InputDialog extends BaseDialog {
14+
15+
public interface InputHandler {
16+
boolean validate( String s ) throws Exception;
17+
void onOk( String s ) throws Exception;
18+
void onCancel();
19+
};
20+
21+
private InputHandler handler;
22+
private EditText input;
23+
int minValue;
24+
int maxValue;
25+
public InputDialog( BaseActivity activity, final String title, final String prompt, boolean isNumberEdit, int minValue, int maxValue, int currentValue, final InputHandler handler )
26+
{
27+
super(activity, title, true, false);
28+
this.handler = handler;
29+
this.minValue = minValue;
30+
this.maxValue = maxValue;
31+
LayoutInflater mInflater = LayoutInflater.from(getContext());
32+
ViewGroup layout = (ViewGroup)mInflater.inflate(R.layout.line_edit_dlg, null);
33+
input = (EditText)layout.findViewById(R.id.input_field);
34+
TextView promptView = (TextView)layout.findViewById(R.id.lbl_prompt);
35+
if (promptView != null) {
36+
promptView.setText(prompt);
37+
}
38+
SeekBar seekBar = (SeekBar)layout.findViewById(R.id.goto_position_seek_bar);
39+
if (seekBar != null) {
40+
seekBar.setMax(maxValue - minValue);
41+
seekBar.setProgress(currentValue);
42+
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
43+
@Override
44+
public void onStopTrackingTouch(SeekBar seekBar) {
45+
}
46+
47+
@Override
48+
public void onStartTrackingTouch(SeekBar seekBar) {
49+
}
50+
51+
@Override
52+
public void onProgressChanged(SeekBar seekBar, int progress,
53+
boolean fromUser) {
54+
if (fromUser) {
55+
String value = String.valueOf(progress + InputDialog.this.minValue);
56+
try {
57+
if (handler.validate(value))
58+
input.setText(value);
59+
} catch (Exception e) {
60+
// ignore
61+
}
62+
}
63+
}
64+
});
65+
}
66+
//input = new EditText(getContext());
67+
if ( isNumberEdit )
68+
input.setKeyListener(DigitsKeyListener.getInstance("0123456789."));
69+
// input.getText().setFilters(new InputFilter[] {
70+
// new DigitsKeyListener()
71+
// });
72+
setView(layout);
73+
}
74+
@Override
75+
protected void onNegativeButtonClick() {
76+
cancel();
77+
handler.onCancel();
78+
}
79+
@Override
80+
protected void onPositiveButtonClick() {
81+
String value = input.getText().toString().trim();
82+
try {
83+
if ( handler.validate(value) )
84+
handler.onOk(value);
85+
else
86+
handler.onCancel();
87+
} catch ( Exception e ) {
88+
handler.onCancel();
89+
}
90+
cancel();
91+
}
92+
}

0 commit comments

Comments
 (0)