Friday 20 May 2016

CloudRail - Integrate Mulitple Services With Just One API

CloudRail - Integrate Mulitple Services With Just One API

CloudRail is a free software library which abstracts multiple APIs from different providers into a single and universal interface.
Full documentation can be found at https://docs.cloudrail.com/
With CloudRail, you can easily integrate external APIs into your application. CloudRail is an abstracted interface that takes several services and then gives a developer-friendly API that uses common functions between all providers. This means that, for example, upload() works in exactly the same way for Dropbox as it does for Google Drive, OneDrive, and other Cloud Storage Services.

Code Sample

// CloudStorage cs = new Box(context, "[clientIdentifier]", "[clientSecret]");
// CloudStorage cs = new OneDrive(context, "[clientIdentifier]", "[clientSecret]");
// CloudStorage cs = new GoogleDrive(context, "[clientIdentifier]", "[clientSecret]");
CloudStorage cs = new Dropbox(context, "[clientIdentifier]", "[clientSecret]");
new Thread() {
    @Override
    public void run() {
        cs.createFolder("/TestFolder"); // <---
        InputStream stream = null;
        try {
            AssetManager assetManager = getAssets();
            stream = assetManager.open("UserData.csv");
            long size = assetManager.openFd("UserData.csv").getLength();
            cs.upload("/TestFolder/Data.csv", stream, size); // <---
        } catch (Exception e) {
            // TODO: handle error
        } finally {
            // TODO: close stream
        }
    }
}.start();

Current Services

Cloud Storage:
  • Dropbox
  • Box
  • Google Drive
  • Microsoft OneDrive
More interfaces like social, payment or messaging are coming soon.

Advantages of Using CloudRail

  • Consistent Interfaces: As functions work the same across all services, you can perform tasks between services simply.
  • Easy Authentication: CloudRail includes easy ways to authentication, to remove one of the biggest hassles of coding for external APIs.
  • Switch services instantly: One line of code is needed to set up the service you are using. Changing which service is as simple as changing the name to the one you wish to use.
  • Simple Documentation: There is no searching around Stack Overflow for the answer. The CloudRail documentation athttps://docs.cloudrail.com/ is regularly updated, clean, and simple to use.
  • No Maintenance Times: The CloudRail Libraries are updated when a provider changes their API.

Maven

build.gradle
repositories {
    maven {
        url "http://maven.cloudrail.com"
    }
}

dependencies {
    compile 'com.cloudrail:cloudrail-si-android:2.0.1'
}

Get Updates

To keep updated with CloudRail, including any new providers that are added, just add your email address tohttps://cloudrail.com/updates/.

Pricing

CloudRail is free to use. For all projects; commercial and non-commercial. We want APIs to be accessible to all developers. We want APIs to be easier to manage. This is only possible if there are free, powerful tools out there to do this.

Questions?

support@cloudrail.com

Friday 29 January 2016

Swipe Number Picker

SwipeNumberPicker

The library provides simple number picker. The number is selected with the swipe gesture, to right - increase, to left - decrease value. Also, by click NumberPickerDialog will be shown.
Demo

Usage
Just add the dependency to your build.gradle:
dependencies {
    compile 'com.github.supervital:swipenumberpicker:1.0.3'
}
In layout:
<com.vi.swipenumberpicker.SwipeNumberPicker
    android:id="@+id/number_picker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    app:snp_numberColor="@android:color/white"
    app:snp_arrowColor="@android:color/white"
    app:snp_backgroundColor="@color/colorAccent"
    app:snp_max="1000"
    app:snp_min="50"
    app:snp_value="95"/>
Attributes:
    <attr name="snp_min" format="integer"/>
    <attr name="snp_max" format="integer"/>
    <attr name="snp_value" format="integer"/>
    <attr name="snp_arrowColor" format="color"/>
    <attr name="snp_backgroundColor" format="color"/>
    <attr name="snp_numberColor" format="color"/>
To set changed value implement the OnValueChangeListener listener and on onValueChange return true
    swipeNumberPicker.setOnValueChangeListener(new OnValueChangeListener() {
        @Override
        public boolean onValueChange(SwipeNumberPicker view, int oldValue, int newValue) {
            boolean isValueOk = (newValue & 1) == 0;
            if (isValueOk)
                result1.setText(Integer.toString(newValue));

            return isValueOk;
        }
    });
Also you can:
  • disable/enable SwipeNumberPicker;
  • disable/enable Showing of a NumberPicker Dialog. If the dialog disabled View.OnClickListener will be called;
  • set the dialog title;
  • set min, max values;
  • set value;
  • set intermediate mode.

Simple Arc Loader

SimpleArcLoader

  • bored of seeing the same old Android Loader ? SimpleArcLoader is one thing you should try.

Preview

 

Setup

Gradle

  dependencies {
      compile 'com.leo.simplearcloader:simplearcloader:1.0.0'
  }

Example 1

To show dialog
SimpleArcDialog mDialog = new SimpleArcDialog(this);
mDialog.setConfiguration(new ArcConfiguration(this));
mDialog.show();

Example 2

Making use of just the Loader
<com.leo.simplearcloader.SimpleArcLoader
  android:visibility="visible"
  android:id="@+id/loader"
  android:layout_centerInParent="true"
  android:layout_width="60dp"
  android:layout_height="60dp"
  custom:arc_style="simple_arc"
  custom:arc_speed="medium"
  custom:arc_margin="3dp">
</com.leo.simplearcloader.SimpleArcLoader>

Example 3

Customizing Dialog/SimpleArcLoader View using ArcConfiguration
ArcConfiguration configuration = new ArcConfiguration(context);
configuration.setLoaderStyle(SimpleArcLoader.STYLE.COMPLETE_ARC);
configuration.setText("Please wait..");

// Using this configuration with Dialog 
mDialog.setConfiguration(configuration);

// Using this configuration with ArcLoader
mSimpleArcLoader.refreshArcLoaderDrawable(configuration);
You can customize Arc/Dialog with ArcConfiguration methods -
  • setLoaderStyle(SimpleArcLoader.STYLE mLoaderStyle)
  • setArcMargin(int mArcMargin)
  • setArcWidthInPixel(int mStrokeWidth)
  • setColors(int[] colors)
  • setTypeFace(Typeface typeFace)
  • setText(String mText)
  • setTextColor(int mTextColor)
  • setTextSize(int size)
  • setAnimationSpeedWithIndex(int mAnimationIndex) Values to be passed SimpleArcLoader.SPEED_SLOW, SimpleArcLoader.SPEED_MEDIUM, SimpleArcLoader.SPEED_FAST
Please refer the examples for some of the customization.

Saturday 23 January 2016

Floating Search View


Floating Search View

Yet another floating search view implementation, also known as persistent search: that implementation fully supports menu (including submenu), logo and animated icon. Dropdown suggestions are backed by a RecyclerView and you can provide your own RecyclerView.AdapterItemDecorator or ItemAnimator. No hiding.

Usage

Add a FloatingSearchView to your view hierarchy, make sure that it takes up the full width and height:
<com.mypopsy.widget.FloatingSearchView
        android:id="@+id/search"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="16dp"
        android:paddingRight="8dp"
        android:paddingLeft="8dp"
        android:background="#90000000"
        android:hint="@string/hint"
        app:logo="@drawable/logo"
        app:fsv_menu="@menu/search"/>
Then, configure your instance and set your listeners to react accordingly:
mSuggestionsAdapter = new MySuggestionsAdapter(); // use a RecyclerView.Adapter
mSearchView.setAdapter(mSuggestionsAdapter);
...
mSearchView.setOnIconClickListener(...);
mSearchView.setOnSearchListener(...);  
mSearchView.addTextChangedListener(...);
mSearchView.setOnSearchFocusChangedListener(...);
Look at the sample.

Menu

The implementation fully supports menu (and submenu):
<com.mypopsy.widget.FloatingSearchView
    ...
    app:fsv_menu="@menu/search"
/>
mSearchView.setOnMenuItemClickListener(...);
Menu items can be automatically hidden when the search view gets focus depending on the value of the MenuItem'sshowAsAction:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/menu1" ... app:showAsAction="always"/> // always shown
    <item android:id="@+id/menu2" ... app:showAsAction="ifRoom"/> // will hide on focus 
    <item android:id="@+id/menu3" ... app:showAsAction="never"/>  // will go into the overflow menu
</menu>

Animated Icon

FloatingSearchView will automagically animate icons drawable, given they declare a progress property:
  • void setProgress(float)
  • float getProgress()

Other

Since the implementation tries to focus on core logic instead of business logic as much as possible, common features like"tap to clear""speech to text" or "loading progress" are voluntarily NOT built-in because they can be easily implemented using menu items as seen in the sample.

Styling

FloatingSearchView do not expose most of TextView's XML attributes (textColor,textSize...). You can style them using theme attributes by applying app:theme for example:
First, create a dedicated theme, possibly heriting from your application theme:
<!-- your custom theme -->
<style name="CustomFloatingSearchViewTheme" parent="AppTheme">
    <item name="editTextStyle">@style/searchViewEditTextStyle</item>
    <item name="android:divider">#c9c9c9</item>
    <item name="android:dividerHeight">1dp</item>
    <item name="colorControlNormal">#696969</item>
</style>

<!-- your custom search view text style --> 
<style name="searchViewEditTextStyle" parent="Widget.AppCompat.EditText">
    <item name="android:textSize">18sp</item>
    <item name="android:textColor">?android:attr/textColorPrimary</item>
    <item name="android:imeOptions">actionSearch</item>
</style>
Then, apply your custom theme through app:theme:
<com.mypopsy.widget.FloatingSearchView
    ...
    app:theme="@style/CustomFloatingSearchViewTheme"
/>
Look at the sample.

Install

This repository can be found on JitPack:
Add it in your root build.gradle at the end of repositories:
allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }
Add the dependency:
dependencies {
            compile 'com.github.renaudcerrato:FloatingSearchView:1.0.0'
    }