Fresh Air - Android


Source link: https://github.com/Raizlabs/FreshAir-Android

Fresh Air - Android

Fresh Air is an application update library. It is designed to check a remote location for application updates and if updates are available, it prompts the user to upgrade the application. When the new version of the application is started, a dialog can be presented that showcases the new features to the user.

Basic Setup

Fresh Air can be set up with just a few simple steps. A working example can also be found in the sample module of this project.

Including In Your Project

Fresh Air is available on our Bintray Maven repository and can be included in your project with the following changes.

  1. Include our repository in your root project build.gradle:
allprojects {

repositories {

 jcenter()

 maven {
 url "https://dl.bintray.com/raizlabs/Libraries" 
}

}
 
}
  1. Include the dependency in your module's build.gradle:
dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'

...

compile 'com.raizlabs:FreshAir:0.1.0' 
}
  1. Initialize the library before use, typically in your Application class:
public class SampleApplication extends Application {

 @Override
public void onCreate() {

 super.onCreate();

  FreshAir.initialize(this);

 ...

}
 
}

Update Checks

Fresh Air can check for new versions of your application using a remotely hosted JSON file. Just call the following method from the onCreate() of your Application, your first Activity, or any other place you would like to check for updates. Note that this process is asynchronous.

public class SampleApplication extends Application {

@Override  public void onCreate() {

super.onCreate();

 FreshAir.initialize(this);

FreshAir.checkForUpdates("https://raw.githubusercontent.com/Raizlabs/FreshAir-Android/develop/Schema/release_notes.json");

...  
}
 
}

See Schema/release_notes.json in this repo for an example of the JSON schema

Release Notes

Fresh Air can present a dialog of release notes to showcase the features that you have added in new versions of your application. This dialog will include a scrollable view of features which each contain an image, title, and description. These will be shown once per version, but not again.

  1. Define the release information that you wish to display. This doesn't display the information, but lets Fresh Air know what you will want to display when the time comes. Typically, you want to put this information in your Application.onCreate() after initializing the library. The release notes follow a Builder pattern which takes a set of Features, which are also constructed through a Builder pattern:
public class SampleApplication extends Application {

 @Override
public void onCreate() {

 super.onCreate();

  FreshAir.initialize(this);

 FreshAir.setReleaseNotes(new ReleaseNotes.Builder()

.addFeature(

  new FeatureInfo.Builder()

 .setImageResource(R.mipmap.ic_launcher)

 .setTitleResource(R.string.Feature1_Title)

 .setDescriptionResource(R.string.Feature1_Description)

)

.addFeature(

  new FeatureInfo.Builder()

 .setImageResource(R.drawable.feature2)

 .setTitleResource(R.string.Feature2_Title)

 .setDescriptionResource(R.string.Feature2_Description)

)

.addFeature(

  new FeatureInfo.Builder()

 .setImageResource(R.drawable.feature3)

 .setTitleResource(R.string.Feature3_Title)

 .setDescriptionResource(R.string.Feature3_Description)

)

// Sometimes handy for minor updates: see docs

.setVersionCode(1));

}
 
}
  1. When you would like to display the release notes dialog, call the following method. This requires a FragmentActivity from the support library. Typically you want to do this from your main launcher Activity or any other entry point to your application:
public class MainActivity extends FragmentActivity {

 @Override
protected void onCreate(Bundle savedInstanceState) {

 super.onCreate(savedInstanceState);

  ...

  FreshAir.showReleaseNotes(this);

}
 
}

Extras

Additional flexibility is available. Consult the JavaDoc for more details, but some of the higher level functionality is listed below.

  • Update Prompts - You can change the text contents of the update prompt via FreshAir.setUpdatePrompt(UpdatePromptInfo). UpdatePromptInfo contains a Builder class for easy overriding.
  • Clear History - You can clear the previously shown updates, forced updates, and release notes via FreshAir.clearFUpdatePromptVersion(), FreshAir.clearForcedUpdateVersion(), and FreshAir.clearReleaseNotesVersion
  • App Disabling - You can manually block out the app via FreshAir.disableApp(). To unset this, you must call FreshAir.clearAppDisabled() and restart the app.
  • Logging - You can alter the level of logging via FreshAir.setLogLevel(int) to clear logging or add more logging for debugging. By default, only warnings and errors are displayed.

Resources

An Android Parallax ListView item (this effect inspired by sound cloud android app).

Android comes with a few "wrapper" classes, like CursorWrapper, that make it relatively easy for you to add just a bit of functionality to an existing object. The wrapper delegates all behaviors to the wrapped object; you just override the specific behaviors you need. This works well in cases where there are many possible underlying implementations, so you could not robustly accomplish these ends by subclassing.

Android lacks such a wrapper for ListAdapter, though. There is a WrappedListAdapter entry in the SDK, but it is an interface, not an implementation.

So, CWAC offers an AdapterWrapper to fill this void.

Sometimes, you want your users to pick a color. A simple approach is to give the user a fixed roster of a handful of colors -- easy, but limited. A fancy approach is to use some form of color wheel, but these can be difficult to use on a touchscreen and perhaps impossible without a touchscreen.

ColorMixer is a widget that provides a simple set of SeekBars to let the user mix red, green, and blue to pick an arbitrary color. It is not very big, so it is easy to fit on a form, and it is still fairly finger-friendly.

It is also packaged as a dialog (ColorMixerDialog), a dialog-themed activity (ColorMixerActivity), and a preference (ColorPreference).

This project has a handful of Android containers (ViewGroup implementations) designed to handle specific scenarios:

  • AspectLockedFrameLayout that resizes itself, and its children, to fit within a specific aspect ratio
  • MirroringFrameLayout and an associated Mirror that duplicates and scales the contents of the MirroringFrameLayout onto the Mirror

Android BounceProgressBar Widget.

Library for handling Kiosk Mode in your Android Application. It restricts device to be using only one activity without possibility to switch to other app.

Features:

  • Run activity of you choice in kiosk mode
  • Blocks every application from going into foreground with activity manager
  • Handles home button by being a Launcher App

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