Giter Site home page Giter Site logo

app_blocker's Introduction

App Blocker & App Redirect (app_blocker) Plugin

This is a modified app blocker plugin which is used to open your app when any restricted app (set by user) is opened. So, it works like an app redirect plugin. Works only on Android.

Getting Started

To use this package, add this package as the dependency to your flutter app. Then follows these steps.
In your flutter main function use this code to configure AppRedirect plugin.

 if(Platform.isAndroid) { 
	AppBlocker appBlocker = AppBlocker(); 
	appBlocker.configure(onResume: (packageName) async {
		appBlocker.bringAppToFront(); 
	}, onBackgroundMessage: null); 
 }

The above code will configure the the AppBlocker/App Redirect Plugin for use.

Then as required, you can call methods on appBlocker.

Method Description
Future<bool> isEnabled() Returns whether or not is AppBlocker is Enabled.
Future<bool> enableAppBlocker() Enables the App Blocker to block the apps.
Future<bool> disableAppBlocker() Disables the App Blocker.
Future<bool> setRestrictionTime(String startTime, String endTime) Set the restriction time window for the App Blocker. The time string must be in HH:MM:SS 24 hours format.
Future<bool> resetRestrictionTime() Resets the restriction time window for the App Blocker to block apps anytime of the day.
Future<Map<String, String>> getRestrictionTime() Returns the map containing startTime and endTime for the restriction time period.
Future<bool> setRestrictionWeekDays(List<int> weekDays) Set the weekdays when you want to App Blocker to block apps. Sunday (1) to Saturday (7).
Future<List<int>> getRestrictedWeekDays() Returns the list of restricted week days for the plugin.
Future<bool> resetRestrictionWeekDays() Resets the weekdays to be restricted
Future<bool> updateBlockedPackages(List<String> packages) Blocks the given list of packages. To reset the blocked packages send an empty list. Each call send a full list of packages to be blocked.
Future<List<String>> getBlockedPackages() Returns the list of blocked packages.
void bringAppToFront() Call this method to bring app to front. You don't need to call this as you might have already done this on onResume handler of the configure function above.
Future<bool> isAppUsagePermissionGranted() Returns Future bool whether or not the app usage permission is granted or not
void openAppUsageSettings() Launch intent for the app usage permission screen for our app.
Future<bool> isBatteryOptimizationIgnored() Returns Future bool whether the battery optimization for our app is ignored or not.
void openBatteryOptimizationSettings() Opens Battery Optimization Ignore Popup/Screen
Future<bool> isOverlayPermissionGranted() Returns Future bool whether the overlay permission is granted or not
void requestOverlayPermission() Method to request for the overlay permission

app_blocker's People

Contributors

ravindrabarthwal avatar

Stargazers

Anshul Agarwala avatar

Watchers

Rajesh Singh avatar Rahul Garg avatar  avatar Kanika Saini avatar

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.