Commit 2bf070bb authored by DESKTOP-NFGF3PG\zxa01's avatar DESKTOP-NFGF3PG\zxa01

update UI

parent 1a4ddac9
package com.example.zxa01.iotclient.common.http; package com.example.zxa01.iotclient.common.http;
import com.example.zxa01.iotclient.common.pojo.device.Device; import com.example.zxa01.iotclient.common.pojo.device.Device;
import com.example.zxa01.iotclient.common.pojo.index.PrivacyChoiceIndex; import com.example.zxa01.iotclient.common.pojo.index.PrivacyChoiceResponse;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyChoice;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport; import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport;
import com.example.zxa01.iotclient.common.shared.Config; import com.example.zxa01.iotclient.common.shared.Config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import java.util.List; import java.util.List;
...@@ -54,21 +52,17 @@ public class Api { ...@@ -54,21 +52,17 @@ public class Api {
@POST("/device/{udn}") @POST("/device/{udn}")
Call<Device> bindDeviceAndGateway(@Path("udn") String udn); Call<Device> bindDeviceAndGateway(@Path("udn") String udn);
// 取得該裝置相關資料
@GET("/device/{udn}")
Call<Device> readDevice(@Path("udn") String udn);
// 取得該裝置的隱私政策與相關資料 // 取得該裝置的隱私政策與相關資料
@GET("/privacy/{udn}") @GET("/privacy/{udn}")
Call<PrivacyPolicyReport> readPrivacyPolicyReportByDevice(@Path("udn") String udn); Call<PrivacyPolicyReport> readPrivacyPolicyReportByDevice(@Path("udn") String udn);
// 表達隱私偏好 // 表達隱私偏好
@POST("/choice") @POST("/choice")
Call<PrivacyChoice> setPrivacyChoice(@Body PrivacyChoice privacyChoice); Call<PrivacyChoiceResponse> setPrivacyChoice(@Body String privacyChoice);
// 取得隱私偏好記錄 // 取得隱私偏好記錄
@GET("/choice") @GET("/choice")
Call<List<PrivacyChoiceIndex>> readPrivacyChoiceRecordsByUser(); Call<List<PrivacyChoiceResponse>> readPrivacyChoiceRecordsByUser();
} }
} }
package com.example.zxa01.iotclient.common.pojo; package com.example.zxa01.iotclient.common.pojo;
public class Setting { public class Setting {
private String key; private String key;
private String value; private String value;
public Setting(String key, String value) { public Setting() {
this.key = key;
this.value = value;
} }
public String getKey() { public String getKey() {
return key; return key;
} }
public void setKey(String key) { public Setting setKey(String key) {
this.key = key; this.key = key;
return this;
} }
public String getValue() { public String getValue() {
return value; return value;
} }
public void setValue(String value) { public Setting setValue(String value) {
this.value = value; this.value = value;
return this;
} }
} }
package com.example.zxa01.iotclient.common.pojo.index; package com.example.zxa01.iotclient.common.pojo.index;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyContent;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyChoice;
import java.time.LocalDateTime; public class PrivacyChoiceResponse {
public class PrivacyChoiceIndex {
private long id; private long id;
private LocalDateTime localDateTime; private String localDateTime;
private PrivacyChoice privacyChoice; private PrivacyContent privacyContent;
public PrivacyChoiceIndex(){ public PrivacyChoiceResponse(){
} }
...@@ -22,19 +20,19 @@ public class PrivacyChoiceIndex { ...@@ -22,19 +20,19 @@ public class PrivacyChoiceIndex {
this.id = id; this.id = id;
} }
public LocalDateTime getLocalDateTime() { public String getLocalDateTime() {
return localDateTime; return localDateTime;
} }
public void setLocalDateTime(LocalDateTime localDateTime) { public void setLocalDateTime(String localDateTime) {
this.localDateTime = localDateTime; this.localDateTime = localDateTime;
} }
public PrivacyChoice getPrivacyChoice() { public PrivacyContent getPrivacyContent() {
return privacyChoice; return privacyContent;
} }
public void setPrivacyChoice(PrivacyChoice privacyChoice) { public void setPrivacyContent(PrivacyContent privacyContent) {
this.privacyChoice = privacyChoice; this.privacyContent = privacyContent;
} }
} }
...@@ -8,7 +8,7 @@ public class DefaultData { ...@@ -8,7 +8,7 @@ public class DefaultData {
private LoginMessage loginMessage; private LoginMessage loginMessage;
private DefaultData() { private DefaultData() {
loginMessage = new LoginMessage("192.168.2.69:8080", "user", "1234"); loginMessage = new LoginMessage("192.168.2.90:8080", "user", "1234");
} }
public static DefaultData getDefaultData() { public static DefaultData getDefaultData() {
......
...@@ -29,15 +29,15 @@ public class DetailModel extends BaseObservable { ...@@ -29,15 +29,15 @@ public class DetailModel extends BaseObservable {
} }
public void readDevice(@NonNull String udn) { public void readDevice(@NonNull String udn) {
Api.getApi().readDevice(udn).enqueue(new Callback<Device>() { Api.getApi().readPrivacyPolicyReportByDevice(udn).enqueue(new Callback<PrivacyPolicyReport>() {
@Override @Override
public void onResponse(Call<Device> call, Response<Device> response) { public void onResponse(Call<PrivacyPolicyReport> call, Response<PrivacyPolicyReport> response) {
setDeviceMLD(response == null || response.body() == null ? setDeviceMLD(response == null || response.body() == null ?
null : response.body()); null : response.body().getDevice());
} }
@Override @Override
public void onFailure(Call<Device> call, Throwable t) { public void onFailure(Call<PrivacyPolicyReport> call, Throwable t) {
Log.e("readDevice - onFailure()", t.getMessage(), t); Log.e("readDevice - onFailure()", t.getMessage(), t);
} }
}); });
......
...@@ -6,7 +6,7 @@ import android.content.Context; ...@@ -6,7 +6,7 @@ import android.content.Context;
public class HomeViewModel extends ViewModel { public class HomeViewModel extends ViewModel {
private Context context; private Context context;
private HomeModel homeModel = new HomeModel(); private HomeModel homeModel;
public HomeViewModel(Context context) { public HomeViewModel(Context context) {
this.context = context; this.context = context;
......
...@@ -5,6 +5,7 @@ import com.example.zxa01.iotclient.common.pojo.device.Device; ...@@ -5,6 +5,7 @@ import com.example.zxa01.iotclient.common.pojo.device.Device;
import android.arch.lifecycle.MutableLiveData; import android.arch.lifecycle.MutableLiveData;
import android.databinding.BaseObservable; import android.databinding.BaseObservable;
import android.support.annotation.NonNull;
import android.util.Log; import android.util.Log;
import java.util.List; import java.util.List;
...@@ -29,8 +30,8 @@ public class DeviceModel extends BaseObservable { ...@@ -29,8 +30,8 @@ public class DeviceModel extends BaseObservable {
Api.getApi().readDevices().enqueue( Api.getApi().readDevices().enqueue(
new Callback<List<Device>>() { new Callback<List<Device>>() {
@Override @Override
public void onResponse(Call<List<Device>> call, Response<List<Device>> response) { public void onResponse(Call<List<Device>> call, @NonNull Response<List<Device>> response) {
devicesMLD.setValue(response == null || response.body() == null ? devicesMLD.setValue(response.body() == null ?
null : response.body().stream().collect(Collectors.toList())); null : response.body().stream().collect(Collectors.toList()));
} }
......
...@@ -8,14 +8,14 @@ import android.support.v7.widget.RecyclerView; ...@@ -8,14 +8,14 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.example.zxa01.iotclient.BR; import com.example.zxa01.iotclient.BR;
import com.example.zxa01.iotclient.common.pojo.index.PrivacyChoiceIndex; import com.example.zxa01.iotclient.common.pojo.index.PrivacyChoiceResponse;
import java.util.List; import java.util.List;
public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.MyViewHolder> { public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.MyViewHolder> {
private int layoutId; private int layoutId;
private List<PrivacyChoiceIndex> privacyChoiceIndices; private List<PrivacyChoiceResponse> privacyChoiceResponses;
private RecordViewModel viewModel; private RecordViewModel viewModel;
public RecordAdapter(@LayoutRes int layoutId, RecordViewModel viewModel) { public RecordAdapter(@LayoutRes int layoutId, RecordViewModel viewModel) {
...@@ -40,7 +40,7 @@ public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.MyViewHold ...@@ -40,7 +40,7 @@ public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.MyViewHold
@Override @Override
public int getItemCount() { public int getItemCount() {
return privacyChoiceIndices == null ? 0 : privacyChoiceIndices.size(); return privacyChoiceResponses == null ? 0 : privacyChoiceResponses.size();
} }
@Override @Override
...@@ -48,8 +48,8 @@ public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.MyViewHold ...@@ -48,8 +48,8 @@ public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.MyViewHold
return getLayoutIdForPosition(position); return getLayoutIdForPosition(position);
} }
public void setPrivacyChoiceIndices(List<PrivacyChoiceIndex> privacyChoiceIndices) { public void setPrivacyChoiceResponses(List<PrivacyChoiceResponse> privacyChoiceResponses) {
this.privacyChoiceIndices = privacyChoiceIndices; this.privacyChoiceResponses = privacyChoiceResponses;
} }
class MyViewHolder extends RecyclerView.ViewHolder { class MyViewHolder extends RecyclerView.ViewHolder {
......
...@@ -2,26 +2,11 @@ package com.example.zxa01.iotclient.component.home.record; ...@@ -2,26 +2,11 @@ package com.example.zxa01.iotclient.component.home.record;
import android.arch.lifecycle.MutableLiveData; import android.arch.lifecycle.MutableLiveData;
import android.databinding.BaseObservable; import android.databinding.BaseObservable;
import android.support.annotation.NonNull;
import android.util.Log; import android.util.Log;
import com.example.zxa01.iotclient.common.http.Api; import com.example.zxa01.iotclient.common.http.Api;
import com.example.zxa01.iotclient.common.pojo.device.Device; import com.example.zxa01.iotclient.common.pojo.index.PrivacyChoiceResponse;
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.index.PrivacyChoiceIndex;
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 java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -31,31 +16,26 @@ import retrofit2.Response; ...@@ -31,31 +16,26 @@ import retrofit2.Response;
public class RecordModel extends BaseObservable { public class RecordModel extends BaseObservable {
private List<PrivacyChoiceIndex> privacyChoiceIndices = new ArrayList<>(); private MutableLiveData<List<PrivacyChoiceResponse>> privacyChoiceResponsesMLD = new MutableLiveData<>();
private MutableLiveData<List<PrivacyChoiceIndex>> privacyChoiceIndicesMLD = new MutableLiveData<>();
public RecordModel() { public RecordModel() {
} }
private void addPrivacyChoiceIndices(PrivacyChoiceIndex privacyChoiceIndex) { public MutableLiveData<List<PrivacyChoiceResponse>> getPrivacyChoiceResponsesMLD() {
privacyChoiceIndices.add(privacyChoiceIndex); return privacyChoiceResponsesMLD;
}
public MutableLiveData<List<PrivacyChoiceIndex>> getPrivacyChoiceIndicesMLD() {
return privacyChoiceIndicesMLD;
} }
public void fetchRecord() { public void fetchRecord() {
Api.getApi().readPrivacyChoiceRecordsByUser().enqueue(new Callback<List<PrivacyChoiceIndex>>() { Api.getApi().readPrivacyChoiceRecordsByUser().enqueue(new Callback<List<PrivacyChoiceResponse>>() {
@Override @Override
public void onResponse(Call<List<PrivacyChoiceIndex>> call, Response<List<PrivacyChoiceIndex>> response) { public void onResponse(Call<List<PrivacyChoiceResponse>> call, @NonNull Response<List<PrivacyChoiceResponse>> response) {
// TODO transfer response privacyChoiceResponsesMLD.setValue(response.body() == null ?
privacyChoiceIndicesMLD.setValue(response == null || response.body() == null ?
null : response.body().stream().collect(Collectors.toList())); null : response.body().stream().collect(Collectors.toList()));
} }
@Override @Override
public void onFailure(Call<List<PrivacyChoiceIndex>> call, Throwable t) { public void onFailure(Call<List<PrivacyChoiceResponse>> call, Throwable t) {
Log.e("fetchRecord - onFailure()", t.getMessage(), t);
} }
}); });
......
...@@ -8,7 +8,7 @@ import android.databinding.ObservableBoolean; ...@@ -8,7 +8,7 @@ import android.databinding.ObservableBoolean;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.example.zxa01.iotclient.R; import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.common.pojo.index.PrivacyChoiceIndex; import com.example.zxa01.iotclient.common.pojo.index.PrivacyChoiceResponse;
import com.example.zxa01.iotclient.component.privacy.PrivacyActivity; import com.example.zxa01.iotclient.component.privacy.PrivacyActivity;
import java.util.List; import java.util.List;
...@@ -32,30 +32,30 @@ public class RecordViewModel extends ViewModel { ...@@ -32,30 +32,30 @@ public class RecordViewModel extends ViewModel {
recordModel.fetchRecord(); recordModel.fetchRecord();
} }
public MutableLiveData<List<PrivacyChoiceIndex>> observePrivacyChoiceIndicesMLD() { public MutableLiveData<List<PrivacyChoiceResponse>> observePrivacyChoiceIndicesMLD() {
return recordModel.getPrivacyChoiceIndicesMLD(); return recordModel.getPrivacyChoiceResponsesMLD();
} }
/** /**
* child model * child model
*/ */
public PrivacyChoiceIndex getPrivacyChoiceAt(@NonNull Integer index) { public PrivacyChoiceResponse getPrivacyChoiceAt(@NonNull Integer index) {
if (recordModel.getPrivacyChoiceIndicesMLD().getValue() != null && if (recordModel.getPrivacyChoiceResponsesMLD().getValue() != null &&
recordModel.getPrivacyChoiceIndicesMLD().getValue().size() > index) { recordModel.getPrivacyChoiceResponsesMLD().getValue().size() > index) {
return recordModel.getPrivacyChoiceIndicesMLD().getValue().get(index); return recordModel.getPrivacyChoiceResponsesMLD().getValue().get(index);
} }
return null; return null;
} }
public void onPrivacyChoiceClick(@NonNull Integer index) { public void onPrivacyChoiceClick(@NonNull Integer index) {
if (recordModel.getPrivacyChoiceIndicesMLD().getValue() != null && if (recordModel.getPrivacyChoiceResponsesMLD().getValue() != null &&
recordModel.getPrivacyChoiceIndicesMLD().getValue().size() > index) { recordModel.getPrivacyChoiceResponsesMLD().getValue().size() > index) {
context.startActivity( context.startActivity(
new Intent(context, PrivacyActivity.class) new Intent(context, PrivacyActivity.class)
.putExtra("udn", .putExtra("udn",
recordModel.getPrivacyChoiceIndicesMLD().getValue().get(index) recordModel.getPrivacyChoiceResponsesMLD().getValue().get(index)
.getPrivacyChoice().getPrivacyContent().getDevice().getUdn())); .getPrivacyContent().getDevice().getUdn()));
} }
} }
...@@ -67,9 +67,9 @@ public class RecordViewModel extends ViewModel { ...@@ -67,9 +67,9 @@ public class RecordViewModel extends ViewModel {
return adapter; return adapter;
} }
public void setAdapter(List<PrivacyChoiceIndex> privacyChoiceIndices) { public void setAdapter(List<PrivacyChoiceResponse> privacyChoiceResponses) {
isLoading.set(false); isLoading.set(false);
adapter.setPrivacyChoiceIndices(privacyChoiceIndices); adapter.setPrivacyChoiceResponses(privacyChoiceResponses);
} }
} }
...@@ -26,21 +26,6 @@ public class LoginModel extends BaseObservable { ...@@ -26,21 +26,6 @@ public class LoginModel extends BaseObservable {
if (verification(message)) { if (verification(message)) {
settingConfig(message); settingConfig(message);
isAuthorized.setValue(true); isAuthorized.setValue(true);
// Callback<Object> callback = new Callback<Object>() {
// @Override
// public void onResponse(Call<Object> call, Response<Object> response) {
// // TODO login
// isAuthorized.setValue(true);
// }
//
// @Override
// public void onFailure(Call<Object> call, Throwable t) {
// Log.e("login - onFailure()", t.getMessage(), t);
// }
// };
//
// // TODO loginMessage to json
// Api.getApi().getDevices().enqueue(callback);
} }
} }
...@@ -55,9 +40,9 @@ public class LoginModel extends BaseObservable { ...@@ -55,9 +40,9 @@ public class LoginModel extends BaseObservable {
private void settingConfig(@NonNull LoginMessage message) { private void settingConfig(@NonNull LoginMessage message) {
Config.getConfig().setUser(new User().setAccount(message.getAccount())); Config.getConfig().setUser(new User().setAccount(message.getAccount()));
Config.getConfig().setGateway(message.getGateway()); Config.getConfig().setGateway(message.getGateway());
Config.getConfig().addSetting(new Setting(Config.USER, Config.getConfig().getUser().getAccount())); Config.getConfig().addSetting(new Setting().setKey(Config.USER).setValue(Config.getConfig().getUser().getAccount()));
Config.getConfig().addSetting(new Setting(Config.GATEWAY, message.getGateway())); Config.getConfig().addSetting(new Setting().setKey(Config.GATEWAY).setValue(message.getGateway()));
Config.getConfig().addSetting(new Setting(Config.LOGOUT, Config.LOGOUT_MESSAGE)); Config.getConfig().addSetting(new Setting().setKey(Config.LOGOUT).setValue(Config.LOGOUT_MESSAGE));
} }
} }
...@@ -7,9 +7,12 @@ import android.support.annotation.NonNull; ...@@ -7,9 +7,12 @@ import android.support.annotation.NonNull;
import android.util.Log; import android.util.Log;
import com.example.zxa01.iotclient.common.http.Api; import com.example.zxa01.iotclient.common.http.Api;
import com.example.zxa01.iotclient.common.pojo.index.PrivacyChoiceResponse;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyChoice; import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyChoice;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyContent; import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyContent;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport; import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport;
import com.example.zxa01.iotclient.common.shared.Config;
import com.google.gson.Gson;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
...@@ -18,6 +21,7 @@ import retrofit2.Response; ...@@ -18,6 +21,7 @@ import retrofit2.Response;
public class PrivacyModel extends BaseObservable { public class PrivacyModel extends BaseObservable {
private MutableLiveData<Boolean> isUploadMLD = new MutableLiveData<>(); private MutableLiveData<Boolean> isUploadMLD = new MutableLiveData<>();
private MutableLiveData<PrivacyPolicyReport> privacyPolicyReportMLD = new MutableLiveData<>(); private MutableLiveData<PrivacyPolicyReport> privacyPolicyReportMLD = new MutableLiveData<>();
public PrivacyModel() { public PrivacyModel() {
...@@ -50,19 +54,30 @@ public class PrivacyModel extends BaseObservable { ...@@ -50,19 +54,30 @@ public class PrivacyModel extends BaseObservable {
public void setPrivacyChoice(@NonNull PrivacyContent privacyContent, @NonNull boolean isAccepted) { public void setPrivacyChoice(@NonNull PrivacyContent privacyContent, @NonNull boolean isAccepted) {
isUploadMLD.setValue(true); isUploadMLD.setValue(true);
Api.getApi().setPrivacyChoice( Api.getApi().setPrivacyChoice(transferPrivacyContent(privacyContent, isAccepted))
new PrivacyChoice().setPrivacyContent(privacyContent).setAccepted(isAccepted)).enqueue( .enqueue(new Callback<PrivacyChoiceResponse>() {
new Callback<PrivacyChoice>() {
@Override @Override
public void onResponse(Call<PrivacyChoice> call, Response<PrivacyChoice> response) { public void onResponse(Call<PrivacyChoiceResponse> call, Response<PrivacyChoiceResponse> response) {
new Handler().postDelayed(() -> isUploadMLD.setValue(false), 500); dialogDelay();
} }
@Override @Override
public void onFailure(Call<PrivacyChoice> call, Throwable t) { public void onFailure(Call<PrivacyChoiceResponse> call, Throwable t) {
dialogDelay();
Log.e("setPrivacyChoice - onFailure()", t.getMessage(), t); Log.e("setPrivacyChoice - onFailure()", t.getMessage(), t);
} }
}); });
} }
private void dialogDelay() {
new Handler().postDelayed(() -> isUploadMLD.setValue(false), 500);
}
private String transferPrivacyContent(@NonNull PrivacyContent privacyContent, @NonNull boolean isAccepted) {
return new Gson().toJson(
new PrivacyChoice().setPrivacyContent(
privacyContent.setUser(Config.getConfig().getUser()))
.setAccepted(isAccepted));
}
} }
...@@ -59,7 +59,6 @@ public class PrivacyViewModel extends ViewModel { ...@@ -59,7 +59,6 @@ public class PrivacyViewModel extends ViewModel {
public PrivacyPolicy getPrivacyAt(@NonNull Integer index) { public PrivacyPolicy getPrivacyAt(@NonNull Integer index) {
if (privacyModel.getPrivacyPolicyReportMLD().getValue() != null && if (privacyModel.getPrivacyPolicyReportMLD().getValue() != null &&
index != null &&
privacyModel.getPrivacyPolicyReportMLD().getValue().getPolicies().size() > index) { privacyModel.getPrivacyPolicyReportMLD().getValue().getPolicies().size() > index) {
return privacyModel.getPrivacyPolicyReportMLD().getValue().getPolicies().get(index); return privacyModel.getPrivacyPolicyReportMLD().getValue().getPolicies().get(index);
} }
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorGreen" />
<corners android:radius="4dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorLightest" />
<corners android:radius="4dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorRed" />
<corners android:radius="4dp" />
</shape>
\ No newline at end of file
...@@ -40,14 +40,12 @@ ...@@ -40,14 +40,12 @@
android:id="@+id/textViewTitle" android:id="@+id/textViewTitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="@dimen/padding" android:background="@color/colorLightest"
android:paddingTop="@dimen/padding_lg" android:elevation="2dp"
android:paddingRight="@dimen/padding" android:padding="@dimen/padding"
android:paddingBottom="@dimen/padding"
android:background="@drawable/border_bottom_xl"
android:text="@string/record_title" android:text="@string/record_title"
android:textColor="@color/colorAccent" android:textColor="@color/colorLight"
android:textSize="@dimen/font_lg" android:textSize="@dimen/font"
android:textStyle="bold" /> android:textStyle="bold" />
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
...@@ -55,7 +53,7 @@ ...@@ -55,7 +53,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
android:layout_marginTop="@dimen/margin" android:paddingTop="@dimen/padding_sm"
app:setAdapter="@{viewModel.getAdapter()}" app:setAdapter="@{viewModel.getAdapter()}"
tools:listitem="@layout/recycler_view_record" /> tools:listitem="@layout/recycler_view_record" />
......
...@@ -34,37 +34,63 @@ ...@@ -34,37 +34,63 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{viewModel.getPrivacyChoiceAt(position).privacyChoice.privacyContent.device.name}" android:text="@{viewModel.getPrivacyChoiceAt(position).privacyContent.device.name}"
android:textColor="@color/colorLight" android:textColor="@color/colorPrimary"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" android:textStyle="bold"
tools:text="@tools:sample/lorem" /> tools:text="溫度感測器" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/padding_sm" android:paddingTop="@dimen/padding_xs"
android:paddingBottom="@dimen/padding_xs"
android:text='@{@string/privacy_version+" "+String.valueOf(position+1)}' android:text='@{@string/privacy_version+" "+String.valueOf(position+1)}'
android:textSize="@dimen/font_sm" android:textSize="@dimen/font_sm"
tools:text="@tools:sample/lorem" /> tools:text="版本1" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{viewModel.getPrivacyChoiceAt(position).privacyChoice.privacyContent.policy.description}" android:text="@{viewModel.getPrivacyChoiceAt(position).privacyContent.policy.description}"
tools:text="@tools:sample/lorem" /> tools:text="本APP會蒐集使用者周遭溫度作為第三方資料之地區環境分析資料。" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{viewModel.getPrivacyChoiceAt(position).localDateTime.toString()}" android:layout_marginTop="@dimen/margin_sm"
tools:text="@tools:sample/lorem" /> android:layout_marginBottom="@dimen/margin_sm"
android:textColor="@color/colorWhite"
android:background="@drawable/green_radius_background"
android:paddingLeft="@dimen/padding_sm"
android:paddingTop="@dimen/padding_xs"
android:paddingRight="@dimen/padding_sm"
android:paddingBottom="@dimen/padding_xs"
android:text="同意"
android:textSize="@dimen/font_sm"
tools:text="同意" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="同意或拒絕" android:layout_marginTop="@dimen/margin_sm"
tools:text="@tools:sample/lorem" /> android:layout_marginBottom="@dimen/margin_sm"
android:layout_marginLeft="@dimen/margin_sm"
android:background="@drawable/light_radius_background"
android:paddingLeft="@dimen/padding_sm"
android:paddingTop="@dimen/padding_xs"
android:paddingRight="@dimen/padding_sm"
android:paddingBottom="@dimen/padding_xs"
android:text="@{viewModel.getPrivacyChoiceAt(position).localDateTime}"
android:textSize="@dimen/font_sm"
tools:text="2019-01-12 13:52" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
......
...@@ -10,5 +10,7 @@ ...@@ -10,5 +10,7 @@
<color name="colorLightest">#F4F4F4</color> <color name="colorLightest">#F4F4F4</color>
<color name="colorWhite">#FFFFFF</color> <color name="colorWhite">#FFFFFF</color>
<color name="colorTransparent">#00000000</color> <color name="colorTransparent">#00000000</color>
<color name="colorGreen">#28A745</color>
<color name="colorRed">#DC3545</color>
</resources> </resources>
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
<string name="privacy_content">拒絕/同意</string> <string name="privacy_content">拒絕/同意</string>
<string name="privacy_loading_title">隱私選擇儲存中</string> <string name="privacy_loading_title">隱私選擇儲存中</string>
<string name="privacy_loading_message">請稍後...</string> <string name="privacy_loading_message">請稍後...</string>
<string name="privacy_loading_error">儲存失敗,請重新嘗試</string>
<!--Record--> <!--Record-->
<string name="record_title">隱私選擇記錄</string> <string name="record_title">隱私選擇記錄</string>
......
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