Browse Source

Refactored code.

pull/4/head
Mushegh Sahakyan 4 years ago
parent
commit
5557fcc6f4
3 changed files with 5 additions and 6 deletions
  1. +0
    -1
      ui/src/main/java/com/wireguard/android/activity/LoginActivity.java
  2. +1
    -1
      ui/src/main/java/com/wireguard/android/api/ApiConstants.java
  3. +4
    -4
      ui/src/main/java/com/wireguard/android/repository/DataRepository.java

+ 0
- 1
ui/src/main/java/com/wireguard/android/activity/LoginActivity.java View File

@@ -82,7 +82,6 @@ public class LoginActivity extends AppCompatActivity {
}
}
});
// Toast.makeText(LoginActivity.this,"Success",Toast.LENGTH_SHORT).show();
Log.d("TAG","Success");
break;
case LOADING:


+ 1
- 1
ui/src/main/java/com/wireguard/android/api/ApiConstants.java View File

@@ -7,7 +7,7 @@ public class ApiConstants {
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";
public static final String AUTHORIZATION_HEADER = "X-Bubble-Session";
public static final String DEVICE_NAME = "name";
public static final String DEVICE_TYPE = "deviceType";
}

+ 4
- 4
ui/src/main/java/com/wireguard/android/repository/DataRepository.java View File

@@ -80,7 +80,7 @@ public class DataRepository {
@Override protected void createCall() {
final String token = UserStore.getInstance(context).getToken();
final HashMap<String,String> header = new HashMap<>();
header.put(ApiConstants.HEADER,token);
header.put(ApiConstants.AUTHORIZATION_HEADER,token);
clientApi.getAllDevices(header).enqueue(new Callback<List<Device>>() {
@Override public void onResponse(final Call<List<Device>> call, final Response<List<Device>> response) {
if (response.isSuccessful()) {
@@ -107,11 +107,11 @@ public class DataRepository {
@Override protected void createCall() {
final String brand = getBrand();
final String model = getDeviceModel();
final String imei = getDeviceIMEI(context);
final String imei = getDeviceID(context);
final String deviceName = brand + " " + model + " " + ":" + " " + imei;
final String token = UserStore.getInstance(context).getToken();
final HashMap<String,String> header = new HashMap<>();
header.put(ApiConstants.HEADER,token);
header.put(ApiConstants.AUTHORIZATION_HEADER,token);
clientApi.getAllDevices(header).enqueue(new Callback<List<Device>>() {
@Override public void onResponse(final Call<List<Device>> call, final Response<List<Device>> response) {
if (response.isSuccessful()) {
@@ -246,7 +246,7 @@ public class DataRepository {
return Character.isUpperCase(first) ? brand : Character.toUpperCase(first) + brand.substring(1);
}

private String getDeviceIMEI(final Context context) {
private String getDeviceID(final Context context) {
return Settings.Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
}



Loading…
Cancel
Save