Offline HTML Reader for Android
Revisão | 7974910048949fa7734b88a8a074164b0e5a723b (tree) |
---|---|
Hora | 2012-11-20 20:06:26 |
Autor | Kana Koda <kodakana@user...> |
Commiter | Kana Koda |
メモリリークに関する修正。Honeycomb以上でアクションバーを使うように変更。
@@ -4,5 +4,6 @@ | ||
4 | 4 | <classpathentry kind="src" path="gen"/> |
5 | 5 | <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> |
6 | 6 | <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> |
7 | + <classpathentry exported="true" kind="lib" path="/home/kodakana/Documents/Workspace/Kigo/libs/android-support-v4.jar"/> | |
7 | 8 | <classpathentry kind="output" path="bin/classes"/> |
8 | 9 | </classpath> |
@@ -1,11 +1,11 @@ | ||
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | 3 | package="org.pulpdust.unnetbrowser" |
4 | - android:versionCode="3" | |
5 | - android:versionName="0.72" | |
4 | + android:versionCode="4" | |
5 | + android:versionName="0.8" | |
6 | 6 | android:installLocation="auto" > |
7 | 7 | |
8 | - <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" /> | |
8 | + <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" /> | |
9 | 9 | <uses-permission android:name="android.permission.INTERNET"/> |
10 | 10 | |
11 | 11 | <application |
@@ -54,8 +54,6 @@ Android のバージョンによっては、インストール時にその他の | ||
54 | 54 | |
55 | 55 | いろいろ |
56 | 56 | ------- |
57 | - * 本アプリの[メニュー] - [開く]から目的のフォルダを開いたら、ファイルを指定せずに[OK]ボタンを押しても、 | |
58 | - そのフォルダの中にある HTML ファイルを開くことができます。 | |
59 | 57 | * 拡張子 htm、html、xhtml 以外のファイルが指定された場合は、他のアプリを呼び出します。 |
60 | 58 | |
61 | 59 | 許諾条件 |
@@ -20,6 +20,7 @@ Features & Functions | ||
20 | 20 | * You can operate the various functions from the hard keyboard. |
21 | 21 | * Display a list of HTML files or index file (if it exists) Press and hold the [<(Previous)] button. |
22 | 22 | * Forward to the History Press and hold the [>(Next)] button. |
23 | + * Hold the PgUp/PgDn button, you can switch the show or hide the actionbar temporarily. | |
23 | 24 | |
24 | 25 | Keyboard Shortcut |
25 | 26 | ------------------- |
@@ -48,11 +49,10 @@ Keyboard Shortcut | ||
48 | 49 | Permissions |
49 | 50 | ------------ |
50 | 51 | This app requires Internet access permissions to read the images of remote. |
51 | -Depending on the version of Android, which may be displayed to allow the permissions other than this during the installation, it is one that is required by the OS for compatibility, Kigo are those permissions are not used. | |
52 | +Depending on the version of Android, which may be displayed to allow the permissions other than this during the installation, it is one that is required by the OS for compatibility, Unnet Browser are those permissions are not used. | |
52 | 53 | |
53 | 54 | Tips |
54 | 55 | ----- |
55 | - * Once you have opened the desired folder from the [Menu] - [Open], pressing the [OK] button without specifying a file, you can open the HTML files in that folder. | |
56 | 56 | * If the file extension htm, html, xhtml other than is specified, call other apps. |
57 | 57 | |
58 | 58 | License |
@@ -1,11 +1,11 @@ | ||
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | 3 | package="org.pulpdust.unnetbrowser" |
4 | - android:versionCode="3" | |
5 | - android:versionName="0.72" | |
4 | + android:versionCode="4" | |
5 | + android:versionName="0.8" | |
6 | 6 | android:installLocation="auto" > |
7 | 7 | |
8 | - <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" /> | |
8 | + <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" /> | |
9 | 9 | <uses-permission android:name="android.permission.INTERNET"/> |
10 | 10 | |
11 | 11 | <application |
@@ -17,7 +17,8 @@ public final class R { | ||
17 | 17 | public static final class attr { |
18 | 18 | } |
19 | 19 | public static final class drawable { |
20 | - public static final int ic_launcher=0x7f020000; | |
20 | + public static final int bg_actionbar=0x7f020000; | |
21 | + public static final int ic_launcher=0x7f020001; | |
21 | 22 | } |
22 | 23 | public static final class id { |
23 | 24 | public static final int bt_go_find=0x7f080002; |
@@ -39,7 +40,7 @@ public final class R { | ||
39 | 40 | public static final int main=0x7f030001; |
40 | 41 | } |
41 | 42 | public static final class string { |
42 | - public static final int about=0x7f06003b; | |
43 | + public static final int about=0x7f06003d; | |
43 | 44 | public static final int address=0x7f060005; |
44 | 45 | public static final int app_author=0x7f060006; |
45 | 46 | public static final int app_copy=0x7f060008; |
@@ -48,14 +49,14 @@ public final class R { | ||
48 | 49 | public static final int app_name=0x7f060001; |
49 | 50 | public static final int app_ver=0x7f060004; |
50 | 51 | public static final int back=0x7f06001a; |
51 | - public static final int behaviour=0x7f06003a; | |
52 | + public static final int behaviour=0x7f06003c; | |
52 | 53 | public static final int bottom=0x7f06000d; |
53 | 54 | public static final int buttons=0x7f060015; |
54 | 55 | public static final int close=0x7f060010; |
55 | 56 | public static final int copy=0x7f060007; |
56 | - public static final int display=0x7f060039; | |
57 | - public static final int err_404=0x7f06003c; | |
58 | - public static final int err_500=0x7f06003d; | |
57 | + public static final int display=0x7f06003b; | |
58 | + public static final int err_404=0x7f06003e; | |
59 | + public static final int err_500=0x7f06003f; | |
59 | 60 | public static final int etc=0x7f060011; |
60 | 61 | public static final int find=0x7f060014; |
61 | 62 | public static final int first=0x7f060021; |
@@ -64,34 +65,37 @@ public final class R { | ||
64 | 65 | public static final int go_find=0x7f06001b; |
65 | 66 | public static final int hello=0x7f060000; |
66 | 67 | public static final int index=0x7f060013; |
67 | - public static final int info_restart=0x7f06002f; | |
68 | + public static final int info_restart=0x7f060031; | |
68 | 69 | public static final int license=0x7f060009; |
69 | - public static final int loading=0x7f06003e; | |
70 | + public static final int loading=0x7f060040; | |
70 | 71 | public static final int m_next=0x7f060018; |
71 | 72 | public static final int m_prev=0x7f060017; |
72 | 73 | public static final int match=0x7f06001c; |
73 | 74 | public static final int next=0x7f06001e; |
74 | 75 | public static final int open=0x7f06000b; |
76 | + public static final int perf_actionbar_desc=0x7f060041; | |
75 | 77 | public static final int pgdn=0x7f060020; |
76 | 78 | public static final int pgup=0x7f06001f; |
79 | + public static final int pref_actionbar=0x7f06002c; | |
80 | + public static final int pref_actionbar_desc=0x7f06002d; | |
77 | 81 | public static final int pref_button=0x7f060025; |
78 | - public static final int pref_cache=0x7f060038; | |
82 | + public static final int pref_cache=0x7f06003a; | |
79 | 83 | public static final int pref_font=0x7f060026; |
80 | 84 | public static final int pref_image=0x7f060028; |
81 | - public static final int pref_restart=0x7f06002d; | |
82 | - public static final int pref_restart_desc=0x7f06002e; | |
85 | + public static final int pref_restart=0x7f06002f; | |
86 | + public static final int pref_restart_desc=0x7f060030; | |
83 | 87 | public static final int pref_script=0x7f060027; |
84 | 88 | public static final int pref_title=0x7f06002b; |
85 | - public static final int pref_title_desc=0x7f06002c; | |
89 | + public static final int pref_title_desc=0x7f06002e; | |
86 | 90 | public static final int pref_titlebar=0x7f060024; |
87 | - public static final int pref_vol=0x7f060030; | |
88 | - public static final int pref_vol_def=0x7f060031; | |
89 | - public static final int pref_vol_fns=0x7f060035; | |
90 | - public static final int pref_vol_fns_v11=0x7f060036; | |
91 | - public static final int pref_vol_iof=0x7f060037; | |
92 | - public static final int pref_vol_nop=0x7f060033; | |
93 | - public static final int pref_vol_scl=0x7f060032; | |
94 | - public static final int pref_vol_zoom=0x7f060034; | |
91 | + public static final int pref_vol=0x7f060032; | |
92 | + public static final int pref_vol_def=0x7f060033; | |
93 | + public static final int pref_vol_fns=0x7f060037; | |
94 | + public static final int pref_vol_fns_v11=0x7f060038; | |
95 | + public static final int pref_vol_iof=0x7f060039; | |
96 | + public static final int pref_vol_nop=0x7f060035; | |
97 | + public static final int pref_vol_scl=0x7f060034; | |
98 | + public static final int pref_vol_zoom=0x7f060036; | |
95 | 99 | public static final int pref_wide=0x7f06002a; |
96 | 100 | public static final int pref_zoom=0x7f060029; |
97 | 101 | public static final int prefs=0x7f06000f; |
@@ -0,0 +1,4 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> | |
3 | + <solid android:color="#BB000000" /> | |
4 | +</shape> | |
\ No newline at end of file |
@@ -5,7 +5,7 @@ | ||
5 | 5 | <string name="app_name">Unnet Browser</string> |
6 | 6 | <string name="app_desc">オフライン HTML リーダ</string> |
7 | 7 | <string name="version">バージョン</string> |
8 | - <string name="app_ver">0.7</string> | |
8 | + <string name="app_ver">0.8</string> | |
9 | 9 | <string name="address">連絡先</string> |
10 | 10 | <string name="app_author">Kodakana<kodakana.hws@gmail.com></string> |
11 | 11 | <string name="copy">製作・著作</string> |
@@ -45,9 +45,11 @@ | ||
45 | 45 | <string name="pref_zoom">拡大/縮小操作を使う</string> |
46 | 46 | <string name="pref_wide">描画領域を拡げる</string> |
47 | 47 | <string name="pref_title">タイトルバーを隠す</string> |
48 | + <string name="pref_actionbar">アクションバーを隠す</string> | |
49 | + <string name="perf_actionbar_desc">この設定は画面が再構築されるときに完全に反映されます。</string> | |
48 | 50 | <string name="pref_title_desc">この設定は画面が再構築されるときに反映されます。</string> |
49 | 51 | <string name="pref_restart">自動的に開き直す</string> |
50 | - <string name="pref_restart_desc">タイトルバーの設定を反映するために自動的に再起動するかどうか。</string> | |
52 | + <string name="pref_restart_desc">設定を反映するために必要な場合に自動的に再起動するかどうか。</string> | |
51 | 53 | <string name="info_restart">設定を反映するために自動的に再起動します。</string> |
52 | 54 | <string name="pref_vol">音量キー</string> |
53 | 55 | <string name="pref_vol_def">割り当てなし</string> |
@@ -5,7 +5,7 @@ | ||
5 | 5 | <string name="app_name">Unnet Browser</string> |
6 | 6 | <string name="app_desc">is an offline HTML reader.</string> |
7 | 7 | <string name="version">Version</string> |
8 | - <string name="app_ver">0.7</string> | |
8 | + <string name="app_ver">0.8</string> | |
9 | 9 | <string name="address">Address</string> |
10 | 10 | <string name="app_author">Kodakana <kodakana.hws@gmail.com></string> |
11 | 11 | <string name="copy">Copyright</string> |
@@ -45,10 +45,12 @@ | ||
45 | 45 | <string name="pref_zoom">Using zoom controls</string> |
46 | 46 | <string name="pref_wide">Use wide viewport</string> |
47 | 47 | <string name="pref_title">Hide the titlebar</string> |
48 | - <string name="pref_title_desc">This setting will take effect when the screen is reconstructed.</string> | |
48 | + <string name="pref_actionbar">Hide the actionbar</string> | |
49 | + <string name="pref_actionbar_desc">This setting will </string> | |
50 | + <string name="pref_title_desc">This setting will take complete effect when the screen is reconstructed.</string> | |
49 | 51 | <string name="pref_restart">Auto restart</string> |
50 | - <string name="pref_restart_desc">Or automatically restarted in take to effect the setting of the title bar.</string> | |
51 | - <string name="info_restart">Are automatically restarted in take to effect the setting.</string> | |
52 | + <string name="pref_restart_desc">Whether restart automatically if needed to effect the settings.</string> | |
53 | + <string name="info_restart">automatically restart for take to effect the settings.</string> | |
52 | 54 | <string name="pref_vol">Volume Key</string> |
53 | 55 | <string name="pref_vol_def">Default</string> |
54 | 56 | <string name="pref_vol_scl">Page scroll</string> |
@@ -0,0 +1,65 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:title="@string/pref_titlebar" > | |
4 | + <PreferenceCategory android:title="@string/display"> | |
5 | + <ListPreference | |
6 | + android:key="font_size" | |
7 | + android:title="@string/pref_font" | |
8 | + android:entries="@array/font_size_labels" | |
9 | + android:entryValues="@array/font_size_values" | |
10 | + android:dialogTitle="@string/pref_font" | |
11 | + android:defaultValue="16" /> | |
12 | + <CheckBoxPreference | |
13 | + android:key="load_remote" | |
14 | + android:title="@string/pref_image" /> | |
15 | + <CheckBoxPreference | |
16 | + android:key="hide_title" | |
17 | + android:title="@string/pref_actionbar" /> | |
18 | + <CheckBoxPreference | |
19 | + android:key="after_restart" | |
20 | + android:title="@string/pref_restart" | |
21 | + android:summary="@string/pref_restart_desc" /> | |
22 | + </PreferenceCategory> | |
23 | + <PreferenceCategory android:title="@string/behaviour"> | |
24 | + <ListPreference | |
25 | + android:key="vol_func" | |
26 | + android:title="@string/pref_vol" | |
27 | + android:entries="@array/vol_func_labels" | |
28 | + android:entryValues="@array/vol_func_values" | |
29 | + android:dialogTitle="@string/pref_vol" | |
30 | + android:defaultValue="0" /> | |
31 | + <CheckBoxPreference | |
32 | + android:key="show_zoom" | |
33 | + android:title="@string/pref_zoom" | |
34 | + android:defaultValue="true" /> | |
35 | + <CheckBoxPreference | |
36 | + android:key="del_cache" | |
37 | + android:title="@string/pref_cache" | |
38 | + android:defaultValue="true" /> | |
39 | + <CheckBoxPreference | |
40 | + android:key="en_script" | |
41 | + android:title="@string/pref_script" /> | |
42 | +<!-- <CheckBoxPreference --> | |
43 | +<!-- android:key="wide_view" --> | |
44 | +<!-- android:title="@string/pref_wide" /> --> | |
45 | + </PreferenceCategory> | |
46 | + <PreferenceCategory android:title="@string/about"> | |
47 | + <Preference | |
48 | + android:selectable="false" | |
49 | + android:title="@string/app_name" | |
50 | + android:summary="@string/app_desc" /> | |
51 | + <Preference | |
52 | + android:selectable="false" | |
53 | + android:title="@string/version" | |
54 | + android:summary="@string/app_ver" /> | |
55 | + <Preference | |
56 | + android:selectable="false" | |
57 | + android:title="@string/copy" | |
58 | + android:summary="@string/app_copy" /> | |
59 | + <Preference | |
60 | + android:selectable="false" | |
61 | + android:title="@string/license" | |
62 | + android:summary="@string/app_lic" /> | |
63 | + </PreferenceCategory> | |
64 | + | |
65 | +</PreferenceScreen> | |
\ No newline at end of file |
@@ -12,6 +12,7 @@ import java.lang.Math; | ||
12 | 12 | |
13 | 13 | import android.app.Activity; |
14 | 14 | import android.app.AlertDialog; |
15 | +import android.app.Dialog; | |
15 | 16 | import android.content.ActivityNotFoundException; |
16 | 17 | import android.content.Context; |
17 | 18 | import android.content.DialogInterface; |
@@ -22,6 +23,9 @@ import android.net.Uri; | ||
22 | 23 | import android.os.Build; |
23 | 24 | import android.os.Bundle; |
24 | 25 | import android.os.Environment; |
26 | +import android.support.v4.app.DialogFragment; | |
27 | +import android.support.v4.app.FragmentActivity; | |
28 | +import android.support.v4.app.FragmentManager; | |
25 | 29 | import android.preference.PreferenceManager; |
26 | 30 | import android.text.Editable; |
27 | 31 | import android.text.TextWatcher; |
@@ -57,60 +61,62 @@ import android.widget.TextView; | ||
57 | 61 | import android.widget.Toast; |
58 | 62 | import android.graphics.Bitmap; |
59 | 63 | |
60 | -public class UnnetBrowserActivity extends Activity { | |
64 | +public class UnnetBrowserActivity extends FragmentActivity { | |
61 | 65 | final static String TAG = "UnnetBrowserActivity"; |
62 | 66 | public static final String PREFS = "prefs"; |
63 | - WebView webview; | |
67 | + static WebView webview; | |
64 | 68 | TextView textview1; |
65 | - Button button1; | |
69 | + static Button button1; | |
66 | 70 | Button button2; |
67 | 71 | Button button3; |
68 | - Button button4; | |
72 | + static Button button4; | |
69 | 73 | EditText edittext1; |
70 | 74 | Button button5; |
71 | 75 | Uri dir; |
72 | - String dir_s = ""; | |
76 | + static String dir_s = ""; | |
73 | 77 | String dir_prev; |
74 | - String htmls[]; | |
78 | + static String htmls[]; | |
75 | 79 | String sort = "asc"; |
76 | 80 | String fsbj = ""; |
77 | 81 | String exts = "^.+\\.x?html?$"; |
78 | 82 | AlertDialog alrt; |
79 | 83 | EditText findtext; |
80 | 84 | Button gofind; |
81 | - int newidx = 0; | |
85 | + static int newidx = 0; | |
82 | 86 | int newidx_prev; |
83 | - int pnom = 0; | |
84 | - int index_of = -1; | |
87 | + static int pnom = 0; | |
88 | + static int index_of = -1; | |
85 | 89 | int volkey = 0; |
86 | 90 | int matchs = -1; |
87 | 91 | int match = 0; |
88 | 92 | int iscale; |
89 | 93 | float fscale = -1; |
90 | - boolean after_back_key = false; | |
94 | + static boolean after_back_key = false; | |
91 | 95 | boolean will_load = true; |
92 | - boolean hide_title = false; | |
96 | + static boolean hide_title = false; | |
97 | + boolean hide_title_default; | |
93 | 98 | boolean hide_title_p; |
94 | 99 | boolean del_cache = true; |
95 | 100 | boolean mode_find = false; |
96 | 101 | boolean hide_buttons = false; |
97 | 102 | boolean full_screen = false; |
98 | - private static final int MENU_0 = 9; | |
99 | - private static final int MENU_TOP = 1; | |
100 | - private static final int MENU_BTM = 2; | |
101 | - private static final int MENU_SRT = 3; | |
102 | - private static final int MENU_PRF = 4; | |
103 | - private static final int MENU_CLS = 5; | |
103 | + static final int MENU_0 = 9; | |
104 | + static final int MENU_TOP = 1; | |
105 | + static final int MENU_BTM = 2; | |
106 | + static final int MENU_SRT = 3; | |
107 | + static final int MENU_PRF = 4; | |
108 | + static final int MENU_CLS = 5; | |
104 | 109 | // private static final int CTXT_CPY = 6; |
105 | - private static final int MENU_CPY = 7; | |
106 | - private static final int MENU_FND = 8; | |
107 | - private static final int MENU_BTN = 10; | |
108 | - private static final int MENU_FSC = 11; | |
109 | - private static final int MENU_NXT = 12; | |
110 | - private static final int MENU_PRV = 13; | |
111 | - private static final int MENU_IDX = 14; | |
112 | - private static final int MENU_FWD = 15; | |
113 | - private static final int MENU_BCK = 16; | |
110 | + static final int MENU_CPY = 7; | |
111 | + static final int MENU_FND = 8; | |
112 | + static final int MENU_BTN = 10; | |
113 | + static final int MENU_FSC = 11; | |
114 | + static final int MENU_NXT = 12; | |
115 | + static final int MENU_PRV = 13; | |
116 | + static final int MENU_IDX = 14; | |
117 | + static final int MENU_FWD = 15; | |
118 | + static final int MENU_BCK = 16; | |
119 | + Menu omenu; | |
114 | 120 | // DisplayMetrics dmtrcs; |
115 | 121 | Pattern accept = Pattern.compile(exts, |
116 | 122 | Pattern.CASE_INSENSITIVE|Pattern.UNICODE_CASE); |
@@ -133,14 +139,10 @@ public class UnnetBrowserActivity extends Activity { | ||
133 | 139 | hide_buttons = settings.getBoolean("last_buttons", false); |
134 | 140 | hide_title_p = hide_title; |
135 | 141 | full_screen = settings.getBoolean("last_screen", false); |
136 | - Window wndw = getWindow(); | |
137 | - setTitlebar(); | |
138 | - requestWindowFeature(Window.FEATURE_LEFT_ICON); | |
139 | -// wndw.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); | |
140 | 142 | requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); |
143 | + setTitlebar(); | |
141 | 144 | setContentView(R.layout.main); |
142 | - wndw.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_launcher); | |
143 | - setWebView(); | |
145 | + setWebView(this); | |
144 | 146 | // registerForContextMenu(webview); |
145 | 147 | button1 = (Button)findViewById(R.id.button1); |
146 | 148 | button2 = (Button)findViewById(R.id.button2); |
@@ -159,6 +161,35 @@ public class UnnetBrowserActivity extends Activity { | ||
159 | 161 | if (savedInstanceState != null){ |
160 | 162 | webview.restoreState(savedInstanceState); |
161 | 163 | } |
164 | + if (Build.VERSION.SDK_INT >= 11){ | |
165 | + button2.setOnLongClickListener(new OnLongClickListener(){ | |
166 | + public boolean onLongClick(View v){ | |
167 | + if (hide_title){ | |
168 | + return false; | |
169 | + } else { | |
170 | + toHideActionBar(); | |
171 | + hide_title = true; | |
172 | + if (omenu != null) variMenu(omenu); | |
173 | + toUpdateOptionsMenu(); | |
174 | + return true; | |
175 | + } | |
176 | + } | |
177 | + }); | |
178 | + button3.setOnLongClickListener(new OnLongClickListener(){ | |
179 | + public boolean onLongClick(View v){ | |
180 | + if (hide_title){ | |
181 | + toShowActionBar(); | |
182 | + hide_title = false; | |
183 | + if (omenu != null) variMenu(omenu); | |
184 | + toUpdateOptionsMenu(); | |
185 | + return true; | |
186 | + } else { | |
187 | + return false; | |
188 | + } | |
189 | + } | |
190 | + }); | |
191 | + } | |
192 | + | |
162 | 193 | setFinder(); |
163 | 194 | varView(0); |
164 | 195 | // webview.setInitialScale(iscale); |
@@ -182,19 +213,34 @@ public class UnnetBrowserActivity extends Activity { | ||
182 | 213 | dir_s = cdir; |
183 | 214 | if (exDir()){ |
184 | 215 | pnom = curIndex(cfil); |
185 | - loadFiles(true); | |
216 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
186 | 217 | } |
187 | 218 | } else { |
188 | 219 | throwIntent(url); |
189 | 220 | } |
190 | 221 | } else if (dir_s != ""){ |
191 | 222 | if (exDir()){ |
192 | - loadFiles(true); | |
223 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
193 | 224 | } |
194 | 225 | } else { |
195 | 226 | // webview.loadUrl("file:///android_asset/index.html"); |
196 | 227 | } |
197 | 228 | } |
229 | + @Override | |
230 | + public void onStart(){ | |
231 | + super.onStart(); | |
232 | + | |
233 | + } | |
234 | + public void toHideActionBar(){ | |
235 | + forHoneycomb.hideActionBar(this); | |
236 | + } | |
237 | + public void toShowActionBar(){ | |
238 | + forHoneycomb.showActionBar(this); | |
239 | +// if (omenu != null) forHoneycomb.prepareOptionsMenu(omenu, 0); | |
240 | + } | |
241 | + public void toUpdateOptionsMenu(){ | |
242 | + if (Build.VERSION.SDK_INT >= 11) forHoneycomb.updateOptionsMenu(this); | |
243 | + } | |
198 | 244 | public void setFinder(){ |
199 | 245 | textview1 = (TextView) findViewById(R.id.textView1); |
200 | 246 | textview1.setVisibility(View.GONE); |
@@ -239,7 +285,7 @@ public class UnnetBrowserActivity extends Activity { | ||
239 | 285 | super.onConfigurationChanged(nc); |
240 | 286 | // webview.setInitialScale(iscale); |
241 | 287 | } |
242 | - public void setWebView(){ | |
288 | + public void setWebView(final Context c){ | |
243 | 289 | webview = (WebView)findViewById(R.id.webview1); |
244 | 290 | webview.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY); |
245 | 291 | // int dscale = dmtrcs.widthPixels / 10; |
@@ -280,10 +326,10 @@ public class UnnetBrowserActivity extends Activity { | ||
280 | 326 | if (!kev.isAltPressed() && htmls != null){ |
281 | 327 | if (index_of > -1){ |
282 | 328 | pnom = index_of; |
283 | - loadFiles(true); | |
329 | + loadFiles(true, c, getSupportFragmentManager()); | |
284 | 330 | return true; |
285 | 331 | } else { |
286 | - echoIndex(); | |
332 | + echoIndex(c, getSupportFragmentManager()); | |
287 | 333 | return true; |
288 | 334 | } |
289 | 335 | } else { |
@@ -291,14 +337,14 @@ public class UnnetBrowserActivity extends Activity { | ||
291 | 337 | } |
292 | 338 | case KeyEvent.KEYCODE_N: |
293 | 339 | if (!kev.isAltPressed()){ |
294 | - goNext(); | |
340 | + goNext(getApplication()); | |
295 | 341 | return true; |
296 | 342 | } else { |
297 | 343 | return false; |
298 | 344 | } |
299 | 345 | case KeyEvent.KEYCODE_P: |
300 | 346 | if (!kev.isAltPressed()){ |
301 | - goPrev(); | |
347 | + goPrev(getApplication()); | |
302 | 348 | return true; |
303 | 349 | } else { |
304 | 350 | return false; |
@@ -378,7 +424,7 @@ public class UnnetBrowserActivity extends Activity { | ||
378 | 424 | } else { |
379 | 425 | pnom = curIndex(cfil); |
380 | 426 | } |
381 | - loadFiles(true); | |
427 | + loadFiles(true, c, getSupportFragmentManager()); | |
382 | 428 | return true; |
383 | 429 | } |
384 | 430 | } |
@@ -495,9 +541,7 @@ public class UnnetBrowserActivity extends Activity { | ||
495 | 541 | // return super.onContextItemSelected(item); |
496 | 542 | // } |
497 | 543 | // } |
498 | - @Override | |
499 | - public boolean onPrepareOptionsMenu(Menu menu){ | |
500 | - super.onPrepareOptionsMenu(menu); | |
544 | + public boolean variMenu(Menu menu){ | |
501 | 545 | MenuItem prpr0 = (MenuItem) menu.findItem(MENU_PRV); |
502 | 546 | MenuItem prpr1 = (MenuItem) menu.findItem(MENU_NXT); |
503 | 547 | MenuItem prpr2 = (MenuItem) menu.findItem(MENU_IDX); |
@@ -507,26 +551,39 @@ public class UnnetBrowserActivity extends Activity { | ||
507 | 551 | prpr1.setVisible(true); |
508 | 552 | prpr2.setVisible(false); |
509 | 553 | prpr3.setVisible(false); |
510 | - return true; | |
554 | + if (Build.VERSION.SDK_INT >= 11 && !hide_title) forHoneycomb.prepareOptionsMenu(menu, 1); | |
555 | + else if (Build.VERSION.SDK_INT >= 11 && hide_title) forHoneycomb.prepareOptionsMenu(menu, 2); | |
511 | 556 | } else if (hide_buttons && volkey == 2){ |
512 | 557 | prpr0.setVisible(false); |
513 | 558 | prpr1.setVisible(false); |
514 | 559 | prpr2.setVisible(true); |
515 | 560 | prpr3.setVisible(true); |
516 | - return true; | |
561 | + if (Build.VERSION.SDK_INT >= 11 && !hide_title) forHoneycomb.prepareOptionsMenu(menu, 0); | |
562 | + else if (Build.VERSION.SDK_INT >= 11 && hide_title) forHoneycomb.prepareOptionsMenu(menu, 2); | |
517 | 563 | } else if (hide_buttons){ |
518 | 564 | prpr0.setVisible(true); |
519 | 565 | prpr1.setVisible(true); |
520 | 566 | prpr2.setVisible(true); |
521 | 567 | prpr3.setVisible(true); |
522 | - return true; | |
568 | + if (Build.VERSION.SDK_INT >= 11 && !hide_title) forHoneycomb.prepareOptionsMenu(menu, 1); | |
569 | + else if (Build.VERSION.SDK_INT >= 11 && hide_title) forHoneycomb.prepareOptionsMenu(menu, 2); | |
523 | 570 | } else { |
524 | 571 | prpr0.setVisible(false); |
525 | 572 | prpr1.setVisible(false); |
526 | 573 | prpr2.setVisible(false); |
527 | 574 | prpr3.setVisible(false); |
528 | - return true; | |
575 | + if (Build.VERSION.SDK_INT >= 11 && !hide_title) forHoneycomb.prepareOptionsMenu(menu, 0); | |
576 | + else if (Build.VERSION.SDK_INT >= 11 && hide_title) forHoneycomb.prepareOptionsMenu(menu, 2); | |
529 | 577 | } |
578 | + return true; | |
579 | + } | |
580 | + @Override | |
581 | + public boolean onPrepareOptionsMenu(Menu menu){ | |
582 | + super.onPrepareOptionsMenu(menu); | |
583 | +// if (Build.VERSION.SDK_INT >= 11){ | |
584 | +// forHoneycomb.prepareOptionsMenu(menu, 0); | |
585 | +// } | |
586 | + return variMenu(menu); | |
530 | 587 | } |
531 | 588 | @Override |
532 | 589 | public boolean onCreateOptionsMenu(Menu menu){ |
@@ -573,13 +630,18 @@ public class UnnetBrowserActivity extends Activity { | ||
573 | 630 | } |
574 | 631 | MenuItem mnitm5 = menu.add(0, MENU_FND, 0, R.string.find); |
575 | 632 | mnitm5.setAlphabeticShortcut('f'); |
576 | - MenuItem mnitm7 = menu.add(0, MENU_FSC, 0, R.string.fullscreen); | |
577 | - mnitm7.setAlphabeticShortcut('1'); | |
633 | + if (Build.VERSION.SDK_INT <= 10 || Build.VERSION.SDK_INT >= 14){ | |
634 | + MenuItem mnitm7 = menu.add(0, MENU_FSC, 0, R.string.fullscreen); | |
635 | + mnitm7.setAlphabeticShortcut('1'); | |
636 | + } | |
578 | 637 | MenuItem mnitm6 = menu.add(0, MENU_BTN, 0, R.string.buttons); |
579 | 638 | mnitm6.setAlphabeticShortcut('b'); |
580 | 639 | MenuItem mnitm8 = menu.add(0, MENU_PRF, 0, R.string.prefs); |
581 | 640 | // mnitm8.setIcon(android.R.drawable.ic_menu_preferences); |
582 | 641 | mnitm8.setAlphabeticShortcut('p'); |
642 | + if (Build.VERSION.SDK_INT >= 11){ | |
643 | + omenu = menu; | |
644 | + } | |
583 | 645 | |
584 | 646 | return true; |
585 | 647 | } |
@@ -592,13 +654,13 @@ public class UnnetBrowserActivity extends Activity { | ||
592 | 654 | case MENU_TOP: |
593 | 655 | if (dir_s != ""){ |
594 | 656 | pnom = 0; |
595 | - loadFiles(true); | |
657 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
596 | 658 | } |
597 | 659 | return true; |
598 | 660 | case MENU_BTM: |
599 | 661 | if (dir_s != ""){ |
600 | 662 | pnom = newidx - 1; |
601 | - loadFiles(true); | |
663 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
602 | 664 | } |
603 | 665 | return true; |
604 | 666 | case MENU_SRT: |
@@ -606,12 +668,12 @@ public class UnnetBrowserActivity extends Activity { | ||
606 | 668 | if (sort.equals("desc")){ |
607 | 669 | ascHtmls(); |
608 | 670 | sort = "asc"; |
609 | - loadFiles(true); | |
671 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
610 | 672 | return true; |
611 | 673 | } else { |
612 | 674 | descHtmls(); |
613 | 675 | sort = "desc"; |
614 | - loadFiles(true); | |
676 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
615 | 677 | return true; |
616 | 678 | } |
617 | 679 | } |
@@ -635,11 +697,11 @@ public class UnnetBrowserActivity extends Activity { | ||
635 | 697 | return true; |
636 | 698 | case MENU_BTN: |
637 | 699 | if (hide_buttons){ |
638 | - showButtons(); | |
639 | 700 | hide_buttons = false; |
701 | + showButtons(); | |
640 | 702 | } else { |
641 | - hideButtons(); | |
642 | 703 | hide_buttons = true; |
704 | + hideButtons(); | |
643 | 705 | } |
644 | 706 | return true; |
645 | 707 | case MENU_FSC: |
@@ -652,19 +714,19 @@ public class UnnetBrowserActivity extends Activity { | ||
652 | 714 | } |
653 | 715 | return true; |
654 | 716 | case MENU_PRV: |
655 | - goPrev(); | |
717 | + goPrev(getApplication()); | |
656 | 718 | return true; |
657 | 719 | case MENU_NXT: |
658 | - goNext(); | |
720 | + goNext(getApplication()); | |
659 | 721 | return true; |
660 | 722 | case MENU_IDX: |
661 | 723 | if (htmls != null){ |
662 | 724 | if (index_of > -1){ |
663 | 725 | pnom = index_of; |
664 | - loadFiles(true); | |
726 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
665 | 727 | return true; |
666 | 728 | } else { |
667 | - echoIndex(); | |
729 | + echoIndex(getApplication(), getSupportFragmentManager()); | |
668 | 730 | return true; |
669 | 731 | } |
670 | 732 | } else { |
@@ -723,7 +785,7 @@ public class UnnetBrowserActivity extends Activity { | ||
723 | 785 | webview.pageUp(false); |
724 | 786 | return true; |
725 | 787 | } else if (volkey == 2){ |
726 | - goPrev(); | |
788 | + goPrev(getApplication()); | |
727 | 789 | return true; |
728 | 790 | } else if (volkey == 3){ |
729 | 791 | webview.zoomIn(); |
@@ -737,10 +799,10 @@ public class UnnetBrowserActivity extends Activity { | ||
737 | 799 | if (htmls != null){ |
738 | 800 | if (index_of > -1){ |
739 | 801 | pnom = index_of; |
740 | - loadFiles(true); | |
802 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
741 | 803 | return true; |
742 | 804 | } else { |
743 | - echoIndex(); | |
805 | + echoIndex(getApplication(), getSupportFragmentManager()); | |
744 | 806 | return true; |
745 | 807 | } |
746 | 808 | } else { |
@@ -754,7 +816,7 @@ public class UnnetBrowserActivity extends Activity { | ||
754 | 816 | webview.pageDown(false); |
755 | 817 | return true; |
756 | 818 | } else if (volkey == 2){ |
757 | - goNext(); | |
819 | + goNext(getApplication()); | |
758 | 820 | return true; |
759 | 821 | } else if (volkey == 3){ |
760 | 822 | webview.zoomOut(); |
@@ -812,37 +874,67 @@ public class UnnetBrowserActivity extends Activity { | ||
812 | 874 | } |
813 | 875 | return super.dispatchKeyEvent(kev); |
814 | 876 | } |
815 | - public void echoIndex(){ | |
816 | - AlertDialog.Builder bldr = new AlertDialog.Builder(this); | |
817 | - bldr.setTitle(R.string.index); | |
818 | - bldr.setItems(htmls, new DialogInterface.OnClickListener() { | |
819 | - public void onClick(DialogInterface dialog, int which) { | |
820 | - pnom = which; | |
821 | - loadFiles(true); | |
822 | - } | |
823 | - }); | |
824 | - bldr.show(); | |
825 | - | |
877 | + | |
878 | + public static class IndexDialog extends DialogFragment { | |
879 | + static Context cx; | |
880 | + static FragmentManager fm; | |
881 | + public static IndexDialog newInstance(Context c, String[] items, FragmentManager f){ | |
882 | + cx = c; | |
883 | + fm = f; | |
884 | + IndexDialog id = new IndexDialog(); | |
885 | + Bundle args = new Bundle(); | |
886 | + args.putStringArray("htmls", items); | |
887 | + id.setArguments(args); | |
888 | + return id; | |
889 | + } | |
890 | + public Dialog onCreateDialog(Bundle savedInstaceState){ | |
891 | + String[] htmls = getArguments().getStringArray("htmls"); | |
892 | + return new AlertDialog.Builder(getActivity()) | |
893 | + .setTitle(R.string.index) | |
894 | + .setItems(htmls, new DialogInterface.OnClickListener(){ | |
895 | + public void onClick(DialogInterface df, int which){ | |
896 | + pnom = which; | |
897 | + loadFiles(true, cx, fm); | |
898 | + } | |
899 | + }) | |
900 | + .create(); | |
901 | + } | |
826 | 902 | } |
827 | - public void echoFinder(Context cntxt){ | |
828 | - AlertDialog.Builder adbldr = new AlertDialog.Builder(cntxt); | |
829 | - LayoutInflater ifltr = (LayoutInflater) cntxt.getSystemService(LAYOUT_INFLATER_SERVICE); | |
830 | - View layout = ifltr.inflate(R.layout.find, (ViewGroup) findViewById(R.id.layout_root)); | |
831 | - findtext = (EditText) layout.findViewById(R.id.find_sbj); | |
832 | - findtext.setText(fsbj); | |
833 | - gofind = (Button) layout.findViewById(R.id.bt_go_find); | |
834 | - gofind.setOnClickListener(new OnClickListener(){ | |
835 | - public void onClick(View v){ | |
836 | - textFind(findtext.getText().toString()); | |
837 | -// alrt.dismiss(); | |
838 | - } | |
839 | - }); | |
840 | - adbldr.setTitle(R.string.find); | |
841 | - adbldr.setCancelable(true); | |
842 | - adbldr.setView(layout); | |
843 | - alrt = adbldr.create(); | |
844 | - alrt.show(); | |
903 | + public static void echoIndex(Context c, FragmentManager fm){ | |
904 | + DialogFragment dd = IndexDialog.newInstance(c, htmls, fm); | |
905 | + dd.show(fm, "hoge"); | |
845 | 906 | } |
907 | +// public void echoIndex(){ | |
908 | +// AlertDialog.Builder bldr = new AlertDialog.Builder(this); | |
909 | +// bldr.setTitle(R.string.index); | |
910 | +// bldr.setItems(htmls, new DialogInterface.OnClickListener() { | |
911 | +// public void onClick(DialogInterface dialog, int which) { | |
912 | +// pnom = which; | |
913 | +// loadFiles(true); | |
914 | +// } | |
915 | +// }); | |
916 | +// bldr.show(); | |
917 | +// | |
918 | +// } | |
919 | +// public void echoFinder(Context cntxt){ | |
920 | +// AlertDialog.Builder adbldr = new AlertDialog.Builder(cntxt); | |
921 | +// LayoutInflater ifltr = (LayoutInflater) cntxt.getSystemService(LAYOUT_INFLATER_SERVICE); | |
922 | +// View layout = ifltr.inflate(R.layout.find, (ViewGroup) findViewById(R.id.layout_root)); | |
923 | +// findtext = (EditText) layout.findViewById(R.id.find_sbj); | |
924 | +// findtext.setText(fsbj); | |
925 | +// gofind = (Button) layout.findViewById(R.id.bt_go_find); | |
926 | +// gofind.setOnClickListener(new OnClickListener(){ | |
927 | +// public void onClick(View v){ | |
928 | +// textFind(findtext.getText().toString()); | |
929 | +//// alrt.dismiss(); | |
930 | +// } | |
931 | +// }); | |
932 | +// adbldr.setTitle(R.string.find); | |
933 | +// adbldr.setCancelable(true); | |
934 | +// adbldr.setView(layout); | |
935 | +// alrt = adbldr.create(); | |
936 | +// alrt.show(); | |
937 | +// } | |
846 | 938 | public void textFind(String subject){ |
847 | 939 | fsbj = subject; |
848 | 940 | textview1.setVisibility(View.VISIBLE); |
@@ -890,12 +982,12 @@ public class UnnetBrowserActivity extends Activity { | ||
890 | 982 | public void shiftDown(){ |
891 | 983 | KeyEvent shifton = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0); |
892 | 984 | shifton.dispatch(webview); |
893 | - Toast.makeText(this, R.string.shift_on, Toast.LENGTH_SHORT).show(); | |
985 | + Toast.makeText(getApplication(), R.string.shift_on, Toast.LENGTH_SHORT).show(); | |
894 | 986 | } |
895 | 987 | public void shiftUp(){ |
896 | 988 | KeyEvent shiftoff = new KeyEvent(0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0); |
897 | 989 | shiftoff.dispatch(webview); |
898 | - Toast.makeText(this, R.string.shift_off, Toast.LENGTH_SHORT).show(); | |
990 | + Toast.makeText(getApplication(), R.string.shift_off, Toast.LENGTH_SHORT).show(); | |
899 | 991 | } |
900 | 992 | private void pickDirectory(){ |
901 | 993 | // Intent intent = new Intent("org.openintents.action.PICK_DIRECTORY"); |
@@ -912,7 +1004,7 @@ public class UnnetBrowserActivity extends Activity { | ||
912 | 1004 | try { |
913 | 1005 | startActivityForResult(intent, 1); |
914 | 1006 | } catch (ActivityNotFoundException e){ |
915 | - Toast.makeText(this, R.string.first, Toast.LENGTH_LONG).show(); | |
1007 | + Toast.makeText(getApplication(), R.string.first, Toast.LENGTH_LONG).show(); | |
916 | 1008 | } |
917 | 1009 | } |
918 | 1010 | public boolean exDir(){ |
@@ -922,7 +1014,7 @@ public class UnnetBrowserActivity extends Activity { | ||
922 | 1014 | String files[] = fold.list(); |
923 | 1015 | if (files == null){ |
924 | 1016 | dir_s = dir_prev; |
925 | - Toast.makeText(this, R.string.err_404, Toast.LENGTH_LONG).show(); | |
1017 | + Toast.makeText(getApplication(), R.string.err_404, Toast.LENGTH_LONG).show(); | |
926 | 1018 | return false; |
927 | 1019 | } |
928 | 1020 | // int fcount = files.length; |
@@ -944,7 +1036,7 @@ public class UnnetBrowserActivity extends Activity { | ||
944 | 1036 | dir_s = dir_prev; |
945 | 1037 | // exDir(); |
946 | 1038 | will_load = false; |
947 | - Toast.makeText(this, R.string.err_404, Toast.LENGTH_LONG).show(); | |
1039 | + Toast.makeText(getApplication(), R.string.err_404, Toast.LENGTH_LONG).show(); | |
948 | 1040 | return false; |
949 | 1041 | } |
950 | 1042 | index_of = -1; |
@@ -1000,7 +1092,7 @@ public class UnnetBrowserActivity extends Activity { | ||
1000 | 1092 | } |
1001 | 1093 | } |
1002 | 1094 | } |
1003 | - public void loadFiles(boolean load){ | |
1095 | + public static void loadFiles(boolean load, final Context c, final FragmentManager fm){ | |
1004 | 1096 | Log.d(TAG, "loadFiles"); |
1005 | 1097 | if (htmls != null){ |
1006 | 1098 | if (pnom > newidx){ |
@@ -1009,42 +1101,27 @@ public class UnnetBrowserActivity extends Activity { | ||
1009 | 1101 | if (load){ |
1010 | 1102 | webview.loadUrl("file://" + dir_s + "/" + htmls[pnom]); |
1011 | 1103 | } |
1012 | - if (hide_title){ | |
1013 | - echoPos(); | |
1014 | - } | |
1015 | 1104 | // changeTitle(); |
1016 | 1105 | button1.setOnClickListener(new OnClickListener(){ |
1017 | 1106 | public void onClick(View v){ |
1018 | - goPrev(); | |
1107 | + goPrev(c); | |
1019 | 1108 | } |
1020 | 1109 | }); |
1021 | 1110 | button1.setOnLongClickListener(new OnLongClickListener(){ |
1022 | 1111 | public boolean onLongClick(View v){ |
1023 | 1112 | if (index_of > -1){ |
1024 | 1113 | pnom = index_of; |
1025 | - loadFiles(true); | |
1114 | + loadFiles(true, c, fm); | |
1026 | 1115 | return true; |
1027 | 1116 | } else { |
1028 | - echoIndex(); | |
1117 | + echoIndex(c, fm); | |
1029 | 1118 | return true; |
1030 | 1119 | } |
1031 | 1120 | } |
1032 | 1121 | }); |
1033 | -// button2.setOnLongClickListener(new OnLongClickListener(){ | |
1034 | -// public boolean onLongClick(View v){ | |
1035 | -// shiftDown(); | |
1036 | -// return true; | |
1037 | -// } | |
1038 | -// }); | |
1039 | -// button3.setOnLongClickListener(new OnLongClickListener(){ | |
1040 | -// public boolean onLongClick(View v){ | |
1041 | -// shiftUp(); | |
1042 | -// return true; | |
1043 | -// } | |
1044 | -// }); | |
1045 | 1122 | button4.setOnClickListener(new OnClickListener(){ |
1046 | 1123 | public void onClick(View v){ |
1047 | - goNext(); | |
1124 | + goNext(c); | |
1048 | 1125 | } |
1049 | 1126 | }); |
1050 | 1127 | button4.setOnLongClickListener(new OnLongClickListener(){ |
@@ -1060,32 +1137,25 @@ public class UnnetBrowserActivity extends Activity { | ||
1060 | 1137 | }); |
1061 | 1138 | } |
1062 | 1139 | } |
1063 | - public void goPrev(){ | |
1140 | + public static void goPrev(Context c){ | |
1064 | 1141 | if (pnom > 0){ |
1065 | 1142 | pnom = pnom - 1; |
1066 | 1143 | webview.loadUrl("file://" + dir_s + "/" + htmls[pnom]); |
1067 | - if (hide_title){ | |
1068 | - echoPos(); | |
1069 | - } | |
1070 | 1144 | // changeTitle(); |
1071 | 1145 | } |
1072 | 1146 | } |
1073 | - public void goNext(){ | |
1147 | + public static void goNext(Context c){ | |
1074 | 1148 | if (pnom < newidx-1){ |
1075 | 1149 | pnom = pnom + 1; |
1076 | 1150 | webview.loadUrl("file://" + dir_s + "/" + htmls[pnom]); |
1077 | - if (hide_title){ | |
1078 | - echoPos(); | |
1079 | - } | |
1080 | 1151 | // changeTitle(); |
1081 | 1152 | } |
1082 | 1153 | } |
1083 | - public void echoPos(){ | |
1154 | + public static void echoPos(Context c){ | |
1084 | 1155 | int pnom_s = pnom + 1; |
1085 | 1156 | int newidx_s = newidx; |
1086 | - Toast tst = Toast.makeText(this, pnom_s + "/" + newidx_s, Toast.LENGTH_SHORT); | |
1157 | + Toast tst = Toast.makeText(c, pnom_s + "/" + newidx_s, Toast.LENGTH_SHORT); | |
1087 | 1158 | tst.setGravity(Gravity.BOTTOM, 0, 0); |
1088 | - tst.cancel(); | |
1089 | 1159 | tst.show(); |
1090 | 1160 | } |
1091 | 1161 | public void changeTitle(){ |
@@ -1096,8 +1166,17 @@ public class UnnetBrowserActivity extends Activity { | ||
1096 | 1166 | name = webview.getUrl(); |
1097 | 1167 | } |
1098 | 1168 | // String title = pnom_s + "/" + newidx_s + " " + htmls[pnom]; |
1099 | - String title = pnom_s + "/" + newidx_s + " " + name + " - " + getString(R.string.app_name); | |
1100 | - this.setTitle(title); | |
1169 | + String main = pnom_s + "/" + newidx_s; | |
1170 | + String sub = name; | |
1171 | + String title = main + " " + sub + " - " + getString(R.string.app_name); | |
1172 | + if (Build.VERSION.SDK_INT >= 11){ | |
1173 | + forHoneycomb.setTitle(this, main, sub); | |
1174 | + } else { | |
1175 | + this.setTitle(title); | |
1176 | + } | |
1177 | + if (hide_title){ | |
1178 | + echoPos(getApplication()); | |
1179 | + } | |
1101 | 1180 | } |
1102 | 1181 | @Override |
1103 | 1182 | protected void onActivityResult(int requestCode, int resultCode, Intent data){ |
@@ -1137,7 +1216,7 @@ public class UnnetBrowserActivity extends Activity { | ||
1137 | 1216 | asis = exDir(); |
1138 | 1217 | } |
1139 | 1218 | if (newidx > 0){ |
1140 | - loadFiles(will_load); | |
1219 | + loadFiles(will_load, getApplication(), getSupportFragmentManager()); | |
1141 | 1220 | will_load = true; |
1142 | 1221 | } |
1143 | 1222 | } else if (typem.matches()){ |
@@ -1152,7 +1231,7 @@ public class UnnetBrowserActivity extends Activity { | ||
1152 | 1231 | dir_s = cdir; |
1153 | 1232 | if (exDir()){ |
1154 | 1233 | pnom = curIndex(cfil); |
1155 | - loadFiles(true); | |
1234 | + loadFiles(true, getApplication(), getSupportFragmentManager()); | |
1156 | 1235 | } |
1157 | 1236 | } else { |
1158 | 1237 | dir_s = dir_prev; |
@@ -1184,7 +1263,7 @@ public class UnnetBrowserActivity extends Activity { | ||
1184 | 1263 | try{ |
1185 | 1264 | startActivity(intnt); |
1186 | 1265 | } catch (ActivityNotFoundException e){ |
1187 | - Toast.makeText(this, R.string.err_500, Toast.LENGTH_LONG).show(); | |
1266 | + Toast.makeText(getApplication(), R.string.err_500, Toast.LENGTH_LONG).show(); | |
1188 | 1267 | } |
1189 | 1268 | |
1190 | 1269 | } |
@@ -1192,21 +1271,24 @@ public class UnnetBrowserActivity extends Activity { | ||
1192 | 1271 | SharedPreferences shrdprfs = PreferenceManager.getDefaultSharedPreferences(this); |
1193 | 1272 | // hide_buttons = shrdprfs.getBoolean("hide_buttons", false); |
1194 | 1273 | if (mode == 0){ |
1195 | - if (hide_buttons){ | |
1196 | - hideButtons(); | |
1197 | - } else if(!hide_buttons) { | |
1198 | - showButtons(); | |
1199 | - } | |
1200 | - if (mode_find){ | |
1201 | - showFinder(); | |
1202 | - } else { | |
1203 | - hideFinder(); | |
1204 | - } | |
1205 | - if (full_screen){ | |
1206 | - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
1207 | - } else { | |
1208 | - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
1209 | - } | |
1274 | + if (Build.VERSION.SDK_INT >= 11 && hide_title){ | |
1275 | + hide_buttons = false; | |
1276 | + showButtons(); | |
1277 | + } else if (hide_buttons){ | |
1278 | + hideButtons(); | |
1279 | + } else if(!hide_buttons) { | |
1280 | + showButtons(); | |
1281 | + } | |
1282 | + if (mode_find){ | |
1283 | + showFinder(); | |
1284 | + } else { | |
1285 | + hideFinder(); | |
1286 | + } | |
1287 | + if (full_screen){ | |
1288 | + getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
1289 | + } else { | |
1290 | + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
1291 | + } | |
1210 | 1292 | } |
1211 | 1293 | WebSettings wbsttngs = webview.getSettings(); |
1212 | 1294 | wbsttngs.setSaveFormData(false); |
@@ -1223,24 +1305,45 @@ public class UnnetBrowserActivity extends Activity { | ||
1223 | 1305 | del_cache = shrdprfs.getBoolean("del_cache", true); |
1224 | 1306 | if (mode == 1){ |
1225 | 1307 | hide_title = shrdprfs.getBoolean("hide_title", false); |
1226 | - if (hide_title != hide_title_p && shrdprfs.getBoolean("after_restart", false)){ | |
1227 | - Toast.makeText(this, R.string.info_restart, Toast.LENGTH_SHORT).show(); | |
1228 | - restartActivity(); | |
1229 | - } | |
1308 | + if (hide_title != hide_title_default && Build.VERSION.SDK_INT >= 11){ | |
1309 | + if (hide_title){ | |
1310 | + forHoneycomb.hideActionBar(this); | |
1311 | + hide_buttons = false; | |
1312 | + showButtons(); | |
1313 | + toUpdateOptionsMenu(); | |
1314 | + } | |
1315 | + else if (!hide_title) forHoneycomb.showActionBar(this); | |
1316 | + } | |
1317 | + if (hide_title != hide_title_default && shrdprfs.getBoolean("after_restart", false)){ | |
1318 | + Toast.makeText(getApplication(), R.string.info_restart, Toast.LENGTH_SHORT).show(); | |
1319 | + restartActivity(); | |
1320 | + } | |
1230 | 1321 | } |
1231 | 1322 | |
1232 | 1323 | } |
1233 | 1324 | public void setTitlebar(){ |
1234 | 1325 | SharedPreferences shrdprfs = PreferenceManager.getDefaultSharedPreferences(this); |
1235 | 1326 | hide_title = shrdprfs.getBoolean("hide_title", false); |
1236 | - if (hide_title){ | |
1237 | - requestWindowFeature(Window.FEATURE_NO_TITLE); | |
1238 | - } | |
1239 | - | |
1327 | + hide_title_default = hide_title; | |
1328 | + if (Build.VERSION.SDK_INT >= 11){ | |
1329 | + if (hide_title){ | |
1330 | + getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); | |
1331 | + } | |
1332 | + forHoneycomb.setActionBarBackground(this, R.drawable.bg_actionbar); | |
1333 | + forHoneycomb.setActionBar(this, hide_title); | |
1334 | + } else { | |
1335 | + if (hide_title){ | |
1336 | + requestWindowFeature(Window.FEATURE_NO_TITLE); | |
1337 | + } | |
1338 | + Window wndw = getWindow(); | |
1339 | +// wndw.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); | |
1340 | + requestWindowFeature(Window.FEATURE_LEFT_ICON); | |
1341 | + wndw.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_launcher); | |
1342 | + } | |
1240 | 1343 | } |
1241 | 1344 | public void restartActivity(){ |
1242 | 1345 | Intent intent = getIntent(); |
1243 | - intent.setClass(this, this.getClass()); | |
1346 | + intent.setClass(getApplication(), this.getClass()); | |
1244 | 1347 | finish(); |
1245 | 1348 | this.startActivity(intent); |
1246 | 1349 | } |
@@ -1248,13 +1351,21 @@ public class UnnetBrowserActivity extends Activity { | ||
1248 | 1351 | button1.setVisibility(View.VISIBLE); |
1249 | 1352 | button2.setVisibility(View.VISIBLE); |
1250 | 1353 | button3.setVisibility(View.VISIBLE); |
1251 | - button4.setVisibility(View.VISIBLE); | |
1354 | + button4.setVisibility(View.VISIBLE); | |
1355 | + if (Build.VERSION.SDK_INT >= 11 && omenu != null){ | |
1356 | + variMenu(omenu); | |
1357 | + toUpdateOptionsMenu(); | |
1358 | + } | |
1252 | 1359 | } |
1253 | 1360 | public void hideButtons(){ |
1254 | 1361 | button1.setVisibility(View.GONE); |
1255 | 1362 | button2.setVisibility(View.GONE); |
1256 | 1363 | button3.setVisibility(View.GONE); |
1257 | 1364 | button4.setVisibility(View.GONE); |
1365 | + if (Build.VERSION.SDK_INT >= 11 && omenu != null){ | |
1366 | + variMenu(omenu); | |
1367 | + toUpdateOptionsMenu(); | |
1368 | + } | |
1258 | 1369 | } |
1259 | 1370 | public void showFinder(){ |
1260 | 1371 | edittext1.setVisibility(View.VISIBLE); |
@@ -0,0 +1,62 @@ | ||
1 | +package org.pulpdust.unnetbrowser; | |
2 | + | |
3 | +import android.annotation.TargetApi; | |
4 | +import android.app.ActionBar; | |
5 | +import android.app.Activity; | |
6 | +import android.view.Menu; | |
7 | +import android.view.MenuItem; | |
8 | + | |
9 | +@TargetApi(11) | |
10 | +public class forHoneycomb { | |
11 | + public static void setActionBar(Activity av, boolean hide){ | |
12 | + ActionBar ab = av.getActionBar(); | |
13 | + if (hide){ | |
14 | + ab.hide(); | |
15 | + } else { | |
16 | + ab.show(); | |
17 | + } | |
18 | + } | |
19 | + public static void setActionBarBackground(Activity av, int resource){ | |
20 | + ActionBar ab = av.getActionBar(); | |
21 | + ab.setBackgroundDrawable(av.getResources().getDrawable(resource)); | |
22 | + } | |
23 | + public static void showActionBar(Activity av){ | |
24 | + ActionBar ab = av.getActionBar(); | |
25 | + ab.show(); | |
26 | + } | |
27 | + public static void hideActionBar(Activity av){ | |
28 | + ActionBar ab = av.getActionBar(); | |
29 | + ab.hide(); | |
30 | + } | |
31 | + public static void setTitle(Activity av, CharSequence title, CharSequence subtitle){ | |
32 | + ActionBar ab = av.getActionBar(); | |
33 | + ab.setTitle(title); | |
34 | + ab.setSubtitle(subtitle); | |
35 | + } | |
36 | + public static void prepareOptionsMenu(Menu m, int variation){ | |
37 | + MenuItem mip = (MenuItem) m.findItem(UnnetBrowserActivity.MENU_PRV); | |
38 | + MenuItem min = (MenuItem) m.findItem(UnnetBrowserActivity.MENU_NXT); | |
39 | + MenuItem mit = (MenuItem) m.findItem(UnnetBrowserActivity.MENU_TOP); | |
40 | + MenuItem mib = (MenuItem) m.findItem(UnnetBrowserActivity.MENU_BTM); | |
41 | + if (variation == 0){ | |
42 | + mip.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); | |
43 | + min.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); | |
44 | + mit.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); | |
45 | + mib.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); | |
46 | + } else if (variation == 1){ | |
47 | + mip.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); | |
48 | + min.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); | |
49 | + mit.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); | |
50 | + mib.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); | |
51 | + } else if (variation == 2){ | |
52 | + mip.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); | |
53 | + min.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); | |
54 | + mit.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); | |
55 | + mib.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); | |
56 | + } | |
57 | + } | |
58 | + public static void updateOptionsMenu(Activity av){ | |
59 | + av.invalidateOptionsMenu(); | |
60 | + } | |
61 | + | |
62 | +} |