user name and password was change to as per requirement

parent 5a7d3502
...@@ -50,182 +50,182 @@ import butterknife.internal.Utils; ...@@ -50,182 +50,182 @@ import butterknife.internal.Utils;
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 userName; EditText userName;
@BindView(R.id.login_screen_password_edit_text) @BindView(R.id.errormessage)
EditText password; TextView errorMessage;
@BindView(R.id.login_scroll) @BindView(R.id.login_screen_password_edit_text)
ScrollView loginScrollview; EditText password;
private List<UserApiValues> mUserDetails; @BindView(R.id.login_scroll)
private PrefManager prefManager; ScrollView loginScrollview;
private String userNameStrng, passwordStrng; private List<UserApiValues> mUserDetails;
private String sysId; private PrefManager prefManager;
private String userNameStrng, passwordStrng;
@Override private String sysId;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub @Override
super.onCreate(savedInstanceState); protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_login); // TODO Auto-generated method stub
prefManager = PrefManager.getInstance(); super.onCreate(savedInstanceState);
prefManager.init(LoginScreen.this); setContentView(R.layout.activity_login);
ButterKnife.bind(this); prefManager = PrefManager.getInstance();
CheckLoginValues(); prefManager.init(LoginScreen.this);
ButterKnife.bind(this);
password.setOnKeyListener(new View.OnKeyListener() CheckLoginValues();
{
public boolean onKey(View v, int keyCode, KeyEvent event) password.setOnKeyListener(new View.OnKeyListener() {
{ 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) case KeyEvent.KEYCODE_DPAD_CENTER:
{ case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_DPAD_CENTER: callLoginAPI();
case KeyEvent.KEYCODE_ENTER: return true;
callLoginAPI(); default:
return true; break;
default: }
break; }
} return false;
} }
return false; });
}
}); KeyboardVisibilityEvent.setEventListener(LoginScreen.this, new KeyboardVisibilityEventListener() {
@Override
KeyboardVisibilityEvent.setEventListener(LoginScreen.this, new KeyboardVisibilityEventListener() { public void onVisibilityChanged(boolean isOpen) {
@Override if (isOpen) {
public void onVisibilityChanged(boolean isOpen) { loginScrollview.post(new Runnable() {
if (isOpen) { @Override
loginScrollview.post(new Runnable() { public void run() {
@Override loginScrollview.fullScroll(ScrollView.FOCUS_DOWN);
public void run() { }
loginScrollview.fullScroll(ScrollView.FOCUS_DOWN); });
} }
}); }
} });
}
}); CatalogueApplication application = (CatalogueApplication) getApplication();
Tracker tracker = application.getDefaultTracker();
CatalogueApplication application = (CatalogueApplication) getApplication(); // Send initial screen view hit.
Tracker tracker = application.getDefaultTracker(); Util.sendScreenName(tracker, getString(R.string.login_screen_string));
// Send initial screen view hit. }
Util.sendScreenName(tracker, getString(R.string.login_screen_string));
} private void CheckLoginValues() {
SharedPreferences sharedPreferences = getSharedPreferences(PrefManager.PREFERENCES_USER_VALUES_KEY, Context.MODE_PRIVATE);
private void CheckLoginValues() { sysId = sharedPreferences.getString(PrefManager.PREFERENCE_SYS_ID, "");
SharedPreferences sharedPreferences = getSharedPreferences(PrefManager.PREFERENCES_USER_VALUES_KEY, Context.MODE_PRIVATE); if (!TextUtils.isEmpty(sysId)) {
sysId = sharedPreferences.getString(PrefManager.PREFERENCE_SYS_ID, ""); startActivity(new Intent(LoginScreen.this, HomeScreen.class));
if (!TextUtils.isEmpty(sysId)) { finish();
startActivity(new Intent(LoginScreen.this, HomeScreen.class)); }
finish(); }
}
} private void callLoginAPI() {
userNameStrng = userName.getText().toString().trim();
private void callLoginAPI(){ passwordStrng = password.getText().toString().trim();
userNameStrng = userName.getText().toString().trim();
passwordStrng = password.getText().toString().trim(); if (TextUtils.isEmpty(userNameStrng)) {
userName.setError(getResources().getString(R.string.user_error));
if (TextUtils.isEmpty(userNameStrng)) { }
userName.setError(getResources().getString(R.string.user_error)); if (TextUtils.isEmpty(passwordStrng)) {
} password.setError(getResources().getString(R.string.pasw_error));
if (TextUtils.isEmpty(passwordStrng)) { }
password.setError(getResources().getString(R.string.pasw_error)); if (!TextUtils.isEmpty(userNameStrng) && !TextUtils.isEmpty(passwordStrng)) {
} KeyboardUtil.hideKeyboard(LoginScreen.this);
if (!TextUtils.isEmpty(userNameStrng) && !TextUtils.isEmpty(passwordStrng)) { boolean networkStatus = NetworkUtil.getConnectivityStatus(getApplicationContext());
KeyboardUtil.hideKeyboard(LoginScreen.this); if (networkStatus) {
boolean networkStatus = NetworkUtil.getConnectivityStatus(getApplicationContext()); new LoginDetailsSendToServer().execute(userName.getText().toString().trim(), password.getText().toString().trim());
if (networkStatus) { } else {
new LoginDetailsSendToServer().execute(userName.getText().toString().trim(), password.getText().toString().trim()); DialogUtils.showNoConnectionDialog(LoginScreen.this);
} else { }
DialogUtils.showNoConnectionDialog(LoginScreen.this); }
} }
}
} @OnClick(R.id.login_screen_login_text_view)
@OnClick(R.id.login_screen_login_text_view) void onLoginClicked() {
void onLoginClicked() { callLoginAPI();
//startActivity(new Intent(LoginScreen.this, HomeScreen.class)); }
callLoginAPI();
} private class LoginDetailsSendToServer extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog;
private class LoginDetailsSendToServer extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private String userName;
private String userName; @Override
protected void onPreExecute() {
@Override super.onPreExecute();
protected void onPreExecute() { progressDialog = new ProgressDialog(LoginScreen.this);
super.onPreExecute(); progressDialog.setMessage(getString(R.string.loading_string));
progressDialog = new ProgressDialog(LoginScreen.this); progressDialog.show();
progressDialog.setMessage(getString(R.string.loading_string)); progressDialog.setCancelable(false);
progressDialog.show(); }
progressDialog.setCancelable(false);
} @Override
protected SyncStatus doInBackground(String... params) {
@Override userName = params[0];//"a0kuma18";
protected SyncStatus doInBackground(String... params) { String password = params[1];//"v$0ftA$win";
userName = params[0];//"a0kuma18"; return LoginApiManger.submitLoginValues(Constants.GRANT_TYPE, Constants.CLIENT_ID, Constants
String password = params[1];//"v$0ftA$win"; .CLIENT_SECRET, userName,
return LoginApiManger.submitLoginValues(Constants.GRANT_TYPE, Constants.CLIENT_ID, Constants password);
.CLIENT_SECRET, userName, }
password);
} @Override
protected void onPostExecute(SyncStatus syncStatus) {
@Override super.onPostExecute(syncStatus);
protected void onPostExecute(SyncStatus syncStatus) { if (progressDialog != null && progressDialog.isShowing()) {
super.onPostExecute(syncStatus); progressDialog.dismiss();
if (progressDialog != null && progressDialog.isShowing()) { }
progressDialog.dismiss(); if (syncStatus == SyncStatus.SUCCESS) {
} new UserApiDetails().execute(userName);
if (syncStatus == SyncStatus.SUCCESS) { } else {
new UserApiDetails().execute(userName); errorMessage.setVisibility(View.VISIBLE);
} else { errorMessage.setText("Invalid username and password");
Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show(); //Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show();
} }
} }
private class UserApiDetails extends AsyncTask<String, Void, SyncStatus> { private class UserApiDetails extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
progressDialog = new ProgressDialog(LoginScreen.this); progressDialog = new ProgressDialog(LoginScreen.this);
progressDialog.setMessage(getString(R.string.loading_string)); progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show(); progressDialog.show();
progressDialog.setCancelable(false); progressDialog.setCancelable(false);
} }
@Override @Override
protected SyncStatus doInBackground(String... params) { protected SyncStatus doInBackground(String... params) {
String userName = params[0]; String userName = params[0];
return UserApiManager.getUserDetailResponse(userName, new GetUserApiListener() { return UserApiManager.getUserDetailResponse(userName, new GetUserApiListener() {
@Override @Override
public void onDoneApiCall(List<UserApiValues> userValues) { public void onDoneApiCall(List<UserApiValues> userValues) {
mUserDetails = userValues; mUserDetails = userValues;
} }
}); });
} }
@Override @Override
protected void onPostExecute(SyncStatus syncStatus) { protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus); super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) { if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss(); progressDialog.dismiss();
} }
if (syncStatus == SyncStatus.SUCCESS) { if (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 lasrname = 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, lasrname, sysid);
startActivity(new Intent(LoginScreen.this, HomeScreen.class)); startActivity(new Intent(LoginScreen.this, HomeScreen.class));
finish(); finish();
} }
} }
} }
} }
} }
/*private void showErrorDialog(int message) { /*private void showErrorDialog(int message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message) builder.setMessage(message)
.setCancelable(false) .setCancelable(false)
......
package com.vsoft.uoflservicenow.utils; package com.vsoft.uoflservicenow.utils;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import com.vsoft.uoflservicenow.R; import com.vsoft.uoflservicenow.R;
/** /**
* Created by npadhy on 9/7/2016. * Created by krishna on 9/7/2016.
*/ */
public class DialogUtils { public class DialogUtils {
private static AlertDialog alertDialog; public static void showNoConnectionDialog(final Activity activity) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
new ContextThemeWrapper(activity,
public static void showNoConnectionDialog(final Activity activity) { android.R.style.Theme_Holo));
try { alertDialogBuilder.setTitle(activity
activity.runOnUiThread(new Runnable() { .getString(R.string.connection_alert_dialog_title));
alertDialogBuilder
@Override .setMessage(R.string.connection_alert_dialog_message)
public void run() { .setCancelable(true)
if (alertDialog == null) { .setPositiveButton(
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( activity.getString(R.string.settings),
new ContextThemeWrapper(activity, new DialogInterface.OnClickListener() {
android.R.style.Theme_Holo)); @Override
alertDialogBuilder.setTitle(activity public void onClick(
.getString(R.string.connection_alert_dialog_title)); DialogInterface dialog,
alertDialogBuilder int id) {
.setMessage(R.string.connection_alert_dialog_message) activity.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
.setCancelable(true) }
.setPositiveButton( })
activity.getString(R.string.settings), .setNegativeButton(
new DialogInterface.OnClickListener() { activity.getString(R.string.cancel),
@Override new DialogInterface.OnClickListener() {
public void onClick( @Override
DialogInterface dialog, public void onClick(DialogInterface dialog,int which) {
int id) { }
activity });
.startActivity(new Intent( AlertDialog alertDialog = alertDialogBuilder.create();
android.provider.Settings.ACTION_SETTINGS)); alertDialog.show();
alertDialog = null; }
}
})
.setNegativeButton(
activity.getString(R.string.cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
alertDialog = null;
}
});
alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}
});
} catch (Exception e) {
}
}
} }
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" android:layout_marginRight="20dp"
android:padding="10dp" android:padding="10dp"
android:text=""
android:drawableLeft="@mipmap/ic_user_icon" android:drawableLeft="@mipmap/ic_user_icon"
android:singleLine="true" /> android:singleLine="true" />
<EditText <EditText
...@@ -47,7 +46,6 @@ ...@@ -47,7 +46,6 @@
android:drawableLeft="@mipmap/ic_password_icon" android:drawableLeft="@mipmap/ic_password_icon"
android:inputType="textPassword" android:inputType="textPassword"
android:padding="10dp" android:padding="10dp"
android:text=""
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" android:layout_marginRight="20dp"
android:singleLine="true" /> android:singleLine="true" />
...@@ -68,6 +66,19 @@ ...@@ -68,6 +66,19 @@
android:text="@string/login_screen_login_string" android:text="@string/login_screen_login_string"
android:textAlignment="center" /> 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>
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
card_view:cardBackgroundColor="@color/item_gb_color" card_view:cardBackgroundColor="@color/item_gb_color"
card_view:cardCornerRadius="8dp" card_view:cardCornerRadius="8dp"
card_view:cardElevation="3sp" card_view:cardElevation="10dp"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true"
>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
<string name="rejected">Rejected</string> <string name="rejected">Rejected</string>
<string name="user_error">Please Enter UserName</string> <string name="user_error">Please enter username</string>
<string name="pasw_error">Please Enter Password</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>
......
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