Skip to content
This repository has been archived by the owner on Dec 12, 2017. It is now read-only.

Commit

Permalink
Merge pull request #338 from kosssi/master
Browse files Browse the repository at this point in the history
Remove viewer on android < 5.0.0 🎁
  • Loading branch information
nono authored Nov 17, 2016
2 parents 73f6318 + 61109bc commit 41d13c6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="200002" android-versionName="2.0.2" id="io.cozy.files_client" ios-CFBundleIdentifier="io.cozy.mobile.sync" version="2.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-versionCode="200003" android-versionName="2.0.3" id="io.cozy.files_client" ios-CFBundleIdentifier="io.cozy.mobile.sync" version="2.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Cozy Mobile</name>
<description>Sync files from your cozycloud</description>
<author email="[email protected]" href="https://cozy.io">Cozy Cloud</author>
Expand Down
2 changes: 1 addition & 1 deletion src/app/lib/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ log = require("./persistent_log")
prefix: "Config"
date: true

APP_VERSION = "2.0.2"
APP_VERSION = "2.0.3"
DOC_ID = '_local/appconfig'
PERMISSIONS =
File: description: "files permission description"
Expand Down
2 changes: 1 addition & 1 deletion src/app/styles/base/_colors.styl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ red = #FF3713
green = #16D943

body
background-color white
background-color #32363F
color grey-08

.bg-cozy-color
Expand Down
7 changes: 4 additions & 3 deletions src/app/templates/file_viewer.jade
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@
a.collection-item.waves-effect.no-cache.actionDownload
i.icon.mdi.mdi-cloud-download
span= t('modal_action_file_download')
a.collection-item.waves-effect.cache.actionDisplay.in
i.icon.mdi.mdi-play-circle-outline
span= t('modal_action_file_display_in')
if isViewerCompatible
a.collection-item.waves-effect.cache.actionDisplay.in
i.icon.mdi.mdi-play-circle-outline
span= t('modal_action_file_display_in')
a.collection-item.waves-effect.cache.actionDisplay
i.icon.mdi.mdi-open-in-new
span= t('modal_action_file_display_out')
Expand Down
27 changes: 22 additions & 5 deletions src/app/views/file_viewer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ChangeFileHandler = require '../replicator/change/change_file_handler'
HeaderView = require './layout/header'
pathHelper = require '../lib/path'
mimetype = require '../lib/mimetype'
semver = require 'semver'


log = require('../lib/persistent_log')
Expand Down Expand Up @@ -40,6 +41,21 @@ module.exports = class FileViewer extends BaseView
files: @files
parentPath: @parentPath
folderName: @folderName
isViewerCompatible: @isViewerCompatible


setIsViewerCompatible: ->
if device.platform is "Android"
# device.version is not a semantic version:
# - Froyo OS would return "2.2"
# - Eclair OS would return "2.1", "2.0.1", or "2.0"
# - Version can also return update level "2.1-update1"
version = device.version.split('-')[0]
version += '.0' unless semver.valid version
if semver.valid(version) and semver.satisfies version, '<5.0.0'
return @isViewerCompatible = false

@isViewerCompatible = true


initialize: ->
Expand All @@ -49,6 +65,7 @@ module.exports = class FileViewer extends BaseView
@loading = true
@files = []
@config ?= app.init.config
@setIsViewerCompatible()

if @options.path isnt '/'
@parentPath = pathHelper.getDirName @options.path
Expand Down Expand Up @@ -97,7 +114,7 @@ module.exports = class FileViewer extends BaseView

cozyFileId = menu.data 'key'
if @fileCacheHandler.cache[cozyFileId]
return if menu.data 'is-compatible-viewer'
return if @isViewerCompatible and menu.data 'is-compatible-viewer'
event.preventDefault()
return @fileCacheHandler.open menu.data 'fullpath'

Expand All @@ -115,7 +132,7 @@ module.exports = class FileViewer extends BaseView
menu.find('.progress').hide()
progressDesign.css('width', '0%')
@render()
if menu.data 'is-compatible-viewer'
if @isViewerCompatible and menu.data 'is-compatible-viewer'
@router.navigate menu.attr('href'), trigger: true
else
@fileCacheHandler.open menu.data 'fullpath'
Expand Down Expand Up @@ -146,15 +163,15 @@ module.exports = class FileViewer extends BaseView
.modal('open')



actionOpen: (event) ->
isIn = $(event.currentTarget).hasClass 'in'
cozyFileId = @modal.data 'key'
@modal.modal 'close'
$elem = $('[data-key=' + cozyFileId + ']')
if $elem.data 'is-compatible-viewer'
if isIn and @isViewerCompatible and $elem.data 'is-compatible-viewer'
window.location = $('[data-key=' + cozyFileId + ']').attr 'href'
else
$elem.click()
@fileCacheHandler.open $elem.data 'fullpath'


actionRemove: (event) ->
Expand Down
2 changes: 2 additions & 0 deletions src/app/views/media_player.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = class MediaPlayerView extends BaseView
@fileName = pathHelper.getFileName @path
@layout = app.router.layout
@icon = mimetype.getIcon docType: 'file', mime: @mimetype
$('body').removeClass 'bg-cozy-color'


events: ->
Expand Down Expand Up @@ -79,4 +80,5 @@ module.exports = class MediaPlayerView extends BaseView

destroy: ->
StatusBar.backgroundColorByHexString "#33A6FF"
$('body').addClass 'bg-cozy-color'
super
8 changes: 4 additions & 4 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cozy-mobile",
"description": "This is the native mobile client for Cozy.",
"version": "2.0.2",
"version": "2.0.3",
"license": "LGPL-3.0",
"engines": {
"node": "~4.4.7"
Expand Down Expand Up @@ -30,9 +30,9 @@
"jquery": "1.9.1",
"material-design-icons": "3.0.1",
"materialize-css": "https://github.com/cozy/materialize.git",
"moment": "2.15.2",
"moment-timezone": "0.5.7",
"node-polyglot": "2.0.0",
"moment": "2.16.0",
"moment-timezone": "0.5.9",
"node-polyglot": "2.2.0",
"node-viewerjs": "https://github.com/cozy/ViewerJS.git",
"path-browser": "2.2.1",
"pouchdb": "6.0.7",
Expand Down

0 comments on commit 41d13c6

Please sign in to comment.