mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 08:38:03 -06:00
Solve random things
This commit is contained in:
@@ -20,6 +20,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.divider.MaterialDivider;
|
||||
import com.ridgebotics.ridgescout.ui.views.PitScoutingIndicator;
|
||||
import com.ridgebotics.ridgescout.ui.views.ToggleTitleView;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
@@ -76,7 +77,6 @@ public class PitScoutingFragment extends Fragment {
|
||||
|
||||
String fileUsernames = "";
|
||||
ToggleTitleView[] titles;
|
||||
|
||||
AutoSaveManager asm = new AutoSaveManager(this::save, AUTO_SAVE_DELAY);
|
||||
|
||||
ArrayList<RawDataType> rawDataTypes;
|
||||
@@ -99,7 +99,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
}
|
||||
|
||||
public void set_indicator_color(int color){
|
||||
binding.pitFileIndicator.setBackgroundColor(color);
|
||||
binding.pitIndicator.setColor(color);
|
||||
}
|
||||
|
||||
public void update_asm(){
|
||||
@@ -114,10 +114,9 @@ public class PitScoutingFragment extends Fragment {
|
||||
public void loadTeam(){
|
||||
// clear_fields();
|
||||
|
||||
binding.pitFileIndicator.setVisibility(View.VISIBLE);
|
||||
binding.pitsTeamCard.setVisibility(View.VISIBLE);
|
||||
binding.pitBarTeamNum.setText(String.valueOf(team.teamNumber));
|
||||
binding.pitUsername.setText(SettingsManager.getUsername());
|
||||
binding.pitIndicator.setTeamNum(team.teamNumber);
|
||||
binding.pitIndicator.setUsername(SettingsManager.getUsername());
|
||||
binding.pitsTeamCard.fromTeam(team);
|
||||
|
||||
filename = evcode + "-" + team.teamNumber + ".pitscoutdata";
|
||||
@@ -146,7 +145,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
binding.pitFileIndicator.bringToFront();
|
||||
binding.pitIndicator.bringToFront();
|
||||
|
||||
asm.start();
|
||||
|
||||
@@ -154,7 +153,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
|
||||
private void enableRescoutButton(){
|
||||
set_indicator_color(rescout ? rescout_color : saved_color);
|
||||
binding.pitFileIndicator.setOnLongClickListener(v -> {
|
||||
binding.pitIndicator.setOnLongClickListener(v -> {
|
||||
rescout = !rescout;
|
||||
if(rescout){
|
||||
set_indicator_color(rescout_color);
|
||||
@@ -171,7 +170,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void disableRescoutButton(){
|
||||
binding.pitFileIndicator.setOnLongClickListener(null);
|
||||
binding.pitIndicator.setOnLongClickListener(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -128,10 +128,11 @@ public class ScoutingFragment extends Fragment {
|
||||
|
||||
int matchNum = SettingsManager.getMatchNum();
|
||||
int nextMatch = -1;
|
||||
int teamNum = SettingsManager.getTeamNum();
|
||||
try {
|
||||
nextMatch = event.getNextTeamMatch(SettingsManager.getTeamNum(), matchNum).matchIndex;
|
||||
nextMatch = event.getNextTeamMatch(teamNum, matchNum).matchIndex;
|
||||
} catch (Exception e){
|
||||
AlertManager.error(e);
|
||||
AlertManager.error("Sorry, in event ("+evcode+"), your team number ("+teamNum+") wasn't found!", e);
|
||||
}
|
||||
|
||||
binding.textNextMatch.setText("Our next match: Match " + nextMatch);
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
// This is now deprecated
|
||||
// This is now deprecated. use HTTPSync
|
||||
// Class to synchronise data over FTP.
|
||||
public class FTPSync extends Thread {
|
||||
public static final String remoteBasePath = "/RidgeScout/";
|
||||
|
||||
@@ -30,8 +30,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
// This is now deprsicated
|
||||
// Class to syncronise data over FTP.
|
||||
// Class to synchronise data over HTTP.
|
||||
public class HttpSync extends Thread {
|
||||
public static final String timestampsFilename = "timestamps";
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class CustomSpinnerView extends LinearLayout {
|
||||
CustomSpinnerPopup popup = new CustomSpinnerPopup(getContext()).init(options, option -> {
|
||||
// dialog.();
|
||||
if(!isEnabled()) return;
|
||||
item.setText(option);
|
||||
item.setText("▼ " + option);
|
||||
index = options.indexOf(option);
|
||||
if(onClickListener != null) {
|
||||
onClickListener.onClick(option, options.indexOf(option));
|
||||
@@ -105,7 +105,7 @@ public class CustomSpinnerView extends LinearLayout {
|
||||
}
|
||||
|
||||
public void setOption(String option) {
|
||||
item.setText(option);
|
||||
item.setText("▼ " + option);
|
||||
index = options.indexOf(option);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ridgebotics.ridgescout.ui.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
@@ -54,6 +55,20 @@ public class MatchScoutingIndicator extends RelativeLayout {
|
||||
match_indicator_bar_team_num = findViewById(R.id.match_indicator_bar_team_num);
|
||||
box = findViewById(R.id.file_indicator_box);
|
||||
coloredBackground = findViewById(R.id.match_indicator_background);
|
||||
|
||||
int currentNightMode = getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
switch (currentNightMode) {
|
||||
case Configuration.UI_MODE_NIGHT_NO:
|
||||
// Night mode is not active on device
|
||||
match_indicator_back_button.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
|
||||
match_indicator_next_button.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
|
||||
break;
|
||||
case Configuration.UI_MODE_NIGHT_YES:
|
||||
// Night mode is active on device
|
||||
match_indicator_back_button.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
|
||||
match_indicator_next_button.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void setUsername(String username){
|
||||
@@ -73,19 +88,31 @@ public class MatchScoutingIndicator extends RelativeLayout {
|
||||
}
|
||||
|
||||
public void setColor(int color){
|
||||
Drawable drawable = box.getBackground();
|
||||
drawable.mutate();
|
||||
drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
// Set color of main background rectangle
|
||||
Drawable box_drawable = box.getBackground();
|
||||
box_drawable.mutate();
|
||||
box_drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color,hsv);
|
||||
|
||||
int background_color = Color.HSVToColor(220, new float[]{
|
||||
hsv[0],
|
||||
Math.min(hsv[1], 0.75f),
|
||||
Math.min(hsv[2], 0.5f)
|
||||
});
|
||||
|
||||
// Set color of main background rectangle, slightly dimmer
|
||||
coloredBackground.setBackgroundColor(
|
||||
Color.HSVToColor(220, new float[]{
|
||||
hsv[0],
|
||||
Math.min(hsv[1], 0.75f),
|
||||
Math.min(hsv[2], 0.5f)
|
||||
})
|
||||
background_color
|
||||
);
|
||||
|
||||
Drawable left_drawable = match_indicator_back_button.getBackground();
|
||||
left_drawable.mutate();
|
||||
left_drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
Drawable right_drawable = match_indicator_next_button.getBackground();
|
||||
right_drawable.mutate();
|
||||
right_drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.ridgebotics.ridgescout.ui.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
|
||||
// A view for displaying information about a team.
|
||||
public class PitScoutingIndicator extends RelativeLayout {
|
||||
public PitScoutingIndicator(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public PitScoutingIndicator(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public TextView pit_indicator_username;
|
||||
public TextView pit_indicator_team_num;
|
||||
private ConstraintLayout box;
|
||||
private View coloredBackground;
|
||||
|
||||
public void init(Context context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_pit_scouting_indicator, this, true);
|
||||
pit_indicator_username = findViewById(R.id.pit_indicator_username);
|
||||
pit_indicator_team_num = findViewById(R.id.pit_indicator_teamnum);
|
||||
|
||||
box = findViewById(R.id.pit_indicator_box);
|
||||
coloredBackground = findViewById(R.id.pit_indicator_background);
|
||||
|
||||
}
|
||||
|
||||
public void setUsername(String username){
|
||||
pit_indicator_username.setText(username);
|
||||
}
|
||||
|
||||
public void setTeamNum(int teamNum) {
|
||||
pit_indicator_team_num.setText(String.valueOf(teamNum));
|
||||
}
|
||||
|
||||
public void setColor(int color){
|
||||
// Set color of main background rectangle
|
||||
Drawable box_drawable = box.getBackground();
|
||||
box_drawable.mutate();
|
||||
box_drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color,hsv);
|
||||
|
||||
int background_color = Color.HSVToColor(220, new float[]{
|
||||
hsv[0],
|
||||
Math.min(hsv[1], 0.75f),
|
||||
Math.min(hsv[2], 0.5f)
|
||||
});
|
||||
|
||||
// Set color of main background rectangle, slightly dimmer
|
||||
coloredBackground.setBackgroundColor(
|
||||
background_color
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import android.graphics.Color;
|
||||
public class Colors {
|
||||
// Lists and stuff
|
||||
public static final int color_found = 0x7f00ff00;
|
||||
public static final int color_rescout = 0x7f0000ff;
|
||||
public static final int color_rescout = 0xff007fff;
|
||||
public static final int color_not_found = 0x7f7f0000;
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ public class Colors {
|
||||
public static final int unfocused_background_color = 0x50118811;
|
||||
|
||||
|
||||
public static final int unsaved_color = 0x60ff0000;
|
||||
public static final int saved_color = 0x6000ff00;
|
||||
public static final int rescout_color = 0x600000ff;
|
||||
public static final int unsaved_color = 0xffaa0000;
|
||||
public static final int saved_color = 0xff00aa00;
|
||||
public static final int rescout_color = 0xff007fff;
|
||||
|
||||
|
||||
// Data graphs
|
||||
|
||||
@@ -25,11 +25,24 @@ public class ImageRequestTask extends AsyncTask<String, Void, Bitmap> {
|
||||
try {
|
||||
URL url = new URL(src);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
// We do a little bit of spoofing
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
|
||||
connection.setDoInput(true);
|
||||
connection.connect();
|
||||
InputStream input = connection.getInputStream();
|
||||
return BitmapFactory.decodeStream(input);
|
||||
} catch (FileNotFoundException e) {
|
||||
|
||||
int code = connection.getResponseCode();
|
||||
switch (code) {
|
||||
case 200:
|
||||
InputStream input = connection.getInputStream();
|
||||
return BitmapFactory.decodeStream(input);
|
||||
case 403:
|
||||
// AlertManager.error("Got 403, Going to https://www.thebluealliance.com/avatars may fix this");
|
||||
return null;
|
||||
default:
|
||||
AlertManager.error("Error downloading image " + src, "Got response code: " + code);
|
||||
return null;
|
||||
}
|
||||
} catch (FileNotFoundException e){
|
||||
return null;
|
||||
} catch (IOException e){
|
||||
AlertManager.error("Error downloading image " + src, e);
|
||||
|
||||
Reference in New Issue
Block a user