SimpleDialog


Source link: https://github.com/BROUDING/SimpleDialog

Simple Dialog

Simple and easy Android Dialog by BROUDING


Sample .apk

You can download the latest sample APK from this repo here: https://github.com/brouding/SimpleDialog/blob/master/sample/SimpleDialogSample.apk


Gradle Dependency

Repository

The Gradle dependency is available via jCenter. jCenter is the default Maven repository used by Android Studio.

The minimum API level supported by this library is API 14, Android 4.0 (ICE_CREAM_SANDWICH)

Import to your project

add below code in build.gradle (Module: app)

dependencies {
  // ... other dependencies here
  compile 'com.brouding:android-simple-dialog:0.3.0' 
}

How to use ( Find more in Wiki )

SimpleDialog - Basic

Click here for more options

new SimpleDialog.Builder(thisActivity)

  .setTitle("Hello !")

  .setContent("This is basic SimpleDialog :)", 3)

// Customizing (You can find more in Wiki)

//.setBtnConfirmText("Check!")

  //.setBtnConfirmTextColor("#de413e")

  //.setBtnCancelText("Cancel")

  //.setBtnCancelTextColor("#de413e")

  //.setCancelable(true)

 // Default value is false

  //.onConfirm(new SimpleDialog.BtnCallback() {


  //
 @Override

  //
 public void onClick(@NonNull SimpleDialog dialog, @NonNull SimpleDialog.BtnAction which) {


  //

  // Do something

  //
 
}


  //
}
)

  //.setBtnCancelText("Cancel", false)

  //.onCancel(new SimpleDialog.BtnCallback() {


  //
 @Override

  //
 public void onClick(@NonNull SimpleDialog dialog, @NonNull SimpleDialog.BtnAction which) {


  //

  // Do something

  //
 
}


  //
}
)

  .show();

 // Must be called at the end

SimpleDialog - Progress

Click here for more options

Want to make custom GIF?

(Don't forget to save it in res/raw)

new SimpleDialog.Builder(thisActivity)

  .setContent("This is progress SimpleDialog :)", 7)

  // .showProgress must be set true if you want ProgressDialog

  .showProgress(true)
  // Default GIF is in the library (R.raw.simple_dialog_progress_default)

  //.setProgressGIF(R.raw.simple_dialog_progress_default)

  .setBtnCancelText("Cancel")

  .setBtnCancelTextColor("#2861b0")

// Customizing (You can find more in Wiki)

//.setBtnCancelText("Cancel", false)

  //.setBtnCancelTextColor(R.color.colorPrimary)

  //.setBtnCancelShowTime(2000)

  //.onCancel(new SimpleDialog.BtnCallback() {


  //
 @Override

  //
 public void onClick(@NonNull SimpleDialog dialog, @NonNull SimpleDialog.BtnAction which) {


  //

  // thisActivity.finish();


  //
 
}


  //
}
)

  //.showProgress(true)

  .show();

 // Must be called at the end

SimpleDialog - Guide

Click here for more options

new SimpleDialog.Builder(thisActivity)

  .setTitle("Hello !", true)

  .setContent("This is guide SimpleDialog :)\n\n- You can pinch the view !")

  .setGuideImage(R.drawable.image_guide_pinch)

  .setGuideImageSizeDp(150, 150)

  .setPermanentCheck(Pref.PREFERENCE_NAME, Pref.KEY_FIRST_WELCOME)

  .onConfirm(new SimpleDialog.BtnCallbackWithPermanentCheck() {

@Override

public void onClick(@NonNull SimpleDialog dialog, @NonNull SimpleDialog.BtnAction which, boolean isPermanentChecked) {

 if( isPermanentChecked )

  setBtnGuideReset(true);

}

  
}
)

  .setBtnConfirmText("Check!")

  .setBtnConfirmTextColor("#e6b115")

  // I thought cancel button is not necessary, it's unavailable unless there're requests

 // Customizing (You can find more in Wiki)

//.setTitle("Hello !", true)

  //.setBtnPermanentCheckText("?? ?? ??", true)

  //.setGuideImagePaddingDp(10)

  //.setGuideImageSizeDp(100, 100)

  .showIfPermanentValueIsFalse();
  // Must be called at the end (if permanentCheck is necessary)

SimpleDialog - CustomView

Click here for more options

new SimpleDialog.Builder(thisActivity)

  .setTitle("This is Title :)")

  // If the customView is long enough, SimpleDialog will put your layout in the ScrollView automatically

  .setCustomView(R.layout.brouding_simple_dialog_test_layout_custom_long)

  .setBtnConfirmText("Check!")

  .setBtnConfirmTextSizeDp(16)

  .setBtnConfirmTextColor("#1fd1ab")

  .setBtnCancelText("Cancel", false)

  .setBtnCancelTextColor("#555555")

  .show();

 // Must be called at the end

# Tip

If you use same or similar Dialog often and many different places in the app, which you should, it's easy to use making Const String for each dialog and write Dialog builder in Application file like below :

In App.java
public class App extends Application {
  private static App instance;
public static App getInstance() {

return instance;
  
}

public SimpleDialog showDialogWithMessage(final Activity thisActivity, int sign, String text, SimpleDialog.BtnCallback clickListener) {

switch (sign) {

  case Const.GENERAL_WAIT:

  mDialog = new SimpleDialog.Builder(thisActivity)

 .setContent(text==null ? "Loading..." : text)

 .showProgress(true)

 .setBtnCancelText("Cancel")

 .onCancel(clickListener)

 .setCancelable(false)

 .show();

  break;

case Const.NO_NETWORK:

new SimpleDialog.Builder(thisActivity)

 .setContent("Network connection is unstable")

 .setBtnConfirmText("Check")

 .onConfirm(new SimpleDialog.BtnCallback() {

  @Override

  public void onClick(@NonNull SimpleDialog dialog, @NonNull SimpleDialog.BtnAction which) {

thisActivity.finish();

  
}

 
}
)

 .setCancelable(false)

 .show();

  break;

}

 return mDialog;  
}
In BaseActivity.java or BaseFragment.java
public class BaseActivity extends AppCompatActivity {
  public SimpleDialog showDialogWithMessage(int sign) {

return App.getInstance().showDialogWithMessage(this, sign, null, null);

  
}

...
public SimpleDialog showDialogWithMessage(int sign, String text, SimpleDialog.BtnCallback cancelClickListener) {

return App.getInstance().showDialogWithMessage(this, sign, text, cancelClickListener);

  
}
 
}
In MainActivity.java
public class MainActivity extends BaseActivity {
  showDialogWithMessage(Const.GENERAL_WAIT);
 
}

License

Copyright 2017 SimpleDialog authors.  - Jeongwon Lee ([email protected])  All rights reserved.  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. 

Resources

A light-weight android library that can be quickly integrated into any app to let users choose folder, also files (but esp built for folders).

A simple customizable NumberPicker plugin for Android.

Add footer and header & item click listener to RecyclerView adapter.

An android library that is able to set a vector drawable at text view pre-Lollipop.

BetterTextInputLayout is Android support library's TextInputLayout subclass providing following extensions: adds methods to manipulate password visibility from code as showPassword, hidePassword and togglePassword also comes with passwordToggleEnabled enabled by default.

Custom ProgressView to show battery progress.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes