Commit 69a4f4b9 authored by DESKTOP-NFGF3PG\zxa01's avatar DESKTOP-NFGF3PG\zxa01

update the api

parent e809f283
......@@ -36,6 +36,9 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// modelmapper
compile 'net.eunjae.android.modelmapper:ModelMapper:1.0.6'
// rxjava
implementation "io.reactivex:rxjava:1.1.8"
implementation "io.reactivex:rxandroid:1.2.1"
......@@ -44,9 +47,4 @@ dependencies {
implementation "com.squareup.retrofit2:retrofit:2.1.0"
implementation "com.squareup.retrofit2:converter-gson:2.1.0"
// 可移除
implementation 'com.squareup.okhttp3:okhttp:3.14.1'
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
implementation 'com.android.support:gridlayout-v7:28.0.0'
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.zxa01.iotclient">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
......
package com.example.zxa01.iotclient.common.bindings;
import android.databinding.BindingAdapter;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public class CustomViewBindings {
@BindingAdapter("setAdapter")
public static void bindRecyclerViewAdapter(RecyclerView recyclerView, RecyclerView.Adapter<?> adapter) {
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
recyclerView.setAdapter(adapter);
}
}
package com.example.zxa01.iotclient.common.http;
import com.example.zxa01.iotclient.common.pojo.device.Device;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyChoice;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport;
import com.example.zxa01.iotclient.common.shared.Config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.List;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
public class Api {
private static ApiInterface api;
private static final String BASE_URL = "https://dog.ceo";
public static ApiInterface getApi() {
if (api == null) {
OkHttpClient client = new OkHttpClient.Builder()
.build();
Gson gson = new GsonBuilder()
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.baseUrl("http://" + Config.getConfig().getGateway())
.client(new OkHttpClient.Builder()
.build())
.addConverterFactory(
GsonConverterFactory.create(gson))
GsonConverterFactory.create(new GsonBuilder()
.create()))
.build();
api = retrofit.create(ApiInterface.class);
......@@ -39,25 +44,22 @@ public class Api {
@POST("/api/breeds/list/all")
Call<Object> login();
@GET("/api/breeds/list/all")
Call<Object> getDevices();
@GET("/device")
Call<List<Device>> getDevices();
@GET("/api/breeds/list/all")
Call<Object> getDevice();
@GET("/device/{udn}")
Call<Device> readDevice(@Path("udn") String udn);
@GET("/api/breeds/list/all")
Call<Object> getPrivacyPolicyReport();
@GET("/device/privacy/{udn}")
Call<PrivacyPolicyReport> readPrivacyPolicyReportByDevice(@Path("udn") String udn);
@GET("/api/breeds/list/all")
Call<Object> updatePrivacyPolicyChoice();
@POST("/choice")
Call<PrivacyChoice> setPrivacyChoice(@Body PrivacyChoice privacyChoice);
// TODO
@GET("/api/breeds/list/all")
Call<Object> getRecord();
// @GET("/api/breed/{breed}/images")
// Call<DogBreedImages> getImagesByBreed(@Path("breed") String breed);
}
}
......@@ -2,13 +2,14 @@ package com.example.zxa01.iotclient.common.pojo.device;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.RequiresApi;
import java.util.LinkedList;
import java.util.List;
public class Device implements Parcelable {
private String UDN;
private String udn;
private String name;
private Type type;
private Manufacturer manufacturer;
......@@ -31,7 +32,7 @@ public class Device implements Parcelable {
icons.add(new Icon(icon));
}
}
this.setUDN(device.UDN)
this.setUdn(device.udn)
.setName(device.name)
.setType(device.type)
.setManufacturer(device.manufacturer != null ? new Manufacturer(device.manufacturer) : null)
......@@ -42,7 +43,7 @@ public class Device implements Parcelable {
}
private Device(Parcel in) {
UDN = in.readString();
udn = in.readString();
name = in.readString();
type = Type.valueOf(in.readString());
manufacturer = in.readParcelable(Manufacturer.class.getClassLoader());
......@@ -55,7 +56,7 @@ public class Device implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(UDN);
dest.writeString(udn);
dest.writeString(name);
dest.writeString(type.name());
dest.writeParcelable(manufacturer, flags);
......@@ -83,12 +84,12 @@ public class Device implements Parcelable {
}
};
public String getUDN() {
return UDN;
public String getUdn() {
return udn;
}
public Device setUDN(String UDN) {
this.UDN = UDN;
public Device setUdn(String udn) {
this.udn = udn;
return this;
}
......@@ -176,12 +177,12 @@ public class Device implements Parcelable {
Device device = (Device) o;
return UDN != null ? UDN.equals(device.UDN) : device.UDN == null;
return udn != null ? udn.equals(device.udn) : device.udn == null;
}
@Override
public int hashCode() {
return UDN != null ? UDN.hashCode() : 0;
return udn != null ? udn.hashCode() : 0;
}
public enum Type {
......@@ -191,7 +192,7 @@ public class Device implements Parcelable {
@Override
public String toString() {
return "Device{" +
"UDN='" + UDN + '\'' +
"udn='" + udn + '\'' +
", name='" + name + '\'' +
", type=" + type +
", manufacturer=" + manufacturer +
......
......@@ -4,29 +4,35 @@ package com.example.zxa01.iotclient.common.shared;
import com.example.zxa01.iotclient.common.pojo.Setting;
import com.example.zxa01.iotclient.common.pojo.auth.User;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
public class Config {
public static String USER = "使用者";
public static String GATEWAY = "閘道器位置";
public static String LOGOUT = "登出";
public static String LOGOUT_MESSAGE = "登出本帳號";
private static Config config = new Config();
private User user;
private String gateway;
private List<Setting> settings;
private Config() {
this.user = new User();
this.gateway = "";
this.settings = new LinkedList<>();
this.reset();
}
public static Config getConfig() {
return config;
}
public void reset() {
this.user = new User();
this.gateway = "";
this.settings = new LinkedList<>();
}
public User getUser() {
return user;
}
......
......@@ -4,6 +4,7 @@ import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.databinding.ActivityDetailBinding;
......@@ -16,16 +17,20 @@ public class DetailActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_detail);
binding();
init();
}
private void binding() {
viewModel = new DetailViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
init();
}
public void init(){
viewModel.fetchDevice();
viewModel.observeDeviceMLD().observe(this,viewModel::setDevice);
private void init() {
viewModel.fetchDevice(getIntent().getStringExtra("udn"));
viewModel.observeDeviceMLD().observe(this, viewModel::setDevice);
}
@Override
......
package com.example.zxa01.iotclient.component.detail;
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 retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
......@@ -17,43 +20,28 @@ public class DetailModel extends BaseObservable {
public DetailModel() {
}
public void setDeviceMLD(Device device){
deviceMLD.setValue(device);
public MutableLiveData<Device> getDeviceMLD() {
return deviceMLD;
}
public MutableLiveData<Device> getDeviceMLD(){
return deviceMLD;
public void setDeviceMLD(Device device) {
deviceMLD.setValue(device);
}
public void fetchDevice() {
Callback<Object> callback = new Callback<Object>() {
public void readDevice(String udn) {
// TODO instead of udn
Api.getApi().readDevice("1").enqueue(new Callback<Device>() {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
// TODO transfer response
setDeviceMLD(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));
public void onResponse(Call<Device> call, Response<Device> response) {
setDeviceMLD(response == null || response.body() == null ?
null : response.body());
}
@Override
public void onFailure(Call<Object> call, Throwable t) {
public void onFailure(Call<Device> call, Throwable t) {
Log.e("fetchDevice - onFailure()", t.getMessage(), t);
}
};
Api.getApi().getDevice().enqueue(callback);
});
}
......
......@@ -24,8 +24,8 @@ public class DetailViewModel extends ViewModel {
this.context = context;
}
public void fetchDevice() {
detailModel.fetchDevice();
public void fetchDevice(String udn) {
detailModel.readDevice(udn);
}
public MutableLiveData<Device> observeDeviceMLD() {
......@@ -33,7 +33,7 @@ public class DetailViewModel extends ViewModel {
}
public void setDevice(Device device) {
if (device.getUDN() != null) {
if (device != null && device.getUdn() != null) {
this.isLoading.set(false);
this.device.set(device);
}
......@@ -42,7 +42,7 @@ public class DetailViewModel extends ViewModel {
public void settingPrivacy() {
context.startActivity(
new Intent(context, PrivacyActivity.class)
.putExtra("udn", device.get().getUDN()));
.putExtra("udn", device.get().getUdn()));
}
public void downloadPrivacyReport() {
......
package com.example.zxa01.iotclient.component.home;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.component.home.device.DeviceViewModel;
import com.example.zxa01.iotclient.databinding.ActivityHomeBinding;
import com.example.zxa01.iotclient.component.home.device.DeviceFragment;
import com.example.zxa01.iotclient.component.home.record.RecordFragment;
import com.example.zxa01.iotclient.component.home.setting.SettingFragment;
import android.content.Intent;
import android.net.Uri;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
......@@ -14,40 +17,33 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.databinding.DataBindingUtil;
public class HomeActivity extends AppCompatActivity implements
DeviceFragment.OnFragmentInteractionListener,
RecordFragment.OnFragmentInteractionListener,
SettingFragment.OnFragmentInteractionListener {
public class HomeActivity extends AppCompatActivity {
private ActivityHomeBinding binding;
private HomeViewModel viewModel;
/* fragments of HomeActivity */
private DeviceFragment mDeviceFragment = new DeviceFragment();
private RecordFragment mRecordFragment = new RecordFragment();
private SettingFragment mSettingFragment = new SettingFragment();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_home);
setupFragment(binding.navigation);
showFragment(mDeviceFragment);
binding();
init();
}
@Override
public void onDeviceFragment(Uri uri) {
private void binding() {
viewModel = new HomeViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
}
@Override
public void onPrivacyFragment(Uri uri) {
}
@Override
public void onSettingFragment(Uri uri) {
private void init() {
setupFragment(binding.navigation);
showFragment(mDeviceFragment);
}
/* onItemSelected of fragment */
private void setupFragment(BottomNavigationView view) {
view.setOnNavigationItemSelectedListener(
menuItem -> {
......@@ -67,10 +63,9 @@ public class HomeActivity extends AppCompatActivity implements
);
}
/* show of fragment */
private void showFragment(Fragment fragment) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.home_fragment_layout, fragment)
.replace(binding.homeFragmentLayout.getId(), fragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
}
......@@ -78,11 +73,12 @@ public class HomeActivity extends AppCompatActivity implements
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == RESULT_OK) {
// new DeviceViewModel().createDevice(intent.getStringExtra("SCAN_RESULT"));
new DeviceViewModel().createDevice(intent.getStringExtra("SCAN_RESULT"));
} else {
new AlertDialog.Builder(this)
.setMessage(R.string.create_qrcode_error)
.show();
}
}
}
package com.example.zxa01.iotclient.component.home;
import android.databinding.BaseObservable;
public class HomeModel extends BaseObservable {
public HomeModel() {
}
}
package com.example.zxa01.iotclient.component.home;
import android.arch.lifecycle.ViewModel;
import android.content.Context;
public class HomeViewModel extends ViewModel {
private Context context;
private HomeModel homeModel = new HomeModel();
public HomeViewModel(Context context) {
this.context = context;
}
}
......@@ -2,7 +2,6 @@ package com.example.zxa01.iotclient.component.home.device;
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.v4.app.FragmentTransaction;
......@@ -15,42 +14,33 @@ import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.databinding.FragmentDeviceBinding;
import com.example.zxa01.iotclient.component.home.device.create.DeviceCreateFragment;
public class DeviceFragment extends Fragment {
private FragmentDeviceBinding binding;
private DeviceViewModel viewModel;
private FragmentDeviceBinding binding;
public DeviceFragment() {
}
public static DeviceFragment newInstance() {
return new DeviceFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_device, container, false);
viewModel = new DeviceViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
binding.fab.setOnClickListener(item -> drawDialog());
binding.deviceRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
binding();
init();
return binding.getRoot();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
private void binding(){
viewModel = new DeviceViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
binding.fab.setOnClickListener(item -> drawDialog());
binding.deviceRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
}
private void init() {
viewModel.refreshDevices();
viewModel.readDevices();
viewModel.observeDevicesMLD().observe(this, viewModel::setAdapter);
}
......@@ -65,8 +55,4 @@ public class DeviceFragment extends Fragment {
}
public interface OnFragmentInteractionListener {
void onDeviceFragment(Uri uri);
}
}
......@@ -2,70 +2,62 @@ package com.example.zxa01.iotclient.component.home.device;
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 java.util.stream.Collectors;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class DeviceModel extends BaseObservable {
private List<Device> devices = new ArrayList<>();
private MutableLiveData<List<Device>> devicesMLD = new MutableLiveData<>();
// fake
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");
public DeviceModel() {
}
public void addDevice(Device device) {
devices.add(device);
}
public MutableLiveData<List<Device>> getDevicesMLD() {
return devicesMLD;
}
public void fetchDevices() {
Callback<Object> callback = new Callback<Object>() {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
// TODO transfer response
addDevice(oxygenDevice);
devicesMLD.setValue(devices);
}
@Override
public void onFailure(Call<Object> call, Throwable t) {
Log.e("fetchDevices - onFailure()", t.getMessage(), t);
}
};
Api.getApi().getDevices().enqueue(callback);
public void readDevices() {
Api.getApi().getDevices().enqueue(
new Callback<List<Device>>() {
@Override
public void onResponse(Call<List<Device>> call, Response<List<Device>> response) {
devicesMLD.setValue(response == null || response.body() == null ?
null : response.body().stream().collect(Collectors.toList()));
}
@Override
public void onFailure(Call<List<Device>> call, Throwable t) {
Log.e("readDevices - onFailure()", t.getMessage(), t);
}
}
);
}
public void createDevice(String address) {
public void createDevice(String udn) {
// TODO api post-createDevice & update
// Api.getApi().getDevices().enqueue(
//// new Callback<List<Device>>() {
//// @Override
//// public void onResponse(Call<List<Device>> call, Response<List<Device>> response) {
//// devicesMLD.setValue(response == null || response.body() == null ?
//// null : response.body().stream().collect(Collectors.toList()));
//// }
////
//// @Override
//// public void onFailure(Call<List<Device>> call, Throwable t) {
//// Log.e("readDevices - onFailure()", t.getMessage(), t);
//// }
//// }
//// );
}
}
......@@ -9,11 +9,13 @@ import android.arch.lifecycle.ViewModel;
import android.content.Context;
import android.content.Intent;
import android.databinding.ObservableBoolean;
import java.util.List;
public class DeviceViewModel extends ViewModel {
public ObservableBoolean isLoading = new ObservableBoolean(true);
private DeviceModel deviceModel = new DeviceModel();
private DeviceAdapter adapter = new DeviceAdapter(R.layout.recycler_view_device, this);
private Context context;
......@@ -22,12 +24,15 @@ public class DeviceViewModel extends ViewModel {
this.context = context;
}
public DeviceViewModel() {
}
/**
* model
*/
public void refreshDevices() {
deviceModel.fetchDevices();
public void readDevices() {
deviceModel.readDevices();
}
public MutableLiveData<List<Device>> observeDevicesMLD() {
......@@ -37,9 +42,10 @@ public class DeviceViewModel extends ViewModel {
/**
* create
*/
public void createDevice(String address) {
deviceModel.createDevice(address);
refreshDevices();
public void createDevice(String udn) {
deviceModel.createDevice(udn);
readDevices();
}
/**
......@@ -59,10 +65,9 @@ public class DeviceViewModel extends ViewModel {
if (deviceModel.getDevicesMLD().getValue() != null &&
index != null &&
deviceModel.getDevicesMLD().getValue().size() > index) {
// TODO detail of device
context.startActivity(
new Intent(context, DetailActivity.class)
.putExtra("index", index));
.putExtra("udn", deviceModel.getDevicesMLD().getValue().get(index).getUdn()));
}
}
......@@ -75,9 +80,8 @@ public class DeviceViewModel extends ViewModel {
}
public void setAdapter(List<Device> devices) {
this.isLoading.set(false);
this.adapter.setDevices(devices);
this.adapter.notifyDataSetChanged();
isLoading.set(false);
adapter.setDevices(devices);
}
}
......@@ -55,12 +55,16 @@ public class DeviceCreateFragment extends DialogFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_device_create, container, false);
viewModel = new DeviceViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
binding();
return binding.getRoot();
}
private void binding() {
viewModel = new DeviceViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
}
private void qrcodeIntent() {
try {
startActivityForResult(
......
......@@ -21,37 +21,20 @@ public class RecordFragment extends Fragment {
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()));
this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_record, container, false);
this.viewModel = new RecordViewModel(binding.getRoot().getContext());
this.binding.setViewModel(viewModel);
this.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.observePrivacyPolicyReportsMLD().observe(this, viewModel::setAdapter);
this.viewModel.refreshRecord();
this.viewModel.observePrivacyPolicyReportsMLD().observe(this, viewModel::setAdapter);
}
public interface OnFragmentInteractionListener {
void onPrivacyFragment(Uri uri);
}
}
......@@ -33,7 +33,7 @@ public class RecordModel extends BaseObservable {
private MutableLiveData<List<PrivacyPolicyReport>> privacyPolicyReportsMLD = new MutableLiveData<>();
private Device oxygenDevice = new Device()
.setUDN("a1252c49-4188-4e6d-a32e-66604c664fb8")
.setUdn("a1252c49-4188-4e6d-a32e-66604c664fb8")
.setName("指尖式血氧機")
.setType(Device.Type.Sensor)
.setManufacturer(new Manufacturer()
......
......@@ -68,9 +68,8 @@ public class RecordViewModel extends ViewModel {
}
public void setAdapter(List<PrivacyPolicyReport> privacyPolicyReports) {
this.isLoading.set(false);
this.adapter.setPrivacyPolicyReports(privacyPolicyReports);
this.adapter.notifyDataSetChanged();
isLoading.set(false);
adapter.setPrivacyPolicyReports(privacyPolicyReports);
}
}
......@@ -9,6 +9,7 @@ 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.FragmentSettingBinding;
......@@ -21,37 +22,24 @@ public class SettingFragment extends Fragment {
public SettingFragment() {
}
public static SettingFragment newInstance(String param1, String param2) {
return new SettingFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_setting, container, false);
viewModel = new SettingViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
binding.settingRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
binding();
init();
return binding.getRoot();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
private void binding() {
viewModel = new SettingViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
binding.settingRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
}
private void init() {
viewModel.refreshSetting();
viewModel.observeSettingMLD().observe(this,viewModel::setAdapter);
viewModel.observeSettingMLD().observe(this, viewModel::setAdapter);
}
public interface OnFragmentInteractionListener {
void onSettingFragment(Uri uri);
}
}
......@@ -3,10 +3,13 @@ package com.example.zxa01.iotclient.component.home.setting;
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.Setting;
import com.example.zxa01.iotclient.common.shared.Config;
import com.example.zxa01.iotclient.component.login.LoginActivity;
import java.util.List;
......@@ -35,7 +38,6 @@ public class SettingViewModel extends ViewModel {
}
/**
* child model
*/
......@@ -53,7 +55,11 @@ public class SettingViewModel extends ViewModel {
if (settingModel.getSettingMLD().getValue() != null &&
index != null &&
settingModel.getSettingMLD().getValue().size() > index) {
// TODO setting alert
if(settingModel.getSettingMLD().getValue().get(index).getKey().equals(Config.LOGOUT)){
Config.getConfig().reset();
context.startActivity(
new Intent(context, LoginActivity.class));
}
}
}
......@@ -66,8 +72,7 @@ public class SettingViewModel extends ViewModel {
}
public void setAdapter(List<Setting> settings) {
this.isLoading.set(false);
this.adapter.setSettings(settings);
this.adapter.notifyDataSetChanged();
isLoading.set(false);
adapter.setSettings(settings);
}
}
package com.example.zxa01.iotclient.component.login;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.databinding.ActivityLoginBinding;
......@@ -14,27 +15,32 @@ public class LoginActivity extends AppCompatActivity {
private ActivityLoginBinding binding;
private LoginViewModel viewModel;
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
View view = activity.getCurrentFocus();
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_login);
binding();
init();
}
private void binding() {
viewModel = new LoginViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
binding.linearLoginForm.setOnClickListener(view -> hideKeyboard(LoginActivity.this));
init();
}
private void init() {
viewModel.isAuthorized().observe(this,viewModel::checkAuthorized);
viewModel.isAuthorized().observe(this, viewModel::checkAuthorized);
}
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
View view = activity.getCurrentFocus();
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
package com.example.zxa01.iotclient.component.login;
import com.example.zxa01.iotclient.common.http.Api;
import com.example.zxa01.iotclient.common.pojo.Setting;
import com.example.zxa01.iotclient.common.pojo.auth.User;
import com.example.zxa01.iotclient.common.shared.Config;
import com.example.zxa01.iotclient.component.login.pojo.LoginMessage;
import android.arch.lifecycle.MutableLiveData;
import android.databinding.BaseObservable;
import android.support.annotation.NonNull;
......@@ -10,32 +13,22 @@ import android.support.annotation.NonNull;
public class LoginModel extends BaseObservable {
private MutableLiveData<Boolean> isAuthorized;
private static String USER = "使用者";
private static String GATEWAY = "閘道器位置";
private static String Port = "Port";
private static String LOGOUT = "登出";
private static String LOGOUT_MESSAGE = "登出本帳號";
public LoginModel() {
isAuthorized = new MutableLiveData<>();
isAuthorized.setValue(false);
}
public MutableLiveData<Boolean> isAuthorized(){
public MutableLiveData<Boolean> isAuthorized() {
return isAuthorized;
}
public void login(@NonNull LoginMessage message) {
Config.getConfig().setUser(new User().setAccount(message.getAccount()));
Config.getConfig().setGateway(message.getGateway());
Config.getConfig().addSetting(new Setting(USER,Config.getConfig().getUser().getAccount()));
Config.getConfig().addSetting(new Setting(GATEWAY,message.getGateway()));
Config.getConfig().addSetting(new Setting(Port,message.getGateway()));
Config.getConfig().addSetting(new Setting(LOGOUT,LOGOUT_MESSAGE));
isAuthorized.setValue(true);
if (verification(message)) {
settingConfig(message);
isAuthorized.setValue(true);
// Callback<Object> callback = new Callback<Object>() {
// @Override
// public void onResponse(Call<Object> call, Response<Object> response) {
......@@ -51,11 +44,23 @@ public class LoginModel extends BaseObservable {
//
// // TODO loginMessage to json
// Api.getApi().getDevices().enqueue(callback);
}
}
public void vaild() {
//TODO 驗證帳號格式
private boolean verification(@NonNull LoginMessage message) {
return message.getAccount() != null &&
message.getPassword() != null &&
message.getGateway() != null;
}
private void settingConfig(@NonNull LoginMessage message) {
Config.getConfig().setUser(new User().setAccount(message.getAccount()));
Config.getConfig().setGateway(message.getGateway());
Config.getConfig().addSetting(new Setting(Config.USER, Config.getConfig().getUser().getAccount()));
Config.getConfig().addSetting(new Setting(Config.GATEWAY, message.getGateway()));
Config.getConfig().addSetting(new Setting(Config.LOGOUT, Config.LOGOUT_MESSAGE));
}
}
......@@ -15,8 +15,8 @@ public class LoginViewModel extends ViewModel {
private LoginModel loginModel = new LoginModel();
public LoginViewModel(Context context) {
loginMessage.set(new LoginMessage());
this.context = context;
loginMessage.set(new LoginMessage("192.168.2.69:8081","user","1234"));
}
public void login() {
......
package com.example.zxa01.iotclient.component.privacy;
import android.databinding.DataBindingUtil;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PictureDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
......@@ -17,15 +19,19 @@ public class PrivacyActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_privacy);
binding();
init();
}
private void binding() {
viewModel = new PrivacyViewModel(binding.getRoot().getContext());
binding.setViewModel(viewModel);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
init();
}
private void init() {
viewModel.fetchPrivacyPolicyReport();
viewModel.fetchPrivacyPolicyReportByDevice(getIntent().getStringExtra("udn"));
viewModel.observePrivacyPolicyReportMLD().observe(this, viewModel::setPrivacyPolicyReport);
viewModel.observeIsLoadingMLD().observe(this, viewModel::setIsUpload);
}
......@@ -38,5 +44,4 @@ public class PrivacyActivity extends AppCompatActivity {
return super.onOptionsItemSelected(item);
}
}
......@@ -2,22 +2,13 @@ package com.example.zxa01.iotclient.component.privacy;
import android.arch.lifecycle.MutableLiveData;
import android.databinding.BaseObservable;
import android.os.Handler;
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.PrivacyChoice;
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.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 retrofit2.Call;
import retrofit2.Callback;
......@@ -25,90 +16,11 @@ import retrofit2.Response;
public class PrivacyModel extends BaseObservable {
private MutableLiveData<Boolean> isUploadMLD;
private MutableLiveData<PrivacyPolicyReport> privacyPolicyReportMLD;
// fake p3p
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)));
private MutableLiveData<Boolean> isUploadMLD = new MutableLiveData<>();
private MutableLiveData<PrivacyPolicyReport> privacyPolicyReportMLD = new MutableLiveData<>();
public PrivacyModel() {
privacyPolicyReportMLD = new MutableLiveData<>();
privacyPolicyReportMLD.setValue(new PrivacyPolicyReport());
isUploadMLD = new MutableLiveData<>();
isUploadMLD.setValue(false);
}
......@@ -116,44 +28,40 @@ public class PrivacyModel extends BaseObservable {
return privacyPolicyReportMLD;
}
public void fetchPrivacyPolicyReport() {
Callback<Object> callback = new Callback<Object>() {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
// TODO transfer response
privacyPolicyReportMLD.setValue(oxygenPrivacyPolicyReport);
}
@Override
public void onFailure(Call<Object> call, Throwable t) {
Log.e("fetchPrivacyPolicyReport - onFailure()", t.getMessage(), t);
}
};
Api.getApi().getPrivacyPolicyReport().enqueue(callback);
}
public MutableLiveData<Boolean> getIsUploadMLD() {
return isUploadMLD;
}
public void updatePrivacyPolicyChoice(String privacyId, boolean consent) {
isUploadMLD.setValue(true);
Callback<Object> callback = new Callback<Object>() {
public void readPrivacyPolicyReportByDevice(String udn) {
Api.getApi().readPrivacyPolicyReportByDevice(udn).enqueue(new Callback<PrivacyPolicyReport>() {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
// TODO transfer response
isUploadMLD.setValue(false);
public void onResponse(Call<PrivacyPolicyReport> call, Response<PrivacyPolicyReport> response) {
privacyPolicyReportMLD.setValue(response.body());
}
@Override
public void onFailure(Call<Object> call, Throwable t) {
Log.e("updatePrivacyPolicyChoice - onFailure()", t.getMessage(), t);
public void onFailure(Call<PrivacyPolicyReport> call, Throwable t) {
Log.e("readPrivacyPolicyReportByDevice - onFailure()", t.getMessage(), t);
}
};
});
}
Api.getApi().updatePrivacyPolicyChoice().enqueue(callback);
public void setPrivacyChoice(PrivacyContent privacyContent, boolean isAccepted) {
isUploadMLD.setValue(true);
Api.getApi().setPrivacyChoice(
new PrivacyChoice().setPrivacyContent(privacyContent).setAccepted(isAccepted)).enqueue(
new Callback<PrivacyChoice>() {
@Override
public void onResponse(Call<PrivacyChoice> call, Response<PrivacyChoice> response) {
new Handler().postDelayed(() -> isUploadMLD.setValue(false), 500);
}
@Override
public void onFailure(Call<PrivacyChoice> call, Throwable t) {
Log.e("setPrivacyChoice - onFailure()", t.getMessage(), t);
}
});
}
}
package com.example.zxa01.iotclient.component.privacy;
import com.example.zxa01.iotclient.R;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyContent;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicy;
import com.example.zxa01.iotclient.common.pojo.privacy.PrivacyPolicyReport;
import com.example.zxa01.iotclient.common.shared.Config;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
......@@ -12,13 +14,15 @@ import android.databinding.ObservableField;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Switch;
import java.util.List;
public class PrivacyViewModel extends ViewModel {
public ObservableBoolean isLoading = new ObservableBoolean(true);
public ObservableBoolean isUpload = new ObservableBoolean(true);
public ObservableField<PrivacyPolicyReport> privacyPolicyReport = new ObservableField<>(new PrivacyPolicyReport());
public ObservableField<PrivacyPolicyReport> privacyPolicyReport = new ObservableField<>();
private PrivacyModel privacyModel = new PrivacyModel();
private PrivacyAdapter adapter = new PrivacyAdapter(R.layout.recycler_view_privacy, this);
private Context context;
......@@ -26,15 +30,15 @@ public class PrivacyViewModel extends ViewModel {
public PrivacyViewModel(Context context) {
this.context = context;
this.drawDialog();
drawDialog();
}
/**
* model
*/
public void fetchPrivacyPolicyReport() {
privacyModel.fetchPrivacyPolicyReport();
public void fetchPrivacyPolicyReportByDevice(String udn) {
privacyModel.readPrivacyPolicyReportByDevice(udn);
}
public MutableLiveData<PrivacyPolicyReport> observePrivacyPolicyReportMLD() {
......@@ -42,17 +46,12 @@ public class PrivacyViewModel extends ViewModel {
}
public void setPrivacyPolicyReport(PrivacyPolicyReport privacyPolicyReport) {
if (privacyPolicyReport.getId() != null) {
this.isLoading.set(false);
if (privacyPolicyReport != null && privacyPolicyReport.getId() != null) {
this.privacyPolicyReport.set(privacyPolicyReport);
this.setAdapter(privacyPolicyReport.getPolicies());
setAdapter(privacyPolicyReport.getPolicies());
}
}
public void updateP3P() {
// TODO accpet privacy
}
/**
* child model
*/
......@@ -66,13 +65,15 @@ public class PrivacyViewModel extends ViewModel {
return null;
}
public void onChangeClick(Integer index, View view) {
public void onSetPrivacyChoice(Integer index, View view) {
if (privacyModel.getPrivacyPolicyReportMLD().getValue() != null &&
index != null &&
privacyModel.getPrivacyPolicyReportMLD().getValue().getPolicies().size() > index) {
// TODO change pp
privacyModel.updatePrivacyPolicyChoice(
privacyModel.getPrivacyPolicyReportMLD().getValue().getPolicies().get(index).getId(),
privacyModel.setPrivacyChoice(
new PrivacyContent()
.setUser(Config.getConfig().getUser())
.setDevice(privacyModel.getPrivacyPolicyReportMLD().getValue().getDevice())
.setPolicy(privacyModel.getPrivacyPolicyReportMLD().getValue().getPolicies().get(index)),
((Switch) view).isChecked());
}
}
......@@ -107,8 +108,8 @@ public class PrivacyViewModel extends ViewModel {
}
public void setAdapter(List<PrivacyPolicy> privacyPolicies) {
isLoading.set(false);
adapter.setPrivacyPolicyList(privacyPolicies);
adapter.notifyDataSetChanged();
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/colorPrimaryDark"
android:endColor="@color/colorAccent"
android:angle="180"/>
</shape>
\ No newline at end of file
......@@ -128,7 +128,7 @@
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_lg"
android:padding="@dimen/padding_sm"
android:text="@{viewModel.device.UDN}"
android:text="@{viewModel.device.udn}"
android:textSize="@dimen/font" />
</LinearLayout>
......@@ -335,7 +335,6 @@
android:text="@{viewModel.device.model.name}"
android:textSize="@dimen/font" />
</LinearLayout>
</TableRow>
......@@ -478,6 +477,7 @@
</TableLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
</layout>
\ No newline at end of file
......@@ -3,6 +3,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="com.example.zxa01.iotclient.component.home.HomeViewModel" />
</data>
<android.support.constraint.ConstraintLayout
android:id="@+id/container"
android:layout_width="match_parent"
......
......@@ -54,7 +54,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/title_privacy"
android:textColor="@color/colorAccent"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/font_lg" />
<TextView
......@@ -92,6 +92,8 @@
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="@dimen/padding"
android:layout_marginLeft="@dimen/margin_sm"
android:layout_marginRight="@dimen/margin_sm"
app:setAdapter="@{viewModel.getAdapter()}"
tools:listitem="@layout/recycler_view_privacy" />
......
......@@ -23,6 +23,8 @@
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="@dimen/padding"
android:layout_marginRight="@dimen/margin_sm"
android:layout_marginLeft="@dimen/margin_sm"
app:setAdapter="@{viewModel.getAdapter()}"
tools:listitem="@layout/recycler_view_device" />
......
......@@ -53,7 +53,7 @@
android:layout_width="285dp"
android:layout_height="20dp"
android:layout_marginStart="16dp"
android:text="@{viewModel.getDeviceAt(position).UDN}"
android:text="@{viewModel.getDeviceAt(position).udn}"
app:layout_constraintBottom_toBottomOf="@+id/image_device"
app:layout_constraintStart_toEndOf="@+id/image_device"
tools:text="subtitle" />
......@@ -64,6 +64,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:textSize="12sp"
android:text="@{viewModel.getDeviceAt(position).status.toString()}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/image_device"
tools:text="connection" />
......
......@@ -24,41 +24,33 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/padding_sm"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewTitle"
android:layout_width="match_parent"
android:id="@+id/textViewPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/title_privacy"
android:textColor="@color/colorAccent"
android:textSize="@dimen/font_lg" />
android:text='@{@string/privacy_title+" "+String.valueOf(position+1)}'
android:textColor="@color/colorPrimary"
android:textSize="@dimen/font" />
<LinearLayout
android:layout_width="match_parent"
<Switch
android:id="@+id/switch1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{@string/privacy_title+" "+String.valueOf(position+1)}'
android:textColor="@color/colorGray"
android:textSize="@dimen/font" />
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{(view)->viewModel.onChangeClick(position,view)}"
android:text="@string/privacy_content"
android:textAlignment="textEnd"
android:thumbTextPadding="@dimen/padding_lg" />
android:layout_weight="1"
android:onClick="@{(view)->viewModel.onSetPrivacyChoice(position,view)}"
android:text="@string/privacy_content"
android:textAlignment="textEnd"
android:thumbTextPadding="@dimen/padding_lg" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textView7"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#1da1f2</color>
<color name="colorPrimaryDark">#0D92E1</color>
<color name="colorPrimary">#1D76D2</color>
<color name="colorPrimaryDark">#1666BF</color>
<color name="colorAccent">#2A4474</color>
<color name="colorGray">#2d2d2d</color>
<color name="colorLight">#808080</color>
<color name="colorLighter">#dadada</color>
<color name="colorLighter">#E4E4E4</color>
<color name="colorLightest">#F4F4F4</color>
<color name="colorWhite">#FFFFFF</color>
<color name="colorTransparent">#00000000</color>
......
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