Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions push/src/main/java/com/xiaomi/push/sdk/MyPushMessageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.P;

import android.app.ActivityOptions;
import android.app.IntentService;
import android.content.ComponentName;
import android.content.Context;
Expand Down Expand Up @@ -226,8 +227,12 @@ private static long pullUpApp(Context context, String targetPackage, XmPushActio
throw new RuntimeException("can not get default activity for " + targetPackage);
} else {
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

context.startActivity(intent);
ActivityOptions activityOptions = ActivityOptions.makeBasic();
Bundle startBundle = activityOptions.toBundle();
if (ConfigCenter.getInstance().isViaFreeform(context)) {
startBundle.putInt("android.activity.windowingMode", 5);
}
context.startActivity(intent, startBundle);
logger.d(packageInfo(targetPackage, "start activity"));
}

Expand All @@ -244,7 +249,12 @@ private static long pullUpApp(Context context, String targetPackage, XmPushActio
if (i == (APP_CHECK_FRONT_MAX_RETRY / 2)) {
intent = getJumpIntentFromPkg(context, targetPackage);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(intent);
ActivityOptions activityOptions = ActivityOptions.makeBasic();
Bundle startBundle = activityOptions.toBundle();
if (ConfigCenter.getInstance().isViaFreeform(context)) {
startBundle.putInt("android.activity.windowingMode", 5);
}
context.startActivity(intent, startBundle);
}
}

Expand Down
6 changes: 5 additions & 1 deletion push/src/main/java/com/xiaomi/xmsf/utils/ConfigCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public ConfigCenter() {
public static SharedPreferences getSharedPreferences(Context context) {
return context.getSharedPreferences(BuildConfig.APPLICATION_ID + "_preferences", Context.MODE_MULTI_PROCESS);
}


public boolean isViaFreeform(Context ctx) {
return getSharedPreferences(ctx).getBoolean("ViaFreeform", false);
}

public boolean isNotificationOnRegister(Context ctx) {
return getSharedPreferences(ctx).getBoolean("NotificationOnRegister", false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ private fun ExperimentalBlock() {
iceBoxGranted = !iceBoxGranted
setIceBoxSupported(context, iceBoxGranted)
}

SettingsItem(
title = stringResource(R.string.settings_via_freeform),
summary = stringResource(R.string.settings_via_freeform_summary),
key = "ViaFreeform",
defaultValue = false,
)
}
}

Expand Down
6 changes: 5 additions & 1 deletion push/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@
<string name="settings_icebox_permission_summary">点击通知栏时自动解冻冻结的App。
需要安装的冰箱版本号 >= 3.6.0
</string>


<string name="settings_via_freeform">以自由形式 (小窗) 打开通知</string>
<string name="settings_via_freeform_summary">暂时只支持系统级小窗( AOSP原生、桌面模式、Sun OS或Rising OS) 米窗及其 forks 由于是以广播形式打开,暂不支持
</string>


<string name="icebox_permission_granted">已赋权冰箱自动解冻</string>
<string name="icebox_permission_not_granted">未赋权冰箱自动解冻</string>
Expand Down
86 changes: 63 additions & 23 deletions push/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<string name="deny">Reject</string>

<!-- Log -->
<!-- TOOD: See the "wake-up intercep-tion" shown, why?-->
<!-- TOOD: See the "wake-up intercep-tion" shown, why? -->
<string name="log_push_err">Push service failed. Please try to disable the wake-up interception for the manager application, turn off some optimization feature of ROMs.</string>
<string name="log_none">No logs yet.</string>
<string name="log_share_error">Cannot share logs:%1$s</string>
Expand Down Expand Up @@ -71,10 +71,14 @@
<string name="settings_icebox_not_installed">IceBox not installed</string>
<string name="settings_icebox_permission">Auto enable app by IceBox</string>
<string name="settings_icebox_permission_summary">Auto enable app by IceBox SDK.
require IceBox( version > 3.6.0) installed </string>
require IceBox( version > 3.6.0) installed</string>
<string name="icebox_permission_granted">IceBox permission granted</string>
<string name="icebox_permission_not_granted">IceBox permission not granted</string>

<string name="settings_via_freeform">Open Notifications via Freeform</string>
<string name="settings_via_freeform_summary">Only support framework freeform (like AOSP original Freeform, AOSP desktop mode, Sun OS, Rising OS etc. ).
MiFreeform with its forks won\'t work due to it\'s board cast mode.
</string>

<string name="settings_mock_notification">Simulate received a message</string>
<string name="settings_mock_notification_summary">Tap to send a simulated test message.</string>
Expand All @@ -90,7 +94,6 @@
<string name="settings_start_foreground_service_summary">show a foreground notification to keep alive, you can hide it by disable notification channel</string>



<string name="app_name">MiPush Framework</string>

<string name="enable">Enable</string>
Expand All @@ -110,18 +113,24 @@
<string name="action_about">About</string>

<!-- Wizard -->
<string name="wizard_descr"><![CDATA[This project allows any devices to use XiaoMi system-level Push, it can control notifications from other apps to save more battery. For more details, visit the GitHub project:<a href="https://github.com/MiPushFramework/MiPushFramework">MiPushFramework</a>]]></string>
<string name="wizard_descr">
<![CDATA[This project allows any devices to use XiaoMi system-level Push, it can control notifications from other apps to save more battery. For more details, visit the GitHub project:<a href="https://github.com/MiPushFramework/MiPushFramework">MiPushFramework</a>]]>
</string>

<string name="wizard_connect">Connecting</string>

<string name="wizard_title_run_in_background">Allow running in background</string>
<string name="wizard_descr_run_in_background">You have disabled the Push service to run in the background, it will not be able to push in the background, you %1$s, then tap Next button.</string>

<string name="run_in_background_appops_root">Need to use Root access to solve. (we will handle it automatically)</string>
<string name="run_in_background_rikka_appops"><![CDATA[ need to open <b>App Ops</b> tool, and grant the <b>Run in the background or wake up</b> permissions ]]></string>
<string name="rikka_appops_help_toast"><![CDATA[
<string name="run_in_background_rikka_appops">
<![CDATA[ need to open <b>App Ops</b> tool, and grant the <b>Run in the background or wake up</b> permissions ]]>
</string>
<string name="rikka_appops_help_toast">
<![CDATA[
Please grant the <b>Run in the background or wake up</b> permissions.
]]></string>
]]>
</string>

<string name="wizard_title_stats_permission">Usage stats</string>
<string name="wizard_title_stats_permission_text">You need to grant \"Usage stats\" permission or you will not be able to receive notifications.</string>
Expand Down Expand Up @@ -234,12 +243,32 @@ Please grant the <b>Run in the background or wake up</b> permissions.

<string name="status_app_not_registered">not registered</string>
<string name="footer_app_ignored_not_registered">%1$s apps without MiPush SDK</string>
<string name="status_app_not_registered_detail_without_fake_suggest"><![CDATA[
Registration is determined and initiated by the application and generally begins automatically when the application is launched. Some apps are only registered when finding a XiaoMi devices. See also: <b><a href="https://github.com/MiPushFramework/MiPushFramework/wiki/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BC%8F%E6%B3%A8%E5%86%8C%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88">应用程式注册问题解决方案</a></b> and <b><a href="https://github.com/MiPushFramework/MiPushFramework/wiki/%5B%E5%B8%AE%E5%8A%A9%5D-%E5%BA%94%E7%94%A8%E6%B3%A8%E5%86%8C%E9%97%AE%E9%A2%98">[帮助] 应用注册问题</a></b>.
]]></string>
<string name="status_app_not_registered_detail_with_fake_suggest"><![CDATA[
Registration is determined and initiated by the application and generally begins automatically when the application is launched. Some apps are only registered when finding a XiaoMi devices, you can try <b><a href="https://github.com/Magisk-Modules-Repo/MiPushFake">Magisk global-level module</a></b> or <b><a href="https://github.com/TimothyZhang023/Riru-MiPushFake">Magisk apps-level module</a></b> to increase success. See also: <b><a href="https://github.com/MiPushFramework/MiPushFramework/wiki/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BC%8F%E6%B3%A8%E5%86%8C%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88">应用程式注册问题解决方案</a></b> and <b><a href="https://github.com/MiPushFramework/MiPushFramework/wiki/%5B%E5%B8%AE%E5%8A%A9%5D-%E5%BA%94%E7%94%A8%E6%B3%A8%E5%86%8C%E9%97%AE%E9%A2%98">[帮助] 应用注册问题</a></b>.
]]></string>
<string name="status_app_not_registered_detail_without_fake_suggest">
<![CDATA[
Registration is determined and initiated by the application and generally begins automatically when the application is launched. Some apps are only registered when finding a XiaoMi devices. See also: <b>
<a
href="https://github.com/MiPushFramework/MiPushFramework/wiki/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BC%8F%E6%B3%A8%E5%86%8C%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88">应用程式注册问题解决方案</a>
</b> and <b>
<a
href="https://github.com/MiPushFramework/MiPushFramework/wiki/%5B%E5%B8%AE%E5%8A%A9%5D-%E5%BA%94%E7%94%A8%E6%B3%A8%E5%86%8C%E9%97%AE%E9%A2%98">[帮助] 应用注册问题</a>
</b>.
]]>
</string>
<string name="status_app_not_registered_detail_with_fake_suggest">
<![CDATA[
Registration is determined and initiated by the application and generally begins automatically when the application is launched. Some apps are only registered when finding a XiaoMi devices, you can try <b>
<a href="https://github.com/Magisk-Modules-Repo/MiPushFake">Magisk global-level module</a>
</b> or <b>
<a href="https://github.com/TimothyZhang023/Riru-MiPushFake">Magisk apps-level module</a>
</b> to increase success. See also: <b>
<a
href="https://github.com/MiPushFramework/MiPushFramework/wiki/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BC%8F%E6%B3%A8%E5%86%8C%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88">应用程式注册问题解决方案</a>
</b> and <b>
<a
href="https://github.com/MiPushFramework/MiPushFramework/wiki/%5B%E5%B8%AE%E5%8A%A9%5D-%E5%BA%94%E7%94%A8%E6%B3%A8%E5%86%8C%E9%97%AE%E9%A2%98">[帮助] 应用注册问题</a>
</b>.
]]>
</string>
<string name="status_app_not_registered_title">Unregistered</string>

<string name="group_notifications_for_same_session_title">Group all notifications for the same session</string>
Expand All @@ -249,23 +278,34 @@ Registration is determined and initiated by the application and generally begins
<string name="helplib_action_issue">Feedback</string>
<string name="helplib_action_telegram_group">Join Telegram group</string>
<string name="helplib_action_qq_group">Join QQ channel</string>
<string name="helplib_title"><![CDATA[Help & Support]]></string>
<string name="helplib_title">
<![CDATA[Help & Support]]>
</string>
<string name="helplib_title_contact">Contact us</string>
<string name="helplib_title_faq">Frequently asked questions</string>
<string name="status_app_registered_error_title">Abnormal registration</string>
<string name="status_app_registered_error_desc"><![CDATA[
This could be the application doing a reverse registration, or the registration mismatch with the Push service. See also <b><a href="https://github.com/MiPushFramework/MiPushFramework/wiki/%5B%E5%B8%AE%E5%8A%A9%5D-%E6%B3%A8%E5%86%8C%E5%BC%82%E5%B8%B8">[帮助] 注册异常</a></b>.
]]></string>


<string-array name="register_entries" translatable="false">
<string name="status_app_registered_error_desc">
<![CDATA[
This could be the application doing a reverse registration, or the registration mismatch with the Push service. See also <b>
<a
href="https://github.com/MiPushFramework/MiPushFramework/wiki/%5B%E5%B8%AE%E5%8A%A9%5D-%E6%B3%A8%E5%86%8C%E5%BC%82%E5%B8%B8">[帮助] 注册异常</a>
</b>.
]]>
</string>


<string-array
name="register_entries"
translatable="false">
<item>0</item>
<item>2</item>
<item>3</item>
</string-array>

<!-- Help -->
<string-array name="help_articles" translatable="false">
<string-array
name="help_articles"
translatable="false">
<item>help_article_can_not_receive_push|can_not_receive_push</item>
<item>help_article_register_error|register_error</item>
<item>help_article_no_register|no_register</item>
Expand All @@ -280,9 +320,9 @@ This could be the application doing a reverse registration, or the registration
<string name="group_notifications_for_same_session_clear_title">clear all notifications of session when the notification of session was clicked</string>
<string name="show_pass_through">show \"pass through\" message as notification</string>
<string name="action_search">Search</string>
<string name="last_receive">last receive: </string>
<string name="last_receive">last receive:</string>
<string name="mipush_services_not_found">Services Not Found</string>
<string name="try_to_force_register_all_applications">Try to force register all applications</string>


</resources>
</resources>
8 changes: 7 additions & 1 deletion push/src/main/res/xml/fragmented_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@
android:key="IceboxSupported"
android:title="@string/settings_icebox_permission"
android:summary="@string/settings_icebox_permission_summary" />


<SwitchPreference
android:defaultValue="false"
android:key="ViaFreeform"
android:title="@string/settings_via_freeform"
android:summary="@string/settings_via_freeform_summary" />

</PreferenceCategory>

<PreferenceCategory android:title="@string/settings_options">
Expand Down