Skip to content

Commit

Permalink
Fixed user cant change language due to profile creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
AvielCo committed Jun 9, 2020
1 parent 513ca6b commit 3ad3b0c
Show file tree
Hide file tree
Showing 16 changed files with 336 additions and 623 deletions.
6 changes: 6 additions & 0 deletions .idea/render.experimental.xml

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

29 changes: 16 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
android:roundIcon="@mipmap/app_logo2_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".utilities.EntranceDialog"></activity>
<activity android:name=".utilities.PopupEntranceWindow" /> <!-- MAIN ACTIVITY -->
<!-- MAIN ACTIVITY -->
<activity
android:name=".utilities.SplashScreenActivity"
android:launchMode="singleTop"
Expand All @@ -26,10 +25,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".map_profile.profile.WatchProfile"
android:name=".map_profile.profile.ProfileActivity"
android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar" />
android:parentActivityName=".map_profile.maps.MapActivity"
android:theme="@style/AppTheme.NoActionBarWithStatusBar" />

<activity
android:name=".settings.SettingsActivity"
android:launchMode="singleTop"
Expand All @@ -44,7 +46,8 @@
android:parentActivityName=".map_profile.maps.MapActivity" />
<activity
android:name=".settings.admin.UsersListActivity"
android:launchMode="singleTop" /> <!-- Login, Register, Reset/Change password -->
android:launchMode="singleTop" />
<!-- Login, Register, Reset/Change password -->
<activity
android:name=".emailpassword.LoginActivity"
android:launchMode="singleTop"
Expand All @@ -60,7 +63,8 @@
<activity
android:name=".emailpassword.ChangePassActivity"
android:launchMode="singleTop"
android:parentActivityName=".settings.SettingsActivity" /> <!-- Map -->
android:parentActivityName=".settings.SettingsActivity" />
<!-- Map -->
<activity
android:name=".map_profile.maps.MapActivity"
android:launchMode="singleTop"
Expand All @@ -69,24 +73,23 @@
<activity
android:name=".map_profile.maps.LocationsActivity"
android:launchMode="singleTop"
android:parentActivityName=".map_profile.maps.MapActivity" /> <!-- Bulletin Board -->
android:parentActivityName=".map_profile.maps.MapActivity" />
<!-- Bulletin Board -->
<activity
android:name=".bulletinboard.BulletinBoardActivity"
android:launchMode="singleTop"
android:parentActivityName=".map_profile.maps.MapActivity"
android:theme="@style/AppTheme" /> <!-- Profile -->
<activity
android:name=".map_profile.profile.ProfileActivity"
android:launchMode="singleTop"
android:parentActivityName=".map_profile.maps.MapActivity" /> <!-- Contacts -->
android:theme="@style/AppTheme" />

<activity
android:name=".contacts.ContactActivity"
android:launchMode="singleTop"
android:parentActivityName=".map_profile.maps.MapActivity" />
<activity
android:name=".contacts.EditContactActivity"
android:launchMode="singleTop"
android:parentActivityName=".map_profile.maps.MapActivity" /> <!-- Rating -->
android:parentActivityName=".map_profile.maps.MapActivity" />
<!-- Rating -->
<activity
android:name=".RateUsActivity"
android:theme="@style/Theme.AppCompat.DayNight.Dialog.Alert" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener,

private static final String TAG = "LoginActivity";
private static final int REGISTER_REQUEST = 0;
private static final int REMEMBER_REQUEST = 1;
private static String LOG_IN_LOAD;
private TextInputLayout mTextInputEmail, mTextInputPassword;
private long mBackPressedTime;
private LoadToast mLoadToast;
private Bundle bundle;

private String checkbox;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -53,7 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
User currentUser = (User) bundle.getSerializable("current_user");

SharedPreferences preferences = getSharedPreferences("remember_me", MODE_PRIVATE);
String checkbox = preferences.getString("remember", "");
checkbox = preferences.getString("remember", "");
if (checkbox.equals("true")) {
updateUI(mAuth.getCurrentUser(), currentUser);
} else mAuth.signOut();
Expand Down Expand Up @@ -139,8 +140,9 @@ private void updateUI(FirebaseUser firebaseUser, User currentUser) {
if (firebaseUser.isEmailVerified()) {
mLoadToast.success();
if (!currentUser.isBanned()) {
startActivity(new Intent(LoginActivity.this, MapActivity.class)
.putExtras(bundle));
startActivityForResult(new Intent(LoginActivity.this, MapActivity.class)
.putExtras(bundle)
.putExtra("check_box", checkbox.equals("true")), REMEMBER_REQUEST);
} else { //user is banned
startActivity(new Intent(LoginActivity.this, BannedUserActivity.class));
}
Expand Down Expand Up @@ -188,6 +190,15 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
mTextInputPassword.getEditText().setText(password);
}
}
if (requestCode == REMEMBER_REQUEST) {
//if user is checked the remember me checkbox
if (resultCode == RESULT_OK) {
//if user is pressing back button
//we want the app to terminate
finishAffinity();
super.onBackPressed();
}
}
}

@Override
Expand All @@ -212,11 +223,13 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences.Editor editor = preferences.edit();
editor.putString("remember", "true");
editor.apply();
checkbox = "true";
} else {
SharedPreferences preferences = getSharedPreferences("remember_me", MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("remember", "false");
editor.apply();
checkbox = "false";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -22,8 +21,7 @@
import com.evan.parknbark.R;
import com.evan.parknbark.map_profile.MapProfileBottomSheetDialog;
import com.evan.parknbark.map_profile.profile.Profile;
import com.evan.parknbark.map_profile.profile.WatchProfile;
import com.evan.parknbark.settings.admin.UsersListActivity;
import com.evan.parknbark.map_profile.profile.ProfileActivity;
import com.evan.parknbark.utilities.BaseNavDrawerActivity;
import com.evan.parknbark.utilities.User;
import com.google.android.gms.location.FusedLocationProviderClient;
Expand All @@ -39,7 +37,6 @@
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FieldValue;
Expand Down Expand Up @@ -83,6 +80,9 @@ public class MapActivity extends BaseNavDrawerActivity implements OnMapReadyCall
private Marker currentClickedMarker;

private Bundle bundle;
private volatile User currentUser;

private boolean checkBoxRememberMe;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -95,7 +95,9 @@ protected void onCreate(Bundle savedInstanceState) {
CHECKIN_MSG = getString(R.string.checkin_msg);

bundle = getIntent().getExtras();
User currentUser = (User) bundle.getSerializable("current_user");
checkBoxRememberMe = getIntent().getBooleanExtra("check_box", false);

currentUser = (User) bundle.getSerializable("current_user");
currentUserPermission = currentUser.getPermission();

if (!currentUser.isBuiltProfile()) {
Expand All @@ -111,8 +113,11 @@ protected void onResume() {

@Override
public void onBackPressed() {
if (checkBoxRememberMe) {
setResult(RESULT_OK);
}
finish();
FirebaseAuth.getInstance().signOut();
super.onBackPressed();
}

@Override
Expand All @@ -122,6 +127,7 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
if (resultCode != RESULT_OK) {
displayPopupWindow();
} else {
currentUser.setBuiltProfile(true);
db.collection("users").document(mAuth.getCurrentUser().getUid())
.update("builtProfile", true);
}
Expand Down Expand Up @@ -375,7 +381,7 @@ public void checkIn(String title) {
public void displayPopupWindow(){
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
if (which == DialogInterface.BUTTON_POSITIVE)
startActivityForResult(new Intent(MapActivity.this, WatchProfile.class),
startActivityForResult(new Intent(MapActivity.this, ProfileActivity.class),
REQUEST_PROFILE_BUILD);
dialog.dismiss();
};
Expand Down
Loading

0 comments on commit 3ad3b0c

Please sign in to comment.