parent
1b9865e7a9
commit
f7256cc286
Binary file not shown.
@ -1,40 +0,0 @@
|
||||
package com.example.cici.dao;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
||||
|
||||
public class DBOpenHelper extends SQLiteOpenHelper {
|
||||
public DBOpenHelper(Context context,String name, CursorFactory factory,
|
||||
int version) {
|
||||
super(context, name, factory, version);
|
||||
}
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL("create table if not exists user_tb(_id integer primary key autoincrement," +
|
||||
"userID text not null," +
|
||||
"pwd text not null," +
|
||||
"name text not null," +
|
||||
"birthday text not null," +
|
||||
"sex text not null," +
|
||||
"phonenum text not null," +
|
||||
"headpic text not null)");
|
||||
db.execSQL("create table if not exists voice_tb(_id integer primary key autoincrement," +
|
||||
"voiceID text not null," +
|
||||
"voicecontent text not null,"
|
||||
"sharemoment integer," +
|
||||
"diary integer," +
|
||||
"memorandum integer," +
|
||||
"report integer)");
|
||||
db.execSQL("create table if not exists publish_tb(_id integer primary key autoincrement," +
|
||||
"voiceID text not null," +
|
||||
"userID text not null)");
|
||||
}
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
|
||||
package com.example.cici.dao;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
||||
import android.database.Cursor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DBOpenHelper extends SQLiteOpenHelper {
|
||||
private SQLiteDatabase db;
|
||||
public DBOpenHelper(Context context) {
|
||||
super(context, "voice", null, 1);
|
||||
db=getReadableDatabase();
|
||||
}
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL("create table if not exists user_tb(_id integer primary key autoincrement," +
|
||||
"userID text not null," +
|
||||
"pwd text not null," +
|
||||
"name text ," +
|
||||
"birthday text ," +
|
||||
"sex text ," +
|
||||
"headpic text )");
|
||||
db.execSQL("create table if not exists voice_tb(_id integer primary key autoincrement," +
|
||||
"voiceID text not null," +
|
||||
"voicecontent text not null,"+
|
||||
"sharemoment integer," +
|
||||
"diary integer," +
|
||||
"memorandum integer," +
|
||||
"report integer)");
|
||||
db.execSQL("create table if not exists publish_tb(_id integer primary key autoincrement," +
|
||||
"voiceID text not null," +
|
||||
"userID text not null)");
|
||||
}
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
|
||||
db.execSQL("DROP TABLE IF EXISTS user_tb");
|
||||
db.execSQL("DROP TABLE IF EXISTS voice_tb");
|
||||
db.execSQL("DROP TABLE IF EXISTS publish_tb");
|
||||
onCreate(db);
|
||||
|
||||
}
|
||||
// public ArrayList<>
|
||||
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package com.example.cici.util;
|
||||
|
||||
import android.os.CountDownTimer;
|
||||
import android.widget.Button;
|
||||
|
||||
|
||||
public class TimeCountUtil extends CountDownTimer {
|
||||
private Button mButton;
|
||||
|
||||
public TimeCountUtil(Button button, long millisInFuture, long countDownInterval) {
|
||||
super(millisInFuture, countDownInterval);
|
||||
this.mButton = button;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
// 按钮不可用
|
||||
mButton.setEnabled(false);
|
||||
String showText = millisUntilFinished / 1000 + "秒后可重新发送";
|
||||
mButton.setText(showText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
// 按钮设置可用
|
||||
mButton.setEnabled(true);
|
||||
mButton.setText("重新获取验证码");
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.example.cici.util;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class pubFun{
|
||||
public static boolean isEmpty(String input)
|
||||
{
|
||||
if(input==null ||"".equals(input))
|
||||
return true;
|
||||
for(int i=0;i<input.length();i++)
|
||||
{
|
||||
char c=input.charAt(i);
|
||||
if(c!=' '&&c!='\t'&&c!='\r'&&c!='\n')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean isPhoneNumberValid(String phoneNumber){
|
||||
boolean isValid=false;
|
||||
String expression = "^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{5})$";
|
||||
String expression2 = "^\\(?(\\d{3})\\)?[- ]?(\\d{4})[- ]?(\\d{4})$";
|
||||
CharSequence inputStr = phoneNumber;
|
||||
Pattern pattern = Pattern.compile(expression);
|
||||
Matcher matcher = pattern.matcher(inputStr);
|
||||
|
||||
Pattern pattern2 = Pattern.compile(expression2);
|
||||
Matcher matcher2 = pattern2.matcher(inputStr);
|
||||
if(matcher.matches() || matcher2.matches()) {
|
||||
isValid = true;
|
||||
}
|
||||
return isValid;
|
||||
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package com.example.cici.voice;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.cici.dao.DBOpenHelper;
|
||||
import com.example.cici.util.pubFun;
|
||||
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
private EditText editPhone;
|
||||
private EditText editPwd;
|
||||
private Button btnLogin;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.login);
|
||||
editPhone = (EditText) findViewById(R.id.editPhone);
|
||||
editPwd = (EditText) findViewById(R.id.editPwd);
|
||||
btnLogin = (Button) findViewById(R.id.btnLogin);
|
||||
}
|
||||
public void OnMyLoginClick(View v) {
|
||||
if(pubFun.isEmpty(editPhone.getText().toString()) || pubFun.isEmpty(editPwd.getText().toString())){
|
||||
Toast.makeText(this, "手机号或密码不能为空!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
//call DBOpenHelper
|
||||
DBOpenHelper helper = new DBOpenHelper(this);
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
Cursor c = db.query("user_tb",null,"userID=? and pwd=?",new String[]{editPhone.getText().toString(),editPwd.getText().toString()},null,null,null);
|
||||
if(c!=null && c.getCount() >= 1){
|
||||
String[] cols = c.getColumnNames();
|
||||
/* while(c.moveToNext()){
|
||||
for(String ColumnName:cols){
|
||||
Log.i("info",ColumnName+":"+c.getString(c.getColumnIndex(ColumnName)));
|
||||
}
|
||||
}*/
|
||||
c.close();
|
||||
db.close();
|
||||
|
||||
//将登陆用户信息存储到SharedPreferences中
|
||||
SharedPreferences mySharedPreferences= getSharedPreferences("setting",Activity.MODE_PRIVATE); //实例化SharedPreferences对象
|
||||
SharedPreferences.Editor editor = mySharedPreferences.edit();//实例化SharedPreferences.Editor对象
|
||||
editor.putString("userID", editPhone.getText().toString()); //用putString的方法保存数据
|
||||
editor.commit(); //提交当前数据
|
||||
|
||||
this.finish();
|
||||
}
|
||||
else{
|
||||
Toast.makeText(this, "手机号或密码输入错误!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Jump to the registration interface
|
||||
* @param v
|
||||
*/
|
||||
public void OnMyRegistClick(View v) {
|
||||
Intent intent=new Intent(LoginActivity.this,RegistActivity.class);
|
||||
//intent.putExtra("info", "No66778899");
|
||||
LoginActivity.this.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Jump to reset password interface
|
||||
* @param v
|
||||
*/
|
||||
public void OnMyResPwdClick(View v){
|
||||
Intent intent=new Intent(LoginActivity.this,ResPwdActivity.class);
|
||||
LoginActivity.this.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
package com.example.cici.voice;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
package com.example.cici.voice;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ContentValues;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.cici.dao.DBOpenHelper;
|
||||
import com.example.cici.util.pubFun;
|
||||
|
||||
|
||||
public class ResPwdActivity extends AppCompatActivity {
|
||||
private EditText editPhone;
|
||||
private EditText editPwd;
|
||||
private EditText editResPwd;
|
||||
private Button btnConfirm;
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.res_password);
|
||||
editPhone = (EditText) findViewById(R.id.editPhone);
|
||||
editPwd = (EditText) findViewById(R.id.editPwd);
|
||||
editResPwd = (EditText) findViewById(R.id.editResPwd);
|
||||
btnConfirm = (Button) findViewById(R.id.btnConfirm);
|
||||
}
|
||||
|
||||
/**
|
||||
* confirm event
|
||||
* @param v
|
||||
*/
|
||||
public void OnMyConfirmClick(View v) {
|
||||
confirmInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* confirm event
|
||||
*/
|
||||
private void confirmInfo() {
|
||||
if(pubFun.isEmpty(editPhone.getText().toString()) || pubFun.isEmpty(editPwd.getText().toString()) || pubFun.isEmpty(editResPwd.getText().toString())){
|
||||
Toast.makeText(this, "手机号或密码不能为空!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if(!editPwd.getText().toString().equals(editResPwd.getText().toString())){
|
||||
Toast.makeText(this, "输入密码不正确!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
//调用DBOpenHelper
|
||||
DBOpenHelper helper = new DBOpenHelper(this);
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
Cursor c = db.query("user_tb",null,"userID=?",new String[]{editPhone.getText().toString()},null,null,null);
|
||||
if(c!=null && c.getCount() >= 1){
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("pwd", editPwd.getText().toString());
|
||||
String[] args = {String.valueOf(editPhone.getText().toString())};
|
||||
long rowid = db.update("user_tb", cv, "userID=?",args);
|
||||
c.close();
|
||||
db.close();
|
||||
Toast.makeText(this, "密码重置成功!", Toast.LENGTH_SHORT).show();
|
||||
this.finish();
|
||||
}
|
||||
else{
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("提示")
|
||||
.setMessage("该用户不存在,请到注册界面进行注册!")
|
||||
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
setResult(RESULT_OK);
|
||||
Intent intent=new Intent(ResPwdActivity.this,RegistActivity.class);
|
||||
ResPwdActivity.this.startActivity(intent);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
return;
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue