Skip to content

Commit

Permalink
优化首页布局
Browse files Browse the repository at this point in the history
  • Loading branch information
Fan095 committed May 23, 2024
1 parent 0721de5 commit 155cae2
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 166 deletions.
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
-keep class fan.**{*;}
-keep class org.luckypray.dexkit.*
-keep class * extends com.sevtinge.hyperceiler.ui.dashboard.*
-keep class * extends com.sevtinge.hyperceiler.ui.settings.*
-keep class * extends com.sevtinge.hyperceiler.ui.fragment.base.*
-keep class * extends com.sevtinge.hyperceiler.module.base.BaseHook { <init>(); }
-keep class * extends com.sevtinge.hyperceiler.module.base.BaseModule
-keep class com.sevtinge.hyperceiler.module.base.BaseModule {*;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,15 @@
*/
package com.sevtinge.hyperceiler.ui.navigator.page;

import static com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.dp2px;
import static com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.sp2px;
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.sevtinge.hyperceiler.BuildConfig;
import com.sevtinge.hyperceiler.R;
import com.sevtinge.hyperceiler.expansionpacks.utils.ClickCountsUtils;
import com.sevtinge.hyperceiler.ui.dashboard.DashboardFragment;
import com.sevtinge.hyperceiler.ui.fragment.base.SettingsPreferenceFragment;

import fan.preference.Preference;
Expand All @@ -48,10 +37,6 @@ public class AboutPageFragment extends SettingsPreferenceFragment {
private int lIIlIll = 100 >>> 7;
private final int lIIlIlI = 100 >>> 6;

@Override
public int getContentResId() {
return R.xml.prefs_about;
}

@Override
public void initPrefs() {
Expand All @@ -61,7 +46,12 @@ public void initPrefs() {

if (lIIllII != null) {
lIIllII.setTitle(BuildConfig.VERSION_NAME + " | " + BuildConfig.BUILD_TYPE);
if (isMoreHyperOSVersion(1f)) lIIllII.setSummary(R.string.description_hyperos); else lIIllII.setSummary(R.string.description_miui);
lIIllII.setSummary(
String.format(
getString(R.string.ceiler_description),
getString(isMoreHyperOSVersion(1f) ? R.string.hyperos : R.string.miui)
)
);
lIIllII.setOnPreferenceClickListener(lIIllll -> {
if (lIIllll instanceof SwitchPreference switchPreference) {
switchPreference.setChecked(!switchPreference.isChecked());
Expand Down Expand Up @@ -89,6 +79,11 @@ public void initPrefs() {
}
}

@Override
public int getContentResId() {
return R.xml.prefs_about;
}

/**
* 调用 joinQQGroup() 即可发起手Q客户端申请加群
*
Expand All @@ -97,29 +92,10 @@ public void initPrefs() {
private void joinQQGroup(String key) {
Intent intent = new Intent();
intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26jump_from%3Dwebapi%26k%3D" + key));

try {
startActivity(intent);
} catch (Exception e) {
// 未安装手Q或安装的版本不支持
}
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

RecyclerView recyclerView = view.findViewById(fan.preference.R.id.recycler_view);
ViewCompat.setOnApplyWindowInsetsListener(recyclerView, new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
Insets inset = Insets.max(insets.getInsets(WindowInsetsCompat.Type.systemBars()),
insets.getInsets(WindowInsetsCompat.Type.displayCutout()));
// 22dp + 2dp + 12sp + 10dp + 18dp + 0.5dp + inset.bottom + 4dp(?)
v.setPadding(inset.left, 0, inset.right, inset.bottom + dp2px(requireContext(), 56.5F) + sp2px(requireContext(),12));
return insets;
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,15 @@
*/
package com.sevtinge.hyperceiler.ui.navigator.page;

import static com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.dp2px;
import static com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.sp2px;

import android.app.Activity;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.sevtinge.hyperceiler.BuildConfig;
import com.sevtinge.hyperceiler.R;
import com.sevtinge.hyperceiler.ui.LauncherActivity;
import com.sevtinge.hyperceiler.ui.dashboard.DashboardFragment;
import com.sevtinge.hyperceiler.ui.fragment.base.SettingsPreferenceFragment;
import com.sevtinge.hyperceiler.utils.BackupUtils;
import com.sevtinge.hyperceiler.utils.DialogHelper;
Expand All @@ -60,11 +48,6 @@ public class SettingsPageFragment extends SettingsPreferenceFragment
DropDownPreference mLogLevel;
DropDownPreference mLanguage;

@Override
public int getContentResId() {
return R.xml.prefs_settings;
}

@Override
public void initPrefs() {
int mIconMode = Integer.parseInt(PrefsUtils.getSharedStringPrefs(getContext(), "prefs_key_settings_icon", "0"));
Expand Down Expand Up @@ -150,6 +133,11 @@ public void initPrefs() {
});
}

@Override
public int getContentResId() {
return R.xml.prefs_settings;
}

@Override
public boolean onPreferenceChange(Preference preference, Object o) {
if (preference == mIconModePreference) {
Expand All @@ -173,22 +161,4 @@ public void backupSettings(Activity activity) {
public void restoreSettings(Activity activity) {
BackupUtils.restore(activity);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

RecyclerView recyclerView = view.findViewById(fan.preference.R.id.recycler_view);
ViewCompat.setOnApplyWindowInsetsListener(recyclerView, new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
Insets inset = Insets.max(insets.getInsets(WindowInsetsCompat.Type.systemBars()),
insets.getInsets(WindowInsetsCompat.Type.displayCutout()));
// 22dp + 2dp + 12sp + 10dp + 18dp + 0.5dp + inset.bottom + 4dp(?)
v.setPadding(inset.left, 0, inset.right, inset.bottom + dp2px(requireContext(), 56.5F) + sp2px(requireContext(), 12));
return insets;
}
});
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_default_icon.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="165dp"
android:height="165dp"
android:width="@dimen/header_icon_size"
android:height="@dimen/header_icon_size"
android:autoMirrored="true"
android:viewportWidth="30"
android:viewportHeight="30">
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
<!--Introduction to Xposed Modules-->
<string name="xposed_description">Make HyperOS/MIUI Great Again!</string>

<string name="description_hyperos" translatable="false">Make HyperOS Great Again!</string>
<string name="description_miui" translatable="false">Make MIUI Great Again!</string>
<string name="hyperos" translatable="false">HyperOS</string>
<string name="miui" translatable="false">MIUI</string>
<string name="ceiler_description" translatable="false">Make %s Great Again!</string>

<string name="new_permission_wifi_state_desc">add and delete files on device\'s internal storage</string>
<string name="new_permission_location_desc">used to provide services such as latitude and longitude</string>
Expand Down
Loading

0 comments on commit 155cae2

Please sign in to comment.