#4 implement_add_device_functionality

Fusionado
gegham fusionados 17 commits de implement_add_device_functionality en dev hace 4 años
Aún no existe contenido.
gegham fue asignado por musheghsahakyan98 hace 4 años
gegham cambios solicitados hace 4 años
@@ -66,0 +70,4 @@
switch (deviceStatusResource.status){
case SUCCESS:
Toast.makeText(LoginActivity.this,"Success",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(LoginActivity.this,MainActivity.class);
gegham comentado hace 4 años

No need to open the MainActivity yet. Most probably we will still need to get the VPN.conf before going to the main activity.

No need to open the MainActivity yet. Most probably we will still need to get the VPN.conf before going to the main activity.
@@ -66,0 +75,4 @@
startActivity(intent);
Log.d("TAG","Success");
break;
case LOADING:
gegham comentado hace 4 años

We need to have loaders showing during the API calls. Use the same approach as in mytello, with blocking user actions on the screen during the loader showing.

We need to have loaders showing during the API calls. Use the same approach as in mytello, with blocking user actions on the screen during the loader showing.
@@ -66,0 +85,4 @@
}
}
});
// Toast.makeText(LoginActivity.this,"Success",Toast.LENGTH_SHORT).show();
gegham comentado hace 4 años

Remove this line.

Remove this line.
@@ -6,2 +7,4 @@
public static final String ADD_DEVICE_URL = "me/devices";
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
public static final String HEADER = "X-Bubble-Session";
gegham comentado hace 4 años

Change the name of this property to reflect which exact header it is.

Change the name of this property to reflect which exact header it is.
@@ -86,0 +246,4 @@
return Character.isUpperCase(first) ? brand : Character.toUpperCase(first) + brand.substring(1);
}

private String getDeviceIMEI(final Context context) {
gegham comentado hace 4 años

Rename, tp reflect the method correctly.

Rename, tp reflect the method correctly.
gegham cambios solicitados hace 4 años
@@ -71,6 +75,151 @@ public class DataRepository {
}.getMutableLiveData();
}

public MutableLiveData<StatusResource<Device>> getAllDevices(Context context) {
gegham comentado hace 4 años

There should be 3 methods for devices:
getAllDevices(): we already have this. It should fetch all the devices from the API.
addDevice(): This method should add a new device to API. It should not deal with anything but adding a device.
getDevice(): This should be the method called from the LoginActivity. It should:
1. Check if there is an existing device in shared prefs, then just return it.
2. If there is no device, then make the getAllDevices call, and then the addDevice call, with the logic that we already have.

So the Login activity and it’s ViewModel shouldn’t be aware if the device was created or it already existed.

There should be 3 methods for devices: getAllDevices(): we already have this. It should fetch all the devices from the API. addDevice(): This method should add a new device to API. It should not deal with anything but adding a device. getDevice(): This should be the method called from the LoginActivity. It should: 1. Check if there is an existing device in shared prefs, then just return it. 2. If there is no device, then make the getAllDevices call, and then the addDevice call, with the logic that we already have. So the Login activity and it's ViewModel shouldn't be aware if the device was created or it already existed.
gegham cambios solicitados hace 4 años
@@ -71,6 +75,154 @@ public class DataRepository {
}.getMutableLiveData();
}

gegham comentado hace 4 años

login() -> isDeviceLoggedIn() -> getAllDevices ->
-> getVPNConf()
-> addDevice() -> getVPNConf()
-> createTunnel() -> SUCCESS -> LoginActivity -> MainActivity

login() -> isDeviceLoggedIn() -> getAllDevices -> -> getVPNConf() -> addDevice() -> getVPNConf() -> createTunnel() -> SUCCESS -> LoginActivity -> MainActivity
gegham cambios solicitados hace 4 años
@@ -73,3 +73,3 @@
</intent-filter>
</activity>
<activity android:name=".activity.BaseActivityBubble" />
gegham comentado hace 4 años

Do we need to have the BaseActivity in Manifest?

Do we need to have the BaseActivity in Manifest?
@@ -0,0 +32,4 @@
final Dialog dialog = new Dialog(getActivity(), getTheme()) {
@Override
public void onBackPressed() {
if (getActivity().getSupportFragmentManager().findFragmentByTag(LoginActivity.LOADING_TAG) != null) {
gegham comentado hace 4 años

Why is the LoginActivity.LOADING_TAG used here?

Why is the LoginActivity.LOADING_TAG used here?
@@ -74,0 +128,4 @@
final String brand = getBrand();
final String model = getDeviceModel();
final String imei = getDeviceID(context);
final String deviceName = brand + " " + model + " " + ":" + " " + imei;
gegham comentado hace 4 años

Put all the hardcoded strings in constants: " “, " : "

Put all the hardcoded strings in constants: " ", " : "
@@ -74,0 +138,4 @@
String brandModel = brand + " " + model + " ";
final List<Device> list = response.body();
final List<String> arrayListDevicesName = new ArrayList<>();
boolean flag = true;
gegham comentado hace 4 años

Rename the boolean

Rename the boolean
@@ -74,0 +142,4 @@
for (final Device device : list) {
final String[] deviceNameItem = device.getName().split(":");
final String[] myDeviceName = deviceName.split(":");
if(deviceNameItem.length>1){
gegham comentado hace 4 años

Check only the IMEI ( Android ID ) with equals

Check only the IMEI ( Android ID ) with equals
@@ -74,0 +143,4 @@
final String[] deviceNameItem = device.getName().split(":");
final String[] myDeviceName = deviceName.split(":");
if(deviceNameItem.length>1){
if(deviceNameItem[0].contains(myDeviceName[0]) && deviceNameItem[1].contains(myDeviceName[1])){
gegham comentado hace 4 años

Change magic numbers to constants

Change magic numbers to constants
@@ -74,0 +247,4 @@
}.getMutableLiveData();
}

private MutableLiveData<List<Device>> getAllDevices(Context context){
gegham comentado hace 4 años

Do we need LIveData here?

Do we need LIveData here?
gegham cambios solicitados hace 4 años
@@ -66,0 +83,4 @@
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listDevices->{
boolean flag = true;
gegham comentado hace 4 años

Rename the flag boolean

Rename the flag boolean
@@ -66,0 +115,4 @@
String brandModel = brand + SPACE + model + SPACE;
final List<Device> list = listDevices;
final List<String> arrayListDevicesName = new ArrayList<>();
boolean isHaveDevice = false;
gegham comentado hace 4 años

Rename isHaveDevice to hasDevice

Rename isHaveDevice to hasDevice
@@ -66,0 +142,4 @@
brandModel = deviceName;
final HashMap<String, String> body = new HashMap<>();
body.put(ApiConstants.DEVICE_NAME, brandModel);
body.put(ApiConstants.DEVICE_TYPE, "android");
gegham comentado hace 4 años

Rename disposable2 and disposable properties accordingly

Rename disposable2 and disposable properties accordingly
gegham aprobado estos cambios hace 4 años
gegham cerró este pull request hace 4 años
gegham rama eliminada implement_add_device_functionality hace 4 años

Revisores

gegham aprobado estos cambios hace 4 años
El Pull Request se ha fusionado como 7dd33ca862.
Inicie sesión para unirse a esta conversación.
No hay revisores
Sin etiquetas
Sin Milestone
No asignados
2 participantes
Notificaciones
Fecha de vencimiento

Sin fecha de vencimiento.

Dependencias

Este pull request actualmente no tiene ninguna dependencia.

Cargando…
Aún no existe contenido.