Merge pull request #3923 from keymanapp/fix/fv/android/force-keyboard-setup

fix(android/oem): Check keyboard selected  before allowing setup
This commit is contained in:
Darcy Wong 2020-11-26 11:06:06 +07:00 • committed by GitHub
commit 63d92cd05b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 179 additions and 146 deletions

View file

@ -0,0 +1,8 @@
root = true
; applies to all files
[*]
indent_style = space
[*.{java, sh, css, html, xml}]
indent_size = 4

View file

@ -1,35 +1,35 @@
@font-face {
font-family: "Nunito";
src: url("nunito-regular-webfont.eot");
src: url("nunito-regular-webfont.eot");
src: url("nunito-regular-webfont.ttf") format("truetype"),
url("nunito-regular-webfont.otf") format("opentype"),
url("nunito-regular-webfont.otf") format("opentype"),
url("nunito-regular-webfont.woff") format("woff"),
url("nunito-regular-webfont.svg#nunitoregular") format("svg");
}
@font-face {
font-family: "Open Sans";
src: url("opensans-regular-webfont.eot");
src: url("opensans-regular-webfont.eot");
src: url("opensans-regular-webfont.ttf") format("truetype"),
url("opensans-regular-webfont.otf") format("opentype"),
url("opensans-regular-webfont.otf") format("opentype"),
url("opensans-regular-webfont.woff") format("woff"),
url("opensans-regular-webfont.svg#open_sansregular") format("svg");
}
html, body{
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
padding: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
padding: 0;
}
html{
margin: 0;
min-height: 100%;
position: relative;
margin: 0;
min-height: 100%;
position: relative;
}
body{
background: #f7511e;
background: #f7511e;
background: -moz-linear-gradient(25deg, #f7511e 0%, #aa1225 55%, #9f031f 100%);
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#f7511e), color-stop(55%,#aa1225), color-stop(100%,#9f031f));
background: -webkit-linear-gradient(25deg, #f7511e 0%,#aa1225 55%,#9f031f 100%);
@ -37,19 +37,19 @@ body{
background: -ms-linear-gradient(25deg, #f7511e 0%,#aa1225 55%,#9f031f 100%);
/*background: linear-gradient(25deg, #f7511e 0%,#aa1225 55%,#9f031f 100%);*/
color: #fff;
font-family: 'Open Sans';
margin: 0 0 200px 0;
color: #fff;
font-family: 'Open Sans';
margin: 0 0 200px 0;
}
#instructions{
padding: 0 30px 10px;
width: calc(100% - 60px);
padding: 0 30px 10px;
width: calc(100% - 60px);
}
#instructions p{
font-size: 0.875em;
margin: 15px 0;
font-size: 0.875em;
margin: 15px 0;
}
#logo {
@ -59,8 +59,8 @@ body{
}
#logo img{
max-width: 400px;
width: 100%;
max-width: 400px;
width: 100%;
}
#logo p{
@ -73,44 +73,44 @@ body{
}
h2{
color: #ffd988;
font-family: 'Nunito';
font-size: 1.25em;
font-weight: normal;
color: #ffd988;
font-family: 'Nunito';
font-size: 1.25em;
font-weight: normal;
}
.steps{
display: table;
width: 100%;
display: table;
width: 100%;
}
.step{
display: table-row;
display: table-row;
}
.step-number, .step-instruction{
border-bottom: 1px solid #A0BC76;
display: table-cell;
vertical-align: top;
border-bottom: 1px solid #A0BC76;
display: table-cell;
vertical-align: top;
}
.step-number{
width: 80px;
width: 80px;
}
.step-number img{
display: block;
height: 30px;
margin: 15px auto;
width: 30px;
-webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.2));
filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.2));
display: block;
height: 30px;
margin: 15px auto;
width: 30px;
-webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.2));
filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.2));
}
.step-number span {
display: block;
height: 30px;
line-height: 30px;
line-height: 25px;
margin: 15px auto;
width: 30px;
-webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.2));
@ -123,39 +123,56 @@ h2{
color: white;
text-align: center;
font-family: 'Nunito';
font-size: 1.5em;
font-size: 1.0em;
font-weight: bold;
}
.steps.use .step-number, .steps.use .step-instruction{
border-bottom: 0 none;
border-bottom: 0 none;
}
.step-instruction{
margin-top: 10px;
margin-top: 10px;
}
.step-instruction img{
-webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
height: 30px;
margin-right: 5px;
vertical-align: top;
width: 30px;
opacity: 0.25;
.step-instruction span{
display: inline-block;
-webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
height: 30px;
margin-right: 5px;
vertical-align: top;
width: 30px;
}
.step-instruction input[type="button"]{
background-color: #DDDDDD;
border: 0 none;
border-radius: 5px;
color: #333;
-webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
height: 30px;
line-height: 30px;
text-transform: uppercase;
width: 150px;
background-color: #DDDDDD;
border: 0 none;
border-radius: 5px;
color: #333;
-webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.1));
height: 30px;
line-height: 30px;
width: 150px;
}
.checkIconOff {
alt: 'CheckBoxOff';
background: url('check-off.png');
background-size: contain;
opacity: 0;
}
.checkIconOn {
alt: 'CheckBoxOn';
background: url('check-on.png');
background-size: contain;
opacity: 1.0;
}
#button2:disabled {
opacity: 0.25;
}
#supporters{
@ -207,9 +224,9 @@ h2{
}
#footer{
background-color: #605E4B;
color: #CFCEC8;
height: 200px;
background-color: #605E4B;
color: #CFCEC8;
height: 200px;
bottom: 0;
left: 0;
position: absolute;
@ -218,15 +235,15 @@ h2{
}
#footer h2, #footer a{
color: #CFCEC8;
color: #CFCEC8;
}
#footer p{
font-size: 0.875em;
margin: 5px 0;
font-size: 0.875em;
margin: 5px 0;
}
#footer img{
height: auto;
width: 50px;
height: auto;
width: 50px;
}

View file

@ -1,99 +1,106 @@
<!DOCTYPE html>
<html>
<head>
<title>FirstVoices Keyboards installation</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" name="viewport">
<link rel="stylesheet" type="text/css" href="android-instructions.css" />
<script language="JavaScript">
function showSetup() {
window.jsInterface.showSetup();
}
<head>
<title>FirstVoices Keyboards installation</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" name="viewport">
<link rel="stylesheet" type="text/css" href="android-instructions.css" />
<script language="JavaScript">
function showSetup() {
window.jsInterface.showSetup();
}
function showRegionList() {
window.jsInterface.showRegionList();
}
function showRegionList() {
window.jsInterface.showRegionList();
}
function setCheckBox1On() {
var checkbox1 = document.getElementById("checkbox1");
if (checkbox1.src != "check-on.png") {
checkbox1.src = "check-on.png";
checkbox1.style.opacity = 1.0;
}
}
function setCheckBoxOn(id) {
var checkbox = document.getElementById(id);
if (checkbox) {
if (checkbox.className != "checkIconOn") {
checkbox.className = "checkIconOn";
}
function setCheckBox1Off() {
var checkbox1 = document.getElementById("checkbox1");
if (checkbox1.src != "check-off.png") {
checkbox1.src = "check-off.png";
checkbox1.style.opacity = 0.25;
}
}
if (id == "checkbox1") {
enableButton2();
}
}
}
function setCheckBox2On() {
var checkbox2 = document.getElementById("checkbox2");
if (checkbox2.src != "check-on.png") {
checkbox2.src = "check-on.png";
checkbox2.style.opacity = 1.0;
}
}
function setCheckBoxOff(id) {
var checkbox = document.getElementById(id);
if (checkbox) {
if (checkbox.className != "checkIconOff") {
checkbox.className = "checkIconOff";
}
function setCheckBox2Off() {
var checkbox2 = document.getElementById("checkbox2");
if (checkbox2.src != "check-off.png") {
checkbox2.src = "check-off.png";
checkbox2.style.opacity = 0.25;
}
}
</script>
</head>
if (id == "checkbox1") {
disableButton2();
}
}
}
<body>
function disableButton2() {
var button2 = document.getElementById("button2");
button2.disabled = true;
}
<div id="instructions">
<div id="logo">
<img src="firstvoices-logo.gif" alt="FirstVoices" />
<p>Keyboards</p>
</div>
function enableButton2() {
var button2 = document.getElementById("button2");
button2.disabled = false;
}
</script>
</head>
<body>
<div id="instructions">
<div id="logo">
<img src="firstvoices-logo.gif" alt="FirstVoices" />
<p>Keyboards</p>
</div>
<h2>Installation instructions</h2>
<div class="steps">
<div class="step">
<div class="step-number"><span>1</span></div>
<div class="step-instruction">
<p><input type="button" value="Select keyboards" onclick="showRegionList()" id="button1" /> <img src="check-off.png" alt="CheckBox" class="checkicon" id="checkbox1" /></p>
<p><input type="button" value="Select keyboards" onclick="showRegionList()" id="button1" />
<span class="checkIconOff" id="checkbox1"></span></p>
</div>
</div>
<div class="step">
<div class="step-number"><span>2</span></div>
<div class="step-instruction">
<p><input type="button" value="Setup" onclick="showSetup()" id="button2" /> <img src="check-off.png" alt="CheckBox" class="checkicon" id="checkbox2" /></p>
<!-- Setup disabled until a keyboard is selected -->
<p><input type="button" value="Setup" onclick="showSetup()" id="button2" disabled />
<span class="checkIconOff" id="checkbox2"></span></p>
</div>
</div>
</div>
<h2>To use FirstVoices Keyboards</h2>
<p>After completing these steps above, selected FirstVoices keyboards will be available on your Android device.</p>
</div>
<h2>To use FirstVoices Keyboards</h2>
<p>After completing these steps above, selected FirstVoices keyboards will be available on your Android device.</p>
</div>
<div id="supporters">
<p>FirstVoices gratefully acknowledges the following supporters of this project:</p>
<a href="http://www.newrelationshiptrust.ca/"><img src="nrt.svg" alt="" /></a>
<a href="http://www.fpcc.ca/"><img src="fpcc.svg" alt="" /></a>
<a href="http://www.languagegeek.com/"><img src="languagegeek.png" alt="" /></a>
</div>
<div id="supporters">
<p>FirstVoices gratefully acknowledges the following supporters of this project:</p>
<a href="http://www.newrelationshiptrust.ca/"><img src="nrt.svg" alt="" /></a>
<a href="http://www.fpcc.ca/"><img src="fpcc.svg" alt="" /></a>
<a href="http://www.languagegeek.com/"><img src="languagegeek.png" alt="" /></a>
</div>
<div id="donation">
<p>If you like this app please consider supporting FirstVoices by donating to the First Peoples' Cultural Foundation</p>
<p><a href="http://fpcf.ca/donate-now/">Donate</a></p>
</div>
<div id="donation">
<p>If you like this app please consider supporting FirstVoices by donating to the First Peoples' Cultural Foundation</p>
<p><a href="http://fpcf.ca/donate-now/">Donate</a></p>
</div>
<div id="footer">
<h2>Developed by</h2>
<img src="keyman.svg" alt="" />
<p>SIL International</p>
<p><a href="http://www.keyman.com">www.keyman.com</a></p>
</div>
<div id="footer">
<h2>Developed by</h2>
<img src="keyman.svg" alt="" />
<p>SIL International</p>
<p><a href="https://www.keyman.com">www.keyman.com</a></p>
</div>
</body>
</body>
</html>

View file

@ -10,6 +10,7 @@ import android.webkit.JavascriptInterface;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
import io.sentry.android.core.SentryAndroid;
@ -120,14 +121,14 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onPageFinished(WebView view, String url) {
if (didCompleteSelectKeyboard())
view.loadUrl("javascript:setCheckBox1On();");
view.loadUrl("javascript:setCheckBoxOn('checkbox1');");
else
view.loadUrl("javascript:setCheckBox1Off();");
view.loadUrl("javascript:setCheckBoxOff('checkbox1');");
if (didCompleteSetup())
view.loadUrl("javascript:setCheckBox2On();");
view.loadUrl("javascript:setCheckBoxOn('checkbox2');");
else
view.loadUrl("javascript:setCheckBox2Off();");
view.loadUrl("javascript:setCheckBoxOff('checkbox2');");
}
});
@ -141,14 +142,14 @@ public class MainActivity extends AppCompatActivity {
WebView webView = findViewById(R.id.webView);
if (webView != null) {
if (didCompleteSelectKeyboard())
webView.loadUrl("javascript:setCheckBox1On();");
webView.loadUrl("javascript:setCheckBoxOn('checkbox1');");
else
webView.loadUrl("javascript:setCheckBox1Off();");
webView.loadUrl("javascript:setCheckBoxOff('checkbox1');");
if (didCompleteSetup())
webView.loadUrl("javascript:setCheckBox2On();");
webView.loadUrl("javascript:setCheckBoxOn('checkbox2');");
else
webView.loadUrl("javascript:setCheckBox2Off();");
webView.loadUrl("javascript:setCheckBoxOff('checkbox2');");
}
}
@ -197,7 +198,7 @@ public class MainActivity extends AppCompatActivity {
}
}
private boolean didCompleteSelectKeyboard() {
private static boolean didCompleteSelectKeyboard() {
return FVShared.getInstance().activeKeyboardCount() > 0;
}