Android Open Source - socialcde4android Change Password Dialog






From Project

Back to project page socialcde4android.

License

The source code is released under:

MIT License

If you think the Android project socialcde4android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package it.uniba.socialcde4android.dialogs;
/*from ww w.  j av a2s  .  c  o m*/


import it.uniba.socialcde4android.R;


import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class ChangePasswordDialog extends DialogFragment{

  private static final String ARG_PASSW = "old passw";
  private String old_password;
  private OnChangePasswordListener mListener;
  private EditText old_password_edit;
  private EditText new_password_edit;
  private EditText repeat_password_edit;
  
  public static ChangePasswordDialog newInstance( String password) {
    ChangePasswordDialog dialog = new ChangePasswordDialog();
    Bundle args = new Bundle();
    args.putString(ARG_PASSW, password);
    dialog.setArguments(args);
    return dialog;
  }

  public ChangePasswordDialog(){
    
  }
  
  public interface OnChangePasswordListener{
    //metodo per cambiare la password
    public void change_password(String new_password);
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Holo_Light_Dialog); 
    if (getArguments() != null) {
      old_password = getArguments().getString(ARG_PASSW);
    }
    mListener = (OnChangePasswordListener) getActivity();
  }
  
  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) {
    View v = null;
  
    v = inflater.inflate(R.layout.dialog_change_password, container, false);
      
        //getDialog().getWindow().setBackgroundDrawableResource(R.drawable.dialog_background);
    old_password_edit = (EditText)  v.findViewById(R.id.editTextdialogOLDPASSWORD);
    new_password_edit = (EditText)  v.findViewById(R.id.editTextDialogNEWPassword);
    repeat_password_edit = (EditText)  v.findViewById(R.id.editTextdialogRepeatPASSWORD);
    old_password_edit.requestFocus();

        Button ok_button = (Button) v.findViewById(R.id.button2_dialog_OKCHANGEPASS);
      Button cancel_button = (Button) v.findViewById(R.id.button1_dialog_CANCELCHANGEPASS);
      
      ok_button.setOnClickListener(new Button.OnClickListener() {
      @Override
      public void onClick(View v) {
        //controlla che la oldpassword sia giusta
        //poi controlla che le nuove password siano uguali tra loro 
        if (old_password_edit.getText().toString().equals("") || new_password_edit.getText().toString().equals("") || repeat_password_edit.getText().toString().equals("") ){
          Toast.makeText(ChangePasswordDialog.this.getActivity(), "Please compile all the fields."  , Toast.LENGTH_SHORT).show();
        }else if (!old_password_edit.getText().toString().equals(old_password)){
          Toast.makeText(ChangePasswordDialog.this.getActivity(), "Please check your old password."  , Toast.LENGTH_SHORT).show();
          Animation shake = AnimationUtils.loadAnimation(ChangePasswordDialog.this.getActivity(), R.anim.shake);
          old_password_edit.startAnimation(shake);
          old_password_edit.setText("");
        }else if (!new_password_edit.getText().toString().equals(repeat_password_edit.getText().toString())){
          Toast.makeText(ChangePasswordDialog.this.getActivity(), "Passwords do not match."  , Toast.LENGTH_SHORT).show();
          Animation shake = AnimationUtils.loadAnimation(ChangePasswordDialog.this.getActivity(), R.anim.shake);
          new_password_edit.startAnimation(shake);
          repeat_password_edit.startAnimation(shake);
          new_password_edit.setText("");
          repeat_password_edit.setText("");
        }else{
          //pu? cambiare la password
          mListener.change_password(new_password_edit.getText().toString());
          ChangePasswordDialog.this.dismiss();
        }
      }
    });
      
      cancel_button.setOnClickListener(new Button.OnClickListener() {
      @Override
      public void onClick(View v) {
        ChangePasswordDialog.this.dismiss();
      }
    });
        return v;
    }

    
}




Java Source Code List

it.uniba.socialcde4android.activity.HomeActivity.java
it.uniba.socialcde4android.activity.LoginActivity.java
it.uniba.socialcde4android.activity.RegistrationActivity.java
it.uniba.socialcde4android.activity.WebViewActivity.java
it.uniba.socialcde4android.adapters.ConfiguratedImageLoader.java
it.uniba.socialcde4android.adapters.FeaturesAdapter.java
it.uniba.socialcde4android.adapters.ServicesAdapter.java
it.uniba.socialcde4android.adapters.SquareImageView.java
it.uniba.socialcde4android.adapters.TimeLineAdapter.java
it.uniba.socialcde4android.adapters.UserAvatarsAdapter.java
it.uniba.socialcde4android.adapters.UsersAdapter.java
it.uniba.socialcde4android.config.Config.java
it.uniba.socialcde4android.costants.Consts.java
it.uniba.socialcde4android.costants.Error_consts.java
it.uniba.socialcde4android.costants.Services_id.java
it.uniba.socialcde4android.data.operation.Authorize_Operation.java
it.uniba.socialcde4android.data.operation.ChangePasswordWithPassword_Operation.java
it.uniba.socialcde4android.data.operation.GetAvailableAvatars_Operation.java
it.uniba.socialcde4android.data.operation.GetColleagueProfile_Operation.java
it.uniba.socialcde4android.data.operation.GetFeatures_Operation.java
it.uniba.socialcde4android.data.operation.GetFriends_Operation.java
it.uniba.socialcde4android.data.operation.GetHideSettings_Operation.java
it.uniba.socialcde4android.data.operation.GetOAuthData_Operation.java
it.uniba.socialcde4android.data.operation.GetUser_Operation.java
it.uniba.socialcde4android.data.operation.IsUsernameAvailable_Operation.java
it.uniba.socialcde4android.data.operation.IsWebServiceRunning_Operation.java
it.uniba.socialcde4android.data.operation.RecordService_Operation.java
it.uniba.socialcde4android.data.operation.RetrieveServices_Operation.java
it.uniba.socialcde4android.data.operation.SendTFSpost_Operation.java
it.uniba.socialcde4android.data.operation.SetActiveFeatures_Operation.java
it.uniba.socialcde4android.data.operation.SetAvatar_Operation.java
it.uniba.socialcde4android.data.operation.SetFollowed_Operation.java
it.uniba.socialcde4android.data.operation.SetHideSettings_Operation.java
it.uniba.socialcde4android.data.operation.SubscribeUser_Operation.java
it.uniba.socialcde4android.data.operation.UnregisterService_Operation.java
it.uniba.socialcde4android.data.requestmanager.SocialCDERequestFactory.java
it.uniba.socialcde4android.data.requestmanager.SocialCDERequestManager.java
it.uniba.socialcde4android.data.service.SocialCDERequestService.java
it.uniba.socialcde4android.dialogs.ChangePasswordDialog.java
it.uniba.socialcde4android.dialogs.ChooseAvatarDialog.java
it.uniba.socialcde4android.dialogs.HideUnhideDialog.java
it.uniba.socialcde4android.dialogs.NoNetworkDialog.java
it.uniba.socialcde4android.dialogs.SetServiceFeaturesDialog.java
it.uniba.socialcde4android.dialogs.TFSAuthDialog.java
it.uniba.socialcde4android.fragments.TimeLine_AbstractFragment.java
it.uniba.socialcde4android.fragments.TimeLine_Fragment.java
it.uniba.socialcde4android.fragments.WUserColleagueProfile_Fragment.java
it.uniba.socialcde4android.fragments.WUserProfile_Fragment.java
it.uniba.socialcde4android.preferences.Preferences.java
it.uniba.socialcde4android.shared.library.JsonDateDeserializer.java
it.uniba.socialcde4android.shared.library.WFeature.java
it.uniba.socialcde4android.shared.library.WHidden.java
it.uniba.socialcde4android.shared.library.WOAuthData.java
it.uniba.socialcde4android.shared.library.WPost.java
it.uniba.socialcde4android.shared.library.WService.java
it.uniba.socialcde4android.shared.library.WUser.java
it.uniba.socialcde4android.utility.ScreenUtility.java