From 967ca1723854baf6c48a6b852b4cf48facd3b5b6 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 3 Dec 2017 15:43:07 +0800 Subject: [PATCH] Fix custom channel dialog --- app/build.gradle | 2 +- app/src/main/assets/changelog.md | 2 +- .../topjohnwu/magisk/SettingsActivity.java | 26 +++++++------------ .../main/res/layout/custom_channel_dialog.xml | 25 ++++++++++++++++++ 4 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/layout/custom_channel_dialog.xml diff --git a/app/build.gradle b/app/build.gradle index 492c62d1e..fc52fa8b3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ android { applicationId "com.topjohnwu.magisk" minSdkVersion 21 targetSdkVersion 27 - versionCode 70 + versionCode 71 versionName "5.4.3" ndk { moduleName 'zipadjust' diff --git a/app/src/main/assets/changelog.md b/app/src/main/assets/changelog.md index fbb699fc2..3758aad90 100644 --- a/app/src/main/assets/changelog.md +++ b/app/src/main/assets/changelog.md @@ -1,4 +1,4 @@ -### v5.4.3 (70) +### v5.4.3 (71) - Fix dynamic resource loading, should prevent crashing when checking SafetyNet - Update SignAPK to use very little RAM, should expand old device support - Support settings migration after hiding Magisk Manager diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java index 657cbcdbd..95d339e37 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java @@ -11,16 +11,16 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.preference.SwitchPreference; import android.support.v7.app.ActionBar; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; -import android.text.InputType; +import android.view.LayoutInflater; +import android.view.View; import android.widget.EditText; -import android.widget.LinearLayout; import android.widget.Toast; import com.topjohnwu.magisk.asyncs.CheckUpdates; import com.topjohnwu.magisk.asyncs.HideManager; import com.topjohnwu.magisk.components.Activity; -import com.topjohnwu.magisk.components.AlertDialogBuilder; import com.topjohnwu.magisk.utils.Const; import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Topic; @@ -116,21 +116,15 @@ public class SettingsActivity extends Activity implements Topic.Subscriber { updateChannel.setOnPreferenceChangeListener((pref, o) -> { mm.updateChannel = Integer.parseInt((String) o); if (mm.updateChannel == Const.Value.CUSTOM_CHANNEL) { - LinearLayout layout = new LinearLayout(getActivity()); - EditText url = new EditText(getActivity()); - url.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); + View v = LayoutInflater.from(getActivity()).inflate(R.layout.custom_channel_dialog, null); + EditText url = v.findViewById(R.id.custom_url); url.setText(mm.customChannelUrl); - layout.setOrientation(LinearLayout.VERTICAL); - layout.addView(url); - LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) url.getLayoutParams(); - params.setMargins(Utils.dpInPx(15), 0, Utils.dpInPx(15), 0); - new AlertDialogBuilder(getActivity()) + new AlertDialog.Builder(getActivity()) .setTitle(R.string.settings_update_custom) - .setMessage(R.string.settings_update_custom_msg) - .setView(layout) - .setPositiveButton(R.string.ok, (d, i) -> { - prefs.edit().putString(Const.Key.CUSTOM_CHANNEL, url.getText().toString()).apply(); - }) + .setView(v) + .setPositiveButton(R.string.ok, (d, i) -> + prefs.edit().putString(Const.Key.CUSTOM_CHANNEL, + url.getText().toString()).apply()) .setNegativeButton(R.string.close, null) .show(); } diff --git a/app/src/main/res/layout/custom_channel_dialog.xml b/app/src/main/res/layout/custom_channel_dialog.xml new file mode 100644 index 000000000..601a7144c --- /dev/null +++ b/app/src/main/res/layout/custom_channel_dialog.xml @@ -0,0 +1,25 @@ + + + + + + + \ No newline at end of file