diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java index dd9d517b..fdaae8ed 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java @@ -1,6 +1,7 @@ package org.odk.share.views.ui.settings; import android.bluetooth.BluetoothAdapter; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; @@ -10,18 +11,24 @@ import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; +import android.text.Editable; +import android.text.InputType; import android.text.TextUtils; +import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.widget.EditText; import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; +import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; +import com.google.android.material.textfield.TextInputEditText; import org.odk.share.R; @@ -40,6 +47,13 @@ public class SettingsActivity extends PreferenceActivity { EditTextPreference odkDestinationDirPreference; ListPreference defaultMethodPreference; private SharedPreferences prefs; +<<<<<<< HEAD + String npass; +======= + String n; + String m; +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78 + TextInputEditText edtpass; @Override protected void onCreate(Bundle savedInstanceState) { @@ -53,6 +67,8 @@ protected void onCreate(Bundle savedInstanceState) { addPreferences(); } + + @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { @@ -175,18 +191,45 @@ private ViewGroup getRootView() { return (ViewGroup) findViewById(android.R.id.list).getParent(); } } +<<<<<<< HEAD private void showPasswordDialog() { +======= + + private void showPasswordDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); + + +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78 LayoutInflater factory = LayoutInflater.from(this); View dialogView = factory.inflate(R.layout.dialog_password_til, null); + TextInputLayout tlPassword = dialogView.findViewById(R.id.et_password_layout); tlPassword.getEditText().setText(prefs.getString(PreferenceKeys.KEY_HOTSPOT_PASSWORD, getString(R.string.default_hotspot_password))); +<<<<<<< HEAD + edtpass = (TextInputEditText) dialogView.findViewById(R.id.edtpass); + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + npass = prefs.getString(PreferenceKeys.KEY_HOTSPOT_PASSWORD, getString(R.string.default_hotspot_password)); +======= + edtpass = (TextInputEditText)dialogView.findViewById(R.id.edtpass); + + n=prefs.getString(PreferenceKeys.KEY_HOTSPOT_PASSWORD, getString(R.string.default_hotspot_password)); +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78 + builder.setTitle(getString(R.string.title_hotspot_password)); builder.setView(dialogView); builder.setPositiveButton(getString(R.string.ok), (dialog, which) -> { + + +<<<<<<< HEAD + ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); +======= + ((AlertDialog)dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78 + String password = tlPassword.getEditText().getText().toString(); prefs.edit().putString(PreferenceKeys.KEY_HOTSPOT_PASSWORD, password).apply(); }); @@ -194,8 +237,67 @@ private void showPasswordDialog() { builder.setCancelable(false); AlertDialog alertDialog = builder.create(); + + alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { + + @Override + public void onShow(DialogInterface dialog) { +<<<<<<< HEAD +======= + //set positive OK button to be disabled by default + //((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78 + + edtpass.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { +<<<<<<< HEAD + ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); +======= + ((AlertDialog)dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78 + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { +<<<<<<< HEAD + + if (edtpass.getText().toString().length() >= 8) { + ((AlertDialog) dialog) .getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + } + + if (edtpass.getText().toString().length() < 8) { + ((AlertDialog) dialog) .getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); +======= + if(edtpass.getText().toString().length()>=8) + { + ((AlertDialog)dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); + } + if(edtpass.getText().toString().length()<8) + { + ((AlertDialog)dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78 + } + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); +<<<<<<< HEAD +======= + +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78 + } + }); + + alertDialog.show(); + alertDialog.setCancelable(true); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } + } diff --git a/skunkworks_crow/src/main/res/layout/dialog_password_til.xml b/skunkworks_crow/src/main/res/layout/dialog_password_til.xml index 17f0b1f8..7702096d 100644 --- a/skunkworks_crow/src/main/res/layout/dialog_password_til.xml +++ b/skunkworks_crow/src/main/res/layout/dialog_password_til.xml @@ -5,8 +5,15 @@ android:paddingLeft="16dp" android:paddingRight="16dp" app:passwordToggleEnabled="true"> - - - \ No newline at end of file + android:inputType="textPassword" + android:id="@+id/edtpass" + /> +<<<<<<< HEAD + + +======= + +>>>>>>> d772c59312329a56228f0556aafe8a3024110d78