Skip to content

Commit

Permalink
Merge pull request #542 from thornbill/eleven-four
Browse files Browse the repository at this point in the history
Release 0.11.4
  • Loading branch information
nielsvanvelzen authored Aug 11, 2020
2 parents f7dafcb + 178fe80 commit ab9dea6
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 52 deletions.
136 changes: 124 additions & 12 deletions .ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
variables:
- group: 'jellyfin'

trigger:
batch: true
branches:
include:
- master
Expand All @@ -12,15 +16,123 @@ pr:
include:
- '*'

pool:
vmImage: 'ubuntu-latest'

steps:
- task: Gradle@2
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'build'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
sonarQubeRunAnalysis: false
jobs:
- job: Test
displayName: 'Test'

pool:
vmImage: 'ubuntu-latest'

steps:
- task: Gradle@2
displayName: 'Run Tests'
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'test'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
sonarQubeRunAnalysis: false

- job: Build
displayName: 'Build'

pool:
vmImage: 'ubuntu-latest'

steps:
- task: Gradle@2
displayName: 'Build Debug'
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'assembleDebug'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
sonarQubeRunAnalysis: false

- task: Gradle@2
displayName: 'Build Release'
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'assembleRelease'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
sonarQubeRunAnalysis: false

- task: CopyFiles@2
displayName: 'Copy APKs'
inputs:
SourceFolder: 'app/build/outputs/apk/'
Contents: '**/*.apk'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true

- task: PublishBuildArtifacts@1
displayName: 'Publish APKs'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'jellyfin-androidtv'
publishLocation: 'Container'

- job: Publish
displayName: 'Publish'

dependsOn: Build
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')

pool:
vmImage: 'ubuntu-latest'

steps:
- script: 'echo "##vso[task.setvariable variable=TAG]$(git describe --tags)"'
displayName: 'Set Tag Variable'

- task: DownloadPipelineArtifact@2
displayName: 'Download APKs'
inputs:
source: 'current'
artifact: 'jellyfin-androidtv'
path: '$(System.ArtifactsDirectory)'
runVersion: 'latest'

- task: DownloadSecureFile@1
displayName: 'Download KeyStore'
name: 'KeyStore'
inputs:
secureFile: 'keystore'

- script: '$(find / -name apksigner -print -quit) sign --ks ${KEYSTORE_SECUREFILEPATH} --ks-pass pass:${PASSWORD} --out ${SYSTEM_ARTIFACTSDIRECTORY}/jellyfin-androidtv_release_${TAG}.apk ${SYSTEM_ARTIFACTSDIRECTORY}/jellyfin-androidtv_release-unsigned_${TAG}.apk'
displayName: 'Sign Release APK'
env:
PASSWORD: $(KeyStorePassword)

- task: DeleteFiles@1
displayName: 'Remove Unsigned APK'
inputs:
sourceFolder: '$(System.ArtifactsDirectory)'
contents: 'jellyfin-androidtv_release-unsigned_$(TAG).apk'

- task: GithubRelease@0
displayName: 'GitHub Upload'
inputs:
gitHubConnection: Jellyfin Release Download
repositoryName: jellyfin/jellyfin-androidtv
assets: '$(System.ArtifactsDirectory)/*.apk'
action: 'edit'
assetUploadMode: 'replace'
tag: '$(TAG)'

- task: CopyFilesOverSSH@0
inputs:
sshEndpoint: repository
sourceFolder: '$(System.ArtifactsDirectory)'
contents: '**'
targetFolder: '/srv/repository/releases/client/androidtv/versions/$(TAG)'

- task: SSH@0
inputs:
sshEndpoint: repository
runOptions: 'inline'
inline: 'cd /srv/repository/releases/client/androidtv && rm -rf *.apk && ln -s versions/$(TAG)/jellyfin-androidtv_*_$(TAG).apk .'
18 changes: 13 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
targetSdkVersion(29)

// Release version
versionCode = 908
versionName = "0.11.3"
versionCode = 909
versionName = "0.11.4"
}

compileOptions {
Expand All @@ -34,13 +34,21 @@ android {
applicationIdSuffix = ".debug"
}
}

applicationVariants.all {
val variant = this
variant.outputs.all {
val output = this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
output.outputFileName = output.outputFileName
.replace("app-", "jellyfin-androidtv_")
.replace(".apk", "_${variant.versionName}.apk")
}
}
}

dependencies {
// Jellyfin
val jellyfinApiclientVersion= "v0.6.0"
implementation("com.github.jellyfin.jellyfin-apiclient-java:android:$jellyfinApiclientVersion")
implementation("com.github.jellyfin.jellyfin-apiclient-java:library:$jellyfinApiclientVersion")
implementation("com.github.jellyfin.jellyfin-apiclient-java:android:v0.6.4")

// Kotlin
implementation(kotlin("stdlib-jdk8"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class ChannelManager {
item.canResume -> {
setWatchNextType(WatchNextPrograms.WATCH_NEXT_TYPE_CONTINUE)
setLastPlaybackPositionMillis((item.resumePositionTicks / TICKS_IN_MILLISECOND).toInt())
}
// Episode runtime has been determined
item.runTimeTicks != null -> {
setDurationMillis((item.runTimeTicks / TICKS_IN_MILLISECOND).toInt())
}
// First episode of the season
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void setPlaybackMethod(PlayMethod value) {
}

public BaseItemDto getCurrentlyPlayingItem() {
return mItems.get(mCurrentIndex);
return mItems.size() > mCurrentIndex ? mItems.get(mCurrentIndex) : null;
}
public MediaSourceInfo getCurrentMediaSource() { return mCurrentStreamInfo != null && mCurrentStreamInfo.getMediaSource() != null ? mCurrentStreamInfo.getMediaSource() : getCurrentlyPlayingItem().getMediaSources().get(0);}
public StreamInfo getCurrentStreamInfo() { return mCurrentStreamInfo; }
Expand Down Expand Up @@ -998,13 +998,24 @@ private void startPauseReportLoop() {
mReportLoop = new Runnable() {
@Override
public void run() {
BaseItemDto currentItem = getCurrentlyPlayingItem();
if (currentItem == null) {
// Loop was called while nothing was playing!
stopReportLoop();
return;
}

if (mPlaybackState != PlaybackState.PLAYING) {
// Playback was stopped, don't report progress anymore
return;
}

long currentTime = isLiveTv ? getTimeShiftedProgress() : mVideoManager.getCurrentPosition();
if (isLiveTv && !directStreamLiveTv) {
mFragment.setSecondaryTime(getRealTimeProgress());
}

ReportingHelper.reportProgress(getCurrentlyPlayingItem(), getCurrentStreamInfo(), currentTime * 10000, true);
ReportingHelper.reportProgress(currentItem, getCurrentStreamInfo(), currentTime * 10000, true);
mHandler.postDelayed(this, PROGRESS_REPORTING_PAUSE_INTERVAL);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static DeviceProfile getBaseProfile(boolean isLiveTv) {

profile.setName("Android");
profile.setMaxStreamingBitrate(20000000);
profile.setMaxStaticBitrate(30000000);
profile.setMaxStaticBitrate(100000000);

List<TranscodingProfile> transcodingProfiles = new ArrayList<>();

Expand Down
46 changes: 18 additions & 28 deletions app/src/main/java/org/jellyfin/androidtv/util/TimeUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jellyfin.androidtv.util;

import android.annotation.SuppressLint;
import android.text.format.DateFormat;

import org.jellyfin.androidtv.R;
Expand All @@ -9,14 +10,18 @@
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;

public class TimeUtils {
private static final int MILLIS_PER_SEC = 1000;
private static final int MILLIS_PER_MIN = 60 * MILLIS_PER_SEC;
private static final int MILLIS_PER_HR = 60 * MILLIS_PER_MIN;
private static final long MILLIS_PER_MIN = TimeUnit.MINUTES.toMillis(1);
private static final long MILLIS_PER_HR = TimeUnit.HOURS.toMillis(1);

private static final int SECS_PER_MIN = 60;
private static final int SECS_PER_HR = 60 * SECS_PER_MIN;
private static final long SECS_PER_HR = TimeUnit.HOURS.toSeconds(1);

private static final String DURATION_TIME_FORMAT_NO_HOURS = "%d:%02d";
private static final String DURATION_TIME_FORMAT_WITH_HOURS = "%d:%02d:%02d";

public static long secondsToMillis(double seconds) {
return Math.round(seconds * MILLIS_PER_SEC);
Expand All @@ -33,37 +38,22 @@ public static long hoursToMillis(double hours) {
/**
* Formats time in milliseconds to hh:mm:ss string format.
*
* @param millis
* @return
* @param millis Time in milliseconds
* @return Formatted time
*/
@SuppressLint("DefaultLocale")
public static String formatMillis(long millis) {
long hr = millis / MILLIS_PER_HR;
long hr = TimeUnit.MILLISECONDS.toHours(millis);
millis %= MILLIS_PER_HR;
long min = millis / MILLIS_PER_MIN;
long min = TimeUnit.MILLISECONDS.toMinutes(millis);
millis %= MILLIS_PER_MIN;
long sec = millis / MILLIS_PER_SEC;
long sec = TimeUnit.MILLISECONDS.toSeconds(millis);

StringBuilder builder = new StringBuilder();
// Hours
if (hr > 0) {
builder.append(hr)
.append(":");
}
// Minutes
if (min >= 0) {
if (min < 9 && hr > 0) {
builder.append("0");
}
builder.append(min)
.append(":");
}
// Seconds
if (sec < 10) {
builder.append("0");
if(hr > 0) {
return String.format(DURATION_TIME_FORMAT_WITH_HOURS, hr, min, sec);
} else {
return String.format(DURATION_TIME_FORMAT_NO_HOURS, min, sec);
}
builder.append(sec);

return builder.toString();
}

public static String formatSeconds(int seconds) {
Expand Down
14 changes: 12 additions & 2 deletions app/src/test/java/org/jellyfin/androidtv/util/TimeUtilsTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.jellyfin.androidtv.util;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class TimeUtilsTest {

@Test
Expand All @@ -28,9 +29,18 @@ public void hoursToMillis() {

@Test
public void formatMillis() {
assertEquals("0:00", TimeUtils.formatMillis(0));
assertEquals("0:13", TimeUtils.formatMillis(13000));
assertEquals("5:00", TimeUtils.formatMillis(300000));
assertEquals("9:01", TimeUtils.formatMillis(541000));
assertEquals("9:59", TimeUtils.formatMillis(599000));
assertEquals("26:00", TimeUtils.formatMillis(1560000));
assertEquals("26:01", TimeUtils.formatMillis(1561000));
assertEquals("26:43", TimeUtils.formatMillis(1603000));
assertEquals("1:00:00", TimeUtils.formatMillis(3600000));
assertEquals("1:01:01", TimeUtils.formatMillis(3661000));
assertEquals("1:09:15", TimeUtils.formatMillis(4155000));
assertEquals("1:16:03", TimeUtils.formatMillis(4563489));
assertEquals("12:00:00", TimeUtils.formatMillis(43200000));
}
}
}
2 changes: 1 addition & 1 deletion docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ bash gradlew ${RFLAG}

# Move the artifacts out
mkdir -p ${ARTIFACT_DIR}/apk
mmv "${SOURCE_DIR}/app/build/outputs/apk/*/app-*.apk" "${ARTIFACT_DIR}/apk/jellyfin-androidtv_#2.apk"
mmv "${SOURCE_DIR}/app/build/outputs/apk/*/jellyfin-androidtv_*.apk" "${ARTIFACT_DIR}/apk/"
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ val apiclientLocation = "../jellyfin-apiclient-java"
if (File(apiclientLocation).exists() && enableDependencySubstitution) {
includeBuild(apiclientLocation) {
dependencySubstitution {
substitute(module("com.github.jellyfin.jellyfin-apiclient-java:library")).with(project(":library"))
substitute(module("com.github.jellyfin.jellyfin-apiclient-java:android")).with(project(":android"))
}
}
}

0 comments on commit ab9dea6

Please sign in to comment.