Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/1.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Gamarra committed Nov 12, 2015
2 parents ea20433 + ebe6c6c commit fee85ed
Show file tree
Hide file tree
Showing 87 changed files with 815 additions and 628 deletions.
43 changes: 43 additions & 0 deletions android/Migrate to Liferay Screens 1.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Migrate to Liferay Screens 1.2

## Android SDK

* We recommend using 23 as the `compileSdkVersion`, that means using 23.0.1 or later for android support libraries (appcompat, design...) like this:

```xml

compile 'com.android.support:appcompat-v7:23.+'

```

## Offline changes

* We have added 3 new callbacks in the screenlets that support offline. You don't need to do anything on them, just implement them empty when setting a listener. Like this:

```java
@Override
public void loadingFromCache(boolean success) {
}

@Override
public void retrievingOnline(boolean triedInCache, Exception e) {

}

@Override
public void storingToCache(Object object) {

}
```

Alt + enter in Android Studio when selecting the compiler error can automatically at those methods.

* We have renamed `DDLEntry` to `Record` (in fact we have merged both entities)
* `getAttributes(_)` is now `getModelAttributes().get(_)`
* `getValue(_)` is now `getModelValues().get(_)`

## Mobile SDK Changes

* `JSONObjectAsyncTaskCallback` has been renamed to `JSONObjectCallback` from (com.liferay.mobile.android.callback.typed).
* There are other few small naming changes in the `Mobile SDK` classes, you can see the changes done to the [Liferay Screens project](https://github.com/liferay/liferay-screens/commit/891ae692b2623f74fd19065a5dd45098e45c5fbf)
* There are breaking changes with the `DownloadUtils` class of the Mobile SDK, you have to use `HttpUtil.download` for the same task
2 changes: 1 addition & 1 deletion android/library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ subprojects {

subprojects {

version = '1.2.3'
version = '1.2.4'
group = 'com.liferay.mobile'

buildscript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
*/
public class AssetListCallback extends BaseListCallback<AssetEntry> {

public AssetListCallback(int targetScreenletId, Pair<Integer, Integer> rowsRange, Locale locale) {
super(targetScreenletId, rowsRange, locale);
}
public AssetListCallback(int targetScreenletId, Pair<Integer, Integer> rowsRange, Locale locale) {
super(targetScreenletId, rowsRange, locale);
}

@Override
public AssetEntry createEntity(Map<String, Object> stringObjectMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public int getInputType() {
return InputType.TYPE_NULL;
}
}

private int _value;

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ForgotPasswordCallback(int targetScreenletId) {

@Override
public Boolean transform(Object obj) throws Exception {
return (Boolean)obj;
return (Boolean) obj;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public void onEvent(ForgotPasswordEvent event) {

@Override
public void requestPassword(
long companyId, String login, BasicAuthMethod basicAuthMethod,
String anonymousApiUserName, String anonymousApiPassword)
long companyId, String login, BasicAuthMethod basicAuthMethod,
String anonymousApiUserName, String anonymousApiPassword)
throws Exception {

validate(
companyId, login, basicAuthMethod, anonymousApiUserName,
anonymousApiPassword);

ScreensuserService service = getScreensUserService(
anonymousApiUserName, anonymousApiPassword);
anonymousApiUserName, anonymousApiPassword);

switch (basicAuthMethod) {
case EMAIL:
Expand Down Expand Up @@ -96,7 +96,7 @@ protected ScreensuserService getScreensUserService(

protected void sendForgotPasswordByEmailRequest(
ScreensuserService service, long companyId,
String emailAddress)
String emailAddress)
throws Exception {

service.sendPasswordByEmailAddress(companyId, emailAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void sendGetUserByEmailRequest(UserService service, String email) thro
}

protected void sendGetUserByScreenNameRequest(UserService service, String screenName)
throws Exception {
throws Exception {
service.getUserByScreenName(LiferayServerContext.getCompanyId(), screenName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public LoginOAuthInteractor(int targetScreenletId) {
super(targetScreenletId);
}

public void setOAuthConfig(OAuthConfig value) {
_OAuthConfig = value;
}

public OAuthConfig getOAuthConfig() {
return _OAuthConfig;
}

public void setOAuthConfig(OAuthConfig value) {
_OAuthConfig = value;
}

public void login() throws Exception {
if (_OAuthConfig == null) {
throw new IllegalArgumentException("OAuth configuration cannot be empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.view.View;

import com.liferay.mobile.screens.R;
import com.liferay.mobile.screens.auth.BasicAuthMethod;
import com.liferay.mobile.screens.auth.login.LoginListener;
import com.liferay.mobile.screens.auth.signup.interactor.SignUpInteractor;
import com.liferay.mobile.screens.auth.signup.interactor.SignUpInteractorImpl;
Expand Down Expand Up @@ -72,10 +73,10 @@ public void onSignUpSuccess(User user) {
if (_autoLogin) {
SignUpViewModel viewModel = getViewModel();

String emailAddress = viewModel.getEmailAddress();
String authUsername = getAuthUsernameFromUser(user);
String password = viewModel.getPassword();

SessionContext.createBasicSession(emailAddress, password);
SessionContext.createBasicSession(authUsername, password);
SessionContext.setLoggedUser(user);

if (_autoLoginListener != null) {
Expand All @@ -86,6 +87,18 @@ public void onSignUpSuccess(User user) {
}
}

public String getAuthUsernameFromUser(User user) {
switch (_basicAuthMethod) {
case SCREEN_NAME:
return user.getScreenName();
case USER_ID:
return String.valueOf(user.getId());
case EMAIL:
default:
return user.getEmail();
}
}

public String getAnonymousApiPassword() {
return _anonymousApiPassword;
}
Expand Down Expand Up @@ -164,6 +177,11 @@ protected View createScreenletView(Context context, AttributeSet attributes) {

_credentialsStore = StorageType.valueOf(storeValue);

_autoLogin = typedArray.getBoolean(R.styleable.SignUpScreenlet_autoLogin, true);

int authMethodId = typedArray.getInt(R.styleable.SignUpScreenlet_basicAuthMethod, 0);
_basicAuthMethod = BasicAuthMethod.getValue(authMethodId);

int layoutId = typedArray.getResourceId(
R.styleable.SignUpScreenlet_layoutId, getDefaultLayoutId());

Expand Down Expand Up @@ -208,6 +226,7 @@ protected void onUserAction(String userActionName, SignUpInteractor interactor,
private boolean _autoLogin;
private long _companyId;
private StorageType _credentialsStore;
private BasicAuthMethod _basicAuthMethod;

private SignUpListener _listener;
private LoginListener _autoLoginListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public void onEvent(JSONObjectEvent event) {
}

public void signUp(
long companyId, String firstName, String middleName,
String lastName, String emailAddress, String screenName,
String password, String jobTitle, Locale locale,
String anonymousApiUserName, String anonymousApiPassword)
long companyId, String firstName, String middleName,
String lastName, String emailAddress, String screenName,
String password, String jobTitle, Locale locale,
String anonymousApiUserName, String anonymousApiPassword)
throws Exception {

validate(
Expand Down Expand Up @@ -88,9 +88,9 @@ protected UserService getUserService(
}

protected void sendSignUpRequest(
UserService service, long companyId, String firstName,
String middleName, String lastName, String emailAddress,
String screenName, String password, String jobTitle, Locale locale)
UserService service, long companyId, String firstName,
String middleName, String lastName, String emailAddress,
String screenName, String password, String jobTitle, Locale locale)
throws Exception {

middleName = (middleName != null) ? middleName : "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ private static int _generateScreenletId() {
}
}
}

private static final String _STATE_SCREENLET_ID = "basescreenlet-screenletId";
private static final String _STATE_SUPER = "basescreenlet-super";
private static final String _STATE_INTERACTORS = "basescreenlet-interactors";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private View findActionView(View parent, int actionViewId) {

return findActionView((View) parent.getParent(), actionViewId);
}

private int _actionViewId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ protected OfflinePolicy getOfflinePolicy() {
protected boolean hasToStoreToCache() {
return !_retrievedFromCache;
}

private boolean _retrievedFromCache;
private final OfflinePolicy _offlinePolicy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public BaseCachedWriteRemoteInteractor(int targetScreenletId, OfflinePolicy offl

protected void storeWithCache(Object... args) throws Exception {
if (_offlinePolicy == OfflinePolicy.CACHE_ONLY) {
storeToCache(false, args);
storeToCacheAndLaunchEvent(false, args);
}
else if (_offlinePolicy == OfflinePolicy.CACHE_FIRST) {
try {
storeToCache(false, args);
storeToCacheAndLaunchEvent(false, args);
}
catch (Exception e) {
online(args);
Expand All @@ -32,7 +32,7 @@ else if (_offlinePolicy == OfflinePolicy.REMOTE_FIRST) {
online(args);
}
catch (Exception e) {
storeToCache(false, args);
storeToCacheAndLaunchEvent(false, args);
LiferayLogger.i("Store online first failed, trying to store locally version");
}
}
Expand All @@ -41,32 +41,11 @@ else if (_offlinePolicy == OfflinePolicy.REMOTE_FIRST) {
}
}

protected void onEventWithCache(E event, Object... args) {
if (event.isFailed()) {
try {
storeToCache(false, args);
notifySuccess(event);
}
catch (Exception e) {
notifyError(event);
}
}
else {
if (event.isRemote()) {
storeToCache(true, args);
}
notifySuccess(event);
}
}

protected abstract void online(Object... args) throws Exception;

protected abstract void notifySuccess(E event);

protected abstract void notifyError(E event);

protected abstract void storeToCache(boolean synced, Object... args);

protected abstract void storeToCacheAndLaunchEvent(boolean synced, Object... args);
private final OfflinePolicy _offlinePolicy;

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public void setRowCount(int rowCount) {
}

protected abstract void fillHolder(E entry, H holder);

protected static final int LAYOUT_TYPE_DEFAULT = 0;
protected static final int LAYOUT_TYPE_PROGRESS = 1;
private List<E> _entries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ private void addNewServerEntries(int page, List<E> serverEntries, int rowCount,
entries.set(i + firstRowForPage, serverEntries.get(i));
}
}

private static final String _STATE_ENTRIES = "entries";
private static final String _STATE_ROW_COUNT = "rowCount";
private static final String _STATE_SUPER = "super";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import com.liferay.mobile.screens.base.context.RequestState;
import com.liferay.mobile.screens.base.interactor.BaseCachedRemoteInteractor;
import com.liferay.mobile.screens.cache.Cache;
import com.liferay.mobile.screens.cache.OfflinePolicy;
import com.liferay.mobile.screens.cache.CachedType;
import com.liferay.mobile.screens.cache.OfflinePolicy;
import com.liferay.mobile.screens.cache.sql.CacheSQL;
import com.liferay.mobile.screens.cache.tablecache.TableCache;
import com.liferay.mobile.screens.context.LiferayServerContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@

public class BaseListResult<E> {

public void setEntries(List<E> values) {
_entries = values;
}
public List<E> getEntries() {
return _entries;
}

public void setRowCount(int value) {
_rowCount = value;
}
public void setEntries(List<E> values) {
_entries = values;
}

public List<E> getEntries() {
return _entries;
}

public int getRowCount() {
return _rowCount;
}
public int getRowCount() {
return _rowCount;
}

public void setRowCount(int value) {
_rowCount = value;
}
private List<E> _entries;
private int _rowCount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public interface BaseListViewModel<E> extends BaseViewModel {

void showFinishOperation(int page, List<E> entries, int rowCount);

void showFinishOperation(int page, Exception e);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;

import com.liferay.mobile.screens.cache.CacheSyncService;

/**
* @author Javier Gamarra
*/
Expand Down
Loading

0 comments on commit fee85ed

Please sign in to comment.