Back to project page passwords-by-harry.
The source code is released under:
Apache License
If you think the Android project passwords-by-harry listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (c) 2013. Harry Henry Gebel *//ww w . j a v a 2 s . c o m * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.github.harryfrommarydelde.passwordsbyharry; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; public class LoginActivity extends DataServiceConnectedActivity { private Button doneButton; private EditText passwordText; private CheckBox showPasswordCheck; protected void localOnServiceConnected(DataService.DataBinder dataBinder) { // if there is no encrypted data, get a new master password if (!dataBinder.dataExists()) { startActivity(new Intent(LoginActivity.this, ChangeMasterPasswordActivity.class)); finish(); } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); doneButton = (Button) findViewById(R.id.doneButton); passwordText = (EditText) findViewById(R.id.passwordText); showPasswordCheck = (CheckBox) findViewById(R.id.showPasswordCheck); // set enabled state of done button passwordText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } // Only enable done button when a password is present @Override public void afterTextChanged(Editable s) { if (s.length() == 0) { doneButton.setEnabled(false); } else { doneButton.setEnabled(true); } } }); // see if user wants master password shown showPasswordCheck.setChecked(settings.getBoolean("show_master_password", false)); showPassword(showPasswordCheck); } // Make sure changes in settings are maintained in activity @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("show_master_password")) { showPasswordCheck.setChecked(sharedPreferences.getBoolean("show_master_password", false)); showPassword(showPasswordCheck); } } public void checkPassword(View view) { if (passwordText.length() > 0) { passwordText.setText(""); } } // respond to "Show password" checkbox public void showPassword(View view) { if (((CheckBox) view).isChecked()) { passwordText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else { passwordText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } } }