优化:1234步骤页面增加右上角菜单

This commit is contained in:
pppscn 2022-02-07 11:41:26 +08:00
parent d739cc7f36
commit 70edc8036e
9 changed files with 183 additions and 19 deletions

View File

@ -57,7 +57,7 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
tools:ignore="UnusedAttribute"> tools:ignore="DataExtractionRules,UnusedAttribute">
<meta-data <meta-data
android:name="ScopedStorage" android:name="ScopedStorage"

View File

@ -454,15 +454,11 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
} }
//menu点击事件 //menu点击事件
@SuppressWarnings("CommentedOutCode")
@SuppressLint("NonConstantResourceId") @SuppressLint("NonConstantResourceId")
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
Intent intent; Intent intent;
switch (item.getItemId()) { switch (item.getItemId()) {
//case R.id.to_setting:
// intent = new Intent(this, SettingActivity.class);
// break;
case R.id.to_app_list: case R.id.to_app_list:
intent = new Intent(this, AppListActivity.class); intent = new Intent(this, AppListActivity.class);
break; break;
@ -487,7 +483,8 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
//设置menu图标显示 //设置menu图标显示
@Override @Override
public boolean onMenuOpened(int featureId, Menu menu) { public boolean onMenuOpened(int featureId, Menu menu) {
if (featureId == Window.FEATURE_ACTION_BAR && menu != null) { Log.d(TAG, "onMenuOpened, featureId=" + featureId);
if (menu != null) {
if (menu.getClass().getSimpleName().equals("MenuBuilder")) { if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
try { try {
Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);

View File

@ -5,10 +5,14 @@ import static com.idormy.sms.forwarder.model.RuleModel.STATUS_OFF;
import static com.idormy.sms.forwarder.model.RuleModel.STATUS_ON; import static com.idormy.sms.forwarder.model.RuleModel.STATUS_ON;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
@ -36,6 +40,7 @@ import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.view.StepBar; import com.idormy.sms.forwarder.view.StepBar;
import com.melnykov.fab.FloatingActionButton; import com.melnykov.fab.FloatingActionButton;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -614,4 +619,59 @@ public class RuleActivity extends AppCompatActivity {
return 0; return 0;
} }
//启用menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return super.onCreateOptionsMenu(menu);
}
//menu点击事件
@SuppressLint("NonConstantResourceId")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case R.id.to_app_list:
intent = new Intent(this, AppListActivity.class);
break;
case R.id.to_clone:
intent = new Intent(this, CloneActivity.class);
break;
case R.id.to_about:
intent = new Intent(this, AboutActivity.class);
break;
case R.id.to_help:
Uri uri = Uri.parse("https://gitee.com/pp/SmsForwarder/wikis/pages");
intent = new Intent(Intent.ACTION_VIEW, uri);
break;
default:
return super.onOptionsItemSelected(item);
}
startActivity(intent);
return true;
}
//设置menu图标显示
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
Log.d(TAG, "onMenuOpened, featureId=" + featureId);
if (menu != null) {
if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
try {
Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
m.setAccessible(true);
m.invoke(menu, true);
} catch (NoSuchMethodException e) {
Log.e(TAG, "onMenuOpened", e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
return super.onMenuOpened(featureId, menu);
}
} }

View File

@ -17,12 +17,16 @@ import static com.idormy.sms.forwarder.model.SenderModel.TYPE_WEB_NOTIFY;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
@ -76,6 +80,7 @@ import com.idormy.sms.forwarder.view.ClearEditText;
import com.idormy.sms.forwarder.view.StepBar; import com.idormy.sms.forwarder.view.StepBar;
import com.melnykov.fab.FloatingActionButton; import com.melnykov.fab.FloatingActionButton;
import java.lang.reflect.Method;
import java.net.Proxy; import java.net.Proxy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -2017,4 +2022,59 @@ public class SenderActivity extends AppCompatActivity {
}); });
} }
//启用menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return super.onCreateOptionsMenu(menu);
}
//menu点击事件
@SuppressLint("NonConstantResourceId")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case R.id.to_app_list:
intent = new Intent(this, AppListActivity.class);
break;
case R.id.to_clone:
intent = new Intent(this, CloneActivity.class);
break;
case R.id.to_about:
intent = new Intent(this, AboutActivity.class);
break;
case R.id.to_help:
Uri uri = Uri.parse("https://gitee.com/pp/SmsForwarder/wikis/pages");
intent = new Intent(Intent.ACTION_VIEW, uri);
break;
default:
return super.onOptionsItemSelected(item);
}
startActivity(intent);
return true;
}
//设置menu图标显示
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
Log.d(TAG, "onMenuOpened, featureId=" + featureId);
if (menu != null) {
if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
try {
Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
m.setAccessible(true);
m.invoke(menu, true);
} catch (NoSuchMethodException e) {
Log.e(TAG, "onMenuOpened", e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
return super.onMenuOpened(featureId, menu);
}
} }

View File

@ -16,6 +16,8 @@ import android.provider.Settings;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
@ -46,6 +48,7 @@ import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.view.ClearEditText; import com.idormy.sms.forwarder.view.ClearEditText;
import com.idormy.sms.forwarder.view.StepBar; import com.idormy.sms.forwarder.view.StepBar;
import java.lang.reflect.Method;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -888,4 +891,58 @@ public class SettingActivity extends AppCompatActivity {
builder.create().show(); builder.create().show();
} }
//启用menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return super.onCreateOptionsMenu(menu);
}
//menu点击事件
@SuppressLint("NonConstantResourceId")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case R.id.to_app_list:
intent = new Intent(this, AppListActivity.class);
break;
case R.id.to_clone:
intent = new Intent(this, CloneActivity.class);
break;
case R.id.to_about:
intent = new Intent(this, AboutActivity.class);
break;
case R.id.to_help:
Uri uri = Uri.parse("https://gitee.com/pp/SmsForwarder/wikis/pages");
intent = new Intent(Intent.ACTION_VIEW, uri);
break;
default:
return super.onOptionsItemSelected(item);
}
startActivity(intent);
return true;
}
//设置menu图标显示
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
Log.d(TAG, "onMenuOpened, featureId=" + featureId);
if (menu != null) {
if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
try {
Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
m.setAccessible(true);
m.invoke(menu, true);
} catch (NoSuchMethodException e) {
Log.e(TAG, "onMenuOpened", e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
return super.onMenuOpened(featureId, menu);
}
} }

View File

@ -2,13 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context="com.idormy.sms.forwarder.MainActivity"> tools:ignore="UseCompoundDrawables">
<!--<item
android:id="@+id/to_setting"
android:icon="@drawable/ic_settings"
android:orderInCategory="100"
android:title="@string/setting"
app:showAsAction="never" />-->
<item <item
android:id="@+id/to_app_list" android:id="@+id/to_app_list"
android:icon="@drawable/ic_app" android:icon="@drawable/ic_app"

View File

@ -116,7 +116,6 @@
<string name="invalid_at_mobiles">The specified member cannot be blank or select @all</string> <string name="invalid_at_mobiles">The specified member cannot be blank or select @all</string>
<string name="invalid_webcom_app_parm">CronID, AgentID and Secret cannot be blank</string> <string name="invalid_webcom_app_parm">CronID, AgentID and Secret cannot be blank</string>
<string name="invalid_phone_num">Phone number cannot be blank</string> <string name="invalid_phone_num">Phone number cannot be blank</string>
<string name="new_sender">New Sender</string>
<string name="set_bark_name">GroupName/Status</string> <string name="set_bark_name">GroupName/Status</string>
<string name="set_bark_server">Bark-Server</string> <string name="set_bark_server">Bark-Server</string>
<string name="set_bark_server_tips"> e.g. https://day.app/XXXXXXXX/</string> <string name="set_bark_server_tips"> e.g. https://day.app/XXXXXXXX/</string>
@ -185,7 +184,6 @@
<string name="enable_custom_templates_tips">Priority: custom template for forwarding rules > Global custom template > System default</string> <string name="enable_custom_templates_tips">Priority: custom template for forwarding rules > Global custom template > System default</string>
<string name="enable_regex_replace">Enable regular replacement content</string> <string name="enable_regex_replace">Enable regular replacement content</string>
<string name="enable_regex_replace_tips">Format: RegularExpression===ReplacementResult,One rule per line.\ne.g. (\\d{3})\\d+(\\d{4})===$1****$2</string> <string name="enable_regex_replace_tips">Format: RegularExpression===ReplacementResult,One rule per line.\ne.g. (\\d{3})\\d+(\\d{4})===$1****$2</string>
<string name="regex_check_tips">Format check: line %d is badly formatted! Format: RegularExpression===ReplacementResult</string>
<string name="enable_exclude_from_recents">Hide from recent Apps</string> <string name="enable_exclude_from_recents">Hide from recent Apps</string>
<string name="enable_exclude_from_recents_tips">Enable to hide SmsForwarder from recent Apps to keep it alive</string> <string name="enable_exclude_from_recents_tips">Enable to hide SmsForwarder from recent Apps to keep it alive</string>
<string name="custom_templates">Custom templates</string> <string name="custom_templates">Custom templates</string>
@ -308,7 +306,6 @@
<string name="step_2">Senders</string> <string name="step_2">Senders</string>
<string name="step_3">Rules</string> <string name="step_3">Rules</string>
<string name="step_4">Logs</string> <string name="step_4">Logs</string>
<string name="clean_log">Clean Log</string>
<string name="todo">TODO</string> <string name="todo">TODO</string>
<string name="forwarding_function">Forwarding Function</string> <string name="forwarding_function">Forwarding Function</string>
<string name="forwarding_function_tips">Main switch: Enable the forwarding function as required</string> <string name="forwarding_function_tips">Main switch: Enable the forwarding function as required</string>

View File

@ -116,7 +116,6 @@
<string name="invalid_at_mobiles">指定成员 不能为空 或者 选择@all</string> <string name="invalid_at_mobiles">指定成员 不能为空 或者 选择@all</string>
<string name="invalid_webcom_app_parm">企业ID、AgentID、Secret都不能为空</string> <string name="invalid_webcom_app_parm">企业ID、AgentID、Secret都不能为空</string>
<string name="invalid_phone_num">接收手机号不能为空</string> <string name="invalid_phone_num">接收手机号不能为空</string>
<string name="new_sender">添加发送通道</string>
<string name="set_bark_name">分组名称/状态</string> <string name="set_bark_name">分组名称/状态</string>
<string name="set_bark_server">Bark-Server</string> <string name="set_bark_server">Bark-Server</string>
<string name="set_bark_server_tips">https://day.app/XXXXXXXX/</string> <string name="set_bark_server_tips">https://day.app/XXXXXXXX/</string>
@ -185,7 +184,6 @@
<string name="enable_custom_templates_tips">优先级:转发规则的自定义模板 > 全局自定义模版 > 默认</string> <string name="enable_custom_templates_tips">优先级:转发规则的自定义模板 > 全局自定义模版 > 默认</string>
<string name="enable_regex_replace">启用正则替换内容</string> <string name="enable_regex_replace">启用正则替换内容</string>
<string name="enable_regex_replace_tips">格式:正则表达式===替换结果,每行一个规则.\n例如(\\d{3})\\d{4}(\\d{4})===$1****$2</string> <string name="enable_regex_replace_tips">格式:正则表达式===替换结果,每行一个规则.\n例如(\\d{3})\\d{4}(\\d{4})===$1****$2</string>
<string name="regex_check_tips">正则替换检查:第 %d 行格式错误!格式:正则表达式===替换结果</string>
<string name="enable_exclude_from_recents">不在最近任务列表中显示</string> <string name="enable_exclude_from_recents">不在最近任务列表中显示</string>
<string name="enable_exclude_from_recents_tips">开启后,有效避免手动误杀进程,利于保活</string> <string name="enable_exclude_from_recents_tips">开启后,有效避免手动误杀进程,利于保活</string>
<string name="custom_templates">转发信息模版</string> <string name="custom_templates">转发信息模版</string>
@ -307,7 +305,6 @@
<string name="step_2">发送通道</string> <string name="step_2">发送通道</string>
<string name="step_3">转发规则</string> <string name="step_3">转发规则</string>
<string name="step_4">转发日志</string> <string name="step_4">转发日志</string>
<string name="clean_log">清理日志</string>
<string name="todo">TODO</string> <string name="todo">TODO</string>
<string name="forwarding_function">转发功能</string> <string name="forwarding_function">转发功能</string>
<string name="forwarding_function_tips">总开关,请根据实际需要,启用对应的转发功能</string> <string name="forwarding_function_tips">总开关,请根据实际需要,启用对应的转发功能</string>

View File

@ -7,12 +7,14 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="actionOverflowMenuStyle">@style/OverflowMenu</item> <item name="actionOverflowMenuStyle">@style/OverflowMenu</item>
<item name="android:textColor">@color/white</item>
</style> </style>
<style name="OverflowMenu" parent="Base.Widget.AppCompat.PopupMenu.Overflow"> <style name="OverflowMenu" parent="Base.Widget.AppCompat.PopupMenu.Overflow">
<item name="android:dropDownWidth">100dp</item> <item name="android:dropDownWidth">100dp</item>
<!-- 是否覆盖锚点默认为true即盖住Toolbar --> <!-- 是否覆盖锚点默认为true即盖住Toolbar -->
<item name="overlapAnchor">false</item> <item name="overlapAnchor">false</item>
<item name="android:popupBackground">@color/colorPrimary</item>
</style> </style>
<style name="rg_style"> <style name="rg_style">