Login, Registrieren
Login verbessert Registrieren hinzugefügt
This commit is contained in:
parent
e8c50bba71
commit
efe3885de9
BIN
.idea/caches/gradle_models.ser
generated
BIN
.idea/caches/gradle_models.ser
generated
Binary file not shown.
@ -7,8 +7,8 @@ android {
|
||||
applicationId "at.smartshopper.smartshopperapp"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 28
|
||||
versionCode 11
|
||||
versionName "4.1"
|
||||
versionCode 12
|
||||
versionName "4.2"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
Binary file not shown.
@ -13,30 +13,35 @@
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name="at.smartshopper.smartshopperapp.activitys.EditUser"
|
||||
android:label="@string/title_activity_edit_user"/>
|
||||
<activity android:name="at.smartshopper.smartshopperapp.activitys.DoneItemActivity" />
|
||||
android:name=".activitys.Register"
|
||||
android:label="@string/title_activity_register"></activity>
|
||||
<activity
|
||||
android:name="at.smartshopper.smartshopperapp.activitys.ItemListActivity"
|
||||
android:name=".activitys.EditUser"
|
||||
android:label="@string/title_activity_edit_user" />
|
||||
<activity android:name=".activitys.DoneItemActivity" />
|
||||
<activity
|
||||
android:name=".activitys.ItemListActivity"
|
||||
android:label="@string/title_activity_item_list" />
|
||||
<activity android:name="at.smartshopper.smartshopperapp.activitys.Colorpicker" />
|
||||
<activity android:name="at.smartshopper.smartshopperapp.activitys.LoginActivity">
|
||||
<activity android:name=".activitys.Colorpicker" />
|
||||
<activity android:name=".activitys.LoginActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="smartshopper.cf"
|
||||
android:scheme="https"/>
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="at.smartshopper.smartshopperapp.activitys.Dash"
|
||||
android:name=".activitys.Dash"
|
||||
android:label="SmartShopper"
|
||||
android:theme="@style/AppTheme" />
|
||||
<!--
|
||||
@ -54,16 +59,15 @@
|
||||
android:name="com.google.firebase.messaging.default_notification_color"
|
||||
android:resource="@color/colorPrimaryDark" /> <!-- [START firebase_service] -->
|
||||
<service
|
||||
android:name="at.smartshopper.smartshopperapp.messaging.MyFirebaseMessagingService"
|
||||
android:name=".messaging.MyFirebaseMessagingService"
|
||||
android:stopWithTask="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service> <!-- [END firebase_service] -->
|
||||
<activity
|
||||
android:name="at.smartshopper.smartshopperapp.activitys.ShoppinglistDetails"
|
||||
android:name=".activitys.ShoppinglistDetails"
|
||||
android:label="@string/title_activity_shoppinglist_details" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -7,6 +7,8 @@ import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
@ -241,13 +243,63 @@ public class LoginActivity extends AppCompatActivity {
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
db = new Database();
|
||||
|
||||
Button register = (Button)findViewById(R.id.registrierenBtn);
|
||||
register.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginActivity.this, Register.class);
|
||||
finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Button loginEmailBtn = (Button) findViewById(R.id.loginEmailBtn);
|
||||
final Button loginEmailBtn = (Button) findViewById(R.id.loginEmailBtn);
|
||||
loginEmailBtn.setEnabled(false);
|
||||
final TextView email = (TextView) findViewById(R.id.email);
|
||||
final TextView passwort = (TextView) findViewById(R.id.password);
|
||||
button = (SignInButton) findViewById(R.id.loginGoogleBtn);
|
||||
|
||||
email.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if(!email.getText().toString().isEmpty() && !passwort.getText().toString().isEmpty()){
|
||||
loginEmailBtn.setEnabled(true);
|
||||
}else{
|
||||
loginEmailBtn.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
passwort.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if(!email.getText().toString().isEmpty() && !passwort.getText().toString().isEmpty()){
|
||||
loginEmailBtn.setEnabled(true);
|
||||
}else{
|
||||
loginEmailBtn.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
loginEmailBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -0,0 +1,161 @@
|
||||
package at.smartshopper.smartshopperapp.activitys;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.auth.AuthResult;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
import com.google.firebase.auth.UserProfileChangeRequest;
|
||||
|
||||
import at.smartshopper.smartshopperapp.R;
|
||||
|
||||
public class Register extends Activity {
|
||||
|
||||
private FirebaseAuth mAuth;
|
||||
|
||||
|
||||
private void register(String email, String password, final String name) {
|
||||
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||
if (task.isSuccessful()) {
|
||||
// Sign in success, update UI with the signed-in user's information
|
||||
Log.d("Register", "Erfolgreich registriert");
|
||||
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
|
||||
|
||||
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
|
||||
.setDisplayName(name)
|
||||
.setPhotoUri(Uri.parse("http://techfrage.de/upfiles/13547334191038217.png"))
|
||||
.build();
|
||||
|
||||
user.updateProfile(profileUpdates)
|
||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<Void> task) {
|
||||
if (task.isSuccessful()) {
|
||||
Log.d("Register", "Name und bild gesetzt");
|
||||
Intent intent = new Intent(Register.this, LoginActivity.class);
|
||||
finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// If sign in fails, display a message to the user.
|
||||
Log.w("Register", "Ein fehler ist aufgetreten", task.getException());
|
||||
Toast.makeText(Register.this, "Ein Fehler ist aufgetreten",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_register);
|
||||
|
||||
// ...
|
||||
// Initialize Firebase Auth
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
|
||||
final TextView email = findViewById(R.id.emailregister);
|
||||
final TextView passwort = findViewById(R.id.passwordregister);
|
||||
final TextView name = findViewById(R.id.nameregister);
|
||||
Button back = findViewById(R.id.backLogin);
|
||||
final Button register = findViewById(R.id.register);
|
||||
register.setEnabled(false);
|
||||
|
||||
register.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
register(email.getText().toString(), passwort.getText().toString(), name.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
name.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!name.getText().toString().isEmpty() && !email.getText().toString().isEmpty() && !passwort.getText().toString().isEmpty()) {
|
||||
register.setEnabled(true);
|
||||
} else {
|
||||
register.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
email.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!name.getText().toString().isEmpty() && !email.getText().toString().isEmpty() && !passwort.getText().toString().isEmpty()) {
|
||||
register.setEnabled(true);
|
||||
} else {
|
||||
register.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
passwort.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!name.getText().toString().isEmpty() && !email.getText().toString().isEmpty() && !passwort.getText().toString().isEmpty()) {
|
||||
register.setEnabled(true);
|
||||
} else {
|
||||
register.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Register.this, LoginActivity.class);
|
||||
finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
113
app/src/main/res/layout/activity_register.xml
Normal file
113
app/src/main/res/layout/activity_register.xml
Normal file
@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activitys.Register">
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
tools:layout_editor_absoluteX="8dp"
|
||||
tools:layout_editor_absoluteY="8dp">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="7dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@mipmap/ic_launcher_round" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/nameregister"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="Name"
|
||||
android:inputType="textEmailAddress"
|
||||
tools:layout_editor_absoluteX="33dp"
|
||||
tools:layout_editor_absoluteY="33dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/emailregister"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="Email"
|
||||
android:inputType="textEmailAddress"
|
||||
tools:layout_editor_absoluteX="33dp"
|
||||
tools:layout_editor_absoluteY="33dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/passwordregister"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="Passwort"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:layout_editor_absoluteY="232dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/register"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorAccent"
|
||||
android:text="Jetzt Registrieren" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<Button
|
||||
android:id="@+id/backLogin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Zurück zum Login" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -8,6 +8,7 @@
|
||||
<string name="firebase_sender_id">221332577314</string>
|
||||
<string name="StringTag">SmartShopper</string>
|
||||
<string name="title_activity_edit_user">EditUser</string>
|
||||
<string name="title_activity_register">Register</string>
|
||||
|
||||
</resources>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user