Commit 211878bc by Krishna Vemulawada

offline handle with voice

parents 9cb09194 964f4635
......@@ -72,7 +72,7 @@ android {
vportal {
applicationId "com.vsoft.vera.vportal"
versionCode 1
versionName "0.1.6"
versionName "0.1.7"
}
}
}
......
......@@ -156,6 +156,7 @@ public class CatalogueApplication extends MultiDexApplication {
options.upgrade = true;
mSocket = IO.socket(Constants.CHAT_SERVER_URL,options);
mSocket.io().timeout(-1);
mSocket.io().reconnection(true);
mSocket.io().reconnectionDelay(0);
......
......@@ -3,12 +3,14 @@ package com.vsoft.vera.ui;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
......@@ -18,6 +20,7 @@ import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
......@@ -69,6 +72,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.vsoft.vera.utils.Util.convertDpToPx;
public class ADALActivity extends AppCompatActivity {
......@@ -121,6 +126,7 @@ public class ADALActivity extends AppCompatActivity {
private static final boolean sTelemetryAggregationIsRequired = true;
private LinearLayout mainLayt;
private Handler mWaitHandler = new Handler();
/* Telemetry dispatcher registration */
static {
......@@ -169,10 +175,15 @@ public class ADALActivity extends AppCompatActivity {
callGraphButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (NetworkConnectivity.haveNetworkConnection(ADALActivity.this)) {
onCallGraphClicked();
mWaitHandler.postDelayed(new Runnable() {
@Override
public void run() {
updateSuccessUI();
}
}, 5000);
} else {
DialogUtils.showNoConnectionDialog(ADALActivity .this);
......@@ -185,10 +196,8 @@ public class ADALActivity extends AppCompatActivity {
login_with_otp.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// onSignOutClicked();
Intent intent = new Intent(ADALActivity.this,OtpValidationActivity.class);
startActivity(intent);
}
});
......@@ -284,13 +293,13 @@ public class ADALActivity extends AppCompatActivity {
private void callGraphAPI() {
Log.d(TAG, "Starting volley request to graph");
mProgressDlg = new ProgressDialog(ADALActivity.this);
mProgressDlg.setMessage(getString(R.string.loading_string));
mProgressDlg.show();
mProgressDlg.setCancelable(false);
Log.d(TAG, "Starting volley request to graph");
/* Make sure we have a token to send to graph */
if (mAuthResult.getAccessToken() == null) {return;}
......@@ -317,7 +326,6 @@ public class ADALActivity extends AppCompatActivity {
/*Send broadcast to start SyncService*/
if(!isLogin){
new LoginDetailsSendToServer().execute();
}
......@@ -325,7 +333,6 @@ public class ADALActivity extends AppCompatActivity {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
......@@ -378,19 +385,24 @@ public class ADALActivity extends AppCompatActivity {
// Called on success from /me endpoint
// Removed call Graph API button and paint Sign out
callGraphButton.setVisibility(View.GONE);
login_with_otp.setVisibility(View.GONE);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(convertDpToPx(this, 300),
convertDpToPx(this, 450));
layoutParams.setMargins(convertDpToPx(this, 30), convertDpToPx(this, 30), convertDpToPx(this, 30), convertDpToPx(this, 30));
logo_banner.setLayoutParams(layoutParams);
signOutButton.setVisibility(View.GONE);
findViewById(R.id.welcome).setVisibility(View.GONE);
((TextView) findViewById(R.id.welcome)).setText("Welcome, " +
mAuthResult.getUserInfo().getGivenName());
/*((TextView) findViewById(R.id.welcome)).setText("Welcome, " +
mAuthResult.getUserInfo().getGivenName());*/
findViewById(R.id.graphData).setVisibility(View.GONE);
}
@SuppressLint("SetTextI18n")
private void updateSignedOutUI() {
signOutButton.setVisibility(View.GONE);
findViewById(R.id.welcome).setVisibility(View.INVISIBLE);
findViewById(R.id.graphData).setVisibility(View.INVISIBLE);
......@@ -427,8 +439,6 @@ public class ADALActivity extends AppCompatActivity {
/* Successfully got a token, call graph now */
Log.d(TAG, "Successfully authenticated");
/* Store the mAuthResult */
mAuthResult = authenticationResult;
......@@ -440,7 +450,6 @@ public class ADALActivity extends AppCompatActivity {
@Override
public void run() {
updateSuccessUI();
}
});
}
......@@ -522,6 +531,7 @@ public class ADALActivity extends AppCompatActivity {
updateSuccessUI();
}
});
/* set the sIntSignInInvoked boolean back to false */
sIntSignInInvoked.set(false);
}
......@@ -714,5 +724,4 @@ public class ADALActivity extends AppCompatActivity {
}
}
}
}
......@@ -23,6 +23,7 @@ import android.os.PowerManager;
import android.provider.MediaStore;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import android.support.design.widget.Snackbar;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
......@@ -148,6 +149,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
String takePictureFilePath = "";
private Speaker speaker;
private Boolean isConnected = false;
private Boolean isConnectError = false;
private static final int NONE = -1;
private static final int VOICE_STATE = 1;
private static final int TYPING_STATE = 2;
......@@ -249,7 +251,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
mSocket.connect();
checkTTS();
speaker = new Speaker(this);
//speaker = new Speaker(this);
textDotLoader = findViewById(R.id.avi);
mMessagesView = (RecyclerView) findViewById(R.id.messages);
sendImageToserv = (ImageButton) findViewById(R.id.image_button);
......@@ -261,7 +263,6 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public void imageViewOnClick(String imagePath) {
shoawUserImagePopupImageAlert(imagePath);
}
@Override
......@@ -376,6 +377,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public void onClick(View v) {
if (NetworkConnectivity.haveNetworkConnection(ChatActivity.this)) {
Util.hideSoftKeyboard(ChatActivity.this, v);
mInputMessageView.setText("");
......@@ -388,6 +390,12 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
droidSpeech.startDroidSpeechRecognition();
CURRENT_STATE = VOICE_STATE;
} else {
DialogUtils.showNoConnectionDialog(ChatActivity.this);
}
// readAndWriteCallsData();
}
......@@ -664,6 +672,10 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
* This method calls when we will send message to server.
*/
private void attemptSend() {
if (NetworkConnectivity.haveNetworkConnection(ChatActivity.this)) {
String message = mInputMessageView.getText().toString().trim();
if (!TextUtils.isEmpty(message)){
if (null == mLoggedInUsername) return;
......@@ -711,6 +723,9 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
toastView.setBackgroundColor(Color.BLACK);
toast.show();
}
} else {
DialogUtils.showNoConnectionDialog(ChatActivity.this);
}
}
@Override
......@@ -777,8 +792,21 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public void run() {
isConnected = false;
Toast.makeText(getApplicationContext(),
R.string.disconnect, Toast.LENGTH_LONG).show();
isConnectError = false;
Snackbar snackbar = Snackbar
.make(mMessagesView, R.string.disconnect, Snackbar.LENGTH_LONG);
snackbar.show();
// Changing action button text color
View sbView = snackbar.getView();
TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.YELLOW);
snackbar.show();
/*Toast.makeText(getApplicationContext(),
R.string.disconnect, Toast.LENGTH_LONG).show();*/
}
});
}
......@@ -802,8 +830,8 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
private Emitter.Listener onReconnect = new Emitter.Listener() {
@Override
public void call(Object... args) {
Toast.makeText(getApplicationContext(),
"Reconnection Called", Toast.LENGTH_LONG).show();
/*Toast.makeText(getApplicationContext(),
"Reconnection Called", Toast.LENGTH_LONG).show();*/
//reconnect();
}
......@@ -818,18 +846,42 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
runOnUiThread(new Runnable() {
@Override
public void run() {
if(!isConnectError) {
Snackbar snackbar = Snackbar
.make(mMessagesView, R.string.error_connect, Snackbar.LENGTH_LONG)
.setAction("Dismiss", new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
snackbar.show();
Toast toast = Toast.makeText(getApplicationContext(), R.string.error_connect, Toast.LENGTH_LONG);
// Changing message text color
snackbar.setActionTextColor(Color.RED);
// Changing action button text color
View sbView = snackbar.getView();
TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.YELLOW);
snackbar.show();
isConnectError = true;
}
/*Toast toast = Toast.makeText(getApplicationContext(), R.string.error_connect, Toast.LENGTH_LONG);
View toastView = toast.getView(); // This'll return the default View of the Toast.
/* And now you can get the TextView of the default View of the Toast. */
*//* And now you can get the TextView of the default View of the Toast. *//*
TextView toastMessage = (TextView) toastView.findViewById(android.R.id.message);
toastMessage.setTextSize(15);
toastMessage.setTextColor(Color.WHITE);
toastMessage.setGravity(Gravity.CENTER);
toastMessage.setPadding(30,0,30,0);
toastView.setBackgroundColor(Color.BLACK);
toast.show();
toast.show();*/
}
});
}
......@@ -1337,8 +1389,8 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
mSocket.off(Socket.EVENT_CONNECT, onConnect);
mSocket.off(Socket.EVENT_DISCONNECT, onDisconnect);
mSocket.off(Socket.EVENT_CONNECT_ERROR, onConnectError);
mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, onConnectTimeOut);
mSocket.on(Socket.EVENT_RECONNECT, onReconnect);
mSocket.off(Socket.EVENT_CONNECT_TIMEOUT, onConnectTimeOut);
mSocket.off(Socket.EVENT_RECONNECT, onReconnect);
mSocket.off(NEW_MESSAGE, onNewMessage);
mSocket.off(AUTHENTICATED, authenticated);
mSocket.off(UNAUTHORIZED, unAuthorized);
......
......@@ -208,6 +208,9 @@ public class HomeScreen extends HandleNotificationActivity {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Username: ");
stringBuilder.append(userFullName);
stringBuilder.append("\n");
stringBuilder.append("\n");
stringBuilder.append("Version: "+BuildConfig.VERSION_NAME);
builder.setMessage(stringBuilder.toString())
.setTitle("User Details")
......
......@@ -1160,9 +1160,16 @@ public class Util {
})
// .setNegativeButton(android.R.string.no, null)
.show();
}
/**
* This method converts dp unit to equivalent pixels, depending on device density.
*
* @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels
* @param context Context to get resources and device specific display metrics
* @return A int value to represent px equivalent to dp depending on device density
*/
public static int convertDpToPx(Context context, float dp) {
return (int) (dp * context.getResources().getDisplayMetrics().density);
}
}
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 sign in to comment