mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Merge pull request #65 from ClaytonWWilson/aaron-branch-2
Aaron branch 2
This commit is contained in:
commit
7e19a898ff
@ -60,6 +60,10 @@ public class AuthManager {
|
||||
return authSession.getUserPoolTokens().getValue().getIdToken();
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
@ -152,6 +156,8 @@ public class AuthManager {
|
||||
|
||||
public void signOutUser() throws AuthException {
|
||||
authSession = null;
|
||||
email = null;
|
||||
password = null;
|
||||
waiting = true;
|
||||
Amplify.Auth.signOut(this::signOutSuccess, error -> setAuthError(error));
|
||||
throwIfAuthError();
|
||||
|
||||
@ -21,6 +21,7 @@ import com.example.listify.data.Item;
|
||||
import com.example.listify.data.ItemSearch;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListEntry;
|
||||
import com.example.listify.ui.LoginPage;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import static com.example.listify.SplashActivity.showSplash;
|
||||
|
||||
@ -52,6 +53,11 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
}, 1);
|
||||
}
|
||||
|
||||
if(am.getEmail() == null) {
|
||||
Intent intent = new Intent(MainActivity.this, LoginPage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------Auth Testing---------------------------------------------//
|
||||
|
||||
@ -196,6 +202,24 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
});
|
||||
}
|
||||
|
||||
public void onClickSignout(MenuItem m) {
|
||||
m.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
try {
|
||||
am.signOutUser();
|
||||
Intent intent = new Intent(MainActivity.this, com.example.listify.ui.LoginPage.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendNewListName(String name) {
|
||||
Properties configs = new Properties();
|
||||
|
||||
@ -8,6 +8,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.listify.MainActivity;
|
||||
import com.example.listify.R;
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
@ -25,6 +26,11 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_forgotpswd);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -70,6 +76,7 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
|
||||
am.confirmPasswordReset(newPassword, code);
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
|
||||
@ -25,6 +25,11 @@ public class LoginPage extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -57,6 +62,7 @@ public class LoginPage extends AppCompatActivity {
|
||||
am.signIn(email, password);
|
||||
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
|
||||
@ -19,11 +19,20 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
||||
private Button button1; //Log in page button
|
||||
private Button button2; //Sign up button
|
||||
|
||||
String email;
|
||||
String password;
|
||||
String confirmPassword;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_signup);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -41,9 +50,9 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
||||
EditText passwordText = (EditText) findViewById(R.id.editTextTextPassword);
|
||||
EditText confirmPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
|
||||
|
||||
String email = emailText.getText().toString();
|
||||
String password = passwordText.getText().toString();
|
||||
String confirmPassword = confirmPasswordText.getText().toString();
|
||||
email = emailText.getText().toString();
|
||||
password = passwordText.getText().toString();
|
||||
confirmPassword = confirmPasswordText.getText().toString();
|
||||
|
||||
if(!password.equals(confirmPassword)) {
|
||||
TextView invalidCred = findViewById(R.id.textView3);
|
||||
@ -76,8 +85,10 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
||||
if(!cancel) {
|
||||
try {
|
||||
am.confirmSignUp(code);
|
||||
am.signIn(email, password);
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
|
||||
@ -29,22 +29,12 @@ import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
private Button toLoginPage;
|
||||
private Button toDeleteAccountPage;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = inflater.inflate(R.layout.fragment_home, container, false);
|
||||
|
||||
toLoginPage = (Button) root.findViewById(R.id.button1);
|
||||
toLoginPage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), com.example.listify.ui.LoginPage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
toDeleteAccountPage = (Button) root.findViewById(R.id.button2);
|
||||
toDeleteAccountPage = (Button) root.findViewById(R.id.button);
|
||||
toDeleteAccountPage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -68,6 +58,9 @@ public class HomeFragment extends Fragment {
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
am.deleteUser(requestor);
|
||||
Intent intent = new Intent(getActivity(), com.example.listify.ui.LoginPage.class);
|
||||
startActivity(intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Code"
|
||||
android:inputType="textPersonName"
|
||||
android:hint=""
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
android:layout_marginTop="23dp"
|
||||
android:ems="10"
|
||||
android:hint="Password"
|
||||
android:inputType="textPersonName"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextEmailAddress"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
|
||||
|
||||
|
||||
@ -7,17 +7,7 @@
|
||||
tools:context=".ui.home.HomeFragment">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:text="Log in"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Delete Account"
|
||||
|
||||
@ -8,22 +8,26 @@
|
||||
android:id="@+id/nav_home"
|
||||
android:icon="@drawable/ic_menu_camera"
|
||||
android:title="@string/menu_home" />
|
||||
<!-- <item-->
|
||||
<!-- android:id="@+id/nav_gallery"-->
|
||||
<!-- android:icon="@drawable/ic_menu_gallery"-->
|
||||
<!-- android:title="@string/menu_gallery" />-->
|
||||
<!-- <item-->
|
||||
<!-- android:id="@+id/nav_slideshow"-->
|
||||
<!-- android:icon="@drawable/ic_menu_slideshow"-->
|
||||
<!-- android:title="@string/menu_slideshow" />-->
|
||||
<!-- <item-->
|
||||
<!-- android:id="@+id/nav_gallery"-->
|
||||
<!-- android:icon="@drawable/ic_menu_gallery"-->
|
||||
<!-- android:title="@string/menu_gallery" />-->
|
||||
<!-- <item-->
|
||||
<!-- android:id="@+id/nav_slideshow"-->
|
||||
<!-- android:icon="@drawable/ic_menu_slideshow"-->
|
||||
<!-- android:title="@string/menu_slideshow" />-->
|
||||
<item
|
||||
android:id="@+id/nav_lists"
|
||||
android:icon="@drawable/ic_baseline_list_alt_28"
|
||||
android:title="@string/menu_lists" />
|
||||
<!-- <item-->
|
||||
<!-- android:id="@+id/nav_create_list"-->
|
||||
<!-- android:icon="@drawable/ic_baseline_add_28"-->
|
||||
<!-- android:title="Create New List"-->
|
||||
<!-- android:onClick="onClickCreateList" />-->
|
||||
<item
|
||||
android:id="@+id/nav_create_list"
|
||||
android:icon="@drawable/ic_baseline_add_28"
|
||||
android:title="Create New List"
|
||||
android:onClick="onClickCreateList"/>
|
||||
android:id="@+id/nav_logout"
|
||||
android:title="Sign out"
|
||||
android:onClick="onClickSignout" />
|
||||
</group>
|
||||
</menu>
|
||||
Loading…
Reference in New Issue
Block a user