Commit 2f329ed7 by npadhy

login in keyboard hiden

parent a465a9a0
...@@ -34,7 +34,7 @@ android { ...@@ -34,7 +34,7 @@ android {
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 24 targetSdkVersion 24
versionCode 1 versionCode 1
versionName "0.0.5" versionName "0.0.6"
multiDexEnabled true multiDexEnabled true
} }
buildTypes { buildTypes {
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
android:name="com.vsoft.uoflservicenow.ui.LoginScreen" android:name="com.vsoft.uoflservicenow.ui.LoginScreen"
android:label="@string/app_name" android:label="@string/app_name"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan"> android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
......
...@@ -8,6 +8,8 @@ import android.content.SharedPreferences; ...@@ -8,6 +8,8 @@ import android.content.SharedPreferences;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.Toast; import android.widget.Toast;
...@@ -20,6 +22,7 @@ import com.vsoft.uoflservicenow.api.managers.LoginApiManger; ...@@ -20,6 +22,7 @@ import com.vsoft.uoflservicenow.api.managers.LoginApiManger;
import com.vsoft.uoflservicenow.api.managers.UserApiManager; import com.vsoft.uoflservicenow.api.managers.UserApiManager;
import com.vsoft.uoflservicenow.db.models.UserApiValues; import com.vsoft.uoflservicenow.db.models.UserApiValues;
import com.vsoft.uoflservicenow.enums.SyncStatus; import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.KeyboardUtil;
import com.vsoft.uoflservicenow.utils.PrefManager; import com.vsoft.uoflservicenow.utils.PrefManager;
import com.vsoft.uoflservicenow.utils.Util; import com.vsoft.uoflservicenow.utils.Util;
...@@ -38,150 +41,153 @@ import butterknife.OnClick; ...@@ -38,150 +41,153 @@ import butterknife.OnClick;
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.login_screen_password_edit_text)
EditText password; EditText password;
@BindView(R.id.login_scroll) @BindView(R.id.login_scroll)
ScrollView loginScrollview; ScrollView loginScrollview;
private List<UserApiValues> mUserDetails; private List<UserApiValues> mUserDetails;
private PrefManager prefManager; private PrefManager prefManager;
private String userNameStrng,passwordStrng; private String userNameStrng, passwordStrng;
private String firstName,lastName,sysId; private String firstName, lastName, sysId;
@Override private boolean isShow;
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);
KeyboardVisibilityEvent.setEventListener(LoginScreen.this, new KeyboardVisibilityEventListener() { // CheckLoginValues();
@Override
public void onVisibilityChanged(boolean isOpen) { KeyboardVisibilityEvent.setEventListener(LoginScreen.this, new KeyboardVisibilityEventListener() {
if (isOpen) { @Override
loginScrollview.post(new Runnable() { public void onVisibilityChanged(boolean isOpen) {
@Override if (isOpen) {
public void run() { loginScrollview.post(new Runnable() {
loginScrollview.fullScroll(ScrollView.FOCUS_DOWN); @Override
} public void run() {
}); loginScrollview.fullScroll(ScrollView.FOCUS_DOWN);
} }
} });
}); }
}
CatalogueApplication application = (CatalogueApplication) getApplication(); });
Tracker tracker = application.getDefaultTracker();
// Send initial screen view hit. CatalogueApplication application = (CatalogueApplication) getApplication();
Util.sendScreenName(tracker, getString(R.string.login_screen_string)); Tracker tracker = application.getDefaultTracker();
} // 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);
sysId = sharedPreferences.getString(PrefManager.PREFERENCE_SYS_ID, ""); private void CheckLoginValues() {
if(!TextUtils.isEmpty(sysId)){ SharedPreferences sharedPreferences = getSharedPreferences(PrefManager.PREFERENCES_USER_VALUES_KEY, Context.MODE_PRIVATE);
startActivity(new Intent(LoginScreen.this, HomeScreen.class)); sysId = sharedPreferences.getString(PrefManager.PREFERENCE_SYS_ID, "");
finish(); if (!TextUtils.isEmpty(sysId)) {
} startActivity(new Intent(LoginScreen.this, HomeScreen.class));
} finish();
}
@OnClick(R.id.login_screen_login_text_view) }
void onLoginClicked() {
//startActivity(new Intent(LoginScreen.this, HomeScreen.class)); @OnClick(R.id.login_screen_login_text_view)
userNameStrng=userName.getText().toString().trim(); void onLoginClicked() {
passwordStrng=password.getText().toString().trim(); //startActivity(new Intent(LoginScreen.this, HomeScreen.class));
userNameStrng = userName.getText().toString().trim();
if(TextUtils.isEmpty(userNameStrng)) { passwordStrng = password.getText().toString().trim();
userName.setError(getResources().getString (R.string.user_error));
return; if (TextUtils.isEmpty(userNameStrng)) {
}
else if(!TextUtils.isEmpty(userNameStrng) && !TextUtils.isEmpty(passwordStrng)){ userName.setError(getResources().getString(R.string.user_error));
return;
new LoginDetailsSendToServer().execute(userName.getText().toString().trim(), password.getText().toString().trim()); } else if (!TextUtils.isEmpty(userNameStrng) && !TextUtils.isEmpty(passwordStrng)) {
} KeyboardUtil.hideKeyboard(LoginScreen.this);
} new LoginDetailsSendToServer().execute(userName.getText().toString().trim(), password.getText().toString().trim());
}
class LoginDetailsSendToServer extends AsyncTask<String, Void, SyncStatus> { }
private ProgressDialog progressDialog;
class LoginDetailsSendToServer extends AsyncTask<String, Void, SyncStatus> {
private String userName; private ProgressDialog progressDialog;
@Override
protected void onPreExecute() { private String userName;
super.onPreExecute();
progressDialog = new ProgressDialog(LoginScreen.this); @Override
progressDialog.setMessage(getString(R.string.loading_string)); protected void onPreExecute() {
progressDialog.show(); super.onPreExecute();
progressDialog.setCancelable(false); progressDialog = new ProgressDialog(LoginScreen.this);
} progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
@Override progressDialog.setCancelable(false);
protected SyncStatus doInBackground(String... params) { }
String grantType = "password";
String clientId = "ac0dd3408c1031006907010c2cc6ef6d"; @Override
String clientSecret = "oklj6znxv3o9jmyn2mlp"; protected SyncStatus doInBackground(String... params) {
userName = params[0];//"a0kuma18"; String grantType = "password";
String password = params[1];//"v$0ftA$win"; String clientId = "ac0dd3408c1031006907010c2cc6ef6d";
return LoginApiManger.submitLoginValues(grantType, clientId, clientSecret, userName, password); String clientSecret = "oklj6znxv3o9jmyn2mlp";
} userName = params[0];//"a0kuma18";
String password = params[1];//"v$0ftA$win";
@Override return LoginApiManger.submitLoginValues(grantType, clientId, clientSecret, userName, password);
protected void onPostExecute(SyncStatus syncStatus) { }
super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) { @Override
progressDialog.dismiss(); protected void onPostExecute(SyncStatus syncStatus) {
} super.onPostExecute(syncStatus);
if (syncStatus == SyncStatus.SUCCESS) { if (progressDialog != null && progressDialog.isShowing()) {
new UserApiDetails().execute(userName); progressDialog.dismiss();
} else { }
Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show(); if (syncStatus == SyncStatus.SUCCESS) {
} new UserApiDetails().execute(userName);
} } else {
Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show();
class UserApiDetails extends AsyncTask<String, Void, SyncStatus> { }
private ProgressDialog progressDialog; }
@Override class UserApiDetails extends AsyncTask<String, Void, SyncStatus> {
protected void onPreExecute() { private ProgressDialog progressDialog;
super.onPreExecute();
progressDialog = new ProgressDialog(LoginScreen.this); @Override
progressDialog.setMessage(getString(R.string.loading_string)); protected void onPreExecute() {
progressDialog.show(); super.onPreExecute();
progressDialog.setCancelable(false); progressDialog = new ProgressDialog(LoginScreen.this);
} progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
@Override progressDialog.setCancelable(false);
protected SyncStatus doInBackground(String... params) { }
String userName=params[0];
return UserApiManager.getUserDetailResponse(userName,new GetUserApiListener() { @Override
@Override protected SyncStatus doInBackground(String... params) {
public void onDoneApiCall(List<UserApiValues> userValues) { String userName = params[0];
mUserDetails = userValues; return UserApiManager.getUserDetailResponse(userName, new GetUserApiListener() {
} @Override
}); public void onDoneApiCall(List<UserApiValues> userValues) {
} mUserDetails = userValues;
}
@Override });
protected void onPostExecute(SyncStatus syncStatus) { }
super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) { @Override
progressDialog.dismiss(); protected void onPostExecute(SyncStatus syncStatus) {
} super.onPostExecute(syncStatus);
if (syncStatus == SyncStatus.SUCCESS) { if (progressDialog != null && progressDialog.isShowing()) {
if (mUserDetails != null) { progressDialog.dismiss();
String firstname=mUserDetails.get(0).getFirstName(); }
String lasrname=mUserDetails.get(0).getLastName(); if (syncStatus == SyncStatus.SUCCESS) {
String sysid=mUserDetails.get(0).getSysId(); if (mUserDetails != null) {
PrefManager.saveUserDetailsInPreferences(LoginScreen.this, firstname, lasrname, sysid); String firstname = mUserDetails.get(0).getFirstName();
startActivity(new Intent(LoginScreen.this, HomeScreen.class)); String lasrname = mUserDetails.get(0).getLastName();
finish(); String sysid = mUserDetails.get(0).getSysId();
} PrefManager.saveUserDetailsInPreferences(LoginScreen.this, firstname, lasrname, sysid);
} else { startActivity(new Intent(LoginScreen.this, HomeScreen.class));
Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show(); finish();
} }
} } else {
} Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show();
} }
}
}
}
} }
...@@ -24,6 +24,7 @@ import com.vsoft.uoflservicenow.utils.Util; ...@@ -24,6 +24,7 @@ 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.
...@@ -49,10 +50,9 @@ public class MyRequestActivity extends AppCompatActivity { ...@@ -49,10 +50,9 @@ public class MyRequestActivity extends AppCompatActivity {
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
if(actionBar != null) { if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setElevation(0); actionBar.setElevation(0);
actionBar.setTitle(R.string.my_reques_string); actionBar.setTitle("");
actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowTitleEnabled(true);
} }
...@@ -68,6 +68,10 @@ public class MyRequestActivity extends AppCompatActivity { ...@@ -68,6 +68,10 @@ public class MyRequestActivity extends AppCompatActivity {
} }
} }
@OnClick(R.id.nav_back)
public void backButtonClick() {
finish();
}
class FetchMyRequestData extends AsyncTask<String, Void, SyncStatus> { class FetchMyRequestData extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
......
package com.vsoft.uoflservicenow.utils;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.inputmethod.InputMethodManager;
/**
* Created by npadhy on 9/6/2016.
*/
public class KeyboardUtil
{
public static void hideKeyboard(Activity activity)
{
try
{
InputMethodManager inputManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
catch (Exception e)
{
// Ignore exceptions if any
Log.e("KeyBoardUtil", e.toString(), e);
}
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="34dp"
android:height="34dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#E41B23"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp" android:width="35dp"
android:height="36dp" android:height="45dp"
android:viewportWidth="24.0" android:viewportWidth="24.0"
android:viewportHeight="24.0"> android:viewportHeight="24.0">
<path <path
android:fillColor="@android:color/holo_red_dark" android:fillColor="#FF0000"
android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/> android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/>
</vector> </vector>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout 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="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="#FFF" android:background="#FFF"
android:gravity="center" android:gravity="center"
android:id="@+id/login_scroll"
android:orientation="vertical"> android:orientation="vertical">
<ScrollView <ScrollView
android:id="@+id/login_scroll"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scrollbarStyle="insideOverlay" android:scrollbarStyle="insideOverlay"
android:animateLayoutChanges="true" android:animateLayoutChanges="true">
>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical">
>
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/ic_login_banner" android:background="@drawable/ic_login_banner" />
/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="@drawable/ic_login_layout_bg" android:background="@drawable/ic_login_layout_bg"
android:orientation="vertical" android:orientation="vertical">
>
<EditText <EditText
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:background="@drawable/username_under_bg_box" android:background="@drawable/username_under_bg_box"
android:hint="Username" android:hint="Username"
android:layout_marginLeft="@dimen/login_screen_margin_left" android:layout_marginLeft="20dp"
android:layout_marginRight="@dimen/login_screen_margin_right" android:layout_marginRight="20dp"
android:padding="@dimen/normal_margin" android:padding="10dp"
android:inputType="text"
android:cursorVisible="true"
android:text="a0kuma18" android:text="a0kuma18"
android:drawableLeft="@mipmap/ic_user_icon" android:drawableLeft="@mipmap/ic_user_icon"
android:singleLine="true"> android:singleLine="true" />
</EditText>
<EditText <EditText
android:id="@+id/login_screen_password_edit_text" android:id="@+id/login_screen_password_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -62,30 +46,28 @@ ...@@ -62,30 +46,28 @@
android:hint="Password" android:hint="Password"
android:drawableLeft="@mipmap/ic_password_icon" android:drawableLeft="@mipmap/ic_password_icon"
android:inputType="textPassword" android:inputType="textPassword"
android:padding="@dimen/normal_margin" android:padding="10dp"
android:text="v$0ftA$win" android:text="v$0ftA$win"
android:layout_marginLeft="@dimen/login_screen_margin_left" android:layout_marginLeft="20dp"
android:layout_marginRight="@dimen/login_screen_margin_right" android:layout_marginRight="20dp"
android:singleLine="true" /> android:singleLine="true" />
<TextView <TextView
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_marginTop="@dimen/normal_margin" android:layout_gravity="left"
android:paddingBottom="@dimen/normal_margin" android:layout_marginTop="10dp"
android:paddingTop="@dimen/normal_margin" android:layout_marginBottom="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:background="@drawable/login_bg" android:background="@drawable/login_bg"
android:layout_marginLeft="@dimen/login_screen_margin_left" android:layout_marginLeft="20dp"
android:layout_marginRight="@dimen/login_screen_margin_right" android:layout_marginRight="20dp"
android:textSize="@dimen/large_text_size"
android:text="@string/login_screen_login_string" android:text="@string/login_screen_login_string"
android:textAlignment="center" android:textAlignment="center" />
android:textSize="@dimen/extra_normal_text_size"
/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</ScrollView> </LinearLayout>
\ No newline at end of file \ No newline at end of file
...@@ -5,27 +5,41 @@ ...@@ -5,27 +5,41 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/screen_bg_color" android:background="@color/screen_bg_color"
android:orientation="vertical"> android:orientation="vertical">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/tool_bar_view" android:id="@+id/tool_bar_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="0dp" android:background="@android:color/white"
android:background="@android:color/white" android:minHeight="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize" app:titleTextColor="@color/tool_bar_title_color">
android:padding="0dp" <RelativeLayout
app:contentInsetEnd="0dp" android:layout_width="match_parent"
app:contentInsetLeft="0dp" android:layout_height="wrap_content"
app:contentInsetRight="0dp" android:layout_alignParentLeft="true">
app:contentInsetStart="0dp"/> <ImageView
android:id="@+id/nav_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@drawable/ic_arrow_back_black_24dp"
android:layout_alignParentLeft="true"
/>
<TextView
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="@string/my_reques_string"
android:textColor="@color/tool_bar_title_color" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<ListView <ListView
android:id="@+id/request_screen_list_view" android:id="@+id/request_screen_list_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="8dp" android:layout_margin="10dp"
android:background="@android:color/white" android:background="@android:color/white"
android:divider="#8e8e8e" android:divider="#8e8e8e"
android:dividerHeight="0.5dp" android:dividerHeight="0.5dp"
......
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
<color name="home_screen_bg_color">@color/colorPrimary</color> <color name="home_screen_bg_color">@color/colorPrimary</color>
<color name="screen_bg_color">#c0cfd1</color> <color name="screen_bg_color">#c2d1d3</color>
<color name="bg_border_color">#d6d6d6</color> <color name="bg_border_color">#d6d6d6</color>
<color name="back_button_bg_color">#4f0307</color> <color name="back_button_bg_color">#4f0307</color>
<color name="submit_button_bg_color">#e31b22</color> <color name="submit_button_bg_color">#e31b22</color>
<color name="divider_color">#c9c8cc</color> <color name="divider_color">#c9c8cc</color>
<color name="tool_bar_title_color">#E41B23</color>
</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