login screen and api inigration and home screen

parent e6f19928
Showing with 358 additions and 59 deletions
......@@ -46,4 +46,5 @@ dependencies {
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
compile 'com.android.support:cardview-v7:24.1.1'
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vsoft.uofl_catalogue">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<compatible-screens>
<!-- all normal size screens -->
<screen
android:screenDensity="mdpi"
android:screenSize="normal" />
<screen
android:screenDensity="hdpi"
android:screenSize="normal" />
<screen
android:screenDensity="xhdpi"
android:screenSize="normal" />
<!-- all large size screens -->
<screen
android:screenDensity="mdpi"
android:screenSize="large" />
<screen
android:screenDensity="hdpi"
android:screenSize="large" />
<screen
android:screenDensity="xhdpi"
android:screenSize="large" />
<!-- all xlarge size screens -->
<screen
android:screenDensity="mdpi"
android:screenSize="xlarge" />
<screen
android:screenDensity="hdpi"
android:screenSize="xlarge" />
<screen
android:screenDensity="xhdpi"
android:screenSize="xlarge" />
</compatible-screens>
<application
android:name=".CatalogueApplication"
android:allowBackup="true"
......@@ -15,7 +52,7 @@
android:name=".ui.LoginScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize">
android:windowSoftInputMode="adjustPan|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
......@@ -23,17 +60,17 @@
</activity>
<activity
android:name=".ui.HomeScreen"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait" />
<activity
android:name=".ui.CatalogueScreen"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait" />
<activity
android:name=".ui.CatalogueItemScreen"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait" />
<activity
android:name=".ui.CatalogueVariableScreen"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize"/>
android:windowSoftInputMode="stateHidden|adjustResize" />
</application>
</manifest>
package com.vsoft.uofl_catalogue.adapters;
import android.content.Context;
import android.content.res.TypedArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.vsoft.uofl_catalogue.R;
......@@ -16,10 +18,12 @@ public class HomeScreenAdapter extends BaseAdapter {
private final LayoutInflater mInflater;
private final String[] mGridValues;
private final TypedArray icons;
//Constructor to initialize values
public HomeScreenAdapter(Context mContext, String[ ] mGridValues) {
public HomeScreenAdapter(Context mContext, String[ ] mGridValues,TypedArray icons) {
this.mGridValues = mGridValues;
this.icons=icons;
mInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
......@@ -48,18 +52,20 @@ public class HomeScreenAdapter extends BaseAdapter {
convertView = mInflater.inflate(R.layout.home_screen_adapter, parent, false);
holder = new ViewHolder();
holder.textview = (TextView) convertView.findViewById(R.id.home_screen_adapter_text_view);
holder.imageView = (ImageView) convertView.findViewById(R.id.home_screen_adapter_image_view);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
String value = mGridValues[position];
holder.textview.setText(value);
holder.textview.setText(mGridValues[position]);
holder.imageView.setImageResource(icons.getResourceId(position, -1));
return convertView;
}
static class ViewHolder {
private TextView textview;
private ImageView imageView;
}
}
......@@ -140,4 +140,40 @@ public class RestClient {
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
public static Retrofit getInitializedRestAdapterWithOutAuthorizationHeader() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
// add your other interceptors
Interceptor interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder();
requestBuilder.method(original.method(), original.body());
Request request = requestBuilder.build();
try {
return chain.proceed(request);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
};
httpClient.interceptors().add(interceptor);
// add logging as last interceptor
httpClient.interceptors().add(logging); // <-- this is the important line!
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(Constants.DOMAIN)
.client(httpClient.build())
.addConverterFactory(new GsonStringConverterFactory())
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
}
package com.vsoft.uofl_catalogue.api.interfaces;
import com.vsoft.uofl_catalogue.db.models.CatalogueItem;
import com.vsoft.uofl_catalogue.db.models.CatalogueVariable;
import com.vsoft.uofl_catalogue.db.models.LoginItem;
import com.vsoft.uofl_catalogue.db.models.Reference;
import com.vsoft.uofl_catalogue.utils.Constants;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Url;
/**
* @since 1.0
* @author Kunj on 11/8/16.
*
*/
public interface LoginApi {
// Post Login item API
@FormUrlEncoded
@POST(Constants.URL_POST_LOGIN_ITEM)
Call<ResponseBody> postLoginValues(@Field(LoginItem.Json.GRANT_TYPE) String grantType, @Field(LoginItem.Json.CLIENT_ID) String clientId,
@Field(LoginItem.Json.CLIENT_CECRET) String clientSecret, @Field(LoginItem.Json.USER_NAME) String userName,
@Field(LoginItem.Json.PASSWORD) String password);
}
package com.vsoft.uofl_catalogue.api.managers;
import com.vsoft.uofl_catalogue.api.RestClient;
import com.vsoft.uofl_catalogue.api.interfaces.LoginApi;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
/**
* Created by kvemulavada on 8/29/2016.
*/
public class LoginApiManger {
public static SyncStatus submitLoginValues(String garntType, String clientId, String clientSecret, String userName, String password) {
final Retrofit retrofit = RestClient.getInitializedRestAdapterWithOutAuthorizationHeader();
Call<ResponseBody> call = retrofit.create(LoginApi.class).postLoginValues(garntType, clientId, clientSecret, userName, password);
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if (response.code() == 200) {
return SyncStatus.SUCCESS;
} else {
return SyncStatus.FAIL;
}
} catch (IOException e) {
CatalogueLog.e("CatalogueItemApiManager: submitCatalogueItem: IOException: ", e);
return SyncStatus.FAIL;
} catch (NullPointerException e) {
CatalogueLog.e("CatalogueItemApiManager: submitCatalogueItem: IOException: ", e);
return SyncStatus.FAIL;
}
}
}
package com.vsoft.uofl_catalogue.db.models;
/**
* Created by kvemulavada on 8/29/2016.
*/
public class LoginItem {
public static class Json {
public static final String GRANT_TYPE = "grant_type";
public static final String CLIENT_ID = "client_id";
public static final String CLIENT_CECRET = "client_secret";
public static final String USER_NAME = "username";
public static final String PASSWORD = "password";
}
}
......@@ -24,8 +24,7 @@ public class HomeScreen extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_screen);
ButterKnife.bind(this);
mGridView.setAdapter(new HomeScreenAdapter(this, getResources().getStringArray(R.array.home_screen_array)));
mGridView.setAdapter(new HomeScreenAdapter(this, getResources().getStringArray(R.array.home_screen_array),getResources().obtainTypedArray(R.array.home_screen_icon_array)));
}
@OnItemClick(R.id.home_screen_grid_view)
......
package com.vsoft.uofl_catalogue.ui;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Toast;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.api.managers.LoginApiManger;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
......@@ -14,17 +21,60 @@ 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;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.login_screen);
ButterKnife.bind(this);
}
@OnClick(R.id.login_screen_login_text_view)
void onLoginClicked() {
//startActivity(new Intent(LoginScreen.this, HomeScreen.class));
new LoginDetailsSendToServer().execute(userName.getText().toString().trim(), password.getText().toString().trim());
}
class LoginDetailsSendToServer 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 grant_type = "password";
String client_id = "ac0dd3408c1031006907010c2cc6ef6d";
String client_secret = "oklj6znxv3o9jmyn2mlp";
String username = params[0];//"a0kuma18";
String password = params[1];//"v$0ftA$win";
SyncStatus syncStatus = LoginApiManger.submitLoginValues(grant_type, client_id, client_secret, username, password);
return syncStatus;
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (syncStatus == SyncStatus.SUCCESS) {
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
} else {
Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show();
}
}
}
}
......@@ -115,5 +115,5 @@ public class Constants {
public static final String URL_GET_VARIABLE_CHOICE = API_PATH + "question_choice";
public static final String URL_POST_CATALOGUE_ITEM = "api/uno33/uofl_mobile";
public static final String URL_GET_REFERENCE = API_PATH;
public static final String URL_POST_LOGIN_ITEM = "/oauth_token.do";
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#e51b23" />
<corners android:radius="10dip" />
<stroke
android:width="1dp"
android:color="#e51b23" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:top="-2dp"
android:left="-2dp"
android:right="-2dp"
android:bottom="1dp"
>
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#e51b23"/>
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
card_view:cardBackgroundColor="@color/item_gb_color"
card_view:cardCornerRadius="8dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:background="@color/item_gb_color"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="vertical">
<ImageView
android:layout_margin="@dimen/home_screen_image_margin"
android:id="@+id/home_screen_adapter_image_view"
android:layout_width="@dimen/home_screen_image_height"
android:layout_height="@dimen/home_screen_image_height"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/home_screen_adapter_text_view"
android:layout_width="match_parent"
android:layout_height="@dimen/home_screen_item_height"
android:layout_height="wrap_content"
android:layout_below="@+id/home_screen_adapter_image_view"
android:gravity="center"
android:padding="@dimen/normal_margin"
android:background="@android:color/black"
android:textColor="@android:color/white"
android:textSize="@dimen/large_text_size"/>
\ No newline at end of file
android:textSize="@dimen/large_text_size" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/large_margin"
android:layout_marginRight="@dimen/large_margin">
android:layout_height="match_parent"
android:background="@drawable/ic_login_background"
>
<ImageView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/login_screen_logo"/>
android:layout_gravity="bottom"
android:layout_marginTop="@dimen/login_screen_layout_margin_top"
android:layout_marginLeft="@dimen/login_screen_layout_margin_left"
android:layout_marginRight="@dimen/login_screen_layout_margin_right"
android:layout_marginBottom="@dimen/login_screen_layout_margin_bottom"
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:layout_marginLeft="@dimen/login_screen_margin_left"
android:layout_marginRight="@dimen/login_screen_margin_right"
android:drawableLeft="@mipmap/ic_user_icon"
android:text="a0kuma18"
android:hint="@string/login_screen_user_name_string"
android:lines="1"
android:singleLine="true"
android:layout_marginTop="@dimen/normal_margin"
android:hint="@string/login_screen_user_name_string"/>
android:textCursorDrawable="@null" />
<EditText
android:id="@+id/login_screen_password_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_screen_password_string"
android:inputType="textPassword"
android:lines="1"
android:text="v$0ftA$win"
android:background="@drawable/username_under_bg_box"
android:layout_marginLeft="@dimen/login_screen_margin_left"
android:layout_marginRight="@dimen/login_screen_margin_right"
android:drawableLeft="@mipmap/ic_password_icon"
android:singleLine="true"
android:layout_marginTop="@dimen/normal_margin"
android:hint="@string/login_screen_password_string"/>
android:textCursorDrawable="@null"/>
<TextView
android:id="@+id/login_screen_login_text_view"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="@dimen/normal_margin"
android:background="@color/login_screen_login_button_bg_color"
android:textColor="@android:color/white"
android:textSize="@dimen/extra_normal_text_size"
android:layout_marginTop="@dimen/login_screen_login_bottom"
android:background="@drawable/login_bg"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingLeft="@dimen/extra_large_margin"
android:paddingRight="@dimen/extra_large_margin"
android:text="@string/login_screen_login_string"/>
android:text="@string/login_screen_login_string"
android:textAlignment="center"
android:layout_marginLeft="@dimen/login_screen_margin_left"
android:layout_marginRight="@dimen/login_screen_margin_right"
android:textColor="@android:color/white"
android:textSize="@dimen/extra_normal_text_size" />
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file

2.53 KB | W: | H:

6.04 KB | W: | H:

app/src/main/res/mipmap-hdpi/ic_launcher.png
app/src/main/res/mipmap-hdpi/ic_launcher.png
app/src/main/res/mipmap-hdpi/ic_launcher.png
app/src/main/res/mipmap-hdpi/ic_launcher.png
  • 2-up
  • Swipe
  • Onion skin

1.42 KB | W: | H:

3.31 KB | W: | H:

app/src/main/res/mipmap-mdpi/ic_launcher.png
app/src/main/res/mipmap-mdpi/ic_launcher.png
app/src/main/res/mipmap-mdpi/ic_launcher.png
app/src/main/res/mipmap-mdpi/ic_launcher.png
  • 2-up
  • Swipe
  • Onion skin

4.16 KB | W: | H:

9.26 KB | W: | H:

app/src/main/res/mipmap-xhdpi/ic_launcher.png
app/src/main/res/mipmap-xhdpi/ic_launcher.png
app/src/main/res/mipmap-xhdpi/ic_launcher.png
app/src/main/res/mipmap-xhdpi/ic_launcher.png
  • 2-up
  • Swipe
  • Onion skin

8.35 KB | W: | H:

17.3 KB | W: | H:

app/src/main/res/mipmap-xxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  • 2-up
  • Swipe
  • Onion skin

14.2 KB | W: | H:

29.8 KB | W: | H:

app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -5,6 +5,11 @@
<item>Order Services</item>
<item>My Incidents</item>
<item>My Requests</item>
<item>My Dashboard</item>
</string-array>
<array name="home_screen_icon_array">
<item>@drawable/ic_myincident_icon</item>
<item>@drawable/ic_order_service_icon</item>
<item>@drawable/ic_my_incidents_icon</item>
<item>@drawable/ic_my_requiest_icon</item>
</array>
</resources>
\ No newline at end of file
......@@ -3,7 +3,7 @@
<color name="colorPrimary">#F44336</color>
<color name="colorPrimaryDark">#D32F2F</color>
<color name="colorAccent">#FF5252</color>
<color name="item_gb_color">#000000</color>
<color name="error_color">#FF0000</color>
<color name="dark_gray_color">#A9A9A9</color>
......
......@@ -2,21 +2,33 @@
<resources>
<!--Margins-->
<dimen name="small_margin">5dp</dimen>
<dimen name="normal_margin">10dp</dimen>
<dimen name="large_margin">15dp</dimen>
<dimen name="extra_large_margin">20dp</dimen>
<dimen name="normal_margin">5dp</dimen>
<dimen name="large_margin">10dp</dimen>
<!--Text size-->
<dimen name="small_text_size">12sp</dimen>
<dimen name="normal_text_size">16sp</dimen>
<dimen name="extra_normal_text_size">18sp</dimen>
<dimen name="extra_normal_text_size">24sp</dimen>
<dimen name="large_text_size">20sp</dimen>
<dimen name="separator_value">1dp</dimen>
<!--Home Screen-->
<dimen name="home_screen_item_height">120dp</dimen>
<dimen name="home_screen_image_margin">10dp</dimen>
<dimen name="home_screen_image_height">70dp</dimen>
<!--Login Screen-->
<dimen name="login_screen_margin_left">20dp</dimen>
<dimen name="login_screen_margin_right">20dp</dimen>
<dimen name="login_screen_margin_top">2dp</dimen>
<dimen name="login_screen_login_bottom">15dp</dimen>
<dimen name="login_screen_layout_margin_left">20dp</dimen>
<dimen name="login_screen_layout_margin_right">20dp</dimen>
<dimen name="login_screen_layout_margin_bottom">35dp</dimen>
<dimen name="login_screen_layout_margin_top">10dp</dimen>
<!--Spinner Item height-->
<dimen name="spinner_item_height">40dp</dimen>
</resources>
\ No newline at end of file
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
......
#Mon Dec 28 10:00:20 PST 2015
#Fri Aug 26 15:36:34 IST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
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