diff --git a/README.md b/README.md index 7065b6c..a85a65a 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,11 @@ Android Utility is combination of normal utility functions like described below * show time picker dialog * Hide keyboard panel * Choose image from camera or gallery - +* Endless Scrolling for List view +* Endless Scrolling for Recycler view +* Circular Image View +* Login with Facebook +* Login with Google ## Usage ### Steps @@ -34,7 +38,7 @@ Android Utility is combination of normal utility functions like described below ``` dependencies { - compile 'com.github.pawanchauhan05:utility:0.0.2' + compile 'com.github.pawanchauhan05:utility:0.0.3-beta1' } ``` ## How to use ? @@ -239,11 +243,11 @@ Utils.showTimePicker(getSupportFragmentManager(), new TimeInterface() { } }); ``` -* Hide keyboard panel +### Hide keyboard panel ```java Utils.hideKeyboard(getActivity()); ``` -* Choose image from camera or gallery +### Choose image from camera or gallery ```java public class TestFragment extends Fragment implements RuntimePermissionInitializerInterface { private RunTimePermission permission; @@ -279,7 +283,143 @@ public class TestFragment extends Fragment implements RuntimePermissionInitializ ``` >**_"implement RuntimePermissionInitializerInterface, override onRequestPermissionsResult(), onActivityResult() method is compulsory."_** +### Endless Scroll for List View +```java +listViewInstance.setOnScrollListener(new ListViewEndlessScrollListener() { + @Override + public boolean onLoadMore(int page, int totalItemsCount) { + /* + TODO + 1. show progress dialog + 2. Load data from api + 3. hide progress dialog + */ + return false; // ONLY if more data is actually being loaded; false otherwise. + } + }); +``` +### Endless Scroll for Recycler View +```java +LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); +recyclerViewInstance.setLayoutManager(linearLayoutManager); +recyclerViewInstance.addOnScrollListener(new RecyclerViewEndlessScrollListener(linearLayoutManager) { + @Override + public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { + /* + TODO + 1. Show progress Dialog + 2. load data from api + 3. Hide progress Dialog + */ + } + }); +``` +### Circular image view +```xml + +``` +```java +// set image using java +Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.drawable_name); +circularImageViewInstance.setImageBitmap(icon); +``` +### Login with Facebook +#### Follow steps described below +* AndroidManifest.xml +```xml + + + +``` +* strings.xml +```xml + + add_facebook_app_id + +``` +* Java code +```java +Utils.facebookLogin(new FBLoginInterface() { + @Override + public void doTaskAfterLogin(Bundle facebookBundle) { + // code to be executed after FB login + } + }, getActivity()); + +@Override +protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + FBLogin.onActivityResult(requestCode, resultCode, data); +} +``` +### Login with Google +#### Follow steps described below +* build.gradle (project level gradle file) +```xml +buildscript { + dependencies { + classpath 'com.google.gms:google-services:3.0.0' + } +} +``` +* build.gradle (app level gradle file) +```xml +apply plugin: 'com.android.application' +dependencies { + compile 'com.google.android.gms:play-services-auth:10.2.0' +} +apply plugin: 'com.google.gms.google-services' +``` +* java file +```java +private GoogleSignIn googleSignIn; +@Override +protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + googleSignIn = new GoogleSignIn(this, new GoogleLoginInterface() { + @Override + public void doTaskAfterLogin(Bundle googleBundle) { + // code to be executed after Google login + } + + @Override + public void doTaskAfterSignOut() { + // code to be executed after Logout from Google + } + }); +} + +private void googleLogin() { + Utils.googleLogin(googleSignIn); +} + +private void googleLogout() { + Utils.googleLogout(googleSignIn); +} + +@Override +protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + googleSignIn.onActivityResult(requestCode, resultCode, data); +} +``` +>**_"Add google-services.json at application level."_** + ## Release Notes +### v0.0.3 +* Bug fixes +* Marshmallow permission support added for fragment also +* Endless scroll for list view +* Endless scroll for recycler view +* Circular image view +* Login with Facebook +* Login with Google + ### v0.0.2 * Bug fixes * Show short or long length snackbar diff --git a/app/build.gradle b/app/build.gradle index 154f92c..73375cb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,5 +27,8 @@ dependencies { compile project(':utility') compile 'com.android.support:appcompat-v7:25.1.1' compile 'com.android.support:support-v4:25.1.1' + compile 'com.google.android.gms:play-services-auth:10.2.0' testCompile 'junit:junit:4.12' } + +apply plugin: 'com.google.gms.google-services' diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..958b534 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,48 @@ +{ + "project_info": { + "project_number": "35533953240", + "project_id": "firebase-android-utility" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:35533953240:android:343c624490100f15", + "android_client_info": { + "package_name": "com.androidutility" + } + }, + "oauth_client": [ + { + "client_id": "35533953240-fdr6tit3mp7gfgpg8ac32nniikib3lmc.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.androidutility", + "certificate_hash": "164ec70befb2164772b089d805108820762412dc" + } + }, + { + "client_id": "35533953240-fjv0tof677dmd5rp4aai73nuu67tj9tm.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBRo7WIqHK6hu8E8N_yYavZxiGcc4guLLA" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 1 + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7d343fe..5cd9f47 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> + diff --git a/app/src/main/java/com/androidutility/activity/MainActivity.java b/app/src/main/java/com/androidutility/activity/MainActivity.java index c77e4a9..fcfcc4d 100644 --- a/app/src/main/java/com/androidutility/activity/MainActivity.java +++ b/app/src/main/java/com/androidutility/activity/MainActivity.java @@ -1,19 +1,17 @@ package com.androidutility.activity; -import android.Manifest; -import android.support.v7.app.AppCompatActivity; +import android.content.Intent; import android.os.Bundle; -import android.util.Log; +import android.support.v7.app.AppCompatActivity; import android.view.View; -import com.android.utility.RunTimePermission; -import com.android.utility.RuntimePermissionInterface; + import com.android.utility.Utils; import com.androidutility.R; import com.androidutility.fragment.TestFragment; + public class MainActivity extends AppCompatActivity { - public RunTimePermission permission; private String url = "http://www.maninblack.org/demos/WhereDoAllTheJunkiesComeFrom.mp3"; private String musicFileName = "music"; @@ -28,17 +26,15 @@ protected void onCreate(Bundle savedInstanceState) { } public void checkPermission(View view) { - permission = new RunTimePermission(this, new RuntimePermissionInterface() { - @Override - public void doTaskAfterPermission() { - Log.e("C","F"); - } - }); - permission.runtimePermission(Manifest.permission.WRITE_EXTERNAL_STORAGE); } public void downloadSong(View view) { Utils.downloadMusicFile(url, musicFileName, this); } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + } + } diff --git a/app/src/main/java/com/androidutility/fragment/TestFragment.java b/app/src/main/java/com/androidutility/fragment/TestFragment.java index 6e54289..805e30b 100644 --- a/app/src/main/java/com/androidutility/fragment/TestFragment.java +++ b/app/src/main/java/com/androidutility/fragment/TestFragment.java @@ -1,11 +1,13 @@ package com.androidutility.fragment; +import android.Manifest; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.Fragment; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -13,6 +15,7 @@ import com.android.utility.AlertDialog; import com.android.utility.RunTimePermission; import com.android.utility.RuntimePermissionInitializerInterface; +import com.android.utility.RuntimePermissionInterface; import com.android.utility.Utils; import com.androidutility.R; @@ -31,10 +34,17 @@ public TestFragment() { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_test, container, false); + permission = new RunTimePermission(this, new RuntimePermissionInterface() { + @Override + public void doTaskAfterPermission() { + Log.e("Called","in Fragment"); + + } + }); view.findViewById(R.id.buttonSelectImage).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Utils.selectImage(getActivity(), TestFragment.this, "Select Image"); + Utils.selectImage(TestFragment.this, "Select Image"); } }); return view; diff --git a/app/src/main/res/drawable/pp.jpg b/app/src/main/res/drawable/pp.jpg new file mode 100644 index 0000000..58a2faf Binary files /dev/null and b/app/src/main/res/drawable/pp.jpg differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6d5ebd3..be08c30 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -7,6 +7,13 @@ android:orientation="vertical" tools:context="com.androidutility.activity.MainActivity"> + +