Browse Source

3.0.0 Sync for old version

master
Anthony Restaino 11 years ago
parent
commit
0f12931ff3
  1. 27
      AndroidManifest.xml
  2. BIN
      ic_launcher.png
  3. BIN
      ic_launcher_small.png
  4. BIN
      res/drawable-hdpi/ic_action_refresh.png
  5. BIN
      res/drawable-hdpi/ic_launcher.png
  6. BIN
      res/drawable-mdpi/ic_action_refresh.png
  7. BIN
      res/drawable-mdpi/ic_launcher.png
  8. BIN
      res/drawable-xhdpi/ic_action_refresh.png
  9. BIN
      res/drawable-xhdpi/ic_launcher.png
  10. BIN
      res/drawable-xxhdpi/ic_launcher.png
  11. BIN
      res/drawable-xxxhdpi/ic_launcher.png
  12. 2
      res/layout/activity_main.xml
  13. 6
      res/menu/incognito_menu.xml
  14. 12
      res/menu/menu.xml
  15. 113
      res/values-ar/strings.xml
  16. 2
      res/values-es/strings.xml
  17. 2
      res/values-tr/strings.xml
  18. 80
      res/values-zh-rCN/strings.xml
  19. 94
      res/values/strings.xml
  20. 28
      src/acr/browser/barebones/activities/AdvancedSettingsActivity.java
  21. 133
      src/acr/browser/barebones/activities/BrowserActivity.java
  22. 125
      src/acr/browser/barebones/activities/IncognitoModeActivity.java
  23. 185
      src/acr/browser/barebones/activities/SettingsActivity.java
  24. 2
      src/acr/browser/barebones/utilities/Utils.java
  25. 15
      src/acr/browser/barebones/webviewclasses/CustomDownloadListener.java

27
AndroidManifest.xml

@ -1,21 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acr.browser.barebones" package="acr.browser.barebones"
android:versionCode="60" android:versionCode="66"
android:versionName="2.5.1.4" > android:versionName="3.0.0" >
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"
android:targetSdkVersion="18" /> android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" /> <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" /> <uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" />
<uses-feature android:name="android.hardware.location.gps" android:required="false"/>
<uses-feature android:name="android.hardware.location" android:required="false"/> <uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -51,6 +59,11 @@
<!-- <!--
For these schemes where any of these particular MIME types For these schemes where any of these particular MIME types
have been supplied, we are a good candidate. have been supplied, we are a good candidate.
--> -->
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
@ -114,7 +127,7 @@
<activity <activity
android:name=".activities.AdvancedSettingsActivity" android:name=".activities.AdvancedSettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_activity_advanced_settings" > android:label="@string/advanced" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.ADVANCED_SETTINGS" /> <action android:name="android.intent.action.ADVANCED_SETTINGS" />

BIN
ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 59 KiB

BIN
ic_launcher_small.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
res/drawable-hdpi/ic_action_refresh.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
res/drawable-hdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
res/drawable-mdpi/ic_action_refresh.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

BIN
res/drawable-mdpi/ic_launcher.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
res/drawable-xhdpi/ic_action_refresh.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
res/drawable-xhdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
res/drawable-xxhdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
res/drawable-xxxhdpi/ic_launcher.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

2
res/layout/activity_main.xml

@ -9,7 +9,7 @@
android:id="@+id/urlBar" android:id="@+id/urlBar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
> >

6
res/menu/incognito_menu.xml

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/history" android:title="@string/menu_history" android:titleCondensed="@string/menu_history" android:orderInCategory="1"></item> <item android:id="@+id/history" android:title="@string/action_history" android:titleCondensed="@string/action_history" android:orderInCategory="1"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="@string/menu_bookmarks" android:title="@string/menu_bookmarks" android:orderInCategory="3"></item> <item android:id="@+id/allBookmarks" android:titleCondensed="@string/action_bookmarks" android:title="@string/action_bookmarks" android:orderInCategory="3"></item>
<item android:id="@+id/incognito" android:title="@string/menu_new_tab" android:orderInCategory="5" android:titleCondensed="@string/menu_new_tab"></item> <item android:id="@+id/incognito" android:title="@string/action_new_tab" android:orderInCategory="5" android:titleCondensed="@string/action_new_tab"></item>
</menu> </menu>

12
res/menu/menu.xml

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/history" android:title="@string/menu_history" android:titleCondensed="@string/menu_history" android:orderInCategory="1"></item> <item android:id="@+id/history" android:title="@string/action_history" android:titleCondensed="@string/action_history" android:orderInCategory="1"></item>
<item android:id="@+id/bookmark" android:title="@string/menu_add" android:titleCondensed="@string/menu_add" android:orderInCategory="2"></item> <item android:id="@+id/bookmark" android:title="@string/action_add_bookmark" android:titleCondensed="@string/action_add_bookmark" android:orderInCategory="2"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="@string/menu_bookmarks" android:title="@string/menu_bookmarks" android:orderInCategory="3"></item> <item android:id="@+id/allBookmarks" android:titleCondensed="@string/action_bookmarks" android:title="@string/action_bookmarks" android:orderInCategory="3"></item>
<item android:id="@+id/share" android:title="@string/menu_share" android:titleCondensed="@string/menu_share" android:orderInCategory="4"></item> <item android:id="@+id/share" android:title="@string/action_share" android:titleCondensed="@string/action_share" android:orderInCategory="4"></item>
<item android:id="@+id/settings" android:title="@string/menu_settings" android:titleCondensed="@string/menu_settings" android:orderInCategory="6"></item> <item android:id="@+id/settings" android:title="@string/action_settings" android:titleCondensed="@string/action_settings" android:orderInCategory="6"></item>
<item android:id="@+id/incognito" android:title="@string/menu_incognito" android:orderInCategory="5" android:titleCondensed="@string/menu_incognito"></item> <item android:id="@+id/incognito" android:title="@string/action_incognito" android:orderInCategory="5" android:titleCondensed="@string/action_incognito"></item>
</menu> </menu>

113
res/values-ar/strings.xml

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="app_name">Lightning</string>
<string name="google">جوجل</string>
<string name="settings">إعدادات المتصفح</string>
<string name="location">الوصول إلى موقعك</string>
<string name="password">حفظ كلمات السر</string>
<string name="agent">وكيل المستخدم</string>
<string name="history">مسح السجل</string>
<string name="email">راسلني</string>
<string name="flash">تفعيل مشغل الفلاش</string>
<string name="mobile">عرض بشكل الجوال</string>
<string name="desk">عرض بشكل الكمبيوتر</string>
<string name="custom">عرض وكيل مستخدم مخصص</string>
<string name="home">الصفحة الرئيسية</string>
<string name="settingshelp">سوف يتم تطبيق الإعدادات فقط على علامات التبويب الجديدة</string>
<string name="fullscreen">وضع ملء الشاشة</string>
<string name="java">تفعيل الجافا</string>
<string name="saveTab">استعادة علامات التبويب المفقودة</string>
<string name="settings_title">الإعدادات</string>
<string name="download">مسار التحميلات</string>
<string name="advanced">الإعدادات المتقدمة</string>
<string name="source">رمز المصدر</string>
<string name="license">الرخصة</string>
<string name="github">github.com/anthonycr/Lightning-Browser</string>
<string name="apache"> ترخيص اباتشي 2.0</string>
<string name="title_activity_new_settings">الإعدادات الجديدة</string>
<string name="action_settings">الإعدادات</string>
<string name="version">إصدار التطبيق</string>
<string name="cache"> مسح ذاكرة التخزين المؤقتة عند الخروج</string>
<string name="reflow">تفعيل إلتفاف النص</string>
<string name="block">حظر الصور</string>
<string name="window">السماح للمواقع بالفتح في نوافذ جديدة</string>
<string name="cookies">تفعيل ملفات تعريف الارتباط</string>
<string name="importbookmarks">استيراد العلامات المرجعية من المتصفح</string>
<string name="size">حجم النص</string>
<string name="title_activity_advanced_settings">الإعدادات المتقدمة</string>
<string name="recommended">(مستحسن)</string>
<string name="weird_look">(مواقع قد تبدو غريبة)</string>
<string name="search">محرك البحث</string>
<string name="search_hint">بحث</string>
<string name="wideViewPort">استخدام إطار عرض واسع</string>
<string name="overViewMode">تحميل الصفحات في نظرة عامة</string>
<string name="restore">استعادة علامات التبويب المفقودة عند البدء</string>
<string name="menu_history">السجل</string>
<string name="menu_add">إضافة إلى العلامات المرجعية</string>
<string name="menu_bookmarks">العلامات المرجعية</string>
<string name="menu_share">مشاركة</string>
<string name="menu_settings">الإعدادات</string>
<string name="menu_incognito">علامة تبويب التخفي</string>
<string name="menu_new_tab">علامة تبويب جديدة</string>
<string name="stock_browser_unavailable">(لا يوجد مخزون في المتصفح)</string>
<string name="stock_browser_available">(دعم مخزون المتصفح )</string>
<string name="fullScreenOption">إخفاء شريط الحالة أثناء التصفح</string>
<string name="clear_cookies">مسح ملفات تعريف الارتباط</string>
<string name="gestures">تفعيل إيماءات الأمام و الخلف</string>
<string name="dialog_image">ماذا تريد أن تفعل مع هذه الصورة؟</string>
<string name="action_download">تحميل</string>
<string name="action_open">فتح</string>
<string name="dialog_link">ماذا تريد أن تفعل مع هذا الرابط؟</string>
<string name="dialog_title_share">مشاركة هذه الصفحة</string>
<string name="dialog_bookmark">ماذا تريد ان تفعل مع هذه العلامة المرجعية ؟</string>
<string name="action_delete">حذف</string>
<string name="action_blank">صفحة فارغة</string>
<string name="agent_default">الافتراضي</string>
<string name="agent_desktop">الكمبيوتر</string>
<string name="agent_mobile">الجوال</string>
<string name="agent_custom">مخصص</string>
<string name="title_search_engine">محرك البحث</string>
<string name="action_ok">حسنا</string>
<string name="dialog_download">هل ترغب في تحميل هذا الملف؟</string>
<string name="action_cancel">إلغاء</string>
<string name="title_warning">تحذير</string>
<string name="dialog_adobe_dead">عفوا, لقد أجريت جوجل بعض التغييرات , و مشغل الفلاش لم يعد يعمل على أندرويد 4.4 فما فوق.</string>
<string name="dialog_adobe_not_installed">لم يتم العثور على مشغل الفلاش يرجى تثبيته من المتجر.</string>
<string name="dialog_adobe_unsupported">مشغل الفلاش لا يدعم أندرويد 4.2 فما فوق , و عند تفعيل الفلاش سوف يتعطل المتصفح . يرجى عدم إبلاغنا بالمشاكل في حال تفعيل مشغل الفلاش.</string>
<string name="title_user_agent">وكيل المستخدم</string>
<string name="title_download_location">مسار التحميلات</string>
<string name="title_custom_homepage">صفحة رئيسية مخصصة</string>
<string name="action_webpage">صفحة ويب</string>
<string name="dialog_reflow_warning">عفوا , لقد أجريت جوجل بعض التغييرات و إلتفاف النص لم يعد يعمل على أندرويد 4.4 فما فوق.</string>
<string name="title_clear_history">مسح السجل</string>
<string name="title_clear_cookies">مسح ملفات تعريف الارتباط</string>
<string name="dialog_history">هل تريد مسح جميع سجلات التصفح ؟</string>
<string name="dialog_cookies">هل تريد مسح جميع ملفات تعريف الارتباط ؟</string>
<string name="action_yes">نعم</string>
<string name="action_no">لا</string>
<string name="title_text_size">حجم النص</string>
<string name="size_largest">ضخم</string>
<string name="size_large">كبير</string>
<string name="size_normal">عادي</string>
<string name="size_small">صغير</string>
<string name="size_smallest">ضئيل</string>
<string name="title_error">خطأ</string>
<string name="dialog_import_error">لم يتم العثور على متصفح ليتم إستيراد العلامات مرجعية .</string>
<string name="hint_title">العنوان</string>
<string name="hint_url">الرابط</string>
<string name="title_edit_bookmark">تعديل العلامة المرجعية</string>
<string name="action_edit">تعديل</string>
<string name="action_incognito">علامة تبويب التخفي</string>
<string name="action_homepage">الافتراضي</string>
<string name="drawer_open">فتح قائمة التنقل</string>
<string name="drawer_close">إغلاق قائمة التنقل</string>
<string name="action_websearch">البحث في الويب</string>
<string name="action_refresh">تحديث</string>
<string name="action_new_tab">علامة تبويب جديدة</string>
<string name="action_share">مشاركة</string>
<string name="action_history">السجل</string>
<string name="action_bookmarks">العلامات المرجعية </string>
<string name="action_add_bookmark">إضافة إلى العلامات المرجعية</string>
<string name="action_copy">نسخ الرابط</string>
<string name="action_forward">الأمام</string>
</resources>

2
res/values-es/strings.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Lightning</string> <string name="app_name">Lightning</string>
<string name="google">Google</string> <string name="google">Google</string>
<string name="settings">Ajustes del navegador</string> <string name="settings">Ajustes del navegador</string>
<string name="location">Acceder a tu ubicación</string> <string name="location">Acceder a tu ubicación</string>

2
res/values-tr/strings.xml

@ -3,7 +3,7 @@
<string name="app_name">Lightning</string> <string name="app_name">Lightning</string>
<string name="google">Google</string> <string name="google">Google</string>
<string name="settings">Tarayıcı ayarlarıstring> <string name="settings">Tarayıcı ayarlarıstring</string>
<string name="location">Konum erişimi</string> <string name="location">Konum erişimi</string>
<string name="password">Parolarınızı kaydetme</string> <string name="password">Parolarınızı kaydetme</string>
<string name="agent">Kullanıcı arayüzü</string> <string name="agent">Kullanıcı arayüzü</string>

80
res/values-zh-rCN/strings.xml

@ -1,17 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Lightning+</string>
<string name="drawer_open">打开导航抽屉</string> <string name="app_name">Lightning</string>
<string name="drawer_close">关闭导航抽屉</string>
<string name="action_websearch">网页搜索</string>
<string name="action_refresh">刷新页面</string>
<string name="action_new_tab">新建标签</string>
<string name="action_share">分享页面</string>
<string name="action_history">历史记录</string>
<string name="action_bookmarks">书签列表</string>
<string name="action_add_bookmark">添加书签</string>
<string name="action_copy">复制链接</string>
<string name="action_forward">前进</string>
<string name="google">Google</string> <string name="google">Google</string>
<string name="settings">浏览器设置</string> <string name="settings">浏览器设置</string>
<string name="location">允许站点访问地理位置</string> <string name="location">允许站点访问地理位置</string>
@ -45,6 +35,8 @@
<string name="cookies">启用 Cookies</string> <string name="cookies">启用 Cookies</string>
<string name="importbookmarks">从浏览器中导入书签</string> <string name="importbookmarks">从浏览器中导入书签</string>
<string name="size">页面文本尺寸</string> <string name="size">页面文本尺寸</string>
<string name="title_activity_advanced_settings">AdvancedSettings</string>
<string name="hello_world">Hello world!</string>
<string name="recommended">(推荐)</string> <string name="recommended">(推荐)</string>
<string name="weird_look">(可能导致部分网页排版混乱)</string> <string name="weird_look">(可能导致部分网页排版混乱)</string>
<string name="search">搜索引擎</string> <string name="search">搜索引擎</string>
@ -52,63 +44,17 @@
<string name="wideViewPort">使用宽视图</string> <string name="wideViewPort">使用宽视图</string>
<string name="overViewMode">使用概览模式载入页面</string> <string name="overViewMode">使用概览模式载入页面</string>
<string name="restore">启动时恢复丢失页面</string> <string name="restore">启动时恢复丢失页面</string>
<string name="menu_history">历史记录</string>
<string name="menu_add">添加书签</string>
<string name="menu_bookmarks">书签列表</string>
<string name="menu_share">分享页面</string>
<string name="menu_settings">应用设置</string>
<string name="menu_incognito">隐身标签</string>
<string name="menu_new_tab">新建标签</string>
<string name="stock_browser_unavailable">(尚未检测到已支持原生浏览器)</string> <string name="stock_browser_unavailable">(尚未检测到已支持原生浏览器)</string>
<string name="stock_browser_available">(已检测到受支持的原生浏览器)</string> <string name="stock_browser_available">(已检测到受支持的原生浏览器)</string>
<string name="fullScreenOption">浏览时隐藏状态栏</string> <string name="fullScreenOption">浏览时隐藏状态栏</string>
<string name="clear_cookies">清除浏览器 Cookies</string> <string name="clear_cookies">清除浏览器 Cookies</string>
<string name="dialog_image">您希望对此图片进行什么操作?</string> <string name="gestures">启用前进后退手势控制</string>
<string name="action_download">下载</string>
<string name="action_open">打开</string>
<string name="dialog_link">您希望对此链接进行什么操作?</string>
<string name="dialog_title_share">分享此页面</string>
<string name="dialog_bookmark">What would you like to do with this bookmark?</string>
<string name="action_delete">删除</string>
<string name="action_blank">Blank Page</string>
<string name="agent_default">默认 UA</string>
<string name="agent_desktop">桌面访问</string>
<string name="agent_mobile">移动设备</string>
<string name="agent_custom">自定义 UA</string>
<string name="title_search_engine">搜索引擎</string>
<string name="action_ok">确认</string>
<string name="dialog_download">您是否需要下载此文件?</string>
<string name="action_cancel">取消</string>
<string name="title_warning">警告</string>
<string name="dialog_adobe_dead">"非常抱歉,Google 对此做了一些更改导致 Adobe Flash 无法支持 Android 4.4 以及更高版本。"</string>
<string name="dialog_adobe_not_installed">"未检测到您的设备中安装了 Adobe Flash Player,
请先安装 Adobe Flash Player 后再启用此选项。"</string>
<string name="dialog_adobe_unsupported">Adobe Flash 无法正常支持 Android 4.2 以及更高版本并且可能导致浏览器崩溃,若您启用后出现浏览器崩溃的问题请勿对此问题进行反馈。</string>
<string name="title_user_agent">User Agent</string>
<string name="title_download_location">下载目录</string>
<string name="title_custom_homepage">自定义主页</string>
<string name="action_webpage">网页</string>
<string name="dialog_reflow_warning">"非常抱歉,Google 对此做了一些更改导致文本重拍无法支持 Android 4.4 以及更高版本。"</string>
<string name="title_clear_history">清除历史记录</string>
<string name="title_clear_cookies">清除 Cookies</string>
<string name="dialog_history">您是否确认清除所有浏览器历史记录?</string>
<string name="dialog_cookies">您是否确认清除所有浏览器历史记录 Cookies?</string>
<string name="action_yes">确认</string>
<string name="action_no">取消</string>
<string name="title_text_size">文本大小</string>
<string name="size_largest">最大</string>
<string name="size_large">较大</string>
<string name="size_normal">普通</string>
<string name="size_small">较小</string>
<string name="size_smallest">最小</string>
<string name="title_error">错误</string>
<string name="dialog_import_error">暂未检测到任何可导入书签的浏览器</string>
<string name="hint_title">Title</string>
<string name="hint_url">URL</string>
<string name="title_edit_bookmark">编辑书签</string>
<string name="action_edit">编辑</string>
<string name="action_incognito">新建隐身标签</string>
<string name="hello_world">Hello world!</string>
<string name="action_homepage">默认页面</string>
<string name="action_back">返回</string>
<string name="action_find">页内搜索</string>
<string name="download_pending">正在开始下载…</string>
<string name="cannot_download">仅可下载以 \"http\" 或 \"https\" 开头的链接地址</string>
<string name="download_no_sdcard_dlg_title">未发现 SDCard</string>
<string name="download_no_sdcard_dlg_msg">为正常下载此文件需要 USB 存储设备。</string>
<string name="download_sdcard_busy_dlg_title">USB 存储不可用</string>
<string name="download_sdcard_busy_dlg_msg">USB 存储设备目前正忙,为确保正常下载此文件请在通知栏中确认关闭 USB 大容量存储。</string>
</resources> </resources>

94
res/values/strings.xml

@ -1,9 +1,36 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014 A.C.R. Development
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources> <resources>
<string name="app_name">Lightning</string> <string name="app_name">Lightning</string>
<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>
<string name="action_websearch">Web search</string>
<string name="action_refresh">Refresh</string>
<string name="action_new_tab">New Tab</string>
<string name="action_share">Share</string>
<string name="action_history">History</string>
<string name="action_bookmarks">Bookmarks</string>
<string name="action_add_bookmark">Add Bookmark</string>
<string name="action_copy">Copy Link</string>
<string name="action_forward">Forward</string>
<string name="google">Google</string> <string name="google">Google</string>
<string name="settings">Browser Settings</string> <string name="settings">Settings</string>
<string name="location">Location Access</string> <string name="location">Location Access</string>
<string name="password">Save your passwords</string> <string name="password">Save your passwords</string>
<string name="agent">User Agent</string> <string name="agent">User Agent</string>
@ -21,6 +48,7 @@
<string name="settings_title">Settings</string> <string name="settings_title">Settings</string>
<string name="download">Download Location</string> <string name="download">Download Location</string>
<string name="advanced">Advanced Settings</string> <string name="advanced">Advanced Settings</string>
<string name="gestures">Enable back and forward gestures</string>
<string name="source">Source Code</string> <string name="source">Source Code</string>
<string name="license">License</string> <string name="license">License</string>
<string name="github">github.com/anthonycr/Lightning-Browser</string> <string name="github">github.com/anthonycr/Lightning-Browser</string>
@ -35,8 +63,6 @@
<string name="cookies">Enable Cookies</string> <string name="cookies">Enable Cookies</string>
<string name="importbookmarks">Import bookmarks from Browser</string> <string name="importbookmarks">Import bookmarks from Browser</string>
<string name="size">Text size</string> <string name="size">Text size</string>
<string name="title_activity_advanced_settings">AdvancedSettings</string>
<string name="hello_world">Hello world!</string>
<string name="recommended">(Recommended)</string> <string name="recommended">(Recommended)</string>
<string name="weird_look">(Websites may look weird)</string> <string name="weird_look">(Websites may look weird)</string>
<string name="search">Search Engine</string> <string name="search">Search Engine</string>
@ -44,17 +70,63 @@
<string name="wideViewPort">Use wide viewport</string> <string name="wideViewPort">Use wide viewport</string>
<string name="overViewMode">Load pages in overview mode</string> <string name="overViewMode">Load pages in overview mode</string>
<string name="restore">Restore lost tabs on start</string> <string name="restore">Restore lost tabs on start</string>
<string name="menu_history">History</string>
<string name="menu_add">Add bookmark</string>
<string name="menu_bookmarks">Bookmarks</string>
<string name="menu_share">Share</string>
<string name="menu_settings">Settings</string>
<string name="menu_incognito">Incognito tab</string>
<string name="menu_new_tab">New tab</string>
<string name="stock_browser_unavailable">(No stock browser detected)</string> <string name="stock_browser_unavailable">(No stock browser detected)</string>
<string name="stock_browser_available">(Supported stock browser detected)</string> <string name="stock_browser_available">(Supported stock browser detected)</string>
<string name="fullScreenOption">Hide status bar while browsing</string> <string name="fullScreenOption">Hide status bar while browsing</string>
<string name="clear_cookies">Clear browser cookies</string> <string name="clear_cookies">Clear browser cookies</string>
<string name="gestures">Enable back and foward gestures</string> <string name="dialog_image">What would you like to do with this image?</string>
<string name="action_download">Download</string>
<string name="action_open">Open</string>
<string name="dialog_link">What would you like to do with this link?</string>
<string name="dialog_title_share">Share this page</string>
<string name="dialog_bookmark">What would you like to do with this bookmark?</string>
<string name="action_delete">Delete</string>
<string name="action_blank">Blank Page</string>
<string name="agent_default">Default</string>
<string name="agent_desktop">Desktop</string>
<string name="agent_mobile">Mobile</string>
<string name="agent_custom">Custom</string>
<string name="title_search_engine">Search Engine</string>
<string name="action_ok">OK</string>
<string name="dialog_download">Do you want to download this file?</string>
<string name="action_cancel">Cancel</string>
<string name="title_warning">Warning</string>
<string name="dialog_adobe_dead">We\'re sorry, Google made some changes, and Adobe Flash no longer works on Android 4.4+</string>
<string name="dialog_adobe_not_installed">Adobe Flash Player was not detected.\nPlease install Flash Player.</string>
<string name="dialog_adobe_unsupported">Adobe Flash does not support Andoid 4.2 and above, and will crash the browser. Please do not report any crashes that occur if you enable Flash.</string>
<string name="title_user_agent">User Agent</string>
<string name="title_download_location">Download Location</string>
<string name="title_custom_homepage">Custom Homepage</string>
<string name="action_webpage">Webpage</string>
<string name="dialog_reflow_warning">We\'re sorry, Google made some changes, and Text Reflow no longer works on Android 4.4+</string>
<string name="title_clear_history">Clear History</string>
<string name="title_clear_cookies">Clear Cookies</string>
<string name="dialog_history">Would you like to clear all browser history?</string>
<string name="dialog_cookies">Would you like to clear all browser cookies?</string>
<string name="action_yes">Yes</string>
<string name="action_no">No</string>
<string name="title_text_size">Text Size</string>
<string name="size_largest">Largest</string>
<string name="size_large">Large</string>
<string name="size_normal">Normal</string>
<string name="size_small">Small</string>
<string name="size_smallest">Smallest</string>
<string name="title_error">Error</string>
<string name="dialog_import_error">No browser was detected to import bookmarks from.</string>
<string name="hint_title">Title</string>
<string name="hint_url">URL</string>
<string name="title_edit_bookmark">Edit Bookmark</string>
<string name="action_edit">Edit</string>
<string name="action_incognito">New Incognito Tab</string>
<string name="hello_world">Hello world!</string>
<string name="action_homepage">Default</string>
<string name="action_back">Back</string>
<string name="action_find">Find in Page</string>
<string name="download_pending">Starting download\u2026</string>
<string name="cannot_download">Can only download \"http\" or \"https\" URLs.</string>
<string name="download_no_sdcard_dlg_title" >No SD card</string>
<string name="download_no_sdcard_dlg_msg" >USB storage is required to download the file.</string>
<string name="download_sdcard_busy_dlg_title">USB storage unavailable</string>
<string name="download_sdcard_busy_dlg_msg" >The storage is busy. To allow downloads, touch Turn Off USB Storage in the notification.</string>
</resources> </resources>

28
src/acr/browser/barebones/activities/AdvancedSettingsActivity.java

@ -422,10 +422,10 @@ public class AdvancedSettingsActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(
AdvancedSettingsActivity.this); // dialog AdvancedSettingsActivity.this); // dialog
builder.setTitle("Clear History"); builder.setTitle(CONTEXT.getResources().getString(R.string.title_clear_history));
builder.setMessage( builder.setMessage(
"Would you like to clear all browser history?") CONTEXT.getResources().getString(R.string.dialog_history))
.setPositiveButton("Yes", .setPositiveButton(CONTEXT.getResources().getString(R.string.action_yes),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -444,7 +444,7 @@ public class AdvancedSettingsActivity extends Activity {
} }
}) })
.setNegativeButton("No", .setNegativeButton(CONTEXT.getResources().getString(R.string.action_no),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -513,10 +513,10 @@ public class AdvancedSettingsActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(
AdvancedSettingsActivity.this); // dialog AdvancedSettingsActivity.this); // dialog
builder.setTitle("Clear Cookies"); builder.setTitle(CONTEXT.getResources().getString(R.string.title_clear_cookies));
builder.setMessage( builder.setMessage(
"Would you like to clear all browser cookies?") CONTEXT.getResources().getString(R.string.dialog_cookies))
.setPositiveButton("Yes", .setPositiveButton(CONTEXT.getResources().getString(R.string.action_yes),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -535,7 +535,7 @@ public class AdvancedSettingsActivity extends Activity {
} }
}) })
.setNegativeButton("No", .setNegativeButton(CONTEXT.getResources().getString(R.string.action_no),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -612,8 +612,14 @@ public class AdvancedSettingsActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder picker = new AlertDialog.Builder( AlertDialog.Builder picker = new AlertDialog.Builder(
AdvancedSettingsActivity.this); AdvancedSettingsActivity.this);
picker.setTitle("Text Size"); picker.setTitle(getResources().getString(
CharSequence[] chars = { "Largest", "Large", "Normal", "Small", "Smallest"}; R.string.title_text_size));
CharSequence[] chars = {
getResources().getString(R.string.size_largest),
getResources().getString(R.string.size_large),
getResources().getString(R.string.size_normal),
getResources().getString(R.string.size_small),
getResources().getString(R.string.size_smallest) };
int n = settings.getInt("textsize", 3); int n = settings.getInt("textsize", 3);
@ -628,7 +634,7 @@ public class AdvancedSettingsActivity extends Activity {
} }
}); });
picker.setNeutralButton("OK", picker.setNeutralButton(CONTEXT.getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override

133
src/acr/browser/barebones/activities/BrowserActivity.java

@ -168,7 +168,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
public static boolean DEVICE_HAS_GPS = false; public static boolean DEVICE_HAS_GPS = false;
// semi constants // semi constants
public static Context CONTEXT; public static Context mContext;
public static String SEARCH; public static String SEARCH;
public static List<Integer> tabList; public static List<Integer> tabList;
@ -250,8 +250,8 @@ public class BrowserActivity extends Activity implements OnTouchListener {
currentTabTitle.setPadding(leftPad, 0, rightPad, 0); currentTabTitle.setPadding(leftPad, 0, rightPad, 0);
} }
} }
final TextView title = new TextView(CONTEXT); final TextView title = new TextView(mContext);
title.setText("New Tab"); title.setText(mContext.getResources().getString(R.string.action_new_tab));
if (display) { if (display) {
if (API < 16) { if (API < 16) {
title.setBackgroundDrawable(active); title.setBackgroundDrawable(active);
@ -278,7 +278,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
Drawable[] drawables = title.getCompoundDrawables(); Drawable[] drawables = title.getCompoundDrawables();
bounds = drawables[2].getBounds(); bounds = drawables[2].getBounds();
title.setOnTouchListener(ACTIVITY); title.setOnTouchListener(ACTIVITY);
Animation holo = AnimationUtils.loadAnimation(CONTEXT, R.anim.up); Animation holo = AnimationUtils.loadAnimation(mContext, R.anim.up);
tabLayout.addView(title); tabLayout.addView(title);
title.setVisibility(View.INVISIBLE); title.setVisibility(View.INVISIBLE);
holo.setAnimationListener(new AnimationListener() { holo.setAnimationListener(new AnimationListener() {
@ -300,7 +300,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
title.startAnimation(holo); title.startAnimation(holo);
urlTitle[id] = title; urlTitle[id] = title;
urlTitle[id].setText("New Tab"); urlTitle[id].setText(mContext.getResources().getString(R.string.action_new_tab));
if (theUrl != null) { if (theUrl != null) {
main[id] = generateTab(id, theUrl, display); main[id] = generateTab(id, theUrl, display);
@ -309,14 +309,14 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
} else { } else {
Utils.showToast(CONTEXT, "Max number of tabs reached"); Utils.showToast(mContext, "Max number of tabs reached");
} }
return id; return id;
} }
public static void deleteBookmark(String url) { public static void deleteBookmark(String url) {
File book = new File(CONTEXT.getFilesDir(), "bookmarks"); File book = new File(mContext.getFilesDir(), "bookmarks");
File bookUrl = new File(CONTEXT.getFilesDir(), "bookurl"); File bookUrl = new File(mContext.getFilesDir(), "bookurl");
int n = 0; int n = 0;
try { try {
BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book)); BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book));
@ -355,7 +355,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
readUrl.close(); readUrl.close();
} catch (IOException ignored) { } catch (IOException ignored) {
} }
openBookmarks(CONTEXT, currentTab); openBookmarks(mContext, currentTab);
} }
public static void generateHistory(final CustomWebView view, public static void generateHistory(final CustomWebView view,
@ -425,7 +425,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
e.printStackTrace(); e.printStackTrace();
} }
if (uBar.isShown()) { if (uBar.isShown()) {
currentTabTitle.setText("History"); currentTabTitle.setText(mContext.getResources().getString(R.string.menu_history));
setUrlText(""); setUrlText("");
getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setPadding(tenPad, 0, tenPad, 0);
} }
@ -439,7 +439,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
public static CustomWebView generateTab(final int pageToView, String Url, public static CustomWebView generateTab(final int pageToView, String Url,
final boolean display) { final boolean display) {
CustomWebView view = new CustomWebView(CONTEXT); CustomWebView view = new CustomWebView(mContext);
view.setId(pageToView); view.setId(pageToView);
view.setWebViewClient(new CustomWebViewClient(ACTIVITY)); view.setWebViewClient(new CustomWebViewClient(ACTIVITY));
view.setWebChromeClient(new CustomChromeClient(ACTIVITY)); view.setWebChromeClient(new CustomChromeClient(ACTIVITY));
@ -459,7 +459,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
uBar.bringToFront(); uBar.bringToFront();
if (Url.contains("about:home")) { if (Url.contains("about:home")) {
goBookmarks(CONTEXT, view); goBookmarks(mContext, view);
} else if (Url.contains("about:blank")) { } else if (Url.contains("about:blank")) {
view.loadUrl(""); view.loadUrl("");
} else { } else {
@ -477,15 +477,15 @@ public class BrowserActivity extends Activity implements OnTouchListener {
if (view.isShown() && view.canGoBack() && gestures) { if (view.isShown() && view.canGoBack() && gestures) {
view.goBack(); view.goBack();
} }
Animation left = AnimationUtils.loadAnimation(CONTEXT, R.anim.left); Animation left = AnimationUtils.loadAnimation(mContext, R.anim.left);
background.startAnimation(left); background.startAnimation(left);
} }
static List<Map<String, String>> getBookmarks() { static List<Map<String, String>> getBookmarks() {
List<Map<String, String>> bookmarks = new ArrayList<Map<String, String>>(); List<Map<String, String>> bookmarks = new ArrayList<Map<String, String>>();
File bookUrl = new File(CONTEXT.getFilesDir(), "bookurl"); File bookUrl = new File(mContext.getFilesDir(), "bookurl");
File book = new File(CONTEXT.getFilesDir(), "bookmarks"); File book = new File(mContext.getFilesDir(), "bookmarks");
try { try {
BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl)); BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl));
BufferedReader readBook = new BufferedReader(new FileReader(book)); BufferedReader readBook = new BufferedReader(new FileReader(book));
@ -532,7 +532,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
if (view.isShown() && view.canGoForward() && gestures) { if (view.isShown() && view.canGoForward() && gestures) {
view.goForward(); view.goForward();
} }
Animation right = AnimationUtils.loadAnimation(CONTEXT, R.anim.right); Animation right = AnimationUtils.loadAnimation(mContext, R.anim.right);
background.startAnimation(right); background.startAnimation(right);
} }
@ -560,11 +560,11 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
}; };
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); // dialog AlertDialog.Builder builder = new AlertDialog.Builder(mContext); // dialog
builder.setMessage("What would you like to do with this bookmark?") builder.setMessage(mContext.getResources().getString(R.string.dialog_bookmark))
.setPositiveButton("Rename", dialogClickListener) .setPositiveButton(mContext.getResources().getString(R.string.action_edit), dialogClickListener)
.setNegativeButton("Open", dialogClickListener) .setNegativeButton(mContext.getResources().getString(R.string.action_open), dialogClickListener)
.setNeutralButton("Delete", dialogClickListener).show(); .setNeutralButton(mContext.getResources().getString(R.string.action_delete), dialogClickListener).show();
} }
} }
@ -620,7 +620,8 @@ public class BrowserActivity extends Activity implements OnTouchListener {
FrameLayout screen = (FrameLayout) ACTIVITY.getWindow().getDecorView(); FrameLayout screen = (FrameLayout) ACTIVITY.getWindow().getDecorView();
screen.removeView(fullScreenContainer); screen.removeView(fullScreenContainer);
fullScreenContainer = null; fullScreenContainer = null;
mCustomViewCallback.onCustomViewHidden(); //mCustomViewCallback.onCustomViewHidden();
//apparently causing browser to crash when video ends
ACTIVITY.setRequestedOrientation(orientation); ACTIVITY.setRequestedOrientation(orientation);
background.addView(currentTab); background.addView(currentTab);
uBar.setVisibility(View.VISIBLE); uBar.setVisibility(View.VISIBLE);
@ -636,7 +637,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
final HitTestResult result = currentTab.getHitTestResult(); final HitTestResult result = currentTab.getHitTestResult();
if (currentTab.getUrl().contains( if (currentTab.getUrl().contains(
"file://" + CONTEXT.getFilesDir() + "/bookmarks.html")) { "file://" + mContext.getFilesDir() + "/bookmarks.html")) {
click = new Message(); click = new Message();
click.arg1 = n; click.arg1 = n;
click.setTarget(new ClickHandler()); click.setTarget(new ClickHandler());
@ -667,7 +668,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
if (API > 8) { if (API > 8) {
String url = result.getExtra(); String url = result.getExtra();
Utils.downloadFile(CONTEXT, url, null, null); Utils.downloadFile(mContext, url, null, null);
} }
break; break;
@ -677,14 +678,14 @@ public class BrowserActivity extends Activity implements OnTouchListener {
}; };
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(
CONTEXT); // dialog mContext); // dialog
builder.setMessage( builder.setMessage(
"What would you like to do with this image?") mContext.getResources().getString(R.string.dialog_image))
.setPositiveButton("Open in New Tab", .setPositiveButton(mContext.getResources().getString(R.string.action_new_tab),
dialogClickListener) dialogClickListener)
.setNegativeButton("Open Normally", .setNegativeButton(mContext.getResources().getString(R.string.action_open),
dialogClickListener) dialogClickListener)
.setNeutralButton("Download Image", .setNeutralButton(mContext.getResources().getString(R.string.action_download),
dialogClickListener).show(); dialogClickListener).show();
} else { } else {
@ -723,15 +724,15 @@ public class BrowserActivity extends Activity implements OnTouchListener {
}; };
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(
CONTEXT); // dialog mContext); // dialog
builder.setTitle(result.getExtra()) builder.setTitle(result.getExtra())
.setMessage( .setMessage(
"What do you want to do with this link?") mContext.getResources().getString(R.string.dialog_link))
.setPositiveButton("Open in New Tab", .setPositiveButton(mContext.getResources().getString(R.string.action_new_tab),
dialogClickListener) dialogClickListener)
.setNegativeButton("Open Normally", .setNegativeButton(mContext.getResources().getString(R.string.action_open),
dialogClickListener) dialogClickListener)
.setNeutralButton("Copy link", dialogClickListener) .setNeutralButton(mContext.getResources().getString(R.string.action_copy), dialogClickListener)
.show(); .show();
} }
} }
@ -807,7 +808,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
if (title != null && title.length() != 0) { if (title != null && title.length() != 0) {
urlTitle[numberPage].setText(title); urlTitle[numberPage].setText(title);
urlToLoad[numberPage][1] = title; urlToLoad[numberPage][1] = title;
Utils.updateHistory(CONTEXT, CONTEXT.getContentResolver(), Utils.updateHistory(mContext, mContext.getContentResolver(),
noStockBrowser, urlToLoad[numberPage][0], title); noStockBrowser, urlToLoad[numberPage][0], title);
} }
} }
@ -861,10 +862,10 @@ public class BrowserActivity extends Activity implements OnTouchListener {
public static void reinitializeSettings() { public static void reinitializeSettings() {
int size = tabList.size(); int size = tabList.size();
cookieManager = CookieManager.getInstance(); cookieManager = CookieManager.getInstance();
CookieSyncManager.createInstance(CONTEXT); CookieSyncManager.createInstance(mContext);
cookieManager.setAcceptCookie(settings.getBoolean("cookies", true)); cookieManager.setAcceptCookie(settings.getBoolean("cookies", true));
for (int n = 0; n < size; n++) { for (int n = 0; n < size; n++) {
main[tabList.get(n)].settingsInitialization(CONTEXT); main[tabList.get(n)].settingsInitialization(mContext);
} }
} }
@ -879,20 +880,20 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
} }
final AlertDialog.Builder homePicker = new AlertDialog.Builder(CONTEXT); final AlertDialog.Builder homePicker = new AlertDialog.Builder(mContext);
homePicker.setTitle("Rename Bookmark"); homePicker.setTitle(mContext.getResources().getString(R.string.title_edit_bookmark));
final EditText getText = new EditText(CONTEXT); final EditText getText = new EditText(mContext);
getText.setText(bTitle[index]); getText.setText(bTitle[index]);
homePicker.setView(getText); homePicker.setView(getText);
homePicker.setPositiveButton("OK", homePicker.setPositiveButton(mContext.getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
bTitle[index] = getText.getText().toString(); bTitle[index] = getText.getText().toString();
File book = new File(CONTEXT.getFilesDir(), "bookmarks"); File book = new File(mContext.getFilesDir(), "bookmarks");
File bookUrl = new File(CONTEXT.getFilesDir(), File bookUrl = new File(mContext.getFilesDir(),
"bookurl"); "bookurl");
int n = 0; int n = 0;
try { try {
@ -934,7 +935,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
readUrl.close(); readUrl.close();
} catch (IOException ignored) { } catch (IOException ignored) {
} }
openBookmarks(CONTEXT, currentTab); openBookmarks(mContext, currentTab);
} }
}); });
homePicker.show(); homePicker.show();
@ -1020,8 +1021,8 @@ public class BrowserActivity extends Activity implements OnTouchListener {
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
// start the chooser for sharing // start the chooser for sharing
CONTEXT.startActivity(Intent.createChooser(shareIntent, mContext.startActivity(Intent.createChooser(shareIntent,
"Share this page")); mContext.getResources().getString(R.string.dialog_title_share)));
} }
public static void toggleFullScreen() { public static void toggleFullScreen() {
@ -1140,7 +1141,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_ENTER:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
searchTheWeb(getUrl.getText().toString(), CONTEXT); searchTheWeb(getUrl.getText().toString(), mContext);
return true; return true;
default: default:
break; break;
@ -1162,7 +1163,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
|| (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) { || (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
searchTheWeb(getUrl.getText().toString(), CONTEXT); searchTheWeb(getUrl.getText().toString(), mContext);
return true; return true;
} }
return false; return false;
@ -1192,7 +1193,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
switch (msg.what) { switch (msg.what) {
case 1: { case 1: {
SimpleAdapter adapter = new SimpleAdapter(CONTEXT, list, SimpleAdapter adapter = new SimpleAdapter(mContext, list,
R.layout.two_line_autocomplete, new String[] { R.layout.two_line_autocomplete, new String[] {
"title", "url" }, new int[] { R.id.title, "title", "url" }, new int[] { R.id.title,
R.id.url }); R.id.url });
@ -1304,7 +1305,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
url = ((TextView) arg1.findViewById(R.id.url)).getText() url = ((TextView) arg1.findViewById(R.id.url)).getText()
.toString(); .toString();
getUrl.setText(url); getUrl.setText(url);
searchTheWeb(url, CONTEXT); searchTheWeb(url, mContext);
url = null; url = null;
getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setPadding(tenPad, 0, tenPad, 0);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@ -1487,7 +1488,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
getWindowManager().getDefaultDisplay().getMetrics(metrics); getWindowManager().getDefaultDisplay().getMetrics(metrics);
historyHandler = new DatabaseHandler(this); historyHandler = new DatabaseHandler(this);
cookieManager = CookieManager.getInstance(); cookieManager = CookieManager.getInstance();
CookieSyncManager.createInstance(CONTEXT); CookieSyncManager.createInstance(mContext);
cookieManager.setAcceptCookie(settings.getBoolean("cookies", true)); cookieManager.setAcceptCookie(settings.getBoolean("cookies", true));
progressBar = (ProgressBar) findViewById(R.id.progressBar1); progressBar = (ProgressBar) findViewById(R.id.progressBar1);
@ -1554,7 +1555,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
// user agent // user agent
if (API < 17) { if (API < 17) {
user = new WebView(CONTEXT).getSettings().getUserAgentString(); user = new WebView(mContext).getSettings().getUserAgentString();
} else { } else {
user = WebSettings.getDefaultUserAgent(this); user = WebSettings.getDefaultUserAgent(this);
} }
@ -1761,7 +1762,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // displays main xml layout setContentView(R.layout.activity_main); // displays main xml layout
CONTEXT = this; mContext = this;
ACTIVITY = this; ACTIVITY = this;
settings = getSharedPreferences("settings", 0); settings = getSharedPreferences("settings", 0);
edit = settings.edit(); edit = settings.edit();
@ -1778,7 +1779,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
try { try {
LocationManager locationManager = (LocationManager) CONTEXT LocationManager locationManager = (LocationManager) mContext
.getSystemService(Context.LOCATION_SERVICE); .getSystemService(Context.LOCATION_SERVICE);
if (locationManager.getAllProviders().contains( if (locationManager.getAllProviders().contains(
LocationManager.GPS_PROVIDER)) { LocationManager.GPS_PROVIDER)) {
@ -1821,7 +1822,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
+ "4. Visit settings and advanced settings to change options\n\n" + "4. Visit settings and advanced settings to change options\n\n"
+ "5. Long-press on the new tab button to open the last closed tab"; + "5. Long-press on the new tab button to open the last closed tab";
Utils.createInformativeDialog(CONTEXT, "Browser Tips", message); Utils.createInformativeDialog(mContext, "Browser Tips", message);
edit.putInt("first", 1); edit.putInt("first", 1);
edit.putInt("version", code); edit.putInt("version", code);
edit.commit(); edit.commit();
@ -1937,7 +1938,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
if (id >= 0) { if (id >= 0) {
main[id].loadUrl(url); main[id].loadUrl(url);
} else if (download == 1) { } else if (download == 1) {
Utils.downloadFile(CONTEXT, url, null, null); Utils.downloadFile(mContext, url, null, null);
} else if (url != null) { } else if (url != null) {
newTab(url, true); newTab(url, true);
} }
@ -1950,12 +1951,12 @@ public class BrowserActivity extends Activity implements OnTouchListener {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.history: case R.id.history:
generateHistory(currentTab, CONTEXT); generateHistory(currentTab, mContext);
return true; return true;
case R.id.bookmark: case R.id.bookmark:
if (urlToLoad[currentId][1] != null) { if (urlToLoad[currentId][1] != null) {
if (!urlToLoad[currentId][1].equals("Bookmarks")) { if (!urlToLoad[currentId][1].equals("Bookmarks")) {
Utils.addBookmark(CONTEXT, urlToLoad[currentId][1], Utils.addBookmark(mContext, urlToLoad[currentId][1],
urlToLoad[currentId][0]); urlToLoad[currentId][0]);
} }
} }
@ -1965,9 +1966,9 @@ public class BrowserActivity extends Activity implements OnTouchListener {
return true; return true;
case R.id.allBookmarks: case R.id.allBookmarks:
if (urlToLoad[currentId][1] == null) { if (urlToLoad[currentId][1] == null) {
goBookmarks(CONTEXT, currentTab); goBookmarks(mContext, currentTab);
} else if (!urlToLoad[currentId][1].equals("Bookmarks")) { } else if (!urlToLoad[currentId][1].equals("Bookmarks")) {
goBookmarks(CONTEXT, currentTab); goBookmarks(mContext, currentTab);
} }
return true; return true;
@ -2046,7 +2047,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
private boolean xPress; private boolean xPress;
private Rect edge; private Rect edge;
private final GestureDetector mGestureDetector = new GestureDetector( private final GestureDetector mGestureDetector = new GestureDetector(
CONTEXT, new CustomGestureListener()); mContext, new CustomGestureListener());
private class CustomGestureListener extends SimpleOnGestureListener { private class CustomGestureListener extends SimpleOnGestureListener {
@Override @Override
@ -2157,7 +2158,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
public void onClick(View v) { public void onClick(View v) {
if (API >= 11) { if (API >= 11) {
PopupMenu menu = new PopupMenu(CONTEXT, v); PopupMenu menu = new PopupMenu(mContext, v);
MenuInflater inflate = menu.getMenuInflater(); MenuInflater inflate = menu.getMenuInflater();
inflate.inflate(R.menu.menu, menu.getMenu()); inflate.inflate(R.menu.menu, menu.getMenu());
menu.setOnMenuItemClickListener(new OnMenuItemClickListener() { menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@ -2167,13 +2168,13 @@ public class BrowserActivity extends Activity implements OnTouchListener {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.history: case R.id.history:
generateHistory(currentTab, CONTEXT); generateHistory(currentTab, mContext);
return true; return true;
case R.id.bookmark: case R.id.bookmark:
if (urlToLoad[currentId][1] != null) { if (urlToLoad[currentId][1] != null) {
if (!urlToLoad[currentId][1] if (!urlToLoad[currentId][1]
.equals("Bookmarks")) { .equals("Bookmarks")) {
Utils.addBookmark(CONTEXT, Utils.addBookmark(mContext,
urlToLoad[currentId][1], urlToLoad[currentId][1],
urlToLoad[currentId][0]); urlToLoad[currentId][0]);
} }
@ -2184,10 +2185,10 @@ public class BrowserActivity extends Activity implements OnTouchListener {
return true; return true;
case R.id.allBookmarks: case R.id.allBookmarks:
if (urlToLoad[currentId][1] == null) { if (urlToLoad[currentId][1] == null) {
goBookmarks(CONTEXT, currentTab); goBookmarks(mContext, currentTab);
} else if (!urlToLoad[currentId][1] } else if (!urlToLoad[currentId][1]
.equals("Bookmarks")) { .equals("Bookmarks")) {
goBookmarks(CONTEXT, currentTab); goBookmarks(mContext, currentTab);
} }
return true; return true;
case R.id.share: case R.id.share:

125
src/acr/browser/barebones/activities/IncognitoModeActivity.java

@ -163,7 +163,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
public static final int API = FinalVariables.API; public static final int API = FinalVariables.API;
public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|"; public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|";
// semi constants // semi constants
public static Context CONTEXT; public static Context mContext;
public static String SEARCH; public static String SEARCH;
public static List<Integer> tabList; public static List<Integer> tabList;
@ -242,8 +242,8 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
currentTabTitle.setPadding(leftPad, 0, rightPad, 0); currentTabTitle.setPadding(leftPad, 0, rightPad, 0);
} }
} }
final TextView title = new TextView(CONTEXT); final TextView title = new TextView(mContext);
title.setText("New Tab"); title.setText(mContext.getResources().getString(R.string.action_new_tab));
if (display) { if (display) {
if (API < 16) { if (API < 16) {
title.setBackgroundDrawable(active); title.setBackgroundDrawable(active);
@ -270,7 +270,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
Drawable[] drawables = title.getCompoundDrawables(); Drawable[] drawables = title.getCompoundDrawables();
bounds = drawables[2].getBounds(); bounds = drawables[2].getBounds();
title.setOnTouchListener(ACTIVITY); title.setOnTouchListener(ACTIVITY);
Animation holo = AnimationUtils.loadAnimation(CONTEXT, R.anim.up); Animation holo = AnimationUtils.loadAnimation(mContext, R.anim.up);
tabLayout.addView(title); tabLayout.addView(title);
title.setVisibility(View.INVISIBLE); title.setVisibility(View.INVISIBLE);
holo.setAnimationListener(new AnimationListener() { holo.setAnimationListener(new AnimationListener() {
@ -292,7 +292,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
title.startAnimation(holo); title.startAnimation(holo);
urlTitle[id] = title; urlTitle[id] = title;
urlTitle[id].setText("New Tab"); urlTitle[id].setText(mContext.getResources().getString(R.string.action_new_tab));
if (theUrl != null) { if (theUrl != null) {
main[id] = generateTab(id, theUrl, display); main[id] = generateTab(id, theUrl, display);
@ -301,14 +301,14 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
} else { } else {
Utils.showToast(CONTEXT, "Max number of tabs reached"); Utils.showToast(mContext, "Max number of tabs reached");
} }
return id; return id;
} }
public static void deleteBookmark(String url) { public static void deleteBookmark(String url) {
File book = new File(CONTEXT.getFilesDir(), "bookmarks"); File book = new File(mContext.getFilesDir(), "bookmarks");
File bookUrl = new File(CONTEXT.getFilesDir(), "bookurl"); File bookUrl = new File(mContext.getFilesDir(), "bookurl");
int n = 0; int n = 0;
try { try {
BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book)); BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book));
@ -347,7 +347,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
readUrl.close(); readUrl.close();
} catch (IOException ignored) { } catch (IOException ignored) {
} }
openBookmarks(CONTEXT, currentTab); openBookmarks(mContext, currentTab);
} }
public static void generateHistory(final IncognitoWebView view, public static void generateHistory(final IncognitoWebView view,
@ -431,7 +431,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
public static IncognitoWebView generateTab(final int pageToView, public static IncognitoWebView generateTab(final int pageToView,
String Url, final boolean display) { String Url, final boolean display) {
IncognitoWebView view = new IncognitoWebView(CONTEXT); IncognitoWebView view = new IncognitoWebView(mContext);
view.setId(pageToView); view.setId(pageToView);
view.setWebViewClient(new IncognitoWebViewClient(ACTIVITY)); view.setWebViewClient(new IncognitoWebViewClient(ACTIVITY));
view.setWebChromeClient(new IncognitoChromeClient(ACTIVITY)); view.setWebChromeClient(new IncognitoChromeClient(ACTIVITY));
@ -451,7 +451,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
uBar.bringToFront(); uBar.bringToFront();
if (Url.contains("about:home")) { if (Url.contains("about:home")) {
goBookmarks(CONTEXT, view); goBookmarks(mContext, view);
} else if (Url.contains("about:blank")) { } else if (Url.contains("about:blank")) {
view.loadUrl(""); view.loadUrl("");
} else { } else {
@ -465,7 +465,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
if (view.isShown() && view.canGoBack()) { if (view.isShown() && view.canGoBack()) {
view.goBack(); view.goBack();
} }
Animation left = AnimationUtils.loadAnimation(CONTEXT, R.anim.left); Animation left = AnimationUtils.loadAnimation(mContext, R.anim.left);
background.startAnimation(left); background.startAnimation(left);
} }
@ -497,7 +497,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
if (view.isShown() && view.canGoForward()) { if (view.isShown() && view.canGoForward()) {
view.goForward(); view.goForward();
} }
Animation right = AnimationUtils.loadAnimation(CONTEXT, R.anim.right); Animation right = AnimationUtils.loadAnimation(mContext, R.anim.right);
background.startAnimation(right); background.startAnimation(right);
} }
@ -525,11 +525,11 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
}; };
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); // dialog AlertDialog.Builder builder = new AlertDialog.Builder(mContext); // dialog
builder.setMessage("What would you like to do with this bookmark?") builder.setMessage(mContext.getResources().getString(R.string.dialog_bookmark))
.setPositiveButton("Rename", dialogClickListener) .setPositiveButton(mContext.getResources().getString(R.string.action_edit), dialogClickListener)
.setNegativeButton("Open", dialogClickListener) .setNegativeButton(mContext.getResources().getString(R.string.action_open), dialogClickListener)
.setNeutralButton("Delete", dialogClickListener).show(); .setNeutralButton(mContext.getResources().getString(R.string.action_delete), dialogClickListener).show();
} }
} }
@ -585,7 +585,8 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
FrameLayout screen = (FrameLayout) ACTIVITY.getWindow().getDecorView(); FrameLayout screen = (FrameLayout) ACTIVITY.getWindow().getDecorView();
screen.removeView(fullScreenContainer); screen.removeView(fullScreenContainer);
fullScreenContainer = null; fullScreenContainer = null;
mCustomViewCallback.onCustomViewHidden(); //causing video crashes
//mCustomViewCallback.onCustomViewHidden();
ACTIVITY.setRequestedOrientation(orientation); ACTIVITY.setRequestedOrientation(orientation);
background.addView(currentTab); background.addView(currentTab);
uBar.setVisibility(View.VISIBLE); uBar.setVisibility(View.VISIBLE);
@ -602,7 +603,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
final HitTestResult result = currentTab.getHitTestResult(); final HitTestResult result = currentTab.getHitTestResult();
if (currentTab.getUrl().contains( if (currentTab.getUrl().contains(
"file://" + CONTEXT.getFilesDir() + "/bookmarks.html")) { "file://" + mContext.getFilesDir() + "/bookmarks.html")) {
click = new Message(); click = new Message();
click.arg1 = n; click.arg1 = n;
click.setTarget(new ClickHandler()); click.setTarget(new ClickHandler());
@ -633,7 +634,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
if (API > 8) { if (API > 8) {
String url = result.getExtra(); String url = result.getExtra();
Utils.downloadFile(CONTEXT, url, null, null); Utils.downloadFile(mContext, url, null, null);
} }
break; break;
@ -643,14 +644,14 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
}; };
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(
CONTEXT); // dialog mContext); // dialog
builder.setMessage( builder.setMessage(
"What would you like to do with this image?") mContext.getResources().getString(R.string.dialog_image))
.setPositiveButton("Open in New Tab", .setPositiveButton(mContext.getResources().getString(R.string.action_new_tab),
dialogClickListener) dialogClickListener)
.setNegativeButton("Open Normally", .setNegativeButton(mContext.getResources().getString(R.string.action_open),
dialogClickListener) dialogClickListener)
.setNeutralButton("Download Image", .setNeutralButton(mContext.getResources().getString(R.string.action_download),
dialogClickListener).show(); dialogClickListener).show();
} else { } else {
@ -689,15 +690,15 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
}; };
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(
CONTEXT); // dialog mContext); // dialog
builder.setTitle(result.getExtra()) builder.setTitle(result.getExtra())
.setMessage( .setMessage(
"What do you want to do with this link?") mContext.getResources().getString(R.string.dialog_link))
.setPositiveButton("Open in New Tab", .setPositiveButton(mContext.getResources().getString(R.string.action_new_tab),
dialogClickListener) dialogClickListener)
.setNegativeButton("Open Normally", .setNegativeButton(mContext.getResources().getString(R.string.action_open),
dialogClickListener) dialogClickListener)
.setNeutralButton("Copy link", dialogClickListener) .setNeutralButton(mContext.getResources().getString(R.string.action_copy), dialogClickListener)
.show(); .show();
} }
} }
@ -825,7 +826,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
public static void reinitializeSettings() { public static void reinitializeSettings() {
int size = tabList.size(); int size = tabList.size();
for (int n = 0; n < size; n++) { for (int n = 0; n < size; n++) {
main[tabList.get(n)].settingsInitialization(CONTEXT); main[tabList.get(n)].settingsInitialization(mContext);
} }
} }
@ -840,20 +841,20 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
} }
final AlertDialog.Builder homePicker = new AlertDialog.Builder(CONTEXT); final AlertDialog.Builder homePicker = new AlertDialog.Builder(mContext);
homePicker.setTitle("Rename Bookmark"); homePicker.setTitle(mContext.getResources().getString(R.string.title_edit_bookmark));
final EditText getText = new EditText(CONTEXT); final EditText getText = new EditText(mContext);
getText.setText(bTitle[index]); getText.setText(bTitle[index]);
homePicker.setView(getText); homePicker.setView(getText);
homePicker.setPositiveButton("OK", homePicker.setPositiveButton(mContext.getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
bTitle[index] = getText.getText().toString(); bTitle[index] = getText.getText().toString();
File book = new File(CONTEXT.getFilesDir(), "bookmarks"); File book = new File(mContext.getFilesDir(), "bookmarks");
File bookUrl = new File(CONTEXT.getFilesDir(), File bookUrl = new File(mContext.getFilesDir(),
"bookurl"); "bookurl");
int n = 0; int n = 0;
try { try {
@ -895,7 +896,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
readUrl.close(); readUrl.close();
} catch (IOException ignored) { } catch (IOException ignored) {
} }
openBookmarks(CONTEXT, currentTab); openBookmarks(mContext, currentTab);
} }
}); });
homePicker.show(); homePicker.show();
@ -975,8 +976,8 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
// start the chooser for sharing // start the chooser for sharing
CONTEXT.startActivity(Intent.createChooser(shareIntent, mContext.startActivity(Intent.createChooser(shareIntent,
"Share this page")); mContext.getResources().getString(R.string.dialog_title_share)));
} }
public static void toggleFullScreen() { public static void toggleFullScreen() {
@ -1095,7 +1096,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_ENTER:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
searchTheWeb(getUrl.getText().toString(), CONTEXT); searchTheWeb(getUrl.getText().toString(), mContext);
return true; return true;
default: default:
break; break;
@ -1117,7 +1118,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
|| (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) { || (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
searchTheWeb(getUrl.getText().toString(), CONTEXT); searchTheWeb(getUrl.getText().toString(), mContext);
return true; return true;
} }
return false; return false;
@ -1128,8 +1129,8 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
static List<Map<String, String>> getBookmarks() { static List<Map<String, String>> getBookmarks() {
List<Map<String, String>> bookmarks = new ArrayList<Map<String, String>>(); List<Map<String, String>> bookmarks = new ArrayList<Map<String, String>>();
File bookUrl = new File(CONTEXT.getFilesDir(), "bookurl"); File bookUrl = new File(mContext.getFilesDir(), "bookurl");
File book = new File(CONTEXT.getFilesDir(), "bookmarks"); File book = new File(mContext.getFilesDir(), "bookmarks");
try { try {
BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl)); BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl));
BufferedReader readBook = new BufferedReader(new FileReader(book)); BufferedReader readBook = new BufferedReader(new FileReader(book));
@ -1170,7 +1171,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
switch (msg.what) { switch (msg.what) {
case 1: { case 1: {
SimpleAdapter adapter = new SimpleAdapter(CONTEXT, list, SimpleAdapter adapter = new SimpleAdapter(mContext, list,
R.layout.two_line_autocomplete, new String[] { R.layout.two_line_autocomplete, new String[] {
"title", "url" }, new int[] { R.id.title, "title", "url" }, new int[] { R.id.title,
R.id.url }); R.id.url });
@ -1282,7 +1283,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
url = ((TextView) arg1.findViewById(R.id.url)).getText() url = ((TextView) arg1.findViewById(R.id.url)).getText()
.toString(); .toString();
getUrl.setText(url); getUrl.setText(url);
searchTheWeb(url, CONTEXT); searchTheWeb(url, mContext);
url = null; url = null;
getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setPadding(tenPad, 0, tenPad, 0);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@ -1458,7 +1459,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
getWindowManager().getDefaultDisplay().getMetrics(metrics); getWindowManager().getDefaultDisplay().getMetrics(metrics);
historyHandler = new DatabaseHandler(this); historyHandler = new DatabaseHandler(this);
cookieManager = CookieManager.getInstance(); cookieManager = CookieManager.getInstance();
CookieSyncManager.createInstance(CONTEXT); CookieSyncManager.createInstance(mContext);
cookieManager.setAcceptCookie(false); cookieManager.setAcceptCookie(false);
progressBar = (ProgressBar) findViewById(R.id.progressBar1); progressBar = (ProgressBar) findViewById(R.id.progressBar1);
@ -1525,7 +1526,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
// user agent // user agent
if (API < 17) { if (API < 17) {
user = new WebView(CONTEXT).getSettings().getUserAgentString(); user = new WebView(mContext).getSettings().getUserAgentString();
} else { } else {
user = WebSettings.getDefaultUserAgent(this); user = WebSettings.getDefaultUserAgent(this);
} }
@ -1728,7 +1729,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // displays main xml layout setContentView(R.layout.activity_main); // displays main xml layout
CONTEXT = this; mContext = this;
ACTIVITY = this; ACTIVITY = this;
settings = getSharedPreferences("settings", 0); settings = getSharedPreferences("settings", 0);
edit = settings.edit(); edit = settings.edit();
@ -1760,7 +1761,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
+ "disabled to ensure as best we can that you are not being tracked. " + "disabled to ensure as best we can that you are not being tracked. "
+ "Happy Browsing!"; + "Happy Browsing!";
Utils.createInformativeDialog(CONTEXT, "About Incognito", message); Utils.createInformativeDialog(mContext, "About Incognito", message);
edit.putInt("first", 1); edit.putInt("first", 1);
edit.commit(); edit.commit();
} }
@ -1872,7 +1873,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
if (id >= 0) { if (id >= 0) {
main[id].loadUrl(url); main[id].loadUrl(url);
} else if (download == 1) { } else if (download == 1) {
Utils.downloadFile(CONTEXT, url, null, null); Utils.downloadFile(mContext, url, null, null);
} else if (url != null) { } else if (url != null) {
newTab(url, true); newTab(url, true);
} }
@ -1885,12 +1886,12 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.history: case R.id.history:
generateHistory(currentTab, CONTEXT); generateHistory(currentTab, mContext);
return true; return true;
case R.id.bookmark: case R.id.bookmark:
if (urlToLoad[currentId][1] != null) { if (urlToLoad[currentId][1] != null) {
if (!urlToLoad[currentId][1].equals("Bookmarks")) { if (!urlToLoad[currentId][1].equals("Bookmarks")) {
Utils.addBookmark(CONTEXT, urlToLoad[currentId][1], Utils.addBookmark(mContext, urlToLoad[currentId][1],
urlToLoad[currentId][0]); urlToLoad[currentId][0]);
} }
} }
@ -1900,9 +1901,9 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
return true; return true;
case R.id.allBookmarks: case R.id.allBookmarks:
if (urlToLoad[currentId][1] == null) { if (urlToLoad[currentId][1] == null) {
goBookmarks(CONTEXT, currentTab); goBookmarks(mContext, currentTab);
} else if (!urlToLoad[currentId][1].equals("Bookmarks")) { } else if (!urlToLoad[currentId][1].equals("Bookmarks")) {
goBookmarks(CONTEXT, currentTab); goBookmarks(mContext, currentTab);
} }
return true; return true;
@ -1958,7 +1959,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
private Rect edge; private Rect edge;
private boolean xPress; private boolean xPress;
private final GestureDetector mGestureDetector = new GestureDetector( private final GestureDetector mGestureDetector = new GestureDetector(
CONTEXT, new CustomGestureListener()); mContext, new CustomGestureListener());
private class CustomGestureListener extends SimpleOnGestureListener { private class CustomGestureListener extends SimpleOnGestureListener {
@Override @Override
@ -2070,7 +2071,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
public void onClick(View v) { public void onClick(View v) {
if (API >= 11) { if (API >= 11) {
PopupMenu menu = new PopupMenu(CONTEXT, v); PopupMenu menu = new PopupMenu(mContext, v);
MenuInflater inflate = menu.getMenuInflater(); MenuInflater inflate = menu.getMenuInflater();
inflate.inflate(R.menu.incognito_menu, menu.getMenu()); inflate.inflate(R.menu.incognito_menu, menu.getMenu());
menu.setOnMenuItemClickListener(new OnMenuItemClickListener() { menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@ -2080,13 +2081,13 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.history: case R.id.history:
generateHistory(currentTab, CONTEXT); generateHistory(currentTab, mContext);
return true; return true;
case R.id.bookmark: case R.id.bookmark:
if (urlToLoad[currentId][1] != null) { if (urlToLoad[currentId][1] != null) {
if (!urlToLoad[currentId][1] if (!urlToLoad[currentId][1]
.equals("Bookmarks")) { .equals("Bookmarks")) {
Utils.addBookmark(CONTEXT, Utils.addBookmark(mContext,
urlToLoad[currentId][1], urlToLoad[currentId][1],
urlToLoad[currentId][0]); urlToLoad[currentId][0]);
} }
@ -2097,10 +2098,10 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
return true; return true;
case R.id.allBookmarks: case R.id.allBookmarks:
if (urlToLoad[currentId][1] == null) { if (urlToLoad[currentId][1] == null) {
goBookmarks(CONTEXT, currentTab); goBookmarks(mContext, currentTab);
} else if (!urlToLoad[currentId][1] } else if (!urlToLoad[currentId][1]
.equals("Bookmarks")) { .equals("Bookmarks")) {
goBookmarks(CONTEXT, currentTab); goBookmarks(mContext, currentTab);
} }
return true; return true;
case R.id.share: case R.id.share:

185
src/acr/browser/barebones/activities/SettingsActivity.java

@ -35,7 +35,7 @@ import android.widget.TextView;
public class SettingsActivity extends Activity { public class SettingsActivity extends Activity {
static int API = FinalVariables.API; static int API = FinalVariables.API;
static final String preferences = "settings"; static final String preferences = "settings";
static SharedPreferences.Editor edit; static SharedPreferences.Editor mEditPrefs;
static int agentChoice; static int agentChoice;
static String homepage; static String homepage;
static TextView agentText; static TextView agentText;
@ -63,7 +63,7 @@ public class SettingsActivity extends Activity {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); WindowManager.LayoutParams.FLAG_FULLSCREEN);
} }
edit = settings.edit(); mEditPrefs= settings.edit();
// initialize UI // initialize UI
RelativeLayout layoutLocation = (RelativeLayout) findViewById(R.id.layoutLocation); RelativeLayout layoutLocation = (RelativeLayout) findViewById(R.id.layoutLocation);
@ -131,29 +131,27 @@ public class SettingsActivity extends Activity {
version.setText(code + ""); version.setText(code + "");
if (homepage.contains("about:home")) { if (homepage.contains("about:home")) {
homepageText.setText("Bookmarks"); homepageText.setText(getResources().getString(
R.string.action_homepage));
} else if (homepage.contains("about:blank")) { } else if (homepage.contains("about:blank")) {
homepageText.setText("Blank Page"); homepageText.setText(getResources()
.getString(R.string.action_blank));
} else { } else {
homepageText.setText(homepage); homepageText.setText(homepage);
} }
switch (agentChoice) { switch (agentChoice) {
case 1: case 1:
agentText.setText("Default"); agentText.setText(getResources().getString(R.string.agent_default));
agent = BrowserActivity.defaultUser;
break; break;
case 2: case 2:
agentText.setText("Desktop"); agentText.setText(getResources().getString(R.string.agent_desktop));
agent = FinalVariables.DESKTOP_USER_AGENT;
break; break;
case 3: case 3:
agentText.setText("Mobile"); agentText.setText(getResources().getString(R.string.agent_mobile));
agent = FinalVariables.MOBILE_USER_AGENT;
break; break;
case 4: case 4:
agentText.setText("Custom"); agentText.setText(getResources().getString(R.string.agent_custom));
agent = settings.getString("userAgentString", BrowserActivity.defaultUser);
} }
RelativeLayout r1, r2, r3; RelativeLayout r1, r2, r3;
r1 = (RelativeLayout) findViewById(R.id.setR1); r1 = (RelativeLayout) findViewById(R.id.setR1);
@ -226,7 +224,8 @@ public class SettingsActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder picker = new AlertDialog.Builder( AlertDialog.Builder picker = new AlertDialog.Builder(
SettingsActivity.this); SettingsActivity.this);
picker.setTitle("Search Engine"); picker.setTitle(getResources().getString(
R.string.title_search_engine));
CharSequence[] chars = { "Google", "Bing", "Yahoo", CharSequence[] chars = { "Google", "Bing", "Yahoo",
"StartPage", "DuckDuckGo (Privacy)" , "Baidu (Chinese)", "Yandex (Russian)", "DuckDuckGo Lite (Privacy)"}; "StartPage", "DuckDuckGo (Privacy)" , "Baidu (Chinese)", "Yandex (Russian)", "DuckDuckGo Lite (Privacy)"};
@ -238,8 +237,8 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog,
int which) { int which) {
edit.putInt("search", which + 1); mEditPrefs.putInt("search", which + 1);
edit.commit(); mEditPrefs.commit();
switch (which + 1) { switch (which + 1) {
case 1: case 1:
searchText.setText("Google"); searchText.setText("Google");
@ -268,7 +267,7 @@ public class SettingsActivity extends Activity {
} }
} }
}); });
picker.setNeutralButton("OK", picker.setNeutralButton(getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -365,8 +364,8 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
edit.putBoolean("location", isChecked); mEditPrefs.putBoolean("location", isChecked);
edit.commit(); mEditPrefs.commit();
} }
@ -380,8 +379,8 @@ public class SettingsActivity extends Activity {
if (isChecked) { if (isChecked) {
n = 1; n = 1;
} }
edit.putInt("enableflash", n); mEditPrefs.putInt("enableflash", n);
edit.commit(); mEditPrefs.commit();
boolean flashInstalled = false; boolean flashInstalled = false;
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
@ -393,19 +392,21 @@ public class SettingsActivity extends Activity {
flashInstalled = false; flashInstalled = false;
} }
if (!flashInstalled && isChecked) { if (!flashInstalled && isChecked) {
Utils.createInformativeDialog(SettingsActivity.this, Utils.createInformativeDialog(
"Warning", "Adobe Flash Player was not detected.\n" SettingsActivity.this,
+ "Please install Flash Player."); getResources().getString(R.string.title_warning),
getResources().getString(
R.string.dialog_adobe_not_installed));
buttonView.setChecked(false); buttonView.setChecked(false);
edit.putInt("enableflash", 0); mEditPrefs.putInt("enableflash", 0);
edit.commit(); mEditPrefs.commit();
} else if ((API > 17) && isChecked) { } else if ((API >= 17) && isChecked) {
Utils.createInformativeDialog( Utils.createInformativeDialog(
SettingsActivity.this, SettingsActivity.this,
"Warning", getResources().getString(R.string.title_warning),
"Adobe Flash does not support Android 4.3 and will " getResources().getString(
+ "crash the browser, please do not report crashes that occur if you enable flash."); R.string.dialog_adobe_unsupported));
} }
} }
@ -415,8 +416,8 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
edit.putBoolean("fullscreen", isChecked); mEditPrefs.putBoolean("fullscreen", isChecked);
edit.commit(); mEditPrefs.commit();
} }
@ -430,8 +431,8 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
edit.putBoolean("location", isChecked); mEditPrefs.putBoolean("location", isChecked);
edit.commit(); mEditPrefs.commit();
} }
@ -445,8 +446,8 @@ public class SettingsActivity extends Activity {
if (isChecked) { if (isChecked) {
n = 1; n = 1;
} }
edit.putInt("enableflash", n); mEditPrefs.putInt("enableflash", n);
edit.commit(); mEditPrefs.commit();
boolean flashInstalled = false; boolean flashInstalled = false;
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
@ -458,19 +459,21 @@ public class SettingsActivity extends Activity {
flashInstalled = false; flashInstalled = false;
} }
if (!flashInstalled && isChecked) { if (!flashInstalled && isChecked) {
Utils.createInformativeDialog(SettingsActivity.this, Utils.createInformativeDialog(
"Warning", "Adobe Flash Player was not detected.\n" SettingsActivity.this,
+ "Please install Flash Player."); getResources().getString(R.string.title_warning),
getResources().getString(
R.string.dialog_adobe_not_installed));
buttonView.setChecked(false); buttonView.setChecked(false);
edit.putInt("enableflash", 0); mEditPrefs.putInt("enableflash", 0);
edit.commit(); mEditPrefs.commit();
} else if ((API > 17) && isChecked) { } else if ((API > 17) && isChecked) {
Utils.createInformativeDialog( Utils.createInformativeDialog(
SettingsActivity.this, SettingsActivity.this,
"Warning", getResources().getString(R.string.title_warning),
"Adobe Flash does not support Android 4.3 and will " getResources().getString(
+ "crash the browser, please do not report crashes that occur if you enable flash."); R.string.dialog_adobe_unsupported));
} }
} }
@ -480,8 +483,8 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
edit.putBoolean("fullscreen", isChecked); mEditPrefs.putBoolean("fullscreen", isChecked);
edit.commit(); mEditPrefs.commit();
} }
@ -506,8 +509,13 @@ public class SettingsActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder agentPicker = new AlertDialog.Builder( AlertDialog.Builder agentPicker = new AlertDialog.Builder(
SettingsActivity.this); SettingsActivity.this);
agentPicker.setTitle("User Agent"); agentPicker.setTitle(getResources().getString(
CharSequence[] chars = { "Default", "Desktop", "Mobile" }; R.string.title_user_agent));
CharSequence[] chars = {
getResources().getString(R.string.agent_default),
getResources().getString(R.string.agent_desktop),
getResources().getString(R.string.agent_mobile),
getResources().getString(R.string.agent_custom) };
agentChoice = settings.getInt("agentchoose", 1); agentChoice = settings.getInt("agentchoose", 1);
agentPicker.setSingleChoiceItems(chars, agentChoice - 1, agentPicker.setSingleChoiceItems(chars, agentChoice - 1,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@ -515,30 +523,31 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog,
int which) { int which) {
edit.putInt("agentchoose", which + 1); mEditPrefs.putInt("agentchoose", which + 1);
edit.commit(); mEditPrefs.commit();
switch (which + 1) { switch (which + 1) {
case 1: case 1:
agentText.setText("Default"); agentText.setText(getResources().getString(
agent = BrowserActivity.defaultUser; R.string.agent_default));
break; break;
case 2: case 2:
agentText.setText("Desktop"); agentText.setText(getResources().getString(
agent = FinalVariables.DESKTOP_USER_AGENT; R.string.agent_desktop));
break; break;
case 3: case 3:
agentText.setText("Mobile"); agentText.setText(getResources().getString(
agent = FinalVariables.MOBILE_USER_AGENT; R.string.agent_mobile));
break; break;
case 4: case 4:
agentText.setText("Custom"); agentText.setText(getResources().getString(
agent = settings.getString("userAgentString", BrowserActivity.defaultUser); R.string.agent_custom));
agentPicker(); agentPicker();
break; break;
} }
} }
}); });
agentPicker.setNeutralButton("OK", agentPicker.setNeutralButton(
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -569,18 +578,21 @@ public class SettingsActivity extends Activity {
final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder( final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder(
SettingsActivity.this); SettingsActivity.this);
agentStringPicker.setTitle("Custom Agent"); agentStringPicker.setTitle(getResources().getString(
R.string.title_user_agent));
final EditText getAgent = new EditText(SettingsActivity.this); final EditText getAgent = new EditText(SettingsActivity.this);
agentStringPicker.setView(getAgent); agentStringPicker.setView(getAgent);
agentStringPicker.setPositiveButton("OK", agentStringPicker.setPositiveButton(
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String text = getAgent.getText().toString(); String text = getAgent.getText().toString();
edit.putString("userAgentString", text); mEditPrefs.putString("userAgentString", text);
edit.commit(); mEditPrefs.commit();
agentText.setText("Custom"); agentText.setText(getResources().getString(
R.string.agent_custom));
} }
}); });
agentStringPicker.show(); agentStringPicker.show();
@ -594,8 +606,11 @@ public class SettingsActivity extends Activity {
AlertDialog.Builder picker = new AlertDialog.Builder( AlertDialog.Builder picker = new AlertDialog.Builder(
SettingsActivity.this); SettingsActivity.this);
picker.setTitle("Download Location"); picker.setTitle(getResources().getString(
CharSequence[] chars = { "Default", "Custom" }; R.string.title_download_location));
CharSequence[] chars = {
getResources().getString(R.string.agent_default),
getResources().getString(R.string.agent_custom) };
downloadLocation = settings.getString("download", downloadLocation = settings.getString("download",
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
int n = -1; int n = -1;
@ -614,9 +629,9 @@ public class SettingsActivity extends Activity {
switch (which + 1) { switch (which + 1) {
case 1: case 1:
edit.putString("download", mEditPrefs.putString("download",
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
edit.commit(); mEditPrefs.commit();
download.setText(FinalVariables.EXTERNAL_STORAGE download.setText(FinalVariables.EXTERNAL_STORAGE
+ "/" + "/"
+ Environment.DIRECTORY_DOWNLOADS); + Environment.DIRECTORY_DOWNLOADS);
@ -628,7 +643,8 @@ public class SettingsActivity extends Activity {
} }
} }
}); });
picker.setNeutralButton("OK", picker.setNeutralButton(
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -645,8 +661,9 @@ public class SettingsActivity extends Activity {
public void homePicker() { public void homePicker() {
final AlertDialog.Builder homePicker = new AlertDialog.Builder( final AlertDialog.Builder homePicker = new AlertDialog.Builder(
SettingsActivity.this); this);
homePicker.setTitle("Custom Homepage"); homePicker.setTitle(getResources().getString(
R.string.title_custom_homepage));
final EditText getHome = new EditText(SettingsActivity.this); final EditText getHome = new EditText(SettingsActivity.this);
homepage = settings.getString("home", FinalVariables.HOMEPAGE); homepage = settings.getString("home", FinalVariables.HOMEPAGE);
if (!homepage.startsWith("about:")) { if (!homepage.startsWith("about:")) {
@ -655,14 +672,14 @@ public class SettingsActivity extends Activity {
getHome.setText("http://www.google.com"); getHome.setText("http://www.google.com");
} }
homePicker.setView(getHome); homePicker.setView(getHome);
homePicker.setPositiveButton("OK", homePicker.setPositiveButton(getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String text = getHome.getText().toString(); String text = getHome.getText().toString();
edit.putString("home", text); mEditPrefs.putString("home", text);
edit.commit(); mEditPrefs.commit();
homepageText.setText(text); homepageText.setText(text);
} }
}); });
@ -672,14 +689,15 @@ public class SettingsActivity extends Activity {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void downPicker() { public void downPicker() {
final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder( final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(
SettingsActivity.this); this);
LinearLayout layout = new LinearLayout(this); LinearLayout layout = new LinearLayout(this);
downLocationPicker.setTitle("Custom Location"); downLocationPicker.setTitle(getResources().getString(
R.string.title_download_location));
final EditText getDownload = new EditText(SettingsActivity.this); final EditText getDownload = new EditText(SettingsActivity.this);
getDownload.setBackgroundResource(0); getDownload.setBackgroundResource(0);
downloadLocation = settings.getString("download", downloadLocation = settings.getString("download",
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
int padding = Utils.convertDensityPixesl(this, 10); int padding = Utils.convertDensityPixels(this, 10);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT,
@ -705,14 +723,15 @@ public class SettingsActivity extends Activity {
android.R.drawable.edit_text)); android.R.drawable.edit_text));
} }
downLocationPicker.setView(layout); downLocationPicker.setView(layout);
downLocationPicker.setPositiveButton("OK", downLocationPicker.setPositiveButton(
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String text = getDownload.getText().toString(); String text = getDownload.getText().toString();
edit.putString("download", text); mEditPrefs.putString("download", text);
edit.commit(); mEditPrefs.commit();
download.setText(FinalVariables.EXTERNAL_STORAGE + "/" download.setText(FinalVariables.EXTERNAL_STORAGE + "/"
+ text); + text);
} }
@ -748,13 +767,13 @@ public class SettingsActivity extends Activity {
switch (which + 1) { switch (which + 1) {
case 1: case 1:
edit.putString("home", "about:home"); mEditPrefs.putString("home", "about:home");
edit.commit(); mEditPrefs.commit();
homepageText.setText("Bookmarks"); homepageText.setText("Bookmarks");
break; break;
case 2: case 2:
edit.putString("home", "about:blank"); mEditPrefs.putString("home", "about:blank");
edit.commit(); mEditPrefs.commit();
homepageText.setText("Blank Page"); homepageText.setText("Blank Page");
break; break;
case 3: case 3:

2
src/acr/browser/barebones/utilities/Utils.java

@ -189,7 +189,7 @@ public class Utils {
return intent; return intent;
} }
public static int convertDensityPixesl(Context context, int densityPixels) { public static int convertDensityPixels(Context context, int densityPixels) {
float scale = context.getResources().getDisplayMetrics().density; float scale = context.getResources().getDisplayMetrics().density;
int pixels = (int) (densityPixels * scale + 0.5f); int pixels = (int) (densityPixels * scale + 0.5f);
return pixels; return pixels;

15
src/acr/browser/barebones/webviewclasses/CustomDownloadListener.java

@ -1,6 +1,5 @@
package acr.browser.barebones.webviewclasses; package acr.browser.barebones.webviewclasses;
import acr.browser.barebones.activities.BrowserActivity;
import acr.browser.barebones.utilities.Utils; import acr.browser.barebones.utilities.Utils;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@ -10,9 +9,9 @@ import android.net.Uri;
import android.webkit.DownloadListener; import android.webkit.DownloadListener;
public class CustomDownloadListener implements DownloadListener { public class CustomDownloadListener implements DownloadListener {
private static Context context; private static Context mContext;
public CustomDownloadListener(BrowserActivity activity){ public CustomDownloadListener(Context context){
context = activity; mContext = context;
} }
@ -22,7 +21,7 @@ public class CustomDownloadListener implements DownloadListener {
long contentLength) { long contentLength) {
if (url.endsWith(".mp4") || url.endsWith(".m4a")) { if (url.endsWith(".mp4") || url.endsWith(".m4a")) {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle("Open as..."); builder.setTitle("Open as...");
builder.setMessage( builder.setMessage(
"Do you want to download this video or watch it in an app?") "Do you want to download this video or watch it in an app?")
@ -32,7 +31,7 @@ public class CustomDownloadListener implements DownloadListener {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog,
int id) { int id) {
Utils.downloadFile(context, url, Utils.downloadFile(mContext, url,
contentDisposition, mimetype); contentDisposition, mimetype);
} }
}) })
@ -48,14 +47,14 @@ public class CustomDownloadListener implements DownloadListener {
intent.putExtra( intent.putExtra(
"acr.browser.barebones.Download", "acr.browser.barebones.Download",
1); 1);
context.startActivity(intent); mContext.startActivity(intent);
} }
}); });
AlertDialog alert = builder.create(); AlertDialog alert = builder.create();
alert.show(); alert.show();
} else { } else {
Utils.downloadFile(context, url, contentDisposition, mimetype); Utils.downloadFile(mContext, url, contentDisposition, mimetype);
} }
} }

Loading…
Cancel
Save