Skip to content

mgks/Android-SmartWebView

Repository files navigation

Android Smart WebView

Smart WebView Icon

Variant GitHub Release GitHub License

Android Smart WebView is a modern, open-source solution for building advanced hybrid Android apps. It allows you to effortlessly extend your app with plugins, native features, and a customizable UI.

DOCUMENTATION | GET PLUGINS | ISSUES

Core Features

  • Plugin Architecture: Extend app functionality with self-registering plugins. See the PluginInterface.java, PluginManager.java, and existing plugins in /plugins/ for details.
  • File Uploads & Camera Access: Support for file selection and direct camera capture in WebView.
  • Push Notifications: Integrated Firebase Cloud Messaging (requires google-services.json).
  • Google Analytics: Built-in support (configure GTAG ID in SmartWebView.java).
  • Custom UI Modes: Fullscreen and drawer layouts (configurable in SmartWebView.java).
  • Location & Permissions: Access device GPS/location and manage permissions.
  • Content Sharing: Receive and handle shared content from other apps via ShareActivity.java.
  • Downloads & Printing: Handle file downloads and print web content.
  • Modern WebView: Secure, up-to-date, and highly configurable via SmartWebView.java and MainActivity.java.

Plugin System (v7.1+)

Smart WebView features a plugin system to add new features with minimal effort.

  • Understanding Plugins:
    • The core contract is defined in PluginInterface.java.
    • Plugin lifecycle and registration are managed by PluginManager.java.
    • Example plugins (AdMobPlugin.java, JSInterfacePlugin.java, ToastPlugin.java) are located in /plugins/. These serve as excellent references for creating new plugins.
  • Testing Plugins:
    • Playground.java is used to configure, test, and demonstrate plugin functionality during development.
  • Included Plugins: The project includes an example plugin for Toasts. Plugins are designed to be self-registering.
  • Premium Plugins: List of premium plugins for Project Sponsors.

Quick Start

  1. Clone the repository:
    git clone https://github.com/mgks/Android-SmartWebView.git
  2. Open in Android Studio:
    • File > Open > Select the project folder
  3. Add google-services.json:
    • If you plan to use Firebase services (like FCM for push notifications), obtain your google-services.json file from the Firebase console and place it in the app/ directory.
  4. Build & Run:
    • Build > Clean Project then Build > Rebuild Project

Basic Configuration

Most configuration is done within SmartWebView.java:

  • Main Application URL:
    • Set ASWV_APP_URL to your web application's address.
    • ASWV_OFFLINE_URL (file:///android_asset/offline.html) is used if ASWV_APP_URL points to a local file or if no internet is detected (and ASWP_OFFLINE logic permits).
  • Feature Toggles:
    • Enable or disable features (file uploads, camera access, location services, pull-to-refresh, etc.) by modifying the boolean ASWP_* variables.
  • Permissions:
    • Review and adjust permissions in AndroidManifest.xml based on the features you enable. For example, CAMERA for camera uploads, ACCESS_FINE_LOCATION for GPS.
  • Adding/Modifying Plugins:
    • Plugins are Java classes that implement PluginInterface.
    • They typically self-register with the PluginManager using a static block.
    • Refer to the existing plugins in the /plugins/ directory for examples on how to create and integrate them.

Further Information & Understanding the Code

The best way to understand the project in depth is to explore the source code:

  • SmartWebView.java: Contains most global configurations and constants.
  • MainActivity.java: The main entry point, handles WebView setup, and integrates core features.
  • Functions.java: Utility functions used throughout the app.
  • PluginInterface.java, PluginManager.java, Playground.java: Key components of the plugin architecture.
  • The /plugins/ directory: Contains example plugin implementations.
  • Inline comments throughout the code provide additional context.

Contributing & Support

License

This project is licensed under the MIT License.

For new developers: Programming can be challenging at times, but with practice and persistence, you can develop the skills to create amazing things. The beauty of programming is that it empowers you to bring your ideas to life and create your own world. Keep exploring & experimenting, and all the best for your next project!