Skip to content

Commit

Permalink
button stuff + tool bar back button completed
Browse files Browse the repository at this point in the history
  • Loading branch information
TTDoorTT committed Oct 30, 2024
1 parent 814d5cc commit b30cd96
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 117 deletions.
17 changes: 10 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@

<activity
android:name=".LoginActivity"
android:exported="true"/>
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".DailyQuestActivity"
android:parentActivityName=".MainActivity"
android:exported="true" />

<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:parentActivityName=".LoginActivity"
android:exported="true"/>

</application>

</manifest>
46 changes: 46 additions & 0 deletions app/src/main/java/com/example/camlingo/DailyQuestActivity.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,66 @@
package com.example.camlingo;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.cardview.widget.CardView;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import java.util.Objects;

public class DailyQuestActivity extends AppCompatActivity {

private Button ClaimButton, StarQuestButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_daily_quest);

//find button by id
ClaimButton = findViewById(R.id.claim_button_DailyQuest);
StarQuestButton = findViewById(R.id.startQuest_button_DailyQuest);

//back button on toolbar
Toolbar toolbar = findViewById(R.id.dailyQuest_toolbar);
setSupportActionBar(toolbar);

// Clear default title
Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);

//this adds the back button, so when pressed it goes back to the login page
getSupportActionBar().setDisplayHomeAsUpEnabled(true);


//"Claim Now" button click
ClaimButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//no activity to open yet, just a placeholder here
Intent intent = new Intent(DailyQuestActivity.this, DailyQuestActivity.class);
startActivity(intent);
}
});

//Start today's quest button click
StarQuestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//no activity to open yet, just a placeholder here
Intent intent = new Intent(DailyQuestActivity.this, DailyQuestActivity.class);
startActivity(intent);
}
});


ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.daily_quests), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
Expand Down
38 changes: 38 additions & 0 deletions app/src/main/java/com/example/camlingo/LoginActivity.java
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;
Expand All @@ -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);
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/java/com/example/camlingo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ protected void onCreate(Bundle savedInstanceState) {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

//this adds the back button, so when pressed it goes back to the login page
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

// Clear default title
Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);

Expand All @@ -41,6 +44,28 @@ public void onClick(View v) {
startActivity(new Intent(MainActivity.this, DailyQuestActivity.class));
}
});

//ContinueLearning button click
continueLearningCard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

//no activity to open yet, just a placeholder here
Intent intent = new Intent(MainActivity.this, MainActivity.class);
startActivity(intent);
}
});

//leader board card button click
leaderboardCard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//no activity to open yet, just a placeholder here
Intent intent = new Intent(MainActivity.this, MainActivity.class);
startActivity(intent);
}
});

}

@Override
Expand Down
Loading

0 comments on commit b30cd96

Please sign in to comment.