The Code of the Shadow Sentinel - Образовательные истории

The Code of the Shadow Sentinel

Описание истории

In a world of neon shadows and digital threats, a master architect named Cyrus embarks on a mission to build the ultimate gateway. This story follows the creation of a high-tech password security system, blending a gritty hacker aesthetic with the elegant logic of Java and XML. It includes the complete functional code for an Android Studio project, featuring a dynamic progress bar and real-time validation logic. ### TECHNICAL DELIVERABLES: **activity_main.xml** ```xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0D0D0D" android:orientation="vertical" android:padding="24dp"> <com.google.android.material.textfield.TextInputLayout android:id="@+id/passwordLayout" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Enter Secret Key" android:textColorHint="#4CAF50" app:passwordToggleEnabled="true" app:passwordToggleTint="#4CAF50" app:boxStrokeColor="#4CAF50"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/passwordInput" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword" android:textColor="#FFFFFF" /> </com.google.android.material.textfield.TextInputLayout> <ProgressBar android:id="@+id/strengthMeter" style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="8dp" android:layout_marginTop="16dp" android:max="4" android:progressDrawable="@drawable/custom_progress_bar" /> <TextView android:id="@+id/strengthText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="Strength: Empty" android:textColor="#888888" /> </LinearLayout> ``` **MainActivity.java** ```java public class MainActivity extends AppCompatActivity { private TextInputEditText passwordInput; private ProgressBar strengthMeter; private TextView strengthText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); passwordInput = findViewById(R.id.passwordInput); strengthMeter = findViewById(R.id.strengthMeter); strengthText = findViewById(R.id.strengthText); passwordInput.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { evaluateStrength(s.toString()); } @Override public void afterTextChanged(Editable s) {} }); } private void evaluateStrength(String password) { int score = 0; if (password.length() >= 8) score++; if (password.matches(".*[A-Z].*")) score++; if (password.matches(".*[0-9].*")) score++; if (password.matches(".*[@#$%^&+=!].*")) score++; strengthMeter.setProgress(score); updateUI(score); } private void updateUI(int score) { String[] labels = {"Weak", "Fair", "Good", "Strong", "Unbreakable"}; int[] colors = {Color.GRAY, Color.RED, Color.YELLOW, Color.CYAN, Color.GREEN}; strengthText.setText("Strength: " + labels[score]); strengthMeter.getProgressDrawable().setColorFilter(colors[score], PorterDuff.Mode.SRC_IN); } } ```

Рейтинг:Недостаточно оценок
Язык:Английский
Дата публикации:
Время чтения:1 минут

Ключевые слова

Промпт генерации

"Create a password strength checker for an Android Studio project using Java and XML. The implementation should include: UI/UX (activity_main.xml): A modern TextInputLayout with a password toggle. A dynamic ProgressBar or segmented View bars that change color (Red → Yellow → Green) based on strength. A TextView that provides real-time feedback (e.g., 'Weak', 'Strong'). A list of requirements (Uppercase, Number, Special Char) that turn green with a checkmark icon when satisfied. Logic (MainActivity.java): A TextWatcher to update the meter in real-time as the user types. A robust validation method using Regex to check for length, digits, case sensitivity, and special characters. Custom logic to assign a 'Strength Score' from 0 to 4. Deliverables: Please provide the full code for MainActivity.java, activity_main.xml, and any necessary drawable resources (like a custom progress bar background) or string values. Ensure the code is clean, commented, and ready to be copy-pasted into a standard 'Empty Views Activity' template." i want uiux as hacker and dark background

Комментарии

Загрузка...