Skip to content

Commit

Permalink
v1.1 / Movie / Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
kurema committed Sep 24, 2021
1 parent 8a96bc5 commit 89c07fe
Show file tree
Hide file tree
Showing 29 changed files with 696 additions and 326 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,4 @@ MigrationBackup/
# Secrets
Secrets.cs
/Res/key/*
*.blend1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Android.App;
using Android.Appwidget;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EarphoneLeftAndRight.Droid
{
[BroadcastReceiver(Label = "Stereo Test Widget")]
[IntentFilter(new string[] { "android.appwidget.action.APPWIDGET_UPDATE" })]
[MetaData("android.appwidget.provider", Resource = "@xml/appwidget_provider")]
public class AppWidget : AppWidgetProvider
{
public const string ACTION_SELECTED = "com.github.kurema.earphoneleftandright.widget.ACTION_SELECTED";

public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{
var me = new ComponentName(context, Java.Lang.Class.FromType(typeof(AppWidget)).Name);

appWidgetManager.UpdateAppWidget(me, BuildRemoteViews(context, appWidgetIds));

//base.OnUpdate(context, appWidgetManager, appWidgetIds);
}

RemoteViews BuildRemoteViews(Context context, int[] appWidgetIds)
{
var widgetView = new RemoteViews(context.PackageName, Resource.Layout.app_widget);
var intent = new Intent(context, typeof(AppWidget));
intent.SetAction(ACTION_SELECTED);
var pi = PendingIntent.GetBroadcast(context, 0, intent, PendingIntentFlags.UpdateCurrent);
widgetView.SetOnClickPendingIntent(Resource.Id.imageView1, pi);
return widgetView;
}

public override async void OnReceive(Context context, Intent intent)
{
base.OnReceive(context, intent);

switch (intent.Action)
{
case ACTION_SELECTED:
Manager.Tts.StopIfSpeaking();

await Manager.Tts.SpeakLeft();
await Manager.Tts.SpeakRight();
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AdMobBannerRenderer.cs" />
<Compile Include="AppWidget.cs" />
<Compile Include="PlatformLocalizationDependency.cs" />
<Compile Include="Manager\Tts.cs" />
<Compile Include="PlayTileService.cs" />
Expand Down Expand Up @@ -487,5 +488,14 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable\outline_earbuds_20.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\xml\appwidget_provider.xml" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<AndroidResource Include="Resources\layout\app_widget.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.github.kurema.earphoneleftandright" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="1.1" package="com.github.kurema.earphoneleftandright" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
<application android:label="EarphoneLeftAndRight.Android" android:theme="@style/MainTheme" android:icon="@mipmap/icon">
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-2283413819561540~1209019860" />
Expand Down
Loading

0 comments on commit 89c07fe

Please sign in to comment.