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

BOT-320/Feature menu #321

Merged
merged 11 commits into from
Aug 30, 2017
Merged

BOT-320/Feature menu #321

merged 11 commits into from
Aug 30, 2017

Conversation

Mecharyry
Copy link
Contributor

@Mecharyry Mecharyry commented Aug 27, 2017

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 and FeatureSelectionPersistence which I have tried to make as generic as possible to allow this to be swapped out if necessary.

Screen capture

Feature selection
device-2017-08-27-134059


public interface FeatureSelectionController<LIST, FEATURE> {

void attachFeatureSelectionTo(LIST toAttachTo);
Copy link
Contributor Author

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.

Copy link
Contributor Author

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 {
Copy link
Contributor Author

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> {
Copy link
Contributor Author

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 MenuItems. This class also handles the toggle of menu items.

Copy link
Contributor Author

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;
Copy link
Contributor Author

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);


Copy link
Contributor Author

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);
Copy link
Contributor Author

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 MenuItems ✨

@Mecharyry
Copy link
Contributor Author

Don't want to block work on this bot anymore with PRs. Will create a feature PR against master when an MVP is complete.

@Mecharyry Mecharyry merged commit 980ff4e into tpbot-feature-branch Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant