Skip to content

Commit

Permalink
Ready for v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SydneyOwl committed Sep 15, 2024
1 parent 0a2e3a0 commit 99e5b9f
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 22 deletions.
14 changes: 7 additions & 7 deletions Activities/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ protected override void OnCreate(Bundle savedInstanceState)
// Set our view from the "main" layout resource

// 权限检查
RequestPermissions(new[] { Manifest.Permission.Vibrate, Manifest.Permission.PostNotifications }, 645);

if (CheckSelfPermission(Manifest.Permission.Vibrate) != Permission.Granted)
Toast.MakeText(this, ResourceConstant.String.denied_vibrate, ToastLength.Short);

if (CheckSelfPermission(Manifest.Permission.PostNotifications) != Permission.Granted)
Toast.MakeText(this, ResourceConstant.String.denied_notification, ToastLength.Short);
// RequestPermissions(new[] { Manifest.Permission.Vibrate, Manifest.Permission.PostNotifications }, 645);
//
// if (CheckSelfPermission(Manifest.Permission.Vibrate) != Permission.Granted)
// Toast.MakeText(this, ResourceConstant.String.denied_vibrate, ToastLength.Short);
//
// if (CheckSelfPermission(Manifest.Permission.PostNotifications) != Permission.Granted)
// Toast.MakeText(this, ResourceConstant.String.denied_notification, ToastLength.Short);

_txmsg = FindViewById<TextView>(ResourceConstant.Id.transmittingMessageTextView);
_txLayout = FindViewById<RelativeLayout>(ResourceConstant.Id.transmittingLayout);
Expand Down
2 changes: 1 addition & 1 deletion Activities/SettingsActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected override void OnCreate(Bundle? savedInstanceState)
}

_addWhiteListButton = FindViewById<Button>(ResourceConstant.Id.add_background);
_addWhiteListButton.SetOnClickListener(new OnAddBackgroundListener());
_addWhiteListButton.SetOnClickListener(new OnAddBackgroundListener(this));

_jumpToDxccButton = FindViewById<Button>(ResourceConstant.Id.set_dxcc);
_jumpToDxccButton.SetOnClickListener(new OnJumpDxccListener(this));
Expand Down
24 changes: 15 additions & 9 deletions Behaviors/Watchers/OnAddBackgroundListener.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Android.Views;
using Android.Content;
using Android.Views;
using WsjtxWatcher.Utils.Brand;
using Object = Java.Lang.Object;

Expand All @@ -8,18 +9,23 @@ namespace WsjtxWatcher.Behaviors.Watchers;

public class OnAddBackgroundListener : Object, View.IOnClickListener
{
private Context ctx;
public OnAddBackgroundListener(Context ctx)
{
this.ctx = ctx;
}
public void OnClick(View? v)
{
try
{
if (ChkBrand.IsHuawei()) ChkBrand.GoHuaweiSetting(v.Context);
else if (ChkBrand.IsMeizu()) ChkBrand.GoMeizuSetting(v.Context);
else if (ChkBrand.IsSamsung()) ChkBrand.GoSamsungSetting(v.Context);
else if (ChkBrand.IsSmartisan()) ChkBrand.GoSmartisanSetting(v.Context);
else if (ChkBrand.IsXiaomi()) ChkBrand.GoXiaomiSetting(v.Context);
else if (ChkBrand.IsLeTv()) ChkBrand.GoLetvSetting(v.Context);
else if (ChkBrand.IsOppo()) ChkBrand.GoOppoSetting(v.Context);
else if (ChkBrand.IsVivo()) ChkBrand.GoVivoSetting(v.Context);
if (ChkBrand.IsHuawei()) ChkBrand.GoHuaweiSetting(ctx);
else if (ChkBrand.IsMeizu()) ChkBrand.GoMeizuSetting(ctx);
else if (ChkBrand.IsSamsung()) ChkBrand.GoSamsungSetting(ctx);
else if (ChkBrand.IsSmartisan()) ChkBrand.GoSmartisanSetting(ctx);
else if (ChkBrand.IsXiaomi()) ChkBrand.GoXiaomiSetting(ctx);
else if (ChkBrand.IsLeTv()) ChkBrand.GoLetvSetting(ctx);
else if (ChkBrand.IsOppo()) ChkBrand.GoOppoSetting(ctx);
else if (ChkBrand.IsVivo()) ChkBrand.GoVivoSetting(ctx);
}
catch
{
Expand Down
28 changes: 27 additions & 1 deletion Behaviors/Watchers/OnCheckedChanged.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using _Microsoft.Android.Resource.Designer;
using Android;
using Android.Content;
using Android.Content.PM;
using WsjtxWatcher.Variables;

namespace WsjtxWatcher.Behaviors.Watchers;
Expand All @@ -23,7 +25,11 @@ public void SendNotificationCheckboxChanged(object? o, CompoundButton.CheckedCha
edit.PutBoolean("send_notification_on_call", args.IsChecked);
edit.Apply();

NotificationManager.FromContext(_ctx).AreNotificationsEnabled();
if (_ctx.CheckSelfPermission(Manifest.Permission.PostNotifications) != Permission.Granted)
{
((Activity)_ctx).RequestPermissions(new[] {Manifest.Permission.PostNotifications }, 645);
}
// Toast.MakeText(this, ResourceConstant.String.denied_vibrate, ToastLength.Short);
}

public void VibrateCheckboxChanged(object? o, CompoundButton.CheckedChangeEventArgs args)
Expand All @@ -35,6 +41,10 @@ public void VibrateCheckboxChanged(object? o, CompoundButton.CheckedChangeEventA
var edit = sharedPref.Edit();
edit.PutBoolean("vibrate_on_call", args.IsChecked);
edit.Apply();
if (_ctx.CheckSelfPermission(Manifest.Permission.Vibrate) != Permission.Granted)
{
((Activity)_ctx).RequestPermissions(new[] {Manifest.Permission.Vibrate }, 645);
}
}

public void SendNotificationAllCheckboxChanged(object? o, CompoundButton.CheckedChangeEventArgs args)
Expand All @@ -46,6 +56,10 @@ public void SendNotificationAllCheckboxChanged(object? o, CompoundButton.Checked
var edit = sharedPref.Edit();
edit.PutBoolean("send_notification_on_all", args.IsChecked);
edit.Apply();
if (_ctx.CheckSelfPermission(Manifest.Permission.PostNotifications) != Permission.Granted)
{
((Activity)_ctx).RequestPermissions(new[] {Manifest.Permission.PostNotifications }, 645);
}
}

public void VibrateAllCheckboxChanged(object? o, CompoundButton.CheckedChangeEventArgs args)
Expand All @@ -57,6 +71,10 @@ public void VibrateAllCheckboxChanged(object? o, CompoundButton.CheckedChangeEve
var edit = sharedPref.Edit();
edit.PutBoolean("vibrate_on_all", args.IsChecked);
edit.Apply();
if (_ctx.CheckSelfPermission(Manifest.Permission.Vibrate) != Permission.Granted)
{
((Activity)_ctx).RequestPermissions(new[] {Manifest.Permission.Vibrate }, 645);
}
}

public void SendNotificationDxccCheckboxChanged(object? o, CompoundButton.CheckedChangeEventArgs args)
Expand All @@ -68,6 +86,10 @@ public void SendNotificationDxccCheckboxChanged(object? o, CompoundButton.Checke
var edit = sharedPref.Edit();
edit.PutBoolean("send_notification_on_dxcc", args.IsChecked);
edit.Apply();
if (_ctx.CheckSelfPermission(Manifest.Permission.PostNotifications) != Permission.Granted)
{
((Activity)_ctx).RequestPermissions(new[] {Manifest.Permission.PostNotifications }, 645);
}
}

public void VibrateDxccCheckboxChanged(object? o, CompoundButton.CheckedChangeEventArgs args)
Expand All @@ -79,5 +101,9 @@ public void VibrateDxccCheckboxChanged(object? o, CompoundButton.CheckedChangeEv
var edit = sharedPref.Edit();
edit.PutBoolean("vibrate_on_dxcc", args.IsChecked);
edit.Apply();
if (_ctx.CheckSelfPermission(Manifest.Permission.Vibrate) != Permission.Granted)
{
((Activity)_ctx).RequestPermissions(new[] {Manifest.Permission.Vibrate }, 645);
}
}
}
1 change: 0 additions & 1 deletion Resources/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@
android:text="@string/add_to_background"
android:id="@+id/add_background"
android:layout_below="@id/explain_background"/>

</RelativeLayout>
</RelativeLayout>
</ScrollView>
2 changes: 1 addition & 1 deletion Resources/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<string name="white_list">2. 将应用加入电池优化白名单: 系统为省电,可能会误杀后台UDP服务器,造成无法正常接收信息。
</string>
<string name="add_to_whitelist">加入白名单</string>
<string name="background">3.后台运行权限:如未开启后台运行权限,可能将导致软件进入后台时收到信息无法及时推送</string>
<string name="background">3.后台运行权限:如未开启后台运行权限,可能将导致软件进入后台时收到信息无法及时推送</string>
<string name="add_to_background">后台运行权限</string>
<string name="service_running">服务运行中</string>
<string name="listening_msg">正在监听FT8信息,点击退出...</string>
Expand Down
12 changes: 12 additions & 0 deletions Utils/Brand/ChkBrand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ public static void GoHuaweiSetting(Context ctx)
ShowActivity(ctx, "com.huawei.systemmanager",
"com.huawei.systemmanager.optimize.bootstart.BootStartActivity");
}
finally
{
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
builder.SetTitle("注意");
builder.SetMessage(@"如果未能弹出相应设置窗口,请您参考以下步骤更改白名单设置(以HarmonyOS为例,其他手机型号大同小异,可作参考):
1、在手机自带的设置里,打开【应用与服务】,选定【应用管理】。
2、在列表里翻找出自己想要保持在后台运行的APP,或在搜索框里搜索Wsjtx,进入应用的“应用信息”界面。
3、进入【耗电详情】,点击【启动管理】,关闭【自动管理】,并且打开手动管理的【允许后台活动】选项。");
builder.SetNeutralButton("确定",((sender, args) => {}));
AlertDialog alertDialog = builder.Create();//这个方法可以返回一个alertDialog对象
alertDialog.Show();
}
}

public static bool IsXiaomi()
Expand Down
1 change: 0 additions & 1 deletion Utils/DeviceActions/Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void PopCommonNotification(string msg)
new Notification.Builder(_ctx, _ctx.GetString(ResourceConstant.String.notification_channel_id1))
.SetContentTitle(_ctx.GetString(ResourceConstant.String.user_ft8_msg_available))
.SetContentText(msg)
.SetWhen(DateAndTime.Now.Millisecond)
.SetSmallIcon(ResourceConstant.Mipmap.appicon)
.SetAutoCancel(true)
.Build();
Expand Down
14 changes: 13 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

## 简介

本软件利用`Wsjtx`(或`JTDX`,以下均称`wsjtx`)内置的UDP服务器功能,实现了与wsjtx的数据交互,用户可在软件中查看实时的ft8信息,并可进行取消发送、设置提醒等操作,也可指定需要发送通知进行提醒的场景,尤其适合VHF DX。目前支持简体中文和英语两种语言。
本软件利用`Wsjtx`(或`JTDX`,以下均称`wsjtx`)内置的UDP服务器功能,实现了与wsjtx的数据交互,用户可在软件中查看实时的ft8信息,并可进行取消发送、设置提醒等操作(**部分功能在低版本jtdx上不可用!**),也可指定需要发送通知进行提醒的场景,尤其适合VHF DX。

当软件处于前台运行时,您可以实时查看收到的FT8信息;当软件进入后台,或手机锁屏时,软件将根据您的设置,在收到指定FT8信息时向您推送。

目前支持简体中文和英语两种语言。

<img src="./md_assets/page6.png" style="zoom: 67%;" />

Expand All @@ -16,6 +20,8 @@

## 使用方法

**注意:使用前,如果您的手机开启了省电模式,请务必关闭,否则将造成频繁断联!!**

1. 点击右上角菜单,选择进入设置页面,在设置页面中填写呼号以及梅登海格坐标,并按需修改其他设置。请记下设置页中展示的ip地址和端口号。

2. 回到主界面后,再次点击右上角菜单,点击“开启服务”。
Expand All @@ -38,6 +44,12 @@
+ [ft8cn](https://github.com/N0BOY/FT8CN)项目,借鉴了一些界面的配置以及一些工具类,也从其中学到了不少开发知识,感谢!
+ [WsjtxUtils](https://github.com/KC3PIB/WsjtxUtils),也是我没有选择用java开发的原因,因为没有合适的wsjtx解码库!

## 版本日志

`v0.0.1` Demo版本的WsjtxWatcher

`v0.1.0` 加入呼号搜索、自定义DXCC以及其他功能,修正了一堆bug,优化数据库结构以及读写速度。

## 许可证

本项目使用`The Unlicense`进行许可。
Expand Down

0 comments on commit 99e5b9f

Please sign in to comment.