Changes in login api call
parent
451fd5539a
commit
4e12391a04
|
@ -26,6 +26,10 @@ android {
|
|||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -117,11 +117,11 @@ public class HomeActivity extends AppCompatActivity implements SelectListener {
|
|||
if (item.length > 0) {
|
||||
boolean keyExists = Preference.containsKey(Helper.project_file, "CurrentPosition", this);
|
||||
if (keyExists) {
|
||||
Log.e("Key-Exist: ", "True");
|
||||
//Log.e("Key-Exist: ", "True");
|
||||
currentPositionStatus = Preference.getMyIntPref(Helper.project_file, "CurrentPosition", this);
|
||||
autoCompleteTextView.setText(item[currentPositionStatus], false);
|
||||
} else {
|
||||
Log.e("Key-Exist: ", "False");
|
||||
//Log.e("Key-Exist: ", "False");
|
||||
autoCompleteTextView.setText(item[0], false);
|
||||
}
|
||||
}
|
||||
|
@ -285,12 +285,12 @@ public class HomeActivity extends AppCompatActivity implements SelectListener {
|
|||
if (item.length > 0) {
|
||||
boolean keyExists = Preference.containsKey(Helper.project_file, "CurrentPosition", this);
|
||||
if (keyExists) {
|
||||
Log.e("Key-Exist: ", "True");
|
||||
//Log.e("Key-Exist: ", "True");
|
||||
currentPositionStatus = Preference.getMyIntPref(Helper.project_file, "CurrentPosition", this);
|
||||
autoCompleteTextView.setText(item[currentPositionStatus], false);
|
||||
filterList(item[currentPositionStatus]);
|
||||
} else {
|
||||
Log.e("Key-Exist: ", "False");
|
||||
//Log.e("Key-Exist: ", "False");
|
||||
autoCompleteTextView.setText(item[0], false);
|
||||
filterList(item[currentPositionStatus]);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public interface ApiService {
|
|||
@Query("username") String username
|
||||
);
|
||||
|
||||
@GET("rest/application/authenticate-user")
|
||||
@POST("rest/application/authenticate-user")
|
||||
Call<DriverResponse> isUserAuthenticated(
|
||||
@Body LoginRequest request
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.utopiaindustries.selftrucking.Activities.loginScreens;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
@ -63,8 +64,11 @@ public class LoginActivity extends AppCompatActivity {
|
|||
btnLogin = findViewById(R.id.btn_login);
|
||||
apiService = ApiServiceFactory.getApiService();
|
||||
|
||||
tfEmail.setText("muhammad.mujtaba");
|
||||
tfPassword.setText("Utopia01");
|
||||
/*tfEmail.setText("muhammad.mujtaba");
|
||||
tfPassword.setText("Utopia01");*/
|
||||
|
||||
tfEmail.setText("anthony.pearlmen");
|
||||
//tfPassword.setText("%cw5R"5YmD");
|
||||
|
||||
loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
|
||||
|
||||
|
|
|
@ -43,17 +43,19 @@ public class LoginViewModel extends ViewModel {
|
|||
}
|
||||
|
||||
public void authenticateUser(LoginRequest loginRequest) {
|
||||
//Log.e("LoginRequest: ",""+loginRequest);
|
||||
isLoading.setValue(true);
|
||||
apiService.isUserAuthenticated(loginRequest).enqueue(new Callback<DriverResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<DriverResponse> call, Response<DriverResponse> response) {
|
||||
isLoading.setValue(false);
|
||||
//Log.e("Response: ",""+response);
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
userLiveData.setValue(response.body());
|
||||
Log.e("Success-1","");
|
||||
//Log.e("Success-1",""+response.body());
|
||||
} else {
|
||||
errorLiveData.setValue(response.message());
|
||||
Log.e("Else-2","****");
|
||||
//Log.e("Else-2","****"+response.message());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +63,7 @@ public class LoginViewModel extends ViewModel {
|
|||
public void onFailure(Call<DriverResponse> call, Throwable t) {
|
||||
isLoading.setValue(false);
|
||||
errorLiveData.setValue(t.getMessage());
|
||||
Log.e("onFailure","****");
|
||||
//Log.e("onFailure","****"+t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class Helper {
|
|||
String json = appSharedPrefs.getString(key, "");
|
||||
Gson gson = new Gson();
|
||||
DriverResponse selectedUser = gson.fromJson(json, DriverResponse.class);
|
||||
return selectedUser;
|
||||
return selectedUser;
|
||||
}
|
||||
|
||||
public static boolean isNetworkConnected(Context context) {
|
||||
|
@ -46,4 +46,9 @@ public class Helper {
|
|||
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
public static String escapeDoubleQuotes(String input) {
|
||||
if (input == null) return null;
|
||||
return input.replace("\"", "\\\""); // Add a backslash before the double quote
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.utopiaindustries.selftrucking.helper;
|
||||
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class SSLCheckHttpClient {
|
||||
public static OkHttpClient getOkHttpClient() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Install the all-trusting trust manager
|
||||
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
|
||||
// Create an ssl socket factory with our all-trusting manager
|
||||
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
|
||||
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0])
|
||||
.hostnameVerifier((hostname, session) -> true)
|
||||
.connectTimeout(40, TimeUnit.SECONDS)
|
||||
.readTimeout(40, TimeUnit.SECONDS)
|
||||
.writeTimeout(40, TimeUnit.SECONDS)
|
||||
.build();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue