Add configuration files and remove redundant code

Added IntelliJ IDEA project configuration, lint baseline, and inspection profiles for consistency and static analysis. Removed redundant null-check for intent in `MainActivity` to simplify logic and improve readability.
This commit is contained in:
yjj38 2025-05-30 12:24:32 +08:00
parent 1d65b8c5aa
commit 8b079e8115
6 changed files with 197 additions and 7 deletions

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GoogleJavaFormatSettings">
<option name="enabled" value="false" />
</component>
</project>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="UsePropertyAccessSyntax" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
</profile>
</component>

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

179
app/lint-baseline.xml Normal file
View File

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.10.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.10.0)" variant="all" version="8.10.0">
<issue
id="ScopedStorage"
message="The Google Play store has a policy that limits usage of MANAGE_EXTERNAL_STORAGE"
errorLine1="&lt;uses-permission android:name=&quot;android.permission.MANAGE_EXTERNAL_STORAGE&quot; />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/AndroidManifest.xml"
line="10"
column="32"/>
</issue>
<issue
id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the `android.os.Build.VERSION_CODES` javadoc for details."
errorLine1=" targetSdk 35"
errorLine2=" ~~~~~~~~~~~~">
<location
file="build.gradle"
line="12"
column="9"/>
</issue>
<issue
id="HighSamplingRate"
message="Most apps don&apos;t need access to high sensor sampling rate."
errorLine1=" &lt;uses-permission android:name=&quot;android.permission.HIGH_SAMPLING_RATE_SENSORS&quot; />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/AndroidManifest.xml"
line="15"
column="36"/>
</issue>
<issue
id="ProtectedPermissions"
message="Permission is only granted to system apps"
errorLine1="&lt;uses-permission android:name=&quot;android.permission.BIND_VPN_SERVICE&quot; />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/AndroidManifest.xml"
line="11"
column="18"/>
</issue>
<issue
id="ObsoleteLayoutParam"
message="Invalid layout param in a `LinearLayout`: `layout_centerInParent`"
errorLine1=" android:layout_centerInParent=&quot;true&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/activity_main.xml"
line="20"
column="9"/>
</issue>
<issue
id="Overdraw"
message="Possible overdraw: Root element paints background `@drawable/background` with a theme that also paints a background (inferred theme is `@style/Theme.StudyApp`)"
errorLine1=" android:background=&quot;@drawable/background&quot;>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/activity_main.xml"
line="12"
column="5"/>
</issue>
<issue
id="UnusedResources"
message="The resource `R.color.black` appears to be unused"
errorLine1=" &lt;color name=&quot;black&quot;>#FF000000&lt;/color>"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/res/values/colors.xml"
line="3"
column="12"/>
</issue>
<issue
id="UnusedResources"
message="The resource `R.color.white` appears to be unused"
errorLine1=" &lt;color name=&quot;white&quot;>#FFFFFFFF&lt;/color>"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/res/values/colors.xml"
line="4"
column="12"/>
</issue>
<issue
id="UnusedResources"
message="The resource `R.mipmap.ic_launcher` appears to be unused">
<location
file="src/main/res/mipmap-hdpi/ic_launcher.webp"/>
</issue>
<issue
id="UnusedResources"
message="The resource `R.string.app_name` appears to be unused"
errorLine1=" &lt;string name=&quot;app_name&quot;>study.App&lt;/string>"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="2"
column="13"/>
</issue>
<issue
id="IconLauncherShape"
message="Launcher icons should not fill every pixel of their square region; see the design guide for details">
<location
file="src/main/res/mipmap-hdpi/box.png"/>
</issue>
<issue
id="IconLocation"
message="Found bitmap drawable `res/drawable/background.jpg` in densityless folder">
<location
file="src/main/res/drawable/background.jpg"/>
</issue>
<issue
id="UseTomlInstead"
message="Use version catalog instead"
errorLine1=" implementation &apos;com.squareup.retrofit2:retrofit:2.9.0&apos;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="41"
column="20"/>
</issue>
<issue
id="UseTomlInstead"
message="Use version catalog instead"
errorLine1=" implementation &apos;com.squareup.retrofit2:converter-gson:2.9.0&apos;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="44"
column="20"/>
</issue>
<issue
id="UseTomlInstead"
message="Use version catalog instead"
errorLine1=" implementation &apos;com.squareup.retrofit2:adapter-rxjava3:2.9.0&apos;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="47"
column="20"/>
</issue>
<issue
id="HardcodedText"
message="Hardcoded string &quot;点击开始运行&quot;, should use `@string` resource"
errorLine1=" android:text=&quot;点击开始运行&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/activity_main.xml"
line="18"
column="9"/>
</issue>
<issue
id="HardcodedText"
message="Hardcoded string &quot;运行脚本按钮&quot;, should use `@string` resource"
errorLine1=" android:contentDescription=&quot;运行脚本按钮&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/activity_main.xml"
line="19"
column="9"/>
</issue>
</issues>

View File

@ -247,12 +247,6 @@ public class MainActivity extends AppCompatActivity {
intent = new Intent(this, CustomVpnService.class); intent = new Intent(this, CustomVpnService.class);
if (intent == null) {
Log.e("handleVpnPermissionResult", "Intent is null. Cannot start service.");
showToastOnUiThread(this, "Failed to start VPN service due to null intent.");
return;
}
try { try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent); startForegroundService(intent);