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

fix: firebase upload issue with AndroidManifest.xml #36

Merged
merged 17 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules

android/bin/
android/build/
android/dist/
ios/build/
ios/dist/

# These should eventually be linted as well
android/example/
ios/example/
16 changes: 16 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": [ "axway/env-titanium", "axway/env-node" ],
"parserOptions": {
"ecmaVersion": 2015,
"sourceType": "script"
},
"overrides": [
{
"files": [ "dangerfile.js" ],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
}
}
]
}
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ library 'pipeline-library'
def isMaster = env.BRANCH_NAME.equals('master')

buildModule {
sdkVersion = '9.0.0.v20200127103011' // TODO: Change to 9.0.0.GA once released
sdkVersion = '9.0.0.v20200205134519' // TODO: Change to 9.0.0.GA once released
npmPublish = isMaster
}
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
148 changes: 74 additions & 74 deletions android/Resources/ti.playservices/ti.playservices.js
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
const MAX_RETRY = 1;

function makeGooglePlayServicesAvailable (callback, _retry = 0) {
let result = {
success: false,
code: undefined,
message: undefined
};
let result = {
success: false,
code: undefined,
message: undefined
};

// Attempt to load ti.playservices module if available.
try {
const PlayServices = require('ti.playservices');
const playServicesResult = PlayServices.isGooglePlayServicesAvailable();
const playServicesVersion = PlayServices.GOOGLE_PLAY_SERVICES_VERSION_CODE;
// Attempt to load ti.playservices module if available.
try {
const PlayServices = require('ti.playservices');
const playServicesResult = PlayServices.isGooglePlayServicesAvailable();
const playServicesVersion = PlayServices.GOOGLE_PLAY_SERVICES_VERSION_CODE;

// Listener callback to determine when the user has returned to the app
function playServicesResume () {
Ti.App.removeEventListener('resume', playServicesResume);
makeGooglePlayServicesAvailable(callback, ++_retry);
};
// Listener callback to determine when the user has returned to the app
function playServicesResume () {
Ti.App.removeEventListener('resume', playServicesResume);
makeGooglePlayServicesAvailable(callback, ++_retry);
}

// Google Play Services is available.
result.code = playServicesResult;
if (playServicesResult === PlayServices.RESULT_SUCCESS) {
result.success = true;
result.message = `Google Play Services is available. (version: ${playServicesVersion})`;
} else {
result.success = false;
result.message = `Google Play Services is unavailable. (${PlayServices.getErrorString(playServicesResult)})`;
// Google Play Services is available.
result.code = playServicesResult;
if (playServicesResult === PlayServices.RESULT_SUCCESS) {
result.success = true;
result.message = `Google Play Services is available. (version: ${playServicesVersion})`;
} else {
result.success = false;
result.message = `Google Play Services is unavailable. (${PlayServices.getErrorString(playServicesResult)})`;

switch (playServicesResult) {
switch (playServicesResult) {

// Google Play Services is missing or outdated.
// Attempt to open Google Play store so user can install latest.
case PlayServices.RESULT_SERVICE_MISSING:
case PlayServices.RESULT_SERVICE_VERSION_UPDATE_REQUIRED:
case PlayServices.RESULT_SERVICE_UPDATING:
if (_retry < MAX_RETRY) {
const installPlayServicesIntent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
data: 'market://details?id=com.google.android.gms'
});
Ti.Android.currentActivity.startActivity(installPlayServicesIntent);

setTimeout(() => {
Ti.App.addEventListener('resume', playServicesResume);
}, 1000);
return;
}
break;

// Google Play Services has been disabled.
// Attempt to open Google Play Services app info so user can re-enable.
case PlayServices.RESULT_SERVICE_DISABLED:
if (_retry < MAX_RETRY) {
const detailPlayServicesIntent = Ti.Android.createIntent({
action: 'android.settings.APPLICATION_DETAILS_SETTINGS',
flags: Ti.Android.FLAG_ACTIVITY_NEW_TASK,
data: 'package:com.google.android.gms'
});
Ti.Android.currentActivity.startActivity(detailPlayServicesIntent);
// Google Play Services is missing or outdated.
// Attempt to open Google Play store so user can install latest.
case PlayServices.RESULT_SERVICE_MISSING:
case PlayServices.RESULT_SERVICE_VERSION_UPDATE_REQUIRED:
case PlayServices.RESULT_SERVICE_UPDATING:
if (_retry < MAX_RETRY) {
const installPlayServicesIntent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
data: 'market://details?id=com.google.android.gms'
});
Ti.Android.currentActivity.startActivity(installPlayServicesIntent);

setTimeout(() => {
Ti.App.addEventListener('resume', playServicesResume);
}, 1000);
return;
}
break;
setTimeout(() => {
Ti.App.addEventListener('resume', playServicesResume);
}, 1000);
return;
}
break;

// Google Play Services is invalid.
// This could be running on an unsupported device.
case PlayServices.RESULT_SERVICE_INVALID:
result.message += `\nThis could be an unsupported device.`;
break;
}
}
// Google Play Services has been disabled.
// Attempt to open Google Play Services app info so user can re-enable.
case PlayServices.RESULT_SERVICE_DISABLED:
if (_retry < MAX_RETRY) {
const detailPlayServicesIntent = Ti.Android.createIntent({
action: 'android.settings.APPLICATION_DETAILS_SETTINGS',
flags: Ti.Android.FLAG_ACTIVITY_NEW_TASK,
data: 'package:com.google.android.gms'
});
Ti.Android.currentActivity.startActivity(detailPlayServicesIntent);

// Google Play Services is not available...
} catch (e) {
result.success = false;
result.message = `Could not load 'ti.playservices' module.`;
}
setTimeout(() => {
Ti.App.addEventListener('resume', playServicesResume);
}, 1000);
return;
}
break;

Ti.API.info(`ti.playservices: ${result.message}`);
callback(result);
// Google Play Services is invalid.
// This could be running on an unsupported device.
case PlayServices.RESULT_SERVICE_INVALID:
result.message += '\nThis could be an unsupported device.';
break;
}
}

// Google Play Services is not available...
} catch (e) {
result.success = false;
result.message = 'Could not load \'ti.playservices\' module.';
}

Ti.API.info(`ti.playservices: ${result.message}`);
callback(result);
}

module.exports = {
makeGooglePlayServicesAvailable
makeGooglePlayServicesAvailable
};
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: 17.1.0
version: 17.1.1
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: Titanium Google Play Services module.
Expand Down
45 changes: 28 additions & 17 deletions android/src/ti/playservices/PlayServicesModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,59 @@
*/
package ti.playservices;

import org.appcelerator.kroll.annotations.Kroll;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiApplication;

import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.ConnectionResult;

@Kroll.module(name="PlayServices", id="ti.playservices")
@Kroll.module(name = "PlayServices", id = "ti.playservices")
public class PlayServicesModule extends KrollModule
{
private static final String TAG = "TiPlayServices";

private GoogleApiAvailability api;

@Kroll.constant public static final String GOOGLE_PLAY_SERVICES_PACKAGE = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE;
@Kroll.constant public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE;
@Kroll.constant
public static final String GOOGLE_PLAY_SERVICES_PACKAGE = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE;
@Kroll.constant
public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE;

@Kroll.constant public static final int RESULT_SUCCESS = ConnectionResult.SUCCESS;
@Kroll.constant public static final int RESULT_SERVICE_MISSING = ConnectionResult.SERVICE_MISSING;
@Kroll.constant public static final int RESULT_SERVICE_UPDATING = ConnectionResult.SERVICE_UPDATING;
@Kroll.constant public static final int RESULT_SERVICE_VERSION_UPDATE_REQUIRED = ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED;
@Kroll.constant public static final int RESULT_SERVICE_DISABLED = ConnectionResult.SERVICE_DISABLED;
@Kroll.constant public static final int RESULT_SERVICE_INVALID = ConnectionResult.SERVICE_INVALID;
@Kroll.constant
public static final int RESULT_SUCCESS = ConnectionResult.SUCCESS;
@Kroll.constant
public static final int RESULT_SERVICE_MISSING = ConnectionResult.SERVICE_MISSING;
@Kroll.constant
public static final int RESULT_SERVICE_UPDATING = ConnectionResult.SERVICE_UPDATING;
@Kroll.constant
public static final int RESULT_SERVICE_VERSION_UPDATE_REQUIRED = ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED;
@Kroll.constant
public static final int RESULT_SERVICE_DISABLED = ConnectionResult.SERVICE_DISABLED;
@Kroll.constant
public static final int RESULT_SERVICE_INVALID = ConnectionResult.SERVICE_INVALID;

public PlayServicesModule() {
public PlayServicesModule()
{
super();

this.api = GoogleApiAvailability.getInstance();
}

@Kroll.method
public int isGooglePlayServicesAvailable() {
public int isGooglePlayServicesAvailable()
{
return this.api.isGooglePlayServicesAvailable(TiApplication.getAppRootOrCurrentActivity());
}

@Kroll.method
public boolean isUserResolvableError(int code) {
public boolean isUserResolvableError(int code)
{
return this.api.isUserResolvableError(code);
}

@Kroll.method
public String getErrorString(int code) {
public String getErrorString(int code)
{
return this.api.getErrorString(code);
}

Expand Down
23 changes: 20 additions & 3 deletions apidoc/PlayServices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ description: |
methods:
- name: makeGooglePlayServicesAvailable
summary: Attempts to make Google Play services available on this device.
description: `callback` parameter is only available since 16.1.1.
description: The `callback` parameter is only available since 16.1.1.
since: "11.0.40"
parameters:
- name: callback
summary: Callback fired with the result determining Google Play Services availability.
type: Callback<Object>
type: Callback<Modules.PlayServices.AvailableCallbackObject>

- name: isGooglePlayServicesAvailable
summary: Verifies that Google Play services is installed and enabled on this device.
Expand All @@ -57,7 +57,7 @@ methods:
since: "11.0.40"
returns:
type: Number
constant: [Modules.PlayServices.RESULT_*]
constants: [Modules.PlayServices.RESULT_*]

- name: isUserResolvableError
summary: Checks to see if device is configured for Touch ID authentication.
Expand Down Expand Up @@ -113,3 +113,20 @@ properties:
type: Number
permission: read-only
since: "11.0.40"

---
name: Modules.PlayServices.AvailableCallbackObject
summary: Object passed to <Module.PlayServices.makeGooglePlayServicesAvailable> callback
properties:
- name: code
type: Number
summary: The result of detrmining whether the service is available
constants: Modules.PlayServices.RESULT_*

- name: success
type: Boolean
summary: whether the operation was successful

- name: message
type: String
summary: details on operation success or error
Loading