Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Beta version with fully working offline mode #89
Browse files Browse the repository at this point in the history
  • Loading branch information
indywidualny committed Feb 8, 2016
1 parent bbac237 commit a3583c2
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 14 deletions.
Binary file modified app/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/src/main/java/org/indywidualni/fblite/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public void onCreate() {
/**
* Piwik dry run. Uncomment these lines during app development.
*/
Piwik.getInstance(this).setDryRun(true);
Piwik.getInstance(this).setDebug(true);
//Piwik.getInstance(this).setDryRun(true);
//Piwik.getInstance(this).setDebug(true);

/**
* Count app downloads. Fired only after new installation or upgrade.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
case "transparent_nav":
case "drawer_pos":
case "no_images":
case "keyboard_fix":
case "hardware_acceleration":
relaunch();
break;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/indywidualni/fblite/util/Offline.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public Offline() {
public String getPage(String url) throws SQLException {
url = removeRefID(url);
url = removeEndingSlash(url);
Log.v(getClass().getSimpleName(), "Getting: " + url);
//Log.v(getClass().getSimpleName(), "Getting: " + url);
return dataSource.getPage(url);
}

public void savePage(String url) throws SQLException {
url = removeRefID(url);
url = removeEndingSlash(url);
Log.v(getClass().getSimpleName(), "Saving: " + url);
//Log.v(getClass().getSimpleName(), "Saving: " + url);
new SaveTask().execute(url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@ public void onPageFinished(WebView view, String url) {
String cssFixed = "#header{ position: fixed; z-index: 11; top: 0px; } #root{ padding-top: 44px; } " +
".flyout{ max-height: " + Dimension.heightForFixedFacebookNavbar(context) + "px; overflow-y: scroll; }";

try {
// there is no host in offline mode
if (Uri.parse(url).getHost() != null) {
if (Uri.parse(url).getHost().endsWith("mbasic.facebook.com"))
cssFixed = "#header{ position: fixed; z-index: 11; top: 0px; } #objects_container{ padding-top: 74px; }";
else if (Uri.parse(url).getHost().endsWith("0.facebook.com"))
cssFixed = "#toggleHeaderContent{position: fixed; z-index: 11; top: 0px;} " +
"#header{ position: fixed; z-index: 11; top: 28px; } #objects_container{ padding-top: 102px; }";
} catch (NullPointerException ignore) { /* there is no host host in offline mode */ }
}

view.loadUrl("javascript:function addStyleString(str) { var node = document.createElement('style'); " +
"node.innerHTML = str; document.body.appendChild(node); } addStyleString('" + cssFixed + "');");
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/dialog_offline_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
android:scrollbarStyle="outsideInset"
android:overScrollFooter="@android:color/transparent"
android:clipToPadding="false"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingBottom="10dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingTop="10dp"
/>

<TextView
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,22 @@
<string name="file_logger_needs_permission">Brak dostępu do pamięci zewnętrznej. Log nie może zostać zapisany</string>
<string name="save_img">Zapisz zdjęcie</string>
<string name="downloading_img">Pobieram zdjęcie&#8230;</string>

<string name="download_manager_disabled">DownloadManager jest wyłączony. Włącz go proszę.</string>
<string name="cannot_access_storage">Brak dostępu do pamięci zewnętrznej</string>
<string name="file_cannot_be_saved">Plik nie może zostać zapisany</string>
<string name="camera_exception">Nie mogę użyć aparatu</string>
<string name="load_extra">Ładuj zewnętrzne obrazy</string>
<string name="load_extra_description">Otwieraj zdjęcia z zewnętrznych serwisów. Obecnie niewiele stron jest wspieranych.</string>

<string name="offline_mode">Tryb offline</string>
<string name="offline_mode_enable">Aktywuj tryb offline</string>
<string name="offline_mode_description">Gdy nie ma połączenia z Internetem spróbuj załadować stronę z cache i bazy danych.</string>
<string name="not_found_offline" formatted="false"><![CDATA[<div style=\"position: absolute;top: 50%;left: 50%;transform: translateX(-50%) translateY(-50%);\"><div><h1>Niestety strona nie została znaleziona w bazie</h1><h1>Tip: by cofnąć, cofnij dwukrotnie</h1></div></div>]]></string>
<string name="loading_offline_database">Ładowanie strony z bazy danych</string>
<string name="offline_keep_max">Max liczba stron do przechowania</string>
<string name="offline_keep_max_description">Gdy online odwiedzone strony są zapisywane w bazie danych. Domyślnie (najnowsze) 10 stron.</string>
<string name="offline_dummy_description">Kod źródłowy bieżącej strony jest asynchronicznie zapisywany w bazie danych. W przypadku duplikatu zachowam najnowszą wersję. Odśwież by wymusić aktualizację. Nie działa dla dynamicznych treści.</string>
<string name="keyboard_fix">Napraw niewidoczne formularze &#8635;</string>
<string name="offline_database_empty">Baza danych jest pusta</string>

</resources>
8 changes: 4 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@

<string name="offline_mode">Offline mode</string>
<string name="offline_mode_enable">Enable offline mode</string>
<string name="offline_mode_description">When there is no Internet connection try to load a page from cache and a database.</string>
<string name="offline_mode_description">When there is no Internet connection try to load a page from cache and the database.</string>
<string name="not_found_offline" formatted="false"><![CDATA[<div style=\"position: absolute;top: 50%;left: 50%;transform: translateX(-50%) translateY(-50%);\"><div><h1>Unfortunately this page was not found in offline database</h1><h1>Tip: to go back just go back twice</h1></div></div>]]></string>
<string name="loading_offline_database">Loading page from offline database</string>
<string name="offline_keep_max">Max number of pages to keep</string>
<string name="offline_keep_max_description">When online visited pages are asynchronously saved to cache and a database. A default value is (latest) 10.</string>
<string name="offline_dummy_description">This option is great for Wi-Fi connection because the app will use twice as much data as before. If it\'s not a problem for you use it also during a mobile connection. The source code of the current page is asynchronously saved in a database. If a duplicate is found it will be replaced. Refresh a page to force update it.</string>
<string name="keyboard_fix">Overlaying keyboard fix</string>
<string name="offline_keep_max_description">When online visited pages are asynchronously saved in the database. A default value is (latest) 10 pages.</string>
<string name="offline_dummy_description">The source code of the current page is asynchronously saved in the database. If a duplicate is found it will be replaced. Refresh a page to force update it. It doesn\'t work for a dynamically loaded content.</string>
<string name="keyboard_fix">Overlaying keyboard fix &#8635;</string>
<string name="offline_database_empty">Offline database is empty</string>

</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/xml-v21/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@

<SwitchPreference
android:key="offline_mode"
android:title="@string/offline_mode"
android:title="@string/offline_mode_enable"
android:summary="@string/offline_mode_description"
android:defaultValue="false"/>

Expand Down

0 comments on commit a3583c2

Please sign in to comment.