-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb9e5df
commit 445e662
Showing
48 changed files
with
867 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
This is a template project for Android Studio that allows you to create an android webview application in minutes. You can use it to create a simple app for your website or as a starting point for your HTML5 based android app. | ||
|
||
### Getting started | ||
|
||
[Download](https://github.com/slymax/webview/archive/master.zip) or clone this repository and import it into Android Studio. | ||
|
||
### Using a remote source | ||
|
||
If you want to create an app that shows the content of a remote website | ||
|
||
1. uncomment line **24** in `MainActivity.java` and replace `https://example.com` with your url | ||
|
||
```java | ||
mWebView.loadUrl("https://example.com"); | ||
``` | ||
|
||
2. open the `MyWebViewClient.java` file and replace `example.com` on line **15** with your hostname | ||
|
||
```java | ||
hostname = "example.com"; | ||
``` | ||
|
||
### Using a local source | ||
|
||
If you want to create a local HTML5 android app | ||
|
||
1. uncomment line **27** in `MainActivity.java` | ||
|
||
```java | ||
mWebView.loadUrl("file:///android_asset/index.html"); | ||
``` | ||
|
||
2. put all your files (including your `index.html`) in the `assets` directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "com.bootiemashup.app" | ||
minSdkVersion 26 | ||
targetSdkVersion 34 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
namespace 'com.example.app' | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
def appcompat_version = "1.6.1" | ||
|
||
implementation "androidx.appcompat:appcompat:$appcompat_version" | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Applications/Utilities/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "com.bootiemashup.app", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 1, | ||
"versionName": "1.0", | ||
"outputFile": "app-release.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-feature android:name="android.software.leanback" | ||
android:required="false" /> | ||
<uses-feature android:name="android.hardware.touchscreen" | ||
android:required="false" /> | ||
<application | ||
android:allowBackup="true" | ||
android:banner="@drawable/banner320" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" | ||
android:usesCleartextTraffic="true" | ||
tools:ignore="GoogleAppIndexingWarning" | ||
tools:targetApi="m"> | ||
<activity | ||
android:configChanges="orientation|screenSize" | ||
android:name="com.example.app.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:exported="true" | ||
android:name="com.example.app.TvActivity" | ||
android:theme="@style/Theme.Leanback"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
</head> | ||
<body style="font-family: monospace"> | ||
REPLACE THIS FILE WITH YOUR OWN INDEX.HTML | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package com.example.app; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.app.Activity; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.os.Looper; | ||
import android.webkit.WebSettings; | ||
import android.webkit.WebView; | ||
import android.widget.ImageView; | ||
import android.widget.SeekBar; | ||
import android.widget.Toast; | ||
import android.media.AudioManager; | ||
import android.media.MediaPlayer; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
public class MainActivity extends Activity { | ||
boolean DoublePressToExit = false; | ||
Toast toast; | ||
// creating a variable for | ||
// button and media player | ||
Button playBtn, pauseBtn; | ||
|
||
ImageView playbtn; | ||
SeekBar seekBar; | ||
|
||
MediaPlayer mediaPlayer; | ||
|
||
Runnable runnable; | ||
|
||
Handler handler; | ||
|
||
private WebView mWebView; | ||
|
||
@Override | ||
@SuppressLint("SetJavaScriptEnabled") | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
mWebView = findViewById(R.id.activity_main_webview); | ||
WebSettings webSettings = mWebView.getSettings(); | ||
webSettings.setJavaScriptEnabled(true); | ||
mWebView.setWebViewClient(new MyWebViewClient()); | ||
|
||
// REMOTE RESOURCE | ||
mWebView.loadUrl("https://purplescorpion1.github.io/"); | ||
|
||
// LOCAL RESOURCE | ||
// mWebView.loadUrl("file:///android_asset/index.html"); | ||
|
||
playbtn = findViewById(R.id.btnplay); | ||
|
||
playbtn.setOnClickListener(btnClickListen); | ||
|
||
mediaPlayer = new MediaPlayer(); | ||
|
||
handler = new Handler(); | ||
|
||
} | ||
|
||
private View.OnClickListener btnClickListen = new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (mediaPlayer.isPlaying()) { | ||
mediaPlayer.stop(); | ||
playbtn.setImageResource(R.drawable.play); | ||
} else { | ||
playbtn.setImageResource(R.drawable.pause); | ||
PlaySong(); | ||
} | ||
} | ||
}; | ||
|
||
public void PlaySong(){ | ||
Uri uri = Uri.parse("https://c7.radioboss.fm:18205/stream"); | ||
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); | ||
mediaPlayer.reset(); | ||
|
||
try { | ||
mediaPlayer.setDataSource(MainActivity.this, uri); | ||
}catch (Exception e){e.printStackTrace();} | ||
|
||
mediaPlayer.prepareAsync(); | ||
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { | ||
@Override | ||
public void onPrepared(MediaPlayer mp) { | ||
mediaPlayer.start(); | ||
} | ||
}); | ||
|
||
mediaPlayer.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() { | ||
@Override | ||
public void onBufferingUpdate(MediaPlayer mp, int percent) { | ||
|
||
} | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (DoublePressToExit){ | ||
finishAffinity(); | ||
toast.cancel(); | ||
}else { | ||
DoublePressToExit=true; | ||
Toast.makeText(this, "Press Again To Exit", Toast.LENGTH_SHORT).show(); | ||
Handler handler=new Handler(Looper.getMainLooper()); | ||
handler.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
DoublePressToExit=false; | ||
} | ||
},2000); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.app; | ||
|
||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.webkit.WebView; | ||
import android.webkit.WebViewClient; | ||
|
||
class MyWebViewClient extends WebViewClient { | ||
|
||
@Override | ||
public boolean shouldOverrideUrlLoading(WebView view, String url) { | ||
String hostname; | ||
|
||
// YOUR HOSTNAME | ||
hostname = "purplescorpion1.github.io"; | ||
|
||
Uri uri = Uri.parse(url); | ||
if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith(hostname)) { | ||
return false; | ||
} | ||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); | ||
view.getContext().startActivity(intent); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.