login and register

This commit is contained in:
2017-10-01 23:51:59 +03:00
parent dca2c7a71c
commit 9f9274acf5
23 changed files with 411 additions and 329 deletions

2
.idea/misc.xml generated
View File

@@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -1,17 +1,111 @@
package ch.pizzalink.android.activity;
import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SharedPrefsHelper;
import ch.pizzalink.android.model.responseModel.LoginCustomerResponseModel;
import ch.pizzalink.android.view.PizzalinkButton;
import ch.pizzalink.android.view.PizzalinkEditText;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LoginActivity extends BaseActivity {
@BindView(R.id.emailPizzalinkEditText) PizzalinkEditText emailPizzalinkEditText;
@BindView(R.id.passwordPizzalinkEditText) PizzalinkEditText passwordPizzalinkEditText;
@BindView(R.id.loginButton) Button loginButton;
@BindView(R.id.registerTextView) TextView registerTextView;
@BindString(R.string.not_have_an_accaount) String notHaveAnAccountText;
@BindString(R.string.register_text) String registerText;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_valid_email) String validEmailText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
initViews();
}
@OnClick({R.id.loginButton, R.id.registerTextView})
protected void onClick(View view){
switch (view.getId()){
case R.id.loginButton:
if(checkFields())
login();
break;
case R.id.registerTextView:
startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
break;
}
}
private void initViews(){
initRegisterTextView();
emailPizzalinkEditText.getEditText().setText("aytaccici@gmail.com");
passwordPizzalinkEditText.getEditText().setText("3522625");
}
private void initRegisterTextView(){
Spannable wordtoSpan = new SpannableString(notHaveAnAccountText + " " + registerText);
wordtoSpan.setSpan(new ForegroundColorSpan(Color.RED), 16, wordtoSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
registerTextView.setText(wordtoSpan);
}
private boolean checkFields(){
if(emailPizzalinkEditText.isEmpty() || passwordPizzalinkEditText.isEmpty()){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
return false;
}
if(!emailPizzalinkEditText.isEmail()){
DialogHelper.showAlertDialog(this, validEmailText);
return false;
}
return true;
}
private void login(){
Call<LoginCustomerResponseModel> call = ApiService.apiInterface.login(
emailPizzalinkEditText.getText(), passwordPizzalinkEditText.getText());
call.enqueue(new Callback<LoginCustomerResponseModel>() {
@Override
public void onResponse(Call<LoginCustomerResponseModel> call, Response<LoginCustomerResponseModel> response) {
if(response.isSuccessful()){
SharedPrefsHelper.saveUser(response.body().getData());
SharedPrefsHelper.saveCustomerToken(response.body().getData().getToken());
SharedPrefsHelper.setCustomerLoggedIn(true);
startActivity(new Intent(LoginActivity.this, MainActivity.class));
}
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<LoginCustomerResponseModel> call, Throwable t) {
DialogHelper.showFailedDialog();
}
});
}
}

View File

@@ -1,17 +1,122 @@
package ch.pizzalink.android.activity;
import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.List;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SharedPrefsHelper;
import ch.pizzalink.android.model.responseModel.LoginCustomerResponseModel;
import ch.pizzalink.android.view.PizzalinkButton;
import ch.pizzalink.android.view.PizzalinkEditText;
import ch.pizzalink.android.view.PizzalinkToolbar;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RegisterActivity extends BaseActivity {
@BindView(R.id.registerToolbar) PizzalinkToolbar registerToolbar;
@BindView(R.id.registerButton) Button registerButton;
@BindViews({ R.id.firstnamePizzalinkEditText, R.id.lasstnamePizzalinkEditText,
R.id.telephonePizzalinkEditText, R.id.emailPizzalinkEditText,
R.id.passwordPizzalinkEditText, R.id.passwordAgainPizzalinkEditText,
R.id.address1PizzalinkEditText, R.id.address2PizzalinkEditText,
R.id.cityPizzalinkEditText, R.id.postcodePizzalinkEditText,
R.id.zonePizzalinkEditText, R.id.countryPizzalinkEditText})
List<PizzalinkEditText> pizzalinkEditTextList;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_valid_email) String validEmailText;
@BindString(R.string.alert_passwords_not_matched) String passwordsNotMatchedText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
ButterKnife.bind(this);
initViews();
}
@OnClick(R.id.registerButton)
protected void onClick(){
if(checkFields())
registerUser();
}
private void initViews(){
registerToolbar.setBackIconClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
}
});
}
private boolean checkFields(){
for(PizzalinkEditText pizzalinkEditText : pizzalinkEditTextList){
if(pizzalinkEditText.isEmpty()){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
return false;
}
}
if(!pizzalinkEditTextList.get(3).isEmail()){
DialogHelper.showAlertDialog(this, validEmailText);
return false;
}
if(pizzalinkEditTextList
.get(4)
.getText()
.toLowerCase()
.equals(
pizzalinkEditTextList
.get(5)
.getText()
.toLowerCase())){
DialogHelper.showAlertDialog(this, passwordsNotMatchedText);
return false;
}
return true;
}
private void registerUser(){
Call<LoginCustomerResponseModel> call = ApiService.apiInterface.register(
pizzalinkEditTextList.get(0).getText(), pizzalinkEditTextList.get(1).getText(),pizzalinkEditTextList.get(2).getText(),
pizzalinkEditTextList.get(3).getText(),pizzalinkEditTextList.get(4).getText(),pizzalinkEditTextList.get(5).getText(),
pizzalinkEditTextList.get(6).getText(),pizzalinkEditTextList.get(7).getText(),pizzalinkEditTextList.get(8).getText(),
pizzalinkEditTextList.get(9).getText(),pizzalinkEditTextList.get(10).getText(),pizzalinkEditTextList.get(11).getText());
call.enqueue(new Callback<LoginCustomerResponseModel>() {
@Override
public void onResponse(Call<LoginCustomerResponseModel> call, Response<LoginCustomerResponseModel> response) {
if(response.isSuccessful()){
SharedPrefsHelper.saveUser(response.body().getData());
SharedPrefsHelper.saveCustomerToken(response.body().getData().getToken());
SharedPrefsHelper.setCustomerLoggedIn(true);
startActivity(new Intent(RegisterActivity.this, MainActivity.class));
}
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<LoginCustomerResponseModel> call, Throwable t) {
DialogHelper.showFailedDialog();
}
});
}
}

View File

@@ -34,7 +34,7 @@ public class SplashActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ButterKnife.bind(this);
DisplayHelper.changeStatusColor();
//DisplayHelper.changeStatusColor();
if(NetworkHelper.isNetworkAvailable())
getCategoryList();
else
@@ -80,8 +80,7 @@ public class SplashActivity extends BaseActivity {
handler.postDelayed(new Runnable() {
@Override
public void run() {
//startActivity(new Intent(SplashActivity.this, cls));
startActivity(new Intent(SplashActivity.this, RegisterActivity.class));
startActivity(new Intent(SplashActivity.this, cls));
finish();
}
}, 1000);

View File

@@ -42,90 +42,24 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
private ArrayList<PizzaModel> pizzaList = new ArrayList<>();
private RecyclerItemClickListener recyclerItemClickListener;
private CheckBoxChangedListener checkBoxChangedListener;
public static class PizzaViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.pizzaNameTextView) TextView pizzaNameTextView;
@BindView(R.id.pizzaImageView) ImageView pizzaImageView;
@BindView(R.id.pizzaIngredientsTextView) TextView pizzaIngredientsTextView;
@BindView(R.id.pizzaBottomLayout) LinearLayout pizzaBottomLayout;
@BindView(R.id.expandBottomLayoutImageView) ImageView expandBottomLayoutImageView;
@BindView(R.id.collapseBottomLayoutImageView) ImageView collapseBottomLayoutImageView;
@BindViews({ R.id.pizzaSize1CheckBox, R.id.pizzaSize2CheckBox, R.id.pizzaSize3CheckBox })
List<AppCompatCheckBox> pizzaSizeCheckBoxList;
@BindView(R.id.pizzaSize1Layout) LinearLayout pizzaSize1Layout;
@BindView(R.id.pizzaSize1NameTextView) TextView pizzaSize1NameTextView;
@BindView(R.id.pizzaSize1CheckBox) AppCompatCheckBox pizzaSize1CheckBox;
@BindView(R.id.pizzaSize1LengthTextView) TextView pizzaSize1LengthTextView;
@BindView(R.id.pizzaSize2Layout) LinearLayout pizzaSize2Layout;
@BindView(R.id.pizzaSize2NameTextView) TextView pizzaSize2NameTextView;
@BindView(R.id.pizzaSize2CheckBox) AppCompatCheckBox pizzaSize2CheckBox;
@BindView(R.id.pizzaSize2LengthTextView) TextView pizzaSize2LengthTextView;
@BindView(R.id.pizzaSize3Layout) LinearLayout pizzaSize3Layout;
@BindView(R.id.pizzaSize3NameTextView) TextView pizzaSize3NameTextView;
@BindView(R.id.pizzaSize3CheckBox) AppCompatCheckBox pizzaSize3CheckBox;
@BindView(R.id.pizzaSize3LengthTextView) TextView pizzaSize3LengthTextView;
@BindView(R.id.increasePizzaCountTextView) ImageView increasePizzaCountTextView;
@BindView(R.id.pizzaCountTextView) TextView pizzaCountTextView;
@BindView(R.id.deccreasePizzaCountTextView) ImageView deccreasePizzaCountTextView;
@BindView(R.id.pizzaPriceTextView) TextView pizzaPriceTextView;
@BindView(R.id.addPizzaToCartButton) Button addPizzaToCartButton;
public PizzaViewHolder(final View view,
final RecyclerItemClickListener recyclerItemClickListener,
final CheckBoxChangedListener checkBoxChangedListener) {
public PizzaViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(pizzaBottomLayout, getAdapterPosition());
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
}
});
increasePizzaCountTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(increasePizzaCountTextView, getAdapterPosition());
}
});
deccreasePizzaCountTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(deccreasePizzaCountTextView, getAdapterPosition());
}
});
addPizzaToCartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(addPizzaToCartButton, getAdapterPosition());
}
});
for(final AppCompatCheckBox appCompatCheckBox : pizzaSizeCheckBoxList){
appCompatCheckBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(checkBoxChangedListener != null)
checkBoxChangedListener.onCheckedChanged(appCompatCheckBox, getAdapterPosition());
}
});
}
}
}
@@ -145,11 +79,9 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
}
public PizzaRecyclerAdapter(ArrayList<PizzaModel> pizzaList,
RecyclerItemClickListener recyclerItemClickListener,
CheckBoxChangedListener checkBoxChangedListener){
RecyclerItemClickListener recyclerItemClickListener){
this.pizzaList = pizzaList;
this.recyclerItemClickListener = recyclerItemClickListener;
this.checkBoxChangedListener = checkBoxChangedListener;
}
@Override
@@ -162,8 +94,8 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
switch (viewType){
case HOLDER_PIZZA:
view = inflater.inflate(R.layout.row_pizza_2, viewGroup, false);
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener, checkBoxChangedListener);
view = inflater.inflate(R.layout.row_pizza, viewGroup, false);
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener);
break;
case HOLDER_SPACE:
@@ -172,8 +104,8 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
break;
default:
view = inflater.inflate(R.layout.row_pizza_2, viewGroup, false);
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener, checkBoxChangedListener);
view = inflater.inflate(R.layout.row_pizza, viewGroup, false);
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener);
break;
}
@@ -185,65 +117,18 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
switch (holder.getItemViewType()){
case HOLDER_PIZZA :
PizzaViewHolder pizzaViewHolder = (PizzaViewHolder) holder;
pizzaViewHolder.pizzaNameTextView.setText(pizzaList.get(position).getName());
pizzaViewHolder.pizzaIngredientsTextView.setText(pizzaList.get(position).getIngredients());
pizzaViewHolder.pizzaCountTextView.setText(String.valueOf(pizzaList.get(position).getCount()));
ImageLoadHelper.loadImage(pizzaViewHolder.pizzaImageView, pizzaList.get(position).getImageURL());
if(pizzaList.get(position).isExpanded()){
pizzaViewHolder.expandBottomLayoutImageView.setVisibility(View.GONE);
pizzaViewHolder.collapseBottomLayoutImageView.setVisibility(View.VISIBLE);
pizzaViewHolder.pizzaBottomLayout.setVisibility(View.VISIBLE);
}
else{
pizzaViewHolder.expandBottomLayoutImageView.setVisibility(View.VISIBLE);
pizzaViewHolder.collapseBottomLayoutImageView.setVisibility(View.GONE);
pizzaViewHolder.pizzaBottomLayout.setVisibility(View.GONE);
}
if(pizzaList.get(position).getPizzaSizeList().size() == 0){
pizzaViewHolder.pizzaSize1Layout.setVisibility(View.GONE);
pizzaViewHolder.pizzaSize2Layout.setVisibility(View.GONE);
pizzaViewHolder.pizzaSize3Layout.setVisibility(View.GONE);
}
else if(pizzaList.get(position).getPizzaSizeList().size() == 1){
pizzaViewHolder.pizzaSize1Layout.setVisibility(View.VISIBLE);
pizzaViewHolder.pizzaSize1NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(0).getName());
pizzaViewHolder.pizzaSize2Layout.setVisibility(View.GONE);
pizzaViewHolder.pizzaSize3Layout.setVisibility(View.GONE);
}
else if(pizzaList.get(position).getPizzaSizeList().size() == 2){
pizzaViewHolder.pizzaSize1Layout.setVisibility(View.VISIBLE);
pizzaViewHolder.pizzaSize1NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(0).getName());
pizzaViewHolder.pizzaSize2Layout.setVisibility(View.VISIBLE);
pizzaViewHolder.pizzaSize2NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(1).getName());
pizzaViewHolder.pizzaSize3Layout.setVisibility(View.GONE);
}
else if(pizzaList.get(position).getPizzaSizeList().size() <= 3){
pizzaViewHolder.pizzaSize1Layout.setVisibility(View.VISIBLE);
pizzaViewHolder.pizzaSize1NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(0).getName());
pizzaViewHolder.pizzaSize2Layout.setVisibility(View.VISIBLE);
pizzaViewHolder.pizzaSize2NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(1).getName());
pizzaViewHolder.pizzaSize3Layout.setVisibility(View.VISIBLE);
pizzaViewHolder.pizzaSize3NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(2).getName());
}
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override

View File

@@ -3,7 +3,10 @@ package ch.pizzalink.android.api;
public class ApiEndPoints {
private static final String PREFIX = "pizza2/index.php?route=mobile/service/";
private static final String SUFFIX = "&is_mobile=1";
public static final String API_GET_ALL_CATEGORIES = PREFIX + "getAllCategories&is_mobile=1";
public static final String API_GET_ALL_CATEGORIES = PREFIX + "getAllCategories" + SUFFIX;
public static final String API_REGISTER = PREFIX + "signUp" + SUFFIX;
public static final String API_LOGIN = PREFIX + "login" + SUFFIX;
}

View File

@@ -1,6 +1,7 @@
package ch.pizzalink.android.api;
import ch.pizzalink.android.model.responseModel.CategoryResponseModel;
import ch.pizzalink.android.model.responseModel.LoginCustomerResponseModel;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
@@ -17,6 +18,26 @@ public interface ApiInterface {
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
Call<CategoryResponseModel> getAllCategories();
@FormUrlEncoded
@POST(ApiEndPoints.API_REGISTER)
Call<LoginCustomerResponseModel> register(@Field("firstname") String firstname,
@Field("lastname") String lastname,
@Field("telephone") String telephone,
@Field("email") String email,
@Field("passsword") String passsword,
@Field("passsword1") String passswordRetype,
@Field("address_1") String addressLine1,
@Field("address_2") String addressLine2,
@Field("city") String passswocityrd,
@Field("postcode") String postcode,
@Field("country_id") String country_id,
@Field("zone_id") String zone_id);
@FormUrlEncoded
@POST(ApiEndPoints.API_LOGIN)
Call<LoginCustomerResponseModel> login(@Field("email") String email, @Field("password") String password);
/*
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
Call<CategoryListResponseModel> getAllCategories();

View File

@@ -66,14 +66,11 @@ public class PizzaFragment extends OrderBaseFragment {
private void initRecyclerView(){
/*
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
pizzaRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
*/
RecyclerItemClickListener recyclerItemClickListener = new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
/*
switch (view.getId()){
case R.id.increasePizzaCountTextView:
pizzaList.get(position).setCount(pizzaList.get(position).getCount() + 1);
@@ -96,6 +93,7 @@ public class PizzaFragment extends OrderBaseFragment {
pizzaRecyclerView.scrollToPosition(position);
break;
}
*/
}
};
@@ -106,8 +104,9 @@ public class PizzaFragment extends OrderBaseFragment {
}
};
pizzaRecyclerAdapter = new PizzaRecyclerAdapter(pizzaList, recyclerItemClickListener, checkBoxChangedListener);
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
pizzaRecyclerAdapter = new PizzaRecyclerAdapter(pizzaList, recyclerItemClickListener);
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
pizzaRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
pizzaRecyclerView.setLayoutManager(layoutManager);
pizzaRecyclerView.setAdapter(pizzaRecyclerAdapter);
}

View File

@@ -6,6 +6,7 @@ import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import ch.pizzalink.android.R;
@@ -14,7 +15,7 @@ import ch.pizzalink.android.R;
* Created by cimenmus on 28/09/2017.
*/
public class PizzalinkButton extends RelativeLayout {
public class PizzalinkButton extends LinearLayout {
private View rootView;
private boolean isEnabled;

View File

@@ -15,6 +15,7 @@ import android.widget.TextView;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
import ch.pizzalink.android.helper.PasswordHelper;
/**
* Created by cimenmus on 28/09/2017.
@@ -98,23 +99,33 @@ public class PizzalinkEditText extends LinearLayout implements View.OnClickListe
}
private void hideShowPassword(){
if(isPasswordHidden)
editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
else
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
isPasswordHidden = !isPasswordHidden;
editText.setTypeface(typeFace);
}
private void focusEditText(){
editText.requestFocus();
InputMethodManager inputMethodManager=(InputMethodManager)BaseActivity.currentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
public boolean isEmpty(){
return editText.getText().toString().isEmpty();
}
public boolean isEmail(){
return PasswordHelper.EMAIL_ADDRESS_PATTERN.matcher(editText.getText()).matches();
}
public String getText(){
return editText.getText().toString();
}
public TextView getHintTextView() {
return hintTextView;
}

View File

@@ -21,8 +21,8 @@ public class PizzalinkToolbar extends Toolbar {
private View rootView;
private TextView toolbarTitleTextView;
private ImageView hamburgerIcon;
private boolean showHamburgerIcon;
private ImageView hamburgerIcon, backIcon;
private boolean showHamburgerIcon, showBackIcon;
private String title;
private int toolbarBackgroundColor, titleTextColor;
@@ -44,6 +44,7 @@ public class PizzalinkToolbar extends Toolbar {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PizzalinkToolbar, 0, 0);
try {
showHamburgerIcon = a.getBoolean(R.styleable.PizzalinkToolbar_showHamburgerMenuIcon, false);
showBackIcon = a.getBoolean(R.styleable.PizzalinkToolbar_showBackIcon, false);
title = a.getString(R.styleable.PizzalinkToolbar_title);
/*
toolbarBackgroundColor = a.getColor(R.styleable.PizzalinkToolbar_toolbarBackgroundColor,
@@ -66,8 +67,11 @@ public class PizzalinkToolbar extends Toolbar {
//this.setBackgroundResource(toolbarBackgroundColor);
//toolbarTitleTextView.setTextColor(titleTextColor);
hamburgerIcon = (ImageView) rootView.findViewById(R.id.hamburgerIcon);
backIcon = (ImageView) rootView.findViewById(R.id.backIcon);
if(showHamburgerIcon)
hamburgerIcon.setVisibility(VISIBLE);
if(showBackIcon)
backIcon.setVisibility(VISIBLE);
if(title != null) {
toolbarTitleTextView.setText(title);
toolbarTitleTextView.setVisibility(VISIBLE);
@@ -91,6 +95,10 @@ public class PizzalinkToolbar extends Toolbar {
hamburgerIcon.setVisibility(GONE);
}
public void setBackIconClickListener(OnClickListener onClickListener){
backIcon.setOnClickListener(onClickListener);
}
public ImageView getHamburgerIcon() {
return hamburgerIcon;
}

View File

@@ -0,0 +1,4 @@
<vector android:height="20dp" android:viewportHeight="240.823"
android:viewportWidth="240.823" android:width="20dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff" android:pathData="M57.63,129.01L165.93,237.27c4.75,4.74 12.45,4.74 17.22,0c4.75,-4.74 4.75,-12.44 0,-17.18l-99.71,-99.67l99.69,-99.67c4.75,-4.74 4.75,-12.44 0,-17.19c-4.75,-4.74 -12.46,-4.74 -17.22,0L57.62,111.82C52.94,116.51 52.94,124.33 57.63,129.01z"/>
</vector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@@ -7,8 +7,81 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white"
tools:context="ch.pizzalink.android.activity.LoginActivity">
tools:context="ch.pizzalink.android.activity.LoginActivity"
android:focusable="true"
android:focusableInTouchMode="true">
<ch.pizzalink.android.view.PizzalinkToolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/activity_title_login"
android:background="@color/white"
app:titleTextColor="@color/black" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/loginLayout">
<ImageView
android:layout_width="180dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_centerInParent="true"
android:text="Hello World!"
android:src="@drawable/pizzalink_logo"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/loginLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true">
<ch.pizzalink.android.view.PizzalinkEditText
android:id="@+id/emailPizzalinkEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="@string/email"/>
<ch.pizzalink.android.view.PizzalinkEditText
android:id="@+id/passwordPizzalinkEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="@string/password"/>
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="24dp" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:text="@string/button_login"
style="@style/PizzalinkButton" />
<TextView
android:id="@+id/registerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/register_text"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"
android:padding="24dp" />
</LinearLayout>
</RelativeLayout>

View File

@@ -7,7 +7,9 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white"
tools:context="ch.pizzalink.android.activity.RegisterActivity">
tools:context="ch.pizzalink.android.activity.RegisterActivity"
android:focusable="true"
android:focusableInTouchMode="true">
<ch.pizzalink.android.view.PizzalinkToolbar
android:id="@+id/registerToolbar"
@@ -15,6 +17,7 @@
android:layout_height="wrap_content"
app:title="@string/activity_title_register"
android:background="@color/white"
app:showBackIcon="true"
app:titleTextColor="@color/black" />
<ScrollView
@@ -94,6 +97,18 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="@string/postcode"/>
<ch.pizzalink.android.view.PizzalinkEditText
android:id="@+id/zonePizzalinkEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="@string/zone"/>
<ch.pizzalink.android.view.PizzalinkEditText
android:id="@+id/countryPizzalinkEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="@string/county"/>
<android.support.v4.widget.Space
android:layout_width="match_parent"
@@ -103,14 +118,14 @@
</ScrollView>
<ch.pizzalink.android.view.PizzalinkButton
<Button
android:id="@+id/registerButton"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:isEnabled="false"
app:text="@string/activity_title_register"
style="@style/PizzalinkButton"
android:text="@string/button_register"
android:layout_alignParentBottom="true" />
</RelativeLayout>

View File

@@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ch.pizzalink.android.activity.SplashActivity"
android:background="@color/black">
android:background="@color/white">
<ImageView
android:layout_width="match_parent"
@@ -15,7 +15,7 @@
android:scaleType="fitXY"
android:layout_centerInParent="true"
android:text="Hello World!"
android:layout_margin="48dp"
android:layout_margin="24dp"
android:src="@drawable/pizzalink_logo"/>
</RelativeLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
@@ -10,11 +10,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginRight="12dp"
android:layout_marginEnd="12dp"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:textColor="@color/white"
android:background="@drawable/background_button_enabled"/>
</RelativeLayout>
</LinearLayout>

View File

@@ -30,6 +30,15 @@
android:src="@drawable/ic_hamburger_menu"
android:visibility="gone"/>
<ImageView
android:id="@+id/backIcon"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:padding="20dp"
android:layout_centerVertical="true"
android:src="@drawable/ic_back"
android:visibility="gone"/>
<TextView
android:id="@+id/toolbarTitleTextView"
android:layout_width="wrap_content"

View File

@@ -44,183 +44,16 @@
android:gravity="center"
android:text="Mozzarella, Artischocken, Pilze, Peperoni, Oliven, Oregano"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="12dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:layout_weight="1">
<ImageView
android:id="@+id/increasePizzaCountTextView"
android:layout_width="24dp"
android:layout_height="24dp"
android:paddingLeft="4dp"
android:paddingStart="4dp"
android:paddingRight="4dp"
android:paddingEnd="4dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_up_black" />
<TextView
android:id="@+id/pizzaCountTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textStyle="bold"
android:textSize="12sp"
android:layout_marginTop="4dp"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"/>
<ImageView
android:id="@+id/deccreasePizzaCountTextView"
android:layout_width="24dp"
android:layout_height="24dp"
android:padding="4dp"
android:layout_margin="4dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_down_black"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:layout_weight="1">
<TextView
android:id="@+id/pizzaSize1NameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Klein"
android:textSize="10sp"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/pizzaSize1CheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
/>
<TextView
android:id="@+id/pizzaSize1LengthTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="26cm"
android:textSize="12sp"
android:layout_marginTop="4dp"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:layout_weight="1">
<TextView
android:id="@+id/pizzaSize2NameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Normal"
android:textSize="10sp"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/pizzaSize2CheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
/>
<TextView
android:id="@+id/pizzaSize2LengthTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="32cm"
android:textSize="12sp"
android:layout_marginTop="4dp"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:layout_weight="1">
<TextView
android:id="@+id/pizzaSize3NameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gross"
android:textSize="10sp"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/pizzaSize3CheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
/>
<TextView
android:id="@+id/pizzaSize3LengthTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="50cm"
android:textSize="12sp"
android:layout_marginTop="4dp"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/pizzaPriceTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:text="CHF 25.00"
android:padding="16dp"
android:textStyle="bold"
android:layout_gravity="center_horizontal" />
<Button
android:id="@+id/addPizzaToCartTextView"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_margin="12dp"
style="@style/AddCartButton"
android:text="Add to Cart"/>
</LinearLayout>
</android.support.v7.widget.CardView>

View File

@@ -3,6 +3,7 @@
<declare-styleable name="PizzalinkToolbar">
<attr name="showHamburgerMenuIcon" format="boolean" />
<attr name="showBackIcon" format="boolean" />
<attr name="title" format="string" />
<attr name="toolbarBackgroundColor" format="reference" />
<attr name="toolbarTitleTextColor" format="reference" />

View File

@@ -23,5 +23,6 @@
<color name="quartz">#DCDCDD</color>
<color name="venus">#7F797C</color>
<color name="background_splash">#F4F4F4</color>
</resources>

View File

@@ -44,8 +44,8 @@
<string name="fragment_title_item_beer_drinks">Beer</string>
<string name="fragment_title_dessert">Dessert</string>
<!-- LoginActivity-->
<string name="activity_title_login">Giriş Yap</string>
<!-- RegisterActivity-->
<string name="activity_title_register">Kayıt Ol</string>
<string name="firstname">Ad</string>
<string name="lastname">Soyad</string>
<string name="telephone">Telefon Numarası</string>
@@ -56,11 +56,20 @@
<string name="addres_line_2">Adres 2</string>
<string name="city">Şehir</string>
<string name="postcode">Posta Kodu</string>
<!-- LoginActivity-->
<string name="county">Ülke</string>
<string name="zone">Bölge</string>
<string name="alert_fill_all_fields">Lütfen istenen tüm bigileri doldurunuz.</string>
<string name="alert_valid_email">Lütfen geçerli bir mail adresi giriniz.</string>
<string name="alert_passwords_not_matched">Şifreler uyuşmuyor..</string>
<string name="button_register">KAYIT OL</string>
<!-- RegisterActivity-->
<!-- RegisterActivity-->
<string name="activity_title_register">Kayıt Ol</string>
<!-- RegisterActivity-->
<!-- LoginActivity-->
<string name="activity_title_login">Giriş Yap</string>
<string name="button_login">GİRİŞ YAP</string>
<string name="not_have_an_accaount">Hesabın yok mu?</string>
<string name="register_text">KAYIT OL</string>
<!-- LoginActivity-->
<string name="alert">Uyarı</string>
<string name="error_message">Bir hata oluştu.</string>

View File

@@ -21,4 +21,15 @@
<item name="android:textAllCaps">false</item>
</style>
<style name="PizzalinkButton">
<item name="android:background">@drawable/background_button_enabled</item>
<item name="android:textColor">@color/red</item>
<item name="android:layout_marginLeft">24dp</item>
<item name="android:layout_marginStart">24dp</item>
<item name="android:layout_marginRight">24dp</item>
<item name="android:layout_marginEnd">24dp</item>
<item name="android:textSize">12sp</item>
<item name="android:textAllCaps">false</item>
</style>
</resources>