mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
zoom controls settings, fixed night mode status for all pages
This commit is contained in:
parent
a8adcfe102
commit
0351617fe1
@ -30,4 +30,6 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
<string name="menu_exit">Exit</string>
|
<string name="menu_exit">Exit</string>
|
||||||
<string name="menu_togglenightmode">Toggle night mode</string>
|
<string name="menu_togglenightmode">Toggle night mode</string>
|
||||||
|
<string name="pref_zoom_enable">Enable Zoom</string>
|
||||||
|
<string name="pref_zoom_enable_summary">Enable or disable the zoom controls</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
android:entries="@array/pref_zoom_entries"
|
android:entries="@array/pref_zoom_entries"
|
||||||
android:entryValues="@array/pref_zoom_entryvalues"
|
android:entryValues="@array/pref_zoom_entryvalues"
|
||||||
android:defaultValue="automatic" />
|
android:defaultValue="automatic" />
|
||||||
|
<CheckBoxPreference android:key="pref_zoom_enabled" android:title="@string/pref_zoom_enable" android:summary="@string/pref_zoom_enable_summary" android:defaultValue="false"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<!-- PreferenceCategory
|
<!-- PreferenceCategory
|
||||||
|
@ -56,6 +56,7 @@ public class KiwixMobileActivity extends Activity {
|
|||||||
private ArrayAdapter<String> adapter;
|
private ArrayAdapter<String> adapter;
|
||||||
protected boolean requestClearHistoryAfterLoad;
|
protected boolean requestClearHistoryAfterLoad;
|
||||||
protected boolean requestShowAllMenuItems;
|
protected boolean requestShowAllMenuItems;
|
||||||
|
protected boolean NightMode;
|
||||||
protected int requestWebReloadOnFinished;
|
protected int requestWebReloadOnFinished;
|
||||||
private static final int ZIMFILESELECT_REQUEST_CODE = 1234;
|
private static final int ZIMFILESELECT_REQUEST_CODE = 1234;
|
||||||
private static final int PREFERENCES_REQUEST_CODE = 1235;
|
private static final int PREFERENCES_REQUEST_CODE = 1235;
|
||||||
@ -131,6 +132,7 @@ public class KiwixMobileActivity extends Activity {
|
|||||||
requestClearHistoryAfterLoad=false;
|
requestClearHistoryAfterLoad=false;
|
||||||
requestWebReloadOnFinished = 0;
|
requestWebReloadOnFinished = 0;
|
||||||
requestShowAllMenuItems = false;
|
requestShowAllMenuItems = false;
|
||||||
|
NightMode = false;
|
||||||
|
|
||||||
|
|
||||||
this.requestWindowFeature(Window.FEATURE_PROGRESS);
|
this.requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||||
@ -220,6 +222,13 @@ public class KiwixMobileActivity extends Activity {
|
|||||||
webView.clearHistory();
|
webView.clearHistory();
|
||||||
requestClearHistoryAfterLoad=false;
|
requestClearHistoryAfterLoad=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(NightMode){
|
||||||
|
NightMode=false;
|
||||||
|
ToggleNightMode();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -284,8 +293,7 @@ public class KiwixMobileActivity extends Activity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
loadPref();
|
loadPref();
|
||||||
//Pinch to zoom
|
|
||||||
webView.getSettings().setBuiltInZoomControls(true);
|
|
||||||
//webView.getSettings().setLoadsImagesAutomatically(false);
|
//webView.getSettings().setLoadsImagesAutomatically(false);
|
||||||
//Does not make much sense to cache data from zim files.(Not clear whether
|
//Does not make much sense to cache data from zim files.(Not clear whether
|
||||||
// this actually has any effect)
|
// this actually has any effect)
|
||||||
@ -335,6 +343,8 @@ public class KiwixMobileActivity extends Activity {
|
|||||||
private void loadPref(){
|
private void loadPref(){
|
||||||
SharedPreferences mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
String pref_zoom = mySharedPreferences.getString("pref_zoom", "automatic");
|
String pref_zoom = mySharedPreferences.getString("pref_zoom", "automatic");
|
||||||
|
Boolean pref_zoom_enabled = mySharedPreferences.getBoolean("pref_zoom_enabled", false);
|
||||||
|
|
||||||
if (pref_zoom.equals("automatic")) {
|
if (pref_zoom.equals("automatic")) {
|
||||||
setDefaultZoom();
|
setDefaultZoom();
|
||||||
} else if (pref_zoom.equals("medium")) {
|
} else if (pref_zoom.equals("medium")) {
|
||||||
@ -347,6 +357,10 @@ public class KiwixMobileActivity extends Activity {
|
|||||||
Log.w("kiwix", "pref_displayZoom value ("+pref_zoom+" unknown. Assuming automatic");
|
Log.w("kiwix", "pref_displayZoom value ("+pref_zoom+" unknown. Assuming automatic");
|
||||||
webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
|
webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Pinch to zoom
|
||||||
|
Log.d("kiwix","pref_zoom_enabled value ("+pref_zoom_enabled+")");
|
||||||
|
webView.getSettings().setBuiltInZoomControls(pref_zoom_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -600,6 +614,7 @@ public class KiwixMobileActivity extends Activity {
|
|||||||
hideSearchBar();
|
hideSearchBar();
|
||||||
webView.loadUrl(Uri.parse(ZimContentProvider.CONTENT_URI
|
webView.loadUrl(Uri.parse(ZimContentProvider.CONTENT_URI
|
||||||
+articleUrl).toString());
|
+articleUrl).toString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
String errorString = String.format(getResources().getString(R.string.error_articlenotfound), articleSearchtextView.getText().toString());
|
String errorString = String.format(getResources().getString(R.string.error_articlenotfound), articleSearchtextView.getText().toString());
|
||||||
@ -654,6 +669,7 @@ public class KiwixMobileActivity extends Activity {
|
|||||||
stream.close();
|
stream.close();
|
||||||
String JSInvert = new String(buffer);
|
String JSInvert = new String(buffer);
|
||||||
webView.loadUrl("javascript:"+JSInvert);
|
webView.loadUrl("javascript:"+JSInvert);
|
||||||
|
NightMode = !NightMode;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user