From 27b36802b876805ae30c322ecbadf7286d2239fb Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Mon, 10 May 2021 13:23:25 -0600 Subject: final cleanup before first release --- TODO.md | 4 +++ .../brysonsteck/wiimmfiwatcher/AboutFragment.java | 1 - .../brysonsteck/wiimmfiwatcher/MainActivity.java | 24 +-------------- .../wiimmfiwatcher/WatchCodeFragment.java | 4 --- .../viewmodel/FriendCodeViewModel.java | 36 ++++++++-------------- .../wiimmfiwatcher/wiimmfi/RoomAdapter.java | 3 +- .../wiimmfiwatcher/wiimmfi/RoomData.java | 12 +++----- .../wiimmfiwatcher/wiimmfi/RoomFragment.java | 6 ++-- .../wiimmfiwatcher/wiimmfi/WiimmfiActivity.java | 16 +++++----- 9 files changed, 32 insertions(+), 74 deletions(-) diff --git a/TODO.md b/TODO.md index 88ac650..00baa37 100644 --- a/TODO.md +++ b/TODO.md @@ -16,5 +16,9 @@ These are issues in Wiimmfi Watcher I am at least aware of. Please **DO NOT** su # Features I would like to add * The watcher activity does not refresh automatically like the official website does * Added a refresh button, but is there a better way with Jsoup? Like a new Thread? +* Create a better looking header for the watcher activity + * Add 'sections' I guess??? +* Add the Mario Kart Wii font +* Add pictures for Nintendo and CTGP tracks diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java index c74c8c5..8f9111c 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java @@ -2,7 +2,6 @@ package me.brysonsteck.wiimmfiwatcher; import android.annotation.SuppressLint; import android.os.Bundle; -import android.text.Html; import android.text.method.LinkMovementMethod; import android.view.View; import android.widget.TextView; diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java index d935d48..c37aaf7 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java @@ -1,21 +1,14 @@ package me.brysonsteck.wiimmfiwatcher; - -import android.content.ClipData; import android.os.Bundle; import android.view.View; import androidx.appcompat.app.AppCompatActivity; import androidx.databinding.ObservableArrayList; -import androidx.lifecycle.ViewModelProvider; import androidx.room.Room; -import androidx.sqlite.db.SimpleSQLiteQuery; - -import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import me.brysonsteck.wiimmfiwatcher.database.AppDatabase; import me.brysonsteck.wiimmfiwatcher.model.FriendCode; -import me.brysonsteck.wiimmfiwatcher.viewmodel.FriendCodeViewModel; public class MainActivity extends AppCompatActivity { ObservableArrayList recentFCList = new ObservableArrayList<>(); @@ -27,7 +20,6 @@ public class MainActivity extends AppCompatActivity { setContentView(R.layout.activity_main); View aboutButton = findViewById(R.id.about_button); - if (savedInstanceState == null) { aboutButton.setVisibility(View.VISIBLE); getSupportFragmentManager().beginTransaction() @@ -37,24 +29,10 @@ public class MainActivity extends AppCompatActivity { } - database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build(); - -// aboutButton.setVisibility(View.INVISIBLE); -// ExtendedFloatingActionButton clearButton = findViewById(R.id.clear_button); - FriendCodeViewModel viewModel = new ViewModelProvider(MainActivity.this).get(FriendCodeViewModel.class); -// clearButton.setOnClickListener(new View.OnClickListener() { -// -// -// @Override -// public void onClick(View view) { -// getApplicationContext().deleteDatabase("friend-codes-db"); -// database = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "friend-codes-db").build(); -// } -// }); + database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build(); aboutButton.setOnClickListener((about) -> { -// aboutButton.setClickable(false); aboutButton.setVisibility(View.INVISIBLE); getSupportFragmentManager().beginTransaction() .replace(R.id.friend_code_input_fragment, new AboutFragment(), null) diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java index 465cccf..c1ba705 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java @@ -14,7 +14,6 @@ import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import com.google.android.material.textview.MaterialTextView; import me.brysonsteck.wiimmfiwatcher.model.FriendCode; @@ -102,9 +101,6 @@ public class WatchCodeFragment extends Fragment { } else { errorText.setText(""); viewModel.saveFriendCode("", friendCode.getText().toString()); -// FriendCodeObj friendCodeObj = new FriendCodeObj(); -// friendCodeObj.friendCode = friendCode.getText().toString(); -// database.getFriendCodeDao().insert(friendCodeObj); intent.putExtra("friendCode", friendCode.getText().toString()); startActivity(intent); } diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/viewmodel/FriendCodeViewModel.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/viewmodel/FriendCodeViewModel.java index 87db049..25cdd64 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/viewmodel/FriendCodeViewModel.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/viewmodel/FriendCodeViewModel.java @@ -30,28 +30,16 @@ public class FriendCodeViewModel extends AndroidViewModel { }).start(); } - public void setCurrentEntry(FriendCode entry) { - currentEntry.postValue(entry); - } - - public MutableLiveData getCurrentEntry() { - return currentEntry; - } - - public MutableLiveData getSaving() { - return saving; - } - public ObservableArrayList getEntries() { return entries; } - public boolean deleteAll() { - for (FriendCode entry: entries) { - db.getFriendCodeDao().nukeTable(); - } - return true; - } +// public boolean deleteAll() { +// for (FriendCode entry: entries) { +// db.getFriendCodeDao().nukeTable(); +// } +// return true; +// } public void saveFriendCode(String name, String friendCode) { saving.setValue(true); @@ -70,10 +58,10 @@ public class FriendCodeViewModel extends AndroidViewModel { }).start(); } - public void deleteEntry(FriendCode entry) { - new Thread(() -> { - db.getFriendCodeDao().delete(entry); - entries.remove(entry); - }).start(); - } +// public void deleteEntry(FriendCode entry) { +// new Thread(() -> { +// db.getFriendCodeDao().delete(entry); +// entries.remove(entry); +// }).start(); +// } } 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 0cf7a6e..c7a0f29 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java @@ -19,12 +19,11 @@ import java.util.ArrayList; import me.brysonsteck.wiimmfiwatcher.R; public class RoomAdapter extends RecyclerView.Adapter{ - String display; String playerLink; String header; ArrayList players; - boolean online = true; + public RoomAdapter (String display, String playerLink, String header, ArrayList players) { this.display = display; this.playerLink = playerLink; diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java index f0d9db7..284b735 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java @@ -14,7 +14,7 @@ public class RoomData { String friendCode; ArrayList players = new ArrayList<>(); - public RoomData (ArrayList players, String playerLink, String friendCode) { + public RoomData (ArrayList players, String friendCode) { this.friendCode = friendCode; getPlayerLink(); Document doc = null; @@ -91,10 +91,8 @@ public class RoomData { public void getPlayerLink() { try { - Document doc = null; - - doc = Jsoup.connect("https://wiimmfi.de/stats/mkw") - .userAgent("Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) (UNDER DEVELOPMENT)") + Document doc = Jsoup.connect("https://wiimmfi.de/stats/mkw") + .userAgent("Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) (Developer testing)") .get(); Element table = doc.select("table").get(0); Elements rows = table.select("tr"); @@ -102,13 +100,11 @@ public class RoomData { for (int i = 0; i < rows.size(); i++) { Element row = rows.get(i); Elements colPlayers = row.select("td"); - Elements colHeader = row.select("th"); if (colPlayers.size() > 0) { String data = colPlayers.get(0).select("a").toString(); -// System.out.println(data); if (data.contains(friendCode)) { System.out.println("Found friend code"); playerLink = data.split("\"")[3]; @@ -130,7 +126,7 @@ public class RoomData { public RoomData refresh() { players.clear(); roomHeader = ""; - return new RoomData(players, playerLink, friendCode); + return new RoomData(players, friendCode); } } 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 cbadf63..afb21d6 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java @@ -23,9 +23,9 @@ public class RoomFragment extends Fragment { ArrayList players; RoomData roomData; - public RoomFragment(String friendCode, String header, ArrayList players, String playerLink, String display) { + public RoomFragment(String friendCode, ArrayList players, String playerLink, String display) { super(R.layout.fragment_room); - this.roomData = new RoomData(players, playerLink, friendCode); + this.roomData = new RoomData(players, friendCode); this.header = roomData.getRoomHeader(); this.display = display; this.players = players; @@ -52,8 +52,6 @@ public class RoomFragment extends Fragment { roomData = roomData.refresh(); RoomData newRoomData = roomData.refresh(); players = roomData.getPlayers(); -// playerLink = roomData.getPlayerLink(); -// String otherPlayerLink = newRoomData.getPlayerLink(); 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."; 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 24affee..f3029af 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java @@ -41,7 +41,7 @@ public class WiimmfiActivity extends AppCompatActivity { if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "fc"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc"), null) .setReorderingAllowed(true) .commit(); } @@ -54,49 +54,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, roomHeader, players, playerLink[0], "fc"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.roles) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "roles"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "roles"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.login_regions) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "login_regions"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "login_regions"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.room_match) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "room_match"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "room_match"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.world) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "world"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "world"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.conn_fail) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "conn_fail"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "conn_fail"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.vr_br) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "vr_br"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "vr_br"), null) .setReorderingAllowed(true) .commit(); } -- cgit v1.2.3