-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor setup wizard; add device pairing support.
- Loading branch information
Showing
19 changed files
with
777 additions
and
353 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
kegtab/src/main/java/org/kegbot/app/setup/SetupCompleteStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.kegbot.app.setup; | ||
|
||
import android.app.Fragment; | ||
|
||
import com.google.common.base.Strings; | ||
|
||
import org.kegbot.app.KegbotApplication; | ||
import org.kegbot.app.R; | ||
import org.kegbot.app.config.AppConfiguration; | ||
|
||
public class SetupCompleteStep extends SetupStep { | ||
|
||
private final Fragment mContentFragment = new SetupTextFragment() { | ||
@Override | ||
public String getTitle() { | ||
return getString(R.string.setup_finished_title); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return getString(R.string.setup_finished_description); | ||
} | ||
}; | ||
|
||
public SetupCompleteStep(SetupActivity.SetupState state) { | ||
super(state); | ||
} | ||
|
||
@Override | ||
public Fragment getContentFragment() { | ||
mState.setNextButtonText(R.string.setup_button_finish); | ||
return mContentFragment; | ||
} | ||
|
||
@Override | ||
public Fragment getControlsFragment() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public SetupStep advance() throws SetupValidationException { | ||
return null; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
kegtab/src/main/java/org/kegbot/app/setup/SetupKegbotUrlStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.kegbot.app.setup; | ||
|
||
import android.app.Fragment; | ||
import android.os.Build; | ||
|
||
import com.google.common.base.Strings; | ||
|
||
import org.kegbot.api.KegbotApiException; | ||
import org.kegbot.api.KegbotApiImpl; | ||
import org.kegbot.app.KegbotApplication; | ||
import org.kegbot.app.R; | ||
import org.kegbot.app.config.AppConfiguration; | ||
|
||
public class SetupKegbotUrlStep extends SetupStep { | ||
|
||
private final Fragment mContentFragment = new SetupTextFragment() { | ||
@Override | ||
public String getTitle() { | ||
return getString(R.string.setup_kegbot_url_title); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return getString(R.string.setup_kegbot_url_description); | ||
} | ||
}; | ||
|
||
private final SetupKegbotUrlFragment mControlsFragment = new SetupKegbotUrlFragment(); | ||
|
||
public SetupKegbotUrlStep(SetupActivity.SetupState state) { | ||
super(state); | ||
} | ||
|
||
@Override | ||
public Fragment getContentFragment() { | ||
return mContentFragment; | ||
} | ||
|
||
@Override | ||
public Fragment getControlsFragment() { | ||
return mControlsFragment; | ||
} | ||
|
||
@Override | ||
public SetupStep advance() throws SetupValidationException { | ||
final String error = mControlsFragment.validate(); | ||
if (!Strings.isNullOrEmpty(error)) { | ||
mControlsFragment.onValidationFailed(); | ||
throw new SetupValidationException(error); | ||
} | ||
|
||
final AppConfiguration config = KegbotApplication.get(mControlsFragment.getActivity()).getConfig(); | ||
final KegbotApiImpl api = new KegbotApiImpl(config); | ||
|
||
try { | ||
if (api.supportsDeviceLink()) { | ||
return new SetupPairStep(mState); | ||
} | ||
return new SetupLoginStep(mState); | ||
} catch (KegbotApiException e) { | ||
throw new SetupValidationException("Error connecting to server: " + SetupFragment.toHumanError(e)); | ||
} | ||
} | ||
} |
Oops, something went wrong.