Merge remote-tracking branch 'origin/develop' into feature/macgills/modularisation

This commit is contained in:
Sean Mac Gillicuddy 2019-10-16 10:51:01 +01:00
commit 5b484f5f19
4 changed files with 70 additions and 70 deletions

View File

@ -34,8 +34,7 @@ for you. If you prefer to build without Android Studio you must first
set up the Android SDK and then run the command: `./gradlew build `
from the root directory of the project.
We utilize different build variants (flavours) to build various
different versions of our app. Ensure your build variant is
We utilize different build variants (flavors) to build various versions of our app. Ensure your build variant is
`kiwixDebug` to build the standard app.
## Libraries Used

View File

@ -20,22 +20,22 @@
<body class="content">
<h2>Contributors</h2>
<a href="mailto:abdulwd97@gmail.com">Abdul Wadood</a><nr>
<a href="mailto:adeelzafar619@gmail.com">Adeel Zafar</a><br>
<a href="mailto:sood.aditya.08@gmail.com">Aditya Sood</a><br>
<a href="mailto:ayoubuto@gmail.com">Ayoub Dardory</a><br>
<a href="mailto:cip@gmx.at">Christian Pühringer</a><br>
<a href="mailto:elad.keyshawn@gmail.com">Elad Keyshawn</a><br>
<a href="mailto:kelson@kiwix.org">Emmanuel Engelhart</a><br>
<a href="mailto:mhutti1@gmail.com">Isaac Hutt</a><br>
<a href="mailto:joseph.reeve@googlemail.com">Joseph E. Reeve</a><br>
<a href="mailto:julianharty@gmail.com">Julian Harty</a><br>
<a href="mailto:rashiq.z@gmail.com">Rashiq Ahmad</a><br>
<a href="mailto:reg@kiwix.org">Renaud Gaudin</a><br>
<a href="mailto:seantheappdev@gmail.com">Seán Mac Gillicuddy</a><br>
<a href="mailto:ssiddharth2010@gmail.com">Siddharth Sharma</a><br>
<a href="mailto:sm2030@cam.ac.uk">Souradip Mookerjee</a><br>
<a href="https://translatewiki.net/wiki/Translating:Kiwix">Translatewiki community</a><br>
Abdul Wadood<br>
Adeel Zafar<br>
Aditya Sood<br>
Ayoub Dardory<br>
Christian Pühringer<br>
Elad Keyshawn<br>
Emmanuel Engelhart<br>
Isaac Hutt<br>
Joseph E. Reeve<br>
Julian Harty<br>
Rashiq Ahmad<br>
Renaud Gaudin<br>
Seán Mac Gillicuddy<br>
Siddharth Sharma<br>
Souradip Mookerjee<br>
Translatewiki community<br>
<h2>Licenses</h2>

View File

@ -39,44 +39,44 @@ import org.kiwix.kiwixmobile.core.R;
public class CompatFindActionModeCallback
implements ActionMode.Callback, TextWatcher, View.OnClickListener {
public boolean mIsActive;
public boolean isActive;
private View mCustomView;
private View customView;
private EditText mEditText;
private EditText editText;
private TextView mFindResultsTextView;
private TextView findResultsTextView;
private WebView mWebView;
private WebView webView;
private InputMethodManager mInput;
private InputMethodManager input;
private ActionMode mActionMode;
private ActionMode actionMode;
CompatFindActionModeCallback(Context context) {
mCustomView = LayoutInflater.from(context).inflate(R.layout.webview_search, null);
mEditText = mCustomView.findViewById(R.id.edit);
mEditText.setOnClickListener(this);
mFindResultsTextView = mCustomView.findViewById(R.id.find_results);
mInput = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
mIsActive = false;
customView = LayoutInflater.from(context).inflate(R.layout.webview_search, null);
editText = customView.findViewById(R.id.edit);
editText.setOnClickListener(this);
findResultsTextView = customView.findViewById(R.id.find_results);
input = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
isActive = false;
setText("");
}
public void setActive() {
mIsActive = true;
isActive = true;
}
public void finish() {
mActionMode.finish();
mWebView.clearMatches();
actionMode.finish();
webView.clearMatches();
}
// Place text in the text field so it can be searched for. Need to press
// the find next or find previous button to find all of the matches.
public void setText(String text) {
mEditText.setText(text);
Spannable span = mEditText.getText();
editText.setText(text);
Spannable span = editText.getText();
int length = span.length();
// Ideally, we would like to set the selection to the whole field,
@ -95,22 +95,22 @@ public class CompatFindActionModeCallback
throw new AssertionError(
"WebView supplied to CompatFindActionModeCallback cannot be null");
}
mWebView = webView;
this.webView = webView;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mFindResultsTextView.setVisibility(View.VISIBLE);
mWebView.setFindListener((activeMatchOrdinal, numberOfMatches, isDoneCounting) -> {
findResultsTextView.setVisibility(View.VISIBLE);
this.webView.setFindListener((activeMatchOrdinal, numberOfMatches, isDoneCounting) -> {
String result;
if (mEditText.getText().toString().isEmpty()) {
if (editText.getText().toString().isEmpty()) {
result = "";
} else if (numberOfMatches == 0) {
result = "0/0";
} else {
result = (activeMatchOrdinal + 1) + "/" + numberOfMatches;
}
mFindResultsTextView.setText(result);
findResultsTextView.setText(result);
});
} else {
mFindResultsTextView.setVisibility(View.GONE);
findResultsTextView.setVisibility(View.GONE);
}
}
@ -119,31 +119,31 @@ public class CompatFindActionModeCallback
// If false, find the previous match, up in the document.
private void findNext(boolean next) {
if (mWebView == null) {
if (webView == null) {
throw new AssertionError("No WebView for CompatFindActionModeCallback::findNext");
}
mWebView.findNext(next);
webView.findNext(next);
}
// Highlight all the instances of the string from mEditText in mWebView.
public void findAll() {
if (mWebView == null) {
if (webView == null) {
throw new AssertionError("No WebView for CompatFindActionModeCallback::findAll");
}
CharSequence find = mEditText.getText();
CharSequence find = editText.getText();
if (find.length() == 0) {
mWebView.clearMatches();
webView.clearMatches();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mWebView.findAllAsync(null);
webView.findAllAsync(null);
} else {
mWebView.findAll(null);
webView.findAll(null);
}
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mWebView.findAllAsync(find.toString());
webView.findAllAsync(find.toString());
} else {
mWebView.findAll(find.toString());
webView.findAll(find.toString());
}
// Enable word highlighting with reflection
@ -151,7 +151,7 @@ public class CompatFindActionModeCallback
for (Method ms : WebView.class.getDeclaredMethods()) {
if (ms.getName().equals("setFindIsUp")) {
ms.setAccessible(true);
ms.invoke(mWebView, true);
ms.invoke(webView, true);
break;
}
}
@ -163,14 +163,15 @@ public class CompatFindActionModeCallback
// Show on screen keyboard
public void showSoftInput() {
mEditText.requestFocus();
mEditText.setFocusable(true);
mEditText.setFocusableInTouchMode(true);
mEditText.requestFocusFromTouch();
//wait for any hidden show/hide processes to finish
editText.postDelayed(() -> {
editText.requestFocus();
//show the keyboard
input.showSoftInput(editText, 0);
}, 100);
if (mEditText.requestFocus()) {
mInput.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}
}
@Override
@ -180,21 +181,21 @@ public class CompatFindActionModeCallback
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mode.setCustomView(mCustomView);
mode.setCustomView(customView);
mode.getMenuInflater().inflate(R.menu.menu_webview, menu);
mActionMode = mode;
Editable edit = mEditText.getText();
actionMode = mode;
Editable edit = editText.getText();
Selection.setSelection(edit, edit.length());
mEditText.requestFocus();
editText.requestFocus();
return true;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
mActionMode = null;
mIsActive = false;
mWebView.clearMatches();
mInput.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
actionMode = null;
isActive = false;
webView.clearMatches();
input.hideSoftInputFromWindow(webView.getWindowToken(), 0);
}
@Override
@ -204,12 +205,12 @@ public class CompatFindActionModeCallback
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
if (mWebView == null) {
if (webView == null) {
throw new AssertionError(
"No WebView for CompatFindActionModeCallback::onActionItemClicked");
}
mInput.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
input.hideSoftInputFromWindow(webView.getWindowToken(), 0);
int itemId = item.getItemId();
if (itemId == R.id.find_prev) {

View File

@ -572,7 +572,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
hideTabSwitcher();
} else if (isFullscreenOpened) {
closeFullScreen();
} else if (compatCallback.mIsActive) {
} else if (compatCallback.isActive) {
compatCallback.finish();
} else if (drawerLayout.isDrawerOpen(GravityCompat.END)) {
drawerLayout.closeDrawers();