Commit 49e2e455 by Kunj Gupta

Fix - conflict issues.

parent 03b97a19
......@@ -62,7 +62,6 @@ dependencies {
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:1.0.1'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
......
......@@ -28,6 +28,7 @@ import com.vsoft.uoflservicenow.db.models.Reference;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.listeners.ReferenceListener;
import com.vsoft.uoflservicenow.utils.Constants;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.Util;
import java.util.ArrayList;
......@@ -145,7 +146,7 @@ public class SelectReferenceDialog extends DialogFragment {
if(mApplication.isNetConnected()) {
new FetchReference().execute(mEditText.getText().toString());
} else {
showErrorDialog(R.string.internet_validation_string);
DialogUtils.showNoConnectionDialogWithCloseActivity(getActivity());
}
}
return false;
......
......@@ -25,6 +25,7 @@ import com.vsoft.uoflservicenow.db.models.CatalogueItem;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.Util;
import java.util.List;
......@@ -77,7 +78,7 @@ public class CatalogueItemScreen extends AppCompatActivity {
if(application.isNetConnected()) {
new FetchCatalogueItem().execute();
} else {
showErrorDialog(R.string.internet_validation_string);
DialogUtils.showNoConnectionDialogWithCloseActivity(CatalogueItemScreen.this);
}
}
......
......@@ -24,6 +24,7 @@ import com.vsoft.uoflservicenow.db.models.Catalogue;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.Util;
import java.util.List;
......@@ -68,7 +69,7 @@ public class CatalogueScreen extends AppCompatActivity {
if(application.isNetConnected()) {
new FetchCatalogue().execute();
} else {
showErrorDialog(R.string.internet_validation_string);
DialogUtils.showNoConnectionDialogWithCloseActivity(CatalogueScreen.this);
}
}
......
......@@ -43,6 +43,7 @@ import com.vsoft.uoflservicenow.listeners.ReferenceListener;
import com.vsoft.uoflservicenow.ui.supportviews.DateAndTimePickerFragment;
import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.TagObject;
import com.vsoft.uoflservicenow.utils.Util;
......@@ -113,7 +114,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
if(mApplication.isNetConnected()) {
new FetchCatalogueVariable().execute();
} else {
showErrorDialog(R.string.internet_validation_string);
DialogUtils.showNoConnectionDialogWithCloseActivity(CatalogueVariableScreen.this);
}
}
......@@ -394,7 +395,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
if(mApplication.isNetConnected()) {
new SubmitForm().execute();
} else {
showErrorDialog(R.string.internet_validation_string);
DialogUtils.showNoConnectionDialogWithCloseActivity(CatalogueVariableScreen.this);
}
}
......
......@@ -12,8 +12,6 @@ import com.google.android.gms.analytics.Tracker;
import com.vsoft.uoflservicenow.CatalogueApplication;
import com.vsoft.uoflservicenow.R;
import com.vsoft.uoflservicenow.adapters.HomeScreenAdapter;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.NetworkUtil;
import com.vsoft.uoflservicenow.utils.Util;
import butterknife.BindView;
......@@ -24,10 +22,8 @@ import butterknife.OnItemClick;
* Created by Kunj on 11/8/16.
*/
public class HomeScreen extends AppCompatActivity {
@BindView(R.id.tool_bar_view)
Toolbar mToolbar;
@BindView(R.id.home_screen_grid_view)
GridView mGridView;
@BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.home_screen_grid_view) GridView mGridView;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -59,31 +55,14 @@ public class HomeScreen extends AppCompatActivity {
@OnItemClick(R.id.home_screen_grid_view)
void gridViewItemClicked(int position) {
boolean networkStatus = NetworkUtil.getConnectivityStatus(getApplicationContext());
if (position == 0) {
if (networkStatus) {
startActivity(new Intent(HomeScreen.this, ReportIncidentScreen.class));
} else {
DialogUtils.showNoConnectionDialog(HomeScreen.this);
}
} else if (position == 1) {
if (networkStatus) {
startActivity(new Intent(HomeScreen.this, CatalogueScreen.class));
} else {
DialogUtils.showNoConnectionDialog(HomeScreen.this);
}
} else if (position == 2) {
if (networkStatus) {
startActivity(new Intent(HomeScreen.this, MyIncidentScreen.class));
} else {
DialogUtils.showNoConnectionDialog(HomeScreen.this);
}
} else if (position == 3) {
if (networkStatus) {
startActivity(new Intent(HomeScreen.this, MyRequestActivity.class));
} else {
DialogUtils.showNoConnectionDialog(HomeScreen.this);
}
}
}
}
......@@ -3,7 +3,6 @@ package com.vsoft.uoflservicenow.ui;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
......@@ -12,8 +11,6 @@ import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.analytics.Tracker;
......@@ -27,49 +24,40 @@ import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.Constants;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.KeyboardUtil;
import com.vsoft.uoflservicenow.utils.NetworkUtil;
import com.vsoft.uoflservicenow.utils.PrefManager;
import com.vsoft.uoflservicenow.utils.Util;
import net.yslibrary.android.keyboardvisibilityevent.KeyboardVisibilityEvent;
import net.yslibrary.android.keyboardvisibilityevent.KeyboardVisibilityEventListener;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.internal.Utils;
/**
* Created by Kunj on 11/8/16.
*/
public class LoginScreen extends Activity {
@BindView(R.id.login_screen_username_edit_text)
EditText userName;
@BindView(R.id.errormessage)
TextView errorMessage;
@BindView(R.id.login_screen_password_edit_text)
EditText password;
@BindView(R.id.login_scroll)
ScrollView loginScrollview;
@BindView(R.id.login_screen_username_edit_text) EditText mUserNameEditText;
@BindView(R.id.login_screen_password_edit_text) EditText mPasswordEditText;
private List<UserApiValues> mUserDetails;
private PrefManager prefManager;
private String userNameStrng, passwordStrng;
private String sysId;
private CatalogueApplication mApplication;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
prefManager = PrefManager.getInstance();
prefManager.init(LoginScreen.this);
ButterKnife.bind(this);
mApplication = (CatalogueApplication) getApplication();
PrefManager prefManager = PrefManager.getInstance();
prefManager.init(LoginScreen.this);
CheckLoginValues();
password.setOnKeyListener(new View.OnKeyListener() {
mPasswordEditText.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
......@@ -85,20 +73,6 @@ public class LoginScreen extends Activity {
}
});
KeyboardVisibilityEvent.setEventListener(LoginScreen.this, new KeyboardVisibilityEventListener() {
@Override
public void onVisibilityChanged(boolean isOpen) {
if (isOpen) {
loginScrollview.post(new Runnable() {
@Override
public void run() {
loginScrollview.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
}
});
CatalogueApplication application = (CatalogueApplication) getApplication();
Tracker tracker = application.getDefaultTracker();
Util.sendScreenName(tracker, getString(R.string.login_screen_string));
......@@ -106,7 +80,7 @@ public class LoginScreen extends Activity {
private void CheckLoginValues() {
SharedPreferences sharedPreferences = getSharedPreferences(PrefManager.PREFERENCES_USER_VALUES_KEY, Context.MODE_PRIVATE);
sysId = sharedPreferences.getString(PrefManager.PREFERENCE_SYS_ID, "");
String sysId = sharedPreferences.getString(PrefManager.PREFERENCE_SYS_ID, "");
if (!TextUtils.isEmpty(sysId)) {
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
finish();
......@@ -114,20 +88,19 @@ public class LoginScreen extends Activity {
}
private void callLoginAPI() {
userNameStrng = userName.getText().toString().trim();
passwordStrng = password.getText().toString().trim();
String userNameString = mUserNameEditText.getText().toString().trim();
String passwordString = mPasswordEditText.getText().toString().trim();
if (TextUtils.isEmpty(userNameStrng)) {
userName.setError(getResources().getString(R.string.user_error));
if (TextUtils.isEmpty(userNameString)) {
mUserNameEditText.setError(getResources().getString(R.string.user_error));
}
if (TextUtils.isEmpty(passwordStrng)) {
password.setError(getResources().getString(R.string.pasw_error));
if (TextUtils.isEmpty(passwordString)) {
mPasswordEditText.setError(getResources().getString(R.string.pasw_error));
}
if (!TextUtils.isEmpty(userNameStrng) && !TextUtils.isEmpty(passwordStrng)) {
if (!TextUtils.isEmpty(userNameString) && !TextUtils.isEmpty(passwordString)) {
KeyboardUtil.hideKeyboard(LoginScreen.this);
boolean networkStatus = NetworkUtil.getConnectivityStatus(getApplicationContext());
if (networkStatus) {
new LoginDetailsSendToServer().execute(userName.getText().toString().trim(), password.getText().toString().trim());
if (mApplication.isNetConnected()) {
new LoginDetailsSendToServer().execute(mUserNameEditText.getText().toString().trim(), mPasswordEditText.getText().toString().trim());
} else {
DialogUtils.showNoConnectionDialog(LoginScreen.this);
}
......@@ -180,16 +153,15 @@ public class LoginScreen extends Activity {
}
if (syncStatus != null && syncStatus == SyncStatus.SUCCESS) {
if (mUserDetails != null) {
String firstname = mUserDetails.get(0).getFirstName();
String lasrname = mUserDetails.get(0).getLastName();
String firstName = mUserDetails.get(0).getFirstName();
String lastName = mUserDetails.get(0).getLastName();
String sysid = mUserDetails.get(0).getSysId();
PrefManager.saveUserDetailsInPreferences(LoginScreen.this, firstname, lasrname, sysid);
PrefManager.saveUserDetailsInPreferences(LoginScreen.this, firstName, lastName, sysid);
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
finish();
}
} else {
errorMessage.setVisibility(View.VISIBLE);
errorMessage.setText("Invalid username and password");
Toast.makeText(LoginScreen.this, R.string.login_screen_invalid_usernane_and_password_string, Toast.LENGTH_LONG).show();
}
}
}
......
......@@ -20,6 +20,7 @@ import com.vsoft.uoflservicenow.api.managers.IncidentApiManager;
import com.vsoft.uoflservicenow.db.models.Incident;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.Util;
import java.util.Collections;
......@@ -67,7 +68,7 @@ public class MyIncidentScreen extends AppCompatActivity {
if(application.isNetConnected()) {
new FetchIncident().execute();
} else {
showErrorDialog(R.string.internet_validation_string);
DialogUtils.showNoConnectionDialogWithCloseActivity(MyIncidentScreen.this);
}
}
......
......@@ -19,12 +19,13 @@ import com.vsoft.uoflservicenow.api.listeners.get.GetMyRequestApiListener;
import com.vsoft.uoflservicenow.api.managers.MyRequestApiManager;
import com.vsoft.uoflservicenow.db.models.MyRequest;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.Util;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by kvemulavada on 8/30/2016.
......@@ -63,7 +64,7 @@ public class MyRequestActivity extends AppCompatActivity {
if(application.isNetConnected()) {
new FetchMyRequestData().execute();
} else {
showErrorDialog(R.string.internet_validation_string);
DialogUtils.showNoConnectionDialogWithCloseActivity(MyRequestActivity.this);
}
}
class FetchMyRequestData extends AsyncTask<String, Void, SyncStatus> {
......
......@@ -25,6 +25,7 @@ import com.vsoft.uoflservicenow.api.managers.IncidentApiManager;
import com.vsoft.uoflservicenow.db.models.Incident;
import com.vsoft.uoflservicenow.enums.Impact;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.PrefManager;
import com.vsoft.uoflservicenow.utils.Util;
......@@ -101,7 +102,7 @@ public class ReportIncidentScreen extends AppCompatActivity {
}
}
} else {
showErrorDialog(R.string.internet_validation_string);
DialogUtils.showNoConnectionDialogWithCloseActivity(ReportIncidentScreen.this);
}
}
......
package com.vsoft.uoflservicenow.utils;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.view.ContextThemeWrapper;
import com.vsoft.uoflservicenow.R;
......@@ -12,33 +12,50 @@ import com.vsoft.uoflservicenow.R;
* Created by krishna on 9/7/2016.
*/
public class DialogUtils {
public static void showNoConnectionDialog(final Activity activity) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
new ContextThemeWrapper(activity,
android.R.style.Theme_Holo));
alertDialogBuilder.setTitle(activity
.getString(R.string.connection_alert_dialog_title));
alertDialogBuilder
.setMessage(R.string.connection_alert_dialog_message)
public static void showNoConnectionDialog(final Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getString(R.string.connection_alert_dialog_title));
builder.setMessage(R.string.connection_alert_dialog_message)
.setCancelable(true)
.setPositiveButton(
activity.getString(R.string.settings),
.setPositiveButton(context.getString(R.string.settings),
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int id) {
activity.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
public void onClick(DialogInterface dialog, int id) {
context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
}
})
.setNegativeButton(
activity.getString(R.string.cancel),
.setNegativeButton(context.getString(R.string.cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int which) {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
AlertDialog alert = builder.create();
alert.show();
}
public static void showNoConnectionDialogWithCloseActivity(final Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getString(R.string.connection_alert_dialog_title));
builder.setMessage(R.string.connection_alert_dialog_message)
.setCancelable(false)
.setPositiveButton(context.getString(R.string.settings),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
((Activity)context).finish();
}
})
.setNegativeButton(context.getString(R.string.cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((Activity)context).finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
package com.vsoft.uoflservicenow.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
* Created by npadhy on 9/7/2016.
*/
public class NetworkUtil {
/**
* getConnectivityStatus
*
* @param context
* @return
*/
public static boolean getConnectivityStatus(Context context) {
boolean networkFlag = false;
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
if (null != activeNetwork) {
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
networkFlag = true;
return networkFlag;
}
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
networkFlag = true;
return networkFlag;
}
}
return networkFlag;
}
}
......@@ -26,8 +26,8 @@
android:id="@+id/login_screen_username_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:background="@drawable/username_under_bg_box"
android:drawableLeft="@mipmap/ic_user_icon"
android:hint="Username"
......@@ -53,32 +53,17 @@
android:id="@+id/login_screen_login_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textColor="@color/white"
android:gravity="center"
android:layout_marginTop="@dimen/normal_margin"
android:layout_marginBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/normal_margin"
android:textColor="@android:color/white"
android:background="@drawable/login_bg"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:textSize="@dimen/large_text_size"
android:text="@string/login_screen_login_string"
android:textAlignment="center" />
<TextView
android:id="@+id/errormessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textColor="@color/error_color"
android:textSize="@dimen/small_text_size"
android:text=""
android:gravity="center"
android:visibility="gone"
android:layout_gravity="center_horizontal"
/>
android:text="@string/login_screen_login_string"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -11,7 +11,6 @@
<color name="home_screen_bg_color">@color/colorPrimary</color>
<color name="white">#ffffff</color>
<color name="screen_bg_color">#c2d1d3</color>
<color name="bg_border_color">#d6d6d6</color>
......
......@@ -7,7 +7,6 @@
<string name="error_string">* Required</string>
<string name="none_string">-None-</string>
<string name="search_for_reference_string">Reference</string>
<string name="internet_validation_string">Please connect to internet and try again.</string>
<string name="home_screen_string">Home Screen</string>
<string name="login_screen_string">Login Screen</string>
......@@ -23,10 +22,6 @@
<string name="requested">Requested</string>
<string name="rejected">Rejected</string>
<string name="user_error">Please enter username</string>
<string name="pasw_error">Please enter password</string>
<string name="date_string">%1$s %2$s, %3$s</string>
<string name="date_and_time_string"> %1$s:%2$s</string>
......@@ -40,6 +35,9 @@
<!--Login Screen-->
<string name="login_screen_login_string">Login</string>
<string name="login_screen_invalid_usernane_and_password_string">Invalid UserName and Password</string>
<string name="user_error">Please Enter UserName</string>
<string name="pasw_error">Please Enter Password</string>
<!--Variable Screen-->
<string name="variable_form_misc_info_string">%1$s [add %2$s]</string>
......
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