Skip to content

Commit

Permalink
移除無用的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
qwe7002 authored and qwe7002 committed Jun 25, 2022
1 parent d9a645b commit 69e7120
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void onReceive(@NotNull final Context context, @NotNull Intent intent) {
final SharedPreferences sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE);
if (sharedPreferences.getBoolean("initialized", false)) {
log_func.write_log(context, "Received [" + intent.getAction() + "] broadcast, starting background service.");
service_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false), sharedPreferences.getBoolean("wifi_monitor_switch", false));
service_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false));
if (Paper.book().read("resend_list", new ArrayList<>()).size() != 0) {
Log.d(TAG, "An unsent message was detected, and the automatic resend process was initiated.");
resend_func.start_resend_service(context);
Expand Down
15 changes: 4 additions & 11 deletions app/src/main/java/com/qwe7002/telegram_rc/main_activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,14 @@ protected void onCreate(Bundle savedInstanceState) {
final SwitchMaterial root_switch = findViewById(R.id.root_switch);
final SwitchMaterial privacy_mode_switch = findViewById(R.id.privacy_switch);
final SwitchMaterial display_dual_sim_display_name_switch = findViewById(R.id.display_dual_sim_switch);
final SwitchMaterial wifi_status_switch = findViewById(R.id.wifi_status_switch);
final Button save_button = findViewById(R.id.save_button);
final Button get_id_button = findViewById(R.id.get_id_button);
usage_button = findViewById(R.id.usage_button);
write_settings_button = findViewById(R.id.write_settings_button);
//load config
Paper.init(context);
sharedPreferences = getSharedPreferences("data", MODE_PRIVATE);
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
wifi_status_switch.setChecked(false);
wifi_status_switch.setVisibility(View.GONE);
} else {
wifi_status_switch.setChecked(sharedPreferences.getBoolean("wifi_monitor_switch", false));
}

usage_button.setOnClickListener(v -> {
Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
startActivity(intent);
Expand All @@ -166,7 +160,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (sharedPreferences.getBoolean("initialized", false)) {
update_config();
check_version_upgrade(true);
service_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false), sharedPreferences.getBoolean("wifi_monitor_switch", false));
service_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false));

}

Expand Down Expand Up @@ -482,11 +476,10 @@ public void onResponse(@NonNull Call call, @NonNull Response response) throws IO
editor.putBoolean("privacy_mode", privacy_mode_switch.isChecked());
editor.putBoolean("initialized", true);
editor.putBoolean("privacy_dialog_agree", true);
editor.putBoolean("wifi_monitor_switch", wifi_status_switch.isChecked());
editor.apply();
new Thread(() -> {
service_func.stop_all_service(context);
service_func.start_service(context, battery_monitoring_switch.isChecked(), chat_command_switch.isChecked(), wifi_status_switch.isChecked());
service_func.start_service(context, battery_monitoring_switch.isChecked(), chat_command_switch.isChecked());
}).start();
Looper.prepare();
Snackbar.make(v, R.string.success, Snackbar.LENGTH_LONG)
Expand Down Expand Up @@ -747,7 +740,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
new Thread(() -> {
service_func.stop_all_service(context);
if (sharedPreferences.getBoolean("initialized", false)) {
service_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false), sharedPreferences.getBoolean("wifi_monitor_switch", false));
service_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false));
}
}).start();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void onReceive(final Context context, @NotNull Intent intent) {
case "/restartservice":
new Thread(() -> {
service_func.stop_all_service(context);
service_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false), sharedPreferences.getBoolean("wifi_monitor_switch", false));
service_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false));
}).start();
raw_request_body_text = context.getString(R.string.system_message_head) + "\n" + context.getString(R.string.restart_service);
request_body.text = raw_request_body_text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.qwe7002.telegram_rc.static_class;

import android.Manifest;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand All @@ -11,7 +10,6 @@
import com.qwe7002.telegram_rc.beacon_receiver_service;
import com.qwe7002.telegram_rc.chat_command_service;
import com.qwe7002.telegram_rc.notification_listener_service;
import com.qwe7002.telegram_rc.wifi_connect_status_service;

import java.util.Set;

Expand All @@ -26,21 +24,16 @@ public static void stop_all_service(Context context) {
}
}

public static void start_service(Context context, Boolean battery_switch, Boolean chat_command_switch, Boolean wifi_status_monitor_switch) {
public static void start_service(Context context, Boolean battery_switch, Boolean chat_command_switch) {
Intent battery_service = new Intent(context, com.qwe7002.telegram_rc.battery_service.class);
Intent chat_long_polling_service = new Intent(context, chat_command_service.class);
Intent wifi_connect_ststus_service = new Intent(context, wifi_connect_status_service.class);
start_beacon_service(context);
if (is_notify_listener(context)) {
ComponentName this_component_name = new ComponentName(context, notification_listener_service.class);
PackageManager package_manager = context.getPackageManager();
package_manager.setComponentEnabledSetting(this_component_name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
package_manager.setComponentEnabledSetting(this_component_name, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
if (wifi_status_monitor_switch && context.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
//Determine whether there is permission
context.startForegroundService(wifi_connect_ststus_service);
}
if (battery_switch) {
context.startForegroundService(battery_service);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import okhttp3.RequestBody;
import okhttp3.Response;

@RequiresApi(api = Build.VERSION_CODES.O)
public class ussd_request_callback extends TelephonyManager.UssdResponseCallback {

private final Context context;
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@
android:text="@string/root_switch"
tools:ignore="RtlSymmetry" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/wifi_status_switch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="3dp"
android:text="@string/wifi_status_monitoring"
tools:ignore="RtlSymmetry" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/privacy_switch"
Expand Down

0 comments on commit 69e7120

Please sign in to comment.