From f7256cc286efe1c0efac9c224899c79abfbef76a Mon Sep 17 00:00:00 2001 From: unknown <654649447@qq.com> Date: Mon, 7 Jan 2019 22:30:21 +0800 Subject: [PATCH] first commit --- .../.idea/caches/build_file_checksums.ser | Bin 536 -> 536 bytes .../java/com/example/cici/dao/DBOpenHelper | 40 --- .../com/example/cici/dao/DBOpenHelper.java | 49 ---- .../com/example/cici/ui/LoginActivity.java | 4 +- .../com/example/cici/ui/RegisterActivity.java | 2 +- .../com/example/cici/util/TimeCountUtil.java | 29 -- .../java/com/example/cici/util/pubFun.java | 37 --- .../com/example/cici/voice/LoginActivity.java | 84 ------ .../com/example/cici/voice/MainActivity.java | 13 - .../example/cici/voice/RegistActivity.java | 271 ------------------ .../example/cici/voice/ResPwdActivity.java | 88 ------ .../src/main/res/layout/activity_login.xml | 13 +- 12 files changed, 4 insertions(+), 626 deletions(-) delete mode 100644 数据库/voice/app/src/main/java/com/example/cici/dao/DBOpenHelper delete mode 100644 数据库/voice/app/src/main/java/com/example/cici/dao/DBOpenHelper.java delete mode 100644 数据库/voice/app/src/main/java/com/example/cici/util/TimeCountUtil.java delete mode 100644 数据库/voice/app/src/main/java/com/example/cici/util/pubFun.java delete mode 100644 数据库/voice/app/src/main/java/com/example/cici/voice/LoginActivity.java delete mode 100644 数据库/voice/app/src/main/java/com/example/cici/voice/MainActivity.java delete mode 100644 数据库/voice/app/src/main/java/com/example/cici/voice/RegistActivity.java delete mode 100644 数据库/voice/app/src/main/java/com/example/cici/voice/ResPwdActivity.java diff --git a/数据库/voice/.idea/caches/build_file_checksums.ser b/数据库/voice/.idea/caches/build_file_checksums.ser index bd9b966c1b24cb3904097c5a6448d4d11276ccad..f972399d00691d3ca342cf4801999e9208d137d6 100644 GIT binary patch delta 15 XcmbQiGJ|Ep3>J;m_vALtsbK^FE~5qh delta 15 XcmbQiGJ|Ep3>KAe(R&-`)Gz`7D?tUF diff --git a/数据库/voice/app/src/main/java/com/example/cici/dao/DBOpenHelper b/数据库/voice/app/src/main/java/com/example/cici/dao/DBOpenHelper deleted file mode 100644 index d1fef9d..0000000 --- a/数据库/voice/app/src/main/java/com/example/cici/dao/DBOpenHelper +++ /dev/null @@ -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){ - - } - -} - diff --git a/数据库/voice/app/src/main/java/com/example/cici/dao/DBOpenHelper.java b/数据库/voice/app/src/main/java/com/example/cici/dao/DBOpenHelper.java deleted file mode 100644 index 26f4f78..0000000 --- a/数据库/voice/app/src/main/java/com/example/cici/dao/DBOpenHelper.java +++ /dev/null @@ -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<> - -} - diff --git a/数据库/voice/app/src/main/java/com/example/cici/ui/LoginActivity.java b/数据库/voice/app/src/main/java/com/example/cici/ui/LoginActivity.java index af4cfe1..1d1969a 100644 --- a/数据库/voice/app/src/main/java/com/example/cici/ui/LoginActivity.java +++ b/数据库/voice/app/src/main/java/com/example/cici/ui/LoginActivity.java @@ -98,10 +98,10 @@ public class LoginActivity extends AppCompatActivity { * Jump to reset password interface * @param v */ - public void OnMyResPwdClick(View v){ + /* public void OnMyResPwdClick(View v){ Intent intent=new Intent(LoginActivity.this,ResPwdActivity.class); LoginActivity.this.startActivity(intent); - } + }*/ private boolean isHaveUser(String user){ diff --git a/数据库/voice/app/src/main/java/com/example/cici/ui/RegisterActivity.java b/数据库/voice/app/src/main/java/com/example/cici/ui/RegisterActivity.java index 3f477e2..68bed51 100644 --- a/数据库/voice/app/src/main/java/com/example/cici/ui/RegisterActivity.java +++ b/数据库/voice/app/src/main/java/com/example/cici/ui/RegisterActivity.java @@ -132,6 +132,7 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClick if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) { Toast.makeText(getApplicationContext(), "验证码输入正确", Toast.LENGTH_LONG).show(); + changeHead(); } } else @@ -186,7 +187,6 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClick if(judCord()) { SMSSDK.submitVerificationCode("86", phone_number, cord_number); - changeHead(); } flag=false; break; diff --git a/数据库/voice/app/src/main/java/com/example/cici/util/TimeCountUtil.java b/数据库/voice/app/src/main/java/com/example/cici/util/TimeCountUtil.java deleted file mode 100644 index 32d411e..0000000 --- a/数据库/voice/app/src/main/java/com/example/cici/util/TimeCountUtil.java +++ /dev/null @@ -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("重新获取验证码"); - } -} \ No newline at end of file diff --git a/数据库/voice/app/src/main/java/com/example/cici/util/pubFun.java b/数据库/voice/app/src/main/java/com/example/cici/util/pubFun.java deleted file mode 100644 index f989549..0000000 --- a/数据库/voice/app/src/main/java/com/example/cici/util/pubFun.java +++ /dev/null @@ -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= 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); - } - } - diff --git a/数据库/voice/app/src/main/java/com/example/cici/voice/MainActivity.java b/数据库/voice/app/src/main/java/com/example/cici/voice/MainActivity.java deleted file mode 100644 index ed82e27..0000000 --- a/数据库/voice/app/src/main/java/com/example/cici/voice/MainActivity.java +++ /dev/null @@ -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); - } -} diff --git a/数据库/voice/app/src/main/java/com/example/cici/voice/RegistActivity.java b/数据库/voice/app/src/main/java/com/example/cici/voice/RegistActivity.java deleted file mode 100644 index 6e58c93..0000000 --- a/数据库/voice/app/src/main/java/com/example/cici/voice/RegistActivity.java +++ /dev/null @@ -1,271 +0,0 @@ -package com.example.cici.voice; - -import java.util.Calendar; - -import android.app.Activity; -import android.content.ContentValues; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.os.Handler; -import android.os.Message; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.text.TextUtils; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.RadioButton; -import android.widget.TextView; -import android.widget.Toast; -import android.util.Log; -import android.widget.DatePicker; -import android.app.DatePickerDialog; -import android.app.DatePickerDialog.OnDateSetListener; - -import com.example.cici.dao.DBOpenHelper; -import com.example.cici.util.TimeCountUtil; - -import cn.smssdk.EventHandler; -import cn.smssdk.SMSSDK; - -public class RegistActivity extends AppCompatActivity implements View.OnClickListener { - - private EditText edit_phone; - private EditText edit_cord; - private EditText editPwd; - private EditText editName; - private TextView now; - private Button btn_getCord; - private Button btn_register; - private RadioButton mMaleRb; - private RadioButton mFamaleRb; - private String phone_number; - private String cord_number; - EventHandler eventHandler; - private TimeCountUtil mTimeCountUtil; - private int time=60; - private boolean flag=true; - private TextView tvShowDialog; - private Calendar cal; - private int year,month,day; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.regist); - getDate(); - - getId(); - - mTimeCountUtil = new TimeCountUtil(btn_getCord, 10000, 1000); - eventHandler = new EventHandler() { - public void afterEvent(int event, int result, Object data) { - Message msg=new Message(); - msg.arg1=event; - msg.arg2=result; - msg.obj=data; - handler.sendMessage(msg); - } - }; - - SMSSDK.registerEventHandler(eventHandler); - } - - - private void getDate() { - cal=Calendar.getInstance(); - year=cal.get(Calendar.YEAR); //获取年月日时分秒 - Log.i("wxy","year"+year); - month=cal.get(Calendar.MONTH); //获取到的月份是从0开始计数 - day=cal.get(Calendar.DAY_OF_MONTH); - } - - - @Override - protected void onDestroy() { - super.onDestroy(); - SMSSDK.unregisterEventHandler(eventHandler); - } - - /** - * 使用Handler来分发Message对象到主线程中,处理事件 - */ - Handler handler=new Handler() - { - @Override - public void handleMessage(Message msg) { - super.handleMessage(msg); - int event=msg.arg1; - int result=msg.arg2; - Object data=msg.obj; - if (event == SMSSDK.EVENT_GET_VERIFICATION_CODE) { - if(result == SMSSDK.RESULT_COMPLETE) { - boolean smart = (Boolean)data; - if(smart) { - Toast.makeText(getApplicationContext(),"该手机号已经注册过,请重新输入", - Toast.LENGTH_LONG).show(); - edit_phone.requestFocus(); - return; - } - } - } - if(result==SMSSDK.RESULT_COMPLETE) - { - - if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) { - Toast.makeText(getApplicationContext(), "验证码输入正确", - Toast.LENGTH_LONG).show(); - } - } - else - { - if(flag) - { - btn_getCord.setVisibility(View.VISIBLE); - Toast.makeText(getApplicationContext(),"验证码获取失败请重新获取", Toast.LENGTH_LONG).show(); - edit_phone.requestFocus(); - } - else - { - Toast.makeText(getApplicationContext(),"验证码输入错误", Toast.LENGTH_LONG).show(); - } - } - - } - - }; - - /** - * 获取id - */ - private void getId() - { - edit_phone=findViewById(R.id.editPhone); - edit_cord=findViewById(R.id.editCode); - btn_getCord=findViewById(R.id.btnGetcord); - btn_register=findViewById(R.id.btnRegist); - editPwd = (EditText) findViewById(R.id.editPwd); - editName=findViewById(R.id.editName); - mMaleRb = (RadioButton)findViewById(R.id.male); - mFamaleRb = (RadioButton)findViewById(R.id.famle); - tvShowDialog=(TextView) findViewById(R.id.tvShowDialog); - tvShowDialog.setOnClickListener(this); - btn_getCord.setOnClickListener(this); - btn_register.setOnClickListener(this); - } - - /** - * 按钮点击事件 - */ - public void onClick(View v) - { - switch (v.getId()) - { - case R.id.btnGetcord: - if(judPhone())//去掉左右空格获取字符串 - { - mTimeCountUtil.start(); - SMSSDK.getVerificationCode("86",phone_number); - edit_cord.requestFocus(); - } - break; - case R.id.btnRegist: - if(judCord()) - SMSSDK.submitVerificationCode("86",phone_number,cord_number); - DBOpenHelper helper = new DBOpenHelper(this); - SQLiteDatabase db = helper.getWritableDatabase(); - Cursor c = db.query("user_tb",null,"userID=?",new String[]{edit_phone.getText().toString()},null,null,null); - if(c!=null && c.getCount() >= 1){ - Toast.makeText(this, "该用户已存在", Toast.LENGTH_SHORT).show(); - c.close(); - } - else{ - //insert data - ContentValues values= new ContentValues(); - values.put("userID",edit_phone.getText().toString()); - values.put("pwd",editPwd.getText().toString()); - values.put("name",editName.getText().toString()); - values.put("birthday",tvShowDialog.getText().toString()); - if(mMaleRb.isChecked()){ - values.put("sex",mMaleRb.getText().toString()); - } - else values.put("sex",mFamaleRb.getText().toString()); - - long rowid = db.insert("user_tb",null,values); - - Toast.makeText(this, "注册成功", Toast.LENGTH_SHORT).show(); - this.finish(); - } - db.close(); - flag=false; - break; - case R.id.tvShowDialog: - OnDateSetListener listener=new OnDateSetListener() { - - @Override - public void onDateSet(DatePicker arg0, int year, int month, int day) { - tvShowDialog.setText(year+"-"+(++month)+"-"+day); //将选择的日期显示到TextView中,因为之前获取month直接使用,所以不需要+1,这个地方需要显示,所以+1 - } - }; - DatePickerDialog dialog=new DatePickerDialog(RegistActivity.this, 0,listener,year,month,day);//后边三个参数为显示dialog时默认的日期,月份从0开始,0-11对应1-12个月 - dialog.show(); - break; - - default: - break; - } - } - - private boolean judPhone() - { - if(TextUtils.isEmpty(edit_phone.getText().toString().trim())) - { - Toast.makeText(RegistActivity.this,"请输入您的电话号码",Toast.LENGTH_LONG).show(); - edit_phone.requestFocus(); - return false; - } - else if(edit_phone.getText().toString().trim().length()!=11) - { - Toast.makeText(RegistActivity.this,"您的电话号码位数不正确",Toast.LENGTH_LONG).show(); - edit_phone.requestFocus(); - return false; - } - else - { - phone_number=edit_phone.getText().toString().trim(); - String num="[1][358]\\d{9}"; - if(phone_number.matches(num)) - return true; - else - { - Toast.makeText(RegistActivity.this,"请输入正确的手机号码",Toast.LENGTH_LONG).show(); - return false; - } - } - } - - private boolean judCord() - { - judPhone(); - if(TextUtils.isEmpty(edit_cord.getText().toString().trim())) - { - Toast.makeText(RegistActivity.this,"请输入您的验证码",Toast.LENGTH_LONG).show(); - edit_cord.requestFocus(); - return false; - } - else if(edit_cord.getText().toString().trim().length()!=4) - { - Toast.makeText(RegistActivity.this,"您的验证码位数不正确",Toast.LENGTH_LONG).show(); - edit_cord.requestFocus(); - - return false; - } - else - { - cord_number=edit_cord.getText().toString().trim(); - return true; - } - - } - - -} \ No newline at end of file diff --git a/数据库/voice/app/src/main/java/com/example/cici/voice/ResPwdActivity.java b/数据库/voice/app/src/main/java/com/example/cici/voice/ResPwdActivity.java deleted file mode 100644 index 9343ed7..0000000 --- a/数据库/voice/app/src/main/java/com/example/cici/voice/ResPwdActivity.java +++ /dev/null @@ -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(); - } - } -} diff --git a/数据库/voice/app/src/main/res/layout/activity_login.xml b/数据库/voice/app/src/main/res/layout/activity_login.xml index 0a3d3bf..f3c525a 100644 --- a/数据库/voice/app/src/main/res/layout/activity_login.xml +++ b/数据库/voice/app/src/main/res/layout/activity_login.xml @@ -50,18 +50,7 @@ app:layout_constraintTop_toBottomOf="@+id/et_pwd" app:layout_constraintVertical_bias="0.793" /> - +