aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/me')
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java37
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java8
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java9
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java78
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java25
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java24
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java10
7 files changed, 161 insertions, 30 deletions
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java
index aaf9073..a0229ff 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java
@@ -1,9 +1,13 @@
package me.brysonsteck.wiimmfiwatcher;
import android.annotation.SuppressLint;
+import android.content.res.Configuration;
+import android.graphics.Color;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
+import android.transition.TransitionInflater;
import android.view.View;
+import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -12,18 +16,37 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.MaterialToolbar;
+import java.util.Objects;
+
public class AboutFragment extends Fragment {
View aboutButton;
MaterialToolbar toolbar;
+ ScrollView scrollView;
public AboutFragment() {
super(R.layout.about_fragment);
}
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ TransitionInflater inflater = TransitionInflater.from(requireContext());
+ setEnterTransition(inflater.inflateTransition(R.transition.slide_right));
+ setExitTransition(inflater.inflateTransition(R.transition.slide_right));
+ }
@SuppressLint("SetTextI18n")
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+ scrollView = view.findViewById(R.id.about_view);
+
+ int nightModeFlags =
+ getContext().getResources().getConfiguration().uiMode &
+ Configuration.UI_MODE_NIGHT_MASK;
+ if (nightModeFlags == Configuration.UI_MODE_NIGHT_YES) {
+ // Night mode is active, we're using dark theme
+ scrollView.setBackgroundColor(Color.parseColor("#151515"));
+ }
aboutButton = getActivity().findViewById(R.id.about_button);
toolbar = getActivity().findViewById(R.id.toolbar);
@@ -34,10 +57,11 @@ public class AboutFragment extends Fragment {
TextView github = view.findViewById(R.id.github_text);
TextView contact = view.findViewById(R.id.contact_text);
TextView bugs = view.findViewById(R.id.bugs_text);
+ TextView license = view.findViewById(R.id.license_text);
aboutWatcher.setText("Wiimmfi Watcher is an UNOFFICIAL application created for a school project that I have decided to turn into a full application. " +
"This application was made to provide an easy shortcut to the Wiimmfi website and display data in a mobile friendly way, since the official website doesn't have a mobile friendly version. " +
- "Free and open source, you can watch your Wiimmfi Mario Kart Wii matches on your phone in a quick and easy way. " +
+ "Free and open source, you can watch your Wiimmfi matches on your phone in a quick and easy way. " +
"");
aboutMe.setText("Hi there! My name is Bryson Steck. I am a student studying Computer Science. This is my first official application that I'm maintaining. " +
@@ -49,13 +73,20 @@ public class AboutFragment extends Fragment {
github.setText(R.string.github);
- contact.setText("If you would like to get ahold of me for any reason unrelated to bug reports or this app in general, you can contact me through email at steck.bryson@gmail.com " +
- "or on Discord at bryzinga#9971.");
+ contact.setClickable(true);
+ contact.setMovementMethod(LinkMovementMethod.getInstance());
+
+ contact.setText(R.string.contact);
bugs.setClickable(true);
bugs.setMovementMethod(LinkMovementMethod.getInstance());
bugs.setText(R.string.bugs);
+
+ license.setClickable(true);
+ license.setMovementMethod(LinkMovementMethod.getInstance());
+
+ license.setText(R.string.license);
}
@Override
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java
index c37aaf7..bb7663c 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java
@@ -1,8 +1,10 @@
package me.brysonsteck.wiimmfiwatcher;
+import android.os.Build;
import android.os.Bundle;
import android.view.View;
+import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.ObservableArrayList;
import androidx.room.Room;
@@ -14,6 +16,7 @@ public class MainActivity extends AppCompatActivity {
ObservableArrayList<FriendCode> recentFCList = new ObservableArrayList<>();
AppDatabase database;
+ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -35,6 +38,11 @@ public class MainActivity extends AppCompatActivity {
aboutButton.setOnClickListener((about) -> {
aboutButton.setVisibility(View.INVISIBLE);
getSupportFragmentManager().beginTransaction()
+ .setCustomAnimations(
+ R.anim.slide_in,
+ R.anim.fade_out,
+ R.anim.fade_in,
+ R.anim.slide_out)
.replace(R.id.friend_code_input_fragment, new AboutFragment(), null)
.setReorderingAllowed(true)
.addToBackStack(null)
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java
index 715dce8..ded5e65 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java
@@ -2,6 +2,8 @@ package me.brysonsteck.wiimmfiwatcher;
import android.content.Context;
import android.content.Intent;
+import android.content.res.Configuration;
+import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -39,6 +41,13 @@ public class WatchCodeAdapter extends RecyclerView.Adapter<WatchCodeAdapter.View
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
String currentFC = entries.get(position).friendCode;
MaterialButton fcButton = holder.itemView.findViewById(R.id.recent_friend_code_button);
+ int nightModeFlags =
+ context.getResources().getConfiguration().uiMode &
+ Configuration.UI_MODE_NIGHT_MASK;
+ if (nightModeFlags == Configuration.UI_MODE_NIGHT_YES) {
+ // Night mode is active, we're using dark theme
+ fcButton.setBackgroundColor(Color.parseColor("#313131"));
+ }
fcButton.setText(currentFC);
fcButton.setOnClickListener(view -> {
Intent intent = new Intent(view.getContext(), WiimmfiActivity.class);
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java
index c1ba705..94006a0 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java
@@ -1,10 +1,15 @@
package me.brysonsteck.wiimmfiwatcher;
import android.content.Intent;
+import android.content.res.Configuration;
+import android.graphics.Color;
import android.os.Bundle;
+import android.transition.TransitionInflater;
+import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -23,7 +28,7 @@ import me.brysonsteck.wiimmfiwatcher.wiimmfi.WiimmfiActivity;
public class WatchCodeFragment extends Fragment {
public WatchCodeFragment() {
- super(R.layout.friend_code_input_fragment);
+ super(R.layout.watch_code_fragment);
}
public boolean isValidFriendCode(String friendCode) {
@@ -41,6 +46,15 @@ public class WatchCodeFragment extends Fragment {
}
@Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ TransitionInflater inflater = TransitionInflater.from(requireContext());
+ setEnterTransition(inflater.inflateTransition(R.transition.fade));
+ setExitTransition(inflater.inflateTransition(R.transition.fade));
+ }
+
+
+ @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
FriendCodeViewModel viewModel = new ViewModelProvider(getActivity()).get(FriendCodeViewModel.class);
@@ -88,26 +102,58 @@ public class WatchCodeFragment extends Fragment {
linearLayoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(adapter);
- Button watchButton = view.findViewById(R.id.watch_button);
EditText friendCode = view.findViewById(R.id.friend_code_edit_text);
+
MaterialTextView errorText = view.findViewById(R.id.error_text);
- watchButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(view.getContext(), WiimmfiActivity.class);
- if (!isValidFriendCode(friendCode.getText().toString())) {
- errorText.setText("ERROR: Insert a friend code in the format XXXX-XXXX-XXXX");
- friendCode.setText("");
- } else {
- errorText.setText("");
- viewModel.saveFriendCode("", friendCode.getText().toString());
- intent.putExtra("friendCode", friendCode.getText().toString());
- startActivity(intent);
+ Button watchButton = view.findViewById(R.id.watch_button);
+ watchButton.setOnClickListener(buttonClick -> {
+ startWiimmfiActivity(
+ view,
+ friendCode,
+ errorText,
+ watchButton,
+ viewModel
+ );
+ watchButton.setText("Watch");
+ });
+ friendCode.setOnKeyListener(new View.OnKeyListener()
+ {
+ public boolean onKey(View view1, int keyCode, KeyEvent event)
+ {
+ if (event.getAction() == KeyEvent.ACTION_DOWN)
+ {
+ switch (keyCode)
+ {
+ case KeyEvent.KEYCODE_DPAD_CENTER:
+ case KeyEvent.KEYCODE_ENTER:
+ startWiimmfiActivity(
+ view,
+ friendCode,
+ errorText,
+ watchButton,
+ viewModel
+ );
+ watchButton.setText("Watch");
+ return true;
+ default:
+ break;
+ }
}
+ return false;
}
});
+ }
-
-
+ public void startWiimmfiActivity(View view, EditText friendCode, MaterialTextView errorText, Button watchButton, FriendCodeViewModel viewModel) {
+ Intent intent = new Intent(view.getContext(), WiimmfiActivity.class);
+ if (!isValidFriendCode(friendCode.getText().toString())) {
+ errorText.setText("ERROR: Insert a friend code in the format XXXX-XXXX-XXXX");
+ } else {
+ errorText.setText("");
+ watchButton.setText("Loading...");
+ viewModel.saveFriendCode("", friendCode.getText().toString());
+ intent.putExtra("friendCode", friendCode.getText().toString());
+ startActivity(intent);
+ }
}
}
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java
index c7a0f29..5538869 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java
@@ -1,10 +1,13 @@
package me.brysonsteck.wiimmfiwatcher.wiimmfi;
import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -23,12 +26,14 @@ public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
String playerLink;
String header;
ArrayList<Player> players;
+ Context context;
- public RoomAdapter (String display, String playerLink, String header, ArrayList<Player> players) {
+ public RoomAdapter (String display, String playerLink, String header, ArrayList<Player> players, Context context) {
this.display = display;
this.playerLink = playerLink;
this.header = header;
this.players = players;
+ this.context = context;
}
@NonNull
@@ -46,6 +51,20 @@ public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
TextView miiName = holder.itemView.findViewById(R.id.mii_names);
TextView variableDisplay = holder.itemView.findViewById(R.id.variable_side_data);
Player currentPlayer = players.get(position);
+ LinearLayout.LayoutParams cardViewParams = new LinearLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
+ cardView.setLayoutParams(cardViewParams);
+ ViewGroup.MarginLayoutParams cardViewMarginParams = (ViewGroup.MarginLayoutParams) cardView.getLayoutParams();
+ cardViewMarginParams.setMargins(40,40,40,40);
+ cardView.requestLayout();
+ int nightModeFlags =
+ context.getResources().getConfiguration().uiMode &
+ Configuration.UI_MODE_NIGHT_MASK;
+ if (nightModeFlags == Configuration.UI_MODE_NIGHT_YES) {
+ // Night mode is active, we're using dark theme
+ cardView.setCardBackgroundColor(Color.parseColor("#313131"));
+ }
if (currentPlayer.watching) {
cardView.setCardBackgroundColor(Color.parseColor("#0D47A1"));
rosterNumber.setTextColor(Color.WHITE);
@@ -78,6 +97,10 @@ public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
variableDisplay.setText("VR: " + currentPlayer.vr + " / BR: " + currentPlayer.br);
break;
}
+ if (position + 1 == getItemCount()) {
+ cardViewMarginParams.setMargins(40,40,40,250);
+ cardView.requestLayout();
+ }
}
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java
index afb21d6..2c17476 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java
@@ -1,8 +1,10 @@
package me.brysonsteck.wiimmfiwatcher.wiimmfi;
import android.os.Bundle;
+import android.os.Looper;
import android.view.View;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -24,9 +26,11 @@ public class RoomFragment extends Fragment {
RoomData roomData;
public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display) {
- super(R.layout.fragment_room);
+ super(R.layout.room_fragment);
this.roomData = new RoomData(players, friendCode);
- this.header = roomData.getRoomHeader();
+ new Thread(() -> {
+ this.header = roomData.getRoomHeader();
+ }).start();
this.display = display;
this.players = players;
this.playerLink = playerLink;
@@ -43,23 +47,23 @@ public class RoomFragment extends Fragment {
headerTextView.setText(header);
RecyclerView recyclerView = view.findViewById(R.id.player_data_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players));
+ recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext()));
refreshButton.setOnClickListener((buttonView) -> {
- refreshButton.setEnabled(false);
- players.clear();
+ this.players.clear();
this.header = "";
- roomData = roomData.refresh();
+ this.roomData = roomData.refresh();
RoomData newRoomData = roomData.refresh();
- players = roomData.getPlayers();
+ this.players = roomData.getPlayers();
header = newRoomData.getRoomHeader();
if (header == null) {
header = "This player is not online, not inside a room or does not exist. Click the refresh button to try again, or click on the back button to enter a different friend code.";
}
- headerTextView.setText(header);
+
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players));
- refreshButton.setEnabled(true);
+ recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext()));
+ headerTextView.setText(header);
+
});
}
}
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
index f3029af..1a9576a 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
@@ -1,6 +1,8 @@
package me.brysonsteck.wiimmfiwatcher.wiimmfi;
import android.content.Intent;
+import android.content.res.Configuration;
+import android.graphics.Color;
import android.os.Bundle;
import android.os.StrictMode;
@@ -37,6 +39,14 @@ public class WiimmfiActivity extends AppCompatActivity {
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
NavigationView drawer = findViewById(R.id.navigation_view);
+ int nightModeFlags =
+ this.getResources().getConfiguration().uiMode &
+ Configuration.UI_MODE_NIGHT_MASK;
+ if (nightModeFlags == Configuration.UI_MODE_NIGHT_YES) {
+ // Night mode is active, we're using dark theme
+ drawer.setBackgroundColor(Color.parseColor("#313131"));
+ }
+
toolbar.setTitle("Watching " + friendCode);
if (savedInstanceState == null) {