All Projects → ImaginativeShohag → Oops No Internet

ImaginativeShohag / Oops No Internet

Licence: apache-2.0
Oops! No Internet! No internet dialog and snackbar for the rescue!

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Oops No Internet

Appupdater
A library that checks for your apps' updates on Google Play, GitHub, Amazon, F-Droid or your own server. API 9+ required.
Stars: ✭ 1,793 (+2169.62%)
Mutual labels:  dialog, snackbar
Livesmashbar
An elegant looking and easy to use informative library with LiveData integration for Android.
Stars: ✭ 107 (+35.44%)
Mutual labels:  dialog, snackbar
Noty
A simple library for creating animated warnings/dialogs/alerts for Android.
Stars: ✭ 136 (+72.15%)
Mutual labels:  dialog, snackbar
Flash
⚡️A highly customizable, powerful and easy-to-use alerting library for Flutter.
Stars: ✭ 174 (+120.25%)
Mutual labels:  dialog, snackbar
flutter examples
Random flutter examples
Stars: ✭ 18 (-77.22%)
Mutual labels:  dialog, snackbar
smart-show
Toast # Snackbar # Dialog
Stars: ✭ 500 (+532.91%)
Mutual labels:  dialog, snackbar
denbun
Adjust showing frequency of Android app messages, and to be more user friendly 🐦
Stars: ✭ 17 (-78.48%)
Mutual labels:  dialog, snackbar
Smart Show
Toast & Snackbar & TopBar & Dialog
Stars: ✭ 430 (+444.3%)
Mutual labels:  dialog, snackbar
Layer
丰富多样的 Web 弹出层组件,可轻松实现 Alert/Confirm/Prompt/ 普通提示/页面区块/iframe/tips等等几乎所有的弹出交互。目前已成为最多人使用的弹层解决方案
Stars: ✭ 8,202 (+10282.28%)
Mutual labels:  dialog
Droiddialog
Android Library for showing Material Dialog with little customization
Stars: ✭ 66 (-16.46%)
Mutual labels:  dialog
File Dialog
Trigger the upload file dialog directly from your code easily.
Stars: ✭ 51 (-35.44%)
Mutual labels:  dialog
Nativefiledialog
A tiny, neat C library that portably invokes native file open and save dialogs.
Stars: ✭ 1,100 (+1292.41%)
Mutual labels:  dialog
React Native Alert Pro
The Pro Version of React Native Alert (Android & iOS)
Stars: ✭ 69 (-12.66%)
Mutual labels:  dialog
Ng2 Bootstrap Modal
Library to simplify the work with bootstrap modal dialogs
Stars: ✭ 53 (-32.91%)
Mutual labels:  dialog
Search Dialog
Android Search Dialog Library
Stars: ✭ 77 (-2.53%)
Mutual labels:  dialog
Lovelydialog
This library is a set of simple wrapper classes that are aimed to help you easily create fancy material dialogs.
Stars: ✭ 1,043 (+1220.25%)
Mutual labels:  dialog
Wheelview
a great functional custom WheelView with demo in dialog and bottomDialog,android 滚动选择控件,滚动选择器,时间选择,日期选择
Stars: ✭ 44 (-44.3%)
Mutual labels:  dialog
React Poppop
A mobile support and multi-directional modal for ReactJS
Stars: ✭ 78 (-1.27%)
Mutual labels:  dialog
Csnackbar
This is a wrapper for android Snackbar. Which giving support to change Snackbar color, duration, message or even it's content view with a custom view.
Stars: ✭ 76 (-3.8%)
Mutual labels:  snackbar
Vue A11y Dialog
Vue.js component for a11y-dialog
Stars: ✭ 65 (-17.72%)
Mutual labels:  dialog

Oops! No Internet!

Simple no Internet dialogs and snackbar, which will automatically appear and disappear based on Internet connectivity status.

Developer GitHub release Android Arsenal API

Previews

Preview of NoInternetDialogSignal:

Day Mode Day Mode (Airplane Mode) Night Mode
No Internet Dialog: Signal No Internet Dialog: Signal Airplane Mode Dialog: Signal

Preview of NoInternetDialogPendulum:

Day Mode Day Mode (Airplane Mode) Night Mode
No Internet Dialog: Pendulum No Internet Dialog: Pendulum Airplane Mode Dialog: Pendulum

Preview of NoInternetSnackbarFire:

Day Mode Day Mode (Airplane Mode) Night Mode
No Internet Snackbar: Fire No Internet Dialog: Fire Airplane Mode Snackbar: Fire

Types

The library provides NoInternetObserveComponent, a simple lifecycle-aware component. 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. The library currently provides two Dialogs and a Snackbar out of the box for no Internet notification.

No Internet Dialogs

  • NoInternetDialogPendulum (formerly just NoInternetDialog)
  • NoInternetDialogSignal

No Internet Snackbar

  • NoInternetSnackbarFire

Usage

Dependency

Add the followings to your project level build.gradle file.

android {

    // ...

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    // ...
    
    // Material Components for Android. Replace the version with the latest version of Material Components library.
    implementation 'com.google.android.material:material:1.2.1'

    implementation 'org.imaginativeworld.oopsnointernet:oopsnointernet:2.0.0'
}

Note 0. Minimum SDK for this library is API 21 (Android 5.0 Lollipop).

Note 1. Your application has to use AndroidX to use this library.

Note 2. You have to use *.MaterialComponents.* in your styles.

Finally

Just initialize any of the NoInternetDialog* and/or NoInternetSnackbar* using the builder in onCreate(), that's all! :)

The NoInternetDialog* and/or NoInternetSnackbar* will then automatically appear when no active Internet connection found and disappear otherwise.

Customizable attributes with their default values are given in the following examples.

// Kotlin
class MainActivity : AppCompatActivity() {
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        // ...

        // No Internet Dialog: Pendulum
        NoInternetDialogPendulum.Builder(
            this,
            lifecycle
        ).apply {
            dialogProperties.apply {
                connectionCallback = object : ConnectionCallback { // Optional
                    override fun hasActiveConnection(hasActiveConnection: Boolean) {
                        // ...
                    }
                }

                cancelable = false // Optional
                noInternetConnectionTitle = "No Internet" // Optional
                noInternetConnectionMessage =
                "Check your Internet connection and try again." // Optional
                showInternetOnButtons = true // Optional
                pleaseTurnOnText = "Please turn on" // Optional
                wifiOnButtonText = "Wifi" // Optional
                mobileDataOnButtonText = "Mobile data" // Optional

                onAirplaneModeTitle = "No Internet" // Optional
                onAirplaneModeMessage = "You have turned on the airplane mode." // Optional
                pleaseTurnOffText = "Please turn off" // Optional
                airplaneModeOffButtonText = "Airplane mode" // Optional
                showAirplaneModeOffButtons = true // Optional
            }
        }.build()

        // No Internet Dialog: Signal
        NoInternetDialogSignal.Builder(
            this,
            lifecycle
        ).apply {
            dialogProperties.apply {
                connectionCallback = object : ConnectionCallback { // Optional
                    override fun hasActiveConnection(hasActiveConnection: Boolean) {
                        // ...
                    }
                }

                cancelable = false // Optional
                noInternetConnectionTitle = "No Internet" // Optional
                noInternetConnectionMessage =
                "Check your Internet connection and try again." // Optional
                showInternetOnButtons = true // Optional
                pleaseTurnOnText = "Please turn on" // Optional
                wifiOnButtonText = "Wifi" // Optional
                mobileDataOnButtonText = "Mobile data" // Optional

                onAirplaneModeTitle = "No Internet" // Optional
                onAirplaneModeMessage = "You have turned on the airplane mode." // Optional
                pleaseTurnOffText = "Please turn off" // Optional
                airplaneModeOffButtonText = "Airplane mode" // Optional
                showAirplaneModeOffButtons = true // Optional
            }
        }.build()
        
        // No Internet Snackbar: Fire
        NoInternetSnackbarFire.Builder(
            binding.mainContainer,
            lifecycle
        ).apply {
            snackbarProperties.apply {
                connectionCallback = object : ConnectionCallback { // Optional
                    override fun hasActiveConnection(hasActiveConnection: Boolean) {
                        // ...
                    }
                }

                duration = Snackbar.LENGTH_INDEFINITE // Optional
                noInternetConnectionMessage = "No active Internet connection!" // Optional
                onAirplaneModeMessage = "You have turned on the airplane mode!" // Optional
                snackbarActionText = "Settings" // Optional
                showActionToDismiss = false // Optional
                snackbarDismissActionText = "OK" // Optional
            }
        }.build()
    }
}
// Java
public class Main2Activity extends AppCompatActivity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // ...
        
        // No Internet Dialog: Pendulum
        NoInternetDialogPendulum.Builder builder = new NoInternetDialogPendulum.Builder(
            this,
            getLifecycle()
        );

        DialogPropertiesPendulum properties = builder.getDialogProperties();

        properties.setConnectionCallback(new ConnectionCallback() { // Optional
            @Override
            public void hasActiveConnection(boolean hasActiveConnection) {
                // ...
            }
        });

        properties.setCancelable(false); // Optional
        properties.setNoInternetConnectionTitle("No Internet"); // Optional
        properties.setNoInternetConnectionMessage("Check your Internet connection and try again"); // Optional
        properties.setShowInternetOnButtons(true); // Optional
        properties.setPleaseTurnOnText("Please turn on"); // Optional
        properties.setWifiOnButtonText("Wifi"); // Optional
        properties.setMobileDataOnButtonText("Mobile data"); // Optional

        properties.setOnAirplaneModeTitle("No Internet"); // Optional
        properties.setOnAirplaneModeMessage("You have turned on the airplane mode."); // Optional
        properties.setPleaseTurnOffText("Please turn off"); // Optional
        properties.setAirplaneModeOffButtonText("Airplane mode"); // Optional
        properties.setShowAirplaneModeOffButtons(true); // Optional

        builder.build();
        
        // No Internet Dialog: Signal
        NoInternetDialogSignal.Builder builder = new NoInternetDialogSignal.Builder(
            this,
            getLifecycle()
        );

        DialogPropertiesSignal properties = builder.getDialogProperties();

        properties.setConnectionCallback(new ConnectionCallback() { // Optional
            @Override
            public void hasActiveConnection(boolean hasActiveConnection) {
                // ...
            }
        });

        properties.setCancelable(false); // Optional
        properties.setNoInternetConnectionTitle("No Internet"); // Optional
        properties.setNoInternetConnectionMessage("Check your Internet connection and try again"); // Optional
        properties.setShowInternetOnButtons(true); // Optional
        properties.setPleaseTurnOnText("Please turn on"); // Optional
        properties.setWifiOnButtonText("Wifi"); // Optional
        properties.setMobileDataOnButtonText("Mobile data"); // Optional

        properties.setOnAirplaneModeTitle("No Internet"); // Optional
        properties.setOnAirplaneModeMessage("You have turned on the airplane mode."); // Optional
        properties.setPleaseTurnOffText("Please turn off"); // Optional
        properties.setAirplaneModeOffButtonText("Airplane mode"); // Optional
        properties.setShowAirplaneModeOffButtons(true); // Optional

        builder.build();
        
		// No Internet Snackbar: Fire
        NoInternetSnackbarFire.Builder builder = new NoInternetSnackbarFire.Builder(
            binding.mainContainer,
            getLifecycle()
        );

        SnackbarPropertiesFire properties = builder.getSnackbarProperties();

        properties.setConnectionCallback(new ConnectionCallback() { // Optional
            @Override
            public void hasActiveConnection(boolean hasActiveConnection) {
                // ...
            }
        });

        properties.setDuration(Snackbar.LENGTH_INDEFINITE); // Optional
        properties.setNoInternetConnectionMessage("No active Internet connection!"); // Optional
        properties.setOnAirplaneModeMessage("You have turned on the airplane mode!"); // Optional
        properties.setSnackbarActionText("Settings"); // Optional
        properties.setShowActionToDismiss(false); // Optional
        properties.setSnackbarDismissActionText("OK"); // Optional

        builder.build();
    }
}

The sample project can be found here.

Credits

This library is inspired by NoInternetDialog.

Library name credit goes to Fahima Lamia Neha.

The icons and images used in the sample project are from freepik.com and flaticon.com.

Changelog

2.0.0

We move our library from jitpack.io to maven repository. So no need to add any repositories for using the library.

We 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.

The library now provides a simple lifecycle-aware component for observing the Internet connection changes. It can be used with any kind of custom elements.

We provide two out of the box dialogs and a snackbar implementation.

Notable other changes:

  • New: NoInternetObserveComponent lifecycle-aware component added.
  • New: Custom no Internet dialogs can be easily created using BaseNoInternetDialog class.
  • Changed: Previous NoInternetDialog now NoInternetDialogPendulum.
  • New: New NoInternetDialogSignal dialog added.
  • Removed: NoInternetSnackbar removed.
  • New: New NoInternetSnackbarFire added.
  • New: All the dialogs and snackbar are dark-mode ready.

1.1.4 & 1.1.5

  • NoInternetUtils functions are now documented.
  • Dialog width optimized for small screens.
  • Dependency updated.

1.1.3

NoInternetUtils class methods are now accessible independently.

1.1.2

Airplane animation tweak.

1.1.1

Small change in check internet.

1.1.0

+ Airplane mode button added to the dialog.

+ The snackbar text will be updated based on airplane mode.

1.0.1

Airplane mode animation added to the dialog and known bugs fixed.

1.0.0

The initial release of the library.

Licence

Icons made by Darius Dan from www.flaticon.com
Copyright 2019 Md. Mahmudul Hasan Shohag

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].