Commit 2d02a6e4 by Prabhu Chaitanya Areti

changed url's through service

parents 6bcc8602 dfab12f6
......@@ -18,28 +18,29 @@ android {
flavorDimensions "tier"
signingConfigs {
debug {
// keyAlias 'androiddebugkey'
// keyPassword 'android'
// storeFile file('/Users/chaukadev/.android/debug.keystore')
// storePassword 'android'
keyAlias 'vportal'
keyPassword 'vportal'
storeFile file('vportal.jks')
storePassword 'vportal'
}
config {
// keyAlias 'Uofl'
// keyPassword 'Vsoft@123'
// storeFile file('/Users/apple/Desktop/uofl_builds/Uofl_keys')
// storePassword 'Vsoft@123'
keyAlias 'vportal'
keyPassword 'vportal'
storeFile file('vportal.jks')
storePassword 'vportal'
}
}
compileSdkVersion 27
buildToolsVersion "27.0.0"
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.vsoft.servicenow"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "0.0.33"
versionName "0.0.1"
multiDexEnabled true
}
buildTypes {
......@@ -55,8 +56,8 @@ android {
signingConfig signingConfigs.config
}
staging { //staging is the UAT environment
applicationIdSuffix ".staging"
debuggable true
//applicationIdSuffix ".staging"
debuggable false
buildConfigField "int", "BUILD_TYPE_INT", "3"
signingConfig signingConfigs.debug
}
......@@ -93,7 +94,8 @@ dependencies {
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
compile 'com.jakewharton:butterknife:8.8.1'
compile 'com.google.android.gms:play-services-analytics:12.0.1'
compile 'com.google.android.gms:play-services-analytics:15.0.0'
compile 'com.googlecode.android-query:android-query:0.25.9'
//compile 'com.google.dagger:dagger:2.0'
//annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
......@@ -102,13 +104,13 @@ dependencies {
}
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.nkzawa:socket.io-client:0.3.0'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:animated-vector-drawable:27.1.0'
compile 'com.android.support:support-media-compat:27.1.0'
compile 'com.android.support:support-v4:27.1.0'
compile 'com.google.firebase:firebase-messaging:12.0.1'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:animated-vector-drawable:27.1.1'
compile 'com.android.support:support-media-compat:27.1.1'
compile 'com.android.support:support-v4:27.1.1'
compile 'com.google.firebase:firebase-messaging:15.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
}
......
......@@ -12,6 +12,8 @@ import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
import com.androidquery.AQuery;
import com.androidquery.callback.AjaxStatus;
import com.crashlytics.android.Crashlytics;
import com.github.nkzawa.socketio.client.IO;
import com.github.nkzawa.socketio.client.Socket;
......@@ -25,6 +27,9 @@ import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.PrefManager;
import com.vsoft.servicenow.utils.Util;
import org.json.JSONException;
import org.json.JSONObject;
import java.net.URISyntaxException;
import io.fabric.sdk.android.Fabric;
......@@ -87,15 +92,8 @@ public class CatalogueApplication extends Application {
/*Database is created*/
initializeDatabase();
configureURL();
if(Util.isChatItemEnabled()) {
initializeSocket();
}
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
mNetworkChangeReceiver = new NetworkChangeReceiver();
registerReceiver(mNetworkChangeReceiver, intentFilter);
}
@Override
......@@ -151,4 +149,28 @@ public class CatalogueApplication extends Application {
public Socket getSocket() {
return mSocket;
}
private void configureURL(){
AQuery aq;
aq = new AQuery(this);
aq.ajax("http://ai.test.vsoftconsulting.com:3000/?env=test", JSONObject.class, this, "jsonCallback");
}
public void jsonCallback(String url, JSONObject json, AjaxStatus status) {
//When JSON is not null
try {
if (json != null) {
AppConfig.CHAT_SERVER_URL_STAGING=json.getString("chatbot_url");
if(Util.isChatItemEnabled()) {
initializeSocket();
}
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
mNetworkChangeReceiver = new NetworkChangeReceiver();
registerReceiver(mNetworkChangeReceiver, intentFilter);
}
} catch (JSONException e) {
Log.i("Exception e", e + "");
}
}
}
......@@ -18,6 +18,7 @@ import com.vsoft.servicenow.R;
import com.vsoft.servicenow.db.managers.NotificationsManager;
import com.vsoft.servicenow.db.models.Notifications;
import com.vsoft.servicenow.ui.NotificationScreen;
import com.vsoft.servicenow.ui.PendingApprovalsActivity;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.PrefManager;
......@@ -33,11 +34,18 @@ import java.util.Map;
*/
public class NotificationMessagingService extends FirebaseMessagingService {
private static final String MESSAGE_BODY_INCIDENT_TITLE = "Incidents";
private static final String MESSAGE_BODY_HR_CASE_TITLE = "HR Cases";
private static final String MESSAGE_BODY_REQUEST_TITLE = "Order Services";
private static final String MESSAGE_BODY_APPROVALS_TITLE = "My Approvals";
private static final String FCM_KEY_TITLE = "title";
private static final String FCM_KEY_BODY = "body";
private static final String FCM_KEY_PRIORITY = "priority";
private static final String FCM_KEY_REQUEST_STATE = "state";
private static final String FCM_KEY_INCIDENT_PRIORITY = "priority";
private static final String FCM_KEY_SHORT_DESCRIPTION = "short_description";
private static final String FCM_KEY_CREATED_BY = "created_by";
private static final String FCM_KEY_MESSAGE_BODY_TITLE = "title";
private static final String CHANNEL_ID = "sn_channel";
......@@ -55,47 +63,94 @@ public class NotificationMessagingService extends FirebaseMessagingService {
Map<String, String> dataMap = remoteMessage.getData();
String title = dataMap.get(FCM_KEY_TITLE);
String messageBody = dataMap.get(FCM_KEY_BODY);
String priority = null, shortDes = null, createdBy = null;
String priority = null, shortDes = null, createdBy = null, messageBodyTitle = null, requestState = null, documentId = null;
try {
JSONObject jsonObject = new JSONObject(messageBody);
priority = jsonObject.getString(FCM_KEY_PRIORITY);
if(!jsonObject.isNull(FCM_KEY_INCIDENT_PRIORITY)) {
priority = jsonObject.getString(FCM_KEY_INCIDENT_PRIORITY);
}
if(!jsonObject.isNull(FCM_KEY_SHORT_DESCRIPTION)) {
shortDes = jsonObject.getString(FCM_KEY_SHORT_DESCRIPTION);
}
if(!jsonObject.isNull(FCM_KEY_REQUEST_STATE)) {
requestState = jsonObject.getString(FCM_KEY_REQUEST_STATE);
}
createdBy = jsonObject.getString(FCM_KEY_CREATED_BY);
messageBodyTitle = jsonObject.getString(FCM_KEY_MESSAGE_BODY_TITLE);
} catch (JSONException e) {
e.printStackTrace();
}
Notifications newNotification = new Notifications();
Notifications newNotification = null;
if(messageBodyTitle.equals(MESSAGE_BODY_INCIDENT_TITLE)) {
newNotification = new Notifications();
newNotification.setTitle(title);
newNotification.setShortDescription(shortDes);
newNotification.setPriority(priority);
newNotification.setCreated_by(createdBy);
NotificationsManager.save(newNotification);
} else if(messageBodyTitle.equals(MESSAGE_BODY_REQUEST_TITLE)) {
newNotification = new Notifications();
newNotification.setTitle(title);
newNotification.setShortDescription(shortDes);
newNotification.setPriority(requestState);
newNotification.setCreated_by(createdBy);
NotificationsManager.save(newNotification);
} else if(messageBodyTitle.equals(MESSAGE_BODY_APPROVALS_TITLE)) {
newNotification = new Notifications();
newNotification.setTitle(title);
newNotification.setShortDescription(shortDes);
newNotification.setPriority(requestState);
newNotification.setCreated_by(createdBy);
}
sendNotification(newNotification);
sendLocalMessage(NotificationMessagingService.this, newNotification);
sendNotification(newNotification, messageBodyTitle, null);
if(messageBodyTitle.equals(MESSAGE_BODY_APPROVALS_TITLE)) {
sendLocalMessage(NotificationMessagingService.this, newNotification, true);
} else {
sendLocalMessage(NotificationMessagingService.this, newNotification, false);
}
}
}
private void sendLocalMessage(Context context, Notifications notifications) {
private void sendLocalMessage(Context context, Notifications notifications, boolean isApproval) {
Intent intent = new Intent(Constants.BROADCAST_NOTIFICATION);
intent.putExtra(Constants.DATA_KEY_NOTIFICATION_TITLE, notifications.getTitle());
intent.putExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE, notifications.getShortDescription());
intent.putExtra(Constants.DATA_KEY_NOTIFICATION_IS_APPROVALS, isApproval);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
private void sendNotification(Notifications notification) {
Intent newIntent = new Intent(this, NotificationScreen.class);
private void sendNotification(Notifications notification, String messageBodyTitle, String documentId) {
String title = null;
Intent newIntent = null;
if(messageBodyTitle.equals(MESSAGE_BODY_APPROVALS_TITLE)) {
title = getString(R.string.notification_status_bar_approvals_title_string);
newIntent = new Intent(this, PendingApprovalsActivity.class);
} else if(messageBodyTitle.equals(MESSAGE_BODY_INCIDENT_TITLE)) {
title = getString(R.string.notification_status_bar_incident_title_string);
newIntent = new Intent(this, NotificationScreen.class);
} else if(messageBodyTitle.equals(MESSAGE_BODY_REQUEST_TITLE)) {
title = getString(R.string.notification_status_bar_request_title_string);
newIntent = new Intent(this, NotificationScreen.class);
} else if(messageBodyTitle.equals(MESSAGE_BODY_HR_CASE_TITLE)) {
title = getString(R.string.notification_status_bar_hr_case_title_string);
newIntent = new Intent(this, NotificationScreen.class);
}
newIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, newIntent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle(getString(R.string.notification_status_bar_title_string))
.setContentText(notification.getShortDescription())
.setContentTitle(title)
.setContentText(notification != null ? notification.getShortDescription() : documentId)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setChannelId(CHANNEL_ID)
......@@ -111,7 +166,6 @@ public class NotificationMessagingService extends FirebaseMessagingService {
notificationManager.createNotificationChannel(mChannel);
}
notificationManager.notify(1, notificationBuilder.build());
}
}
......@@ -10,10 +10,10 @@ import com.vsoft.servicenow.api.listeners.post.PostHRCaseVariableFormApiListener
import com.vsoft.servicenow.api.listeners.post.PostIncidentApiListener;
import com.vsoft.servicenow.api.listeners.post.PostVariableFormApiListener;
import com.vsoft.servicenow.api.managers.CatalogueVariableApiManager;
import com.vsoft.servicenow.api.managers.HRCaseItemApiManager;
import com.vsoft.servicenow.api.managers.HRCaseVariableApiManager;
import com.vsoft.servicenow.api.managers.IncidentApiManager;
import com.vsoft.servicenow.api.pojos.HRCaseVariableSubmitApiResponse;
import com.vsoft.servicenow.db.DBConstants;
import com.vsoft.servicenow.db.managers.AttachmentManager;
import com.vsoft.servicenow.db.managers.CatalogueItemInputManager;
import com.vsoft.servicenow.db.managers.CatalogueItemManager;
......@@ -31,8 +31,8 @@ import com.vsoft.servicenow.db.models.Incident;
import com.vsoft.servicenow.enums.SyncStatus;
import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.db.DBConstants;
import com.vsoft.servicenow.utils.PrefManager;
import com.vsoft.servicenow.utils.Util;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -48,10 +48,10 @@ import java.util.List;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import static com.vsoft.servicenow.db.managers.CatalogueItemInputManager.getDirtyItemInput;
import static com.vsoft.servicenow.db.DBConstants.CATALOGUE_ITEM_INPUT_SYS_ID;
import static com.vsoft.servicenow.db.DBConstants.INCIDENT_INPUT_NUMBER;
import static com.vsoft.servicenow.db.DBConstants.SYNC_FLAG_NONE;
import static com.vsoft.servicenow.db.managers.CatalogueItemInputManager.getDirtyItemInput;
/**
......@@ -62,6 +62,7 @@ import static com.vsoft.servicenow.db.DBConstants.SYNC_FLAG_NONE;
public class SyncService extends IntentService {
private SyncStatus syncStatus = SyncStatus.FAIL;
public SyncService() {
super(SyncService.class.getSimpleName());
}
......@@ -69,7 +70,7 @@ public class SyncService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
CatalogueApplication mApplication = (CatalogueApplication) getApplication();
if(!mApplication.isNetConnected()) {
if (!mApplication.isNetConnected()) {
CatalogueLog.e("SyncService: onHandleIntent(): Not connected to net. Exit.");
return;
}
......@@ -81,47 +82,59 @@ public class SyncService extends IntentService {
SyncStatus result;
/*First we will work on dirty variable form*/
List<CatalogueItemInput> catalogueItemInputList = getDirtyItemInput();
if(Constants.DEBUG) CatalogueLog.d("startSync: catalogue form to sync: "+catalogueItemInputList.size());
if (Constants.DEBUG)
CatalogueLog.d("startSync: catalogue form to sync: " + catalogueItemInputList.size());
for (int i = 0; i < catalogueItemInputList.size(); i++) {
CatalogueItemInput catalogueItemInput = catalogueItemInputList.get(i);
result = syncVariableForm(catalogueItemInput);
if(Constants.DEBUG) CatalogueLog.d("startSync: result of syncing catalogueItemInput "+i+": "+result);
if (Constants.DEBUG)
CatalogueLog.d("startSync: result of syncing catalogueItemInput " + i + ": " + result);
}
/*Then we will work on dirty attachment*/
List<Attachment> attachmentList = AttachmentManager.getDirtyAttachment();
if(Constants.DEBUG) CatalogueLog.d("startSync: attachment to sync: "+attachmentList.size());
if (Constants.DEBUG)
CatalogueLog.d("startSync: attachment to sync: " + attachmentList.size());
for (int i = 0; i < attachmentList.size(); i++) {
Attachment attachment = attachmentList.get(i);
result = syncAttachment(attachment);
if(Constants.DEBUG) CatalogueLog.d("startSync: result of syncing attachment "+i+": "+result);
if (Constants.DEBUG)
CatalogueLog.d("startSync: result of syncing attachment " + i + ": " + result);
}
if (Util.isHrCaseEnabled()) {
/*Then we will work on dirty variable form*/
List<HRCaseItemInput> hrCaseItemInputList = HRCaseItemInputManager.getDirtyItemInput();
if(Constants.DEBUG) CatalogueLog.d("startSync: HRCase form to sync: "+hrCaseItemInputList.size());
if (Constants.DEBUG)
CatalogueLog.d("startSync: HRCase form to sync: " + hrCaseItemInputList.size());
for (int i = 0; i < hrCaseItemInputList.size(); i++) {
HRCaseItemInput hrCaseItemInput = hrCaseItemInputList.get(i);
result = syncHRCaseVariableForm(hrCaseItemInput);
if(Constants.DEBUG) CatalogueLog.d("startSync: result of syncing hrCaseItemInput "+i+": "+result);
if (Constants.DEBUG)
CatalogueLog.d("startSync: result of syncing hrCaseItemInput " + i + ": " + result);
}
/*Then we will work on dirty HRCase attachment*/
List<HRCaseAttachment> hrCaseAttachmentList = HRCaseAttachmentManager.getDirtyHRCaseAttachment();
if(Constants.DEBUG) CatalogueLog.d("startSync: HRCaseAttachment to sync: "+hrCaseAttachmentList.size());
if (Constants.DEBUG)
CatalogueLog.d("startSync: HRCaseAttachment to sync: " + hrCaseAttachmentList.size());
for (int i = 0; i < hrCaseAttachmentList.size(); i++) {
HRCaseAttachment hrCaseAttachment = hrCaseAttachmentList.get(i);
result = syncHRCaseAttachment(hrCaseAttachment);
if(Constants.DEBUG) CatalogueLog.d("startSync: result of syncing hrCaseAttachment "+i+": "+result);
if (Constants.DEBUG)
CatalogueLog.d("startSync: result of syncing hrCaseAttachment " + i + ": " + result);
}
}
/*Then we will work on dirty incident form*/
List<Incident> incidentInputList = ReportIncidentValueManager.getDirtyIncident();
if(Constants.DEBUG) CatalogueLog.d("startSync: incident form to sync: "+incidentInputList.size());
if (Constants.DEBUG)
CatalogueLog.d("startSync: incident form to sync: " + incidentInputList.size());
for (int i = 0; i < incidentInputList.size(); i++) {
Incident incident = incidentInputList.get(i);
result = syncIncidentForm(incident);
if(Constants.DEBUG) CatalogueLog.d("startSync: result of syncing incidentInput "+i+": "+result);
if (Constants.DEBUG)
CatalogueLog.d("startSync: result of syncing incidentInput " + i + ": " + result);
}
}
......@@ -129,8 +142,8 @@ public class SyncService extends IntentService {
* Sync VariableForm
**/
private SyncStatus syncVariableForm(final CatalogueItemInput catalogueItemInput) {
CatalogueLog.d( "syncVariableForm");
if(catalogueItemInput.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE || catalogueItemInput.getSysId() == null || catalogueItemInput.getSysId().isEmpty()) {
CatalogueLog.d("syncVariableForm");
if (catalogueItemInput.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE || catalogueItemInput.getSysId() == null || catalogueItemInput.getSysId().isEmpty()) {
final CatalogueItem catalogueItem = CatalogueItemManager.get(catalogueItemInput.getCatalogueItemId());
CatalogueVariableApiManager.submitVariableForm(SyncService.this, catalogueItem.getSysId(),
catalogueItemInput.getData(),
......@@ -157,8 +170,8 @@ public class SyncService extends IntentService {
* Sync Attachment
**/
private SyncStatus syncAttachment(final Attachment attachment) {
CatalogueLog.d( "syncAttachment");
if(attachment.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE) {
CatalogueLog.d("syncAttachment");
if (attachment.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE) {
if (attachment.getMimeType() != null) {
InputStream in = null;
try {
......@@ -201,9 +214,9 @@ public class SyncService extends IntentService {
* Sync Incident form
**/
private SyncStatus syncIncidentForm(final Incident incident) {
CatalogueLog.d( "syncVariableForm");
CatalogueLog.d("syncVariableForm");
String userSysId = PrefManager.getSharedPref(SyncService.this, PrefManager.PREFERENCE_USER_SYS_ID);
if(incident.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE || incident.getNumber() == null || incident.getNumber().isEmpty()) {
if (incident.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE || incident.getNumber() == null || incident.getNumber().isEmpty()) {
JSONObject incidentJsonObject = new JSONObject();
try {
incidentJsonObject.put(Incident.Json.IMPACT, incident.getImpact().getServerString());
......@@ -237,8 +250,8 @@ public class SyncService extends IntentService {
* Sync HRCase VariableForm
**/
private SyncStatus syncHRCaseVariableForm(final HRCaseItemInput hrCaseItemInput) {
CatalogueLog.d( "syncHRCaseVariableForm");
if(hrCaseItemInput.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE || hrCaseItemInput.getSysId() == null || hrCaseItemInput.getSysId().isEmpty()) {
CatalogueLog.d("syncHRCaseVariableForm");
if (hrCaseItemInput.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE || hrCaseItemInput.getSysId() == null || hrCaseItemInput.getSysId().isEmpty()) {
final HRCaseItem hrCaseItem = HRCaseItemManager.get(hrCaseItemInput.getHRCaseItemId());
HRCaseVariableApiManager.submitHRCaseVariableForm(SyncService.this, hrCaseItem.getSysId(),
hrCaseItemInput.getData(),
......@@ -254,7 +267,7 @@ public class SyncService extends IntentService {
String record = hrCaseVariableSubmitApiResponse.getRecord();
String[] recordSpit = record.split("/");
String submittedFormSysId = null;
if(recordSpit.length > 0) {
if (recordSpit.length > 0) {
submittedFormSysId = recordSpit[recordSpit.length - 1];
}
hrCaseItemInput.setSysId(submittedFormSysId);
......@@ -275,8 +288,8 @@ public class SyncService extends IntentService {
* Sync HRCase Attachment
**/
private SyncStatus syncHRCaseAttachment(final HRCaseAttachment hrCaseAttachment) {
CatalogueLog.d( "syncHRCaseAttachment");
if(hrCaseAttachment.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE) {
CatalogueLog.d("syncHRCaseAttachment");
if (hrCaseAttachment.getSyncDirty() == DBConstants.SYNC_FLAG_CREATE) {
if (hrCaseAttachment.getMimeType() != null) {
InputStream in = null;
try {
......
......@@ -101,7 +101,7 @@ public class DroidSpeech {
@Override
public void onLanguageDetailsInfo(String defaultLanguage, List<String> otherLanguages) {
dsProperties.currentSpeechLanguage = defaultLanguage;
dsProperties.currentSpeechLanguage = "en-UK";
dsProperties.supportedSpeechLanguages = otherLanguages;
// Initializing the droid speech properties
......@@ -133,6 +133,7 @@ public class DroidSpeech {
speechIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, Extensions.MAX_VOICE_RESULTS);
if (dsProperties.currentSpeechLanguage != null) {
// Setting the speech language
System.out.println(dsProperties.currentSpeechLanguage);
speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, dsProperties.currentSpeechLanguage);
speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, dsProperties.currentSpeechLanguage);
}
......
......@@ -184,6 +184,34 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
}
});
//Below code for - Last message getting overlapped when virtual keyboard is opened.
mInputMessageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
if(mMessagesView.getAdapter().getItemCount() > 0) {
mMessagesView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v,
int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (bottom < oldBottom) {
mMessagesView.postDelayed(new Runnable() {
@Override
public void run() {
mMessagesView.smoothScrollToPosition(
mMessagesView.getAdapter().getItemCount() - 1);
}
}, 100);
}
}
});
}
}
return false;
}
});
droidSpeech = new DroidSpeech(this, getSupportFragmentManager());
droidSpeech.setOnDroidSpeechListener(this);
......
......@@ -46,6 +46,8 @@ public class HandleNotificationActivity extends AppCompatActivity {
// That's why we need to play explicitly
Util.playNotificationSound(HandleNotificationActivity.this);
boolean isApprovalNotification = intent.getBooleanExtra(Constants.DATA_KEY_NOTIFICATION_IS_APPROVALS, false);
if(!isApprovalNotification) {
AlertDialog.Builder builder = new AlertDialog.Builder(HandleNotificationActivity.this);
builder.setMessage(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE))
.setTitle(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_TITLE))
......@@ -64,6 +66,26 @@ public class HandleNotificationActivity extends AppCompatActivity {
});
AlertDialog alert = builder.create();
alert.show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(HandleNotificationActivity.this);
builder.setMessage(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE))
.setTitle(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_TITLE))
.setCancelable(false)
.setPositiveButton(R.string.go_to_approvals_string,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startActivity(new Intent(HandleNotificationActivity.this,
PendingApprovalsActivity.class));
}
})
.setNegativeButton(R.string.ok_string, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
};
}
......@@ -66,6 +66,8 @@ public class NotificationScreen extends AppCompatActivity {
// That's why we need to play explicitly
Util.playNotificationSound(NotificationScreen.this);
boolean isApprovalNotification = intent.getBooleanExtra(Constants.DATA_KEY_NOTIFICATION_IS_APPROVALS, false);
if(!isApprovalNotification) {
AlertDialog.Builder builder = new AlertDialog.Builder(NotificationScreen.this);
builder.setMessage(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE))
.setTitle(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_TITLE))
......@@ -79,6 +81,26 @@ public class NotificationScreen extends AppCompatActivity {
});
AlertDialog alert = builder.create();
alert.show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(NotificationScreen.this);
builder.setMessage(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE))
.setTitle(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_TITLE))
.setCancelable(false)
.setPositiveButton(R.string.go_to_approvals_string,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startActivity(new Intent(NotificationScreen.this,
PendingApprovalsActivity.class));
}
})
.setNegativeButton(R.string.ok_string, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
};
......
package com.vsoft.servicenow.ui;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.TextUtils;
......@@ -30,6 +37,7 @@ import com.vsoft.servicenow.api.managers.PendingApprovalsApiManager;
import com.vsoft.servicenow.db.managers.PendingApprovalsManager;
import com.vsoft.servicenow.db.models.PendingApprovals;
import com.vsoft.servicenow.enums.SyncStatus;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.DialogUtils;
import com.vsoft.servicenow.utils.Util;
......@@ -48,7 +56,7 @@ import butterknife.OnItemClick;
/**
* Created by Kunj on 26/04/2018.
* */
public class PendingApprovalsActivity extends HandleNotificationActivity {
public class PendingApprovalsActivity extends AppCompatActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.pending_approvals_screen_list_view) ListView mListView;
......@@ -60,6 +68,55 @@ public class PendingApprovalsActivity extends HandleNotificationActivity {
private boolean isProgressRequire;
private CatalogueApplication mApplication;
private final BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//Cancel received notifications
final NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
//Play notification sound because Above we already cancel notifications.
// That's why we need to play explicitly
Util.playNotificationSound(PendingApprovalsActivity.this);
boolean isApprovalNotification = intent.getBooleanExtra(Constants.DATA_KEY_NOTIFICATION_IS_APPROVALS, false);
if(isApprovalNotification) {
AlertDialog.Builder builder = new AlertDialog.Builder(PendingApprovalsActivity.this);
builder.setMessage(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE))
.setTitle(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_TITLE))
.setCancelable(false)
.setPositiveButton(R.string.ok_string,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(PendingApprovalsActivity.this);
builder.setMessage(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE))
.setTitle(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_TITLE))
.setCancelable(false)
.setPositiveButton(R.string.go_to_notification_string,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startActivity(new Intent(PendingApprovalsActivity.this,
NotificationScreen.class));
}
})
.setNegativeButton(R.string.ok_string, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
......@@ -332,4 +389,19 @@ public class PendingApprovalsActivity extends HandleNotificationActivity {
}
}
}
@Override
public void onResume() {
super.onResume();
LocalBroadcastManager.getInstance(PendingApprovalsActivity.this)
.registerReceiver(mMessageReceiver,
new IntentFilter(Constants.BROADCAST_NOTIFICATION));
}
@Override
public void onPause() {
LocalBroadcastManager.getInstance(PendingApprovalsActivity.this)
.unregisterReceiver(mMessageReceiver);
super.onPause();
}
}
......@@ -4,10 +4,17 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Window;
import com.androidquery.AQuery;
import com.androidquery.callback.AjaxStatus;
import com.vsoft.servicenow.AppConfig;
import com.vsoft.servicenow.R;
import org.json.JSONException;
import org.json.JSONObject;
import butterknife.ButterKnife;
/**
......@@ -51,4 +58,5 @@ public class SplashScreen extends Activity {
}, SPLASH_TIME_OUT);
}
}
......@@ -32,6 +32,7 @@ public class Constants {
public static final String DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION = "catalogue_item_short_des";
public static final String DATA_KEY_NOTIFICATION_TITLE = "notification_title";
public static final String DATA_KEY_NOTIFICATION_MESSAGE = "notification_message";
public static final String DATA_KEY_NOTIFICATION_IS_APPROVALS = "notification_is_approvals";
public static final String DATA_KEY_LOGIN_REQUEST_CODE = "login_request_code";
public static final String DATA_KEY_CATEGORY_SYS_ID = "category_sys_id";
public static final String DATA_KEY_HR_CASE_TITLE = "hr_case_title";
......
......@@ -85,7 +85,7 @@
<!--Incident screen-->
<string name="incident_form_report_incident_text_string">Report Incident</string>
<string name="incident_form_top_text_string">Create an Incident record to report and request assistance with an issue you are having\n\nRequest assistance with an issue you are having. An incident record will be created and managed through to successful resolution. You will also be notified of progress.</string>
<string name="incident_form_top_text_string">Create an Incident record to report and request assistance with an issue you are having\n\n. An incident record will be created and managed through to successful resolution. You will also be notified of progress.</string>
<string name="incident_form_impact_text_string">Impact &lt;font color="#FF0000"&gt;*&lt;/font&gt;</string>
<string name="incident_form_incident_successful_submission_string">Incident has been reported successfully</string>
<string name="incident_form_describe_your_issue_text_string">Please Describe Your Issue below &lt;font color="#FF0000"&gt;*&lt;/font&gt;(Max %d)</string>
......@@ -113,7 +113,11 @@
<string name="notification_screen_action_bar_title_string">Notifications</string>
<string name="notification_screen_empty_text_string">No Notifications</string>
<string name="go_to_notification_string">Go to Notification</string>
<string name="notification_status_bar_title_string">New Incident assigned to you</string>
<string name="go_to_approvals_string">Go to Approvals</string>
<string name="notification_status_bar_incident_title_string">New Incident assigned to you</string>
<string name="notification_status_bar_hr_case_title_string">New HR Case assigned to you</string>
<string name="notification_status_bar_request_title_string">New Request assigned to you</string>
<string name="notification_status_bar_approvals_title_string">New Approval assigned to you</string>
<!--Chat Related String-->
<string name="chat_activity_label">Vera</string>
......
......@@ -72,7 +72,7 @@
"client_info": {
"mobilesdk_app_id": "1:222593508124:android:ade631ceed1f3560",
"android_client_info": {
"package_name": "com.vsoft.servicenow.vportal.staging"
"package_name": "com.vsoft.servicenow.vportal"
}
},
"oauth_client": [
......
......@@ -61,5 +61,6 @@ public class AppConfig {
* */
public static final String CHAT_SERVER_URL_RELEASE = "http://111.93.6.218:12914/";
public static final String CHAT_SERVER_URL_DEBUG = "http://111.93.6.218:12911/";
public static final String CHAT_SERVER_URL_STAGING = "http://ai.test.vsoftconsulting.com:3000/";
public static String CHAT_SERVER_URL_STAGING = "";
}
No preview for this file type
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