Skip to content

Commit

Permalink
Merge pull request #7 from pawanchauhan05/0.0.3
Browse files Browse the repository at this point in the history
0.0.3
  • Loading branch information
pawanchauhan05 authored Apr 3, 2017
2 parents 076ca69 + 8c117b6 commit a5a5573
Show file tree
Hide file tree
Showing 21 changed files with 844 additions and 37 deletions.
148 changes: 144 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ 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
#### Add gradle dependecy

```
dependencies {
compile 'com.github.pawanchauhan05:utility:0.0.2'
compile 'com.github.pawanchauhan05:utility:0.0.3-beta1'
}
```
## How to use ?
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
<com.android.utility.CircularImageView
android:id="@+id/circularImageView"
android:src="@drawable/drawable_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
```
```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
<application>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
</application>
```
* strings.xml
```xml
<resources>
<string name="facebook_app_id">add_facebook_app_id</string>
</resources>
```
* 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
Expand Down
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
48 changes: 48 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<activity android:name=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
22 changes: 9 additions & 13 deletions app/src/main/java/com/androidutility/activity/MainActivity.java
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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);
}

}
12 changes: 11 additions & 1 deletion app/src/main/java/com/androidutility/fragment/TestFragment.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
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;

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;

Expand All @@ -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;
Expand Down
Binary file added app/src/main/res/drawable/pp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
android:orientation="vertical"
tools:context="com.androidutility.activity.MainActivity">

<com.android.utility.CircularImageView
android:visibility="gone"
android:id="@+id/circularImageView"
android:src="@drawable/pp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<Button
android:text="check permission"
android:onClick="checkPermission"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="facebook_app_id">379480245784222</string>
</resources>
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.google.gms:google-services:3.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 3 additions & 1 deletion utility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ext {
siteUrl = 'https://github.com/pawanchauhan05/AndroidUtility'
gitUrl = 'https://github.com/pawanchauhan05/AndroidUtility.git'

libraryVersion = '0.0.2'
libraryVersion = '0.0.3'

developerId = 'pawanchauhan05'
developerName = 'Pawan Singh Chauhan'
Expand Down Expand Up @@ -53,6 +53,8 @@ dependencies {
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.android.support:design:25.1.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services-auth:10.2.0'
testCompile 'junit:junit:4.12'
}

Expand Down
Loading

0 comments on commit a5a5573

Please sign in to comment.