Commit 1310b51d by Kunj Gupta

Added Notification part and Device Registration API in Arrow.

parent ab925e59
Showing with 417 additions and 220 deletions
{ {
"project_info": { "project_info": {
"project_number": "222593508124", "project_number": "593992849158",
"firebase_url": "https://v-soft-poc-apps.firebaseio.com", "project_id": "uofl-servicenow-android"
"project_id": "v-soft-poc-apps",
"storage_bucket": "v-soft-poc-apps.appspot.com"
}, },
"client": [ "client": [
{ {
"client_info": { "client_info": {
"mobilesdk_app_id": "1:222593508124:android:d77c1b70d2a38b4d", "mobilesdk_app_id": "1:593992849158:android:84f481659dc7e412",
"android_client_info": { "android_client_info": {
"package_name": "com.vsoft.servicenow.arrow.debug" "package_name": "com.vsoft.uoflservicenow"
} }
}, },
"oauth_client": [ "oauth_client": [],
{
"client_id": "222593508124-1jq94gaia4oahk321cd8ud74jv6tqgr3.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [ "api_key": [
{ {
"current_key": "AIzaSyALtTZoenaAEMfqvBLlHRsAU4P_aoOYBLg" "current_key": "AIzaSyBEzc7fo12bQLx8CkogSGIb2j-vivdbJNg"
} }
], ],
"services": { "services": {
"analytics_service": { "analytics_service": {
"status": 1 "status": 2,
"analytics_property": {
"tracking_id": "UA-83545030-1"
}
}, },
"appinvite_service": { "appinvite_service": {
"status": 1, "status": 1,
"other_platform_oauth_client": [] "other_platform_oauth_client": []
}, },
"ads_service": { "ads_service": {
"status": 2 "status": 1
} }
} }
} }
], ],
"configuration_version": "1" "configuration_version": "1"
} }
\ No newline at end of file
{
"project_info": {
"project_number": "222593508124",
"firebase_url": "https://v-soft-poc-apps.firebaseio.com",
"project_id": "v-soft-poc-apps",
"storage_bucket": "v-soft-poc-apps.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:222593508124:android:d77c1b70d2a38b4d",
"android_client_info": {
"package_name": "com.vsoft.servicenow.arrow.debug"
}
},
"oauth_client": [
{
"client_id": "222593508124-1jq94gaia4oahk321cd8ud74jv6tqgr3.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyALtTZoenaAEMfqvBLlHRsAU4P_aoOYBLg"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
...@@ -5,7 +5,7 @@ package com.vsoft.servicenow; ...@@ -5,7 +5,7 @@ package com.vsoft.servicenow;
*/ */
public class AppConfig { public class AppConfig {
public static final String CHAT_SERVER_URL = "http://111.93.6.218:12910/";//https://socket-io-chat.now.sh/"; public static final String CHAT_SERVER_URL = "http://111.93.6.218:12910/";
public static final String APP_INTERNAL_NAME = "Arrow"; public static final String APP_INTERNAL_NAME = "Arrow";
......
package com.vsoft.servicenow.ui; package com.vsoft.servicenow.ui;
import android.app.Notification;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.TypedArray; import android.content.res.TypedArray;
...@@ -31,7 +32,7 @@ import butterknife.OnItemClick; ...@@ -31,7 +32,7 @@ import butterknife.OnItemClick;
/** /**
* Created by Kunj on 11/8/16. * Created by Kunj on 11/8/16.
*/ */
public class HomeScreen extends AppCompatActivity { public class HomeScreen extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar; @BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.home_screen_grid_view) GridView mGridView; @BindView(R.id.home_screen_grid_view) GridView mGridView;
...@@ -73,6 +74,9 @@ public class HomeScreen extends AppCompatActivity { ...@@ -73,6 +74,9 @@ public class HomeScreen extends AppCompatActivity {
Intent intent = new Intent(HomeScreen.this, ChatActivity.class); Intent intent = new Intent(HomeScreen.this, ChatActivity.class);
intent.putExtra(Constants.DATA_KEY_CHAT_USER_NAME, userFirstName); intent.putExtra(Constants.DATA_KEY_CHAT_USER_NAME, userFirstName);
startActivity(intent); startActivity(intent);
} else if (position == 5) {
Intent intent = new Intent(HomeScreen.this, NotificationScreen.class);
startActivity(intent);
} }
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<item>My Incidents</item> <item>My Incidents</item>
<item>My Requests</item> <item>My Requests</item>
<item>Chatbot</item> <item>Chatbot</item>
<item>Notifications</item>
</string-array> </string-array>
<array name="home_screen_icon_array"> <array name="home_screen_icon_array">
<item>@drawable/ic_myincident_icon</item> <item>@drawable/ic_myincident_icon</item>
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
<item>@drawable/ic_my_incidents_icon</item> <item>@drawable/ic_my_incidents_icon</item>
<item>@drawable/ic_my_requiest_icon</item> <item>@drawable/ic_my_requiest_icon</item>
<item>@drawable/ic_my_requiest_icon</item> <item>@drawable/ic_my_requiest_icon</item>
<item>@drawable/ic_my_requiest_icon</item>
</array> </array>
<string-array name="incident_impact_array"> <string-array name="incident_impact_array">
<item>-None-</item> <item>-None-</item>
......
...@@ -7,6 +7,8 @@ public class AppConfig { ...@@ -7,6 +7,8 @@ public class AppConfig {
public static final String APP_INTERNAL_NAME = "GE"; public static final String APP_INTERNAL_NAME = "GE";
public static final String CHAT_SERVER_URL = "http://111.93.6.218:12910/";
public static final String DOMAIN_PRODUCTION = "https://ven01199.service-now.com/"; public static final String DOMAIN_PRODUCTION = "https://ven01199.service-now.com/";
public static final String DOMAIN_TEST = "https://geapplightrnd.service-now.com/"; public static final String DOMAIN_TEST = "https://geapplightrnd.service-now.com/";
......
...@@ -24,7 +24,7 @@ import butterknife.OnItemClick; ...@@ -24,7 +24,7 @@ import butterknife.OnItemClick;
/** /**
* Created by Kunj on 11/8/16. * Created by Kunj on 11/8/16.
*/ */
public class HomeScreen extends AppCompatActivity { public class HomeScreen extends android.support.v7.app.AppCompatActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar; @BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.home_screen_grid_view) GridView mGridView; @BindView(R.id.home_screen_grid_view) GridView mGridView;
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
</compatible-screens> </compatible-screens>
<application <application
android:name="com.vsoft.servicenow.CatalogueApplication" android:name="com.vsoft.servicenow.CatalogueApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
...@@ -88,6 +87,9 @@ ...@@ -88,6 +87,9 @@
<activity <activity
android:name="com.vsoft.servicenow.ui.MyIncidentScreen" android:name="com.vsoft.servicenow.ui.MyIncidentScreen"
android:screenOrientation="portrait"/> android:screenOrientation="portrait"/>
<activity
android:name="com.vsoft.servicenow.ui.NotificationScreen"
android:screenOrientation="portrait"/>
<service android:name=".service.SyncService" /> <service android:name=".service.SyncService" />
......
...@@ -65,14 +65,9 @@ public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapte ...@@ -65,14 +65,9 @@ public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapte
// - replace the contents of the view with that element // - replace the contents of the view with that element
final Notifications notifications = mNotificationsList.get(position); final Notifications notifications = mNotificationsList.get(position);
holder.titleTextView.setText(notifications.getTitle()); holder.titleTextView.setText(notifications.getTitle());
holder.messageTextView.setText(notifications.getMessage()); holder.shortDesTextView.setText(notifications.getShortDescription());
holder.dateTextView.setText(Util.getDateTimeStringForDisplay(notifications.getTime())); holder.priorityTextView.setText(notifications.getPriority());
// holder.deleteImageView.setOnClickListener(new View.OnClickListener() { holder.createdByTextView.setText(notifications.getCreated_by());
// @Override
// public void onClick(View view) {
// showSuccessfulLogoutDialog(notifications);
// }
// });
} }
/** /**
...@@ -87,19 +82,15 @@ public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapte ...@@ -87,19 +82,15 @@ public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapte
/** /**
* messageTextView: This is message text view. * messageTextView: This is message text view.
*/ */
@BindView(R.id.notification_adapter_message_text_view) @BindView(R.id.notification_adapter_short_des_text_view)
TextView messageTextView; TextView shortDesTextView;
/** /**
* dateTextView: This is date text view. * dateTextView: This is date text view.
*/ */
@BindView(R.id.notification_adapter_date_text_view) @BindView(R.id.notification_adapter_priority_text_view)
TextView dateTextView; TextView priorityTextView;
/** @BindView(R.id.notification_adapter_created_by_text_view)
* deleteImageView: This is delete icon image view. TextView createdByTextView;
*/
// @BindView(R.id.notification_adapter_delete_image_view)
// ImageView deleteImageView;
/** /**
* Constructor of NotificationHolder class. * Constructor of NotificationHolder class.
*/ */
......
...@@ -4,8 +4,12 @@ import com.vsoft.servicenow.utils.Constants; ...@@ -4,8 +4,12 @@ import com.vsoft.servicenow.utils.Constants;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query; import retrofit2.http.Query;
import retrofit2.http.Url;
/** /**
...@@ -14,11 +18,14 @@ import retrofit2.http.Query; ...@@ -14,11 +18,14 @@ import retrofit2.http.Query;
* *
*/ */
public interface UserApi { public interface UserApi {
String DEVICE_TOKEN = "u_user_device_token";
// Get Catalogue API // Get Catalogue API
@GET(Constants.URL_GET_USERDETAILS) @GET(Constants.URL_GET_USERDETAILS)
Call<ResponseBody> getuserDetails(@Query(Constants.URL_PARAM_SYSPRM_USERNAME) String sysparmQuery); Call<ResponseBody> getuserDetails(@Query(Constants.URL_PARAM_SYSPRM_USERNAME) String sysparmQuery);
@PUT(Constants.URL_PUT_DEVICE_REGISTERATION)
Call<ResponseBody> putDeviceRegistration(@Path("user_sys_id") String userSysId, @Body String body);
} }
package com.vsoft.servicenow.api.listeners.put;
import com.vsoft.servicenow.api.pojos.LoginApiResponse;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface PutDeviceRegistrationApiListener {
void onDoneApiCall();
void onFailApiCall();
}
...@@ -11,7 +11,9 @@ import com.google.gson.JsonParseException; ...@@ -11,7 +11,9 @@ import com.google.gson.JsonParseException;
import com.vsoft.servicenow.api.interfaces.UserApi; import com.vsoft.servicenow.api.interfaces.UserApi;
import com.vsoft.servicenow.api.listeners.get.GetUserDetailApiListener; import com.vsoft.servicenow.api.listeners.get.GetUserDetailApiListener;
import com.vsoft.servicenow.api.RestClient; import com.vsoft.servicenow.api.RestClient;
import com.vsoft.servicenow.api.listeners.put.PutDeviceRegistrationApiListener;
import com.vsoft.servicenow.db.models.UserApiValues; import com.vsoft.servicenow.db.models.UserApiValues;
import com.vsoft.servicenow.ui.LoginScreen;
import com.vsoft.servicenow.utils.CatalogueLog; import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.Constants; import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.PrefManager; import com.vsoft.servicenow.utils.PrefManager;
...@@ -120,4 +122,40 @@ public class UserApiManager { ...@@ -120,4 +122,40 @@ public class UserApiManager {
} }
} }
public static void putDeviceRegistration(Context context, String userSysId, PutDeviceRegistrationApiListener listener) {
String accessToken = PrefManager.getSharedPref(context, PrefManager.PREFERENCE_ACCESS_TOKEN);
String deviceToken = PrefManager.getSharedPref(context, Constants.PREFS_NOTIFICATION_TOKEN);
if(accessToken.isEmpty() || deviceToken.isEmpty()) {
listener.onFailApiCall();
return;
}
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put(UserApi.DEVICE_TOKEN, deviceToken);
} catch(JSONException e) {
CatalogueLog.e("putDeviceRegistration: JSONException: " + e.toString());
}
final Retrofit retrofit = RestClient.getInitializedRestAdapter(accessToken);
Call<ResponseBody> call = retrofit.create(UserApi.class).putDeviceRegistration(userSysId, jsonObject.toString());
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if (response.isSuccessful()) {
if(response.code() == 200) {
listener.onDoneApiCall();
} else {
listener.onFailApiCall();
}
} else {
listener.onFailApiCall();
}
} catch (IOException e) {
listener.onFailApiCall();
} catch (NullPointerException e) {
listener.onFailApiCall();
}
}
} }
...@@ -207,8 +207,9 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants { ...@@ -207,8 +207,9 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
db.execSQL("create table IF NOT EXISTS " + TABLE_NOTIFICATIONS + "(" db.execSQL("create table IF NOT EXISTS " + TABLE_NOTIFICATIONS + "("
+ NOTIFICATIONS_ID + " integer primary key autoincrement, " + NOTIFICATIONS_ID + " integer primary key autoincrement, "
+ NOTIFICATIONS_TITLE + " text, " + NOTIFICATIONS_TITLE + " text, "
+ NOTIFICATIONS_MESSAGE + " text, " + NOTIFICATIONS_SHORT_DES + " text, "
+ NOTIFICATIONS_TIME + " DATETIME" + NOTIFICATIONS_PRIORITY + " text, "
+ NOTIFICATIONS_CREATED_BY + " text"
+ ");"); + ");");
} }
} }
...@@ -5,7 +5,9 @@ import android.database.Cursor; ...@@ -5,7 +5,9 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import com.vsoft.servicenow.CatalogueApplication; import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.db.models.Catalogue;
import com.vsoft.servicenow.db.models.Notifications; import com.vsoft.servicenow.db.models.Notifications;
import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.DBConstants; import com.vsoft.servicenow.utils.DBConstants;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -15,7 +17,7 @@ import java.util.List; ...@@ -15,7 +17,7 @@ import java.util.List;
/** /**
* NotificationsManager: This is database manager class of notification, * NotificationsManager: This is database manager class of notification,
* it will handle all the operation of database for notification. * it will handle all the operation of database for notification.
* @author Kunj on 16-01-2017. * @author Kunj on 20-03-2018.
*/ */
public final class NotificationsManager implements DBConstants { public final class NotificationsManager implements DBConstants {
...@@ -57,10 +59,7 @@ public final class NotificationsManager implements DBConstants { ...@@ -57,10 +59,7 @@ public final class NotificationsManager implements DBConstants {
public static List<Notifications> getAllNotifications() { public static List<Notifications> getAllNotifications() {
SQLiteDatabase db = CatalogueApplication.getDatabase(); SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) { if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_NOTIFICATIONS Cursor c = db.rawQuery("select * from " + TABLE_NOTIFICATIONS, null);
+ " ORDER BY "
+ DBConstants.NOTIFICATIONS_TIME
+ " DESC", null);
ArrayList<Notifications> notificationsList; ArrayList<Notifications> notificationsList;
if (c.getCount() > 0) { if (c.getCount() > 0) {
notificationsList = new ArrayList<>(c.getCount()); notificationsList = new ArrayList<>(c.getCount());
...@@ -104,15 +103,18 @@ public final class NotificationsManager implements DBConstants { ...@@ -104,15 +103,18 @@ public final class NotificationsManager implements DBConstants {
private static void fillAllNotificationDetails(Cursor c, Notifications.NotificationsBuilder builder) { private static void fillAllNotificationDetails(Cursor c, Notifications.NotificationsBuilder builder) {
builder.setId(c.getLong(INDEX_NOTIFICATIONS_ID)); builder.setId(c.getLong(INDEX_NOTIFICATIONS_ID));
builder.setTitle(c.getString(INDEX_NOTIFICATIONS_TITLE)); builder.setTitle(c.getString(INDEX_NOTIFICATIONS_TITLE));
builder.setMessage(c.getString(INDEX_NOTIFICATIONS_MESSAGE)); builder.setShortDes(c.getString(INDEX_NOTIFICATIONS_SHORT_DES));
builder.setTime(c.getLong(INDEX_NOTIFICATIONS_TIME)); builder.setPriority(c.getString(INDEX_NOTIFICATIONS_PRIORITY));
builder.setCreatedBy(c.getString(INDEX_NOTIFICATIONS_CREATED_BY));
} }
private static ContentValues getContentValues(Notifications notifications) { private static ContentValues getContentValues(Notifications notifications) {
CatalogueLog.e("notification: "+notifications);
ContentValues cv = new ContentValues(NOTIFICATIONS_COLUMN_COUNT - 1); ContentValues cv = new ContentValues(NOTIFICATIONS_COLUMN_COUNT - 1);
cv.put(NOTIFICATIONS_TITLE, notifications.getTitle()); cv.put(NOTIFICATIONS_TITLE, notifications.getTitle());
cv.put(NOTIFICATIONS_MESSAGE, notifications.getMessage()); cv.put(NOTIFICATIONS_SHORT_DES, notifications.getShortDescription());
cv.put(NOTIFICATIONS_TIME, notifications.getTime()); cv.put(NOTIFICATIONS_PRIORITY, notifications.getPriority());
cv.put(NOTIFICATIONS_CREATED_BY, notifications.getCreated_by());
return cv; return cv;
} }
} }
...@@ -9,8 +9,9 @@ public final class Notifications { ...@@ -9,8 +9,9 @@ public final class Notifications {
private long id = -1; private long id = -1;
private String title; private String title;
private String message; private String shortDescription;
private long time; private String created_by;
private String priority;
/** /**
* Default constructor. * Default constructor.
...@@ -34,30 +35,28 @@ public final class Notifications { ...@@ -34,30 +35,28 @@ public final class Notifications {
this.title = title; this.title = title;
} }
public String getMessage() { public String getShortDescription() {
return message; return shortDescription;
} }
public void setMessage(String message) { public void setShortDescription(String shortDescription) {
this.message = message; this.shortDescription = shortDescription;
} }
public long getTime() { public String getCreated_by() {
return time; return created_by;
} }
public void setTime(long time) { public void setCreated_by(String created_by) {
this.time = time; this.created_by = created_by;
} }
@Override public String getPriority() {
public String toString() { return priority;
return "Notifications{" }
+ "id=" + id
+ ", title='" + title + '\'' public void setPriority(String priority) {
+ ", message='" + message + '\'' this.priority = priority;
+ ", time=" + time
+ '}';
} }
/** /**
...@@ -66,8 +65,9 @@ public final class Notifications { ...@@ -66,8 +65,9 @@ public final class Notifications {
public static final class NotificationsBuilder { public static final class NotificationsBuilder {
private long id = -1; private long id = -1;
private String title; private String title;
private String message; private String shortDescription;
private long time; private String created_by;
private String priority;
private NotificationsBuilder() { private NotificationsBuilder() {
} }
...@@ -96,18 +96,20 @@ public final class Notifications { ...@@ -96,18 +96,20 @@ public final class Notifications {
} }
/** /**
* setTime: This method will set the notification time. * setMessage: This method will set the notification message.
*/ */
public NotificationsBuilder setTime(long notificationTime) { public NotificationsBuilder setShortDes(String shortDescription) {
this.time = notificationTime; this.shortDescription = shortDescription;
return this; return this;
} }
/** public NotificationsBuilder setCreatedBy(String created_by) {
* setMessage: This method will set the notification message. this.created_by = created_by;
*/ return this;
public NotificationsBuilder setMessage(String notificationMessage) { }
this.message = notificationMessage;
public NotificationsBuilder setPriority(String priority) {
this.priority = priority;
return this; return this;
} }
...@@ -115,7 +117,7 @@ public final class Notifications { ...@@ -115,7 +117,7 @@ public final class Notifications {
* but: This method will return NotificationBuilder reference. * but: This method will return NotificationBuilder reference.
*/ */
public NotificationsBuilder but() { public NotificationsBuilder but() {
return aNotification().setId(id).setTitle(title).setMessage(message).setTime(time); return aNotification().setId(id).setTitle(title).setShortDes(shortDescription).setPriority(priority).setCreatedBy(created_by);
} }
/** /**
...@@ -125,8 +127,9 @@ public final class Notifications { ...@@ -125,8 +127,9 @@ public final class Notifications {
Notifications notifications = new Notifications(); Notifications notifications = new Notifications();
notifications.setId(id); notifications.setId(id);
notifications.setTitle(title); notifications.setTitle(title);
notifications.setMessage(message); notifications.setShortDescription(shortDescription);
notifications.setTime(time); notifications.setPriority(priority);
notifications.setCreated_by(created_by);
return notifications; return notifications;
} }
} }
......
...@@ -4,11 +4,17 @@ import com.google.firebase.iid.FirebaseInstanceId; ...@@ -4,11 +4,17 @@ import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService; import com.google.firebase.iid.FirebaseInstanceIdService;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.vsoft.servicenow.CatalogueApplication; import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.api.interfaces.UserApi;
import com.vsoft.servicenow.api.listeners.put.PutDeviceRegistrationApiListener;
import com.vsoft.servicenow.api.managers.UserApiManager;
import com.vsoft.servicenow.db.models.Catalogue; import com.vsoft.servicenow.db.models.Catalogue;
import com.vsoft.servicenow.utils.CatalogueLog; import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.Constants; import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.PrefManager; import com.vsoft.servicenow.utils.PrefManager;
import org.json.JSONException;
import org.json.JSONObject;
/** /**
* NotificationInstanceIdService: This is service class to get refresh token. * NotificationInstanceIdService: This is service class to get refresh token.
* @author kunj on 16/01/17. * @author kunj on 16/01/17.
...@@ -23,22 +29,33 @@ public class NotificationInstanceIdService extends FirebaseInstanceIdService { ...@@ -23,22 +29,33 @@ public class NotificationInstanceIdService extends FirebaseInstanceIdService {
CatalogueLog.d("Refreshed token: " + refreshedToken); CatalogueLog.d("Refreshed token: " + refreshedToken);
PrefManager.setSharedPref(CatalogueApplication.getContext(), Constants.PREFS_NOTIFICATION_TOKEN, refreshedToken); PrefManager.setSharedPref(CatalogueApplication.getContext(), Constants.PREFS_NOTIFICATION_TOKEN, refreshedToken);
sendRegistrationToServer(refreshedToken);
// sendRegistrationToServer(refreshedToken);
} }
// private void sendRegistrationToServer(String refreshedToken) { private void sendRegistrationToServer(String refreshedToken) {
// long userId = SharedPreferencesStore.getSharedPrefLong(Constants.PREFS_LOGGED_IN_USER_ID); String userSysId = PrefManager.getSharedPref(CatalogueApplication.getContext(), PrefManager.PREFERENCE_SYS_ID);
// if (userId == -1) { if (userSysId == null || userSysId.isEmpty()) {
// OklahomaLog.e("NotificationInstanceIdService: sendRegistrationToServer: userId is -1."); CatalogueLog.e("NotificationInstanceIdService: sendRegistrationToServer: userSysId is null.");
// return; return;
// } }
//
// JsonObject deviceJsonObject = new JsonObject(); JSONObject deviceJsonObject = new JSONObject();
// deviceJsonObject.addProperty(Constants.POST_JSON_USER_ID, userId);
// deviceJsonObject.addProperty(Constants.POST_JSON_PUSH_NOTIFY_KEY, refreshedToken); try {
// deviceJsonObject.addProperty(Constants.POST_JSON_DEVICE_TYPE, Constants.DEVICE_TYPE); deviceJsonObject.put(UserApi.DEVICE_TOKEN, refreshedToken);
// deviceJsonObject.addProperty(Constants.POST_JSON_TEMP_DEVICE_ID, ""); } catch (JSONException e) {
// DeviceRegistrationApiManager.postDeviceRegistration(deviceJsonObject); CatalogueLog.e("NotificationInstanceIdService: JSONException: "+ e);
// } }
UserApiManager.putDeviceRegistration(CatalogueApplication.getContext(), userSysId, new PutDeviceRegistrationApiListener() {
@Override
public void onDoneApiCall() {
CatalogueLog.e("NotificationInstanceIdService: putDeviceRegistration: onDoneApiCall");
}
@Override
public void onFailApiCall() {
CatalogueLog.e("NotificationInstanceIdService: putDeviceRegistration: onFailApiCall");
}
});
}
} }
...@@ -11,12 +11,16 @@ import android.support.v4.content.LocalBroadcastManager; ...@@ -11,12 +11,16 @@ import android.support.v4.content.LocalBroadcastManager;
import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage; import com.google.firebase.messaging.RemoteMessage;
import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.R; import com.vsoft.servicenow.R;
import com.vsoft.servicenow.db.managers.NotificationsManager; import com.vsoft.servicenow.db.managers.NotificationsManager;
import com.vsoft.servicenow.db.models.Notifications; import com.vsoft.servicenow.db.models.Notifications;
import com.vsoft.servicenow.ui.NotificationScreen; import com.vsoft.servicenow.ui.NotificationScreen;
import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.Constants; import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.PrefManager;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Map; import java.util.Map;
...@@ -28,7 +32,10 @@ import java.util.Map; ...@@ -28,7 +32,10 @@ import java.util.Map;
public class NotificationMessagingService extends FirebaseMessagingService { public class NotificationMessagingService extends FirebaseMessagingService {
private static final String FCM_KEY_TITLE = "title"; private static final String FCM_KEY_TITLE = "title";
private static final String FCM_KEY_MESSAGE = "body"; private static final String FCM_KEY_BODY = "body";
private static final String FCM_KEY_PRIORITY = "priority";
private static final String FCM_KEY_SHORT_DESCRIPTION = "short_description";
private static final String FCM_KEY_CREATED_BY = "created_by";
/** /**
* This is default constructor of NotificationMessagingService. * This is default constructor of NotificationMessagingService.
...@@ -39,30 +46,37 @@ public class NotificationMessagingService extends FirebaseMessagingService { ...@@ -39,30 +46,37 @@ public class NotificationMessagingService extends FirebaseMessagingService {
@Override @Override
public void onMessageReceived(RemoteMessage remoteMessage) { public void onMessageReceived(RemoteMessage remoteMessage) {
// long userId = SharedPreferences String userSysId = PrefManager.getSharedPref(CatalogueApplication.getContext(), PrefManager.PREFERENCE_SYS_ID);
// .getSharedPrefLong(Constants.PREFS_LOGGED_IN_USER_ID); if (userSysId != null && !userSysId.isEmpty()) {
// if (userId != -1) {
CatalogueLog.e("RemoteMessage: "+remoteMessage.toString());
Map<String, String> dataMap = remoteMessage.getData(); Map<String, String> dataMap = remoteMessage.getData();
CatalogueLog.e("data: "+dataMap.toString());
String title = dataMap.get(FCM_KEY_TITLE); String title = dataMap.get(FCM_KEY_TITLE);
String message = dataMap.get(FCM_KEY_MESSAGE); String messageBody = dataMap.get(FCM_KEY_BODY);
String priority = null, shortDes = null, createdBy = null;
try {
JSONObject jsonObject = new JSONObject(messageBody);
priority = jsonObject.getString(FCM_KEY_PRIORITY);
shortDes = jsonObject.getString(FCM_KEY_SHORT_DESCRIPTION);
createdBy = jsonObject.getString(FCM_KEY_CREATED_BY);
} catch (JSONException e) {
e.printStackTrace();
}
Notifications newNotification = new Notifications(); Notifications newNotification = new Notifications();
newNotification.setTitle(title == null ? "" : title); newNotification.setTitle(title);
newNotification.setMessage(message); newNotification.setShortDescription(shortDes);
newNotification.setTime(System.currentTimeMillis()); newNotification.setPriority(priority);
newNotification.setCreated_by(createdBy);
NotificationsManager.save(newNotification); NotificationsManager.save(newNotification);
sendNotification(newNotification); sendNotification(newNotification);
sendLocalMessage(NotificationMessagingService.this, newNotification); sendLocalMessage(NotificationMessagingService.this, newNotification);
// } }
} }
private void sendLocalMessage(Context context, Notifications notifications) { private void sendLocalMessage(Context context, Notifications notifications) {
Intent intent = new Intent(Constants.BROADCAST_NOTIFICATION); Intent intent = new Intent(Constants.BROADCAST_NOTIFICATION);
intent.putExtra(Constants.DATA_KEY_NOTIFICATION_TITLE, notifications.getTitle()); intent.putExtra(Constants.DATA_KEY_NOTIFICATION_TITLE, notifications.getTitle());
intent.putExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE, notifications.getMessage()); intent.putExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE, notifications.getShortDescription());
LocalBroadcastManager.getInstance(context).sendBroadcast(intent); LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
} }
......
...@@ -44,7 +44,7 @@ import butterknife.OnClick; ...@@ -44,7 +44,7 @@ import butterknife.OnClick;
/** /**
* Created by Kunj on 11/8/16. * Created by Kunj on 11/8/16.
*/ */
public class CatalogueItemScreen extends AppCompatActivity { public class CatalogueItemScreen extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar; @BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.catalogue_item_screen_list_view) ListView mListView; @BindView(R.id.catalogue_item_screen_list_view) ListView mListView;
......
...@@ -41,7 +41,7 @@ import butterknife.OnClick; ...@@ -41,7 +41,7 @@ import butterknife.OnClick;
/** /**
* Created by Kunj on 11/8/16. * Created by Kunj on 11/8/16.
*/ */
public class CatalogueScreen extends AppCompatActivity { public class CatalogueScreen extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar; @BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.catalogue_screen_list_view) ListView mListView; @BindView(R.id.catalogue_screen_list_view) ListView mListView;
......
...@@ -108,7 +108,7 @@ import butterknife.OnClick; ...@@ -108,7 +108,7 @@ import butterknife.OnClick;
/** /**
* Created by Kunj on 11/8/16. * Created by Kunj on 11/8/16.
*/ */
public class CatalogueVariableScreen extends AppCompatActivity { public class CatalogueVariableScreen extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar; @BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.variable_screen_container_layout) LinearLayout mContainerLayout; @BindView(R.id.variable_screen_container_layout) LinearLayout mContainerLayout;
......
package com.vsoft.servicenow.ui;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import com.vsoft.servicenow.R;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.Util;
/**
* Created by chaukadev on 3/20/18.
*/
public class HandleNotificationActivity extends AppCompatActivity {
@Override
public void onResume() {
super.onResume();
LocalBroadcastManager.getInstance(HandleNotificationActivity.this)
.registerReceiver(mMessageReceiver,
new IntentFilter(Constants.BROADCAST_NOTIFICATION));
}
@Override
public void onPause() {
LocalBroadcastManager.getInstance(HandleNotificationActivity.this)
.unregisterReceiver(mMessageReceiver);
super.onPause();
}
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(HandleNotificationActivity.this);
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_notification_string,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startActivity(new Intent(HandleNotificationActivity.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();
}
};
}
...@@ -3,6 +3,7 @@ package com.vsoft.servicenow.ui; ...@@ -3,6 +3,7 @@ package com.vsoft.servicenow.ui;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
...@@ -13,12 +14,15 @@ import android.widget.EditText; ...@@ -13,12 +14,15 @@ import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.gms.analytics.Tracker; import com.google.android.gms.analytics.Tracker;
import com.vsoft.servicenow.api.interfaces.UserApi;
import com.vsoft.servicenow.api.listeners.get.GetUserDetailApiListener; import com.vsoft.servicenow.api.listeners.get.GetUserDetailApiListener;
import com.vsoft.servicenow.api.listeners.get.GetUserLoginApiListener; import com.vsoft.servicenow.api.listeners.get.GetUserLoginApiListener;
import com.vsoft.servicenow.api.listeners.put.PutDeviceRegistrationApiListener;
import com.vsoft.servicenow.api.managers.LoginApiManager; import com.vsoft.servicenow.api.managers.LoginApiManager;
import com.vsoft.servicenow.api.managers.UserApiManager; import com.vsoft.servicenow.api.managers.UserApiManager;
import com.vsoft.servicenow.api.pojos.LoginApiResponse; import com.vsoft.servicenow.api.pojos.LoginApiResponse;
import com.vsoft.servicenow.db.models.UserApiValues; import com.vsoft.servicenow.db.models.UserApiValues;
import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.Constants; import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.DialogUtils; import com.vsoft.servicenow.utils.DialogUtils;
import com.vsoft.servicenow.utils.KeyboardUtil; import com.vsoft.servicenow.utils.KeyboardUtil;
...@@ -27,6 +31,9 @@ import com.vsoft.servicenow.CatalogueApplication; ...@@ -27,6 +31,9 @@ import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.R; import com.vsoft.servicenow.R;
import com.vsoft.servicenow.utils.PrefManager; import com.vsoft.servicenow.utils.PrefManager;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List; import java.util.List;
import butterknife.BindView; import butterknife.BindView;
...@@ -151,8 +158,19 @@ public class LoginScreen extends Activity { ...@@ -151,8 +158,19 @@ public class LoginScreen extends Activity {
UserApiManager.getUserDetailResponse(LoginScreen.this, userName, new GetUserDetailApiListener() { UserApiManager.getUserDetailResponse(LoginScreen.this, userName, new GetUserDetailApiListener() {
@Override @Override
public void onDoneApiCall(List<UserApiValues> userValues) { public void onDoneApiCall(List<UserApiValues> userValues) {
apiStatus = API_SUCCESS_USER_DETAIL;
mUserDetails = userValues; mUserDetails = userValues;
UserApiManager.putDeviceRegistration(LoginScreen.this, userValues.get(0).getSysId(), new PutDeviceRegistrationApiListener() {
@Override
public void onDoneApiCall() {
apiStatus = API_SUCCESS_USER_DETAIL;
}
@Override
public void onFailApiCall() {
apiStatus = API_FAIL_USER_DETAIL;
}
});
} }
@Override @Override
......
...@@ -39,7 +39,7 @@ import butterknife.OnItemClick; ...@@ -39,7 +39,7 @@ import butterknife.OnItemClick;
/** /**
* Created by kunj on 30/8/16. * Created by kunj on 30/8/16.
*/ */
public class MyIncidentScreen extends AppCompatActivity { public class MyIncidentScreen extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar; @BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.my_incidents_screen_list_view) ListView mListView; @BindView(R.id.my_incidents_screen_list_view) ListView mListView;
......
...@@ -39,7 +39,7 @@ import butterknife.OnItemClick; ...@@ -39,7 +39,7 @@ import butterknife.OnItemClick;
/** /**
* Created by kvemulavada on 8/30/2016. * Created by kvemulavada on 8/30/2016.
*/ */
public class MyRequestActivity extends AppCompatActivity { public class MyRequestActivity extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar; @BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.request_screen_list_view) ListView mListView; @BindView(R.id.request_screen_list_view) ListView mListView;
......
...@@ -14,6 +14,7 @@ import android.support.v7.app.AppCompatActivity; ...@@ -14,6 +14,7 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
...@@ -48,6 +49,8 @@ public class NotificationScreen extends AppCompatActivity { ...@@ -48,6 +49,8 @@ public class NotificationScreen extends AppCompatActivity {
*/ */
@BindView(R.id.notification_screen_empty_text_view) @BindView(R.id.notification_screen_empty_text_view)
TextView mEmptyTextView; TextView mEmptyTextView;
@BindView(R.id.tool_bar_view)
Toolbar mToolbar;
private NotificationAdapter mAdapter; private NotificationAdapter mAdapter;
...@@ -67,16 +70,12 @@ public class NotificationScreen extends AppCompatActivity { ...@@ -67,16 +70,12 @@ public class NotificationScreen extends AppCompatActivity {
builder.setMessage(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE)) builder.setMessage(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_MESSAGE))
.setTitle(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_TITLE)) .setTitle(intent.getStringExtra(Constants.DATA_KEY_NOTIFICATION_TITLE))
.setCancelable(false) .setCancelable(false)
.setPositiveButton(R.string.go_to_notification_string, .setPositiveButton(R.string.ok_string,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
updateNotificationList(); updateNotificationList();
} }
})
.setNegativeButton(R.string.ok_string, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
updateNotificationList();
}
}); });
AlertDialog alert = builder.create(); AlertDialog alert = builder.create();
alert.show(); alert.show();
...@@ -91,13 +90,13 @@ public class NotificationScreen extends AppCompatActivity { ...@@ -91,13 +90,13 @@ public class NotificationScreen extends AppCompatActivity {
ButterKnife.bind(this); ButterKnife.bind(this);
final ActionBar actionBar = getSupportActionBar(); setSupportActionBar(mToolbar);
if (actionBar != null) { ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(getResources()
.getString(R.string.notification_screen_action_bar_title_string));
actionBar.setElevation(0); actionBar.setElevation(0);
actionBar.setDisplayShowHomeEnabled(true); actionBar.setTitle(R.string.notification_screen_action_bar_title_string);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowTitleEnabled(true);
} }
...@@ -153,14 +152,10 @@ public class NotificationScreen extends AppCompatActivity { ...@@ -153,14 +152,10 @@ public class NotificationScreen extends AppCompatActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem menuItem) {
// Handle item selection if (menuItem.getItemId() == android.R.id.home) {
switch (item.getItemId()) { finish();
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
} }
return super.onOptionsItemSelected(menuItem);
} }
} }
...@@ -37,7 +37,7 @@ import butterknife.OnClick; ...@@ -37,7 +37,7 @@ import butterknife.OnClick;
/** /**
* Created by kunj on 30/8/16. * Created by kunj on 30/8/16.
*/ */
public class ReportIncidentScreen extends AppCompatActivity { public class ReportIncidentScreen extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view) @BindView(R.id.tool_bar_view)
Toolbar mToolbar; Toolbar mToolbar;
......
...@@ -30,11 +30,14 @@ public class Constants { ...@@ -30,11 +30,14 @@ public class Constants {
public static final String DATA_KEY_CATALOGUE_ITEM_DESCRIPTION = "catalogue_item_des"; public static final String DATA_KEY_CATALOGUE_ITEM_DESCRIPTION = "catalogue_item_des";
public static final String DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION = "catalogue_item_short_des"; public static final String DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION = "catalogue_item_short_des";
public static final String DATA_KEY_CHAT_USER_NAME = "username"; public static final String DATA_KEY_CHAT_USER_NAME = "username";
public static final String DATA_KEY_NOTIFICATION_TITLE = "notification_title";
public static final String DATA_KEY_NOTIFICATION_MESSAGE = "notification_message";
/** /**
* Broadcast custom intent * Broadcast custom intent
*/ */
public static final String ACTION_SYNC = "action_sync"; public static final String ACTION_SYNC = "action_sync";
public static final String BROADCAST_NOTIFICATION = "broadcast_notification";
/** /**
* Broadcast custom intent * Broadcast custom intent
...@@ -146,6 +149,7 @@ public class Constants { ...@@ -146,6 +149,7 @@ public class Constants {
/*Login API */ /*Login API */
public static final String URL_POST_LOGIN_ITEM = "/oauth_token.do"; public static final String URL_POST_LOGIN_ITEM = "/oauth_token.do";
public static final String URL_REFRESH_LOGIN = URL_POST_LOGIN_ITEM; public static final String URL_REFRESH_LOGIN = URL_POST_LOGIN_ITEM;
public static final String URL_PUT_DEVICE_REGISTERATION = "api/now/table/sys_user/{user_sys_id}";
/*Catalogue Category API */ /*Catalogue Category API */
public static final String URL_GET_CATALOGUE = DOMAIN + AppConfig.URL_GET_CATALOGUE; public static final String URL_GET_CATALOGUE = DOMAIN + AppConfig.URL_GET_CATALOGUE;
...@@ -171,18 +175,4 @@ public class Constants { ...@@ -171,18 +175,4 @@ public class Constants {
/*Chat Activity*/ /*Chat Activity*/
public static final String CHAT_USER_API_URL = DOMAIN + URL_GET_USERDETAILS.substring(1); public static final String CHAT_USER_API_URL = DOMAIN + URL_GET_USERDETAILS.substring(1);
/**
* Broadcast String: broadcast notification.
*/
public static final String BROADCAST_NOTIFICATION = "broadcast_notification";
/**
* Intent String: Notification title.
*/
public static final String DATA_KEY_NOTIFICATION_TITLE = "notification_title";
/**
* Intent String: Notification message.
*/
public static final String DATA_KEY_NOTIFICATION_MESSAGE = "notification_message";
} }
...@@ -16,6 +16,7 @@ public interface DBConstants { ...@@ -16,6 +16,7 @@ public interface DBConstants {
String TABLE_UI_POLICY_ACTION = "ui_policy_action"; String TABLE_UI_POLICY_ACTION = "ui_policy_action";
String TABLE_CATALOGUE_ITEM_INPUT = "input_catalogue_item"; String TABLE_CATALOGUE_ITEM_INPUT = "input_catalogue_item";
String TABLE_ATTACHMENT = "attachment"; String TABLE_ATTACHMENT = "attachment";
String TABLE_NOTIFICATIONS = "notifications";
String ID = "_id"; String ID = "_id";
String SYS_ID = "sys_id"; String SYS_ID = "sys_id";
...@@ -345,45 +346,24 @@ public interface DBConstants { ...@@ -345,45 +346,24 @@ public interface DBConstants {
int ATTACHMENT_COLUMN_COUNT = 6; int ATTACHMENT_COLUMN_COUNT = 6;
/** /**
* Notification table name. * Notification table
*/
String TABLE_NOTIFICATIONS = "notifications";
/**
* NOTIFICATIONS_ID: Id column name for Notification table.
*/ */
String NOTIFICATIONS_ID = ID; String NOTIFICATIONS_ID = ID;
/**
* NOTIFICATIONS_TITLE: Time column name for Notification table.
*/
String NOTIFICATIONS_TITLE = "title"; String NOTIFICATIONS_TITLE = "title";
/** String NOTIFICATIONS_SHORT_DES = "short_des";
* NOTIFICATIONS_MESSAGE: Message column name for Notification table. String NOTIFICATIONS_PRIORITY = "priority";
*/ String NOTIFICATIONS_CREATED_BY = "created_by";
String NOTIFICATIONS_MESSAGE = "message";
/**
* NOTIFICATIONS_TIME: Time column name for Notification table.
*/
String NOTIFICATIONS_TIME = "time";
/** /**
* INDEX_NOTIFICATIONS_ID: Id indices for Notification table. * Notification table. *Use these only if you fetch all columns*
*/ */
int INDEX_NOTIFICATIONS_ID = 0; int INDEX_NOTIFICATIONS_ID = 0;
/**
* INDEX_NOTIFICATIONS_TITLE: Title indices for Notification table.
*/
int INDEX_NOTIFICATIONS_TITLE = 1; int INDEX_NOTIFICATIONS_TITLE = 1;
/** int INDEX_NOTIFICATIONS_SHORT_DES = 2;
* INDEX_NOTIFICATIONS_MESSAGE: Message indices for Notification table. int INDEX_NOTIFICATIONS_PRIORITY = 3;
*/ int INDEX_NOTIFICATIONS_CREATED_BY = 4;
int INDEX_NOTIFICATIONS_MESSAGE = 2;
/**
* INDEX_NOTIFICATIONS_TIME: Time indices for Notification table.
*/
int INDEX_NOTIFICATIONS_TIME = 3;
/** /**
* NOTIFICATIONS_COLUMN_COUNT: Total column count for notification table. * NOTIFICATIONS_COLUMN_COUNT: Total column count for notification table.
*/ */
int NOTIFICATIONS_COLUMN_COUNT = 4; int NOTIFICATIONS_COLUMN_COUNT = 5;
} }
\ No newline at end of file
...@@ -8,37 +8,39 @@ ...@@ -8,37 +8,39 @@
android:paddingRight="@dimen/normal_margin" android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/extra_large_margin"> android:paddingTop="@dimen/extra_large_margin">
<!--<ImageView
android:id="@+id/notification_adapter_delete_image_view"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/notification_delete"/>-->
<TextView <TextView
android:id="@+id/notification_adapter_title_text_view" android:id="@+id/notification_adapter_title_text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:layout_marginRight="@dimen/small_margin" android:layout_marginRight="@dimen/small_margin"
android:textColor="@android:color/white"
android:textSize="@dimen/extra_normal_text_size" /> android:textSize="@dimen/extra_normal_text_size" />
<TextView <TextView
android:id="@+id/notification_adapter_message_text_view" android:id="@+id/notification_adapter_short_des_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/notification_adapter_title_text_view" android:layout_below="@id/notification_adapter_title_text_view"
android:layout_marginTop="@dimen/small_margin"
android:textColor="@android:color/white"
android:textSize="@dimen/normal_text_size" />
<TextView
android:id="@+id/notification_adapter_priority_text_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/notification_adapter_short_des_text_view"
android:layout_marginTop="@dimen/small_margin" android:layout_marginTop="@dimen/small_margin"
android:textColor="@android:color/white"
android:textSize="@dimen/normal_text_size" /> android:textSize="@dimen/normal_text_size" />
<TextView <TextView
android:id="@+id/notification_adapter_date_text_view" android:id="@+id/notification_adapter_created_by_text_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/notification_adapter_message_text_view" android:layout_below="@id/notification_adapter_priority_text_view"
android:layout_alignParentRight="true"
android:layout_marginTop="@dimen/small_margin" android:layout_marginTop="@dimen/small_margin"
android:layout_centerVertical="true" android:textColor="@android:color/white"
android:textSize="@dimen/normal_text_size" /> android:textSize="@dimen/normal_text_size" />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
<merge <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_height="match_parent"> android:orientation="vertical">
<android.support.v7.widget.RecyclerView <include layout="@layout/toolbar" />
android:id="@+id/notification_recycle_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:divider="@color/list_divider_color"
android:dividerHeight="@dimen/list_divider_height"
android:scrollbars="vertical"/>
<TextView <FrameLayout
android:id="@+id/notification_screen_empty_text_view" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/colorPrimary" <android.support.v7.widget.RecyclerView
android:text="@string/notification_screen_empty_text_string" android:id="@+id/notification_recycle_view"
android:textSize="@dimen/normal_text_size" android:layout_width="match_parent"
android:gravity="center" android:layout_height="match_parent"
android:visibility="gone"/> android:background="@color/colorPrimary"
</merge> android:divider="@color/list_divider_color"
\ No newline at end of file android:dividerHeight="@dimen/list_divider_height"
android:scrollbars="vertical" />
<TextView
android:id="@+id/notification_screen_empty_text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:gravity="center"
android:text="@string/notification_screen_empty_text_string"
android:textSize="@dimen/normal_text_size"
android:visibility="gone" />
</FrameLayout>
</LinearLayout>
\ No newline at end of file
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
<color name="login_screen_login_button_background_color">@color/colorPrimaryDark</color> <color name="login_screen_login_button_background_color">@color/colorPrimaryDark</color>
<color name="login_screen_edit_text_background_color">@color/colorPrimaryDark</color> <color name="login_screen_edit_text_background_color">@color/colorPrimaryDark</color>
<!--Setting screen--> <!--Notification screen-->
<color name="list_divider_color">@color/light_gray</color> <color name="list_divider_color">@color/light_gray</color>
</resources> </resources>
...@@ -44,6 +44,6 @@ ...@@ -44,6 +44,6 @@
<dimen name="uofl_tool_bar_refresh_button_width">35dp</dimen> <dimen name="uofl_tool_bar_refresh_button_width">35dp</dimen>
<dimen name="uofl_tool_bar_refresh_button_height">35dp</dimen> <dimen name="uofl_tool_bar_refresh_button_height">35dp</dimen>
<!--Setting screen--> <!--Notification screen-->
<dimen name="list_divider_height">0.5dp</dimen> <dimen name="list_divider_height">0.5dp</dimen>
</resources> </resources>
\ No newline at end of file
...@@ -107,6 +107,5 @@ ...@@ -107,6 +107,5 @@
<!--Notifications--> <!--Notifications-->
<string name="notification_screen_action_bar_title_string">Notifications</string> <string name="notification_screen_action_bar_title_string">Notifications</string>
<string name="notification_screen_empty_text_string">No Notifications</string> <string name="notification_screen_empty_text_string">No Notifications</string>
<string name="notification_screen_delete_msg_string">Are you sure you want to delete?</string>
<string name="go_to_notification_string">Go to Notification</string> <string name="go_to_notification_string">Go to Notification</string>
</resources> </resources>
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