mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-24 05:04:50 -04:00
#1031 Delete webview history when user clears Histry in HistoryActivity
This commit is contained in:
parent
3a449b149f
commit
4fd58b5aeb
@ -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,37 +1654,45 @@ 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) {
|
||||||
String title = data.getStringExtra(EXTRA_CHOSE_X_TITLE);
|
if (data.getBooleanExtra(HistoryActivity.USER_CLEARED_HISTORY, false)) {
|
||||||
String url = data.getStringExtra(EXTRA_CHOSE_X_URL);
|
for (KiwixWebView kiwixWebView : webViewList) {
|
||||||
if (data.getData() != null) {
|
kiwixWebView.clearHistory();
|
||||||
final Uri uri = data.getData();
|
|
||||||
File file = null;
|
|
||||||
if (uri != null) {
|
|
||||||
String path = uri.getPath();
|
|
||||||
if (path != null) {
|
|
||||||
file = new File(path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (file == null) {
|
webViewList.clear();
|
||||||
Toast.makeText(this, R.string.error_file_not_found, Toast.LENGTH_LONG).show();
|
newTab(HOME_URL);
|
||||||
|
} else {
|
||||||
|
String title = data.getStringExtra(EXTRA_CHOSE_X_TITLE);
|
||||||
|
String url = data.getStringExtra(EXTRA_CHOSE_X_URL);
|
||||||
|
if (data.getData() != null) {
|
||||||
|
final Uri uri = data.getData();
|
||||||
|
File file = null;
|
||||||
|
if (uri != null) {
|
||||||
|
String path = uri.getPath();
|
||||||
|
if (path != null) {
|
||||||
|
file = new File(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file == null) {
|
||||||
|
Toast.makeText(this, R.string.error_file_not_found, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Intent zimFile = new Intent(MainActivity.this, MainActivity.class);
|
||||||
|
zimFile.setData(uri);
|
||||||
|
if (url != null) {
|
||||||
|
zimFile.putExtra(EXTRA_CHOSE_X_URL, url);
|
||||||
|
} else if (title != null) {
|
||||||
|
zimFile.putExtra(EXTRA_CHOSE_X_URL, ZimContentProvider.getPageUrlFromTitle(title));
|
||||||
|
}
|
||||||
|
startActivity(zimFile);
|
||||||
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Intent zimFile = new Intent(MainActivity.this, MainActivity.class);
|
newTab();
|
||||||
zimFile.setData(uri);
|
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
zimFile.putExtra(EXTRA_CHOSE_X_URL, url);
|
getCurrentWebView().loadUrl(url);
|
||||||
} else if (title != null) {
|
} else if (title != null) {
|
||||||
zimFile.putExtra(EXTRA_CHOSE_X_URL, ZimContentProvider.getPageUrlFromTitle(title));
|
getCurrentWebView().loadUrl(ZimContentProvider.getPageUrlFromTitle(title));
|
||||||
}
|
}
|
||||||
startActivity(zimFile);
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
newTab();
|
|
||||||
if (url != null) {
|
|
||||||
getCurrentWebView().loadUrl(url);
|
|
||||||
} else if (title != null) {
|
|
||||||
getCurrentWebView().loadUrl(ZimContentProvider.getPageUrlFromTitle(title));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user