update encoding
This commit is contained in:
parent
48a6c430aa
commit
74fea999e5
|
@ -13,6 +13,9 @@ import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
import com.example.monnthic.monnethicmobile.R;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import monnethic.mobile.database.User;
|
import monnethic.mobile.database.User;
|
||||||
import monnethic.mobile.restApi.UserApiHandler;
|
import monnethic.mobile.restApi.UserApiHandler;
|
||||||
import monnethic.mobile.wallet.HomeWalletActivity;
|
import monnethic.mobile.wallet.HomeWalletActivity;
|
||||||
|
@ -66,6 +69,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
//AsyncTask for login
|
//AsyncTask for login
|
||||||
private class UserLoggerTask extends AsyncTask<User,String,JSONObject> {
|
private class UserLoggerTask extends AsyncTask<User,String,JSONObject> {
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
ProgressDialog progDailog = new ProgressDialog(LoginActivity.this);
|
||||||
private UserLoggerTask(final Context context){
|
private UserLoggerTask(final Context context){
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +77,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
ProgressDialog progDailog = new ProgressDialog(LoginActivity.this);
|
|
||||||
progDailog.setMessage("Login...");
|
progDailog.setMessage("Login...");
|
||||||
progDailog.setIndeterminate(false);
|
progDailog.setIndeterminate(false);
|
||||||
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||||
|
@ -99,9 +102,11 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(mContext, "AN ERROR OCCURED", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, "AN ERROR OCCURED", Toast.LENGTH_SHORT).show();
|
||||||
|
progDailog.dismiss();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Toast.makeText(mContext, "AN ERROR OCCURED", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, "AN ERROR OCCURED", Toast.LENGTH_SHORT).show();
|
||||||
|
progDailog.dismiss();
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -16,6 +16,8 @@ public class Config {
|
||||||
static private String getBaseUrlUser(){
|
static private String getBaseUrlUser(){
|
||||||
if(API==0){
|
if(API==0){
|
||||||
return "http://5.39.76.139:10053/api/rest/user/";
|
return "http://5.39.76.139:10053/api/rest/user/";
|
||||||
|
//return "http://10.0.2.2:10053/api/rest/user/";
|
||||||
|
//return "http://localhost:10053/api/rest/user/";
|
||||||
} else {
|
} else {
|
||||||
return "http://37.187.101.44:10053/api/rest/user/";
|
return "http://37.187.101.44:10053/api/rest/user/";
|
||||||
}
|
}
|
||||||
|
@ -23,6 +25,8 @@ public class Config {
|
||||||
static private String getBaseUrlTransaction(){
|
static private String getBaseUrlTransaction(){
|
||||||
if(API==0){
|
if(API==0){
|
||||||
return "http://5.39.76.139:10053/api/rest/transaction/";
|
return "http://5.39.76.139:10053/api/rest/transaction/";
|
||||||
|
//return "http://10.0.2.2:10053/api/rest/transaction/";
|
||||||
|
//return "http://localhost:10053/api/rest/transaction/";
|
||||||
} else {
|
} else {
|
||||||
return "http://37.187.101.44:10053/api/rest/transaction/";
|
return "http://37.187.101.44:10053/api/rest/transaction/";
|
||||||
}
|
}
|
||||||
|
@ -30,6 +34,8 @@ public class Config {
|
||||||
static private String getBaseUrlWallet(){
|
static private String getBaseUrlWallet(){
|
||||||
if(API==0){
|
if(API==0){
|
||||||
return "http://5.39.76.139:10053/api/rest/wallet/";
|
return "http://5.39.76.139:10053/api/rest/wallet/";
|
||||||
|
//return "http://10.0.2.2:10053/api/rest/wallet/";
|
||||||
|
//return "http://localhost:10053/api/rest/wallet/";
|
||||||
} else {
|
} else {
|
||||||
return "http://37.187.101.44:10053/api/rest/wallet/";
|
return "http://37.187.101.44:10053/api/rest/wallet/";
|
||||||
}
|
}
|
||||||
|
@ -37,6 +43,8 @@ public class Config {
|
||||||
static private String getBaseUrlSession(){
|
static private String getBaseUrlSession(){
|
||||||
if(API==0){
|
if(API==0){
|
||||||
return "http://5.39.76.139:10053/api/rest/session/";
|
return "http://5.39.76.139:10053/api/rest/session/";
|
||||||
|
//return "http://10.0.2.2:10053/api/rest/session/";
|
||||||
|
//return "http://localhost:10053/api/rest/session/";
|
||||||
} else {
|
} else {
|
||||||
return "http://37.187.101.44:10053/api/rest/session/";
|
return "http://37.187.101.44:10053/api/rest/session/";
|
||||||
}
|
}
|
||||||
|
@ -44,6 +52,8 @@ public class Config {
|
||||||
static private String getConfigBaseUrl(){
|
static private String getConfigBaseUrl(){
|
||||||
if(API==0){
|
if(API==0){
|
||||||
return "http://5.39.76.139:10053/api/rest/demo/conf";
|
return "http://5.39.76.139:10053/api/rest/demo/conf";
|
||||||
|
//return "http://10.0.2.2:10053/api/rest/demo/conf";
|
||||||
|
//return "http://localhost:10053/api/rest/demo/conf/";
|
||||||
} else {
|
} else {
|
||||||
return "http://37.187.101.44:10053/api/rest/demo/conf";
|
return "http://37.187.101.44:10053/api/rest/demo/conf";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
package monnethic.mobile.restApi;
|
package monnethic.mobile.restApi;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class HttpCallHandler {
|
public class HttpCallHandler {
|
||||||
|
@ -59,7 +64,7 @@ public class HttpCallHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
DataOutputStream os = new DataOutputStream(urlConnection.getOutputStream());
|
DataOutputStream os = new DataOutputStream(urlConnection.getOutputStream());
|
||||||
os.writeBytes(jsonParam.toString());
|
os.write(jsonParam.toString().getBytes("UTF-8"));
|
||||||
|
|
||||||
int statusCode = urlConnection.getResponseCode();
|
int statusCode = urlConnection.getResponseCode();
|
||||||
if(statusCode != 200){
|
if(statusCode != 200){
|
||||||
|
@ -105,7 +110,7 @@ public class HttpCallHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
DataOutputStream os = new DataOutputStream(urlConnection.getOutputStream());
|
DataOutputStream os = new DataOutputStream(urlConnection.getOutputStream());
|
||||||
os.writeBytes(jsonParam.toString());
|
os.write(jsonParam.toString().getBytes("UTF-8"));
|
||||||
urlConnection.getResponseCode();
|
urlConnection.getResponseCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package monnethic.mobile.restApi;
|
package monnethic.mobile.restApi;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -56,7 +58,6 @@ public class UserApiHandler {
|
||||||
if(jsonObject.getInt("status")!=200){
|
if(jsonObject.getInt("status")!=200){
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("OUT OUT OUT / "+jsonObject.toString());
|
|
||||||
u.setUser_hash(jsonObject.getString("user_hash"));
|
u.setUser_hash(jsonObject.getString("user_hash"));
|
||||||
JSONObject jsonReturn = new JSONObject();
|
JSONObject jsonReturn = new JSONObject();
|
||||||
jsonReturn.put("status",200);
|
jsonReturn.put("status",200);
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package monnethic.mobile.test.restAPI;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import monnethic.mobile.database.User;
|
||||||
|
import monnethic.mobile.restApi.UserApiHandler;
|
||||||
|
|
||||||
|
public class testLogin {
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
@Test
|
||||||
|
public void registerUser(){
|
||||||
|
String name = "Georges";
|
||||||
|
String firstname = "Patrick";
|
||||||
|
String phone = "0724812479";
|
||||||
|
String association = "gonette";
|
||||||
|
String email = "patrick.g@mail.com";
|
||||||
|
String password = "Gpatr014<*ù";
|
||||||
|
|
||||||
|
try{
|
||||||
|
User u = new User(name,firstname,email,password,phone,association);
|
||||||
|
|
||||||
|
UserApiHandler userApiHandler = new UserApiHandler();
|
||||||
|
JSONObject userReturn= userApiHandler.registerUser(u);
|
||||||
|
System.out.println(userReturn.toString());
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loginUser(){
|
||||||
|
String email = "patrick.g@mail.com";
|
||||||
|
String password = "Gpatr014<*ù";
|
||||||
|
|
||||||
|
try{
|
||||||
|
User u = new User(email,password);
|
||||||
|
|
||||||
|
UserApiHandler userApiHandler = new UserApiHandler();
|
||||||
|
JSONObject userReturn= userApiHandler.loginUser(u);
|
||||||
|
System.out.println(userReturn.toString());
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue