Skip to content

Commit cfa632b

Browse files
committed
Kernel update
1 parent 26df563 commit cfa632b

File tree

3 files changed

+88
-5
lines changed

3 files changed

+88
-5
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.androidbootmanager.app.ui.addrom;
2+
3+
import android.os.Bundle;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.TextView;
8+
9+
import androidx.annotation.NonNull;
10+
import androidx.annotation.Nullable;
11+
import androidx.fragment.app.Fragment;
12+
import androidx.lifecycle.ViewModelProvider;
13+
14+
import org.androidbootmanager.app.R;
15+
import org.androidbootmanager.app.roms.ROM;
16+
import org.androidbootmanager.app.roms.ROMsList;
17+
import org.androidbootmanager.app.ui.roms.ROMFragment;
18+
import org.androidbootmanager.app.ui.wizard.WizardViewModel;
19+
20+
import java.util.Objects;
21+
22+
public class UpROMWelcomeWizardPageFragment extends Fragment {
23+
protected WizardViewModel model;
24+
protected AddROMViewModel imodel;
25+
26+
@Nullable
27+
@Override
28+
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
29+
@Nullable Bundle savedInstanceState) {
30+
model = new ViewModelProvider(requireActivity()).get(WizardViewModel.class);
31+
imodel = new ViewModelProvider(requireActivity()).get(AddROMViewModel.class);
32+
model.setPositiveFragment(DeviceROMInstallerWizardPageFragment.class);
33+
model.setNegativeFragment(null);
34+
model.setPositiveAction(null);
35+
model.setNegativeAction(() -> requireActivity().finish());
36+
model.setPositiveText(getString(R.string.next));
37+
model.setNegativeText(getString(R.string.cancel));
38+
ROMsList l = new ROMsList(model.getCodename().getValue(), requireContext());
39+
ROMFragment.Entry e = ROMFragment.current;
40+
if (e.config.get("xsystem") != null)
41+
Objects.requireNonNull(imodel.getParts().getValue()).add(Integer.parseInt(e.config.get("xsystem")));
42+
if (e.config.get("xrom").equals("UT"))
43+
imodel.setROM(l.getROMs().stream().filter(r -> r.scriptname.equals("add_ubuntutouch_systemimage_haliumboot.sh")).findFirst().get());
44+
else if (e.config.get("xrom").equals("SFOS"))
45+
imodel.setROM(l.getROMs().stream().filter(r -> r.scriptname.equals("add_sailfish.sh")).findFirst().get());
46+
imodel.getName().add(e.config.get("title"));
47+
imodel.getName().add(e.file.replace("/data/abm/bootset/lk2nd/entries/","").replace(".cfg",""));
48+
Objects.requireNonNull(imodel.getROM().getValue()).parts.clear();
49+
Objects.requireNonNull(imodel.getROM().getValue()).flashes.clear();
50+
Objects.requireNonNull(imodel.getROM().getValue()).strings.clear();
51+
Objects.requireNonNull(imodel.getParts().getValue()).add(Integer.parseInt(e.config.get("xdata")));
52+
final View root = inflater.inflate(R.layout.wizard_installer_welcome, container, false);
53+
final TextView message = root.findViewById(R.id.wizard_installer_welcome_txt);
54+
message.setText(R.string.kernel_update_msg);
55+
return root;
56+
}
57+
}

app/src/main/java/org/androidbootmanager/app/ui/roms/ROMFragment.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.widget.ImageView;
1010
import android.widget.TextView;
1111
import android.widget.Toast;
12+
import android.widget.Toolbar;
1213

1314
import androidx.annotation.NonNull;
1415
import androidx.appcompat.app.AlertDialog;
@@ -25,9 +26,13 @@
2526
import com.topjohnwu.superuser.io.SuFile;
2627

2728
import org.androidbootmanager.app.R;
29+
import org.androidbootmanager.app.roms.ROM;
2830
import org.androidbootmanager.app.ui.addrom.AddROMWelcomeWizardPageFragment;
31+
import org.androidbootmanager.app.ui.addrom.UpROMWelcomeWizardPageFragment;
2932
import org.androidbootmanager.app.ui.home.InstalledViewModel;
33+
import org.androidbootmanager.app.ui.installer.InstallerWelcomeWizardPageFragment;
3034
import org.androidbootmanager.app.ui.wizard.WizardActivity;
35+
import org.androidbootmanager.app.ui.wizard.WizardViewModel;
3136
import org.androidbootmanager.app.util.ActionAbortedCleanlyError;
3237
import org.androidbootmanager.app.util.ConfigFile;
3338
import org.androidbootmanager.app.util.ConfigTextWatcher;
@@ -44,8 +49,9 @@ public class ROMFragment extends Fragment {
4449
ROMRecyclerViewAdapter adapter;
4550
InstalledViewModel model;
4651
FloatingActionButton fab;
52+
public static Entry current;
4753

48-
private static class Entry {
54+
public static class Entry {
4955
public final String file;
5056
public ConfigFile config;
5157
public Entry(String outFile) throws ActionAbortedCleanlyError {
@@ -130,6 +136,10 @@ public ViewHolder(View view) {
130136
proposed_ = new ConfigFile();
131137
}
132138
final ConfigFile proposed = proposed_;
139+
final Toolbar t = new Toolbar(requireContext());
140+
t.setTitle(R.string.edit_entry);
141+
t.setBackgroundColor(getResources().getColor(R.color.colorAccent, requireActivity().getTheme()));
142+
t.setNavigationIcon(android.R.drawable.ic_menu_close_clear_cancel);
133143
View dialog = LayoutInflater.from(requireContext()).inflate(R.layout.edit_entry,null);
134144
((EditText) dialog.findViewById(R.id.editentryTitle)).setText(e.config.get("title"));
135145
((EditText) dialog.findViewById(R.id.editentryTitle)).addTextChangedListener(new ConfigTextWatcher(proposed, "title"));
@@ -145,17 +155,29 @@ public ViewHolder(View view) {
145155
dialog.findViewById(R.id.editentryDataPart).setEnabled(false);
146156
((EditText) dialog.findViewById(R.id.editentrySysPart)).setText(e.config.get("xsystem"));
147157
dialog.findViewById(R.id.editentrySysPart).setEnabled(false);
148-
new AlertDialog.Builder(requireContext())
158+
AlertDialog d = new AlertDialog.Builder(requireContext())
149159
.setCancelable(true)
150-
.setNeutralButton(R.string.cancel, (p1, p2) -> p1.dismiss())
160+
.setNeutralButton(R.string.kernel_update, (p1, p2) -> {
161+
if (e.config.get("xsystem").equals("real") || e.config.get("xdata").equals("real")) {
162+
new AlertDialog.Builder(requireContext())
163+
.setTitle(R.string.failed)
164+
.setMessage(R.string.update_real_rom)
165+
.setCancelable(true)
166+
.setNegativeButton(R.string.ok, (d2, p) -> d2.dismiss())
167+
.show();
168+
return;
169+
}
170+
current = e;
171+
startActivity(new Intent(requireActivity(), WizardActivity.class).putExtra("StartFragment", UpROMWelcomeWizardPageFragment.class));
172+
})
151173
.setNegativeButton(R.string.delete, (p1, p2) -> MiscUtils.sure(requireContext(), p1, getString(R.string.delete_msg_2, e.config.get("title")), (p112, p212) -> {
152174
if (e.config.get("xsystem") != null && e.config.get("xdata") != null)
153175
if (e.config.get("xsystem").equals("real") || e.config.get("xdata").equals("real")) {
154176
new AlertDialog.Builder(requireContext())
155177
.setTitle(R.string.failed)
156178
.setMessage(R.string.delete_real_rom)
157179
.setCancelable(true)
158-
.setNegativeButton(R.string.ok, (d, p) -> d.dismiss())
180+
.setNegativeButton(R.string.ok, (d2, p) -> d2.dismiss())
159181
.show();
160182
return;
161183
}
@@ -170,9 +192,10 @@ public ViewHolder(View view) {
170192
e.save();
171193
updateEntries();
172194
})
173-
.setTitle(R.string.edit_entry)
195+
.setCustomTitle(t)
174196
.setView(dialog)
175197
.show();
198+
t.setNavigationOnClickListener(a -> d.dismiss());
176199
});
177200
}
178201

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@
116116
<string name="data_part">OS User data</string>
117117
<string name="data">Data</string>
118118
<string name="system">System</string>
119+
<string name="update_real_rom">You cannot update your real ROM via ABM!</string>
120+
<string name="kernel_update">Kernel Update</string>
121+
<string name="kernel_update_msg">You are about to update the kernel/boot image of the selected ROM and regenerate it\'s config.</string>
119122
<string name="select_part">Please select an unused partition on your SD card configured with the following type: %1$s. Please make sure it really is the correct one, you can cancel and label it if unsure. If you didn\'t create one yet, do that first.</string>
120123
<!-- How an partition is used -->
121124
<string name="usage">Usage</string>

0 commit comments

Comments
 (0)