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
|
||||
* 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
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<FriendCode> 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();
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
aboutButton.setOnClickListener((about) -> {
|
||||
// aboutButton.setClickable(false);
|
||||
aboutButton.setVisibility(View.INVISIBLE);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.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.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);
|
||||
}
|
||||
|
|
|
@ -30,28 +30,16 @@ public class FriendCodeViewModel extends AndroidViewModel {
|
|||
}).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() {
|
||||
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();
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -19,12 +19,11 @@ import java.util.ArrayList;
|
|||
import me.brysonsteck.wiimmfiwatcher.R;
|
||||
|
||||
public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
|
||||
|
||||
String display;
|
||||
String playerLink;
|
||||
String header;
|
||||
ArrayList<Player> players;
|
||||
boolean online = true;
|
||||
|
||||
public RoomAdapter (String display, String playerLink, String header, ArrayList<Player> players) {
|
||||
this.display = display;
|
||||
this.playerLink = playerLink;
|
||||
|
|
|
@ -14,7 +14,7 @@ public class RoomData {
|
|||
String friendCode;
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
|
||||
public RoomData (ArrayList<Player> players, String playerLink, String friendCode) {
|
||||
public RoomData (ArrayList<Player> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ public class RoomFragment extends Fragment {
|
|||
ArrayList<Player> players;
|
||||
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);
|
||||
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.";
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Reference in a new issue