Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #25 from jasonelle/develop
Browse files Browse the repository at this point in the history
V2.1
  • Loading branch information
clsource authored Sep 16, 2021
2 parents 80da580 + b3cf3f5 commit fed9d0e
Show file tree
Hide file tree
Showing 20 changed files with 321 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Sentimental Versioning](http://sentimentalversioning.org/).

## [3.0.0] Next Release
## [2.1.0] Next Release

This version is the current in development. Will be released after the week of *6th November 2020*.
### Added

- Mixin POST [PR #21](https://github.com/jasonelle/jasonette-android/pull/21)

### Changed

- Normal Webview now is Advanced Webview (Enables file uploading) [PR #19](https://github.com/jasonelle/jasonette-android/pull/19)

### Fixed

- Fixed stack overflow error in $geo.get action [PR #20](https://github.com/jasonelle/jasonette-android/pull/20)

## [2.0.0](https://github.com/jasonelle/jasonelle/releases/tag/v2.0)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Releases are made in the [Jasonelle Repo](https://github.com/jasonelle/jasonelle

- [Jasonette v2.0.0](https://github.com/jasonelle/jasonelle/releases/tag/v2.0).

- Jasonette *v3.0.0* (In Progress).
- Jasonette *v2.1.0* (In Progress).

## [Contribution](CONTRIBUTING.md)

Expand Down
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ android {
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.jasonette"
minSdkVersion 21
targetSdkVersion 28
minSdkVersion 22
// Android 8 is the minimum required for the playstore
targetSdkVersion 26
versionCode 3
versionName "0.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
tools:replace="android:name"
android:theme="@style/AppTheme">
android:theme="@style/SplashTheme">
<activity android:name=".Core.JasonViewActivity" android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jasonette.seed">

<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="22" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
Expand All @@ -16,7 +10,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/SplashTheme">
<activity android:name=".Core.JasonViewActivity" android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -80,8 +74,8 @@
<!-- Uncomment below lines to enable $geo.get -->
<!--
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="22" />
-->

<!-- Uncomment below lines to enable $audio.record -->
Expand All @@ -93,5 +87,11 @@
<meta-data android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="barcode"/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- Uncomment for enabling media picker -->
<!--
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
-->

</manifest>
3 changes: 3 additions & 0 deletions app/src/main/assets/agent
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ $agent={
}
};

// Ensure $agent is present in the window global
window.$agent = $agent;

6 changes: 6 additions & 0 deletions app/src/main/assets/file/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
This file is loaded automatically on $webcontainer.
Use it to modify the website with javascript.
*/

console.log("file://custom.js loaded");
22 changes: 19 additions & 3 deletions app/src/main/java/com/jasonette/seed/Action/JasonGeoAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,32 @@ public void onProviderDisabled(String provider) {
&& ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 51);
} else {
getLocationManagerInfo(action, event, context);
//get the "options"->"distance" value. If not set, minDistance = 0
int distance = 0;
if (action.has("options")) {
JSONObject options = action.getJSONObject("options");
if(options.has("distance")) {
distance = Integer.parseInt(options.getString("distance"));
}
}
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, distance, locationListener, Looper.getMainLooper());
}
} else {
getLocationManagerInfo(action, event, context);
//get the "options"->"distance" value. If not set, minDistance = 0
int distance = 0;
if (action.has("options")) {
JSONObject options = action.getJSONObject("options");
if(options.has("distance")) {
distance = Integer.parseInt(options.getString("distance"));
}
}
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, distance, locationListener, Looper.getMainLooper());
}
} catch (SecurityException e){
JasonHelper.permission_exception("$geo.get", context);
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
}
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener, Looper.getMainLooper());
}
}

78 changes: 76 additions & 2 deletions app/src/main/java/com/jasonette/seed/Action/JasonMediaAction.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package com.jasonette.seed.Action;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.util.Base64;
import android.util.Log;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.commonsware.cwac.cam2.AbstractCameraActivity;
import com.commonsware.cwac.cam2.CameraActivity;
import com.commonsware.cwac.cam2.VideoRecorderActivity;
Expand Down Expand Up @@ -124,11 +132,76 @@ public void picker(final JSONObject action, JSONObject data, final JSONObject ev
}

}
public void camera(final JSONObject action, JSONObject data, final JSONObject event, final Context context) {

// Image picker intent
// Just ask the permissions
// $media.permissions
public void permissions(final JSONObject action, JSONObject data, final JSONObject event, final Context context) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {

if(action.has("options")) {
JSONObject options = action.getJSONObject("options");
String type = "all";
if (options.has("type")) {

type = options.getString("type");

if (type.equalsIgnoreCase("camera")) {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.CAMERA}, 100);
}

if (type.equalsIgnoreCase("files")) {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 101);
}

if (type.equalsIgnoreCase("all")) {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE}, 151);
}

} else {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE}, 251);
}
} else {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE}, 51);
}
}
}

// We need at least 100 ms to call the success with the result
// If not then it will be omitted since it will too fast
// for the system to process.
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
try {
JSONObject ret = new JSONObject();
ret.put("files", ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
ret.put("camera", ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED);
JasonHelper.next("success", action, ret, event, context);
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
}
}
}, 100); // Millisecond 1000 = 1 sec

} catch (SecurityException e){
JasonHelper.permission_exception("$media.permissions", context);
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
}
}

public void camera(final JSONObject action, JSONObject data, final JSONObject event, final Context context) {

try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.CAMERA}, 51);
}
}

AbstractCameraActivity.Quality q = AbstractCameraActivity.Quality.LOW;
String type = "photo";
Expand Down Expand Up @@ -203,6 +276,7 @@ public void camera(final JSONObject action, JSONObject data, final JSONObject ev
callback.put("class", "JasonMediaAction");
callback.put("method", "process");
JasonHelper.dispatchIntent(action, data, event, context, intent, callback);

} catch (SecurityException e){
JasonHelper.permission_exception("$media.camera", context);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ public void start(final JSONObject action, final JSONObject data, final JSONObje
Boolean repeats = options.has("repeats");
final int interval = (int)(Float.valueOf(options.getString("interval"))*1000);
final JSONObject timerAction = options.getJSONObject("action");

//if 'repeat' property exists, it will read the boolean value
//before this fix, the value 'repeat = false' would still trigger the repeat function

if(repeats) {
repeats = options.getBoolean("repeats");
}

//this is a new field implementation called 'skip'. It gives an alternate option to the repeating loop
//if false, or undefined, it will do nothing. But if set to 'true', it will trigger the interval, but will skip the first iteration
Boolean skipFirstInteraction = options.has("skip");

if(skipFirstInteraction) {
skipFirstInteraction = options.getBoolean("skip");
}


if(repeats) {
final Runnable runnableCode = new Runnable() {
Expand All @@ -54,7 +70,14 @@ public void run() {
handler.postDelayed(this, interval);
}
};
handler.post(runnableCode);

//if skip = true, it will delay the first iteration
if (skipFirstInteraction) {
handler.postDelayed(runnableCode, interval);
} else {
//skip = false or null/undefined
handler.post(runnableCode);
}

// Register timer
timers.put(name, runnableCode);
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/jasonette/seed/Action/JasonUtilAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,18 @@ public void run() {
final ArrayList<EditText> textFields = new ArrayList<EditText>();
if (action.has("options")) {
options = action.getJSONObject("options");
String title = options.get("title").toString();
String description = options.get("description").toString();

String title = "";
String description = "";

if (options.has("title")) {
title = options.get("title").toString();
}

if (options.has("description")) {
description = options.get("description").toString();
}

builder.setTitle(title);
builder.setMessage(description);

Expand Down
Loading

0 comments on commit fed9d0e

Please sign in to comment.