-
Notifications
You must be signed in to change notification settings - Fork 129
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
BOT-320/Feature menu #321
BOT-320/Feature menu #321
Conversation
|
||
public interface FeatureSelectionController<LIST, FEATURE> { | ||
|
||
void attachFeatureSelectionTo(LIST toAttachTo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to make the feature selection menu as generic as possible so that it can be swapped out if necessary. The goal is to have most code live in core and only expose android when we need to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of this interface, the LIST
is the thing you want to attach each feature item to. FEATURE
is the representation of the feature stored in the list. In android this will be the menuItem
but could easily be an enum or anything else.
@@ -0,0 +1,11 @@ | |||
package com.novoda.tpbot.feature_selection; | |||
|
|||
public interface FeatureSelectionPersistence { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATM the persistence is SharedPreferences
but we should be able to swap it out.
|
||
import com.novoda.tpbot.R; | ||
|
||
public final class MenuFeatureSelectionController implements FeatureSelectionController<Menu, MenuItem> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handles the inflation of the Menu
and the individual MenuItem
s. This class also handles the toggle of menu items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to try and remove as much code from the activity
as possible.
@@ -3,12 +3,12 @@ | |||
import android.os.Handler; | |||
import android.os.Looper; | |||
|
|||
import com.novoda.tpbot.Direction; | |||
import com.novoda.tpbot.Result; | |||
import com.novoda.support.Observable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just auto-formatting 😄
@@ -50,7 +50,6 @@ protected void onCreate(Bundle savedInstanceState) { | |||
ServerDeclarationView serverDeclarationView = Views.findById(switchableView, R.id.bot_server_declaration_view); | |||
serverDeclarationView.setServerDeclarationListener(serverDeclarationListener); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just auto-formatting 😄
@@ -39,4 +47,19 @@ public void onClick(View v) { | |||
} | |||
}; | |||
|
|||
@Override | |||
public boolean onCreateOptionsMenu(Menu menu) { | |||
featureSelectionController.attachFeatureSelectionTo(menu); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So little code in the activity now for MenuItem
s ✨
Don't want to block work on this bot anymore with PRs. Will create a feature PR against master when an MVP is complete. |
Problem
As per issue #320, it is becoming more tedious to manually test individual components of TpBot. In order to test the connection to the Bot you first need to connect to the server and then enable the accessibility service each and every time 😢
Solution
Add some checkboxes to the
LandingActivity
menu so that individual features can be disabled.Introduced a
FeatureSelectionController
andFeatureSelectionPersistence
which I have tried to make as generic as possible to allow this to be swapped out if necessary.Screen capture