Skip to content

Commit c899249

Browse files
committedMay 31, 2020
- encryptMsg error resolved and all URL not open inside webview
1 parent a2911d5 commit c899249

File tree

6 files changed

+133
-137
lines changed

6 files changed

+133
-137
lines changed
 

‎Android-WebView-in-Kotlin.iml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id="Android-WebView-in-Kotlin" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="java-gradle" name="Java-Gradle">
5+
<configuration>
6+
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
7+
<option name="BUILDABLE" value="false" />
8+
</configuration>
9+
</facet>
10+
</component>
11+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
12+
<exclude-output />
13+
<content url="file://$MODULE_DIR$">
14+
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
15+
</content>
16+
<orderEntry type="inheritedJdk" />
17+
<orderEntry type="sourceFolder" forTests="false" />
18+
</component>
19+
</module>

‎README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Android WebView Example with Kotlin. Website to Native Android App Template.
1+
# Android WebView Example with Kotlin. Website to Native Android App Template.
22

33

44
## Description
@@ -11,26 +11,26 @@ An [Android WebView](https://d.android.com/guide/webapps/webview) developed in [
1111
Android web view is web-based content which came from “*android.webkit*” library. The concept of web view is its load offline or online webpage.
1212

1313
**Online web view**: If you have a website which is responsive and runs well on the mobile browser then using web view you can develop android or ios app. Which load the URL and fill like Android app.
14-
14+
1515
**Offline web view**: If you want to load the webpage in offline then the logic keeps the file in your asset folder and load the offline page. But in that case, you can’t use the server database and can’t update the app without publishing.
16-
16+
1717
**Native app vs cross-platform web view app?**
1818
Web view app possible to develop in both platform. Both app main concept is the same.
1919

2020
**Native APP**: Native app is official to provide a platform. Android official platform is Android studio which uses Java or Kotlin language. Because of it’s official so the resource is available and you get some advantage of using it.
21-
21+
2222
**Cross-platform**: Cross app is an unofficial platform. Xamarin & flutter one of them. The benefit is you get Android and iOS both app from one platform. But the resource is limited some time it’s paid.
2323
From my experience I suggest must use Native app because of it’s official and in future if you need to add anything then easy to integrate.
2424

2525
**Is it possible to change web view UI?**
2626
The web view is loading your website. So all it’s show that you have on your website. Not possible to change anything inside the web view. But if you can change the app color, add multiple pages, use AdMob, firebase, one signal notification, etc.
2727

2828
**How to use it?**
29-
Just set your website url on *MainActivity.kt* as URL.
29+
Just set your website url on *MainActivity.kt* as URL.
3030
```
3131
internal var URL = "https://www.infixsoft.com/"
3232
```
33-
Here is the video tutorial: https://youtu.be/c5AlbZKKsUk
33+
Here is the video tutorial: https://youtu.be/c5AlbZKKsUk
3434

3535
*****************************************************************************
3636

@@ -40,7 +40,7 @@ Here is the video tutorial: https://youtu.be/c5AlbZKKsUk
4040

4141
+++++++ . . . . . +++++++ . . . . . +++++++ . . . . . +++++++
4242

43-
**RocketWeb is the pro version of the webview, where availabe multiple color control and theme,** see live example:
43+
**RocketWeb is the pro version of the webview, where availabe multiple color control and theme,** see live example:
4444
<br>
4545
<a href="https://play.google.com/store/apps/details?id=infix.imrankst1221.rocket.web">https://play.google.com/store/apps/details?id=infix.imrankst1221.rocket.web</a>
4646
<br>
@@ -49,7 +49,7 @@ Here is the video tutorial: https://youtu.be/c5AlbZKKsUk
4949
</a>
5050
<br>
5151

52-
Buy pro version of webview only at $20
52+
For better experience and customiation use RocketWeb:s
5353
<br>
5454
<a href="https://codecanyon.net/item/rocketweb-android-web-app-solution-webtoapp/22985174">https://codecanyon.net/item/rocketweb-android-web-app-solution-webtoapp/22985174</a>
5555
<br>
@@ -78,6 +78,6 @@ Buy pro version of webview only at $20
7878

7979

8080

81-
* Buy me a Coffee. ☕️
82-
83-
<a href="https://www.paypal.me/imrankst1221" target="_blank"><img src="https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg" width="100" height="40" style="margin-bottom:-15px;"></a>
81+
* Buy me a Coffee. ☕️
82+
83+
<a href="https://www.paypal.me/imrankst1221" target="_blank"><img src="https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg" width="100" height="40" style="margin-bottom:-15px;"></a>

‎app/app.iml

+74-100
Large diffs are not rendered by default.

‎app/src/main/java/imrankst1221/website/in/webview/MainActivity.kt

+25-22
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MainActivity : Activity() {
9393
/** If you want to show adMob */
9494
//showAdMob();
9595

96-
var secret: SecretKey? = null
96+
/*var secret: SecretKey? = null
9797
val toEncrypt = URL
9898
try {
9999
secret = generateKey()
@@ -104,7 +104,7 @@ class MainActivity : Activity() {
104104
Log.d(TAG, decryptMsg(toDecrypt, secret))
105105
} catch (e: Exception) {
106106
Log.e(TAG, "" + e.message)
107-
}
107+
}*/
108108

109109
}
110110

@@ -165,16 +165,19 @@ class MainActivity : Activity() {
165165

166166
Log.d(TAG, "URL: " + url!!)
167167
if (internetCheck(mContext)) {
168-
//view.loadUrl(url);
168+
// If you wnat to open url inside then use
169+
view.loadUrl(url);
170+
169171
// if you wanna open outside of app
170-
if (url != null && url.startsWith(URL)) {
172+
/*if (url.contains(URL)) {
171173
view.loadUrl(url)
172174
return false
173-
}
174-
// Otherwise, give the default behavior (open in browser)
175-
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
176-
startActivity(intent)
177-
return true
175+
}else {
176+
// Otherwise, give the default behavior (open in browser)
177+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
178+
startActivity(intent)
179+
return true
180+
}*/
178181
} else {
179182
prgs.visibility = View.GONE
180183
mWebView.visibility = View.GONE
@@ -359,17 +362,17 @@ class MainActivity : Activity() {
359362

360363
private fun showAdMob() {
361364
/** Layout of AdMob screen View */
362-
//layoutFooter = (LinearLayout) findViewById(R.id.layout_footer);
363-
//adView = (AdView) findViewById(R.id.adMob);
364-
/*try {
365-
if(internetCheck(mContext)){
366-
//initializeAdMob();
367-
}else{
368-
Log.d("---------","--no internet-");
369-
}
370-
}catch (Exception ex){
371-
Log.d("-----------", ""+ex);
372-
}*/
365+
/*layoutFooter = (LinearLayout) findViewById(R.id.layout_footer);
366+
adView = (AdView) findViewById(R.id.adMob);
367+
try {
368+
if(internetCheck(mContext)){
369+
//initializeAdMob();
370+
}else{
371+
Log.d("---------","--no internet-");
372+
}
373+
}catch (Exception ex){
374+
Log.d("-----------", ""+ex);
375+
}*/
373376
}
374377

375378
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
@@ -404,7 +407,7 @@ class MainActivity : Activity() {
404407
return SecretKeySpec(key, "AES")
405408
}
406409

407-
@Throws(NoSuchAlgorithmException::class, NoSuchPaddingException::class, InvalidKeyException::class, InvalidParameterSpecException::class, IllegalBlockSizeException::class, BadPaddingException::class, UnsupportedEncodingException::class)
410+
/*@Throws(NoSuchAlgorithmException::class, NoSuchPaddingException::class, InvalidKeyException::class, InvalidParameterSpecException::class, IllegalBlockSizeException::class, BadPaddingException::class, UnsupportedEncodingException::class)
408411
fun encryptMsg(message: String, secret: SecretKey): ByteArray {
409412
var cipher: Cipher? = null
410413
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding")
@@ -418,7 +421,7 @@ class MainActivity : Activity() {
418421
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding")
419422
cipher!!.init(Cipher.DECRYPT_MODE, secret)
420423
return String(cipher.doFinal(cipherText), charset("UTF-8"))
421-
}
424+
}*/
422425

423426

424427
/**** Initial AdMob */

‎build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.41'
4+
ext.kotlin_version = '1.3.71'
55
repositories {
66
jcenter()
77
maven {
@@ -11,7 +11,7 @@ buildscript {
1111
google()
1212
}
1313
dependencies {
14-
classpath 'com.android.tools.build:gradle:3.4.2'
14+
classpath 'com.android.tools.build:gradle:3.5.3'
1515
classpath 'com.google.gms:google-services:4.3.0'
1616
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1717
// NOTE: Do not place your application dependencies here; they belong
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Jul 17 20:39:37 BDT 2019
1+
#Sun May 31 13:14:05 BDT 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

0 commit comments

Comments
 (0)
Please sign in to comment.