{"id":13786893,"url":"https://github.com/ImaginativeShohag/Oops-No-Internet","last_synced_at":"2025-05-12T00:30:41.554Z","repository":{"id":46237558,"uuid":"226654245","full_name":"ImaginativeShohag/Oops-No-Internet","owner":"ImaginativeShohag","description":"Oops! No Internet! No internet dialog and snackbar for the rescue!","archived":false,"fork":false,"pushed_at":"2023-12-12T18:01:29.000Z","size":19968,"stargazers_count":205,"open_issues_count":4,"forks_count":36,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T19:13:37.795Z","etag":null,"topics":["airplane-mode","android","android-library","dialog","internet-dialog","kotlin","no-internet-dialog","nointernet","snackbar"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ImaginativeShohag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.buymeacoffee.com/ImShohag"]}},"created_at":"2019-12-08T11:07:21.000Z","updated_at":"2025-03-26T12:25:30.000Z","dependencies_parsed_at":"2024-05-03T01:52:49.247Z","dependency_job_id":"ae5e7886-bd0a-4681-88d8-2fc9356943df","html_url":"https://github.com/ImaginativeShohag/Oops-No-Internet","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImaginativeShohag%2FOops-No-Internet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImaginativeShohag%2FOops-No-Internet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImaginativeShohag%2FOops-No-Internet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImaginativeShohag%2FOops-No-Internet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ImaginativeShohag","download_url":"https://codeload.github.com/ImaginativeShohag/Oops-No-Internet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253655755,"owners_count":21943068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["airplane-mode","android","android-library","dialog","internet-dialog","kotlin","no-internet-dialog","nointernet","snackbar"],"created_at":"2024-08-03T20:00:20.761Z","updated_at":"2025-05-12T00:30:36.537Z","avatar_url":"https://github.com/ImaginativeShohag.png","language":"Kotlin","funding_links":["https://www.buymeacoffee.com/ImShohag"],"categories":["Library"],"sub_categories":[],"readme":"# Oops! No Internet!\n\nSimple no Internet dialogs and snackbar, which will automatically appear and disappear based on Internet connectivity status.\n\n[![Developer](https://img.shields.io/badge/Maintainer-ImaginativeShohag-green)](https://github.com/ImaginativeShohag)\n[![GitHub release](https://img.shields.io/github/release/ImaginativeShohag/Oops-No-Internet.svg)](https://github.com/ImaginativeShohag/Oops-No-Internet/releases)\n[![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-Oops!%20No%20Internet!-green.svg?style=flat)]( https://android-arsenal.com/details/1/8005 )\n[![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21)\n\n## Previews\n\n### Preview of `NoInternetDialogSignal`:\n\n|                           Day Mode                           |                   Day Mode (Airplane Mode)                   |                          Night Mode                          |\n| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |\n| ![No Internet Dialog: Signal](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/dialog_signal_1.gif) | ![No Internet Dialog: Signal](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/dialog_signal_2.gif) | ![Airplane Mode Dialog: Signal](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/dialog_signal_3.gif) |\n\n### Preview of `NoInternetDialogPendulum`:\n\n|                           Day Mode                           |                   Day Mode (Airplane Mode)                   |                          Night Mode                          |\n| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |\n| ![No Internet Dialog: Pendulum](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/dialog_pendulum_1.gif) | ![No Internet Dialog: Pendulum](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/dialog_pendulum_2.gif) | ![Airplane Mode Dialog: Pendulum](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/dialog_pendulum_3.gif) |\n\n### Preview of `NoInternetSnackbarFire`:\n\n|                           Day Mode                           |                   Day Mode (Airplane Mode)                   |                          Night Mode                          |\n| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |\n| ![No Internet Snackbar: Fire](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/snackbar_fire_1.png) | ![No Internet Dialog: Fire](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/snackbar_fire_2.png) | ![Airplane Mode Snackbar: Fire](https://github.com/ImaginativeShohag/Oops-No-Internet/blob/master/images/snackbar_fire_3.png) |\n\n## Types\n\nThe library provides `NoInternetObserveComponent`, a simple [lifecycle-aware component](https://developer.android.com/topic/libraries/architecture/lifecycle). The purpose of the component is to provide an easy way to notify about the  Internet connection connectivity change. It gives a simple interface to connect with any elements (`Dialog`, `Snackbar`, etc.) with ease. You can also use the `BaseNoInternetDialog` class to easily create custom no Internet dialog.\nThe library currently provides two `Dialogs` and a `Snackbar` out of the box for no Internet notification.\n\n### No Internet Dialogs\n\n* `NoInternetDialogPendulum` (formerly just `NoInternetDialog`)\n* `NoInternetDialogSignal`\n\n### No Internet Snackbar\n\n* `NoInternetSnackbarFire`\n\n## Usage\n\n### Dependency\n\n#### Add the followings to your project level `build.gradle` file.\n\n```groovy\nandroid {\n\n    // ...\n\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n}\n\ndependencies {\n    // ...\n    \n    // Material Components for Android. Replace the version with the latest version of Material Components library.\n    implementation 'com.google.android.material:material:1.2.1'\n\n    implementation 'org.imaginativeworld.oopsnointernet:oopsnointernet:2.0.0'\n}\n```\n\n**Note 0.** Minimum SDK for this library is **API 21** (Android 5.0 Lollipop).\n\n**Note 1.** Your application has to use **AndroidX** to use this library.\n\n**Note 2.** You have to use **\\*.MaterialComponents.\\*** in your styles.\n\n### Finally\n\nJust initialize any of the `NoInternetDialog*` and/or `NoInternetSnackbar*` using the builder in `onCreate()`, that's all! :)\n\nThe `NoInternetDialog*` and/or `NoInternetSnackbar*` will then automatically appear when no active Internet connection found and disappear otherwise.\n\nCustomizable attributes with their default values are given in the following examples.\n\n```kotlin\n// Kotlin\nclass MainActivity : AppCompatActivity() {\n    \n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        \n        // ...\n\n        // No Internet Dialog: Pendulum\n        NoInternetDialogPendulum.Builder(\n            this,\n            lifecycle\n        ).apply {\n            dialogProperties.apply {\n                connectionCallback = object : ConnectionCallback { // Optional\n                    override fun hasActiveConnection(hasActiveConnection: Boolean) {\n                        // ...\n                    }\n                }\n\n                cancelable = false // Optional\n                noInternetConnectionTitle = \"No Internet\" // Optional\n                noInternetConnectionMessage =\n                \"Check your Internet connection and try again.\" // Optional\n                showInternetOnButtons = true // Optional\n                pleaseTurnOnText = \"Please turn on\" // Optional\n                wifiOnButtonText = \"Wifi\" // Optional\n                mobileDataOnButtonText = \"Mobile data\" // Optional\n\n                onAirplaneModeTitle = \"No Internet\" // Optional\n                onAirplaneModeMessage = \"You have turned on the airplane mode.\" // Optional\n                pleaseTurnOffText = \"Please turn off\" // Optional\n                airplaneModeOffButtonText = \"Airplane mode\" // Optional\n                showAirplaneModeOffButtons = true // Optional\n            }\n        }.build()\n\n        // No Internet Dialog: Signal\n        NoInternetDialogSignal.Builder(\n            this,\n            lifecycle\n        ).apply {\n            dialogProperties.apply {\n                connectionCallback = object : ConnectionCallback { // Optional\n                    override fun hasActiveConnection(hasActiveConnection: Boolean) {\n                        // ...\n                    }\n                }\n\n                cancelable = false // Optional\n                noInternetConnectionTitle = \"No Internet\" // Optional\n                noInternetConnectionMessage =\n                \"Check your Internet connection and try again.\" // Optional\n                showInternetOnButtons = true // Optional\n                pleaseTurnOnText = \"Please turn on\" // Optional\n                wifiOnButtonText = \"Wifi\" // Optional\n                mobileDataOnButtonText = \"Mobile data\" // Optional\n\n                onAirplaneModeTitle = \"No Internet\" // Optional\n                onAirplaneModeMessage = \"You have turned on the airplane mode.\" // Optional\n                pleaseTurnOffText = \"Please turn off\" // Optional\n                airplaneModeOffButtonText = \"Airplane mode\" // Optional\n                showAirplaneModeOffButtons = true // Optional\n            }\n        }.build()\n        \n        // No Internet Snackbar: Fire\n        NoInternetSnackbarFire.Builder(\n            binding.mainContainer,\n            lifecycle\n        ).apply {\n            snackbarProperties.apply {\n                connectionCallback = object : ConnectionCallback { // Optional\n                    override fun hasActiveConnection(hasActiveConnection: Boolean) {\n                        // ...\n                    }\n                }\n\n                duration = Snackbar.LENGTH_INDEFINITE // Optional\n                noInternetConnectionMessage = \"No active Internet connection!\" // Optional\n                onAirplaneModeMessage = \"You have turned on the airplane mode!\" // Optional\n                snackbarActionText = \"Settings\" // Optional\n                showActionToDismiss = false // Optional\n                snackbarDismissActionText = \"OK\" // Optional\n            }\n        }.build()\n    }\n}\n```\n\n```java\n// Java\npublic class Main2Activity extends AppCompatActivity {\n    \n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        \n        // ...\n        \n        // No Internet Dialog: Pendulum\n        NoInternetDialogPendulum.Builder builder = new NoInternetDialogPendulum.Builder(\n            this,\n            getLifecycle()\n        );\n\n        DialogPropertiesPendulum properties = builder.getDialogProperties();\n\n        properties.setConnectionCallback(new ConnectionCallback() { // Optional\n            @Override\n            public void hasActiveConnection(boolean hasActiveConnection) {\n                // ...\n            }\n        });\n\n        properties.setCancelable(false); // Optional\n        properties.setNoInternetConnectionTitle(\"No Internet\"); // Optional\n        properties.setNoInternetConnectionMessage(\"Check your Internet connection and try again\"); // Optional\n        properties.setShowInternetOnButtons(true); // Optional\n        properties.setPleaseTurnOnText(\"Please turn on\"); // Optional\n        properties.setWifiOnButtonText(\"Wifi\"); // Optional\n        properties.setMobileDataOnButtonText(\"Mobile data\"); // Optional\n\n        properties.setOnAirplaneModeTitle(\"No Internet\"); // Optional\n        properties.setOnAirplaneModeMessage(\"You have turned on the airplane mode.\"); // Optional\n        properties.setPleaseTurnOffText(\"Please turn off\"); // Optional\n        properties.setAirplaneModeOffButtonText(\"Airplane mode\"); // Optional\n        properties.setShowAirplaneModeOffButtons(true); // Optional\n\n        builder.build();\n        \n        // No Internet Dialog: Signal\n        NoInternetDialogSignal.Builder builder = new NoInternetDialogSignal.Builder(\n            this,\n            getLifecycle()\n        );\n\n        DialogPropertiesSignal properties = builder.getDialogProperties();\n\n        properties.setConnectionCallback(new ConnectionCallback() { // Optional\n            @Override\n            public void hasActiveConnection(boolean hasActiveConnection) {\n                // ...\n            }\n        });\n\n        properties.setCancelable(false); // Optional\n        properties.setNoInternetConnectionTitle(\"No Internet\"); // Optional\n        properties.setNoInternetConnectionMessage(\"Check your Internet connection and try again\"); // Optional\n        properties.setShowInternetOnButtons(true); // Optional\n        properties.setPleaseTurnOnText(\"Please turn on\"); // Optional\n        properties.setWifiOnButtonText(\"Wifi\"); // Optional\n        properties.setMobileDataOnButtonText(\"Mobile data\"); // Optional\n\n        properties.setOnAirplaneModeTitle(\"No Internet\"); // Optional\n        properties.setOnAirplaneModeMessage(\"You have turned on the airplane mode.\"); // Optional\n        properties.setPleaseTurnOffText(\"Please turn off\"); // Optional\n        properties.setAirplaneModeOffButtonText(\"Airplane mode\"); // Optional\n        properties.setShowAirplaneModeOffButtons(true); // Optional\n\n        builder.build();\n        \n\t\t// No Internet Snackbar: Fire\n        NoInternetSnackbarFire.Builder builder = new NoInternetSnackbarFire.Builder(\n            binding.mainContainer,\n            getLifecycle()\n        );\n\n        SnackbarPropertiesFire properties = builder.getSnackbarProperties();\n\n        properties.setConnectionCallback(new ConnectionCallback() { // Optional\n            @Override\n            public void hasActiveConnection(boolean hasActiveConnection) {\n                // ...\n            }\n        });\n\n        properties.setDuration(Snackbar.LENGTH_INDEFINITE); // Optional\n        properties.setNoInternetConnectionMessage(\"No active Internet connection!\"); // Optional\n        properties.setOnAirplaneModeMessage(\"You have turned on the airplane mode!\"); // Optional\n        properties.setSnackbarActionText(\"Settings\"); // Optional\n        properties.setShowActionToDismiss(false); // Optional\n        properties.setSnackbarDismissActionText(\"OK\"); // Optional\n\n        builder.build();\n    }\n}\n```\n\nThe sample project can be found [here](https://github.com/ImaginativeShohag/Oops-No-Internet/tree/master/sample).\n\n## Credits\n\nThis library is inspired by [NoInternetDialog](https://github.com/appwise-labs/NoInternetDialog).\n\nLibrary name credit goes to Fahima Lamia Neha.\n\nThe icons and images used in the sample project are from freepik.com and flaticon.com.\n\n## Changelog\n\n### 2.0.0\n\nWe move our library from **jitpack.io** to **maven** repository. So no need to add any repositories for using the library.\n\nWe changed the file structures and re-right the whole library. So you have to do a little refactoring to use version 2 of the library. Just follow the samples, you will get it. Or add an issue if there any problem to migrate.\n\nThe library now provides a simple lifecycle-aware component for observing the Internet connection changes. It can be used with any kind of custom elements.\n\nWe provide two out of the box dialogs and a snackbar implementation.\n\nNotable other changes:\n\n* **New:** `NoInternetObserveComponent` lifecycle-aware component added.\n* **New:** Custom no Internet dialogs can be easily created using `BaseNoInternetDialog` class.\n* **Changed:** Previous `NoInternetDialog` now `NoInternetDialogPendulum`.\n* **New:** New `NoInternetDialogSignal` dialog added.\n* **Removed:** `NoInternetSnackbar` removed.\n* **New:** New `NoInternetSnackbarFire` added.\n* **New:** All the dialogs and snackbar are dark-mode ready.\n\n### 1.1.4 \u0026 1.1.5\n\n- `NoInternetUtils` functions are now documented.\n- Dialog width optimized for small screens.\n- Dependency updated.\n\n### 1.1.3\n\n`NoInternetUtils` class methods are now accessible independently.\n\n### 1.1.2\n\nAirplane animation tweak.\n\n### 1.1.1\n\nSmall change in check internet.\n\n### 1.1.0\n\n\\+ Airplane mode button added to the dialog.\n\n\\+ The snackbar text will be updated based on airplane mode.\n\n### 1.0.1\n\nAirplane mode animation added to the dialog and known bugs fixed.\n\n### 1.0.0\n\nThe initial release of the library.\n\n## Licence\n\n\u003cdiv\u003eIcons made by \u003ca href=\"https://www.flaticon.com/authors/darius-dan\" title=\"Darius Dan\"\u003eDarius Dan\u003c/a\u003e from \u003ca href=\"https://www.flaticon.com/\" title=\"Flaticon\"\u003ewww.flaticon.com\u003c/a\u003e\u003c/div\u003e\n\n```\nCopyright 2019 Md. Mahmudul Hasan Shohag\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FImaginativeShohag%2FOops-No-Internet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FImaginativeShohag%2FOops-No-Internet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FImaginativeShohag%2FOops-No-Internet/lists"}