mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-14 01:48:47 -04:00
Add LongClickListener for opening up links in a new tab
This commit is contained in:
parent
7b9ef9d972
commit
aa6e28b581
@ -25,6 +25,7 @@
|
|||||||
<string name="choose_file">Select a ZIM Content File (*.zim)</string>
|
<string name="choose_file">Select a ZIM Content File (*.zim)</string>
|
||||||
<string name="add_bookmark">Add bookmark</string>
|
<string name="add_bookmark">Add bookmark</string>
|
||||||
<string name="remove_bookmark">Remove bookmark</string>
|
<string name="remove_bookmark">Remove bookmark</string>
|
||||||
|
<string name="open_in_new_tab">Open link in new tab?</string>
|
||||||
<string name="error_nozimfilesfound">No ZIM files found on your device.\nTake a look at the Help Page to get directions on how to load content into Kiwix.\nIf you did put a ZIM file on your device/external storage, you might retry in a minute or restart your device.</string>
|
<string name="error_nozimfilesfound">No ZIM files found on your device.\nTake a look at the Help Page to get directions on how to load content into Kiwix.\nIf you did put a ZIM file on your device/external storage, you might retry in a minute or restart your device.</string>
|
||||||
<string name="error_filenotfound">Error: The selected ZIM file could not be found.</string>
|
<string name="error_filenotfound">Error: The selected ZIM file could not be found.</string>
|
||||||
<string name="error_fileinvalid">Error: The selected file is not a valid ZIM file.</string>
|
<string name="error_fileinvalid">Error: The selected file is not a valid ZIM file.</string>
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
<item name="deleteDrawable">@drawable/ic_action_delete</item>
|
<item name="deleteDrawable">@drawable/ic_action_delete</item>
|
||||||
<item name="dividerColor">@color/divider_light</item>
|
<item name="dividerColor">@color/divider_light</item>
|
||||||
<item name="selectedBackground">@drawable/list_bg_light</item>
|
<item name="selectedBackground">@drawable/list_bg_light</item>
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
|
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
|
||||||
|
@ -256,7 +256,7 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
newTab();
|
newTab();
|
||||||
|
|
||||||
manageExternalLaunchAndRestoringViewState(savedInstanceState);
|
manageExternalLaunchAndRestoringViewState(savedInstanceState);
|
||||||
// setUpWebView();
|
setUpWebView();
|
||||||
setUpExitFullscreenButton();
|
setUpExitFullscreenButton();
|
||||||
// setUpArticleSearchTextView(savedInstanceState);
|
// setUpArticleSearchTextView(savedInstanceState);
|
||||||
loadPrefs();
|
loadPrefs();
|
||||||
@ -840,6 +840,39 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
getCurrentWebView().setOnLongClickListener(new KiwixWebView.OnLongClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLongClick(final String url) {
|
||||||
|
boolean handleEvent = false;
|
||||||
|
if (url.startsWith(ZimContentProvider.CONTENT_URI.toString())) {
|
||||||
|
// This is my web site, so do not override; let my WebView load the page
|
||||||
|
handleEvent = true;
|
||||||
|
|
||||||
|
} else if (url.startsWith("file://")) {
|
||||||
|
// To handle help page (loaded from resources)
|
||||||
|
handleEvent = true;
|
||||||
|
|
||||||
|
} else if (url.startsWith(ZimContentProvider.UI_URI.toString())) {
|
||||||
|
handleEvent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handleEvent) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(KiwixMobileActivity.this);
|
||||||
|
|
||||||
|
builder.setPositiveButton(android.R.string.yes,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
newTab(url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(android.R.string.no, null);
|
||||||
|
builder.setMessage(getString(R.string.open_in_new_tab));
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
final Handler saveHandler = new
|
final Handler saveHandler = new
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@ public class KiwixWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadPrefs() {
|
public void loadPrefs() {
|
||||||
|
disableZoomControls();
|
||||||
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager
|
SharedPreferences sharedPreferences = PreferenceManager
|
||||||
.getDefaultSharedPreferences(getContext());
|
.getDefaultSharedPreferences(getContext());
|
||||||
@ -193,10 +194,10 @@ public class KiwixWebView extends WebView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableZoomControls(boolean disable) {
|
public void disableZoomControls() {
|
||||||
|
|
||||||
getSettings().setBuiltInZoomControls(true);
|
getSettings().setBuiltInZoomControls(true);
|
||||||
getSettings().setDisplayZoomControls(true);
|
getSettings().setDisplayZoomControls(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnPageChangedListener(OnPageChangeListener listener) {
|
public void setOnPageChangedListener(OnPageChangeListener listener) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user