final cleanup before first release
This commit is contained in:
parent
eb45e67349
commit
27b36802b8
9 changed files with 32 additions and 74 deletions
4
TODO.md
4
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
|
# Features I would like to add
|
||||||
* The watcher activity does not refresh automatically like the official website does
|
* 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?
|
* 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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package me.brysonsteck.wiimmfiwatcher;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
|
@ -1,21 +1,14 @@
|
||||||
package me.brysonsteck.wiimmfiwatcher;
|
package me.brysonsteck.wiimmfiwatcher;
|
||||||
|
|
||||||
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.databinding.ObservableArrayList;
|
import androidx.databinding.ObservableArrayList;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
|
||||||
import androidx.room.Room;
|
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.database.AppDatabase;
|
||||||
import me.brysonsteck.wiimmfiwatcher.model.FriendCode;
|
import me.brysonsteck.wiimmfiwatcher.model.FriendCode;
|
||||||
import me.brysonsteck.wiimmfiwatcher.viewmodel.FriendCodeViewModel;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
ObservableArrayList<FriendCode> recentFCList = new ObservableArrayList<>();
|
ObservableArrayList<FriendCode> recentFCList = new ObservableArrayList<>();
|
||||||
|
@ -27,7 +20,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
View aboutButton = findViewById(R.id.about_button);
|
View aboutButton = findViewById(R.id.about_button);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
aboutButton.setVisibility(View.VISIBLE);
|
aboutButton.setVisibility(View.VISIBLE);
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
@ -37,24 +29,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build();
|
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();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
aboutButton.setOnClickListener((about) -> {
|
aboutButton.setOnClickListener((about) -> {
|
||||||
// aboutButton.setClickable(false);
|
|
||||||
aboutButton.setVisibility(View.INVISIBLE);
|
aboutButton.setVisibility(View.INVISIBLE);
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.replace(R.id.friend_code_input_fragment, new AboutFragment(), null)
|
.replace(R.id.friend_code_input_fragment, new AboutFragment(), null)
|
||||||
|
|
|
@ -14,7 +14,6 @@ import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
||||||
import com.google.android.material.textview.MaterialTextView;
|
import com.google.android.material.textview.MaterialTextView;
|
||||||
|
|
||||||
import me.brysonsteck.wiimmfiwatcher.model.FriendCode;
|
import me.brysonsteck.wiimmfiwatcher.model.FriendCode;
|
||||||
|
@ -102,9 +101,6 @@ public class WatchCodeFragment extends Fragment {
|
||||||
} else {
|
} else {
|
||||||
errorText.setText("");
|
errorText.setText("");
|
||||||
viewModel.saveFriendCode("", friendCode.getText().toString());
|
viewModel.saveFriendCode("", friendCode.getText().toString());
|
||||||
// FriendCodeObj friendCodeObj = new FriendCodeObj();
|
|
||||||
// friendCodeObj.friendCode = friendCode.getText().toString();
|
|
||||||
// database.getFriendCodeDao().insert(friendCodeObj);
|
|
||||||
intent.putExtra("friendCode", friendCode.getText().toString());
|
intent.putExtra("friendCode", friendCode.getText().toString());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,28 +30,16 @@ public class FriendCodeViewModel extends AndroidViewModel {
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentEntry(FriendCode entry) {
|
|
||||||
currentEntry.postValue(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableLiveData<FriendCode> getCurrentEntry() {
|
|
||||||
return currentEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableLiveData<Boolean> getSaving() {
|
|
||||||
return saving;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObservableArrayList<FriendCode> getEntries() {
|
public ObservableArrayList<FriendCode> getEntries() {
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteAll() {
|
// public boolean deleteAll() {
|
||||||
for (FriendCode entry: entries) {
|
// for (FriendCode entry: entries) {
|
||||||
db.getFriendCodeDao().nukeTable();
|
// db.getFriendCodeDao().nukeTable();
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void saveFriendCode(String name, String friendCode) {
|
public void saveFriendCode(String name, String friendCode) {
|
||||||
saving.setValue(true);
|
saving.setValue(true);
|
||||||
|
@ -70,10 +58,10 @@ public class FriendCodeViewModel extends AndroidViewModel {
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteEntry(FriendCode entry) {
|
// public void deleteEntry(FriendCode entry) {
|
||||||
new Thread(() -> {
|
// new Thread(() -> {
|
||||||
db.getFriendCodeDao().delete(entry);
|
// db.getFriendCodeDao().delete(entry);
|
||||||
entries.remove(entry);
|
// entries.remove(entry);
|
||||||
}).start();
|
// }).start();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,11 @@ import java.util.ArrayList;
|
||||||
import me.brysonsteck.wiimmfiwatcher.R;
|
import me.brysonsteck.wiimmfiwatcher.R;
|
||||||
|
|
||||||
public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
|
public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
|
||||||
|
|
||||||
String display;
|
String display;
|
||||||
String playerLink;
|
String playerLink;
|
||||||
String header;
|
String header;
|
||||||
ArrayList<Player> players;
|
ArrayList<Player> players;
|
||||||
boolean online = true;
|
|
||||||
public RoomAdapter (String display, String playerLink, String header, ArrayList<Player> players) {
|
public RoomAdapter (String display, String playerLink, String header, ArrayList<Player> players) {
|
||||||
this.display = display;
|
this.display = display;
|
||||||
this.playerLink = playerLink;
|
this.playerLink = playerLink;
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class RoomData {
|
||||||
String friendCode;
|
String friendCode;
|
||||||
ArrayList<Player> players = new ArrayList<>();
|
ArrayList<Player> players = new ArrayList<>();
|
||||||
|
|
||||||
public RoomData (ArrayList<Player> players, String playerLink, String friendCode) {
|
public RoomData (ArrayList<Player> players, String friendCode) {
|
||||||
this.friendCode = friendCode;
|
this.friendCode = friendCode;
|
||||||
getPlayerLink();
|
getPlayerLink();
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
|
@ -91,10 +91,8 @@ public class RoomData {
|
||||||
|
|
||||||
public void getPlayerLink() {
|
public void getPlayerLink() {
|
||||||
try {
|
try {
|
||||||
Document doc = null;
|
Document doc = Jsoup.connect("https://wiimmfi.de/stats/mkw")
|
||||||
|
.userAgent("Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) (Developer testing)")
|
||||||
doc = Jsoup.connect("https://wiimmfi.de/stats/mkw")
|
|
||||||
.userAgent("Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) (UNDER DEVELOPMENT)")
|
|
||||||
.get();
|
.get();
|
||||||
Element table = doc.select("table").get(0);
|
Element table = doc.select("table").get(0);
|
||||||
Elements rows = table.select("tr");
|
Elements rows = table.select("tr");
|
||||||
|
@ -102,13 +100,11 @@ public class RoomData {
|
||||||
for (int i = 0; i < rows.size(); i++) {
|
for (int i = 0; i < rows.size(); i++) {
|
||||||
Element row = rows.get(i);
|
Element row = rows.get(i);
|
||||||
Elements colPlayers = row.select("td");
|
Elements colPlayers = row.select("td");
|
||||||
Elements colHeader = row.select("th");
|
|
||||||
|
|
||||||
|
|
||||||
if (colPlayers.size() > 0) {
|
if (colPlayers.size() > 0) {
|
||||||
|
|
||||||
String data = colPlayers.get(0).select("a").toString();
|
String data = colPlayers.get(0).select("a").toString();
|
||||||
// System.out.println(data);
|
|
||||||
if (data.contains(friendCode)) {
|
if (data.contains(friendCode)) {
|
||||||
System.out.println("Found friend code");
|
System.out.println("Found friend code");
|
||||||
playerLink = data.split("\"")[3];
|
playerLink = data.split("\"")[3];
|
||||||
|
@ -130,7 +126,7 @@ public class RoomData {
|
||||||
public RoomData refresh() {
|
public RoomData refresh() {
|
||||||
players.clear();
|
players.clear();
|
||||||
roomHeader = "";
|
roomHeader = "";
|
||||||
return new RoomData(players, playerLink, friendCode);
|
return new RoomData(players, friendCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ public class RoomFragment extends Fragment {
|
||||||
ArrayList<Player> players;
|
ArrayList<Player> players;
|
||||||
RoomData roomData;
|
RoomData roomData;
|
||||||
|
|
||||||
public RoomFragment(String friendCode, String header, ArrayList<Player> players, String playerLink, String display) {
|
public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display) {
|
||||||
super(R.layout.fragment_room);
|
super(R.layout.fragment_room);
|
||||||
this.roomData = new RoomData(players, playerLink, friendCode);
|
this.roomData = new RoomData(players, friendCode);
|
||||||
this.header = roomData.getRoomHeader();
|
this.header = roomData.getRoomHeader();
|
||||||
this.display = display;
|
this.display = display;
|
||||||
this.players = players;
|
this.players = players;
|
||||||
|
@ -52,8 +52,6 @@ public class RoomFragment extends Fragment {
|
||||||
roomData = roomData.refresh();
|
roomData = roomData.refresh();
|
||||||
RoomData newRoomData = roomData.refresh();
|
RoomData newRoomData = roomData.refresh();
|
||||||
players = roomData.getPlayers();
|
players = roomData.getPlayers();
|
||||||
// playerLink = roomData.getPlayerLink();
|
|
||||||
// String otherPlayerLink = newRoomData.getPlayerLink();
|
|
||||||
header = newRoomData.getRoomHeader();
|
header = newRoomData.getRoomHeader();
|
||||||
if (header == null) {
|
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.";
|
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.";
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class WiimmfiActivity extends AppCompatActivity {
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
getSupportFragmentManager().beginTransaction()
|
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)
|
.setReorderingAllowed(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
@ -54,49 +54,49 @@ public class WiimmfiActivity extends AppCompatActivity {
|
||||||
if (menuItem.getItemId() == R.id.friend_code) {
|
if (menuItem.getItemId() == R.id.friend_code) {
|
||||||
players.clear();
|
players.clear();
|
||||||
getSupportFragmentManager().beginTransaction()
|
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)
|
.setReorderingAllowed(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
if (menuItem.getItemId() == R.id.roles) {
|
if (menuItem.getItemId() == R.id.roles) {
|
||||||
players.clear();
|
players.clear();
|
||||||
getSupportFragmentManager().beginTransaction()
|
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)
|
.setReorderingAllowed(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
if (menuItem.getItemId() == R.id.login_regions) {
|
if (menuItem.getItemId() == R.id.login_regions) {
|
||||||
players.clear();
|
players.clear();
|
||||||
getSupportFragmentManager().beginTransaction()
|
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)
|
.setReorderingAllowed(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
if (menuItem.getItemId() == R.id.room_match) {
|
if (menuItem.getItemId() == R.id.room_match) {
|
||||||
players.clear();
|
players.clear();
|
||||||
getSupportFragmentManager().beginTransaction()
|
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)
|
.setReorderingAllowed(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
if (menuItem.getItemId() == R.id.world) {
|
if (menuItem.getItemId() == R.id.world) {
|
||||||
players.clear();
|
players.clear();
|
||||||
getSupportFragmentManager().beginTransaction()
|
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)
|
.setReorderingAllowed(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
if (menuItem.getItemId() == R.id.conn_fail) {
|
if (menuItem.getItemId() == R.id.conn_fail) {
|
||||||
players.clear();
|
players.clear();
|
||||||
getSupportFragmentManager().beginTransaction()
|
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)
|
.setReorderingAllowed(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
if (menuItem.getItemId() == R.id.vr_br) {
|
if (menuItem.getItemId() == R.id.vr_br) {
|
||||||
players.clear();
|
players.clear();
|
||||||
getSupportFragmentManager().beginTransaction()
|
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)
|
.setReorderingAllowed(true)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue