-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
3035686
commit 3533c6f
Showing
10 changed files
with
369 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
app/src/main/java/io/treehouses/remote/ChPasswordDialogFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package io.treehouses.remote; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.app.Dialog; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.EditText; | ||
|
||
/** | ||
* Created by going-gone on 4/19/2018. | ||
*/ | ||
|
||
public class ChPasswordDialogFragment extends android.support.v4.app.DialogFragment { | ||
|
||
private static String TAG = "ChPasswordDialogFragment"; | ||
|
||
protected EditText passwordEditText; | ||
protected EditText confirmPassEditText; | ||
TextBoxValidation textBoxValidation = new TextBoxValidation(); | ||
|
||
public static ChPasswordDialogFragment newInstance(int num) { | ||
ChPasswordDialogFragment chPassDialogFragment = new ChPasswordDialogFragment(); | ||
return chPassDialogFragment; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
Log.d(TAG,"In onCreateDialog()"); | ||
|
||
// Build the dialog and set up the button click handlers | ||
LayoutInflater inflater = getActivity().getLayoutInflater(); | ||
View mView = inflater.inflate(R.layout.chpass_dialog,null); | ||
initLayoutView(mView); | ||
|
||
final AlertDialog mDialog = getAlertDialog(mView); | ||
mDialog.setTitle(R.string.change_password); | ||
|
||
//initially disable button click | ||
textBoxValidation.getListener(mDialog); | ||
setTextChangeListener(mDialog); | ||
|
||
return mDialog; | ||
} | ||
//creates the dialog for the change password dialog | ||
protected AlertDialog getAlertDialog(View mView) { | ||
return new AlertDialog.Builder(getActivity()) | ||
.setView(mView) | ||
.setTitle(R.string.change_password) | ||
.setIcon(android.R.drawable.ic_dialog_alert) | ||
.setPositiveButton(R.string.change_password, | ||
new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int whichButton) { | ||
dialog.dismiss(); | ||
String chPass = passwordEditText.getText().toString(); | ||
|
||
Intent i = new Intent(); | ||
i.putExtra("password", chPass); | ||
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, i); | ||
} | ||
} | ||
) | ||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int whichButton) { | ||
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_CANCELED, getActivity().getIntent()); | ||
} | ||
}) | ||
.create(); | ||
} | ||
//initialize the view | ||
protected void initLayoutView(View mView) { | ||
passwordEditText = (EditText)mView.findViewById(R.id.changePassword); | ||
confirmPassEditText = (EditText)mView.findViewById(R.id.confirmPassword); | ||
|
||
} | ||
//listener for text change within this dialog | ||
public void setTextChangeListener(final AlertDialog mDialog) { | ||
textBoxValidation.mDialog = mDialog; | ||
textBoxValidation.textWatcher = passwordEditText; | ||
textBoxValidation.PWD = passwordEditText; | ||
textBoxValidation.changePWValidation(confirmPassEditText, getContext()); | ||
|
||
textBoxValidation.mDialog = mDialog; | ||
textBoxValidation.textWatcher = confirmPassEditText; | ||
textBoxValidation.PWD = passwordEditText; | ||
textBoxValidation.changePWValidation(confirmPassEditText, getContext()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"> | ||
|
||
<EditText | ||
android:id="@+id/changePassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="4dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/password"/> | ||
<EditText | ||
android:id="@+id/confirmPassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="16dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/confirm_password"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"> | ||
|
||
<EditText | ||
android:id="@+id/changePassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="4dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/password"/> | ||
<EditText | ||
android:id="@+id/confirmPassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="16dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/confirm_password"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"> | ||
|
||
<EditText | ||
android:id="@+id/changePassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="4dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/password"/> | ||
<EditText | ||
android:id="@+id/confirmPassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="16dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/confirm_password"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"> | ||
|
||
<EditText | ||
android:id="@+id/changePassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="4dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/password"/> | ||
<EditText | ||
android:id="@+id/confirmPassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="16dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/confirm_password"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"> | ||
|
||
<EditText | ||
android:id="@+id/changePassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="4dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/password"/> | ||
<EditText | ||
android:id="@+id/confirmPassword" | ||
android:inputType="textPassword" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:layout_marginLeft="4dp" | ||
android:layout_marginRight="4dp" | ||
android:layout_marginBottom="16dp" | ||
android:fontFamily="sans-serif" | ||
android:hint="@string/confirm_password"/> | ||
|
||
</LinearLayout> |
Oops, something went wrong.