Skip to content

Commit

Permalink
Merge pull request #4 from maxcanna/muzei3
Browse files Browse the repository at this point in the history
Support Muzei API 3
  • Loading branch information
maxcanna authored Mar 20, 2021
2 parents a94f2e5 + e8d3827 commit 5179d69
Show file tree
Hide file tree
Showing 120 changed files with 159 additions and 400 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
- name: Set env vars
run: |
./gradlew getVersionNumber
echo VERSION_NUMBER=$(cat versionNumber) >> $GITHUB_ENV
echo APK_NAME=$(cat versionNumber | cut -c 1-5) >> $GITHUB_ENV
echo VERSION_NUMBER=$(cat MuzeiWebcam/versionNumber) >> $GITHUB_ENV
echo APK_NAME=$(cat MuzeiWebcam/versionNumber | cut -c 1-5) >> $GITHUB_ENV
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV
git log --reverse --no-merges --format='- %s' $(git log --merges --format='%H' -n 2)..HEAD -- >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
./gradlew getVersionNumber
git config --global user.email "[email protected]"
git config --global user.name "Massimiliano Cannarozzo"
git tag -a $(cat versionNumber) -m "$(cat versionNumber)"
git tag -a $(cat MuzeiWebcam/versionNumber) -m "$(cat MuzeiWebcam/versionNumber)"
git push "https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git" --tags
9 changes: 5 additions & 4 deletions MuzeiWebcam/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
apply plugin: 'com.android.application'

def versionMajor = 1
def versionMajor = 2
def versionMinor = 0
def versionPatch = 3
def versionPatch = 0
def versionBuild = 0

android {
compileSdkVersion 30
buildToolsVersion '29.0.3'

defaultConfig {
minSdkVersion 14
minSdkVersion 19
targetSdkVersion 30
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
Expand All @@ -22,6 +22,7 @@ task getVersionNumber{
}

dependencies {
implementation 'com.google.android.apps.muzei:muzei-api:1.0'
implementation 'com.google.android.apps.muzei:muzei-api:3.4.0'
implementation 'uk.co.chrisjenx:calligraphy:1.2.0'
implementation 'androidx.preference:preference:1.1.1'
}
Binary file removed MuzeiWebcam/libs/libGoogleAnalyticsV2.jar
Binary file not shown.
17 changes: 9 additions & 8 deletions MuzeiWebcam/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:name=".MuzeiWebcamApplication"
android:fullBackupContent="@xml/backup_descriptor"
android:theme="@style/MWTheme" >

<service
android:name="net.luxteam.muzeiwebcam.api.WebcamArtSource"
<provider
android:name="net.luxteam.muzeiwebcam.api.WebcamArtProvider"
android:authorities="net.luxteam.muzeiwebcam"
android:permission="com.google.android.apps.muzei.api.ACCESS_PROVIDER"
android:exported="true"
android:description="@string/source_description"
android:icon="@drawable/ic_source"
android:icon="@drawable/ic_launcher"
android:label="@string/source_name" >
<intent-filter>
<action android:name="com.google.android.apps.muzei.api.MuzeiArtSource" />
<action android:name="com.google.android.apps.muzei.api.MuzeiArtProvider" />
</intent-filter>

<meta-data
android:name="color"
android:value="@color/sourceColor" />
<meta-data
android:name="settingsActivity"
android:value="net.luxteam.muzeiwebcam.ui.activity.SettingsActivity" />
</service>
</provider>

<activity
android:name="net.luxteam.muzeiwebcam.ui.activity.SettingsActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package net.luxteam.muzeiwebcam.api;
//
// WebcamArtProvider
// Muzei Webcam
//
// Created by massimilianocannarozzo on 07/03/21.
// Copyright (c) 2021 Muzei Webcam. All rights reserved.
//

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;

import com.google.android.apps.muzei.api.provider.Artwork;
import com.google.android.apps.muzei.api.provider.MuzeiArtProvider;

import net.luxteam.muzeiwebcam.R;
import net.luxteam.muzeiwebcam.utils.Utils;

import org.jetbrains.annotations.NotNull;

import java.text.SimpleDateFormat;
import java.util.Date;

public class WebcamArtProvider extends MuzeiArtProvider {

@Override
public void onLoadRequested(boolean firstTime) {
final Date now = new Date();
final Artwork lastAddedArtwork = getLastAddedArtwork();

if (lastAddedArtwork != null && now.getTime() - lastAddedArtwork.getDateAdded().getTime() < 10000) {
return;
}

Context ctx = this.getContext();
String subtitle = SimpleDateFormat.getInstance().format(now);
String title = Utils.getStringValue(ctx, ctx.getString(R.string.preference_key_name));
String url = Utils.getStringValue(ctx, ctx.getString(R.string.preference_key_url));
String viewUrl = url;

if(TextUtils.isEmpty(title)){
title = ctx.getString(R.string.app_name);
}

if(TextUtils.isEmpty(url)){
url = ctx.getString(R.string.source_default_url);
viewUrl = ctx.getString(R.string.source_default_view_url);
subtitle = ctx.getString(R.string.source_default_subtitle);
}

final Artwork artwork = new Artwork.Builder()
.title(title)
.byline(subtitle)
.webUri(Uri.parse(viewUrl))
.persistentUri(Uri.parse(url))
.metadata(String.valueOf(now.getTime()))
.build();
setArtwork(artwork);
}

@NotNull
@Override
public String getDescription() {
final Context ctx = getContext();
String url = Utils.getStringValue(ctx, ctx.getString(R.string.preference_key_url));
return url == null
? ctx.getString(R.string.source_default_subtitle)
: null;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Copyright (c) 2014 Muzei Webcam. All rights reserved.
//

import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
Expand All @@ -22,7 +22,7 @@

import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

public class AboutActivity extends Activity {
public class AboutActivity extends AppCompatActivity {

@Override
protected void attachBaseContext(Context newBase) {
Expand All @@ -38,7 +38,6 @@ protected void onCreate(Bundle savedInstanceState) {
TextView mCreditsTextView = (TextView) findViewById(R.id.about_credits);
ImageView mTwitterImageView = (ImageView) findViewById(R.id.about_twitter);
ImageView mFacebookImageView = (ImageView) findViewById(R.id.about_facebook);
ImageView mGplusImageView = (ImageView) findViewById(R.id.about_gplus);
ImageView mGplayImageView = (ImageView) findViewById(R.id.about_gplay);
ImageView mGithubImageView = (ImageView) findViewById(R.id.about_github);

Expand All @@ -61,14 +60,6 @@ public void onClick(View view) {
}
});

mGplusImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_contacts_gplus)));
startActivity(browserIntent);
}
});

mGplayImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
// Copyright (c) 2014 Muzei Webcam. All rights reserved.
//

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import net.luxteam.muzeiwebcam.ui.fragment.MWPreferenceFragment;

import androidx.fragment.app.FragmentActivity;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

public class SettingsActivity extends Activity {
public class SettingsActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -31,7 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
f.setArguments(b);
}

getFragmentManager()
getSupportFragmentManager()
.beginTransaction()
.replace(android.R.id.content, f)
.commitAllowingStateLoss();
Expand All @@ -41,9 +41,4 @@ protected void onCreate(Bundle savedInstanceState) {
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(new CalligraphyContextWrapper(newBase));
}

@Override
protected void onPause() {
super.onPause();
}
}
Loading

0 comments on commit 5179d69

Please sign in to comment.