aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java11
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/Updater.java14
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/SetImageView.java103
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java18
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java14
-rw-r--r--app/src/main/res/drawable/globe.jpgbin0 -> 27859 bytes
-rw-r--r--app/src/main/res/layout/activity_main.xml40
-rw-r--r--app/src/main/res/layout/activity_wiimmfi.xml3
-rw-r--r--app/src/main/res/layout/room_fragment.xml7
-rw-r--r--images/globe.jpgbin0 -> 27859 bytes
10 files changed, 174 insertions, 36 deletions
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java
index 1657e38..4e6fe30 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java
@@ -6,6 +6,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
+import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.room.Room;
@@ -90,6 +91,7 @@ public class MainActivity extends AppCompatActivity {
super.onStart();
final String[] newestRelease = {""};
final boolean[] outdated = {false};
+ final boolean[] failed = {false};
Thread thread = new Thread() {
public void run() {
Updater updater = new Updater();
@@ -99,6 +101,10 @@ public class MainActivity extends AppCompatActivity {
System.out.println("\tA newer version of Wiimmfi Watcher is available! (" + updater.getNewestRelease() + ")");
System.out.println("\tView the release notes and the source code here: " + updater.getGithubRelease());
System.out.println("\t---------------------------------------------------------------");
+ } else if (updater.hasFailed()) {
+ System.out.println("---------------------------------------------------------------");
+ System.out.println("\t\t An error has occurred while getting information from the update server.");
+ System.out.println("\t\t---------------------------------------------------------------");
} else {
System.out.println("---------------------------------------------------------------");
System.out.println("\t\t" + updater.getNewestRelease() + " is the latest release of Wiimmfi Watcher.");
@@ -106,6 +112,7 @@ public class MainActivity extends AppCompatActivity {
}
newestRelease[0] = updater.getNewestRelease();
outdated[0] = updater.isOutdated();
+ failed[0] = updater.hasFailed();
}
};
thread.start();
@@ -136,8 +143,10 @@ public class MainActivity extends AppCompatActivity {
}
})
.show();
+ } else if (failed[0] && !shownUpdate) {
+ shownUpdate = true;
+ Toast.makeText(this, "An error occurred while checking for updates for Wiimmfi Watcher. Please try again later.", Toast.LENGTH_LONG).show();
}
-
}
@Override
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/Updater.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/Updater.java
index eb3e813..a4dd552 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/Updater.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/Updater.java
@@ -15,6 +15,7 @@ public class Updater {
public boolean outdated = false;
public String newestRelease;
public String githubRelease;
+ public boolean failed = false;
public String playStore = "https://play.google.com/store/apps/details?id=me.brysonsteck.wiimmfiwatcher";
public Updater() {
@@ -54,15 +55,22 @@ public class Updater {
}
public void compareRelease(String deviceRelease) {
- if (!deviceRelease.equals(newestRelease)) {
- outdated = true;
- }
+ if (newestRelease == null) {
+ failed = true;
+ }
+ else if (!deviceRelease.equals(newestRelease)) {
+ outdated = true;
+ }
}
public boolean isOutdated() {
return outdated;
}
+ public boolean hasFailed() {
+ return failed;
+ }
+
public String getNewestRelease() {
return newestRelease;
}
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/SetImageView.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/SetImageView.java
new file mode 100644
index 0000000..d77da38
--- /dev/null
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/SetImageView.java
@@ -0,0 +1,103 @@
+package me.brysonsteck.wiimmfiwatcher.wiimmfi;
+
+import android.widget.ImageView;
+
+import me.brysonsteck.wiimmfiwatcher.R;
+
+public class SetImageView {
+
+ public SetImageView(ImageView image, String header, boolean failure) {
+ if (failure) {
+ image.setImageResource(R.drawable.globe);
+ } else {
+ header = header.toLowerCase();
+ if (header.contains("wii luigi circuit")) {
+ image.setImageResource(R.drawable.course_lc);
+ } else if (header.contains("wii moo moo meadows")) {
+ image.setImageResource(R.drawable.course_mmm);
+ } else if (header.contains("wii mushroom gorge")) {
+ image.setImageResource(R.drawable.course_mg);
+ } else if (header.contains("wii toad's factory")) {
+ image.setImageResource(R.drawable.course_tf);
+ } else if (header.contains("wii mario circuit")) {
+ image.setImageResource(R.drawable.course_mc);
+ } else if (header.contains("wii coconut mall")) {
+ image.setImageResource(R.drawable.course_cm);
+ } else if (header.contains("wii dk summit") || header.contains("wii dk's snowboard cross")) {
+ image.setImageResource(R.drawable.course_dks);
+ } else if (header.contains("wii wario's gold mine")) {
+ image.setImageResource(R.drawable.course_wgm);
+ } else if (header.contains("wii daisy circuit")) {
+ image.setImageResource(R.drawable.course_dc);
+ } else if (header.contains("wii koopa cape")) {
+ image.setImageResource(R.drawable.course_kc);
+ } else if (header.contains("wii maple treeway")) {
+ image.setImageResource(R.drawable.course_mt);
+ } else if (header.contains("wii grumble volcano")) {
+ image.setImageResource(R.drawable.course_gv);
+ } else if (header.contains("wii dry dry ruins")) {
+ image.setImageResource(R.drawable.course_ddr);
+ } else if (header.contains("wii moonview highway")) {
+ image.setImageResource(R.drawable.course_mh);
+ } else if (header.contains("wii bowser's castle")) {
+ image.setImageResource(R.drawable.course_bc);
+ } else if (header.contains("wii rainbow road")) {
+ image.setImageResource(R.drawable.course_rr);
+ } else if (header.contains("gcn peach beach")) {
+ image.setImageResource(R.drawable.course_rpb);
+ } else if (header.contains("ds yoshi falls")) {
+ image.setImageResource(R.drawable.course_ryf);
+ } else if (header.contains("snes ghost valley 2")) {
+ image.setImageResource(R.drawable.course_rgv2);
+ } else if (header.contains("n64 mario raceway")) {
+ image.setImageResource(R.drawable.course_rmr);
+ } else if (header.contains("n64 sherbet land")) {
+ image.setImageResource(R.drawable.course_rsl);
+ } else if (header.contains("gba shy guy beach")) {
+ image.setImageResource(R.drawable.course_rsgb);
+ } else if (header.contains("ds delfino square")) {
+ image.setImageResource(R.drawable.course_rds);
+ } else if (header.contains("gcn waluigi stadium")) {
+ image.setImageResource(R.drawable.course_rws);
+ } else if (header.contains("ds desert hills")) {
+ image.setImageResource(R.drawable.course_rdh);
+ } else if (header.contains("gba bowser's castle 3")) {
+ image.setImageResource(R.drawable.course_rbc3);
+ } else if (header.contains("n64 dk's jungle parkway")) {
+ image.setImageResource(R.drawable.course_rdkjp);
+ } else if (header.contains("gcn mario circuit")) {
+ image.setImageResource(R.drawable.course_rmc);
+ } else if (header.contains("snes mario circuit 3")) {
+ image.setImageResource(R.drawable.course_rmc3);
+ } else if (header.contains("ds peach gardens")) {
+ image.setImageResource(R.drawable.course_rpg);
+ } else if (header.contains("gcn dk mountain")) {
+ image.setImageResource(R.drawable.course_rdkm);
+ } else if (header.contains("n64 bowser's castle")) {
+ image.setImageResource(R.drawable.course_rbc);
+ } else if (header.contains("wii block plaza")) {
+ image.setImageResource(R.drawable.battle_bp);
+ } else if (header.contains("wii delfino pier")) {
+ image.setImageResource(R.drawable.battle_dp);
+ } else if (header.contains("wii funky stadium")) {
+ image.setImageResource(R.drawable.battle_fs);
+ } else if (header.contains("wii chain chomp")) {
+ image.setImageResource(R.drawable.battle_ccw);
+ } else if (header.contains("wii thwomp desert")) {
+ image.setImageResource(R.drawable.battle_td);
+ } else if (header.contains("snes battle course 4")) {
+ image.setImageResource(R.drawable.battle_rbc4);
+ } else if (header.contains("n64 skyscraper")) {
+ image.setImageResource(R.drawable.battle_rs);
+ } else if (header.contains("gba battle course 3")) {
+ image.setImageResource(R.drawable.battle_rbc3);
+ } else if (header.contains("gcn cookie land")) {
+ image.setImageResource(R.drawable.battle_rcl);
+ } else if (header.contains("ds twilight house")) {
+ image.setImageResource(R.drawable.battle_rth);
+ } else if (header.contains("last track:") && !header.contains("nintendo")) {
+ image.setImageResource(R.drawable.course_ctgp);
+ }
+ }
+ }
+}
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 6936275..de7c97c 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
@@ -5,6 +5,7 @@ import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.os.StrictMode;
+import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;
@@ -32,6 +33,7 @@ public class WiimmfiActivity extends AppCompatActivity {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
+ ImageView image = findViewById(R.id.image);
MaterialToolbar toolbar = findViewById(R.id.toolbar);
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
NavigationView drawer = findViewById(R.id.navigation_view);
@@ -48,7 +50,7 @@ public class WiimmfiActivity extends AppCompatActivity {
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
@@ -61,49 +63,49 @@ public class WiimmfiActivity extends AppCompatActivity {
if (menuItem.getItemId() == R.id.friend_code) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.roles) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "roles", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "roles", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.login_regions) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "login_regions", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "login_regions", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.room_match) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "room_match", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "room_match", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.world) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "world", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "world", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.conn_fail) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "conn_fail", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "conn_fail", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.vr_br) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "vr_br", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "vr_br", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java
index d6326f7..90c97da 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java
@@ -2,7 +2,9 @@ package me.brysonsteck.wiimmfiwatcher.wiimmfi.fragments;
import android.os.Bundle;
import android.view.View;
+import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -18,6 +20,7 @@ import java.util.ArrayList;
import me.brysonsteck.wiimmfiwatcher.R;
import me.brysonsteck.wiimmfiwatcher.wiimmfi.Player;
import me.brysonsteck.wiimmfiwatcher.wiimmfi.RoomData;
+import me.brysonsteck.wiimmfiwatcher.wiimmfi.SetImageView;
public class RoomFragment extends Fragment {
String display;
@@ -26,8 +29,9 @@ public class RoomFragment extends Fragment {
ArrayList<Player> players;
RoomData roomData;
MaterialToolbar toolbar;
+ ImageView image;
- public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display, MaterialToolbar toolbar) {
+ public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display, MaterialToolbar toolbar, ImageView image) {
super(R.layout.room_fragment);
this.roomData = new RoomData(players, friendCode);
new Thread(() -> {
@@ -37,6 +41,7 @@ public class RoomFragment extends Fragment {
this.players = players;
this.playerLink = playerLink;
this.toolbar = toolbar;
+ this.image = image;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
@@ -46,20 +51,24 @@ public class RoomFragment extends Fragment {
if (header == null) {
headerTextView.setText(R.string.header_null_error);
toolbar.setNavigationIcon(null);
+ SetImageView setImageView = new SetImageView(image, header, true);
}
if (roomData.error != null) {
headerTextView.setText(getResources().getString(R.string.jsoup_error, roomData.error));
toolbar.setNavigationIcon(null);
+ SetImageView setImageView = new SetImageView(image, header, true);
}
if (roomData.error == null && header != null) {
headerTextView.setText(header);
toolbar.setNavigationIcon(R.drawable.ic_baseline_menu_24);
+ SetImageView setImageView = new SetImageView(image, header, false);
}
RecyclerView recyclerView = view.findViewById(R.id.player_data_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext()));
refreshButton.setOnClickListener((buttonView) -> {
+ Toast.makeText(getContext(), "Refreshing!", Toast.LENGTH_LONG).show();
this.players.clear();
this.header = "";
this.roomData = roomData.refresh();
@@ -69,14 +78,17 @@ public class RoomFragment extends Fragment {
if (header == null) {
headerTextView.setText(R.string.header_null_error);
toolbar.setNavigationIcon(null);
+ SetImageView setImageView = new SetImageView(image, header, true);
}
if (newRoomData.error instanceof java.net.SocketTimeoutException || newRoomData.error instanceof java.net.UnknownHostException) {
headerTextView.setText(getResources().getString(R.string.jsoup_error, roomData.error));
toolbar.setNavigationIcon(null);
+ SetImageView setImageView = new SetImageView(image, header, true);
}
if (roomData.error == null && header != null) {
headerTextView.setText(header);
toolbar.setNavigationIcon(R.drawable.ic_baseline_menu_24);
+ SetImageView setImageView = new SetImageView(image, header, false);
}
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext()));
diff --git a/app/src/main/res/drawable/globe.jpg b/app/src/main/res/drawable/globe.jpg
new file mode 100644
index 0000000..0ee5e50
--- /dev/null
+++ b/app/src/main/res/drawable/globe.jpg
Binary files differ
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 863ff0c..6ee8a70 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -31,26 +31,26 @@
app:title="Wiimmfi Watcher"
app:titleTextColor="@color/white" />
- <com.google.android.material.tabs.TabLayout
- android:id="@+id/tablayout_main"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/blue_700"
- app:tabIndicatorColor="@color/white"
- app:tabMode="fixed"
- app:tabTextColor="@color/white">
-
- <com.google.android.material.tabs.TabItem
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Friend Code" />
-
- <com.google.android.material.tabs.TabItem
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Mii Name" />
-
- </com.google.android.material.tabs.TabLayout>
+<!-- <com.google.android.material.tabs.TabLayout-->
+<!-- android:id="@+id/tablayout_main"-->
+<!-- android:layout_width="match_parent"-->
+<!-- android:layout_height="match_parent"-->
+<!-- android:background="@color/blue_700"-->
+<!-- app:tabIndicatorColor="@color/white"-->
+<!-- app:tabMode="fixed"-->
+<!-- app:tabTextColor="@color/white">-->
+
+<!-- <com.google.android.material.tabs.TabItem-->
+<!-- android:layout_width="wrap_content"-->
+<!-- android:layout_height="wrap_content"-->
+<!-- android:text="Friend Code" />-->
+
+<!-- <com.google.android.material.tabs.TabItem-->
+<!-- android:layout_width="wrap_content"-->
+<!-- android:layout_height="wrap_content"-->
+<!-- android:text="Mii Name" />-->
+
+<!-- </com.google.android.material.tabs.TabLayout>-->
</com.google.android.material.appbar.AppBarLayout>
diff --git a/app/src/main/res/layout/activity_wiimmfi.xml b/app/src/main/res/layout/activity_wiimmfi.xml
index 41cf4fe..478ad10 100644
--- a/app/src/main/res/layout/activity_wiimmfi.xml
+++ b/app/src/main/res/layout/activity_wiimmfi.xml
@@ -26,11 +26,12 @@
app:collapsedTitleTextAppearance="@style/TextAppearance.App.CollapsingToolbar.Collapsed">
<ImageView
+ android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
- android:src="@drawable/course_ctgp" />
+ android:src="@drawable/globe" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
diff --git a/app/src/main/res/layout/room_fragment.xml b/app/src/main/res/layout/room_fragment.xml
index bf49aa1..c0e7807 100644
--- a/app/src/main/res/layout/room_fragment.xml
+++ b/app/src/main/res/layout/room_fragment.xml
@@ -11,10 +11,13 @@
android:id="@+id/room_header_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:padding="18dp"
+ android:paddingTop="18dp"
+ android:paddingLeft="18dp"
+ android:paddingRight="18dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent" />
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/player_data_recycler_view"
diff --git a/images/globe.jpg b/images/globe.jpg
new file mode 100644
index 0000000..0ee5e50
--- /dev/null
+++ b/images/globe.jpg
Binary files differ