|
|
package net.micode.notes.ui;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
import android.content.SharedPreferences;
|
|
|
import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
|
import android.widget.Button;
|
|
|
import android.widget.EditText;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import net.micode.notes.R;
|
|
|
|
|
|
public class LoginActivity extends Activity {
|
|
|
|
|
|
EditText lg_password;
|
|
|
Button lg_login;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
SharedPreferences pref=getSharedPreferences("user management",MODE_PRIVATE);
|
|
|
boolean User_boolean = pref.getBoolean("user",false);//获取用户是否设置了密码
|
|
|
if(!User_boolean) //User_boolean = false时,(没有设置密码),直接跳转到便签主界面
|
|
|
{
|
|
|
Intent intent=new Intent(LoginActivity.this,SplashActivity.class);
|
|
|
startActivity(intent);
|
|
|
finish();
|
|
|
}
|
|
|
|
|
|
setContentView(R.layout.activity_login);
|
|
|
getWindow().setSoftInputMode(
|
|
|
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
|
|
|
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
|
lg_password=(EditText) findViewById(R.id.lg_password);
|
|
|
lg_login=(Button)findViewById(R.id.login);
|
|
|
lg_login.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
SharedPreferences pref=getSharedPreferences("user management",MODE_PRIVATE);
|
|
|
String password=pref.getString("password","");
|
|
|
if(password.equals("")==false&&password.equals(lg_password.getText().toString())==true){
|
|
|
Intent intent=new Intent(LoginActivity.this,SplashActivity.class);
|
|
|
startActivity(intent);
|
|
|
finish();
|
|
|
}
|
|
|
else{
|
|
|
Toast.makeText(LoginActivity.this, "密码错误", Toast.LENGTH_SHORT).show();
|
|
|
lg_password.setText("");//把密码框内输入过的错误密码清空
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
|
|
|
}
|
|
|
}
|