-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c2ef894
Showing
33 changed files
with
902 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "26.0.0" | ||
defaultConfig { | ||
applicationId "com.rishabh.socialgrub" | ||
minSdkVersion 15 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
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' | ||
}) | ||
compile 'com.android.support:appcompat-v7:25.3.1' | ||
compile 'com.android.support:design:25.3.1' | ||
testCompile 'junit:junit:4.12' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /home/rishabh/Android/Sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/rishabh/socialgrub/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.rishabh.socialgrub; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { | ||
@Test public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.rishabh.socialgrub", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="github.nisrulz.tablayout" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/rishabh/socialgrub/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.rishabh.socialgrub; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.design.widget.NavigationView; | ||
import android.support.design.widget.TabLayout; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v4.widget.DrawerLayout; | ||
import android.support.v7.app.ActionBarDrawerToggle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.MenuItem; | ||
import com.rishabh.socialgrub.adaptor.TabsPagerAdapter; | ||
import github.nisrulz.tablayout.R; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
Toolbar toolbar; | ||
TabLayout tabLayout; | ||
private ViewPager viewPager; | ||
private TabsPagerAdapter mAdapter; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
initNavDrawerToggel(); | ||
} | ||
|
||
private void initNavDrawerToggel() { | ||
toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
//toolbar.setTitle("InstaGrabber"); | ||
|
||
// Initilization | ||
viewPager = (ViewPager) findViewById(R.id.pager); | ||
|
||
|
||
mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); | ||
viewPager.setAdapter(mAdapter); | ||
|
||
tabLayout = (TabLayout) findViewById(R.id.tab_layout); | ||
tabLayout.addTab(tabLayout.newTab().setText("Facebook")); | ||
tabLayout.addTab(tabLayout.newTab().setText("Instagram")); | ||
tabLayout.addTab(tabLayout.newTab().setText("Twitter")); | ||
|
||
tabLayout.setupWithViewPager(viewPager); | ||
getSupportActionBar().setHomeButtonEnabled(true); | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.rishabh.socialgrub; | ||
|
||
import android.Manifest; | ||
import android.annotation.TargetApi; | ||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.DialogInterface; | ||
import android.content.pm.PackageManager; | ||
import android.os.Build; | ||
import android.support.v4.app.ActivityCompat; | ||
import android.support.v4.content.ContextCompat; | ||
import android.support.v7.app.AlertDialog; | ||
|
||
/** | ||
* Created by rishabh on 25/2/17. | ||
*/ | ||
|
||
public class Utilities { | ||
|
||
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 123; | ||
|
||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) | ||
public static boolean checkPermission(final Context context) { | ||
int currentAPIVersion = Build.VERSION.SDK_INT; | ||
if (currentAPIVersion >= android.os.Build.VERSION_CODES.M) { | ||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { | ||
if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, Manifest.permission.READ_EXTERNAL_STORAGE)) { | ||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); | ||
alertBuilder.setCancelable(true); | ||
alertBuilder.setTitle("Permission necessary"); | ||
alertBuilder.setMessage("External storage permission is necessary"); | ||
alertBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { | ||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) | ||
public void onClick(DialogInterface dialog, int which) { | ||
ActivityCompat.requestPermissions((Activity) context, new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); | ||
} | ||
}); | ||
AlertDialog alert = alertBuilder.create(); | ||
alert.show(); | ||
} else { | ||
ActivityCompat.requestPermissions((Activity) context, new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); | ||
} | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
// check permission utility | ||
public static int REQUEST = 100; | ||
|
||
public static boolean getCameraPermission(Activity activity) { | ||
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { | ||
ActivityCompat.requestPermissions(activity, new String[]{ Manifest.permission.CAMERA}, | ||
REQUEST); | ||
} else { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public static boolean getStoragePermission(Activity activity) { | ||
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ActivityCompat | ||
.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { | ||
ActivityCompat.requestPermissions(activity, new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, | ||
REQUEST); | ||
} else { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
|
||
|
||
public static boolean getLocationPermission(Activity activity) { | ||
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || ActivityCompat | ||
.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { | ||
ActivityCompat.requestPermissions(activity, new String[]{ Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, | ||
REQUEST); | ||
} else { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
app/src/main/java/com/rishabh/socialgrub/adaptor/TabsPagerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.rishabh.socialgrub.adaptor; | ||
|
||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentManager; | ||
import android.support.v4.app.FragmentStatePagerAdapter; | ||
import android.util.SparseArray; | ||
import android.view.ViewGroup; | ||
import com.rishabh.socialgrub.tabs.FacebookFragment; | ||
import com.rishabh.socialgrub.tabs.InstagramFragment; | ||
import com.rishabh.socialgrub.tabs.TwitterFragment; | ||
import java.lang.ref.WeakReference; | ||
|
||
public class TabsPagerAdapter extends FragmentStatePagerAdapter { | ||
|
||
private final SparseArray<WeakReference<Fragment>> instantiatedFragments = new SparseArray<>(); | ||
|
||
|
||
public TabsPagerAdapter(FragmentManager fm) { | ||
super(fm); | ||
} | ||
|
||
@Override | ||
public Fragment getItem(int index) { | ||
|
||
switch (index) { | ||
case 0: | ||
FacebookFragment facebookFragment =new FacebookFragment(); | ||
facebookFragment.setRetainInstance(true); | ||
return facebookFragment; | ||
case 1: | ||
InstagramFragment instagramFragment=new InstagramFragment(); | ||
instagramFragment.setRetainInstance(true); | ||
return instagramFragment; | ||
case 2: | ||
TwitterFragment twitterFragment=new TwitterFragment(); | ||
twitterFragment.setRetainInstance(true); | ||
return twitterFragment; | ||
default: | ||
return new FacebookFragment(); | ||
} | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
// get item count - equal to number of tabs | ||
return 2; | ||
} | ||
|
||
|
||
@Override public CharSequence getPageTitle(int position) { | ||
if(position==0){ | ||
return new String("Download"); | ||
}else { | ||
return new String("History"); | ||
} | ||
} | ||
|
||
@Override | ||
public Object instantiateItem(final ViewGroup container, final int position) { | ||
final Fragment fragment = (Fragment) super.instantiateItem(container, position); | ||
instantiatedFragments.put(position, new WeakReference<>(fragment)); | ||
return fragment; | ||
} | ||
|
||
@Override | ||
public void destroyItem(final ViewGroup container, final int position, final Object object) { | ||
instantiatedFragments.remove(position); | ||
super.destroyItem(container, position, object); | ||
} | ||
|
||
@Nullable | ||
public Fragment getFragment(final int position) { | ||
final WeakReference<Fragment> wr = instantiatedFragments.get(position); | ||
if (wr != null) { | ||
return wr.get(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/rishabh/socialgrub/tabs/FacebookFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.rishabh.socialgrub.tabs; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.webkit.WebSettings; | ||
import android.webkit.WebView; | ||
import android.widget.Toast; | ||
import github.nisrulz.tablayout.R; | ||
|
||
public class FacebookFragment extends Fragment { | ||
|
||
private WebView mWebView; | ||
|
||
@Override | ||
public void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
Log.i("Tag1","GamesFrag"); | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
|
||
View rootView = inflater.inflate(R.layout.fragment_facebook, container, false); | ||
|
||
mWebView = (WebView) rootView.findViewById(R.id.wvFacebook); | ||
|
||
WebSettings webSettings = mWebView.getSettings(); | ||
webSettings.setJavaScriptEnabled(true); | ||
|
||
String url="https://www.facebook.com/"; | ||
if(url!=null) { | ||
mWebView.loadUrl(url); | ||
}else{ | ||
Toast.makeText(getContext(), "URL Dead", Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
return rootView; | ||
} | ||
|
||
} |
Oops, something went wrong.