9-30
This commit is contained in:
@@ -75,7 +75,6 @@ dependencies {
|
||||
implementation 'com.github.bumptech.glide:glide:3.8.0'
|
||||
implementation 'com.android.support:support-v4:19.1.0'
|
||||
|
||||
|
||||
//okhttp 网络通信库
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
|
||||
// json解析库
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<!-- To auto-complete the email text field in the login form with the user's emails -->
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
|
||||
<application
|
||||
android:name=".NutritionMaster"
|
||||
android:allowBackup="true"
|
||||
@@ -49,7 +54,10 @@
|
||||
<activity android:name=".modules.addinformation.AddActivity" />
|
||||
<activity android:name=".modules.viewpagerfragments.customization.CustomizationActivity" />
|
||||
<activity android:name=".modules.information.InformationActivity" />
|
||||
<activity android:name=".modules.RecipeActivity.RecipeActivity"></activity>
|
||||
<activity android:name=".modules.RecipeActivity.RecipeActivity" />
|
||||
<activity
|
||||
android:name=".LoginActivity"
|
||||
android:label="@string/title_activity_login"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -4,10 +4,13 @@ import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.bean.MyUser;
|
||||
|
||||
import com.orhanobut.logger.AndroidLogAdapter;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/8/26.
|
||||
*/
|
||||
@@ -16,11 +19,14 @@ public class NutritionMaster extends Application {
|
||||
public static NutritionMaster mInstance;
|
||||
private int appCount = 0;
|
||||
|
||||
public static MyUser user;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mInstance = this;
|
||||
init();
|
||||
initUser();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,4 +85,15 @@ public class NutritionMaster extends Application {
|
||||
return appCount > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化用户信息
|
||||
*/
|
||||
private void initUser() {
|
||||
user = new MyUser();
|
||||
user.setNickName("ScorpioMiku");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class MyUser {
|
||||
* password : password
|
||||
* last_login : null
|
||||
* is_superuser : false
|
||||
* username : okhttptest
|
||||
* nickName : okhttptest
|
||||
* first_name :
|
||||
* last_name :
|
||||
* email :
|
||||
@@ -28,7 +28,7 @@ public class MyUser {
|
||||
private String password;
|
||||
private Object last_login;
|
||||
private boolean is_superuser;
|
||||
private String username;
|
||||
private String nickName;
|
||||
private String first_name;
|
||||
private String last_name;
|
||||
private String email;
|
||||
@@ -80,12 +80,12 @@ public class MyUser {
|
||||
this.is_superuser = is_superuser;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getFirst_name() {
|
||||
@@ -176,7 +176,7 @@ public class MyUser {
|
||||
", password='" + password + '\'' +
|
||||
", last_login=" + last_login +
|
||||
", is_superuser=" + is_superuser +
|
||||
", username='" + username + '\'' +
|
||||
", nickName='" + nickName + '\'' +
|
||||
", first_name='" + first_name + '\'' +
|
||||
", last_name='" + last_name + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.example.ninefourone.nutritionmaster.modules;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
@@ -12,21 +11,24 @@ import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.ToxicBakery.viewpager.transforms.CubeOutTransformer;
|
||||
|
||||
import com.cb.ratingbar.CBRatingBar;
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.adapter.HomePagerAdapter;
|
||||
import com.example.ninefourone.nutritionmaster.base.BaseActivity;
|
||||
import com.example.ninefourone.nutritionmaster.bean.Occupation;
|
||||
import com.example.ninefourone.nutritionmaster.camera.FoodMaterialCamera;
|
||||
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddActivity;
|
||||
import com.example.ninefourone.nutritionmaster.modules.information.InformationActivity;
|
||||
import com.example.ninefourone.nutritionmaster.ui.NoScrollViewPager;
|
||||
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.PermissionUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtils;
|
||||
import com.flyco.tablayout.SlidingTabLayout;
|
||||
import com.github.mikephil.charting.charts.RadarChart;
|
||||
import com.github.mikephil.charting.components.Description;
|
||||
@@ -38,6 +40,7 @@ import com.github.mikephil.charting.data.RadarDataSet;
|
||||
import com.github.mikephil.charting.data.RadarEntry;
|
||||
import com.github.mikephil.charting.formatter.IndexAxisValueFormatter;
|
||||
import com.github.siyamed.shapeimageview.CircularImageView;
|
||||
import com.google.gson.Gson;
|
||||
import com.miguelcatalan.materialsearchview.MaterialSearchView;
|
||||
import com.mxn.soul.flowingdrawer_core.ElasticDrawer;
|
||||
import com.mxn.soul.flowingdrawer_core.FlowingDrawer;
|
||||
@@ -46,12 +49,16 @@ import com.nightonke.boommenu.BoomButtons.OnBMClickListener;
|
||||
import com.nightonke.boommenu.BoomMenuButton;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
@@ -85,7 +92,10 @@ public class MainActivity extends BaseActivity {
|
||||
LinearLayout informationLayout;
|
||||
@BindView(R.id.title_layout)
|
||||
AppBarLayout titleLayout;
|
||||
|
||||
@BindView(R.id.user_nick_name)
|
||||
TextView userNickName;
|
||||
@BindView(R.id.user_occupation_text)
|
||||
TextView userOccupationText;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
@@ -117,6 +127,7 @@ public class MainActivity extends BaseActivity {
|
||||
initViewPager();
|
||||
initSearchView();
|
||||
initBMB();
|
||||
initOccupations();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +162,7 @@ public class MainActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
// TODO: add setContentView(...) invocation
|
||||
ButterKnife.bind(this);
|
||||
Logger.d("oncreate");
|
||||
// Logger.d("oncreate");
|
||||
setSupportActionBar(toolBar);
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
askPermission();
|
||||
@@ -159,7 +170,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
Logger.d("oncreateMenu");
|
||||
// Logger.d("oncreateMenu");
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
MenuItem item = menu.findItem(R.id.id_action_search);
|
||||
searchView.setMenuItem(item);
|
||||
@@ -168,7 +179,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
Logger.d("prepareMenu");
|
||||
// Logger.d("prepareMenu");
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@@ -311,7 +322,14 @@ public class MainActivity extends BaseActivity {
|
||||
MessageUtils.MakeToast("权限赋予成功");
|
||||
}
|
||||
|
||||
@OnClick({R.id.navigation_layout, R.id.add_information_button})
|
||||
|
||||
/**
|
||||
* 点击事件
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
|
||||
@OnClick({R.id.navigation_layout, R.id.add_information_button, R.id.information_layout, R.id.user_occupation_text})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.navigation_layout:
|
||||
@@ -321,12 +339,36 @@ public class MainActivity extends BaseActivity {
|
||||
Intent intent = new Intent(MainActivity.this, AddActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.information_layout:
|
||||
break;
|
||||
case R.id.user_occupation_text:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.information_layout)
|
||||
public void onViewClicked() {
|
||||
Intent intent = new Intent(MainActivity.this, InformationActivity.class);
|
||||
startActivity(intent);
|
||||
/**
|
||||
* 初始化职业常量
|
||||
*/
|
||||
private void initOccupations() {
|
||||
if (userOccupationText.getText().equals("请选择您的职业")) {
|
||||
WebUtils.getAllOccupations(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
Occupation[] occupations = new Gson().fromJson(response.body().string(), Occupation[].class);
|
||||
for (int i = 0; i < occupations.length; i++) {
|
||||
// Logger.d(occupations[i].getOccupation_name());
|
||||
ConstantUtils.occupationList.add(occupations[i].getOccupation_name());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
package com.example.ninefourone.nutritionmaster.modules.login;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.app.LoaderManager.LoaderCallbacks;
|
||||
|
||||
import android.content.CursorLoader;
|
||||
import android.content.Loader;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
|
||||
import static android.Manifest.permission.READ_CONTACTS;
|
||||
|
||||
/**
|
||||
* A login screen that offers login via email/password.
|
||||
*/
|
||||
public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<Cursor> {
|
||||
|
||||
/**
|
||||
* Id to identity READ_CONTACTS permission request.
|
||||
*/
|
||||
private static final int REQUEST_READ_CONTACTS = 0;
|
||||
|
||||
/**
|
||||
* A dummy authentication store containing known user names and passwords.
|
||||
* TODO: remove after connecting to a real authentication system.
|
||||
*/
|
||||
private static final String[] DUMMY_CREDENTIALS = new String[]{
|
||||
"foo@example.com:hello", "bar@example.com:world"
|
||||
};
|
||||
/**
|
||||
* Keep track of the login task to ensure we can cancel it if requested.
|
||||
*/
|
||||
private UserLoginTask mAuthTask = null;
|
||||
|
||||
// UI references.
|
||||
private AutoCompleteTextView mEmailView;
|
||||
private EditText mPasswordView;
|
||||
private View mProgressView;
|
||||
private View mLoginFormView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
// Set up the login form.
|
||||
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
|
||||
populateAutoComplete();
|
||||
|
||||
mPasswordView = (EditText) findViewById(R.id.password);
|
||||
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
|
||||
if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
|
||||
attemptLogin();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
|
||||
mEmailSignInButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
attemptLogin();
|
||||
}
|
||||
});
|
||||
|
||||
mLoginFormView = findViewById(R.id.login_form);
|
||||
mProgressView = findViewById(R.id.login_progress);
|
||||
}
|
||||
|
||||
private void populateAutoComplete() {
|
||||
if (!mayRequestContacts()) {
|
||||
return;
|
||||
}
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
private boolean mayRequestContacts() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
return true;
|
||||
}
|
||||
if (checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
}
|
||||
if (shouldShowRequestPermissionRationale(READ_CONTACTS)) {
|
||||
Snackbar.make(mEmailView, R.string.permission_rationale, Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
public void onClick(View v) {
|
||||
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback received when a permissions request has been completed.
|
||||
*/
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
if (requestCode == REQUEST_READ_CONTACTS) {
|
||||
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
populateAutoComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to sign in or register the account specified by the login form.
|
||||
* If there are form errors (invalid email, missing fields, etc.), the
|
||||
* errors are presented and no actual login attempt is made.
|
||||
*/
|
||||
private void attemptLogin() {
|
||||
if (mAuthTask != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset errors.
|
||||
mEmailView.setError(null);
|
||||
mPasswordView.setError(null);
|
||||
|
||||
// Store values at the time of the login attempt.
|
||||
String email = mEmailView.getText().toString();
|
||||
String password = mPasswordView.getText().toString();
|
||||
|
||||
boolean cancel = false;
|
||||
View focusView = null;
|
||||
|
||||
// Check for a valid password, if the user entered one.
|
||||
if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
|
||||
mPasswordView.setError(getString(R.string.error_invalid_password));
|
||||
focusView = mPasswordView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
// Check for a valid email address.
|
||||
if (TextUtils.isEmpty(email)) {
|
||||
mEmailView.setError(getString(R.string.error_field_required));
|
||||
focusView = mEmailView;
|
||||
cancel = true;
|
||||
} else if (!isEmailValid(email)) {
|
||||
mEmailView.setError(getString(R.string.error_invalid_email));
|
||||
focusView = mEmailView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (cancel) {
|
||||
// There was an error; don't attempt login and focus the first
|
||||
// form field with an error.
|
||||
focusView.requestFocus();
|
||||
} else {
|
||||
// Show a progress spinner, and kick off a background task to
|
||||
// perform the user login attempt.
|
||||
showProgress(true);
|
||||
mAuthTask = new UserLoginTask(email, password);
|
||||
mAuthTask.execute((Void) null);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmailValid(String email) {
|
||||
//TODO: Replace this with your own logic
|
||||
return email.contains("@");
|
||||
}
|
||||
|
||||
private boolean isPasswordValid(String password) {
|
||||
//TODO: Replace this with your own logic
|
||||
return password.length() > 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the progress UI and hides the login form.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||
private void showProgress(final boolean show) {
|
||||
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
|
||||
// for very easy animations. If available, use these APIs to fade-in
|
||||
// the progress spinner.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
|
||||
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
|
||||
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
mLoginFormView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mProgressView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// The ViewPropertyAnimator APIs are not available, so simply show
|
||||
// and hide the relevant UI components.
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
||||
return new CursorLoader(this,
|
||||
// Retrieve data rows for the device user's 'profile' contact.
|
||||
Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
|
||||
ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,
|
||||
|
||||
// Select only email addresses.
|
||||
ContactsContract.Contacts.Data.MIMETYPE +
|
||||
" = ?", new String[]{ContactsContract.CommonDataKinds.Email
|
||||
.CONTENT_ITEM_TYPE},
|
||||
|
||||
// Show primary email addresses first. Note that there won't be
|
||||
// a primary email address if the user hasn't specified one.
|
||||
ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
||||
List<String> emails = new ArrayList<>();
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
emails.add(cursor.getString(ProfileQuery.ADDRESS));
|
||||
cursor.moveToNext();
|
||||
}
|
||||
|
||||
addEmailsToAutoComplete(emails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> cursorLoader) {
|
||||
|
||||
}
|
||||
|
||||
private void addEmailsToAutoComplete(List<String> emailAddressCollection) {
|
||||
//Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
|
||||
ArrayAdapter<String> adapter =
|
||||
new ArrayAdapter<>(LoginActivity.this,
|
||||
android.R.layout.simple_dropdown_item_1line, emailAddressCollection);
|
||||
|
||||
mEmailView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
private interface ProfileQuery {
|
||||
String[] PROJECTION = {
|
||||
ContactsContract.CommonDataKinds.Email.ADDRESS,
|
||||
ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
|
||||
};
|
||||
|
||||
int ADDRESS = 0;
|
||||
int IS_PRIMARY = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an asynchronous login/registration task used to authenticate
|
||||
* the user.
|
||||
*/
|
||||
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
private final String mEmail;
|
||||
private final String mPassword;
|
||||
|
||||
UserLoginTask(String email, String password) {
|
||||
mEmail = email;
|
||||
mPassword = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
// TODO: attempt authentication against a network service.
|
||||
|
||||
try {
|
||||
// Simulate network access.
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String credential : DUMMY_CREDENTIALS) {
|
||||
String[] pieces = credential.split(":");
|
||||
if (pieces[0].equals(mEmail)) {
|
||||
// Account exists, return true if the password matches.
|
||||
return pieces[1].equals(mPassword);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: register the new account here.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Boolean success) {
|
||||
mAuthTask = null;
|
||||
showProgress(false);
|
||||
|
||||
if (success) {
|
||||
finish();
|
||||
} else {
|
||||
mPasswordView.setError(getString(R.string.error_incorrect_password));
|
||||
mPasswordView.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
mAuthTask = null;
|
||||
showProgress(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ public class BodyInformationFragment extends BaseFragment {
|
||||
|
||||
private ISportStepInterface iSportStepInterface;
|
||||
|
||||
private ServiceConnection coon;
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutResId() {
|
||||
@@ -94,7 +96,7 @@ public class BodyInformationFragment extends BaseFragment {
|
||||
//开启计步
|
||||
Intent stepCounterStart = new Intent(getActivity(), TodayStepService.class);
|
||||
getActivity().startService(stepCounterStart);
|
||||
getActivity().bindService(stepCounterStart, new ServiceConnection() {
|
||||
coon = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
iSportStepInterface = ISportStepInterface.Stub.asInterface(service);
|
||||
@@ -111,7 +113,8 @@ public class BodyInformationFragment extends BaseFragment {
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
||||
}
|
||||
}, Context.BIND_AUTO_CREATE);
|
||||
};
|
||||
getActivity().bindService(stepCounterStart, coon, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,4 +175,9 @@ public class BodyInformationFragment extends BaseFragment {
|
||||
ChartDrawer.initSingleLineChart(stepLineChart, stepPointValues, "步数");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
// getActivity().unbindService(coon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,7 @@ public class ConstantUtils {
|
||||
{"烫的", "冷的", "没有特别喜欢的"},
|
||||
{"查看"}
|
||||
};
|
||||
|
||||
public static ArrayList<String> occupationList = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,12 @@ package com.example.ninefourone.nutritionmaster.utils;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.bean.Occupation;
|
||||
import com.google.gson.Gson;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
@@ -43,6 +48,7 @@ public class WebUtils {
|
||||
|
||||
/**
|
||||
* 获取count个随机菜谱,在回调中解析为一个Menu数组
|
||||
*
|
||||
* @param count
|
||||
* @param callback
|
||||
*/
|
||||
@@ -126,6 +132,12 @@ public class WebUtils {
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
public static void getAllOccupations(Callback callback) {
|
||||
OkHttpClient mClient = new OkHttpClient();
|
||||
Request request = new Request.Builder().url("http://120.77.182.38/occupation/").build();
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取体质需要的食材
|
||||
* {
|
||||
@@ -188,11 +200,11 @@ public class WebUtils {
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
public static void changeUserOccupation(String username,String password, String occupation, Callback callback) {
|
||||
public static void changeUserOccupation(String username, String password, String occupation, Callback callback) {
|
||||
String url = "http://120.77.182.38/myuser/" + username + "/";
|
||||
RequestBody formBody = new FormBody.Builder()
|
||||
.add("username", username)
|
||||
.add("password",password)
|
||||
.add("password", password)
|
||||
.add("occupation", occupation)
|
||||
.build();
|
||||
|
||||
@@ -205,11 +217,11 @@ public class WebUtils {
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
public static void changeUserPhysique(String username,String password, String physique, Callback callback) {
|
||||
public static void changeUserPhysique(String username, String password, String physique, Callback callback) {
|
||||
String url = "http://120.77.182.38/myuser/" + username + "/";
|
||||
RequestBody formBody = new FormBody.Builder()
|
||||
.add("username", username)
|
||||
.add("password",password)
|
||||
.add("password", password)
|
||||
.add("physique", physique)
|
||||
.build();
|
||||
|
||||
@@ -315,17 +327,19 @@ public class WebUtils {
|
||||
}
|
||||
});*/
|
||||
|
||||
WebUtils.changeUserOccupation("updatatest","1234" ,"气虚质", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// WebUtils.changeUserOccupation("updatatest","1234" ,"气虚质", new Callback() {
|
||||
// @Override
|
||||
// public void onFailure(Call call, IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(Call call, Response response) throws IOException {
|
||||
// System.out.println(response.body().string());
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
System.out.println(response.body().string());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
24
app/src/main/res/drawable/ic_defualt_avatar.xml
Normal file
24
app/src/main/res/drawable/ic_defualt_avatar.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<vector android:height="24dp" android:viewportHeight="1024.0"
|
||||
android:viewportWidth="1024.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#92BE33" android:pathData="M512,1024C230.4,1024 0,793.6 0,512S230.4,0 512,0s512,230.4 512,512 -230.4,512 -512,512z"/>
|
||||
<path android:fillColor="#61872E" android:pathData="M1024,512c0,-30.4 -2.8,-60.1 -8,-89L580.5,202.5s-36.1,-0.8 -48.2,0c-12,0.8 -41.6,1.5 -61.2,12.1 -19.6,10.6 -49.7,38 -49.7,38s-10,-7.1 -25.1,-3.5c-15,3.5 -19.3,22.3 -19.3,22.3s-10.8,86 -9.3,157.4c0,0 -37.4,-32.7 -25.9,32.6 4.2,23.5 26.7,9.2 34.2,6.7 15,73.4 106.7,129.7 98,153 -5.5,14.7 -6.5,16.2 -22.1,21.8 -10.5,3.8 -28.1,5.6 -35.6,17.7 -14,22.5 -7.4,23.8 -7.4,23.8s-92.6,38.5 -100.5,49.6c-7.9,11.1 -7.9,96.9 -7.9,96.9l183.4,192.5c9.2,0.5 18.5,0.8 27.9,0.8 281.6,0 512,-230.4 512,-512z"/>
|
||||
<path android:fillColor="#0D946D" android:pathData="M510.5,716.6l5.6,-9.9 52.2,-19.3 24.7,-21 42.7,14.4 55,25.4 23.6,19.3 2.8,23.2 6.2,80.7 -216.1,5.5zM503.8,717.7l-5.5,-10 -51.4,-19.3 -24.3,-21 -42,14.4 -54.2,25.4 -23.2,19.3 -2.8,23.2 -6.1,80.7 212.8,5.5z"/>
|
||||
<path android:fillColor="#F3D8C2" android:pathData="M562.4,604.4l9.4,41.4 6.6,22.1 -35.4,16.6 -18.8,5.5 -7.7,17.1 -8.8,6.1 -4.4,-25.4 -39.8,-10.5 -10.5,-11.6 6.1,-19.9 10,-40.9 28.2,12.7 19.4,2.8z"/>
|
||||
<path android:fillColor="#3AB394" android:pathData="M527.6,687.3l-6.1,18.8 15.5,-2.2 31.5,-7.2 19.3,-11.1 16.6,-17.7 11.1,1.1 3.3,-9.4 -13.8,-8.8 -11.6,-5.5 -6.1,-10.5 -14.4,-2.2 -5,3.9 7.7,13.8 4.4,14.4 -7.7,10.5zM458.5,630.9l-14.9,0.5 -14.9,8.3 -19.3,7.2 -6.6,16.6v12.7l24.3,-7.2 19.9,19.3 39.8,16 14.4,2.2 -1.1,-18.8 -19.9,-3.9 -16.6,-6.6 -14.9,-8.3 2.8,-18.2z"/>
|
||||
<path android:fillColor="#F3D8C2" android:pathData="M585.1,331.2c-0.8,2.4 -1.9,4.6 -3.4,6.8 -0.6,0.9 -1.6,1.4 -2.7,1.8v20.9s-89.9,-23.7 -114,-66.4c-4.2,1.3 -8.4,2.7 -12.7,3.2 -13.8,8.4 -64.9,41.6 -71.1,73.6 -7.2,37 268.4,104.5 268.4,104.5s14.1,-96.1 -64.4,-144.4"/>
|
||||
<path android:fillColor="#F3D8C2" android:pathData="M649.5,475.6c-19.1,82.5 -86.8,143.8 -135.6,143.8 -13,0 -30.1,-7 -47.9,-19.4 -44.3,-30.8 -92.9,-95.1 -92.9,-169.5 0,-22.2 0,-34.3 5.3,-54.1"/>
|
||||
<path android:fillColor="#474341" android:pathData="M513.9,623.8c-13.8,0 -31.7,-7.2 -50.4,-20.2 -47.2,-32.8 -94.8,-99.1 -94.8,-173.1 0,-22.4 0,-34.7 5.4,-55.2l8.5,2.3c-5.2,19.4 -5.2,31.3 -5.2,53 0,70.8 45.7,134.4 91,165.9 17,11.8 33.5,18.6 45.4,18.6 46.7,0 112.8,-60 131.3,-140.4l8.6,2c-20.1,86.8 -89.9,147.2 -140,147.2"/>
|
||||
<path android:fillColor="#B77917" android:pathData="M655.5,268.3c-13.3,-12.5 -32.7,-7 -48.9,-0.9 2.6,-5.5 12.1,-22.2 14.6,-27.6 -10.8,-9.4 -32.9,-0.1 -45,6.5 3.4,-7.7 9.9,-23.7 17.3,-25.2 -14.3,-30.2 -48.5,-28.3 -77.7,-24.9 -36.8,4.3 -72.2,22.4 -99.9,50.9 -10,-8.8 -25.3,-4.4 -34,6.1 -8.7,10.5 -12.3,25.3 -14.8,39.7 -5.9,33.5 -5.1,91 -2.8,125.2l12.6,-0.1c-0.2,-54.8 30.5,-113.5 86.1,-129.5 4.2,-1.2 6.5,3.5 4.9,6.5 4.6,20.5 35.9,33.5 52.8,41.8 17.1,8.4 53.3,27.6 60.3,-0.5 0.9,-3.5 4.9,-3.9 7.4,-2 8.7,6.9 12.4,16.1 19.6,24.4 6.3,7.3 13.9,13.2 20.1,20.7 9.1,11.1 15.3,22.6 18,36.3l20.2,-0.2c24.1,-69.4 -0.9,-138 -10.6,-147.2"/>
|
||||
<path android:fillColor="#474341" android:pathData="M511.7,625.7c-14.2,0 -32.5,-7.3 -51.5,-20.5 -47.6,-33.1 -95.6,-100 -95.6,-174.7 0,-21.8 0,-35 5.5,-55.7a6.3,6.3 0,0 1,7.7 -4.4,6.3 6.3,0 0,1 4.4,7.7c-5.1,19.2 -5.1,31 -5.1,52.5 0,70.2 45.3,133.1 90.2,164.4 16.7,11.6 32.8,18.3 44.3,18.3 46,0 111.1,-59.4 129.5,-138.9a6.3,6.3 0,0 1,7.5 -4.7,6.3 6.3,0 0,1 4.7,7.5c-20.3,87.6 -91,148.7 -141.8,148.7M725.1,842.2H293.7l-6.3,-6.6s3.1,-57.3 5.2,-96.9c2.3,-42.9 117.3,-73.8 130.5,-77.2 3.3,-0.9 6.8,1.1 7.6,4.5a6.3,6.3 0,0 1,-4.5 7.6c-46.1,11.9 -119.7,40.2 -121.1,65.7 -1.7,31.5 -4,74.1 -4.8,90.3h418.1c-0.9,-16.2 -3.2,-58.8 -4.8,-90.3 -1.3,-25.6 -68.5,-54 -110.5,-66a6.3,6.3 0,0 1,-4.3 -7.7,6.3 6.3,0 0,1 7.7,-4.3c12,3.4 117.4,34.6 119.6,77.4 2.1,39.6 5.2,96.9 5.2,96.9l-6.3,6.6z"/>
|
||||
<path android:fillColor="#474341" android:pathData="M529.1,693.8a6.3,6.3 0,0 1,-0.7 -12.5c17.8,-2.1 33.5,-8.6 43.8,-18 -8.6,-17.7 -13.2,-35.9 -13.8,-54.2a6.3,6.3 0,0 1,6.1 -6.4c3.4,0 6.3,2.6 6.4,6.1 0.5,17.8 5.4,35.6 14.4,52.9l-0.9,7.2c-12.1,13.2 -32,22.3 -54.6,24.9a4.7,4.7 0,0 1,-0.7 0.1M502.7,695.5a5.8,5.8 0,0 1,-0.8 -0c-23.7,-2.8 -43.1,-11.9 -56.2,-26.1l-0.9,-7.2c9.1,-16.7 14.1,-33.9 15,-51.2 0.2,-3.5 3.2,-6.3 6.6,-5.9a6.3,6.3 0,0 1,5.9 6.6c-0.9,17.7 -5.7,35.3 -14.3,52.4 11,10.4 26.2,16.8 45.4,19a6.3,6.3 0,0 1,-0.7 12.5"/>
|
||||
<path android:fillColor="#474341" android:pathData="M498.3,689.2v140.8c0,8.1 12.5,8.1 12.5,0v-140.8c0,-8.1 -12.5,-8.1 -12.5,0"/>
|
||||
<path android:fillColor="#474341" android:pathData="M504.6,737.3c-0.9,0 -1.9,-0.2 -2.8,-0.7a6.3,6.3 0,0 1,-2.8 -8.4L520,686.4a6.3,6.3 0,0 1,8.4 -2.8,6.3 6.3,0 0,1 2.8,8.4l-21,41.8a6.3,6.3 0,0 1,-5.6 3.5M423.9,676.8c20.4,22.3 46.4,30.8 75.4,36.3 7.9,1.5 11.3,-10.6 3.3,-12.1 -26.9,-5.1 -50.8,-12.2 -69.8,-33.1 -5.4,-6 -14.3,2.9 -8.9,8.9"/>
|
||||
<path android:fillColor="#474341" android:pathData="M519.4,712.8c32.6,-3 71,-10.2 89,-41.2 4,-7 -6.8,-13.3 -10.8,-6.3 -15.6,27 -50.2,32.5 -78.2,35 -8,0.7 -8,13.3 0,12.5M406.7,669.8c0.4,-7.8 3.6,-14.8 10.7,-18.7 4.5,-2.5 9.8,-1 14,-3.5 3.8,-2.3 6.3,-6.2 10.6,-8.2 5.3,-2.6 10.7,-3 16.4,-2.6 8,0.6 8,-11.9 0,-12.5 -7.9,-0.6 -15.7,0.6 -22.7,4.3 -6.1,3.2 -9.6,6.6 -16.3,8.4 -15.4,4 -24.4,17.4 -25.1,32.8 -0.4,8.1 12.1,8 12.5,0"/>
|
||||
<path android:fillColor="#474341" android:pathData="M574,640.9c7,-2.4 13.1,0.1 15.1,7.2 0.9,2.9 3.2,4.2 6,4.6 5.3,0.7 12.7,1.5 15.5,6.8 1.8,3.4 1.9,9.4 2.3,13.1 0.8,7.9 13.4,8 12.5,0 -0.8,-7.8 -1.1,-17.9 -6.7,-23.9 -5.7,-6.1 -15.8,-7.5 -23.6,-8.5 2,1.5 4,3.1 6,4.6 -4,-13.6 -17.1,-20.6 -30.6,-16 -7.6,2.6 -4.3,14.7 3.3,12.1M359.8,425.7a6.3,6.3 0,0 1,-6.2 -5.9c-2,-29.9 -3.5,-90.3 3,-126.7 2.7,-15.2 6.6,-30.9 16.3,-42.6 6.2,-7.4 15.2,-12.3 24,-13 5.2,-0.4 10,0.6 14.3,2.8 28.3,-27.4 63.9,-44.8 100.9,-49.1 23.6,-2.7 67.6,-7.8 84.8,28.4a6.3,6.3 0,0 1,-4.4 8.8c-1.1,0.3 -2.8,1.8 -5.4,6.3 12.6,-4.5 26.9,-6.5 36.3,1.6 2.1,1.8 2.8,4.9 1.6,7.4 -1.3,2.8 -4.4,8.5 -7.6,14.2l-0,0c12.8,-3.2 28.6,-4.2 40.7,7.1 12.9,11.9 37,83.4 12.3,153.9a6.3,6.3 0,0 1,-11.8 -4.2c23.3,-66.4 -0.6,-132.7 -9,-140.5 -10.5,-9.8 -26.8,-5.6 -42.9,0.4a6.3,6.3 0,0 1,-6.8 -1.6,6.3 6.3,0 0,1 -1,-6.9c1.3,-2.8 4.4,-8.5 7.6,-14.2 1.6,-2.8 3.1,-5.7 4.4,-8.1 -7.4,-1.6 -19.9,1.7 -34.1,9.3a6.3,6.3 0,0 1,-7.2 -0.9,6.3 6.3,0 0,1 -1.5,-7.1l0.6,-1.3c4.1,-9.3 8.5,-18.5 14.2,-23.6 -13.7,-20.9 -41.7,-19.6 -69.3,-16.4 -35.7,4.1 -70.2,21.6 -97.1,49.1a6.3,6.3 0,0 1,-8.6 0.4c-2.7,-2.4 -6.1,-3.4 -10,-3.1 -5.6,0.4 -11.3,3.6 -15.4,8.5 -7.9,9.4 -11.2,23.2 -13.6,36.7 -5.5,30.6 -5.3,85.5 -2.8,123.6a6.3,6.3 0,0 1,-5.8 6.7,1.7 1.7,0 0,1 -0.4,0"/>
|
||||
<path android:fillColor="#474341" android:pathData="M648.2,430.5a6.3,6.3 0,0 1,-6.1 -5.1c-6.8,-34.8 -32.2,-62.4 -56.5,-85.1 0.1,3.1 0.2,6.3 0.3,9.7 0,2.5 0.1,4.7 0.2,6.3a6.2,6.2 0,0 1,-2 5c-1.4,1.3 -3.2,1.9 -5.1,1.6 -24.4,-3.3 -83.5,-16.4 -116.2,-65.9 -25.2,10.9 -74,38.8 -82.8,93.3a6.3,6.3 0,1 1,-12.4 -2c10.5,-64.4 70.2,-94.8 95.4,-104.9a6.3,6.3 0,0 1,7.7 2.6c26.5,44.1 76.3,58.7 102.7,63.4 -0.2,-7.1 -0.5,-19.2 -2.2,-23a6.3,6.3 0,1 1,9.9 -7.2c28.7,26.1 64.5,58.6 73.3,103.8 0.7,3.4 -1.6,6.7 -5,7.3 -0.4,0.1 -0.8,0.1 -1.2,0.1"/>
|
||||
<path android:fillColor="#F3D8C2" android:pathData="M366.7,424.6c-1.3,-3.2 -5.6,-4.7 -9.3,-4.2 -3.7,0.5 -6.8,2.7 -9.3,5.3 -8.8,8.9 -11.1,21.7 -10.7,33.6 0.2,5.5 0.9,11.2 3.7,16.1 2.9,4.9 8.3,8.9 14.4,8.9 7.3,0 13.1,-5.1 18.1,-10"/>
|
||||
<path android:fillColor="#474341" android:pathData="M372.2,421.4c-6.4,-8.9 -17.2,-9.3 -25.7,-2.6 -10.6,8.3 -14.6,22.1 -15.2,35 -0.6,12.8 1.9,27.6 14.3,34.2 12.3,6.6 23.7,-0.8 32.6,-9.2 5.9,-5.5 -3,-14.4 -8.9,-8.9 -6.5,6.1 -15.1,13.3 -22.7,2.3 -3.1,-4.4 -3,-11.5 -2.9,-16.6 0.1,-4.3 0.6,-8.6 1.7,-12.7 0.7,-2.5 10.3,-23 15.9,-15.2 4.7,6.5 15.6,0.2 10.8,-6.3"/>
|
||||
<path android:fillColor="#F3D8C2" android:pathData="M648.2,432.3c0.3,-12 13.5,-12.5 17.7,-11.9 4.2,0.5 7.8,2.7 10.7,5.3 10.1,8.9 12.7,21.7 12.3,33.6 -0.2,5.6 -1,11.2 -4.3,16.2 -3.3,4.9 -9.5,8.9 -16.5,8.9 -8.3,0 -15,-5.1 -20.7,-10"/>
|
||||
<path android:fillColor="#474341" android:pathData="M654.5,432.3c0.8,-6.4 8.8,-6.3 13,-4.7 7.8,2.9 12.3,11.1 14.1,18.9 1.4,5.7 1.9,13.7 0.3,19.4 -4.7,16.7 -20.2,12.1 -30.1,4 -6.2,-5.1 -15.1,3.7 -8.9,8.9 11.9,9.8 27,16.9 40.9,6.3 13.2,-10.1 13.6,-30.9 8.9,-45.5 -4.2,-13 -15.2,-25.8 -29.8,-25.7 -11.6,0.1 -19.4,7 -20.9,18.3 -1,8 11.5,7.9 12.5,-0M478.3,788.2a4.4,4.4 0,0 1,-4.2 -3c-2.2,-6.4 1,-12.3 3.5,-17.1 0.6,-1.1 1.2,-2.2 1.7,-3.3 -1,-0.5 -1.9,-0.9 -2.8,-1.3 -3.9,-1.7 -8.3,-3.6 -10.8,-8.1 -1.8,-3.2 -2.2,-7.3 -1.1,-11.7 1.5,-6.3 5.5,-12.4 11.8,-17.9 3.2,-2.8 6.5,-5.2 9.8,-7.5 1.9,-1.3 3.7,-2.6 5.5,-4a4.4,4.4 0,0 1,6.7 -4.9,5.9 5.9,0 0,1 2.6,4.7c0.1,3 -2,5.7 -3.8,7a186.9,186.9 0,0 1,-6 4.4c-3.2,2.3 -6.3,4.5 -9.1,6.9 -4.9,4.3 -8,8.8 -9.1,13.4 -0.5,2.2 -0.4,4.1 0.2,5.4 1,1.9 3.6,3 6.5,4.3 1.4,0.6 2.8,1.2 4.1,1.9 0.9,0.5 3.5,1.9 4.3,4.8 0.6,2.2 -0,4.1 -0.6,5.5 -0.7,1.5 -1.5,3.1 -2.3,4.7 -2.1,3.9 -3.9,7.3 -2.9,10.1a4.4,4.4 0,0 1,-4.2 5.9m15.3,-71.5h0.1,-0.1zM551.6,787.3a4.4,4.4 0,0 1,-3.2 -1.4c-3,-3.2 -4,-7.3 -4.9,-11 -0.7,-3.1 -1.4,-5.7 -3,-7.1 -1.2,-1 -3.2,-1.6 -5.4,-2.3 -3.9,-1.2 -8.8,-2.7 -11,-7.8 -1,-2.4 -1.1,-5.2 -0.3,-8.3 0.7,-2.8 1.9,-5.3 3.1,-7.7 1.5,-3.2 2.9,-5.9 2.7,-8.5 -0.2,-4 -4,-7.1 -5.6,-8.2 -3.1,-2.2 -6.3,-3 -8.5,-2.2 -2.3,0.8 -4.8,-0.4 -5.6,-2.7a4.4,4.4 0,0 1,2.7 -5.6c5,-1.8 11,-0.5 16.5,3.3 5.6,4 9,9.4 9.4,14.9 0.3,4.9 -1.8,9.2 -3.6,12.9 -1,2.1 -2,4.1 -2.5,6 -0.4,1.6 -0.2,2.4 -0.1,2.7 0.5,1.2 2.4,1.8 5.4,2.8 2.8,0.9 6,1.8 8.6,4 3.8,3.2 4.9,7.8 5.8,11.8 0.7,2.8 1.3,5.5 2.7,7a4.4,4.4 0,0 1,-0.2 6.2,4.5 4.5,0 0,1 -3,1.2"/>
|
||||
<path android:fillColor="#925618" android:pathData="M400.5,263.8c-24.6,5.1 -26.4,50.3 -26.2,69.2 0.1,5.7 8.9,5.7 8.8,0 -0.1,-13.1 0.7,-56.8 19.7,-60.7 5.6,-1.1 3.2,-9.7 -2.4,-8.5M650.4,357.7c-0.1,7.6 -0.7,15.1 -1.2,22.7 -0.4,5.7 8.5,5.7 8.8,0 0.5,-7.5 1.1,-15.1 1.2,-22.7 0.1,-5.7 -8.8,-5.7 -8.8,0M544.8,328.2a114.4,114.4 0,0 0,11.7 4c5.5,1.5 7.8,-7 2.4,-8.5a114.3,114.3 0,0 1,-11.7 -4c-5.3,-2.1 -7.6,6.4 -2.4,8.5M466.3,270.6c19.6,16.7 38.9,35.3 61,48.9 4.9,3 9.3,-4.7 4.5,-7.6 -21.4,-13.2 -40.1,-31.2 -59.2,-47.5 -4.3,-3.7 -10.6,2.5 -6.3,6.2"/>
|
||||
</vector>
|
||||
77
app/src/main/res/layout/activity_login.xml
Normal file
77
app/src/main/res/layout/activity_login.xml
Normal file
@@ -0,0 +1,77 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="com.example.ninefourone.nutritionmaster.modules.login.LoginActivity">
|
||||
|
||||
<!-- Login progress -->
|
||||
<ProgressBar
|
||||
android:id="@+id/login_progress"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/login_form"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/email_login_form"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/prompt_email"
|
||||
android:inputType="textEmailAddress"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/prompt_password"
|
||||
android:imeActionId="6"
|
||||
android:imeActionLabel="@string/action_sign_in_short"
|
||||
android:imeOptions="actionUnspecified"
|
||||
android:inputType="textPassword"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/email_sign_in_button"
|
||||
style="?android:textAppearanceSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/action_sign_in"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
@@ -147,27 +147,39 @@
|
||||
android:layout_height="60dp"
|
||||
android:src="@drawable/test_avatar" />
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginTop="10dp">
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_nick_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:gravity="center"
|
||||
android:text="ScorpioMiku"
|
||||
android:textColor="#FFF" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_occupation_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:gravity="center"
|
||||
android:text="请选择您的职业"
|
||||
android:textColor="#FFF" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignTop="@+id/add_information_button"
|
||||
android:alpha="0.2"
|
||||
android:src="@drawable/icon_black" />
|
||||
|
||||
@@ -179,6 +191,8 @@
|
||||
android:layout_marginRight="25dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:src="@drawable/ic_data_add" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -5,4 +5,18 @@
|
||||
<string name="pig">M1080.3,453.7c-77.2,88.2 -214.6,234.4 -214.6,234.4s22,160.2 35.3,269.7c5.9,55.9 -37.5,80.1 -86,58.1 -92.6,-43.4 -233.7,-111 -265.3,-126.4 -32.3,14.7 -174.2,81.6 -267.5,124.9 -49.2,21.3 -92.6,-2.2 -87.5,-58.1 12.5,-109.5 35.3,-269 35.3,-269S91.1,541.9 13.2,453.7c-27.9,-32.3 -9.6,-77.9 44.8,-86 111.7,-19.8 284.4,-51.4 284.4,-51.4s94.8,-163.1 154.3,-263.1C529.8,-7.8 552.6,-0.4 556.3,1c10.3,2.9 26.5,15.4 47,52.2 58.8,99.9 152.1,263.1 152.1,263.1s170.5,31.6 280.7,51.4c53.6,8.1 71.3,54.4 44.1,86z</string>
|
||||
<string name="food_meterial_title">食材识别</string>
|
||||
<string name="food_title">菜品识别</string>
|
||||
<string name="title_activity_login">登录</string>
|
||||
|
||||
<!-- Strings related to login -->
|
||||
<string name="prompt_email">Email</string>
|
||||
<string name="prompt_password">Password (optional)</string>
|
||||
<string name="action_sign_in">Sign in or register</string>
|
||||
<string name="action_sign_in_short">Sign in</string>
|
||||
<string name="error_invalid_email">This email address is invalid</string>
|
||||
<string name="error_invalid_password">This password is too short</string>
|
||||
<string name="error_incorrect_password">This password is incorrect</string>
|
||||
<string name="error_field_required">This field is required</string>
|
||||
<string name="permission_rationale">"Contacts permissions are needed for providing email
|
||||
completions."
|
||||
</string>
|
||||
</resources>
|
||||
|
||||
@@ -25,6 +25,7 @@ allprojects {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://bintray.com/rameshbhupathi/maven' }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user