Skip to content

Commit

Permalink
Disable change password feature, clear preference if another user log…
Browse files Browse the repository at this point in the history
…ged in
  • Loading branch information
alilm committed Mar 17, 2015
1 parent 6afd6d4 commit 67e1789
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.volcano.esecurebox.Intents;
import com.volcano.esecurebox.Managers;
import com.volcano.esecurebox.R;
import com.volcano.esecurebox.util.PrefUtils;
import com.volcano.esecurebox.util.SoftKeyboardUtils;
import com.volcano.esecurebox.util.Utils;

Expand Down Expand Up @@ -95,6 +96,8 @@ public void onClick(View v) {
startActivityForResult(Intents.getSignupIntent(SignupActivity.MODE_CREATE), Intents.REQUEST_CODE_SIGNUP);
}
});

mUsernameEdit.setText(PrefUtils.getPref(PrefUtils.PREF_LAST_USERNAME, null));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class SignupActivity extends AbstractActivity {
private TextView mUsernameErrorText;

private int mExtraMode;
private User mUser ;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -103,7 +102,12 @@ public void onFocusChange(View v, boolean hasFocus) {
mPasswordEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
if (hasFocus) {
mPasswordErrorText.setText(R.string.hint_password_select);
mPasswordErrorText.setTextColor(getResources().getColor(R.color.green));
mPasswordErrorText.setVisibility(View.VISIBLE);
}
else {
isPasswordValid();
}
}
Expand Down Expand Up @@ -204,6 +208,8 @@ private boolean isPasswordValid() {
boolean isValid = true;
if (mPasswordEdit.getText().toString().trim().length() <
getResources().getInteger(R.integer.min_password_length) ) {
mPasswordErrorText.setText(R.string.error_password_minimum_character);
mPasswordErrorText.setTextColor(getResources().getColor(R.color.red_2));
mPasswordErrorText.setVisibility(View.VISIBLE);
isValid = false;
}
Expand Down Expand Up @@ -265,11 +271,11 @@ private void loadProfile() {
mPasswordEdit.setVisibility(View.GONE);
mEmailEdit.setEnabled(false);

mUser = Managers.getAccountManager().getCurrentUser();
mNameEdit.setText(mUser.getName());
mNameEdit.setSelection(mUser.getName().length());
mUsernameEdit.setText(mUser.getUsername());
mEmailEdit.setText(mUser.getEmail());
final User user = Managers.getAccountManager().getCurrentUser();
mNameEdit.setText(user.getName());
mNameEdit.setSelection(user.getName().length());
mUsernameEdit.setText(user.getUsername());
mEmailEdit.setText(user.getEmail());
}

private void update() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.volcano.esecurebox.VlApplication;
import com.volcano.esecurebox.model.User;
import com.volcano.esecurebox.security.SecurityUtils;
import com.volcano.esecurebox.util.PrefUtils;

/**
* Manager handles all operation for users
Expand All @@ -38,13 +39,12 @@ public User getCurrentUser() {
return (User) ParseUser.getCurrentUser();
}

public void signin(String username, final String password, final LogInCallback callback) {
public void signin(final String username, final String password, final LogInCallback callback) {
ParseUser.logInInBackground(username, password, new LogInCallback() {
@Override
public void done(ParseUser parseUser, ParseException e) {
if (e == null) {
broadcastLoginReset();
SecurityUtils.initializeCryptography(password);
initialization(username, password);
}
callback.done(parseUser, e);
}
Expand All @@ -56,7 +56,7 @@ public void signout() {
ParseUser.logOut();
}

public void signup(String username, String name, String password, String email, final SignUpCallback callback) {
public void signup(final String username, final String name, final String password, final String email, final SignUpCallback callback) {
final User user = new User();
user.setUsername(username);
user.setName(name);
Expand All @@ -69,7 +69,7 @@ public void signup(String username, String name, String password, String email,
@Override
public void done(ParseException e) {
if (e == null) {
broadcastLoginReset();
initialization(username, password);
}
callback.done(e);
}
Expand Down Expand Up @@ -134,4 +134,16 @@ private void broadcastLoginReset() {
Managers.getMixpanelManager().setIdentity(getCurrentUser() == null ? null : getCurrentUser().getObjectId());
LocalBroadcastManager.getInstance(VlApplication.getInstance()).sendBroadcast(new Intent(Intents.ACTION_LOGIN_RESET));
}

private void initialization(String username, String password) {
SecurityUtils.initializeCryptography(password);

broadcastLoginReset();

final String lastUsername = PrefUtils.getPref(PrefUtils.PREF_LAST_USERNAME, "");
if (!lastUsername.equals(username)) {
Managers.getApplicationLockManager().getApplicationLock().setPasscode(null);
}
PrefUtils.setPref(PrefUtils.PREF_LAST_USERNAME, username);
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
// Copyright (c) 2015 Volcano. All rights reserved.
package com.volcano.esecurebox.fragment;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.afollestad.materialdialogs.AlertDialogWrapper;
import com.parse.ParseException;
import com.parse.SaveCallback;
import com.volcano.esecurebox.Intents;
import com.volcano.esecurebox.Managers;
import com.volcano.esecurebox.R;
import com.volcano.esecurebox.activity.SignupActivity;
import com.volcano.esecurebox.analytics.MixpanelManager;
import com.volcano.esecurebox.fragment.PasscodeFragment.Mode;
import com.volcano.esecurebox.util.SoftKeyboardUtils;
import com.volcano.esecurebox.util.Utils;
import com.volcano.esecurebox.widget.RobotoEditText;
import com.volcano.esecurebox.widget.RobotoTextView;

import java.util.Collections;

Expand All @@ -34,15 +27,15 @@
public class SettingsFragment extends PreferenceFragment {

private Preference mEditProfilePref;
private Preference mChangePasswordPref;
//private Preference mChangePasswordPref;
private Preference mPasscodeEnablePref;
private Preference mPasscodeChangePref;
private Preference mAboutPref;
private Preference mReportBugPref;
private Preference mRatePref;
private Preference mSharePref;

private AlertDialog mChangePasswordDialog;
//private AlertDialog mChangePasswordDialog;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -58,6 +51,7 @@ public boolean onPreferenceClick(Preference preference) {
}
});

/*
mChangePasswordPref = findPreference(getString(R.string.preference_general_change_password_key));
mChangePasswordPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
Expand Down Expand Up @@ -150,6 +144,7 @@ private void enable(boolean enable) {
return false;
}
});
*/

mPasscodeEnablePref = findPreference(getString(R.string.preference_passcode_enable_key));
mPasscodeEnablePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
public final class PrefUtils {

public static String PREF_LAST_USERNAME = "last_username";
public static String PREF_NAVIGATOR_LAST_CATEGORY = "navigator_last_category";
public static String PREF_NAVIGATOR_USER_LEARNED = "navigator_user_learned";

Expand Down
6 changes: 5 additions & 1 deletion eSecureBox/src/main/res/layout/activity_sign_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
android:inputType="textPassword"
android:imeOptions="actionDone"
android:hint="@string/hint_password"
style="@style/Text.RegularDark16" />
style="@style/Text.RegularDark16">

<requestFocus />

</com.volcano.esecurebox.widget.RobotoEditText>

<com.volcano.esecurebox.widget.RobotoTextView
android:id="@+id/text_password"
Expand Down
1 change: 0 additions & 1 deletion eSecureBox/src/main/res/layout/activity_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
android:id="@+id/text_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/error_password_minimum_character"
android:gravity="center_vertical"
style="@style/Text.RegularRed13"
android:visibility="gone"/>
Expand Down
2 changes: 2 additions & 0 deletions eSecureBox/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<color name="fab_pressed">#A13028</color>
<color name="fab_transparent_background">#79999999</color>

<color name="green">#23850E</color>

<color name="grey_1">#858585</color>
<color name="grey_2">#737373</color>
<color name="grey_3">#8c8c8c</color>
Expand Down
1 change: 1 addition & 0 deletions eSecureBox/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<string name="hint_new_password">New password</string>
<string name="hint_old_password">Old password</string>
<string name="hint_password">Password</string>
<string name="hint_password_select">All of your data is protected by your password. Select a memorable password only by you</string>
<string name="hint_select_sub_category">Select Account Type</string>
<string name="hint_username">Username</string>

Expand Down
4 changes: 2 additions & 2 deletions eSecureBox/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
android:key="@string/preference_general_edit_profile_key"
android:title="@string/preference_general_profile_edit_title"/>

<Preference
<!--<Preference
android:key="@string/preference_general_change_password_key"
android:title="@string/preference_general_change_password_title"/>
android:title="@string/preference_general_change_password_title"/>-->

</PreferenceCategory>

Expand Down

0 comments on commit 67e1789

Please sign in to comment.