2828import com .afollestad .materialdialogs .MaterialDialog ;
2929import com .melnykov .fab .FloatingActionButton ;
3030
31+ import org .efidroid .efidroidmanager .AppConstants ;
3132import org .efidroid .efidroidmanager .DataHelper ;
3233import org .efidroid .efidroidmanager .R ;
3334import org .efidroid .efidroidmanager .RootToolsEx ;
@@ -49,21 +50,20 @@ public class MainActivity extends AppCompatActivity
4950 OperatingSystemFragment .OnOperatingSystemFragmentInteractionListener ,
5051 DataHelper .DeviceInfoLoadCallback , InstallFragment .OnInstallFragmentInteractionListener {
5152
53+ // args
54+ private static final String ARG_DEVICE_INFO = "deviceinfo" ;
55+ private static final String ARG_ACTIVEMENU_ID = "activemenu_id" ;
56+ private static final String ARG_HAS_ROOT = "has_root" ;
57+ private static final String ARG_OPERATING_SYSTEMS = "operating_systems" ;
58+ private static final String ARG_INSTALL_STATUS = "install_status" ;
5259 // status
5360 private boolean hasRoot = false ;
5461 private boolean mTouchDisabled = false ;
5562 private int mActiveMenuItemId = 0 ;
5663 private MenuItem mPreviousMenuItem ;
5764 private AsyncTask <?, ?, ?> mFragmentLoadingTask = null ;
58-
5965 // data
6066 private DeviceInfo mDeviceInfo = null ;
61-
62- // args
63- private static final String ARG_DEVICE_INFO = "deviceinfo" ;
64- private static final String ARG_ACTIVEMENU_ID = "activemenu_id" ;
65- private static final String ARG_HAS_ROOT = "has_root" ;
66-
6767 // UI
6868 private NavigationView mNavigationView ;
6969 private FloatingActionButton mFab ;
@@ -75,10 +75,10 @@ public class MainActivity extends AppCompatActivity
7575 private CollapsingToolbarLayout mCollapsingToolbarLayout ;
7676 private AppBarLayout mAppBarLayout ;
7777 private FrameLayout mToolbarFrameLayout ;
78-
7978 // operating systems
8079 private ArrayList <OperatingSystem > mOperatingSystems ;
81- private static final String ARG_OPERATING_SYSTEMS = "operating_systems" ;
80+ // installation
81+ private InstallationStatus mInstallStatus = null ;
8282
8383 private AsyncTask <Void , Void , Exception > makeOperatingSystemsTask () {
8484 final ArrayList <OperatingSystem > list = new ArrayList <>();
@@ -158,10 +158,6 @@ protected void onPostExecute(Exception e) {
158158 };
159159 }
160160
161- // installation
162- private InstallationStatus mInstallStatus = null ;
163- private static final String ARG_INSTALL_STATUS = "install_status" ;
164-
165161 private AsyncTask <Void , Void , Exception > makeInstallationStatusTask (final InstallFragment .InstallStatusLoadCallback callback ) {
166162 final InstallationStatus installStatus = new InstallationStatus ();
167163
@@ -286,15 +282,31 @@ public void onDeviceInfoLoadError(Exception e) {
286282 new MaterialDialog .Builder (this )
287283 .title (R .string .error )
288284 .content (getString (R .string .cant_load_device_info_check_connection ) + e .getLocalizedMessage ())
289- .positiveText (R .string .try_again )
285+ .positiveText (R .string .try_again ). neutralText ( R . string . override_ota_server )
290286 .cancelable (false ).onPositive (new MaterialDialog .SingleButtonCallback () {
291287 @ Override
292288 public void onClick (@ NonNull MaterialDialog dialog , @ NonNull DialogAction which ) {
293289 DataHelper .loadDeviceInfo (MainActivity .this , MainActivity .this );
294290 }
291+ }).onNeutral (new MaterialDialog .SingleButtonCallback () {
292+ @ Override
293+ public void onClick (@ NonNull MaterialDialog dialog , @ NonNull DialogAction which ) {
294+ showOverrideOTAServerDialog ();
295+ }
295296 }).show ();
296297 }
297298
299+ public void showOverrideOTAServerDialog () {
300+ new MaterialDialog .Builder (MainActivity .this ).title (R .string .override_ota_server )
301+ .input (null , AppConstants .getUrlServerConfig (MainActivity .this ), new MaterialDialog .InputCallback () {
302+ @ Override
303+ public void onInput (@ NonNull MaterialDialog dialog , CharSequence input ) {
304+ AppConstants .setUrlServerConfig (MainActivity .this , input .toString ());
305+ DataHelper .loadDeviceInfo (MainActivity .this , MainActivity .this );
306+ }
307+ }).show ();
308+ }
309+
298310 private void onLoadUiData () {
299311 if (!hasRoot && !RootToolsEx .isAccessGiven (0 , 0 )) {
300312 new MaterialDialog .Builder (this )
@@ -485,6 +497,10 @@ public void onRefresh() {
485497 } else {
486498 fragment = new InstallFragment ();
487499 }
500+ } else if (id == R .id .nav_override_ota ) {
501+ mDrawer .closeDrawer (GravityCompat .START );
502+ showOverrideOTAServerDialog ();
503+ return true ;
488504 }
489505
490506 mActiveMenuItemId = item .getItemId ();
0 commit comments