Commit 2f329ed7 by npadhy

login in keyboard hiden

parent a465a9a0
......@@ -34,7 +34,7 @@ android {
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "0.0.5"
versionName "0.0.6"
multiDexEnabled true
}
buildTypes {
......
......@@ -52,7 +52,7 @@
android:name="com.vsoft.uoflservicenow.ui.LoginScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan">
android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
......
......@@ -8,6 +8,8 @@ import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ScrollView;
import android.widget.Toast;
......@@ -20,6 +22,7 @@ import com.vsoft.uoflservicenow.api.managers.LoginApiManger;
import com.vsoft.uoflservicenow.api.managers.UserApiManager;
import com.vsoft.uoflservicenow.db.models.UserApiValues;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.KeyboardUtil;
import com.vsoft.uoflservicenow.utils.PrefManager;
import com.vsoft.uoflservicenow.utils.Util;
......@@ -38,150 +41,153 @@ import butterknife.OnClick;
public class LoginScreen extends Activity {
@BindView(R.id.login_screen_username_edit_text)
EditText userName;
@BindView(R.id.login_screen_password_edit_text)
EditText password;
@BindView(R.id.login_scroll)
ScrollView loginScrollview;
private List<UserApiValues> mUserDetails;
private PrefManager prefManager;
private String userNameStrng,passwordStrng;
private String firstName,lastName,sysId;
@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);
CheckLoginValues();
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();
// 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, "");
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));
userNameStrng=userName.getText().toString().trim();
passwordStrng=password.getText().toString().trim();
if(TextUtils.isEmpty(userNameStrng)) {
userName.setError(getResources().getString (R.string.user_error));
return;
}
else if(!TextUtils.isEmpty(userNameStrng) && !TextUtils.isEmpty(passwordStrng)){
new LoginDetailsSendToServer().execute(userName.getText().toString().trim(), password.getText().toString().trim());
}
}
class LoginDetailsSendToServer extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog;
private String userName;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(LoginScreen.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected SyncStatus doInBackground(String... params) {
String grantType = "password";
String clientId = "ac0dd3408c1031006907010c2cc6ef6d";
String clientSecret = "oklj6znxv3o9jmyn2mlp";
userName = params[0];//"a0kuma18";
String password = params[1];//"v$0ftA$win";
return LoginApiManger.submitLoginValues(grantType, clientId, clientSecret, userName, password);
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
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
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(LoginScreen.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected SyncStatus doInBackground(String... params) {
String userName=params[0];
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()) {
progressDialog.dismiss();
}
if (syncStatus == SyncStatus.SUCCESS) {
if (mUserDetails != null) {
String firstname=mUserDetails.get(0).getFirstName();
String lasrname=mUserDetails.get(0).getLastName();
String sysid=mUserDetails.get(0).getSysId();
PrefManager.saveUserDetailsInPreferences(LoginScreen.this, firstname, lasrname, sysid);
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
finish();
}
} else {
Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show();
}
}
}
}
@BindView(R.id.login_screen_username_edit_text)
EditText userName;
@BindView(R.id.login_screen_password_edit_text)
EditText password;
@BindView(R.id.login_scroll)
ScrollView loginScrollview;
private List<UserApiValues> mUserDetails;
private PrefManager prefManager;
private String userNameStrng, passwordStrng;
private String firstName, lastName, sysId;
private boolean isShow;
@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);
// CheckLoginValues();
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();
// 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, "");
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));
userNameStrng = userName.getText().toString().trim();
passwordStrng = password.getText().toString().trim();
if (TextUtils.isEmpty(userNameStrng)) {
userName.setError(getResources().getString(R.string.user_error));
return;
} 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;
private String userName;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(LoginScreen.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected SyncStatus doInBackground(String... params) {
String grantType = "password";
String clientId = "ac0dd3408c1031006907010c2cc6ef6d";
String clientSecret = "oklj6znxv3o9jmyn2mlp";
userName = params[0];//"a0kuma18";
String password = params[1];//"v$0ftA$win";
return LoginApiManger.submitLoginValues(grantType, clientId, clientSecret, userName, password);
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
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
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(LoginScreen.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected SyncStatus doInBackground(String... params) {
String userName = params[0];
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()) {
progressDialog.dismiss();
}
if (syncStatus == SyncStatus.SUCCESS) {
if (mUserDetails != null) {
String firstname = mUserDetails.get(0).getFirstName();
String lasrname = mUserDetails.get(0).getLastName();
String sysid = mUserDetails.get(0).getSysId();
PrefManager.saveUserDetailsInPreferences(LoginScreen.this, firstname, lasrname, sysid);
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
finish();
}
} else {
Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show();
}
}
}
}
}
......@@ -24,6 +24,7 @@ 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.
......@@ -49,10 +50,9 @@ public class MyRequestActivity extends AppCompatActivity {
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
if (actionBar != null) {
actionBar.setElevation(0);
actionBar.setTitle(R.string.my_reques_string);
actionBar.setTitle("");
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
}
......@@ -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> {
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"
android:width="36dp"
android:height="36dp"
android:width="35dp"
android:height="45dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<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"/>
</vector>
<?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_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#FFF"
android:gravity="center"
android:id="@+id/login_scroll"
android:orientation="vertical">
<ScrollView
android:id="@+id/login_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="insideOverlay"
android:animateLayoutChanges="true"
>
android:scrollbarStyle="insideOverlay"
android:animateLayoutChanges="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
>
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ic_login_banner"
/>
android:background="@drawable/ic_login_banner" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ic_login_layout_bg"
android:orientation="vertical"
>
android:orientation="vertical">
<EditText
android:id="@+id/login_screen_username_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/username_under_bg_box"
android:hint="Username"
android:layout_marginLeft="@dimen/login_screen_margin_left"
android:layout_marginRight="@dimen/login_screen_margin_right"
android:padding="@dimen/normal_margin"
android:inputType="text"
android:cursorVisible="true"
android:hint="Username"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:padding="10dp"
android:text="a0kuma18"
android:drawableLeft="@mipmap/ic_user_icon"
android:singleLine="true">
</EditText>
android:singleLine="true" />
<EditText
android:id="@+id/login_screen_password_edit_text"
android:layout_width="match_parent"
......@@ -62,30 +46,28 @@
android:hint="Password"
android:drawableLeft="@mipmap/ic_password_icon"
android:inputType="textPassword"
android:padding="@dimen/normal_margin"
android:padding="10dp"
android:text="v$0ftA$win"
android:layout_marginLeft="@dimen/login_screen_margin_left"
android:layout_marginRight="@dimen/login_screen_margin_right"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:singleLine="true" />
<TextView
android:id="@+id/login_screen_login_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/normal_margin"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:layout_gravity="left"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textColor="@android:color/white"
android:background="@drawable/login_bg"
android:layout_marginLeft="@dimen/login_screen_margin_left"
android:layout_marginRight="@dimen/login_screen_margin_right"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textSize="@dimen/large_text_size"
android:text="@string/login_screen_login_string"
android:textAlignment="center"
android:textSize="@dimen/extra_normal_text_size"
/>
android:textAlignment="center" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</ScrollView>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
......@@ -5,27 +5,41 @@
android:layout_height="match_parent"
android:background="@color/screen_bg_color"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="@android:color/white"
android:minHeight="?attr/actionBarSize"
android:padding="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"/>
android:id="@+id/tool_bar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:minHeight="?attr/actionBarSize"
app:titleTextColor="@color/tool_bar_title_color">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true">
<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
android:id="@+id/request_screen_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:layout_margin="10dp"
android:background="@android:color/white"
android:divider="#8e8e8e"
android:dividerHeight="0.5dp"
......
......@@ -11,10 +11,11 @@
<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="back_button_bg_color">#4f0307</color>
<color name="submit_button_bg_color">#e31b22</color>
<color name="divider_color">#c9c8cc</color>
<color name="tool_bar_title_color">#E41B23</color>
</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