Git Product home page Git Product logo

quaestioorg / android-kotlin-webview Goto Github PK

View Code? Open in Web Editor NEW
16.0 6.0 15.0 579 KB

An Android WebView simply converted from Java to Kotlin using the basic Android Studio tool.

Home Page: https://play.google.com/store/apps/details?id=org.quaestio.quaestio.org

License: Apache License 2.0

Kotlin 100.00%
andorid app kotlin kotlin-android webview webview-app android-application kotlin-language webapp web-app

android-kotlin-webview's Introduction

Android Kotlin WebView

API

Description

An Android WebView simply converted from Java to Kotlin using the basic Android Studio tool.

Table of Contents

Installation

  1. Clone the project;
  2. unzip the folder;
  3. run Android Studio;
  4. open a new project;
  5. and pick the package.

Usage

Change the URL indirectly from strings.xml from:

<string name="website_domain">quaestio.org</string>

<string name="website_url">https://quaestio.org</string>

to:

<string name="website_domain">your.url</string>

<string name="website_url">http://your.url</string>

Or change the loadURLdirectly in MainActivity.kt from:

21 mWebView.loadUrl(getString(R.string.website_url))

30 if (Uri.parse(url).host == getString(R.string.website_domain)) {

to:

21 mWebView.loadUrl("http://your.url")

30 if (Uri.parse(url).host == "your.url") {

And don't forget to edit the following lines in the AndroidManifest.xml file:

<data

android:host="quaestio.org"

android:scheme="https" />

Contributing

This sample is open to contributions; please, read Contributing guidelines before opening new issues or submitting pull requests to this repository.

Credits

A live demo can be seen from Quaestio's web app which loads similar Android Kotlin WebView pieces of code.

A special thanks to Vamsi Tallapudi's Android Java WebView sample and CodeRefer's tutorials for the introductory lessons they provided in the past.

Screenshots

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use files of this sample except in compliance with its License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

android-kotlin-webview's People

Contributors

jorgeamvf avatar naxa777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

android-kotlin-webview's Issues

"Redundant override"

This inspection reports redundant 'override' function which can be omitted.

        override fun onPageFinished(view: WebView, url: String) {
            // TODO Auto-generated method stub
            super.onPageFinished(view, url)
        }

Kotlin community members guess it may be a lint issue instead of a real problem:

This looks like a Lint issue. [...]

"Overrides deprecated member in 'android.webkit.WebViewClient'"

This inspection reports deprecated members being overridden.

        override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
            if (Uri.parse(url).host == getString(R.string.website_domain)) {
                return false
            }
            val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
            startActivity(intent)
            return true
        }

The method above was deprecated in API level 24 and must be covered by the one below which:

Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView.

shouldOverrideUrlLoading(WebView view, WebResourceRequest request)

CANNOT CHANGE APP ID WITHOUT BREAKING ERRORS

CANNOT CHANGE APP ID WITHOUT BREAKING ERRORS

"Copy of a Lint report first phrase"
No idea what this is

Reproduction of the warning report.

Modify app ID
Brief description explaining the situation.
Everytime i modify the app id, (org.quaestio.kotlinconvertedwebveiw) to LITERALLY ANYTHING, it returns this error

IDE recommendation

https://i.imgur.com/M5mAzP4.png

the error is for anything using the R. <string variable> frame.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.