Skip to content

Commit

Permalink
Merge pull request #91 from hansemannn/MOD-2397
Browse files Browse the repository at this point in the history
[MOD-2397] Fix null-acess on "expirationDate", format sources
  • Loading branch information
hansemannn authored Feb 10, 2018
2 parents 377c135 + a190507 commit 88c755f
Show file tree
Hide file tree
Showing 29 changed files with 1,502 additions and 1,442 deletions.
26 changes: 26 additions & 0 deletions android/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
Language: Java
AccessModifierOffset: -4
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
# class, constructor, method should be next line
BreakBeforeBraces: Linux
# Keep '=' at end of line when wrapping, but move things like '&&', '||' to beginning of newline
BreakBeforeBinaryOperators: NonAssignment
# FIXME: break for brace after synchronized block, anonymous class declarations
BreakAfterJavaFieldAnnotations: true
ColumnLimit: 120
IndentCaseLabels: true
IndentWidth: 4
MaxEmptyLinesToKeep: 1
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpacesInParentheses: false
TabWidth: 4
UseTab: ForContinuationAndIndentation
SpaceAfterCStyleCast: true
# Spaces inside {} for array literals, i.e. "new Object[] { args }"
Cpp11BracedListStyle: false
ReflowComments: false
38 changes: 0 additions & 38 deletions android/documentation/changelog.md

This file was deleted.

39 changes: 0 additions & 39 deletions android/documentation/index.md

This file was deleted.

2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 7.1.0
version: 7.1.1
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86
description: facebook
Expand Down
55 changes: 29 additions & 26 deletions android/src/facebook/ActivityWorkerProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import com.facebook.*;

@Kroll.proxy(creatableInModule=TiFacebookModule.class)
@Kroll.proxy(creatableInModule = TiFacebookModule.class)
public class ActivityWorkerProxy extends KrollProxy implements OnActivityResultEvent, OnInstanceStateEvent
{
private static final String TAG = "ActivityWorkerProxy";
Expand All @@ -43,50 +43,53 @@ public void handleCreationDict(KrollDict options)
{
super.handleCreationDict(options);
}

@Override
public void onCreate(Activity activity, Bundle savedInstanceState) {
Log.d(TAG, "onCreate called for ActivityWorkerProxy");
public void onCreate(Activity activity, Bundle savedInstanceState)
{
Log.d(TAG, "onCreate called for ActivityWorkerProxy");
((TiBaseActivity) activity).addOnActivityResultListener(this);
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(
AccessToken oldAccessToken,
AccessToken currentAccessToken) {
if (currentAccessToken == null) {
// User logged out
TiFacebookModule.getFacebookModule().fireEvent(TiFacebookModule.EVENT_LOGOUT, null);
} else {
// AccessToken refreshed
if (TiFacebookModule.getFacebookModule().isAccessTokenRefreshCalled()) {
TiFacebookModule.getFacebookModule().setAccessTokenRefreshCalled(false);
TiFacebookModule.getFacebookModule().fireEvent(TiFacebookModule.EVENT_TOKEN_UPDATED, null);
}
}
}
};

@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken)
{
if (currentAccessToken == null) {
// User logged out
TiFacebookModule.getFacebookModule().fireEvent(TiFacebookModule.EVENT_LOGOUT, null);
} else {
// AccessToken refreshed
if (TiFacebookModule.getFacebookModule().isAccessTokenRefreshCalled()) {
TiFacebookModule.getFacebookModule().setAccessTokenRefreshCalled(false);
TiFacebookModule.getFacebookModule().fireEvent(TiFacebookModule.EVENT_TOKEN_UPDATED, null);
}
}
}
};
}

@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data)
{
Log.d(TAG, "ActivityWorkerProxy onActivityResult");
TiFacebookModule.getFacebookModule().getCallbackManager().onActivityResult(requestCode, resultCode, data);
}

@Override
public void onDestroy(Activity activity) {
public void onDestroy(Activity activity)
{
Log.d(TAG, "ActivityWorkerProxy onDestroy");
accessTokenTracker.stopTracking();
}

@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(Bundle outState)
{
Log.d(TAG, "ActivityWorkerProxy onSaveInstanceState");
}

@Override
public void onRestoreInstanceState(Bundle inState) {
public void onRestoreInstanceState(Bundle inState)
{
Log.d(TAG, "ActivityWorkerProxy onRestoreInstanceState");
}
}
}
29 changes: 13 additions & 16 deletions android/src/facebook/LikeButtonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,36 @@
import org.appcelerator.titanium.view.TiUIView;
import org.appcelerator.titanium.proxy.TiViewProxy;


import android.app.Activity;

@Kroll.proxy(creatableInModule = TiFacebookModule.class, propertyAccessors={
"foregroundColor",
"likeViewStyle",
"auxiliaryViewPosition",
"objectID",
"horizontalAlignment"
})
public class LikeButtonProxy extends TiViewProxy
@Kroll.proxy(creatableInModule = TiFacebookModule.class,
propertyAccessors = { "foregroundColor", "likeViewStyle", "auxiliaryViewPosition", "objectID",
"horizontalAlignment" })
public class LikeButtonProxy extends TiViewProxy
{
private static final String TAG = "LikeButtonProxy";
public LikeButtonProxy() {
public LikeButtonProxy()
{
super();
defaultValues.put("likeViewStyle", "standard");
defaultValues.put("auxiliaryViewPosition", "bottom");
defaultValues.put("horizontalAlignment", "center");
Log.d(TAG, "[VIEWPROXY LIFECYCLE EVENT] init");
Log.w(TAG, "The LikeButton API has been deprecated by the Facebook SDK 4.29.0 and will be removed in the future");
Log.d(TAG, "[VIEWPROXY LIFECYCLE EVENT] init");
Log.w(TAG,
"The LikeButton API has been deprecated by the Facebook SDK 4.29.0 and will be removed in the future");
}

@Override
public TiUIView createView(Activity activity)
{
public TiUIView createView(Activity activity)
{
LikeButtonView view = new LikeButtonView(this);
view.getLayoutParams().autoFillsHeight = true;
view.getLayoutParams().autoFillsWidth = true;
return view;
}

@Override
public void handleCreationDict(KrollDict options)
public void handleCreationDict(KrollDict options)
{
Log.d(TAG, "VIEWPROXY LIFECYCLE EVENT] handleCreationDict " + options);
super.handleCreationDict(options);
Expand Down
54 changes: 27 additions & 27 deletions android/src/facebook/LikeButtonView.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
import com.facebook.share.widget.LikeView.HorizontalAlignment;
import com.facebook.share.widget.LikeView.Style;


public class LikeButtonView extends TiUIView
public class LikeButtonView extends TiUIView
{
private static final String TAG = "LikeButtonView";
private LikeView likeView;
public LikeButtonView(TiViewProxy proxy)

public LikeButtonView(TiViewProxy proxy)
{
super(proxy);
Log.d(TAG, "[VIEW LIFECYCLE EVENT] view");
Expand All @@ -40,50 +39,52 @@ public LikeButtonView(TiViewProxy proxy)
// for your view to be rendered correctly.
setNativeView(likeView);
}

// The view is automatically registered as a model listener when the view
// is realized by the view proxy. That means that the processProperties
// method will be called during creation and that propertiesChanged and
// method will be called during creation and that propertiesChanged and
// propertyChanged will be called when properties are changed on the proxy.
private void setLikeViewStyle(String name) {
for(Style style : Style.values()) {
private void setLikeViewStyle(String name)
{
for (Style style : Style.values()) {
if (style.name().toString().equalsIgnoreCase(name)) {
likeView.setLikeViewStyle(style);
break;
}
}
}
}

private void setAuxiliaryViewPosition(String name) {
for(AuxiliaryViewPosition avp : AuxiliaryViewPosition.values()) {
private void setAuxiliaryViewPosition(String name)
{
for (AuxiliaryViewPosition avp : AuxiliaryViewPosition.values()) {
if (avp.name().toString().equalsIgnoreCase(name)) {
likeView.setAuxiliaryViewPosition(avp);
break;
}
}
}
}

private void setHorizontalAlignment(String name) {
for(HorizontalAlignment ha : HorizontalAlignment.values()) {

private void setHorizontalAlignment(String name)
{
for (HorizontalAlignment ha : HorizontalAlignment.values()) {
if (ha.name().toString().equalsIgnoreCase(name)) {
likeView.setHorizontalAlignment(ha);
break;
}
}
}
}

@Override
public void processProperties(KrollDict props)
public void processProperties(KrollDict props)
{
super.processProperties(props);
Log.d(TAG,"[VIEW LIFECYCLE EVENT] processProperties " + props);
Log.d(TAG, "[VIEW LIFECYCLE EVENT] processProperties " + props);
if (props.containsKey("objectId")) {
likeView.setObjectIdAndType(props.getString("objectID"),LikeView.ObjectType.PAGE);
likeView.setObjectIdAndType(props.getString("objectID"), LikeView.ObjectType.PAGE);
}
if (props.containsKey("likeViewStyle")) {
String styleName = props.getString("likeViewStyle");
setLikeViewStyle(styleName);

}
if (props.containsKey("auxiliaryViewPosition")) {
String positionName = props.getString("auxiliaryViewPosition");
Expand All @@ -95,16 +96,16 @@ public void processProperties(KrollDict props)
}
if (props.containsKey("foregroundColor")) {
likeView.setForegroundColor(TiColorHelper.parseColor(props.getString("foregroundColor")));
}
}
}

@Override
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy)
{
// This method is called whenever a proxy property value is updated. Note that this
// This method is called whenever a proxy property value is updated. Note that this
// method is only called if the new value is different than the current value.
if (key.equals("objectID")) {
likeView.setObjectIdAndType(TiConvert.toString(newValue),LikeView.ObjectType.PAGE);
likeView.setObjectIdAndType(TiConvert.toString(newValue), LikeView.ObjectType.PAGE);
} else if (key.equals("likeViewStyle")) {
setLikeViewStyle(TiConvert.toString(newValue));
} else if (key.equals("auxiliaryViewPosition")) {
Expand All @@ -116,7 +117,6 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
} else {
super.propertyChanged(key, oldValue, newValue, proxy);
}
Log.d(TAG,"[VIEW LIFECYCLE EVENT] propertyChanged: " + key + ' ' + oldValue + ' ' + newValue);
Log.d(TAG, "[VIEW LIFECYCLE EVENT] propertyChanged: " + key + ' ' + oldValue + ' ' + newValue);
}

}
Loading

0 comments on commit 88c755f

Please sign in to comment.