Allow obfuscate settings
This commit is contained in:
1 parent
26c6052286
commit
16202efc7b
7 files changed
+67
-74
No files matched your search
Vendored
-3
@@ -11,9 +11,6 @@
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
-keep,allowoptimization class com.hippo.ehviewer.ui.fragment.* extends com.hippo.ehviewer.ui.fragment.BaseFragment { }
|
||||
-keep,allowoptimization class com.hippo.ehviewer.ui.fragment.* extends com.hippo.ehviewer.ui.fragment.BasePreferenceFragment { }
|
||||
|
||||
-keep class androidx.viewpager.widget.ViewPager$LayoutParams { int position; }
|
||||
|
||||
-keepattributes LineNumberTable,SourceFile
|
||||
|
||||
@@ -15,76 +15,70 @@
|
||||
* You should have received a copy of the GNU General Public License along with EhViewer.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.hippo.ehviewer.ui.fragment
|
||||
|
||||
package com.hippo.ehviewer.ui.fragment;
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.ui.SettingsActivity
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.SettingsActivity;
|
||||
|
||||
|
||||
public class BasePreferenceFragment extends PreferenceFragmentCompat
|
||||
implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
setTitle(getFragmentTitle());
|
||||
open class BasePreferenceFragment : PreferenceFragmentCompat(),
|
||||
Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
setTitle(fragmentTitle)
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public int getFragmentTitle() {
|
||||
return -1;
|
||||
@get:StringRes
|
||||
open val fragmentTitle: Int
|
||||
get() = -1
|
||||
|
||||
override fun onPreferenceChange(preference: Preference, newValue: Any): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
return false;
|
||||
override fun onPreferenceClick(preference: Preference): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
return false;
|
||||
}
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(@Nullable Bundle savedInstanceState, String rootKey) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
try {
|
||||
Fragment classObj = (Fragment) Class.forName(key).newInstance();
|
||||
requireActivity().getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||
.replace(R.id.fragment, classObj)
|
||||
.addToBackStack(null)
|
||||
.commitAllowingStateLoss();
|
||||
} catch (ClassNotFoundException | IllegalAccessException |
|
||||
java.lang.InstantiationException ignored) {
|
||||
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||
val fragment = when (preference.key) {
|
||||
"eh" -> EhFragment()
|
||||
"download" -> DownloadFragment()
|
||||
"privacy" -> PrivacyFragment()
|
||||
"advance" -> AdvancedFragment()
|
||||
"about" -> AboutFragment()
|
||||
"filter" -> FilterFragment()
|
||||
"mytags" -> MyTagsFragment()
|
||||
"uconfig" -> UConfigFragment()
|
||||
"hosts" -> HostsFragment()
|
||||
else -> null
|
||||
}
|
||||
return true;
|
||||
fragment?.let {
|
||||
requireActivity().supportFragmentManager
|
||||
.beginTransaction()
|
||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||
.replace(R.id.fragment, it)
|
||||
.addToBackStack(null)
|
||||
.commitAllowingStateLoss()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private void setTitle(@StringRes int string) {
|
||||
requireActivity().setTitle(string);
|
||||
private fun setTitle(@StringRes string: Int) {
|
||||
requireActivity().setTitle(string)
|
||||
}
|
||||
|
||||
public void showTip(@StringRes int id, int length) {
|
||||
((SettingsActivity) requireActivity()).showTip(getString(id), length);
|
||||
fun showTip(@StringRes id: Int, length: Int) {
|
||||
(requireActivity() as SettingsActivity).showTip(getString(id), length)
|
||||
}
|
||||
|
||||
public void showTip(CharSequence message, int length) {
|
||||
((SettingsActivity) requireActivity()).showTip(message, length);
|
||||
fun showTip(message: CharSequence?, length: Int) {
|
||||
(requireActivity() as SettingsActivity).showTip(message, length)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package com.hippo.ehviewer.ui.fragment
|
||||
import android.app.Activity
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
@@ -91,7 +92,7 @@ class EhFragment : BasePreferenceFragment() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getFragmentTitle(): Int {
|
||||
return R.string.settings_eh
|
||||
}
|
||||
@get:StringRes
|
||||
override val fragmentTitle: Int
|
||||
get() = R.string.settings_eh
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.hippo.ehviewer.ui.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.preference.SeekBarPreference
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
import com.hippo.ehviewer.R
|
||||
@@ -59,9 +60,9 @@ class PrivacyFragment : BasePreferenceFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFragmentTitle(): Int {
|
||||
return R.string.settings_privacy
|
||||
}
|
||||
@get:StringRes
|
||||
override val fragmentTitle: Int
|
||||
get() = R.string.settings_privacy
|
||||
|
||||
private fun setUnlockDelaySummary(value: Int) {
|
||||
unlockDelay.summary = if (value == 0) {
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
android:key="com.hippo.ehviewer.ui.fragment.HostsFragment"
|
||||
android:key="hosts"
|
||||
android:summary="@string/settings_advanced_custom_hosts_summary"
|
||||
android:title="@string/settings_advanced_custom_hosts_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
@@ -33,13 +33,13 @@
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<com.hippo.ehviewer.preference.SignInRequiredPreference
|
||||
android:key="com.hippo.ehviewer.ui.fragment.UConfigFragment"
|
||||
android:key="uconfig"
|
||||
android:summary="@string/settings_u_config_summary"
|
||||
android:title="@string/settings_u_config"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<com.hippo.ehviewer.preference.SignInRequiredPreference
|
||||
android:key="com.hippo.ehviewer.ui.fragment.MyTagsFragment"
|
||||
android:key="mytags"
|
||||
android:summary="@string/settings_my_tags_summary"
|
||||
android:title="@string/settings_my_tags"
|
||||
app:iconSpaceReserved="false" />
|
||||
@@ -158,7 +158,7 @@
|
||||
app:singleLineTitle="false" />
|
||||
|
||||
<Preference
|
||||
android:key="com.hippo.ehviewer.ui.fragment.FilterFragment"
|
||||
android:key="filter"
|
||||
android:summary="@string/settings_eh_filter_summary"
|
||||
android:title="@string/settings_eh_filter"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
@@ -18,26 +18,26 @@
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/v_sad_panda_primary_x24"
|
||||
android:key="com.hippo.ehviewer.ui.fragment.EhFragment"
|
||||
android:key="eh"
|
||||
android:title="@string/settings_eh" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/v_download_primary_x24"
|
||||
android:key="com.hippo.ehviewer.ui.fragment.DownloadFragment"
|
||||
android:key="download"
|
||||
android:title="@string/settings_download" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/v_sec_primary_x24"
|
||||
android:key="com.hippo.ehviewer.ui.fragment.PrivacyFragment"
|
||||
android:key="privacy"
|
||||
android:title="@string/settings_privacy" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/v_adb_primary_x24"
|
||||
android:key="com.hippo.ehviewer.ui.fragment.AdvancedFragment"
|
||||
android:key="advance"
|
||||
android:title="@string/settings_advanced" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/v_info_primary_x24"
|
||||
android:key="com.hippo.ehviewer.ui.fragment.AboutFragment"
|
||||
android:key="about"
|
||||
android:title="@string/settings_about" />
|
||||
</PreferenceScreen>
|
||||
Reference in new issue
Block a user