mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 20:54:13 -04:00
Merge pull request #1451 from kiwix/feature/macgills/#1031-clear-webview-history
#1031 Delete webview history when user clears History in HistoryActivity
This commit is contained in:
commit
13c86ec0d1
@ -36,6 +36,7 @@ public class HistoryActivity extends BaseActivity implements HistoryContract.Vie
|
|||||||
private final List<HistoryListItem> fullHistory = new ArrayList<>();
|
private final List<HistoryListItem> fullHistory = new ArrayList<>();
|
||||||
private final List<HistoryListItem> deleteList = new ArrayList<>();
|
private final List<HistoryListItem> deleteList = new ArrayList<>();
|
||||||
private static final String LIST_STATE_KEY = "recycler_list_state";
|
private static final String LIST_STATE_KEY = "recycler_list_state";
|
||||||
|
public static final String USER_CLEARED_HISTORY = "user_cleared_history";
|
||||||
|
|
||||||
@BindView(R.id.toolbar)
|
@BindView(R.id.toolbar)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@ -192,6 +193,7 @@ public class HistoryActivity extends BaseActivity implements HistoryContract.Vie
|
|||||||
fullHistory.clear();
|
fullHistory.clear();
|
||||||
historyList.clear();
|
historyList.clear();
|
||||||
historyAdapter.notifyDataSetChanged();
|
historyAdapter.notifyDataSetChanged();
|
||||||
|
setResult(RESULT_OK, new Intent().putExtra(USER_CLEARED_HISTORY, true));
|
||||||
Toast.makeText(this, R.string.all_history_cleared_toast, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.all_history_cleared_toast, Toast.LENGTH_SHORT).show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1654,6 +1654,13 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
case REQUEST_FILE_SELECT:
|
case REQUEST_FILE_SELECT:
|
||||||
case REQUEST_HISTORY_ITEM_CHOSEN:
|
case REQUEST_HISTORY_ITEM_CHOSEN:
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
|
if (data.getBooleanExtra(HistoryActivity.USER_CLEARED_HISTORY, false)) {
|
||||||
|
for (KiwixWebView kiwixWebView : webViewList) {
|
||||||
|
kiwixWebView.clearHistory();
|
||||||
|
}
|
||||||
|
webViewList.clear();
|
||||||
|
newTab(HOME_URL);
|
||||||
|
} else {
|
||||||
String title = data.getStringExtra(EXTRA_CHOSE_X_TITLE);
|
String title = data.getStringExtra(EXTRA_CHOSE_X_TITLE);
|
||||||
String url = data.getStringExtra(EXTRA_CHOSE_X_URL);
|
String url = data.getStringExtra(EXTRA_CHOSE_X_URL);
|
||||||
if (data.getData() != null) {
|
if (data.getData() != null) {
|
||||||
@ -1687,6 +1694,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
getCurrentWebView().loadUrl(ZimContentProvider.getPageUrlFromTitle(title));
|
getCurrentWebView().loadUrl(ZimContentProvider.getPageUrlFromTitle(title));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user