Friday 20 May 2016

BubbleLayout

BubbleLayout

Bubble View for Android with custom stroke width and color, arrow size, position and direction.
BubbleLayout Extends the FrameLayout.

Gradle

Add the dependency to your build.gradle.
dependencies {
    compile 'com.daasuu:BubbleLayout:1.0.0'
}

Basic Usage


Include the BubbleLayout widget in your layout.
<com.daasuu.bl.BubbleLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="12dp"
    android:padding="8dp"
    app:bl_arrowDirection="right"
    app:bl_arrowHeight="8dp"
    app:bl_arrowPosition="16dp"
    app:bl_arrowWidth="8dp"
    app:bl_cornersRadius="6dp"
    app:bl_strokeWidth="1dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="4dp"
        android:text="BubbleLayout"
        android:textColor="@android:color/holo_red_dark" />

</com.daasuu.bl.BubbleLayout>

Attributes

There are several attributes you can set:
attrdescription
bl_arrowWidthWidth of the arrow, default 8dp
bl_arrowHeightHeight of the arrow, default 8dp
bl_arrowPositionPosition of the arrow, default 12dp
bl_cornersRadiusCorner radius of the BubbleLayout, default 0dp
bl_bubbleColorColor of the BubbleLayout, default WHITE
bl_strokeWidthWidth of the stroke, default 0dp
bl_strokeColorColor of the stroke, default GLAY
bl_arrowDirectionDrawing position of the arrow : 'left' or 'top' or 'right' or 'bottom', default 'left'

Samples

<com.daasuu.bl.BubbleLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="12dp"
    android:padding="8dp"
    app:bl_arrowDirection="top"
    app:bl_arrowHeight="8dp"
    app:bl_arrowPosition="12dp"
    app:bl_arrowWidth="8dp"
    app:bl_bubbleColor="@android:color/holo_blue_light"
    app:bl_cornersRadius="8dp">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:src="@mipmap/ic_launcher" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="4dp"
            android:text="BubbleLayout"
            android:textColor="@android:color/holo_red_dark" />

    </LinearLayout>

</com.daasuu.bl.BubbleLayout>

<com.daasuu.bl.BubbleLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="8dp"
    app:bl_arrowDirection="left"
    app:bl_arrowHeight="8dp"
    app:bl_arrowPosition="16dp"
    app:bl_arrowWidth="8dp"
    app:bl_strokeWidth="1dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="4dp"
        android:text="BubbleLayout"
        android:textColor="@android:color/holo_red_dark" />

</com.daasuu.bl.BubbleLayout>

Button button = (Button) findViewById(R.id.btn_popup);

BubbleLayout bubbleLayout = (BubbleLayout) LayoutInflater.from(this).inflate(R.layout.layout_sample_popup, null);
PopupWindow popupWindow = BubblePopupHelper.create(this, bubbleLayout);

button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        int[] location = new int[2];
        v.getLocationInWindow(location);
        popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0], v.getHeight() + location[1]);
    }
});
layout_sample_popup.xml
<?xml version="1.0" encoding="utf-8"?>
<com.daasuu.bl.BubbleLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="@dimen/activity_horizontal_margin"
    app:bl_arrowDirection="top"
    app:bl_arrowHeight="12dp"
    app:bl_arrowPosition="16dp"
    app:bl_arrowWidth="8dp"
    app:bl_bubbleColor="@color/colorAccent"
    app:bl_cornersRadius="2dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="4dp"
        android:text="BubbleLayout Popup"
        android:textColor="@android:color/white" />

</com.daasuu.bl.BubbleLayout>

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.