-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
button stuff + tool bar back button completed
- Loading branch information
Showing
9 changed files
with
273 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/example/camlingo/DailyQuestActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
package com.example.camlingo; | ||
|
||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
|
||
import androidx.activity.EdgeToEdge; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
@@ -10,11 +15,44 @@ | |
|
||
public class LoginActivity extends AppCompatActivity { | ||
|
||
private Button loginButton; | ||
private EditText UsernameEditText; | ||
private EditText PassWEditText; | ||
private SharedPreferences prefs; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
EdgeToEdge.enable(this); | ||
setContentView(R.layout.activity_login); | ||
|
||
loginButton = findViewById(R.id.button_login); | ||
UsernameEditText = findViewById(R.id.username_input); | ||
PassWEditText = findViewById(R.id.password_input); | ||
prefs = getSharedPreferences("UserPrefs", MODE_PRIVATE); | ||
|
||
//preserve username so it will appear next time | ||
String inputusername = prefs.getString("DefaultEmail", "[email protected]"); | ||
UsernameEditText.setText(inputusername); | ||
|
||
//when the login button is pressed | ||
loginButton.setOnClickListener(view -> { | ||
String user = UsernameEditText.getText().toString(); | ||
String password = PassWEditText.getText().toString(); | ||
|
||
//place for checking user and password validation | ||
|
||
//preserved username | ||
SharedPreferences.Editor edit = prefs.edit(); | ||
edit.putString("DefaultUserName", user); | ||
edit.apply(); | ||
|
||
//start login activity | ||
Intent intent = new Intent(LoginActivity.this, MainActivity.class); | ||
startActivity(intent); | ||
}); | ||
|
||
|
||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { | ||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); | ||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.