Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

SQ-60/Check remote config for onboarding #256

Merged
merged 30 commits into from
Apr 4, 2017

Conversation

rock3r
Copy link
Collaborator

@rock3r rock3r commented Apr 4, 2017

This PR is HUGE and I'm really sorry about that but I went up and down paths that led me nowhere. I have tidied things up as much as I could but it's still a significant amount of changes, because the original idea turned out to be somewhat flawed. Sorryyyyy

The idea is that now we have a ProximityFeature that checks whether the Bluetooth is available on the device, and if the kill switch has not been pulled. There's a lot of refactoring and cleaning (hence a noisy diff).

Next (and last) step is to understand why the preferences don't look disabled when they are, and possibly use the Feature in the Preconditions to reduce duplication.

@rock3r rock3r requested a review from fourlastor April 4, 2017 08:29
Copy link
Contributor

@fourlastor fourlastor left a comment

Choose a reason for hiding this comment

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

Few questions 💃

@@ -21,6 +23,8 @@ public static RoutingComponent obtain(Activity activity) {
.navigationModule(new NavigationModule())
.signInModule(new SignInModule())
.routingModule(new RoutingModule())
.proximityFeatureModule(new ProximityFeatureModule())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this have the proximity feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Used by the Onboarding class (through the OnboardingModule) to decide whether we can show the Proximity onboarding page (https://github.com/rock3r/squanchy/pull/256/files#diff-e08306406758fca42ffe92c82be63267R35)

}

@Override
public void featureDisabled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we have Timber.e something here? This shouldn't happen I suppose (as in you shouldn't get here to start with if the feature is disabled)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

abc912e (same for the SettingsFragment)

};
}

private void showNonFatalProximityError(Snackbar snackbar) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we do the same as showFatalProximityError? As in passing only the @StringRes and making the snackbar here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok will have to make it more complicated because some snackbars have actions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh. Used to. Failed miserably and now we have two things that show the same message. That is bad. Will fix

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't really care about that case that was covered by the snackbar actions, so I will simply uniform all the things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

public class BluetoothModule {

@Provides
BluetoothManager bluetoothManager(Activity activity) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you really need an activity? what about a context?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good luck injecting a Context. Dagger will explode because there's different kinds of Context, Application and Activity, and it doesn't know which one to use. This could, I suppose, use an Application instead. But no, you cannot have a @Provide Context if you need to also distinguish between Activity and Application in other modules (which is our case).

Copy link
Collaborator 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.

You technically could 😅 using a qualifier :P but ok

@@ -15,9 +15,9 @@

boolean anyUnsatisfied() {
for (Precondition precondition : preconditions) {
boolean canCheck = precondition.performsSynchronousSatisfiedCheck();
//boolean canCheckIfSatisfied = precondition.performsSynchronousSatisfiedCheck();
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, will take out

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

.addApi(LocationServices.API)
.build();

SettingsFragmentComponent component = SettingsInjector.obtainForFragment(
Copy link
Contributor

Choose a reason for hiding this comment

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

why is there an obtainForFragment method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Two different components (Activity and Fragment), one injector

return new ProximityPreconditions.Callback() {
@Override
public void notOptedIn() {
showProximityEnablingError(Snackbar.make(getViewOrThrow(), R.string.proximity_error_not_opted_in, Snackbar.LENGTH_LONG));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can encapsulate Snackbar.make inside showProximityEnablingError and pass only the message

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done already in 615db96 addressing the equivalent comment in LocationOnboardingActivity. This was once used to offer actions in snackbars, then I took them out and forgot to re-simplify this. Sorry.

<string name="onboarding_error_location_failed_action">ENABLE MANUALLY</string>
<string name="onboarding_error_google_client_connection">Unable to verify location settings for the device. Please try again shortly.</string>

<string name="proximity_error_not_opted_in">Sorry, unable to opt in because… you’re not opted in? If that makes any sense.</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

you didn't opt in? It's not like a state in which you are 👅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's an illegal state, someone started the preconditions satisfaction action (which is meant to be run after opting in) while not opted in :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah but what I meant is "You're not opted in" isn't correct, the correct form is "You didn't opt in"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


<string name="proximity_error_not_opted_in">Sorry, unable to opt in because… you’re not opted in? If that makes any sense.</string>
<string name="proximity_error_remote_config_kill_switch">Sorry, the feature has been disabled remotely.</string>
<string name="proximity_error_permission_denied">We need the location permission to continue.</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

the proximity_error_location_denied string is the same

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

<string name="proximity_error_location_denied">We need the location permission to continue.</string>
<string name="proximity_error_bluetooth_denied">We need the Bluetooth to be active to continue.</string>
<string name="proximity_error_location_failed">Unable to verify location settings for the device.</string>
<string name="proximity_error_location_failed_action">ENABLE MANUALLY</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this? XD

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Old thing. Will take out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fourlastor fourlastor merged commit 56f7cf2 into SQ-60/onboarding_feature Apr 4, 2017
@rock3r rock3r deleted the SQ-60/Check_RemoteConfig branch April 4, 2017 15:17
@rock3r rock3r mentioned this pull request Apr 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants