Skip to content

Commit 1b2dab7

Browse files
authored
Merge pull request #43 from pulkit4tech/dev
Beta Release
2 parents a48291e + ff05177 commit 1b2dab7

30 files changed

+718
-77
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.idea/libraries/cardview_v7_25_0_1.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.DS_Store

6 KB
Binary file not shown.

app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies {
3737
compile 'com.android.volley:volley:1.0.0'
3838
compile 'com.google.android.gms:play-services:10.0.1'
3939
compile 'com.github.bumptech.glide:glide:3.7.0'
40+
compile 'com.android.support:cardview-v7:25.0.1'
4041
}
4142

4243
apply plugin: 'com.google.gms.google-services'

app/src/.DS_Store

6 KB
Binary file not shown.

app/src/main/.DS_Store

6 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
<uses-permission android:name="android.permission.INTERNET" />
1212

1313
<application
14+
android:name="android.support.multidex.MultiDexApplication"
1415
android:allowBackup="true"
15-
android:icon="@mipmap/ic_launcher"
16+
android:icon="@drawable/app_icon"
1617
android:label="@string/app_name"
1718
android:supportsRtl="true"
18-
android:theme="@style/AppTheme.NoActionBar"
19-
android:name="android.support.multidex.MultiDexApplication">
20-
<activity android:name=".MainActivity"
19+
android:theme="@style/AppTheme.NoActionBar">
20+
<activity
21+
android:name=".MainActivity"
2122
android:screenOrientation="portrait">
2223
<intent-filter>
2324
<action android:name="android.intent.action.MAIN" />
@@ -37,6 +38,7 @@
3738
android:name="com.google.android.geo.API_KEY"
3839
android:value="@string/google_maps_key" />
3940

41+
<activity android:name=".PrivyDetailsActivity"></activity>
4042
</application>
4143

4244
</manifest>

app/src/main/java/com/pulkit4tech/privy/MainActivity.java

+76-36
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Intent;
55
import android.content.SharedPreferences;
66
import android.content.pm.PackageManager;
7+
import android.graphics.Bitmap;
78
import android.support.annotation.NonNull;
89
import android.support.design.widget.CoordinatorLayout;
910
import android.support.design.widget.FloatingActionButton;
@@ -13,6 +14,8 @@
1314
import android.support.v4.app.Fragment;
1415
import android.os.Bundle;
1516
import android.support.v4.app.FragmentTransaction;
17+
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
18+
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
1619
import android.support.v4.view.GravityCompat;
1720
import android.support.v4.widget.DrawerLayout;
1821
import android.support.v7.app.ActionBarDrawerToggle;
@@ -27,6 +30,7 @@
2730

2831
import com.bumptech.glide.Glide;
2932
import com.bumptech.glide.load.engine.DiskCacheStrategy;
33+
import com.bumptech.glide.request.target.BitmapImageViewTarget;
3034
import com.google.android.gms.auth.api.Auth;
3135
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
3236
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
@@ -76,6 +80,8 @@ protected void onCreate(Bundle savedInstanceState) {
7680
if (savedInstanceState == null) {
7781
setUpInfo();
7882
}
83+
84+
loadMapFragment();
7985
}
8086

8187
@Override
@@ -91,9 +97,6 @@ private void setUpInfo() {
9197
if (checkIfLoggedIn()) {
9298
fab.hide();
9399
}
94-
95-
navigationView.getMenu().getItem(0).setChecked(true);
96-
loadMapFragment();
97100
}
98101

99102
private void setUpNavigationDrawer() {
@@ -119,26 +122,39 @@ private void setUpNavigationHeader() {
119122
}
120123

121124
private void setUpNavigationHeaderValue() {
122-
userName.setText(mSharedPreferences.getString(NAME, getString(R.string.sign_in)));
125+
userName.setText(mSharedPreferences.getString(NAME, ""));
123126
emailId.setText(mSharedPreferences.getString(EMAIL, ""));
127+
loadProfilePic();
128+
129+
changeSignInSignOutOption();
130+
}
131+
132+
private void loadProfilePic() {
124133
Glide.with(mContext).load(mSharedPreferences.getString(PROFILE_PIC_URL, ""))
125-
.override(150, 150)
134+
.asBitmap()
126135
.fitCenter()
127-
.crossFade()
128136
.diskCacheStrategy(DiskCacheStrategy.ALL)
129-
.error(R.mipmap.ic_launcher)
130-
.into(profileImg);
131-
132-
changeSignInSignOutOption();
137+
.error(R.drawable.default_avatar)
138+
.into(new BitmapImageViewTarget(profileImg) {
139+
@Override
140+
protected void setResource(Bitmap resource) {
141+
RoundedBitmapDrawable circularBitmapDrawable =
142+
RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
143+
circularBitmapDrawable.setCircular(true);
144+
profileImg.setImageDrawable(circularBitmapDrawable);
145+
}
146+
});
133147
}
134148

135149
private void changeSignInSignOutOption() {
136150
Menu menu = navigationView.getMenu();
137151
MenuItem sign_in_out_item = menu.findItem(R.id.nav_sign_in_out);
138152
if (checkIfLoggedIn()) {
139153
sign_in_out_item.setTitle(R.string.sign_out);
154+
sign_in_out_item.setIcon(this.getResources().getDrawable(R.drawable.sign_out));
140155
} else {
141156
sign_in_out_item.setTitle(R.string.sign_in);
157+
sign_in_out_item.setIcon(this.getResources().getDrawable(R.drawable.sign_in));
142158
}
143159
}
144160

@@ -233,27 +249,27 @@ public void onBackPressed() {
233249
}
234250
}
235251

236-
@Override
237-
public boolean onCreateOptionsMenu(Menu menu) {
238-
// Inflate the menu; this adds items to the action bar if it is present.
239-
getMenuInflater().inflate(R.menu.main, menu);
240-
return true;
241-
}
242-
243-
@Override
244-
public boolean onOptionsItemSelected(MenuItem item) {
245-
// Handle action bar item clicks here. The action bar will
246-
// automatically handle clicks on the Home/Up button, so long
247-
// as you specify a parent activity in AndroidManifest.xml.
248-
int id = item.getItemId();
249-
250-
//noinspection SimplifiableIfStatement
251-
if (id == R.id.action_settings) {
252-
return true;
253-
}
254-
255-
return super.onOptionsItemSelected(item);
256-
}
252+
// @Override
253+
// public boolean onCreateOptionsMenu(Menu menu) {
254+
// // Inflate the menu; this adds items to the action bar if it is present.
255+
// getMenuInflater().inflate(R.menu.main, menu);
256+
// return true;
257+
// }
258+
//
259+
// @Override
260+
// public boolean onOptionsItemSelected(MenuItem item) {
261+
// // Handle action bar item clicks here. The action bar will
262+
// // automatically handle clicks on the Home/Up button, so long
263+
// // as you specify a parent activity in AndroidManifest.xml.
264+
// int id = item.getItemId();
265+
//
266+
// //noinspection SimplifiableIfStatement
267+
// if (id == R.id.action_settings) {
268+
// return true;
269+
// }
270+
//
271+
// return super.onOptionsItemSelected(item);
272+
// }
257273

258274
@SuppressWarnings("StatementWithEmptyBody")
259275
@Override
@@ -268,15 +284,38 @@ public boolean onNavigationItemSelected(MenuItem item) {
268284
loadAddNewPrivyActivity();
269285
closeDrawer();
270286
} else if (id == R.id.nav_sign_in_out) {
271-
if (checkIfLoggedIn())
287+
if (checkIfLoggedIn()) {
272288
signOut();
273-
else
289+
} else {
274290
startGoogleSignInActivity(RC_SIGN_IN);
291+
}
292+
} else if (id == R.id.nav_share) {
293+
shareApp();
294+
closeDrawer();
295+
} else if (id == R.id.nav_feedback) {
296+
sendFeedBack();
297+
closeDrawer();
275298
}
276-
//TODO : Add other conditions
277299
return true;
278300
}
279301

302+
private void sendFeedBack() {
303+
Intent Email = new Intent(Intent.ACTION_SEND);
304+
Email.setType("text/email");
305+
Email.putExtra(Intent.EXTRA_EMAIL, new String[]{getString(R.string.app_feedback_mail)});
306+
Email.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject));
307+
startActivity(Intent.createChooser(Email, getString(R.string.send_feedback_msg)));
308+
}
309+
310+
private void shareApp() {
311+
Intent sendIntent = new Intent();
312+
sendIntent.setAction(Intent.ACTION_SEND);
313+
sendIntent.putExtra(Intent.EXTRA_TEXT,
314+
getString(R.string.social_share_msg));
315+
sendIntent.setType("text/plain");
316+
startActivity(sendIntent);
317+
}
318+
280319
private void closeDrawer() {
281320
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
282321
drawer.closeDrawer(GravityCompat.START);
@@ -285,7 +324,8 @@ private void closeDrawer() {
285324
@Override
286325
protected void onPostResume() {
287326
super.onPostResume();
288-
loadMapFragment();
327+
// if(checkLocationEnabledPermission())
328+
// loadMapFragment();
289329
}
290330

291331
@Override
@@ -352,7 +392,6 @@ private void handleSignInResult(GoogleSignInResult result) {
352392
}
353393

354394
private void addLoginInfo(GoogleSignInAccount acct) {
355-
// TODO : add Profile Picture
356395
SharedPreferences.Editor editor = mSharedPreferences.edit();
357396
editor.putBoolean(LOGGED_IN, true);
358397
if (acct.getDisplayName() != null)
@@ -403,6 +442,7 @@ private void loadAddNewPrivyActivity() {
403442
}
404443

405444
private void loadMapFragment() {
445+
navigationView.getMenu().getItem(0).setChecked(true);
406446
if (!checkLocationEnabledPermission()) {
407447
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSIONS_REQUEST_FINE_LOCATIONS);
408448
} else {

0 commit comments

Comments
 (0)