Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#33 : Added Profile Pic #36

Merged
merged 1 commit into from
Jan 13, 2017
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
11 changes: 11 additions & 0 deletions .idea/libraries/glide_3_7_0.xml

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

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
compile 'com.google.code.gson:gson:2.8.0'
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'
}

apply plugin: 'com.google.gms.google-services'
23 changes: 18 additions & 5 deletions app/src/main/java/com/pulkit4tech/privy/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
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 @@ -58,8 +61,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private SharedPreferences mSharedPreferences;
private String NAME = "user_name";
private String EMAIL = "email_id";
private String PROFILE_PIC_URL = "profile_pic_url";
private String LOGGED_IN = "logged_in";
// private ImageView profileImg;
private ImageView profileImg;
private TextView userName, emailId;

@Override
Expand Down Expand Up @@ -107,7 +111,7 @@ private void setUpNavigationDrawer() {

private void setUpNavigationHeader() {
View nav_head = navigationView.getHeaderView(0);
// profileImg = (ImageView) nav_head.findViewById(R.id.profile_pic);
profileImg = (ImageView) nav_head.findViewById(R.id.profile_pic);
userName = (TextView) nav_head.findViewById(R.id.user_name);
emailId = (TextView) nav_head.findViewById(R.id.email_id);

Expand All @@ -118,6 +122,12 @@ private void setUpNavigationHeaderValue() {
// TODO : Set Profile Image
userName.setText(mSharedPreferences.getString(NAME, getString(R.string.sign_in)));
emailId.setText(mSharedPreferences.getString(EMAIL, ""));
Glide.with(mContext).load(mSharedPreferences.getString(PROFILE_PIC_URL, ""))
.thumbnail(0.5f)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.error(R.mipmap.ic_launcher)
.into(profileImg);

changeSignInSignOutOption();
}
Expand Down Expand Up @@ -174,7 +184,6 @@ private void setGoogleApiClientInfo() {
// Testing Google Sign in
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestProfile()
.build();

// Build a GoogleApiClient with access to the Google Sign-In API and the
Expand Down Expand Up @@ -340,8 +349,12 @@ private void addLoginInfo(GoogleSignInAccount acct) {
// TODO : add Profile Picture
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(LOGGED_IN, true);
editor.putString(NAME, acct.getDisplayName());
editor.putString(EMAIL, acct.getEmail());
if (acct.getDisplayName() != null)
editor.putString(NAME, acct.getDisplayName());
if (acct.getEmail() != null)
editor.putString(EMAIL, acct.getEmail());
if (acct.getPhotoUrl() != null)
editor.putString(PROFILE_PIC_URL, acct.getPhotoUrl().toString());
editor.commit();

snackMsg(getString(R.string.sign_in_msg));
Expand Down
Binary file added app/src/main/res/drawable/default_avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/default_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions app/src/main/res/layout/app_bar_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:layout_gravity="bottom|start"
android:layout_marginBottom="@dimen/fab_margin_bottom"
android:layout_marginStart="@dimen/fab_margin_start"
app:srcCompat="@drawable/google"
app:backgroundTint="@android:color/white"
/>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/nav_header_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"

app:srcCompat="@android:drawable/sym_def_app_icon" />

<TextView
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="nav_header_height">160dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="activity_horizontal_margin">16sp</dimen>
<dimen name="nav_header_height">160sp</dimen>
<dimen name="activity_vertical_margin">16sp</dimen>
<dimen name="nav_header_vertical_spacing">16sp</dimen>
<dimen name="fab_margin">16sp</dimen>

<!--Floating action button-->
<dimen name="design_fab_image_size" tools:override="true">36dp</dimen>
<dimen name="fab_margin_bottom">30sp</dimen>
<dimen name="fab_margin_start">10sp</dimen>
</resources>