Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions .idea/libraries/cardview_v7_25_0_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added app/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:cardview-v7:25.0.1'
}

apply plugin: 'com.google.gms.google-services'
Binary file added app/src/.DS_Store
Binary file not shown.
Binary file added app/src/main/.DS_Store
Binary file not shown.
10 changes: 6 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar"
android:name="android.support.multidex.MultiDexApplication">
<activity android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -37,6 +38,7 @@
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />

<activity android:name=".PrivyDetailsActivity"></activity>
</application>

</manifest>
112 changes: 76 additions & 36 deletions app/src/main/java/com/pulkit4tech/privy/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
Expand All @@ -13,6 +14,8 @@
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
Expand All @@ -27,6 +30,7 @@

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
Expand Down Expand Up @@ -76,6 +80,8 @@ protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState == null) {
setUpInfo();
}

loadMapFragment();
}

@Override
Expand All @@ -91,9 +97,6 @@ private void setUpInfo() {
if (checkIfLoggedIn()) {
fab.hide();
}

navigationView.getMenu().getItem(0).setChecked(true);
loadMapFragment();
}

private void setUpNavigationDrawer() {
Expand All @@ -119,26 +122,39 @@ private void setUpNavigationHeader() {
}

private void setUpNavigationHeaderValue() {
userName.setText(mSharedPreferences.getString(NAME, getString(R.string.sign_in)));
userName.setText(mSharedPreferences.getString(NAME, ""));
emailId.setText(mSharedPreferences.getString(EMAIL, ""));
loadProfilePic();

changeSignInSignOutOption();
}

private void loadProfilePic() {
Glide.with(mContext).load(mSharedPreferences.getString(PROFILE_PIC_URL, ""))
.override(150, 150)
.asBitmap()
.fitCenter()
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.error(R.mipmap.ic_launcher)
.into(profileImg);

changeSignInSignOutOption();
.error(R.drawable.default_avatar)
.into(new BitmapImageViewTarget(profileImg) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
circularBitmapDrawable.setCircular(true);
profileImg.setImageDrawable(circularBitmapDrawable);
}
});
}

private void changeSignInSignOutOption() {
Menu menu = navigationView.getMenu();
MenuItem sign_in_out_item = menu.findItem(R.id.nav_sign_in_out);
if (checkIfLoggedIn()) {
sign_in_out_item.setTitle(R.string.sign_out);
sign_in_out_item.setIcon(this.getResources().getDrawable(R.drawable.sign_out));
} else {
sign_in_out_item.setTitle(R.string.sign_in);
sign_in_out_item.setIcon(this.getResources().getDrawable(R.drawable.sign_in));
}
}

Expand Down Expand Up @@ -233,27 +249,27 @@ public void onBackPressed() {
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// // Handle action bar item clicks here. The action bar will
// // automatically handle clicks on the Home/Up button, so long
// // as you specify a parent activity in AndroidManifest.xml.
// int id = item.getItemId();
//
// //noinspection SimplifiableIfStatement
// if (id == R.id.action_settings) {
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }

@SuppressWarnings("StatementWithEmptyBody")
@Override
Expand All @@ -268,15 +284,38 @@ public boolean onNavigationItemSelected(MenuItem item) {
loadAddNewPrivyActivity();
closeDrawer();
} else if (id == R.id.nav_sign_in_out) {
if (checkIfLoggedIn())
if (checkIfLoggedIn()) {
signOut();
else
} else {
startGoogleSignInActivity(RC_SIGN_IN);
}
} else if (id == R.id.nav_share) {
shareApp();
closeDrawer();
} else if (id == R.id.nav_feedback) {
sendFeedBack();
closeDrawer();
}
//TODO : Add other conditions
return true;
}

private void sendFeedBack() {
Intent Email = new Intent(Intent.ACTION_SEND);
Email.setType("text/email");
Email.putExtra(Intent.EXTRA_EMAIL, new String[]{getString(R.string.app_feedback_mail)});
Email.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject));
startActivity(Intent.createChooser(Email, getString(R.string.send_feedback_msg)));
}

private void shareApp() {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,
getString(R.string.social_share_msg));
sendIntent.setType("text/plain");
startActivity(sendIntent);
}

private void closeDrawer() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
Expand All @@ -285,7 +324,8 @@ private void closeDrawer() {
@Override
protected void onPostResume() {
super.onPostResume();
loadMapFragment();
// if(checkLocationEnabledPermission())
// loadMapFragment();
}

@Override
Expand Down Expand Up @@ -352,7 +392,6 @@ private void handleSignInResult(GoogleSignInResult result) {
}

private void addLoginInfo(GoogleSignInAccount acct) {
// TODO : add Profile Picture
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(LOGGED_IN, true);
if (acct.getDisplayName() != null)
Expand Down Expand Up @@ -403,6 +442,7 @@ private void loadAddNewPrivyActivity() {
}

private void loadMapFragment() {
navigationView.getMenu().getItem(0).setChecked(true);
if (!checkLocationEnabledPermission()) {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSIONS_REQUEST_FINE_LOCATIONS);
} else {
Expand Down
Loading