Skip to content

Commit

Permalink
Merge pull request RohitSurwase#3 from Rohitss/develop
Browse files Browse the repository at this point in the history
All demos are published with steps.
  • Loading branch information
rohitss authored Jan 1, 2017
2 parents 4aa272a + 7035d0d commit e84077c
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 41 deletions.
2 changes: 2 additions & 0 deletions AutoReadSmsOtp/AutoReadSmsOtp.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Auto Read SMS or OTP with runtime-permission

* Steps:
* 1. Add Permissions to manifest
* * <uses-permission android:name="android.permission.READ_SMS" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* This class is used to Auto Read SMS Received.
* Created by Rohit.
* Created by rohitss.
*/
public class SmsReceiver extends BroadcastReceiver {
//TODO: Change this constant according to your project "SMS_SENDER_NAME"
Expand Down
3 changes: 3 additions & 0 deletions NavigationDrawerInApp/NavigationDrawerInApp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Navigation Drawer throughout application.

This demo will be ready soon.
10 changes: 5 additions & 5 deletions NavigationDrawerInApp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -21,9 +21,9 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
// exclude group: 'com.android.support', module: 'support-annotations'
// })
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
// testCompile 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.rohitss.navigationdrawerinapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

Expand All @@ -10,4 +10,5 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
//TODO: This demo app will be ready soon.
}
4 changes: 0 additions & 4 deletions NavigationDrawerInApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ buildscript {
}

allprojects {
//You do not need to change buildDir if you have placed your project at root directory
//path of buildDir depends on the machine where you are working
// buildDir = "C:\\AndroidProjectBuild/${rootProject.name}/${project.name}"

repositories {
jcenter()
}
Expand Down
10 changes: 9 additions & 1 deletion PickAndCropImage/PickAndCropImage.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
//Step 1. Add Gradle dependency to app-gradle.
This demo app show, how we can add image chooser with material UI
Image chooser will include all gallery and camera apps.
Best part is that we can also crop selected image using this demo code.
To crop image I have used "Android-Image-Cropper" by "ArthurHub" library.
* Library github link - "https://github.com/ArthurHub/Android-Image-Cropper"
//Step 1. Add Gradle dependency to app-gradle.
//Step 2. Add CropImageActivity to app-manifest
//Step 3. Add ImageUtilityHelper class in your project.
//Step 4. Create object of ImageUtilityHelper class.
2 changes: 1 addition & 1 deletion PickAndCropImage/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* This class is used to Pick and Crop Image using Camera/Gallery application.
* This class uses- "Android-Image-Cropper" by "ArthurHub" library to crop image.
* Library github link - "https://github.com/ArthurHub/Android-Image-Cropper"
* Created by RohitSS
* Created by rohitss
*/

public class ImageUtilityHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import android.view.View;
import android.widget.ImageView;

/**
* This is the activity class where we want to add image picker.
* Created by rohitss.
*/
public class MainActivity extends AppCompatActivity {
public static final int IMAGE_CHOOSER_CODE = 100;
private static final int WRITE_PERMISSION_CODE = 5;
Expand All @@ -38,9 +42,10 @@ protected void onCreate(Bundle savedInstanceState) {

public void pickAndCropImage(View view) {
if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
//Permission denied, so request permission
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_PERMISSION_CODE);
} else {
//TODO: Function that requires permission
//Permission allowed
getImageChooser();
}
}
Expand Down
44 changes: 31 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
AndroidDesignPatterns
Android Design Patterns

Collection of best code snippets to help everyone to simplify android app development.
Collection of best code snippets to help everyone to simplify Android App Development.

Basic idea of this project is to gather all the example of different topics at one place.
Basic idea of this repository is to gather all the example of different topics at one place.

Currently this collection includes
1. Different ways to show splash screen
2. Best and correct way to show splash screen.
3. Adding Navigation Drawer throughout the application
4. Swipeable tabs with TabLayout
5. Auto read SMS/OTP
6. Image Picker with camera and gallery options.

Demos which will be added soon
- Synchronised Local SQLite Database.
- Most effective way to use RecyclerView
- Activity Life Cycle Methods
- Fragment Life Cycle Methods

Sample for commenting functions/activities in this project
/**
* <b>functionName</b>
* <p>This function is used to ....</p>
* <p1>Created By - userName</p1>
*/


# /**
# * <b>functionName</b>
# * <p>This function is used to ....</p>
# * <p1>Created By - userName</p1>
# */
Ex.-
/**
* <b>private void showSplashScreen()</b>
* <p>This function is used to show splash screen</p>
* <p1>Created By - Rohitss</p1>
*/
# /**
# * <b>private void showSplashScreen()</b>
# * <p>This function is used to show splash screen</p>
# * <p1>Created By - Rohitss</p1>
# */
1 change: 1 addition & 0 deletions SplashScreenDemo1/SplashScreenDemo1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This demo shows different ways to show splash screen
3 changes: 3 additions & 0 deletions SplashScreenRightWay/SplashScreenRightWay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This demo shows the right way to show splash screen in application.

This way app don't need to load theme to show splash screen.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;


/**
* Created by JayYogeshwar on 27-12-2016.
* This is dummy activity which will show up after flash screen.
* Created By rohitss.
*/
public class SecondActivity extends AppCompatActivity {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
import android.view.Window;
import android.view.WindowManager;

/**
* This is activity class which will act as a flash screen.
* This class dont have any view at all.
* Created By rohitss.
*/
public class SplashActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
//setContentView is not needed as we are showing splash screen using theme in styles.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//Add 2 seconds pause for splash screen using handler
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
Expand All @@ -27,6 +34,7 @@ public void run() {
@Override
protected void onStop() {
super.onStop();
//finish splash screen activity.
finish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

/**
* This is the class where we want to add swipeable tabs.
* Created By - rohitss.
*/
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Initialize VIewPager
ViewPager mViewPager = (ViewPager) findViewById(R.id.viewPager_Home);
TabLayout mTabLayout = (TabLayout) findViewById(R.id.tabLayout_Home);
MyViewPagerAdapter myViewPagerAdapter = new MyViewPagerAdapter(getSupportFragmentManager());
mViewPager.setAdapter(myViewPagerAdapter);
//Sync TabLayout with ViewPager.
mTabLayout.setupWithViewPager(mViewPager);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import android.support.v4.app.FragmentStatePagerAdapter;

/**
* Created by JayYogeshwar on 06-12-2016.
* This is the adapter class for our ViewPager.
* This class extends FragmentStatePagerAdapter for better performance.
* Created By - rohitss.
*/
public class MyViewPagerAdapter extends FragmentStatePagerAdapter {
private String[] arrTabNames = {"Page 1", "Page 2", "Page 3"};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.rohitss.swipeabletabs;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
* A simple {@link Fragment} subclass.
* This is a dummy fragment.
* Created By - rohitss.
*/
public class OneFragment extends Fragment {

Expand All @@ -25,6 +24,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home, container, false);
}

public static OneFragment newInstance() {

Bundle args = new Bundle();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package com.rohitss.swipeabletabs;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
* A simple {@link Fragment} subclass.
* This is a dummy fragment.
* Created By - rohitss.
*/
public class ThreeFragment extends Fragment {


public ThreeFragment() {
// Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.rohitss.swipeabletabs;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
* A simple {@link Fragment} subclass.
* This is a dummy fragment.
* Created By - rohitss.
*/
public class TwoFragment extends Fragment {

Expand All @@ -25,6 +24,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_charge, container, false);
}

public static TwoFragment newInstance() {

Bundle args = new Bundle();
Expand Down

0 comments on commit e84077c

Please sign in to comment.