Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small cleanup of the code structure #2267

Merged

Conversation

Mathias-Boulay
Copy link
Contributor

Sigh...
I shouldn't even have to do this, but it seems the previous people here committed heresy.
So here I am, fixing a few mistakes that took time to deal with. It also comes with more modularity, which maybe will be of some importance later on.

Anyway, what's new there ?
Not much for the end user, most things concerns the devs here

Android 12 gamepad support

Since android 12 revamped its internals, I could not rely on Java reflection to save on object creation.
The new implementation doesn't use any reflection and relies on primitive types.
A 3 months overdue fix in other words, since reflection isn't the best thing to use in production software

Fix Null reference of currentDisplayMetrics

Turns out we forgot to store the function results into this static variable.
It May not fix all crashes, seems it seems a bit device dependant but it should work for 99.99% of phones.

Modularity, rise !

Most of the effort has been put into modularizing components to unlink them from an activity.
The following changes have been made:

MineGLView

This view now handles the surface listener and user inputs and the debugging of input pointers.
Launching minecraft is still up to the BaseMainActivity.

The onTouchEvent code structure has been overhauled, now being MUCH flatter than before.
It is also slightly optimized, a welcome addition given how many times this function is called 😅

Touchpad

The Touchpad is its own component, with a separate touch detection from the mineGLView. It works pretty much by itself now. Work should be done to modularize this component even more ?

Logger

The Logger class is a class following the singleton pattern.
It is here to replace the LoggableActivity which should never have existed in the first place. WE DON'T PUT LOGGERS INTO CONTEXT CONTAINING OBJECTS !

LoggerView

An almost drop-in replacement to the LinearLayout that was duplicated across layouts needing to check on logs.
Just drop the LoggerView into the layout, it works by itself. You can set its visibility to display or hide logs easily.

MCOptionUtils

This class now integrates a public interface MCOptionListener which notifies if any mc option was changed.

Miscenalleous

  • Convenience functions moved to CallbackBridge class
  • Gamepad doesn't hold any activity as an instance variable anymore
  • Fixed square area detection for touch slopiness
  • Updated gradle file to latest target sdk and packages
  • Made gradle date functions static
  • Surely other stuff 😅

Mathias-Boulay and others added 29 commits November 15, 2021 22:29
- Improved control onTouch performance
- Remove context holding from the Gamepad object
- Simplified main_with_custom_ctrl layout hierarchy
- Move static inputs methods to CallbackBridge
- Restored pointerDebugTextview, now auto-instanciated.
- Simplified main_with_ctrl hierarchy
@Mathias-Boulay Mathias-Boulay changed the title [UNFINISHED] Small cleanup of the code structure Small cleanup of the code structure Nov 21, 2021
@Mathias-Boulay
Copy link
Contributor Author

lmao I closed it instead of merging it

@Mathias-Boulay Mathias-Boulay merged commit 3cfcae8 into PojavLauncherTeam:v3_openjdk Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant