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

Screen manager #824

Merged

Conversation

BrettyWhite
Copy link
Contributor

@BrettyWhite BrettyWhite commented Jul 24, 2018

Fixes #782

This PR is ready for review.

Risk

This PR makes minor API changes.

Testing Plan

  • This code snippet can be used to test the manager:
// Begin update transaction
proxy.getScreenManager().beginTransaction();

//proxy.getScreenManager().setDisplayLayout(PredefinedLayout.DOUBLE_GRAPHIC_WITH_SOFTBUTTONS);

// Set text fields
proxy.getScreenManager().setTextField1("It is");
proxy.getScreenManager().setTextField2("Wednesday");
proxy.getScreenManager().setTextField3("My");
proxy.getScreenManager().setTextField4("Dudes");


// Set primary graphic
proxy.getScreenManager().setPrimaryGraphic(new SdlArtwork("image1", FileType.GRAPHIC_PNG, R.drawable.image1, true));


// Create softButtonObject1
SoftButtonState softButtonState1 = new SoftButtonState("object1-state1", "it is", new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, R.mipmap.ic_launcher, false));
SoftButtonState softButtonState2 = new SoftButtonState("object1-state2", "Wed", new SdlArtwork(IMAGE1_FILENAME, FileType.GRAPHIC_PNG, R.drawable.image1, false));
SoftButtonObject softButtonObject1 = new SoftButtonObject("object1", Arrays.asList(softButtonState1, softButtonState2), softButtonState1.getName(), new SoftButtonObject.OnEventListener() {
    @Override
    public void onPress(SoftButtonObject softButtonObject, OnButtonPress onButtonPress) {
        softButtonObject.transitionToNextState();
    }

    @Override
    public void onEvent(SoftButtonObject softButtonObject, OnButtonEvent onButtonEvent) {

    }
});


// Create softButtonObject2
SoftButtonState softButtonState3 = new SoftButtonState("object2-state1", "my", new SdlArtwork(IMAGE2_FILENAME, FileType.GRAPHIC_PNG, R.drawable.image2, false));
SoftButtonState softButtonState4 = new SoftButtonState("object2-state2", "dudes!", null);
SoftButtonObject softButtonObject2 = new SoftButtonObject("object2", Arrays.asList(softButtonState3, softButtonState4), softButtonState3.getName(), null);
softButtonObject2.setOnEventListener(new SoftButtonObject.OnEventListener() {
    @Override
    public void onPress(SoftButtonObject softButtonObject, OnButtonPress onButtonPress) {
        softButtonObject.transitionToNextState();
    }

    @Override
    public void onEvent(SoftButtonObject softButtonObject, OnButtonEvent onButtonEvent) {

    }
});


// Set the soft button objects
proxy.getScreenManager().setSoftButtonObjects(Arrays.asList(softButtonObject1, softButtonObject2));


// Commit update transaction
proxy.getScreenManager().commit(new CompletionListener() {
    @Override
    public void onComplete(boolean success) {
        Log.i(TAG, "UPDATES COMPLETE: " + success);

    }
});

Summary

This PR implements the ScreenManager as described in the proposal.

  • Implemented SoftButtonManager
  • Implemented TextAndGraphicManager
  • Implemented ScreenManager
  • Added test classes to test the functionalties for the managers

CLA

BrettyWhite and others added 30 commits July 24, 2018 10:11
…anager

# Conflicts:
#	sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java
…2_screen_manager_softbutton_manager

# Conflicts:
#	sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java
@Override
public synchronized void onComplete(boolean success) {
if(!success){
Log.d(TAG, "Sub manager failed to initialize");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a check against if the submanagers failed to initialize so that the screen manager transitions to error state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now it sets the screen manager state to ERROR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both managers are not null and are in the ERROR state the ScreenManager will transition to the READY state after this call. However, this callback is essentially pointless at this point. Both the SoftButtonManager and TextAndGraphicManager will be in the READY state after their constructors return. See here, the start() methods are not used in either managers and will set the completionListneer, check state, realize they are in READY state (as at this point neither have a logic path to allow them to go into ERROR state), notify the callback, then clear the reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only place that I can think of for switching to state ERROR is that when they cannot retrieve capabilities.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The start method is called, but it is not overridden (not used) in either submanager so they will always return immediately.


//Constructors

TextAndGraphicManager(ISdl internalInterface, FileManager fileManager, SoftButtonManager softButtonManager) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All vars should be considered @nonnull right?


for (TextField field : textFields) {
if (field.getName() != null) {
TextFieldName name = field.getName();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the declaration for TexFieldName name; before the for loop and just set the name through each iteration rather than create a new reference.

@@ -18,7 +18,7 @@
// states - if this gets more complicated we can move elsewhere
private int state;
private final Object STATE_LOCK = new Object();
public static final int SETTING_UP = 0x00, READY = 0x30, SHUTDOWN = 0x60, ERROR = 0x90;
public static final int SETTING_UP = 0x00, READY = 0x30, SHUTDOWN = 0x60, ERROR = 0x90, LIMITED = 0xC0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this as follows:

public static final int SETTING_UP = 0x00, READY = 0x30, LIMITED = 0x50, SHUTDOWN = 0x80, ERROR = 0xC0;

@bilal-alsharifi bilal-alsharifi merged commit 101d980 into feature/issue_782_Android_Managers Sep 27, 2018
@bilal-alsharifi bilal-alsharifi deleted the feature/screen_manager branch September 27, 2018 18:52
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.

None yet

4 participants