99import android .widget .ImageView ;
1010import android .widget .TextView ;
1111import android .widget .Toast ;
12+ import android .widget .Toolbar ;
1213
1314import androidx .annotation .NonNull ;
1415import androidx .appcompat .app .AlertDialog ;
2526import com .topjohnwu .superuser .io .SuFile ;
2627
2728import org .androidbootmanager .app .R ;
29+ import org .androidbootmanager .app .roms .ROM ;
2830import org .androidbootmanager .app .ui .addrom .AddROMWelcomeWizardPageFragment ;
31+ import org .androidbootmanager .app .ui .addrom .UpROMWelcomeWizardPageFragment ;
2932import org .androidbootmanager .app .ui .home .InstalledViewModel ;
33+ import org .androidbootmanager .app .ui .installer .InstallerWelcomeWizardPageFragment ;
3034import org .androidbootmanager .app .ui .wizard .WizardActivity ;
35+ import org .androidbootmanager .app .ui .wizard .WizardViewModel ;
3136import org .androidbootmanager .app .util .ActionAbortedCleanlyError ;
3237import org .androidbootmanager .app .util .ConfigFile ;
3338import 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
0 commit comments