Use TextView with ListTagHandler instead of WebView for help
this looks much nicer and removes a problem with german umlauts
This commit is contained in:
parent
d127e98815
commit
3180de4de3
4 changed files with 47 additions and 18 deletions
13
Jenkinsfile
vendored
13
Jenkinsfile
vendored
|
@ -1,10 +1,17 @@
|
|||
stage 'Build'
|
||||
stage 'assemble'
|
||||
node {
|
||||
checkout scm
|
||||
sh "./gradlew clean :android:build"
|
||||
sh "./gradlew clean assembleWithMapsWithAnalyticsforPlay"
|
||||
}
|
||||
|
||||
stage 'lint'
|
||||
node {
|
||||
checkout scm
|
||||
sh "./gradlew lintWithMapsWithAnalyticsforPlayRelease"
|
||||
publishHTML(target:[allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'android/build/outputs/', reportFiles: 'lint-results-withMapsWithAnalyticsForPlayRelease.html', reportName: 'Lint reports'])
|
||||
}
|
||||
|
||||
stage 'UITest'
|
||||
node {
|
||||
sh "./gradlew spoonWithMapsWithAnalyticsforFDroid"
|
||||
sh "./gradlew spoonWithMapsWithAnalyticsforPlay"
|
||||
}
|
|
@ -1,13 +1,17 @@
|
|||
package org.ligi.passandroid.steps;
|
||||
|
||||
import android.support.test.espresso.web.assertion.WebViewAssertions;
|
||||
import org.ligi.passandroid.R;
|
||||
|
||||
import static android.support.test.espresso.web.matcher.DomMatchers.containingTextInBody;
|
||||
import static android.support.test.espresso.web.sugar.Web.onWebView;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public class HelpSteps {
|
||||
|
||||
public static void checkThatHelpIsThere() {
|
||||
onWebView().check(WebViewAssertions.webContent(containingTextInBody("Example passes")));
|
||||
onView(withId(R.id.help_text)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,19 +3,23 @@ package org.ligi.passandroid.ui;
|
|||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.ligi.passandroid.R;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class HelpActivity extends AppCompatActivity {
|
||||
|
||||
@Bind(R.id.help_webview)
|
||||
WebView helpWebView;
|
||||
@Bind(R.id.help_text)
|
||||
TextView helpText;
|
||||
|
||||
@Bind(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
@ -26,16 +30,30 @@ public class HelpActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_help);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
WebSettings webSettings = helpWebView.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setStandardFontFamily("Sans-Serif");
|
||||
final Spanned html = Html.fromHtml(getString(R.string.help_content), null, new ListTagHandler());
|
||||
|
||||
helpWebView.loadData(getString(R.string.help_content),"text/html","utf-8");
|
||||
helpText.setText(html);
|
||||
helpText.setMovementMethod(new LinkMovementMethod());
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (getSupportActionBar()!=null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
class ListTagHandler implements Html.TagHandler {
|
||||
|
||||
@Override
|
||||
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
|
||||
if (tag.equalsIgnoreCase("li")) {
|
||||
if (opening) {
|
||||
output.append("\u2022 ");
|
||||
} else {
|
||||
output.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/help_webview"
|
||||
<TextView
|
||||
android:id="@+id/help_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp"/>
|
||||
|
|
Loading…
Reference in a new issue