mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 08:38:03 -06:00
Work on the back button
This commit is contained in:
@@ -7,6 +7,7 @@ import com.astatin3.scoutingapp2025.utility.fileEditor;
|
|||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.navigation.NavController;
|
import androidx.navigation.NavController;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
import androidx.navigation.ui.AppBarConfiguration;
|
import androidx.navigation.ui.AppBarConfiguration;
|
||||||
@@ -20,6 +21,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
private ActivityMainBinding binding;
|
private ActivityMainBinding binding;
|
||||||
|
private BottomNavigationView navView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -39,7 +41,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
BottomNavigationView navView = findViewById(R.id.nav_view);
|
navView = findViewById(R.id.nav_view);
|
||||||
// Passing each menu ID as a set of Ids because each
|
// Passing each menu ID as a set of Ids because each
|
||||||
// menu should be considered as top level destinations.
|
// menu should be considered as top level destinations.
|
||||||
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
|
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.astatin3.scoutingapp2025.ui.data;
|
|||||||
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -11,6 +12,8 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.astatin3.scoutingapp2025.MainActivity;
|
||||||
|
import com.astatin3.scoutingapp2025.R;
|
||||||
import com.astatin3.scoutingapp2025.SettingsVersionStack.latestSettings;
|
import com.astatin3.scoutingapp2025.SettingsVersionStack.latestSettings;
|
||||||
import com.astatin3.scoutingapp2025.databinding.FragmentDataBinding;
|
import com.astatin3.scoutingapp2025.databinding.FragmentDataBinding;
|
||||||
import com.astatin3.scoutingapp2025.utility.fileEditor;
|
import com.astatin3.scoutingapp2025.utility.fileEditor;
|
||||||
@@ -49,4 +52,30 @@ public class dataFragment extends Fragment {
|
|||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
if(getView() == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getView().setFocusableInTouchMode(true);
|
||||||
|
getView().requestFocus();
|
||||||
|
getView().setOnKeyListener(new View.OnKeyListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
|
|
||||||
|
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK){
|
||||||
|
// handle back button's click listener
|
||||||
|
|
||||||
|
System.out.println("Back");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -67,9 +67,6 @@ public class pitScoutingView extends ConstraintLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(ScoutingDataWriter.save(values.length-1, username, filename, types));
|
System.out.println(ScoutingDataWriter.save(values.length-1, username, filename, types));
|
||||||
|
|
||||||
// fileEditor.createFile(filename);
|
|
||||||
// save_fields();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set_indicator_color(int color){
|
public void set_indicator_color(int color){
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.astatin3.scoutingapp2025.ui.scouting;
|
package com.astatin3.scoutingapp2025.ui.scouting;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -10,12 +11,14 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.astatin3.scoutingapp2025.MainActivity;
|
||||||
import com.astatin3.scoutingapp2025.SettingsVersionStack.latestSettings;
|
import com.astatin3.scoutingapp2025.SettingsVersionStack.latestSettings;
|
||||||
import com.astatin3.scoutingapp2025.databinding.FragmentScoutingBinding;
|
import com.astatin3.scoutingapp2025.databinding.FragmentScoutingBinding;
|
||||||
|
|
||||||
public class scoutingFragment extends Fragment {
|
public class scoutingFragment extends Fragment {
|
||||||
|
|
||||||
private FragmentScoutingBinding binding;
|
private FragmentScoutingBinding binding;
|
||||||
|
private boolean is_main_page = true;
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
@@ -30,12 +33,14 @@ public class scoutingFragment extends Fragment {
|
|||||||
if(latestSettings.settings.get_evcode().equals("unset")){
|
if(latestSettings.settings.get_evcode().equals("unset")){
|
||||||
binding.noEventError.setVisibility(View.VISIBLE);
|
binding.noEventError.setVisibility(View.VISIBLE);
|
||||||
binding.buttons.setVisibility(View.GONE);
|
binding.buttons.setVisibility(View.GONE);
|
||||||
|
is_main_page = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.matchScoutingButton.setOnClickListener(v -> {
|
binding.matchScoutingButton.setOnClickListener(v -> {
|
||||||
binding.buttons.setVisibility(View.GONE);
|
binding.buttons.setVisibility(View.GONE);
|
||||||
binding.matchScoutingView.setVisibility(View.VISIBLE);
|
binding.matchScoutingView.setVisibility(View.VISIBLE);
|
||||||
binding.matchScoutingView.init(binding);
|
binding.matchScoutingView.init(binding);
|
||||||
|
is_main_page = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
binding.pitScoutingButton.setOnClickListener(v -> {
|
binding.pitScoutingButton.setOnClickListener(v -> {
|
||||||
@@ -43,8 +48,40 @@ public class scoutingFragment extends Fragment {
|
|||||||
binding.buttons.setVisibility(View.GONE);
|
binding.buttons.setVisibility(View.GONE);
|
||||||
// binding.pitScoutArea.setVisibility(View.VISIBLE);
|
// binding.pitScoutArea.setVisibility(View.VISIBLE);
|
||||||
binding.pitScoutingView.init(binding);
|
binding.pitScoutingView.init(binding);
|
||||||
|
is_main_page = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
if(getView() == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getView().setFocusableInTouchMode(true);
|
||||||
|
getView().requestFocus();
|
||||||
|
getView().setOnKeyListener(new View.OnKeyListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
|
|
||||||
|
if (event.getAction() == KeyEvent.ACTION_UP
|
||||||
|
&& keyCode == KeyEvent.KEYCODE_BACK
|
||||||
|
&& !is_main_page){
|
||||||
|
|
||||||
|
binding.buttons.setVisibility(View.VISIBLE);
|
||||||
|
binding.matchScoutingView.setVisibility(View.GONE);
|
||||||
|
binding.pitScoutingView.setVisibility(View.GONE);
|
||||||
|
is_main_page = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,12 +28,10 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="48dp"
|
android:layout_marginBottom="48dp"
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
tools:visibility="gone">
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/matchScoutingButton"
|
android:id="@+id/matchScoutingButton"
|
||||||
@@ -194,12 +192,14 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginBottom="60dp"
|
android:layout_marginBottom="60dp"
|
||||||
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="1.0"
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_bias="1.0">
|
app:layout_constraintVertical_bias="1.0"
|
||||||
|
tools:visibility="gone">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -239,12 +239,10 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#60ff0000"
|
android:background="#60ff0000"
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@id/back_button"
|
app:layout_constraintBottom_toBottomOf="@id/back_button"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
tools:visibility="gone">
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/pit_back_button"
|
android:id="@+id/pit_back_button"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="60dp"
|
android:layout_marginBottom="60dp"
|
||||||
android:visibility="visible"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
@@ -233,7 +233,7 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:visibility="visible">
|
tools:visibility="gone">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user