Commit 49e2e455 by Kunj Gupta

Fix - conflict issues.

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