Commit a8725b95 authored by DESKTOP-NFGF3PG\zxa01's avatar DESKTOP-NFGF3PG\zxa01

commit record

parent 9c755131
......@@ -49,6 +49,13 @@ public class Api {
@GET("/api/breeds/list/all")
Call<Object> getPrivacyPolicyReport();
@GET("/api/breeds/list/all")
Call<Object> updatePrivacyPolicyChoice();
@GET("/api/breeds/list/all")
Call<Object> getRecord();
// @GET("/api/breed/{breed}/images")
// Call<DogBreedImages> getImagesByBreed(@Path("breed") String breed);
......
package com.example.zxa01.iotclient.detail.viewModel;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.common.pojo.device.Device;
import com.example.zxa01.iotclient.detail.model.DetailModel;
import com.example.zxa01.iotclient.privacy.view.PrivacyActivity;
......@@ -9,6 +10,8 @@ import android.content.Context;
import android.content.Intent;
import android.databinding.ObservableBoolean;
import android.databinding.ObservableField;
import android.view.Gravity;
import android.widget.Toast;
public class DetailViewModel extends ViewModel {
......@@ -43,5 +46,8 @@ public class DetailViewModel extends ViewModel {
public void downloadPrivacyReport() {
// TODO download
Toast toast = Toast.makeText(context, R.string.detail_report_download, Toast.LENGTH_LONG);
toast.setGravity(Gravity.BOTTOM,0,15);
toast.show();
}
}
......@@ -2,8 +2,7 @@ package com.example.zxa01.iotclient.home;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.databinding.ActivityHomeBinding;
import com.example.zxa01.iotclient.home.device.view.DeviceFragment;
import com.example.zxa01.iotclient.home.device.viewModel.DeviceViewModel;
import com.example.zxa01.iotclient.home.record.RecordFragment;
import com.example.zxa01.iotclient.home.record.view.RecordFragment;
import com.example.zxa01.iotclient.home.setting.SettingFragment;
import android.content.Intent;
import android.net.Uri;
......@@ -82,7 +81,7 @@ public class HomeActivity extends AppCompatActivity implements
// new DeviceViewModel().createDevice(intent.getStringExtra("SCAN_RESULT"));
} else {
new AlertDialog.Builder(this)
.setMessage(R.string.qrcode_error)
.setMessage(R.string.create_qrcode_error)
.show();
}
}
......
package com.example.zxa01.iotclient.home.device.model;
import com.example.zxa01.iotclient.common.http.Api;
import com.example.zxa01.iotclient.common.pojo.device.Device;
import com.example.zxa01.iotclient.common.pojo.device.Manufacturer;
import com.example.zxa01.iotclient.common.pojo.device.Model;
import android.arch.lifecycle.MutableLiveData;
import android.databinding.BaseObservable;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class DeviceModel extends BaseObservable {
private List<Device> deviceList;
private MutableLiveData<List<Device>> devices;
private List<Device> devices = new ArrayList<>();
private MutableLiveData<List<Device>> devicesMLD = new MutableLiveData<>();
// fake
private Device oxygenDevice = new Device()
......@@ -31,21 +35,17 @@ public class DeviceModel extends BaseObservable {
.setDescription("本設備是為符合不同領域及照護應用而設計,並把這些特色融入小如指節的分析儀中,可在數秒內量測出準確可靠的血氧及心跳值。")
.setUrl("https://www.amazon.com/Pulse-Oximeter-Blood-Oxygen-Monitor/dp/B00HXXO332"))
.setUPC("B00HXXO332")
.setLocation("25.013068, 121.541651")
.setStatus(Device.Status.Disconnected);
.setLocation("25.013068, 121.541651");
public DeviceModel() {
deviceList = new ArrayList<>();
devices = new MutableLiveData<>();
}
public void addDevice(Device device) {
deviceList.add(device);
devices.add(device);
}
public MutableLiveData<List<Device>> getDevices() {
return devices;
public MutableLiveData<List<Device>> getDevicesMLD() {
return devicesMLD;
}
public void fetchDevices() {
......@@ -53,10 +53,8 @@ public class DeviceModel extends BaseObservable {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
// TODO transfer response
Log.i("Test", response.message());
addDevice(oxygenDevice);
addDevice(oxygenDevice);
devices.setValue(deviceList);
devicesMLD.setValue(devices);
}
@Override
......
......@@ -52,7 +52,7 @@ public class DeviceFragment extends Fragment {
private void init() {
viewModel.refreshDevices();
viewModel.getDevices().observe(this, deviceList -> viewModel.setAdapter(deviceList));
viewModel.observeDevicesMLD().observe(this, viewModel::setAdapter);
}
private void drawDialog() {
......
......@@ -35,13 +35,13 @@ public class DeviceCreateFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setView(R.layout.fragment_device_create)
.setNeutralButton(R.string.button_qrcode,
.setNeutralButton(R.string.create_button_qrcode,
(dialog, whichButton) -> qrcodeIntent()
)
.setPositiveButton(R.string.button_correct,
.setPositiveButton(R.string.create_button_correct,
(dialog, whichButton) -> viewModel.createDevice("address")
)
.setNegativeButton(R.string.button_cancel, (dialog, whichButton) -> {
.setNegativeButton(R.string.create_button_cancel, (dialog, whichButton) -> {
})
.create();
}
......
......@@ -32,8 +32,8 @@ public class DeviceViewModel extends ViewModel {
deviceModel.fetchDevices();
}
public MutableLiveData<List<Device>> getDevices() {
return deviceModel.getDevices();
public MutableLiveData<List<Device>> observeDevicesMLD() {
return deviceModel.getDevicesMLD();
}
public void createDevice(String address) {
......@@ -46,18 +46,18 @@ public class DeviceViewModel extends ViewModel {
*/
public Device getDeviceAt(Integer index) {
if (deviceModel.getDevices().getValue() != null &&
if (deviceModel.getDevicesMLD().getValue() != null &&
index != null &&
deviceModel.getDevices().getValue().size() > index) {
return deviceModel.getDevices().getValue().get(index);
deviceModel.getDevicesMLD().getValue().size() > index) {
return deviceModel.getDevicesMLD().getValue().get(index);
}
return null;
}
public void onDevicesClick(Integer index) {
if (deviceModel.getDevices().getValue() != null &&
if (deviceModel.getDevicesMLD().getValue() != null &&
index != null &&
deviceModel.getDevices().getValue().size() > index) {
deviceModel.getDevicesMLD().getValue().size() > index) {
// TODO detail of device
context.startActivity(
new Intent(context, DetailActivity.class)
......@@ -73,9 +73,9 @@ public class DeviceViewModel extends ViewModel {
return adapter;
}
public void setAdapter(List<Device> deviceList) {
public void setAdapter(List<Device> devices) {
this.isLoading.set(false);
this.adapter.setDevices(deviceList);
this.adapter.setDevices(devices);
this.adapter.notifyDataSetChanged();
}
......
package com.example.zxa01.iotclient.home.record;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.zxa01.iotclient.R;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link RecordFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link RecordFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class RecordFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public RecordFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment PrivacyFragment.
*/
// TODO: Rename and change types and number of parameters
public static RecordFragment newInstance(String param1, String param2) {
RecordFragment fragment = new RecordFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_record, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onPrivacyFragment(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onPrivacyFragment(Uri uri);
}
}
package com.example.zxa01.iotclient.home.record.model;
import android.arch.lifecycle.MutableLiveData;
import android.databinding.BaseObservable;
import android.util.Log;
import com.example.zxa01.iotclient.common.http.Api;
import com.example.zxa01.iotclient.common.pojo.device.Device;
import com.example.zxa01.iotclient.common.pojo.device.Manufacturer;
import com.example.zxa01.iotclient.common.pojo.device.Model;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicy;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Access;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Collector;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Datum;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Dispute;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Purpose;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Recipient;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Remedy;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Retention;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Statement;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RecordModel extends BaseObservable {
private List<PrivacyPolicyReport> privacyPolicyReports = new ArrayList<>();
private MutableLiveData<List<PrivacyPolicyReport>> privacyPolicyReportsMLD = new MutableLiveData<>();
private Device oxygenDevice = new Device()
.setUDN("a1252c49-4188-4e6d-a32e-66604c664fb8")
.setName("指尖式血氧機")
.setType(Device.Type.Sensor)
.setManufacturer(new Manufacturer()
.setName("Facelake")
.setSerialNumber("3176927193")
.setUrl("http://facelake.com"))
.setModel(new Model()
.setName("指尖式血氧機")
.setDescription("本設備是為符合不同領域及照護應用而設計,並把這些特色融入小如指節的分析儀中,可在數秒內量測出準確可靠的血氧及心跳值。")
.setUrl("https://www.amazon.com/Pulse-Oximeter-Blood-Oxygen-Monitor/dp/B00HXXO332"))
.setUPC("B00HXXO332")
.setLocation("25.013068, 121.541651")
.setStatus(Device.Status.Disconnected);
private PrivacyPolicyReport oxygenPrivacyPolicyReport = new PrivacyPolicyReport()
.setId("0cfb6be3-6f0f-4e63-85b8-e9c936707c0b")
.setVersion("1.0")
.setDescription("為提供您最佳的互動照護服務,本APP部分服務內容可能會請您提供心跳資訊及血氧飽和度資訊,以作為持續自動追蹤心率的技術,提供整日健康狀況的深入分析以及運動強度的資訊。")
.setDevice(oxygenDevice)
.addPrivacyPolicy(new PrivacyPolicy()
.setId("119df569-06b1-4d63-84cd-bde7c9e4ab7e")
.setDescription("為提供您最佳的互動照護服務,本APP部分服務內容可能會請您提供血氧飽和度資訊,以作為呼吸系統疾病、循環系統疾病、其它治療、檢查引起的損傷之遠端醫療照護分析資料。")
.setCollector(new Collector()
.setName("健康促進中心")
.setEmail("[email protected]")
.setPhone("0988415875"))
.setAccess(Access.OTHER_IDENT)
.setDispute(new Dispute()
.setRelatedOrganization("地方法院")
.setType(Dispute.Type.LAW))
.addRemedy(new Remedy()
.setType(Remedy.Type.LAW))
.addStatement(new Statement()
.setConsequence("a1252c49-4188-4e6d-a32e-66604c664fb9")
.addPurpose(new Purpose()
.setType(Purpose.Type.PSEUDO_ANALYSIS)
.setDescription("本APP會使用者蒐集血氧飽和度資訊作為呼吸系統疾病、循環系統疾病、其它治療、檢查引起的損傷之遠端醫療照護分析資料。"))
.addDatum(new Datum()
.setType(Datum.Type.HEALTH)
.setDescription("血氧飽和度資訊"))
.addRecipient(new Recipient()
.setEntity("健康促進中心")
.setType(Recipient.Type.OURS))
.setRetention(Retention.STATED_PURPOSE)))
.addPrivacyPolicy(new PrivacyPolicy()
.setId("abe5ca7b-780e-4857-87e6-014870fe0a3f")
.setDescription("為提供您最佳的互動照護服務,本APP會蒐集使用者心跳資訊,作為持續自動追蹤心率的技術,提供整日健康狀況的深入分析以及運動強度的資訊。")
.setCollector(new Collector()
.setName("健康促進中心")
.setEmail("[email protected]")
.setPhone("0988415875"))
.setAccess(Access.OTHER_IDENT)
.setDispute(new Dispute()
.setRelatedOrganization("地方法院")
.setType(Dispute.Type.LAW))
.addRemedy(new Remedy()
.setType(Remedy.Type.CORRECT))
.addRemedy(new Remedy()
.setType(Remedy.Type.LAW))
.addRemedy(new Remedy()
.setType(Remedy.Type.MONEY))
.addStatement(new Statement()
.setConsequence("a1252c49-4188-4e6d-a32e-66604c664fba")
.addPurpose(new Purpose()
.setType(Purpose.Type.INDIVIDUAL_ANALYSIS)
.setDescription("本APP會蒐集使用者心跳資訊,作為持續自動追蹤心率的技術,提供整日健康狀況的深入分析以及運動強度的資訊。"))
.addDatum(new Datum()
.setType(Datum.Type.HEALTH)
.setDescription("心跳資訊"))
.addRecipient(new Recipient()
.setEntity("健康促進中心")
.setType(Recipient.Type.OURS))
.setRetention(Retention.STATED_PURPOSE)));
public RecordModel(){
}
public void addPrivacyPolicyReport(PrivacyPolicyReport privacyPolicyReport){
privacyPolicyReports.add(privacyPolicyReport);
}
public MutableLiveData<List<PrivacyPolicyReport>> getPrivacyPolicyReportsMLD() {
return privacyPolicyReportsMLD;
}
public void fetchRecord() {
Callback<Object> callback = new Callback<Object>() {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
// TODO transfer response
addPrivacyPolicyReport(oxygenPrivacyPolicyReport);
privacyPolicyReportsMLD.setValue(privacyPolicyReports);
}
@Override
public void onFailure(Call<Object> call, Throwable t) {
Log.e("fetchDevices - onFailure()", t.getMessage(), t);
}
};
Api.getApi().getRecord().enqueue(callback);
}
}
package com.example.zxa01.iotclient.home.record.view;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.example.zxa01.iotclient.BR;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport;
import com.example.zxa01.iotclient.home.record.viewModel.RecordViewModel;
import java.util.List;
public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.MyViewHolder> {
private int layoutId;
private List<PrivacyPolicyReport> privacyPolicyReports;
private RecordViewModel viewModel;
public RecordAdapter(@LayoutRes int layoutId, RecordViewModel viewModel) {
this.layoutId = layoutId;
this.viewModel = viewModel;
}
private int getLayoutIdForPosition(int position) {
return layoutId;
}
@Override
public RecordAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new RecordAdapter.MyViewHolder(DataBindingUtil.inflate(
LayoutInflater.from(parent.getContext()), viewType, parent, false));
}
@Override
public void onBindViewHolder(RecordAdapter.MyViewHolder holder, int position) {
holder.bind(viewModel, position);
}
@Override
public int getItemCount() {
return privacyPolicyReports == null ? 0 : privacyPolicyReports.size();
}
@Override
public int getItemViewType(int position) {
return getLayoutIdForPosition(position);
}
public void setPrivacyPolicyReports(List<PrivacyPolicyReport> privacyPolicyReports) {
this.privacyPolicyReports = privacyPolicyReports;
}
class MyViewHolder extends RecyclerView.ViewHolder {
final ViewDataBinding binding;
MyViewHolder(ViewDataBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
void bind(RecordViewModel viewModel, Integer position) {
viewModel.getPrivacyPolicyReportAt(position);
binding.setVariable(BR.viewModel, viewModel);
binding.setVariable(BR.position, position);
binding.executePendingBindings();
}
}
}
package com.example.zxa01.iotclient.home.record.view;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.databinding.FragmentRecordBinding;
import com.example.zxa01.iotclient.home.record.viewModel.RecordViewModel;
public class RecordFragment extends Fragment {
private FragmentRecordBinding binding;
private RecordViewModel viewModel;
public RecordFragment() {
}
public static RecordFragment newInstance(String param1, String param2) {
return new RecordFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_record, container, false);
viewModel = new RecordViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
binding.recordRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
init();
return binding.getRoot();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
private void init() {
viewModel.refreshRecord();
viewModel.observePrivacyPolicyReportsMLDD().observe(this, viewModel::setAdapter);
}
public interface OnFragmentInteractionListener {
void onPrivacyFragment(Uri uri);
}
}
package com.example.zxa01.iotclient.home.record.viewModel;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import android.content.Context;
import android.content.Intent;
import android.databinding.ObservableBoolean;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport;
import com.example.zxa01.iotclient.home.record.model.RecordModel;
import com.example.zxa01.iotclient.home.record.view.RecordAdapter;
import com.example.zxa01.iotclient.privacy.view.PrivacyActivity;
import java.util.List;
public class RecordViewModel extends ViewModel {
public ObservableBoolean isLoading = new ObservableBoolean(true);
private RecordModel recordModel = new RecordModel();
private RecordAdapter adapter = new RecordAdapter(R.layout.recycler_view_record, this);
private Context context;
public RecordViewModel(Context context) {
this.context = context;
}
/**
* model
*/
public void refreshRecord() {
recordModel.fetchRecord();
}
public MutableLiveData<List<PrivacyPolicyReport>> observePrivacyPolicyReportsMLDD() {
return recordModel.getPrivacyPolicyReportsMLD();
}
/**
* child model
*/
public PrivacyPolicyReport getPrivacyPolicyReportAt(Integer index) {
if (recordModel.getPrivacyPolicyReportsMLD().getValue() != null &&
index != null &&
recordModel.getPrivacyPolicyReportsMLD().getValue().size() > index) {
return recordModel.getPrivacyPolicyReportsMLD().getValue().get(index);
}
return null;
}
public void onPrivacyPolicyReportClick(Integer index) {
if (recordModel.getPrivacyPolicyReportsMLD().getValue() != null &&
index != null &&
recordModel.getPrivacyPolicyReportsMLD().getValue().size() > index) {
// TODO detail of device
context.startActivity(
new Intent(context, PrivacyActivity.class)
.putExtra("index", index));
}
}
/**
* adapter
*/
public RecordAdapter getAdapter() {
return adapter;
}
public void setAdapter(List<PrivacyPolicyReport> privacyPolicyReports) {
this.isLoading.set(false);
this.adapter.setPrivacyPolicyReports(privacyPolicyReports);
this.adapter.notifyDataSetChanged();
}
}
......@@ -34,8 +34,7 @@ public class LoginActivity extends AppCompatActivity {
}
private void init() {
viewModel.isAuthorized().observe(this,
isAuthorized -> viewModel.checkAuthorized(isAuthorized));
viewModel.isAuthorized().observe(this,viewModel::checkAuthorized);
}
}
......@@ -3,6 +3,8 @@ package com.example.zxa01.iotclient.privacy.model;
import android.arch.lifecycle.MutableLiveData;
import android.databinding.BaseObservable;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import com.example.zxa01.iotclient.common.http.Api;
import com.example.zxa01.iotclient.common.pojo.device.Device;
......@@ -19,13 +21,15 @@ import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Recipient;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Remedy;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Retention;
import com.example.zxa01.iotclient.common.pojo.privacy.p3p.Statement;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class PrivacyModel extends BaseObservable {
private MutableLiveData<PrivacyPolicyReport> privacyPolicyReport;
private MutableLiveData<Boolean> isUploadMLD;
private MutableLiveData<PrivacyPolicyReport> privacyPolicyReportMLD;
// fake p3p
private Device oxygenDevice = new Device()
......@@ -105,11 +109,14 @@ public class PrivacyModel extends BaseObservable {
.setRetention(Retention.STATED_PURPOSE)));
public PrivacyModel() {
privacyPolicyReport = new MutableLiveData<>();
privacyPolicyReportMLD = new MutableLiveData<>();
privacyPolicyReportMLD.setValue(new PrivacyPolicyReport());
isUploadMLD = new MutableLiveData<>();
isUploadMLD.setValue(false);
}
public MutableLiveData<PrivacyPolicyReport> getPrivacyPolicyReport() {
return privacyPolicyReport;
public MutableLiveData<PrivacyPolicyReport> getPrivacyPolicyReportMLD() {
return privacyPolicyReportMLD;
}
public void fetchPrivacyPolicyReport() {
......@@ -117,8 +124,7 @@ public class PrivacyModel extends BaseObservable {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
// TODO transfer response
Log.i("Test", response.message());
privacyPolicyReport.setValue(oxygenPrivacyPolicyReport);
privacyPolicyReportMLD.setValue(oxygenPrivacyPolicyReport);
}
@Override
......@@ -131,9 +137,26 @@ public class PrivacyModel extends BaseObservable {
}
public MutableLiveData<Boolean> getIsUploadMLD() {
return isUploadMLD;
}
public void updatePrivacyPolicyChoice(String privacyId, boolean consent) {
isUploadMLD.setValue(true);
Callback<Object> callback = new Callback<Object>() {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
// TODO transfer response
isUploadMLD.setValue(false);
}
@Override
public void onFailure(Call<Object> call, Throwable t) {
Log.e("updatePrivacyPolicyChoice - onFailure()", t.getMessage(), t);
}
};
public void updatePP(String privacyId,boolean consent) {
// TODO update 偏好
Api.getApi().updatePrivacyPolicyChoice().enqueue(callback);
}
}
package com.example.zxa01.iotclient.privacy.view;
import android.databinding.DataBindingUtil;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
......@@ -8,6 +11,7 @@ import android.view.MenuItem;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.databinding.ActivityPrivacyBinding;
import com.example.zxa01.iotclient.detail.viewModel.DetailViewModel;
import com.example.zxa01.iotclient.home.device.view.create.DeviceCreateFragment;
import com.example.zxa01.iotclient.privacy.viewModel.PrivacyViewModel;
public class PrivacyActivity extends AppCompatActivity {
......@@ -28,8 +32,8 @@ public class PrivacyActivity extends AppCompatActivity {
private void init() {
viewModel.fetchPrivacyPolicyReport();
viewModel.getPrivacyPolicyReport().observe(this,
privacyPolicies -> viewModel.setAdapter(privacyPolicies.getPolicies()));
viewModel.observePrivacyPolicyReportMLD().observe(this, viewModel::setPrivacyPolicyReport);
viewModel.observeIsLoading().observe(this, viewModel::setIsUpload);
}
@Override
......@@ -39,4 +43,6 @@ public class PrivacyActivity extends AppCompatActivity {
}
return super.onOptionsItemSelected(item);
}
}
......@@ -52,7 +52,7 @@ public class PrivacyAdapter extends RecyclerView.Adapter<PrivacyAdapter.MyViewHo
return getLayoutIdForPosition(position);
}
public void setDevices(List<PrivacyPolicy> privacyPolicyList) {
public void setPrivacyPolicyList(List<PrivacyPolicy> privacyPolicyList) {
this.privacyPolicyList = privacyPolicyList;
}
......
......@@ -51,7 +51,7 @@
android:layout_width="@dimen/layout_width"
android:layout_height="wrap_content"
android:padding="@dimen/padding_sm"
android:text="隱私政策"
android:text="@string/privacy_title"
android:textAlignment="textEnd"
android:textColor="@color/colorAccent"
android:textSize="@dimen/font"
......@@ -62,20 +62,20 @@
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/font"
android:textSize="@dimen/font_sm"
android:padding="@dimen/padding"
android:onClick="@{()->viewModel.settingPrivacy()}"
android:text="偏好設定" />
android:text="@string/detail_preference_setting" />
<Button
android:id="@+id/buttonPrivacyReport"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/font"
android:textSize="@dimen/font_sm"
android:padding="@dimen/padding"
android:onClick="@{()->viewModel.downloadPrivacyReport()}"
android:text="檢測報告下載" />
android:text="@string/detail_detect_report" />
</LinearLayout>
......
......@@ -12,22 +12,38 @@
type="com.example.zxa01.iotclient.privacy.viewModel.PrivacyViewModel" />
</data>
<android.support.constraint.ConstraintLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
tools:context=".privacy.view.PrivacyActivity">
<ProgressBar
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:secondaryProgress="40"
android:theme="@style/ProgressTheme"
android:visibility="@{viewModel.isLoading ? View.VISIBLE : View.GONE}" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:background="@color/colorWhite"
android:orientation="vertical"
android:visibility="@{viewModel.isLoading ? View.GONE : View.VISIBLE}"
tools:context=".privacy.view.PrivacyActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/margin_lg"
android:layout_marginLeft="@dimen/margin_lg"
android:layout_marginTop="@dimen/margin_lg"
android:layout_marginRight="@dimen/margin_lg"
android:layout_marginBottom="@dimen/margin"
android:background="@drawable/border_bottom_xl"
android:orientation="horizontal"
android:padding="@dimen/padding_sm">
......@@ -37,7 +53,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="隱私政策報告"
android:text="@string/title_privacy"
android:textColor="@color/colorAccent"
android:textSize="@dimen/font_lg" />
......@@ -46,7 +62,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="版本 1.0"
android:text='@{@string/privacy_version+" "+viewModel.privacyPolicyReport.version}'
android:textAlignment="textEnd" />
</LinearLayout>
......@@ -55,11 +71,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_lg"
android:layout_marginTop="@dimen/margin_sm"
android:layout_marginRight="@dimen/margin_lg"
android:paddingBottom="@dimen/margin"
android:background="@drawable/border_bottom"
android:padding="@dimen/padding_sm"
android:text="描述" />
android:text="@{viewModel.privacyPolicyReport.description}" />
<TextView
android:id="@+id/textViewDescription2"
......@@ -69,7 +84,7 @@
android:layout_marginTop="@dimen/margin_sm"
android:layout_marginRight="@dimen/margin_lg"
android:padding="@dimen/padding_sm"
android:text="我們會依照下列政策收集相關資料" />
android:text="@string/privacy_request" />
<android.support.v7.widget.RecyclerView
android:id="@+id/privacy_recycler_view"
......@@ -82,5 +97,5 @@
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</FrameLayout>
</layout>
\ No newline at end of file
......@@ -25,7 +25,7 @@
android:background="@color/colorLighter"
android:fontFamily="monospace"
android:padding="@dimen/padding"
android:text="@string/title_device_create"
android:text="@string/create_title"
android:textAlignment="center"
android:textSize="@dimen/font" />
......@@ -34,7 +34,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_sm"
android:hint="@string/input_placeholder"
android:hint="@string/create_input_placeholder"
android:padding="@dimen/padding_lg" />
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".home.record.RecordFragment">
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<TextView
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="com.example.zxa01.iotclient.home.record.viewModel.RecordViewModel" />
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="records" />
tools:context=".home.record.view.RecordFragment">
<ProgressBar
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:secondaryProgress="40"
android:theme="@style/ProgressTheme"
android:visibility="@{viewModel.isLoading ? View.VISIBLE : View.GONE}" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:orientation="vertical"
android:visibility="@{viewModel.isLoading ? View.GONE : View.VISIBLE}">
<TextView
android:id="@+id/textViewTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/padding"
android:paddingTop="@dimen/padding_lg"
android:paddingRight="@dimen/padding"
android:paddingBottom="@dimen/padding"
android:background="@drawable/border_bottom_xl"
android:text="@string/record_title"
android:textColor="@color/colorAccent"
android:textSize="@dimen/font_lg"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="@+id/record_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layout_marginTop="@dimen/margin"
app:setAdapter="@{viewModel.getAdapter()}"
tools:listitem="@layout/recycler_view_record" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
</FrameLayout>
</layout>
\ No newline at end of file
......@@ -10,4 +10,5 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/recycler_view_setting" />
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
......@@ -21,7 +19,6 @@
android:layout_margin="@dimen/margin_sm"
android:background="@drawable/shadow"
android:elevation="2dp"
android:onClick="@{()->viewModel.onChangeClick(position)}"
android:padding="@dimen/margin">
<LinearLayout
......@@ -29,6 +26,15 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textViewTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/title_privacy"
android:textColor="@color/colorAccent"
android:textSize="@dimen/font_lg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -38,7 +44,7 @@
android:id="@+id/textViewPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隱私政策 1"
android:text='@{@string/privacy_title+" "+String.valueOf(position+1)}'
android:textColor="@color/colorGray"
android:textSize="@dimen/font" />
......@@ -47,8 +53,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="拒絕/同意 "
android:onClick="@{()->viewModel.onChangeClick(position)}"
android:onClick="@{(view)->viewModel.onChangeClick(position,view)}"
android:text="@string/privacy_content"
android:textAlignment="textEnd"
android:thumbTextPadding="@dimen/padding_lg" />
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="position"
type="java.lang.Integer" />
<variable
name="viewModel"
type="com.example.zxa01.iotclient.home.record.viewModel.RecordViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_bottom"
android:orientation="vertical"
android:onClick="@{()->viewModel.onPrivacyPolicyReportClick(position)}"
android:padding="@dimen/margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{viewModel.getPrivacyPolicyReportAt(position).device.name}"
android:textColor="@color/colorLight"
android:textSize="18sp"
android:textStyle="bold"
tools:text="@tools:sample/lorem" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/padding_sm"
android:text='@{@string/privacy_version+" "+String.valueOf(position+1)}'
android:textSize="@dimen/font_sm"
tools:text="@tools:sample/lorem" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{viewModel.getPrivacyPolicyReportAt(position).description}"
tools:text="@tools:sample/lorem" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='2019.04.23'
tools:text="@tools:sample/lorem" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -9,7 +9,7 @@
<item
android:id="@+id/navigation_privacy"
android:icon="@drawable/ic_lock_outline_black_24dp"
android:title="@string/nav_privacy" />
android:title="@string/nav_record" />
<item
android:id="@+id/navigation_setting"
......
......@@ -2,22 +2,41 @@
<!--Title-->
<string name="title_detail">裝置資訊</string>
<string name="title_privacy">隱私偏好設定</string>
<string name="title_privacy">隱私選擇設定</string>
<string name="title_setting">設定</string>
<string name="title_device_create">新增裝置</string>
<!--Home-->
<string name="app_name">IOTClient</string>
<string name="nav_device">Device</string>
<string name="nav_privacy">Privacy</string>
<string name="nav_record">Record</string>
<string name="nav_setting">Setting</string>
<!--Create-->
<string name="input_placeholder">請輸入裝置的UDN</string>
<string name="button_qrcode">QRcode</string>
<string name="button_correct">新增</string>
<string name="button_cancel">返回</string>
<string name="qrcode_error">格式錯誤</string>
<string name="create_title">新增裝置</string>
<string name="create_input_placeholder">請輸入裝置的UDN</string>
<string name="create_button_qrcode">QRcode</string>
<string name="create_button_correct">新增</string>
<string name="create_button_cancel">返回</string>
<string name="create_qrcode_error">格式錯誤</string>
<!--Detail-->
<string name="detail_preference_setting">隱私偏好設定</string>
<string name="detail_detect_report">檢測報告下載</string>
<string name="detail_report_download">下載中...</string>
<!--Privacy-->
<string name="privacy_report_title">隱私政策報告</string>
<string name="privacy_version">版本</string>
<string name="privacy_request">我們會依照下列政策收集相關資料</string>
<string name="privacy_title">隱私政策</string>
<string name="privacy_content">拒絕/同意</string>
<string name="privacy_loading_title">隱私選擇儲存中</string>
<string name="privacy_loading_message">請稍後...</string>
<!--Record-->
<string name="record_title">隱私選擇記錄</string>
<string name="record_view">檢視</string>
<!--Login-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment