zgh_branch
徐海麓 2 years ago
commit 098b06f4b4

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
<bytecodeTargetLevel target="17" />
</component>
</project>

@ -7,6 +7,7 @@
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="Android Studio default JDK" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

@ -0,0 +1,37 @@
package com.example;
//导入所需的类和接口
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import java.util.ArrayList;
import java.util.List;
public class ViewPagerAdapter extends FragmentPagerAdapter {
private List<Fragment> fragments = new ArrayList<>();
private List<String> fragmentTitles = new ArrayList<>();
//两个列表将会存储即将被加入到ViewPager中的 Fragment 和 页面标题。
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
public void addFragment(Fragment fragment, String title) {
fragments.add(fragment);
fragmentTitles.add(title);
}//用于添加 Fragment 和对应的标题到 fragments 和 fragmentTitles 列表中。
//重写 getItem() 方法是为了返回 ViewPager 中要求位置的 Fragment 实例。
@Override
public Fragment getItem(int position) {
return fragments.get(position);
}
//getCount() 返回在适配器中的 Fragment 数量。
@Override
public int getCount() {
return fragments.size();
}
//getPageTitle() 方法返回在 ViewPager 中要求位置的页面标题。
@Override
public CharSequence getPageTitle(int position) {
return fragmentTitles.get(position);
}
}

@ -0,0 +1,50 @@
package com.example.sleep;
import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.example.sleep.database.dao.DaoMaster;
import com.example.sleep.database.dao.DaoSession;
import com.example.sleep.service.SensorService;
import com.example.sleep.utils.ApkHelper;
import com.shihoo.daemon.DaemonEnv;
import java.io.File;
public class App extends Application {
public static DaoSession mDaoSession;
public static Context mContext;
public void onCreate() {
/*
Daemon
*/
super.onCreate();
initGreenDao();
String processName = ApkHelper.getProcessName(this.getApplicationContext());
if ("com.sleephelper.howard.sleephelper".equals(processName)) {
Log.e("app", "启动主进程");
} else if ("com.sleephelper.howard.sleephelper:work".equals(processName)) {
Log.e("app", "启动了工作进程");
} else if ("com.sleephelper.howard.sleephelper:watch".equals(processName)) {
DaemonEnv.mWorkServiceClass = SensorService.class;
Log.e("app", "启动了守护进程");
}
mContext = this;
}
//数据库初始化
private void initGreenDao() {
DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper
(this, this.getExternalFilesDir(null) + File.separator + "sleepRecord.db");
SQLiteDatabase db = helper.getWritableDatabase();
DaoMaster daoMaster = new DaoMaster(db);
mDaoSession = daoMaster.newSession();
}
}

@ -0,0 +1,112 @@
package com.example.sleep;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import java.util.List;
public class DreamAnalyszeScreen extends Fragment {
private Button startSleep;//开始按钮
private FragmentActivity activity;
private TextView dreamDes;//用于显示梦境解答
private EditText dreamtTitle;//用于输入梦境关键词
private ProgressBar progress;
private Gson gson = new Gson();// 用于处理JSON数据
private Handler handler = new Handler(Looper.getMainLooper())//// 创建Handler对象用于处理从网络请求返回的消息
{
@Override
public void handleMessage(Message msg)
{
super.handleMessage(msg);
String data = (String) msg.obj;
DreamBean dreamResponse = gson.fromJson(data, DreamBean.class);//将JSON数据转换为DreamBean对象
DreamBean.Result result = dreamResponse.getResult();
if (result == null) //如果没有结果,提示“对不起没有收录此梦境”
{
progress.setVisibility(View.GONE);
startSleep.setVisibility(View.VISIBLE);
Toast.makeText(activity,"对不起没有收录此梦境",Toast.LENGTH_SHORT).show();
return;
}
List<DreamBean.Dream> dreams = result.getList();//获取梦境列表
for (DreamBean.Dream dream : dreams)//进行梦境解答
{
String result1 = dream.getResult();
// dreamDes.setText(result1);
//显示梦境解答结果
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
dreamDes.setText(Html.fromHtml(result1, Html.FROM_HTML_MODE_LEGACY));
} else {
dreamDes.setText(result1);
}
progress.setVisibility(View.GONE);
startSleep.setVisibility(View.VISIBLE);
return;
}
//若没有结果,提示“对不起没有收录此梦境”
progress.setVisibility(View.GONE);
startSleep.setVisibility(View.VISIBLE);
Toast.makeText(activity,"对不起没有收录此梦境",Toast.LENGTH_SHORT).show();
}
};
@SuppressLint("MissingInflatedId")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// 在这里设置 SleepFragment 的布局,例如从 XML 文件中加载
View view = inflater.inflate(R.layout.fragment_dream, container, false);
startSleep = view.findViewById(R.id.btn_start);
dreamDes = view.findViewById(R.id.dream_des);
dreamtTitle = view.findViewById(R.id.dream_title);
progress = view.findViewById(R.id.progress_bar);
initListener();
return view;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
// 在这里获取关联的Activity上下文
activity = getActivity();
}
private void initListener() {
startSleep.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String keywords = dreamtTitle.getText().toString();//获取输入的梦境关键词
if (TextUtils.isEmpty(keywords))//若关键词为空,显示提示信息
{
Toast.makeText(activity,"请输入梦境",Toast.LENGTH_SHORT).show();
return;
}
startSleep.setVisibility(View.GONE);
progress.setVisibility(View.VISIBLE);
new NetWork().getDream(keywords,handler);// 通过NetWork类的getDream方法获取梦境解答并通过Handler处理返回的消息
}
});
}
}

@ -0,0 +1,85 @@
package com.example.sleep;
import java.util.List;
public class DreamBean //定义一个JavaBean类DreamBean用于存储梦境解析API返回的JSON数据。
{
private int code;
private String msg;
private Result result;//私有变量Result用于存储具体的梦境解析结果
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Result getResult()//返回梦境结果我们可以通过调用DreamBean对象的getResult()方法获取到Result对象
{
return result;
}
public void setResult(Result result) {
this.result = result;
}
public static class Result {
private List<Dream> list;//定义梦境列表
public List<Dream> getList() {
return list;
}//获取梦境列表
public void setList(List<Dream> list) {
this.list = list;
}//设置List属性的值
}
public static class Dream {
private int id;
private String type;
private String title;
private String result;
public int getId() {
return id;
}//获取id的值
public void setId(int id) {
this.id = id;
}//设置id的值
public String getType() {
return type;
}//获取type
public void setType(String type) {
this.type = type;
}//设置type
public String getTitle() {
return title;
}//获取title
public void setTitle(String title) {
this.title = title;
}//设置title
public String getResult() {
return result;
}//获取result
public void setResult(String result) {
this.result = result;
}
}
}

@ -0,0 +1,94 @@
package com.example.sleep;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.util.Base64;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.example.sleep.database.dao.DatabaseManager;
import java.io.ByteArrayOutputStream;
public class EditScreen extends FragmentActivity {
private ImageView showImage;
private ImageView postImage;
private String imageUrl;
private EditText messageEdit;
private Bitmap bitmap;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.event_content_activity);
Bundle extras = getIntent().getExtras();
boolean isPhoto = getIntent().getBooleanExtra("isPhoto", false);
postImage = findViewById(R.id.event_content_post);
messageEdit = findViewById(R.id.event_content);
showImage = findViewById(R.id.event_image);
// 根据传入的数据决定是否显示图片
if (isPhoto) {
imageUrl = getIntent().getStringExtra("bitmapImageString");
Bitmap bitmap = BitmapFactory.decodeFile(imageUrl);
showImage.setImageBitmap(bitmap);
} else {
if (extras != null) {
bitmap = extras.getParcelable("bitmapImage");
if (bitmap != null) {
showImage.setImageBitmap(bitmap);
}
}
}
postImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String message = messageEdit.getText().toString();
if (TextUtils.isEmpty(message)) {
Toast.makeText(EditScreen.this, "请添加消息", Toast.LENGTH_SHORT).show();
return;
}
// 从SharedPreferences获取用户名
SharedPreferences sharedPreferences = EditScreen.this.getSharedPreferences("MyPreferences", Context.MODE_PRIVATE);
String retrievedUserName = sharedPreferences.getString("UserNameKey", "DefaultUserName");
// 打开数据库管理器
DatabaseManager manager = new DatabaseManager(EditScreen.this);
manager.open();
// 根据是否是照片贴文,将消息和图片信息保存到数据库
if (isPhoto) {
manager.postMood(retrievedUserName, message, imageUrl);
} else {
String bitmapUrl = bitmapToBase64(bitmap);
manager.postMood(retrievedUserName, message, bitmapUrl);
}
// 关闭数据库管理器
manager.close();
finish();
}
});
}
// 将Bitmap转换为Base64编码的字符串
public String bitmapToBase64(Bitmap bitmap) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
}
}

@ -0,0 +1,122 @@
package com.example.sleep;
import java.io.Serializable;
import java.util.List;
import java.io.Serializable;
import java.util.List;
// 事件类
public class Event implements Serializable {
public String id; // 事件的唯一标识符
public String title; // 事件的标题
public String des; // 事件的描述
public String imageUrl; // 事件的图片URL
public List<EventContent> contents; // 包含事件内容的列表
// 事件类构造函数
public Event(String id, String title, String des, String imageUrl, List<EventContent> contents) {
this.id = id;
this.title = title;
this.des = des;
this.imageUrl = imageUrl;
this.contents = contents;
}
// 无参构造函数
public Event() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDes() {
return des;
}
public void setDes(String des) {
this.des = des;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public List<EventContent> getContents() {
return contents;
}
public void setContents(List<EventContent> contents) {
this.contents = contents;
}
}
// 事件内容类
class EventContent implements Serializable {
public String contentId; // 内容的唯一标识符
public String userId; // 用户的唯一标识符,与事件内容关联
public String content; // 事件的具体内容
public String userName; // 用户的名字
// 事件内容类构造函数
public EventContent(String contentId, String userId, String content, String userName) {
this.contentId = contentId;
this.userId = userId;
this.content = content;
this.userName = userName;
}
// 无参构造函数
public EventContent() {
}
public String getContentId() {
return contentId;
}
public void setContentId(String contentId) {
this.contentId = contentId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}

@ -0,0 +1,22 @@
package com.example.sleep;
public class ItemModel {
private String imageUrl; // 用于存储图像URL或资源标识符
private String text; // 用于存储文本信息
// 构造函数,用于创建 ItemModel 对象并初始化其属性
public ItemModel(String imageUrl, String text) {
this.imageUrl = imageUrl;
this.text = text;
}
// 获取图像URL或资源标识符的方法
public String getImageResId() {
return imageUrl;
}
// 获取文本信息的方法
public String getText() {
return text;
}
}

@ -0,0 +1,135 @@
package com.example.sleep;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.example.ViewPagerAdapter;
import com.example.sleep.database.GetRecord;
import com.example.sleep.database.RecordBean;
import com.example.sleep.service.GoSleepService;
import static com.example.sleep.database.GetRecord.getRecord;
/**
*
*/
public class MainScreen extends FragmentActivity {
private static final int REQUEST_READ_EXTERNAL_STORAGE = 1;
private long exitTime = 0;
private ViewPager viewPager;
private TabLayout tabLayout;
private Button backRl;
//初始化
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
readLog();
/*initView();*/
startGoSleepService();
viewPager = findViewById(R.id.viewPager);
backRl = findViewById(R.id.btn_AfterSleep);
backRl.setOnClickListener(v -> finish());
tabLayout = findViewById(R.id.tabLayout);
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new SleepFragment(), "睡眠");
adapter.addFragment(new DreamAnalyszeScreen(), "解梦");
adapter.addFragment(new Share(), "分享");
adapter.addFragment(new SuggestScreen(), "报告");
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
// 检查权限
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// 请求权限
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_READ_EXTERNAL_STORAGE);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_READ_EXTERNAL_STORAGE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// 权限已获得
} else {
// 权限被拒绝
Toast.makeText(this, "Permission Denied!", Toast.LENGTH_SHORT).show();
}
}
}
//按钮
public void ClickRecord(View v) {
Intent i = new Intent();
i.setClass(MainScreen.this, CalendarPage.class);
MainScreen.this.startActivity(i);
MainScreen.this.finish();
}
//按下返回键的效果
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
if (System.currentTimeMillis() - exitTime > 2000) {
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
} else {
finish();
System.exit(0);
}
return true;
}
return super.onKeyDown(keyCode, event);
}
//读睡眠记录,判断是否异常退出
private void readLog() {
RecordBean mRecord;
GetRecord mGetRecord = getRecord();
mRecord = mGetRecord.getLatestRecord();
if (mRecord != null) {
if (!mRecord.getValid()) {
Intent i = new Intent();
i.setClass(MainScreen.this, SleepMonitoringScreen.class);
MainScreen.this.startActivity(i);
MainScreen.this.finish();
}
}
}
public void startGoSleepService() {
Intent ifSleepIntent = new Intent(this, GoSleepService.class);
this.startService(ifSleepIntent);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}

@ -0,0 +1,82 @@
package com.example.sleep;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
private List<ItemModel> dataList; // 数据列表
private Context context; // 上下文对象
public MyAdapter(Context context, List<ItemModel> dataList) {
this.context = context;
this.dataList = dataList;
}
public void setDataList(List<ItemModel> dataList) {
this.dataList = dataList;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(context).inflate(R.layout.item_layout, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
ItemModel item = dataList.get(position);
holder.textView.setText("用户评论: " + item.getText());
// 尝试从文件中加载图片如果失败则从Base64字符串解码为Bitmap
Bitmap bitmap;
try {
bitmap = BitmapFactory.decodeFile(item.getImageResId());
} catch (Exception e) {
bitmap = base64ToBitmap(item.getImageResId());
}
if (bitmap == null) {
bitmap = base64ToBitmap(item.getImageResId());
}
holder.imageView.setImageBitmap(bitmap);
}
public Bitmap base64ToBitmap(String base64Encoded) {
byte[] decodedByte = Base64.decode(base64Encoded, 0);
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}
@Override
public int getItemCount() {
if (dataList == null) {
return 0;
}
return dataList.size();
}
static class MyViewHolder extends RecyclerView.ViewHolder {
ImageView imageView;
TextView textView;
MyViewHolder(@NonNull View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.imageView);
textView = itemView.findViewById(R.id.textView);
}
}
}

@ -0,0 +1,31 @@
package com.example.sleep;
import android.content.Context;
import android.content.SharedPreferences;
public class MySharedPreferences {
private static final String PREF_NAME = "MyAppPreferences"; // SharedPreferences 的名称
private static final String KEY_HOURS = "hours"; // 用于存储小时的键名
private static final String KEY_MINUTES = "minutes"; // 用于存储分钟的键名
// 保存小时和分钟到 SharedPreferences
public static void saveTime(Context context, int hours, int minutes) {
SharedPreferences sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); // 获取 SharedPreferences 对象
SharedPreferences.Editor editor = sharedPreferences.edit(); // 获取 SharedPreferences 编辑器
editor.putInt(KEY_HOURS, hours); // 存储小时数据
editor.putInt(KEY_MINUTES, minutes); // 存储分钟数据
editor.apply(); // 提交数据更改
}
// 从 SharedPreferences 中获取小时
public static int getHours(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); // 获取 SharedPreferences 对象
return sharedPreferences.getInt(KEY_HOURS, 0); // 获取存储的小时数据,默认值为 0表示如果没有存储的值则返回 0
}
// 从 SharedPreferences 中获取分钟
public static int getMinutes(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); // 获取 SharedPreferences 对象
return sharedPreferences.getInt(KEY_MINUTES, 0); // 获取存储的分钟数据,默认值为 0表示如果没有存储的值则返回 0
}
}

@ -0,0 +1,56 @@
package com.example.sleep;
import android.os.Handler;
import android.os.Message;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class NetWork {
//定义方法,用来获取信息
public void getDream(String keywords, Handler handler) {
new Thread(new Runnable() //创建新的线程来进行网络请求
{
@Override
public void run() {
String tianapi_data = "";
try {
URL url = new URL( "https://apis.tianapi.com/dream/index");//创建url对象指定API接口的地址https://apis.tianapi.com/dream/index
HttpURLConnection conn = (HttpURLConnection) url.openConnection();//打开HTTP连接
conn.setRequestMethod("POST");//设置请求方式为Post
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
conn.setDoOutput(true);
conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
OutputStream outputStream = conn.getOutputStream();//获取输出流
String content = "key=4e90d7122409e092670d627e2129047d&num=10&word="+keywords;//构建请求参数
outputStream.write(content.getBytes());//将请求参数写入输出流
outputStream.flush();
outputStream.close();//关闭输出流
InputStream inputStream = conn.getInputStream();//获取输入流
InputStreamReader inputStreamReader = new InputStreamReader (inputStream,"utf-8");
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuilder tianapi = new StringBuilder();
String temp = null;
while ( null != (temp = bufferedReader.readLine())){
tianapi.append(temp);
}
tianapi_data = tianapi.toString();
inputStream.close();//关闭输入流
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(tianapi_data);
Message message = handler.obtainMessage();// 使用Handler将API返回的数据封装到Message对象中发送给主线程进行处理
message.obj = tianapi_data;
handler.sendMessage(message);
}
}).start();
}
}

@ -0,0 +1,73 @@
package com.example.sleep;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.example.sleep.database.GetRecord;
import com.example.sleep.database.RecordBean;
import com.example.sleep.recyclerView.Trace;
import com.example.sleep.recyclerView.TraceListAdapter;
import java.util.ArrayList;
import java.util.List;
import static com.example.sleep.database.GetRecord.getRecord;
/**
*
*/
public class Record extends Activity {
private RecyclerView rvTrace;
private List<Trace> traceList = new ArrayList<>();//睡眠记录列表
private String date = "";//日期
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.records);
rvTrace = findViewById(R.id.timelList);
date = this.getIntent().getStringExtra("date");
initData();
}
//睡眠记录数据初始化
private void initData() {
GetRecord mGetRecord = getRecord();//获取数据库操作对象
//List<RecordBean> records = mGetRecord.queryAllList();
List<RecordBean> records = mGetRecord.queryByDate(date);// 根据日期查询睡眠记录
if (records.size() == 1)
{
//如果只有一条记录,直接跳转到记录详情页面
Intent i = new Intent(Record.this, SleepresultScreen.class);
i.putExtra("date", date);
i.putExtra("position", 0);
Record.this.startActivity(i);
Record.this.finish();
} else {
//如果有多条记录,将记录添加到列表中,并设置 RecyclerView 的适配器
for (RecordBean e : records) {
traceList.add(new Trace(e.getDate(), e.getStartTime() + "-" + e.getEndTime()
+ " " + e.getTotalTime() / 60 + "时" + e.getTotalTime() % 60 + "分"));
}
TraceListAdapter adapter = new TraceListAdapter(this, traceList, date);
rvTrace.setLayoutManager(new LinearLayoutManager(this));
rvTrace.setAdapter(adapter);
}
}
//左上的返回
public void ClickBack(View v) {
Record.this.finish();
}
@Override
public void onDestroy() {
super.onDestroy();
}
}

@ -0,0 +1,235 @@
package com.example.sleep;
import static android.app.Activity.RESULT_OK;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.example.sleep.database.dao.DatabaseManager;
import java.io.File;
import java.util.List;
public class Share extends Fragment {
private static final int RESULT_LOAD_IMAGE = 111;
private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 222;
private ImageView eventPostImage;
private static final int MY_PERMISSIONS_REQUEST_CAMERA = 3;
private static final int REQUEST_IMAGE_CAPTURE = 1;
private Bitmap imageBitmap;
private RecyclerView eventRl;
private MyAdapter adapter;
private List<ItemModel> dataList;
// 在Fragment的onCreateView方法中初始化RecyclerView并设置适配器
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.i("11111", "onCreateView");
View view = inflater.inflate(R.layout.event_content, container, false);
eventRl = view.findViewById(R.id.rl);
eventPostImage = view.findViewById(R.id.event_image);
eventPostImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 当点击事件被触发时,显示底部对话框
if (true) { // 在这里应该有条件检查
showDialog();
}
}
});
initData();
return view;
}
@Override
public void onResume() {
super.onResume();
Log.i("11111", "onResume");
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("MyPreferences", Context.MODE_PRIVATE);
String retrievedUserName = sharedPreferences.getString("UserNameKey", "DefaultUserName");
loadData(retrievedUserName);
adapter.setDataList(dataList);
adapter.notifyDataSetChanged();
}
private void initData() {
eventRl.setLayoutManager(new LinearLayoutManager(getActivity()));
/*SharedPreferences sharedPreferences = getActivity().getSharedPreferences("MyPreferences", Context.MODE_PRIVATE);
String retrievedUserName = sharedPreferences.getString("UserNameKey", "DefaultUserName");
loadData(retrievedUserName); // 初始化数据*/
adapter = new MyAdapter(getActivity(), dataList);
eventRl.setAdapter(adapter);
}
private void loadData(String username) {
DatabaseManager manager = new DatabaseManager(getActivity());
manager.open();
dataList = manager.getUserNameEvent(username);
}
private void showDialog() {
// 显示底部对话框
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getActivity());
View bottomSheetView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_bottom_sheet_dialog, null);
bottomSheetDialog.setContentView(bottomSheetView);
bottomSheetView.findViewById(R.id.btn_take_photo).setOnClickListener(v -> {
// 处理拍摄按钮点击事件
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
// 请求相机权限
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.CAMERA}, MY_PERMISSIONS_REQUEST_CAMERA);
} else {
openCamera();
}
bottomSheetDialog.dismiss();
});
bottomSheetView.findViewById(R.id.btn_choose_from_gallery).setOnClickListener(v -> {
// 处理从相册中选择按钮点击事件
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// 请求读取外部存储权限
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
} else {
// 权限已经授予,进入图片选择流程
dispatchChoosePictureIntent();
}
bottomSheetDialog.dismiss();
});
bottomSheetView.findViewById(R.id.btn_cancel).setOnClickListener(v -> {
bottomSheetDialog.dismiss(); // 关闭对话框
});
bottomSheetDialog.show();
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_CAMERA: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// 用户授予了相机权限,可以拍照
openCamera();
} else {
// 用户拒绝了相机权限
}
}
case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// 用户授予了读取外部存储权限
dispatchChoosePictureIntent();
} else {
// 用户拒绝了读取外部存储权限
}
}
}
}
private void dispatchChoosePictureIntent() {
if (true) {
// 从相册中选择图片
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, RESULT_LOAD_IMAGE);
return;
}
// 创建拍照和选择图片的Intent
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Intent pickPictureIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, pickPictureIntent);
chooserIntent.putExtra(Intent.EXTRA_TITLE, "选择图片");
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
// 创建拍照所需的文件
File photoFile = null;
if (photoFile != null) {
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{takePictureIntent});
}
}
}
private void openCamera() {
// 打开相机应用拍照
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_IMAGE_CAPTURE) {
// 处理相机返回的数据
Bundle extras = data.getExtras();
imageBitmap = (Bitmap) extras.get("data");
// 启动新Activity并传递拍摄的图片
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putParcelable("bitmapImage", imageBitmap);
intent.putExtra("isPhoto", false);
intent.putExtras(bundle);
intent.setClass(getActivity(), EditScreen.class);
startActivity(intent);
} else if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImageUri = data.getData();
// 处理URI获取图片路径或者直接存储URI
// ...
// 如果你想获取图片的实际文件路径,可以如此操作
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getActivity().getContentResolver().query(selectedImageUri, filePathColumn, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
int columnIndex = cursor.getColumnIndexOrThrow(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
// 将图片路径保存到数据库
// saveImagePathToDatabase(picturePath);
// 使用 imageBitmap ...
Intent intent = new Intent();
intent.putExtra("bitmapImageString", picturePath);
intent.putExtra("isPhoto", true);
intent.setClass(getActivity(), EditScreen.class);
startActivity(intent);
}
// 或者可以保存URI.toString()到数据库
// saveImageUriToDatabase(selectedImageUri.toString());
}
}
}
}

@ -0,0 +1,158 @@
package com.example.sleep;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.charts.PieChart;
import com.example.sleep.database.GetRecord;
import com.example.sleep.database.RecordBean;
import com.example.sleep.drawChart.DrawLineChart;
import com.example.sleep.drawChart.DrawPieChart;
import java.util.List;
import java.util.Locale;
import static com.example.sleep.database.GetRecord.getRecord;
/**
*
*/
public class SleepresultScreen extends Activity {
Button btn_left;
Button btn_right;
TextView mDate;
TextView mStartTime;
TextView mStopTime;
TextView mSleepTime;
TextView mDeep;
TextView mSwallow;
TextView mDream;
LineChart mLineChart;
PieChart mPieChart;
DrawPieChart mDrawPieChart;
DrawLineChart mDrawLineChart;
private int idx;
private int max;
private int month;
private int day;
private boolean left_invisible;
private boolean right_invisible;
private String date;
private List<RecordBean> records;
private RecordBean mRecord;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//设置布局文件
//初始化视图部件
setContentView(R.layout.record_details);
mLineChart = findViewById(R.id.lineChart);
mPieChart = findViewById(R.id.mPiechart);
btn_left = findViewById(R.id.left);
btn_right = findViewById(R.id.right);
mDate = findViewById(R.id.date);
mStartTime = findViewById(R.id.startTime);
mStopTime = findViewById(R.id.stopTime);
mSleepTime = findViewById(R.id.sleepTime);
mDeep = findViewById(R.id.deep);
mSwallow = findViewById(R.id.swallow);
mDream = findViewById(R.id.dream);
idx = this.getIntent().getIntExtra("position", 0);
date = this.getIntent().getStringExtra("date");
readLog();//读取睡眠记录
setText();//设置文本内容
initView();//初始化视图
}
//视图
private void initView()
{
mDrawPieChart = new DrawPieChart(mPieChart, mRecord, getResources());
mDrawLineChart = new DrawLineChart(mLineChart, mRecord, getResources());
if (idx >= max) {
right_invisible = true;
btn_right.setVisibility(View.INVISIBLE);
}
if (idx == 0) {
left_invisible = true;
btn_left.setVisibility(View.INVISIBLE);
}
}
//设置文本
private void setText() {
mDate.setText(String.format(Locale.getDefault(), "%d月%d日", month, day));
mStartTime.setText(String.format(getResources().getString(R.string.sleep_time), mRecord.getStartTime()));
mStopTime.setText(String.format(getResources().getString(R.string.get_up_time), mRecord.getEndTime()));
mSleepTime.setText(String.format(Locale.getDefault(), "时长 %02d:%02d",
mRecord.getTotalTime() / 60, mRecord.getTotalTime() % 60));
mDeep.setText(String.format(Locale.getDefault(), "深度睡眠 %02d:%02d",
mRecord.getDeepTime() / 60, mRecord.getDeepTime() % 60));
mSwallow.setText(String.format(Locale.getDefault(), "浅层睡眠 %02d:%02d",
mRecord.getSwallowTime() / 60, mRecord.getSwallowTime() % 60));
mDream.setText(String.format(Locale.getDefault(), "醒/梦 %02d:%02d",
mRecord.getAwakeTime() / 60, mRecord.getAwakeTime() % 60));
}
//左上的返回
public void ClickBackDetails(View v) {
SleepresultScreen.this.finish();
}
//向左切换睡眠记录
public void ClickLeft(View v) {
mRecord = records.get(--idx);
setText();
mDrawPieChart = new DrawPieChart(mPieChart, mRecord, getResources());
mDrawLineChart = new DrawLineChart(mLineChart, mRecord, getResources());
if (idx == 0) {
left_invisible = true;
btn_left.setVisibility(View.INVISIBLE);
}
if (right_invisible) {
right_invisible = false;
btn_right.setVisibility(View.VISIBLE);
}
}
//向右切换睡眠记录
public void ClickRight(View v) {
mRecord = records.get(++idx);
setText();
mDrawPieChart = new DrawPieChart(mPieChart, mRecord, getResources());
mDrawLineChart = new DrawLineChart(mLineChart, mRecord, getResources());
if (idx >= max) {
right_invisible = true;
btn_right.setVisibility(View.INVISIBLE);
}
if (left_invisible) {
left_invisible = false;
btn_left.setVisibility(View.VISIBLE);
}
}
/**
*
*/
private void readLog() {
GetRecord mGetRecord = getRecord();
records = mGetRecord.queryByDate(date);
mRecord = records.get(idx);
max = records.size() - 1;
String[] arr = mRecord.getDate().split("-");
month = Integer.parseInt(arr[0]);
day = Integer.parseInt(arr[1]);
}
@Override
public void onDestroy() {
super.onDestroy();
}
}

@ -0,0 +1,41 @@
package com.example.sleep;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import com.example.sleep.activity.LoginActivity;
//整个程序的入口splash界面
public class SplashActivity extends Activity {
private static final int DELAY_TIME = 1500;
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// myPermission();
// 利用消息处理器实现延迟跳转到登录窗口
new Handler().postDelayed(() -> {
Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
// 启动登录窗口
startActivity(intent);
// 关闭启动画面
finish();
}, DELAY_TIME);
}
}

@ -0,0 +1,85 @@
package com.example.sleep;
import static android.content.Context.MODE_PRIVATE;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.sleep.database.RecordBean;
import com.example.sleep.database.MyDataBaseHelper;
import com.example.sleep.drawChart.SimpleLineChart;
import java.util.HashMap;
public class SuggestScreen extends Fragment {
private RecordBean mRecord;//睡眠记录对象
private SimpleLineChart mSimpleLineChart;//折线图组件
private TextView suggestion, gradeText;//文本显示组件
//视图
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.chart_fragment, container, false); // 加载布局文件
init(view);//初始化方法
return view;//返回视图
}
public void init(View view) {
suggestion = (TextView) view.findViewById(R.id.suggest);//建议文本
gradeText = (TextView) view.findViewById(R.id.grade);//评分文本
//调用数据库
MyDataBaseHelper dbHelp = new MyDataBaseHelper(getActivity());
SQLiteDatabase sqLiteDatabase = dbHelp.getWritableDatabase();
try {
Cursor cursor = sqLiteDatabase.rawQuery("select * from grade_table", null);//从数据库中查询数据
int counts = Math.min(cursor.getCount(), 7);
String[] time = new String[counts];//存储时间的数组
double[] grade = new double[counts];//存储评分的数组
if (cursor.moveToLast() == true) {
for (int i = 0; i < counts; i++) {
time[i] = cursor.getString(cursor.getColumnIndex("time"));//获取时间并存储到数组中
grade[i] = cursor.getDouble(cursor.getColumnIndex("grade"));//获取评分并存储到数组中
cursor.moveToPrevious();//移动到上一行
}
}
if (time.length != 0) {
mSimpleLineChart = (SimpleLineChart) view.findViewById(R.id.simpleLineChart);//获取折线图组件
String[] yItem = {"100", "80", "60", "40", "20", "0"};
mSimpleLineChart.setXItem(time);//设置x轴刻度标签
mSimpleLineChart.setYItem(yItem);//设置y周刻度标签
HashMap<Integer, Double> pointMap = new HashMap();//存储折线点的hashmap
for (int i = 0; i < time.length; i++) {
pointMap.put(i, grade[i] / 100);//将时间和评分的映射存储到hashmap中
}
mSimpleLineChart.setData(pointMap);//设置折线图的数据
SharedPreferences sharedpref = getActivity().getSharedPreferences("info", MODE_PRIVATE);
String suggest = sharedpref.getString("suggestion", "");//建议文本
float gra = sharedpref.getFloat("grade", 0);//评分
suggestion.setText("睡眠助手的建议:\n"+ suggest);
long x = Math.round(gra);
gradeText.setText(x + "");
} else {
suggestion.setText("睡眠助手的建议:\n体验一下我们的app吧~");//时间组为空时,显示
}
} catch (Exception e) {
Log.i("e", e.toString());
}
}
private void getSleepTime(){
}
}

@ -0,0 +1,95 @@
package com.example.sleep.activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
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.sleep.App;
import com.example.sleep.MainScreen;
import com.example.sleep.R;
import com.example.sleep.database.UserBean;
import com.example.sleep.database.dao.DaoSession;
import com.example.sleep.database.dao.UserBeanDao;
import java.util.List;
// LoginActivity.java
//定义了一个名为LoginActivity的类。这个类在Android应用中处理用户的登录操作。
public class LoginActivity extends AppCompatActivity {
private EditText usernameEditText;
private EditText passwordEditText;
private Button loginButton;
private Button registerButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
//初始化LoginActivity的各种资源以及为一些控件设置事件监听器。
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
usernameEditText = findViewById(R.id.usernameEditText);
passwordEditText = findViewById(R.id.passwordEditText);
loginButton = findViewById(R.id.loginButton);
registerButton = findViewById(R.id.registerButton);
findViewById(R.id.btn_AfterSleep).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 处理登录逻辑
String username = usernameEditText.getText().toString();
String password = passwordEditText.getText().toString();
// 1. 获取SharedPreferences实例
SharedPreferences sharedPreferences = LoginActivity.this.getSharedPreferences("MyPreferences", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("UserNameKey", username);
editor.apply();
// 验证用户名和密码从GreenDAO数据库中检查
// 如果匹配成功,执行登录操作
// 否则,显示错误消息
// 获取 GreenDAO 的 DAOSession
DaoSession mDaoSession = App.mDaoSession;
UserBeanDao userBeanDao = mDaoSession.getUserBeanDao();
// 查询数据库以验证用户名和密码
List<UserBean> matchingUsers = userBeanDao.queryBuilder()
.where(UserBeanDao.Properties.Username.eq(username), UserBeanDao.Properties.Password.eq(password))
.list();
if (matchingUsers != null && !matchingUsers.isEmpty()) {
Intent intent = new Intent();
intent.setClass(LoginActivity.this, MainScreen.class);
startActivity(intent);
finish();
} else {
Toast.makeText(LoginActivity.this, "用户名或密码不正确", Toast.LENGTH_SHORT).show();
}
}
});
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 跳转到注册页面
startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
}
});
}
}

@ -0,0 +1,55 @@
package com.example.sleep.activity;
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.sleep.App;
import com.example.sleep.R;
import com.example.sleep.database.UserBean;
import com.example.sleep.database.dao.DaoSession;
import com.example.sleep.database.dao.UserBeanDao;
//处理用户的注册操作
public class RegisterActivity extends AppCompatActivity {
private EditText registerUsernameEditText;//用户名
private EditText registerPasswordEditText;//密码
private Button registerButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
//设置一些基本的视图元素,并为其中视图元素设置一个简单的事件处理程序。
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
registerUsernameEditText = findViewById(R.id.usernameEditText);
registerPasswordEditText = findViewById(R.id.passwordEditText);
registerButton = findViewById(R.id.registerButton);
findViewById(R.id.btn_AfterSleep).setOnClickListener(v -> finish());
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 处理注册逻辑
String newUsername = registerUsernameEditText.getText().toString();
String newPassword = registerPasswordEditText.getText().toString();
// 将新用户的用户名和密码保存到GreenDAO数据库中
// 执行注册操作
// 创建一个新的 User 对象并设置用户名和密码
UserBean newUser = new UserBean();
newUser.setUsername(newUsername);
newUser.setPassword(newPassword);
// 获取 GreenDAO 的 DAOSession
DaoSession mDaoSession = App.mDaoSession;
UserBeanDao userBeanDao = mDaoSession.getUserBeanDao();
long id = userBeanDao.insert(newUser);
System.out.println("userDao: " + id);
if (id != -1) Toast.makeText(RegisterActivity.this,"注册成功",Toast.LENGTH_SHORT).show();
finish();
}
});
}
}

@ -0,0 +1,198 @@
package com.example.sleep.database;
import android.util.Log;
import com.example.sleep.App;
import com.example.sleep.database.dao.DaoSession;
import com.example.sleep.database.dao.RecordBeanDao;
import com.example.sleep.database.dao.RemindBeanDao;
import java.util.List;
import java.util.Locale;
/**
*
*/
public class GetRecord {
private RecordBeanDao recordBeanDao;
private RemindBeanDao remindBeanDao;
private static final String TAG = "GreenDao";
private static GetRecord getRecord;
private GetRecord() {
DaoSession mDaoSession = App.mDaoSession;
recordBeanDao = mDaoSession.getRecordBeanDao();
remindBeanDao = mDaoSession.getRemindBeanDao();
}
public static GetRecord getRecord() {
if (getRecord == null) {
getRecord = new GetRecord();
}
return getRecord;
}
/**
*
*
* @param date
* @param startTime
* @return
*/
public RecordBean insertData(String date, String startTime) {
RecordBean mRecord = new RecordBean(null, date, startTime, startTime, 0,
false, 0, 0, 0, "", false);
try {
recordBeanDao.insert(mRecord);
} catch (Exception e) {
Log.e(TAG, "数据库插入失败");
}
return mRecord;
}
/**
* id
*
* @param id id
*/
public void deleteById(Long id) {
try {
recordBeanDao.deleteByKey(id);
} catch (Exception e) {
Log.e(TAG, "数据库删除失败");
}
}
/**
*
*
* @param mRecord
*/
public void delete(RecordBean mRecord) {
try {
recordBeanDao.delete(mRecord);
} catch (Exception e) {
Log.e(TAG, "数据库删除失败");
}
}
/**
*
*
* @param mRecord
* @param sleepDetail
*/
public void update(RecordBean mRecord, String sleepDetail) {
if (mRecord != null) {
mRecord.setSleepDetail(mRecord.getSleepDetail() + sleepDetail);
recordBeanDao.update(mRecord);
}
}
/**
*
*
* @param mRecord
* @param endHour
* @param endMin
* @param totalTime
* @param deepTime
* @param swallowTime
* @param awakeTime
*/
public void finalUpdate(RecordBean mRecord, int endHour, int endMin, long totalTime,
int deepTime, int swallowTime, int awakeTime) {
totalTime /= 1000 * 60;
if (totalTime > 2) {
mRecord.setDrawChart(true);
}
mRecord.setEndTime(String.format(Locale.getDefault(), "%02d:%02d", endHour, endMin));
mRecord.setTotalTime((int) totalTime);
mRecord.setDeepTime(deepTime);
mRecord.setSwallowTime(swallowTime);
mRecord.setAwakeTime(awakeTime);
mRecord.setValid(true);
recordBeanDao.update(mRecord);
}
/**
*
*
* @return
*/
public List queryAllList() {
return recordBeanDao.queryBuilder().orderDesc(RecordBeanDao.Properties.Id).list();
}
/**
*
*
* @param date
* @return
*/
public List queryByDate(String date) {
return recordBeanDao.queryBuilder().where(RecordBeanDao.Properties.Date.eq(date)).orderAsc(RecordBeanDao.Properties.Id).list();
}
/**
*
*
* @param month
* @param days
* @return
*/
public boolean[] queryByMonth(String month, int days) {
boolean[] result = new boolean[days + 1];
String date;
for (int i = 1; i <= days; ++i) {
date = month + "-" + i;
result[i] = !recordBeanDao.queryBuilder().where(RecordBeanDao.Properties.Date.eq(date)).build().list().isEmpty();
}
return result;
}
/**
* id
*/
public RecordBean getRecordById(long id) {
return recordBeanDao.queryBuilder().where(RecordBeanDao.Properties.Id.eq(id)).build().unique();
}
/**
*
*/
public RecordBean getLatestRecord() {
List<RecordBean> records = recordBeanDao.queryBuilder().orderDesc(RecordBeanDao.Properties.Id).list();
if (!records.isEmpty())
return records.get(0);
return null;
}
/**
*
*
* @param time
*/
public void updateRemind(String time) {
if (remindBeanDao.queryBuilder().list().isEmpty()) {
remindBeanDao.insert(new RemindBean(null, "22:00"));
}
RemindBean remindBean = remindBeanDao.queryBuilder().list().get(0);
if (remindBean != null) {
remindBean.setTime(time);
remindBeanDao.update(remindBean);
}
}
/**
*
*
* @return
*/
public String getRemind() {
if (remindBeanDao.queryBuilder().list().isEmpty()) {
remindBeanDao.insert(new RemindBean(null, "22:00"));
}
return remindBeanDao.queryBuilder().list().get(0).getTime();
}
}

@ -0,0 +1,80 @@
package com.example.sleep.database;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class MyDataBaseHelper extends SQLiteOpenHelper//用于创建和更新数据库
{
private static final String DB_NAME = "DB2.db";
private static final String TABLE_NAME = "grade_table";
private static final int DB_VERSION = 1;
// 用户状态表
public static final String TABLE_STATUS = "statusTable";
public static final String STATUS_ID = "status_id";
public static final String USER_NAME = "user_name";
public static final String CONTENT = "content";
public static final String IMAGE_URL = "image_url";
public static final String TIMESTAMP = "timestamp";
// 评论表
public static final String TABLE_COMMENTS = "commentsTable";
public static final String COMMENT_ID = "comment_id";
public static final String COMMENTER = "commenter";
public static final String COMMENT = "comment";
public MyDataBaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
public MyDataBaseHelper(Context context) {
this(context, DB_NAME, null, DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
try {
//创建成绩表
String CREATE_TABLE = "CREATE TABLE if not exists " + TABLE_NAME
+ "(_id INTEGER PRIMARY KEY autoincrement,time TEXT," +
"sumOfSleep INTEGER," +
"timeOfSleep DOUBLE,grade DOUBLE)";
db.execSQL(CREATE_TABLE);
//创建用户状态表
String createStatusTable = "CREATE TABLE " + TABLE_STATUS + "(" +
STATUS_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
USER_NAME + " TEXT," +
CONTENT + " TEXT," +
IMAGE_URL + " TEXT," +
TIMESTAMP + " DATETIME DEFAULT CURRENT_TIMESTAMP)";
//创建评论表
String createCommentsTable = "CREATE TABLE " + TABLE_COMMENTS + "(" +
COMMENT_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
STATUS_ID + " INTEGER," +
COMMENTER + " TEXT," +
COMMENT + " TEXT," +
TIMESTAMP + " DATETIME DEFAULT CURRENT_TIMESTAMP," +
"FOREIGN KEY(" + STATUS_ID + ") REFERENCES " + TABLE_STATUS + "(" + STATUS_ID + "))";
db.execSQL(createStatusTable);//执行创建用户状态表的SQL语句
db.execSQL(createCommentsTable);//执行创建评论表的SQL语句
} catch (Exception e) {
Log.i("e", e.toString());//若出现异常,记录错误日志
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
System.out.println("database update!");//输出日志,表示数据库正在更新
db.execSQL("DROP TABLE IF EXISTS " + TABLE_STATUS);//删除用户状态表
db.execSQL("DROP TABLE IF EXISTS " + TABLE_COMMENTS);//删除评论表
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);//删除成绩表
onCreate(db);
}
}

@ -0,0 +1,130 @@
package com.example.sleep.database;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
//声明实体类
@Entity
public class RecordBean {
@Id(autoincrement = true)
private Long id;
private String date;//格式mm:dd
private String startTime;//格式hh:mm
private String endTime;
private int totalTime;
private boolean drawChart;
private int deepTime;
private int swallowTime;
private int awakeTime;
private String sleepDetail;//格式:"dayOfYear*24*60+hour*60+minute 传感器参数,"
private boolean valid;
@Generated(hash = 605421460)
public RecordBean(Long id, String date, String startTime, String endTime,
int totalTime, boolean drawChart, int deepTime, int swallowTime,
int awakeTime, String sleepDetail, boolean valid) {
this.id = id;
this.date = date;
this.startTime = startTime;
this.endTime = endTime;
this.totalTime = totalTime;
this.drawChart = drawChart;
this.deepTime = deepTime;
this.swallowTime = swallowTime;
this.awakeTime = awakeTime;
this.sleepDetail = sleepDetail;
this.valid = valid;
}
@Generated(hash = 96196931)
public RecordBean() {
}
//接下来的操作可对上述定义的值进行设置和读取
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getDate() {
return this.date;
}
public void setDate(String date) {
this.date = date;
}
public String getStartTime() {
return this.startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return this.endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public int getTotalTime() {
return this.totalTime;
}
public void setTotalTime(int totalTime) {
this.totalTime = totalTime;
}
public boolean getDrawChart() {
return this.drawChart;
}
public void setDrawChart(boolean drawChart) {
this.drawChart = drawChart;
}
public int getDeepTime() {
return this.deepTime;
}
public void setDeepTime(int deepTime) {
this.deepTime = deepTime;
}
public int getSwallowTime() {
return this.swallowTime;
}
public void setSwallowTime(int swallowTime) {
this.swallowTime = swallowTime;
}
public int getAwakeTime() {
return this.awakeTime;
}
public void setAwakeTime(int awakeTime) {
this.awakeTime = awakeTime;
}
public String getSleepDetail() {
return this.sleepDetail;
}
public void setSleepDetail(String sleepDetail) {
this.sleepDetail = sleepDetail;
}
public boolean getValid() {
return this.valid;
}
public void setValid(boolean valid) {
this.valid = valid;
}
}

@ -0,0 +1,39 @@
package com.example.sleep.database;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
//声明实体类
@Entity
public class RemindBean
{
@Id(autoincrement = true)
private Long id;//主键
private String time;//time
@Generated(hash = 1395260710)
public RemindBean(Long id, String time) {
this.id = id;
this.time = time;
}
@Generated(hash = 1914622572)
public RemindBean() {
}
//对上述设置的值进行set和get方法
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getTime() {
return this.time;
}
public void setTime(String time) {
this.time = time;
}
}

@ -0,0 +1,50 @@
package com.example.sleep.database;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
//声明实体类
@Entity
public class UserBean {
@Id(autoincrement = true)
private Long id;
private String username;
private String password;
@Generated(hash = 2052951463)
public UserBean(Long id, String username, String password) {
this.id = id;
this.username = username;
this.password = password;
}
@Generated(hash = 1203313951)
public UserBean() {
}
//对设置的值进行set和get操作
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
}

@ -0,0 +1,102 @@
package com.example.sleep.database.dao;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;
import org.greenrobot.greendao.AbstractDaoMaster;
import org.greenrobot.greendao.database.StandardDatabase;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseOpenHelper;
import org.greenrobot.greendao.identityscope.IdentityScopeType;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 2): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 2;
/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
RecordBeanDao.createTable(db, ifNotExists);
RemindBeanDao.createTable(db, ifNotExists);
UserBeanDao.createTable(db, ifNotExists);
}
/** Drops underlying database table using DAOs. */
public static void dropAllTables(Database db, boolean ifExists) {
RecordBeanDao.dropTable(db, ifExists);
RemindBeanDao.dropTable(db, ifExists);
UserBeanDao.dropTable(db, ifExists);
}
/**
* WARNING: Drops all table on Upgrade! Use only during development.
* Convenience method using a {@link DevOpenHelper}.
*/
public static DaoSession newDevSession(Context context, String name) {
Database db = new DevOpenHelper(context, name).getWritableDb();
DaoMaster daoMaster = new DaoMaster(db);
return daoMaster.newSession();
}
public DaoMaster(SQLiteDatabase db) {
this(new StandardDatabase(db));
}
public DaoMaster(Database db) {
super(db, SCHEMA_VERSION);
registerDaoClass(RecordBeanDao.class);
registerDaoClass(RemindBeanDao.class);
registerDaoClass(UserBeanDao.class);
}
public DaoSession newSession() {
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
}
public DaoSession newSession(IdentityScopeType type) {
return new DaoSession(db, type, daoConfigMap);
}
/**
* Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
*/
public static abstract class OpenHelper extends DatabaseOpenHelper {
public OpenHelper(Context context, String name) {
super(context, name, SCHEMA_VERSION);
}
public OpenHelper(Context context, String name, CursorFactory factory) {
super(context, name, factory, SCHEMA_VERSION);
}
@Override
public void onCreate(Database db) {
Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
createAllTables(db, false);
}
}
/** WARNING: Drops all table on Upgrade! Use only during development. */
public static class DevOpenHelper extends OpenHelper {
public DevOpenHelper(Context context, String name) {
super(context, name);
}
public DevOpenHelper(Context context, String name, CursorFactory factory) {
super(context, name, factory);
}
@Override
public void onUpgrade(Database db, int oldVersion, int newVersion) {
Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
dropAllTables(db, true);
onCreate(db);
}
}
}

@ -0,0 +1,76 @@
package com.example.sleep.database.dao;
import java.util.Map;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.AbstractDaoSession;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.identityscope.IdentityScopeType;
import org.greenrobot.greendao.internal.DaoConfig;
import com.example.sleep.database.RecordBean;
import com.example.sleep.database.RemindBean;
import com.example.sleep.database.UserBean;
import com.example.sleep.database.dao.RecordBeanDao;
import com.example.sleep.database.dao.RemindBeanDao;
import com.example.sleep.database.dao.UserBeanDao;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* {@inheritDoc}
*
* @see org.greenrobot.greendao.AbstractDaoSession
*/
public class DaoSession extends AbstractDaoSession {
private final DaoConfig recordBeanDaoConfig;
private final DaoConfig remindBeanDaoConfig;
private final DaoConfig userBeanDaoConfig;
private final RecordBeanDao recordBeanDao;
private final RemindBeanDao remindBeanDao;
private final UserBeanDao userBeanDao;
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
daoConfigMap) {
super(db);
recordBeanDaoConfig = daoConfigMap.get(RecordBeanDao.class).clone();
recordBeanDaoConfig.initIdentityScope(type);
remindBeanDaoConfig = daoConfigMap.get(RemindBeanDao.class).clone();
remindBeanDaoConfig.initIdentityScope(type);
userBeanDaoConfig = daoConfigMap.get(UserBeanDao.class).clone();
userBeanDaoConfig.initIdentityScope(type);
recordBeanDao = new RecordBeanDao(recordBeanDaoConfig, this);
remindBeanDao = new RemindBeanDao(remindBeanDaoConfig, this);
userBeanDao = new UserBeanDao(userBeanDaoConfig, this);
registerDao(RecordBean.class, recordBeanDao);
registerDao(RemindBean.class, remindBeanDao);
registerDao(UserBean.class, userBeanDao);
}
public void clear() {
recordBeanDaoConfig.clearIdentityScope();
remindBeanDaoConfig.clearIdentityScope();
userBeanDaoConfig.clearIdentityScope();
}
public RecordBeanDao getRecordBeanDao() {
return recordBeanDao;
}
public RemindBeanDao getRemindBeanDao() {
return remindBeanDao;
}
public UserBeanDao getUserBeanDao() {
return userBeanDao;
}
}

@ -0,0 +1,124 @@
package com.example.sleep.database.dao;
import static com.example.sleep.database.MyDataBaseHelper.CONTENT;
import static com.example.sleep.database.MyDataBaseHelper.IMAGE_URL;
import static com.example.sleep.database.MyDataBaseHelper.TIMESTAMP;
import static com.example.sleep.database.MyDataBaseHelper.USER_NAME;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.example.sleep.ItemModel;
import com.example.sleep.database.MyDataBaseHelper;
import java.util.ArrayList;
import java.util.List;
public class DatabaseManager {
private MyDataBaseHelper dbHelper;
private SQLiteDatabase database;
public DatabaseManager(Context context) {
dbHelper = new MyDataBaseHelper(context);
}
public void open() {
database = dbHelper.getWritableDatabase();
}
public void close() {
dbHelper.close();
}
// A用户发表心情
public long postMood(String userName, String content, String imageUrl) {
ContentValues values = new ContentValues();
values.put(USER_NAME, userName);
values.put(CONTENT, content);
values.put(IMAGE_URL, imageUrl);
return database.insert(MyDataBaseHelper.TABLE_STATUS, null, values);
}
public List<ItemModel> getUserNameEvent(String userName) {
// 使用参数化查询以防止SQL注入
String selection = USER_NAME + " = ?";
String[] selectionArgs = {userName};
List<ItemModel> dataList = new ArrayList<>();
Cursor cursor = database.query(MyDataBaseHelper.TABLE_STATUS, null, selection, selectionArgs, null, null, TIMESTAMP + " DESC");
while (cursor.moveToNext()) {
String text = cursor.getString(cursor.getColumnIndex(CONTENT));
String imageUrl = cursor.getString(cursor.getColumnIndex(IMAGE_URL));
// 根据你的ItemModel的构造函数来适当地修改下一行
dataList.add(new ItemModel(imageUrl, text));
}
cursor.close();
database.close();
return dataList;
}
// B用户评论A用户的心情
public long commentMood(long statusId, String commenter, String comment) {
ContentValues values = new ContentValues();
values.put(MyDataBaseHelper.STATUS_ID, statusId);
values.put(MyDataBaseHelper.COMMENTER, commenter);
values.put(MyDataBaseHelper.COMMENT, comment);
return database.insert(MyDataBaseHelper.TABLE_COMMENTS, null, values);
}
// B用户查看A用户的心情和评论
public Cursor viewMoodAndComments(long statusId) {
String query = "SELECT * FROM " + MyDataBaseHelper.TABLE_STATUS + " s " +
"LEFT JOIN " + MyDataBaseHelper.TABLE_COMMENTS + " c " +
"ON s." + MyDataBaseHelper.STATUS_ID + " = c." + MyDataBaseHelper.STATUS_ID +
" WHERE s." + MyDataBaseHelper.STATUS_ID + " = ?";
return database.rawQuery(query, new String[]{String.valueOf(statusId)});
}
// A用户查看自己的心情和B用户的评论
public Cursor viewOwnMoodAndComments(String userName) {
String query = "SELECT * FROM " + MyDataBaseHelper.TABLE_STATUS + " s " +
"LEFT JOIN " + MyDataBaseHelper.TABLE_COMMENTS + " c " +
"ON s." + MyDataBaseHelper.STATUS_ID + " = c." + MyDataBaseHelper.STATUS_ID +
" WHERE s." + USER_NAME + " = ?";
return database.rawQuery(query, new String[]{userName});
}
// 插入一条心情动态
public long insertStatus(String userName, String content, String imageUrl) {
ContentValues values = new ContentValues();
values.put(USER_NAME, userName);
values.put(CONTENT, content);
values.put(IMAGE_URL, imageUrl);
return database.insert(MyDataBaseHelper.TABLE_STATUS, null, values);
}
// 插入一条评论
public long insertComment(long statusId, String commenter, String comment) {
ContentValues values = new ContentValues();
values.put(MyDataBaseHelper.STATUS_ID, statusId);
values.put(MyDataBaseHelper.COMMENTER, commenter);
values.put(MyDataBaseHelper.COMMENT, comment);
return database.insert(MyDataBaseHelper.TABLE_COMMENTS, null, values);
}
public Cursor getStatusWithComments(long statusId) {
String query = "SELECT * FROM " + MyDataBaseHelper.TABLE_STATUS + " s " +
"LEFT JOIN " + MyDataBaseHelper.TABLE_COMMENTS + " c " +
"ON s." + MyDataBaseHelper.STATUS_ID + " = c." + MyDataBaseHelper.STATUS_ID +
" WHERE s." + MyDataBaseHelper.STATUS_ID + " = ?";
return database.rawQuery(query, new String[]{String.valueOf(statusId)});
}
}

@ -0,0 +1,207 @@
package com.example.sleep.database.dao;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import com.example.sleep.database.RecordBean;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "RECORD_BEAN".
*/
public class RecordBeanDao extends AbstractDao<RecordBean, Long> {
public static final String TABLENAME = "RECORD_BEAN";
/**
* Properties of entity RecordBean.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property Date = new Property(1, String.class, "date", false, "DATE");
public final static Property StartTime = new Property(2, String.class, "startTime", false, "START_TIME");
public final static Property EndTime = new Property(3, String.class, "endTime", false, "END_TIME");
public final static Property TotalTime = new Property(4, int.class, "totalTime", false, "TOTAL_TIME");
public final static Property DrawChart = new Property(5, boolean.class, "drawChart", false, "DRAW_CHART");
public final static Property DeepTime = new Property(6, int.class, "deepTime", false, "DEEP_TIME");
public final static Property SwallowTime = new Property(7, int.class, "swallowTime", false, "SWALLOW_TIME");
public final static Property AwakeTime = new Property(8, int.class, "awakeTime", false, "AWAKE_TIME");
public final static Property SleepDetail = new Property(9, String.class, "sleepDetail", false, "SLEEP_DETAIL");
public final static Property Valid = new Property(10, boolean.class, "valid", false, "VALID");
}
public RecordBeanDao(DaoConfig config) {
super(config);
}
public RecordBeanDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"RECORD_BEAN\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"DATE\" TEXT," + // 1: date
"\"START_TIME\" TEXT," + // 2: startTime
"\"END_TIME\" TEXT," + // 3: endTime
"\"TOTAL_TIME\" INTEGER NOT NULL ," + // 4: totalTime
"\"DRAW_CHART\" INTEGER NOT NULL ," + // 5: drawChart
"\"DEEP_TIME\" INTEGER NOT NULL ," + // 6: deepTime
"\"SWALLOW_TIME\" INTEGER NOT NULL ," + // 7: swallowTime
"\"AWAKE_TIME\" INTEGER NOT NULL ," + // 8: awakeTime
"\"SLEEP_DETAIL\" TEXT," + // 9: sleepDetail
"\"VALID\" INTEGER NOT NULL );"); // 10: valid
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"RECORD_BEAN\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, RecordBean entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String date = entity.getDate();
if (date != null) {
stmt.bindString(2, date);
}
String startTime = entity.getStartTime();
if (startTime != null) {
stmt.bindString(3, startTime);
}
String endTime = entity.getEndTime();
if (endTime != null) {
stmt.bindString(4, endTime);
}
stmt.bindLong(5, entity.getTotalTime());
stmt.bindLong(6, entity.getDrawChart() ? 1L: 0L);
stmt.bindLong(7, entity.getDeepTime());
stmt.bindLong(8, entity.getSwallowTime());
stmt.bindLong(9, entity.getAwakeTime());
String sleepDetail = entity.getSleepDetail();
if (sleepDetail != null) {
stmt.bindString(10, sleepDetail);
}
stmt.bindLong(11, entity.getValid() ? 1L: 0L);
}
@Override
protected final void bindValues(SQLiteStatement stmt, RecordBean entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String date = entity.getDate();
if (date != null) {
stmt.bindString(2, date);
}
String startTime = entity.getStartTime();
if (startTime != null) {
stmt.bindString(3, startTime);
}
String endTime = entity.getEndTime();
if (endTime != null) {
stmt.bindString(4, endTime);
}
stmt.bindLong(5, entity.getTotalTime());
stmt.bindLong(6, entity.getDrawChart() ? 1L: 0L);
stmt.bindLong(7, entity.getDeepTime());
stmt.bindLong(8, entity.getSwallowTime());
stmt.bindLong(9, entity.getAwakeTime());
String sleepDetail = entity.getSleepDetail();
if (sleepDetail != null) {
stmt.bindString(10, sleepDetail);
}
stmt.bindLong(11, entity.getValid() ? 1L: 0L);
}
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public RecordBean readEntity(Cursor cursor, int offset) {
RecordBean entity = new RecordBean( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // date
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // startTime
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // endTime
cursor.getInt(offset + 4), // totalTime
cursor.getShort(offset + 5) != 0, // drawChart
cursor.getInt(offset + 6), // deepTime
cursor.getInt(offset + 7), // swallowTime
cursor.getInt(offset + 8), // awakeTime
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // sleepDetail
cursor.getShort(offset + 10) != 0 // valid
);
return entity;
}
@Override
public void readEntity(Cursor cursor, RecordBean entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setDate(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setStartTime(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setEndTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setTotalTime(cursor.getInt(offset + 4));
entity.setDrawChart(cursor.getShort(offset + 5) != 0);
entity.setDeepTime(cursor.getInt(offset + 6));
entity.setSwallowTime(cursor.getInt(offset + 7));
entity.setAwakeTime(cursor.getInt(offset + 8));
entity.setSleepDetail(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
entity.setValid(cursor.getShort(offset + 10) != 0);
}
@Override
protected final Long updateKeyAfterInsert(RecordBean entity, long rowId) {
entity.setId(rowId);
return rowId;
}
@Override
public Long getKey(RecordBean entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
@Override
public boolean hasKey(RecordBean entity) {
return entity.getId() != null;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
}

@ -0,0 +1,129 @@
package com.example.sleep.database.dao;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import com.example.sleep.database.RemindBean;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "REMIND_BEAN".
*/
public class RemindBeanDao extends AbstractDao<RemindBean, Long> {
public static final String TABLENAME = "REMIND_BEAN";
/**
* Properties of entity RemindBean.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property Time = new Property(1, String.class, "time", false, "TIME");
}
public RemindBeanDao(DaoConfig config) {
super(config);
}
public RemindBeanDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"REMIND_BEAN\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"TIME\" TEXT);"); // 1: time
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"REMIND_BEAN\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, RemindBean entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String time = entity.getTime();
if (time != null) {
stmt.bindString(2, time);
}
}
@Override
protected final void bindValues(SQLiteStatement stmt, RemindBean entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String time = entity.getTime();
if (time != null) {
stmt.bindString(2, time);
}
}
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public RemindBean readEntity(Cursor cursor, int offset) {
RemindBean entity = new RemindBean( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1) // time
);
return entity;
}
@Override
public void readEntity(Cursor cursor, RemindBean entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setTime(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
}
@Override
protected final Long updateKeyAfterInsert(RemindBean entity, long rowId) {
entity.setId(rowId);
return rowId;
}
@Override
public Long getKey(RemindBean entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
@Override
public boolean hasKey(RemindBean entity) {
return entity.getId() != null;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
}

@ -0,0 +1,143 @@
package com.example.sleep.database.dao;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import com.example.sleep.database.UserBean;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "USER_BEAN".
*/
public class UserBeanDao extends AbstractDao<UserBean, Long> {
public static final String TABLENAME = "USER_BEAN";
/**
* Properties of entity UserBean.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property Username = new Property(1, String.class, "username", false, "USERNAME");
public final static Property Password = new Property(2, String.class, "password", false, "PASSWORD");
}
public UserBeanDao(DaoConfig config) {
super(config);
}
public UserBeanDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"USER_BEAN\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"USERNAME\" TEXT," + // 1: username
"\"PASSWORD\" TEXT);"); // 2: password
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"USER_BEAN\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, UserBean entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String username = entity.getUsername();
if (username != null) {
stmt.bindString(2, username);
}
String password = entity.getPassword();
if (password != null) {
stmt.bindString(3, password);
}
}
@Override
protected final void bindValues(SQLiteStatement stmt, UserBean entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String username = entity.getUsername();
if (username != null) {
stmt.bindString(2, username);
}
String password = entity.getPassword();
if (password != null) {
stmt.bindString(3, password);
}
}
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public UserBean readEntity(Cursor cursor, int offset) {
UserBean entity = new UserBean( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // username
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2) // password
);
return entity;
}
@Override
public void readEntity(Cursor cursor, UserBean entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setUsername(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setPassword(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
}
@Override
protected final Long updateKeyAfterInsert(UserBean entity, long rowId) {
entity.setId(rowId);
return rowId;
}
@Override
public Long getKey(UserBean entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
@Override
public boolean hasKey(UserBean entity) {
return entity.getId() != null;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
}

@ -0,0 +1,22 @@
package com.example.sleep.recyclerView;
/**
*
*/
public class Trace {
private String Date; // 记录的日期
private String Time; // 记录的时间
public Trace(String mDate, String mTime) {
this.Date = mDate;
this.Time = mTime;
}
public String getDate() {
return Date;
}
public String getTime() {
return Time;
}
}

@ -0,0 +1,119 @@
package com.example.sleep.recyclerView;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.sleep.R;
import com.example.sleep.SleepresultScreen;
import java.util.List;
public class TraceListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private LayoutInflater inflater;
private List<Trace> traceList;
private Context context;
private String date;
public class ViewHolder extends RecyclerView.ViewHolder {
private TextView mDate, mTime;
private TextView mTopLine;
private ImageView mDot;
ViewHolder(View itemView) {
super(itemView);
mDate = itemView.findViewById(R.id.Date);
mTime = itemView.findViewById(R.id.Time);
mTopLine = itemView.findViewById(R.id.TopLine);
mDot = itemView.findViewById(R.id.Dot);
}
void bindHolder(Trace trace) {
mDate.setText(trace.getDate());
mTime.setText(trace.getTime());
}
}
public TraceListAdapter(Context context, List<Trace> traceList, String date) {
// 构造函数,初始化适配器的数据
this.context = context;
inflater = LayoutInflater.from(context);
this.traceList = traceList;
this.date = date;
}
@Override
@NonNull
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
// 创建并返回记录项的 ViewHolder
return new ViewHolder(inflater.inflate(R.layout.list_cell, parent, false));
}
/**
*
*
* @param holder holder
* @param position
*/
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
ViewHolder itemHolder = (ViewHolder) holder;
if (position == 0) {
// 第一行头的竖线不显示
itemHolder.mTopLine.setVisibility(View.INVISIBLE);
itemHolder.mDot.setBackgroundResource(R.drawable.timeline);
} else if (position > 0) {
itemHolder.mTopLine.setVisibility(View.VISIBLE);
itemHolder.mDot.setBackgroundResource(R.drawable.timeline);
}
itemHolder.bindHolder(traceList.get(position));
final TextView tv1 = holder.itemView.findViewById(R.id.Date);
final TextView tv2 = holder.itemView.findViewById(R.id.Time);
tv1.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
// 点击日期文本的事件处理
Intent i = new Intent(context, SleepresultScreen.class);
i.putExtra("date", date);
i.putExtra("position", holder.getAdapterPosition());
context.startActivity(i);
}
}
);
tv2.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
// 点击时间文本的事件处理
Intent i = new Intent(context, SleepresultScreen.class);
i.putExtra("date", date);
i.putExtra("position", holder.getAdapterPosition());
context.startActivity(i);
}
}
);
}
@Override
public int getItemCount() {
return traceList.size();
}
public interface OnItemClickListener {
void onItemClick(View view, int position);
}
private OnItemClickListener mOnItemClickListener;
public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
// 设置 RecyclerView 点击事件的监听器
this.mOnItemClickListener = mOnItemClickListener;
}
}

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="3dp"></corners>
<solid android:color="#42000000" />
<solid android:color="#fff"></solid>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent"></solid>
<corners android:radius="25dip"></corners>
<stroke
android:width="1px"
android:color="#ff9c0e"></stroke>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/white" />
<size
android:width="20dp"
android:height="20dp" />
</shape>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/colorPrimary" />
<size
android:width="20dp"
android:height="20dp" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/colorPrimary" />
<size
android:width="20dp"
android:height="20dp" />
</shape>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="#ffff9c0e" />
<size
android:width="4dp"
android:height="4dp" />
</shape>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/view_syllabus_active_mark_background" android:state_enabled="true"></item>
<item android:drawable="@drawable/view_syllabus_unactive_mark_background" android:state_enabled="false"></item>
</selector>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="#cccccc" />
<size
android:width="4dp"
android:height="4dp" />
</shape>

@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size
android:width="150dp"
android:height="150dp"/>
<corners
android:radius="80dp"/>
<solid
android:color="@color/cyan"/>
</shape>

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1023 B

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#88000042" />
<padding
android:bottom="5dp"
android:left="10dp"
android:right="10dp"
android:top="5dp" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="10dp"
android:height="10dp" />
<solid android:color="@color/silver" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save