mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Android Bookmarks can be loaded by either Title or URL #255
I may have also made a migration path but am not too sure as very difficult to test.
This commit is contained in:
parent
6bbc6d93a9
commit
ee6f214023
@ -5,6 +5,7 @@ NEW: Kiwix search home screen widget
|
|||||||
NEW: Download manager
|
NEW: Download manager
|
||||||
NEW: Improved ZIM management
|
NEW: Improved ZIM management
|
||||||
NEW: Build against newer version of Android NDK/SDK
|
NEW: Build against newer version of Android NDK/SDK
|
||||||
|
NEW: Bookmarks for multiple articles with the same title can be created
|
||||||
FIXED: Opening problem with ZIM filenames with special characters
|
FIXED: Opening problem with ZIM filenames with special characters
|
||||||
FIXED: Useless "w820dp" language
|
FIXED: Useless "w820dp" language
|
||||||
FIXED: Failing he, id, yi locales
|
FIXED: Failing he, id, yi locales
|
||||||
|
@ -200,7 +200,11 @@ public class BookmarksActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra("choseX", bookmarks.get(position));
|
if (!bookmarkUrls.get(position).equals("null")) {
|
||||||
|
intent.putExtra("choseXURL", bookmarkUrls.get(position));
|
||||||
|
} else {
|
||||||
|
intent.putExtra("choseXTitle", bookmarks.get(position));
|
||||||
|
}
|
||||||
intent.putExtra("bookmarkClicked", true);
|
intent.putExtra("bookmarkClicked", true);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
|
@ -713,7 +713,7 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
|||||||
.setAction(ShortcutUtils.stringsGetter(R.string.undo, this), v -> {
|
.setAction(ShortcutUtils.stringsGetter(R.string.undo, this), v -> {
|
||||||
|
|
||||||
if (mWebViews.size() == 1 && prevSize == 1) {
|
if (mWebViews.size() == 1 && prevSize == 1) {
|
||||||
openArticleFromBookmark(tempForUndo.getTitle());
|
openArticleFromBookmarkURL(tempForUndo.getUrl());
|
||||||
} else {
|
} else {
|
||||||
restoreTabAtIndex(tempForUndo.getUrl(), index);
|
restoreTabAtIndex(tempForUndo.getUrl(), index);
|
||||||
selectTab(index);
|
selectTab(index);
|
||||||
@ -1151,11 +1151,16 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
|||||||
refreshBookmarks();
|
refreshBookmarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean openArticleFromBookmark(String bookmarkTitle) {
|
public boolean openArticleFromBookmarkTitle(String bookmarkTitle) {
|
||||||
// Log.d(TAG_KIWIX, "openArticleFromBookmark: " + articleSearchtextView.getText());
|
// Log.d(TAG_KIWIX, "openArticleFromBookmark: " + articleSearchtextView.getText());
|
||||||
return openArticle(ZimContentProvider.getPageUrlFromTitle(bookmarkTitle));
|
return openArticle(ZimContentProvider.getPageUrlFromTitle(bookmarkTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean openArticleFromBookmarkURL(String bookmarkURL) {
|
||||||
|
// Log.d(TAG_KIWIX, "openArticleFromBookmark: " + articleSearchtextView.getText());
|
||||||
|
return openArticle(bookmarkURL);
|
||||||
|
}
|
||||||
|
|
||||||
private void contentsDrawerHint() {
|
private void contentsDrawerHint() {
|
||||||
mLeftDrawerLayout.postDelayed(new Runnable() {
|
mLeftDrawerLayout.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -1391,9 +1396,17 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
|||||||
bookmarks = bookmarksDao.getBookmarks();
|
bookmarks = bookmarksDao.getBookmarks();
|
||||||
|
|
||||||
if (itemClicked) {
|
if (itemClicked) {
|
||||||
String bookmarkChosen = data.getStringExtra("choseX");
|
String bookmarkChosen;
|
||||||
newTab();
|
if (data.getStringExtra("choseXURL") != null) {
|
||||||
openArticleFromBookmark(bookmarkChosen);
|
bookmarkChosen = data.getStringExtra("choseXURL");
|
||||||
|
newTab();
|
||||||
|
getCurrentWebView().loadUrl(bookmarkChosen);
|
||||||
|
} else {
|
||||||
|
newTab();
|
||||||
|
bookmarkChosen = data.getStringExtra("choseXTitle");
|
||||||
|
openArticleFromBookmarkTitle(bookmarkChosen);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshBookmarkSymbol(menu);
|
refreshBookmarkSymbol(menu);
|
||||||
|
@ -59,7 +59,11 @@ public class BookmarksDao {
|
|||||||
* Save {@code searchString} as the most recent search.
|
* Save {@code searchString} as the most recent search.
|
||||||
*/
|
*/
|
||||||
public void saveBookmark(String articleUrl, String articleTitle) {
|
public void saveBookmark(String articleUrl, String articleTitle) {
|
||||||
mDb.persist(new Bookmarks().setBookmarkUrl(articleUrl).setBookmarkTitle(articleTitle));
|
if (articleUrl != null) {
|
||||||
|
mDb.persist(new Bookmarks().setBookmarkUrl(articleUrl).setBookmarkTitle(articleTitle));
|
||||||
|
} else {
|
||||||
|
mDb.persist(new Bookmarks().setBookmarkUrl("null").setBookmarkTitle(articleTitle));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,6 +92,23 @@ public class KiwixDatabase extends SquidDatabase {
|
|||||||
db.execSQL("DROP TABLE IF EXISTS Bookmarks");
|
db.execSQL("DROP TABLE IF EXISTS Bookmarks");
|
||||||
tryCreateTable(Bookmarks.TABLE);
|
tryCreateTable(Bookmarks.TABLE);
|
||||||
BookmarksDao bookmarksDao = new BookmarksDao(this);
|
BookmarksDao bookmarksDao = new BookmarksDao(this);
|
||||||
|
if (ZimContentProvider.getId() != null) {
|
||||||
|
try {
|
||||||
|
InputStream stream = context.openFileInput(ZimContentProvider.getId() + ".txt");
|
||||||
|
String in;
|
||||||
|
if (stream != null) {
|
||||||
|
BufferedReader read = new BufferedReader(new InputStreamReader(stream));
|
||||||
|
while ((in = read.readLine()) != null) {
|
||||||
|
bookmarksDao.saveBookmark(null,in);
|
||||||
|
}
|
||||||
|
Log.d(KiwixMobileActivity.TAG_KIWIX, "Switched to bookmarkfile " + ZimContentProvider.getId());
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
Log.e(KiwixMobileActivity.TAG_KIWIX, "File not found: " + e.toString());
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(KiwixMobileActivity.TAG_KIWIX, "Can not read file: " + e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user