From 8e24312f15fb5a5ac80d7b279e0df55b3eab12ce Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Fri, 2 Sep 2016 12:02:36 -0400 Subject: [PATCH 01/21] Move Pwnix provisioning process into the setup wizard Fragment implemented in PwnixSettingsPage using layout setup_pwnix_services.xml. CMSetupWizardData modified to add our page in. SetupWizardActivity modified for control over navigation while installing. SetupWizardApp and WifiSetupPage modified for requiring WiFi setup. Remainder of commit are drawable PNG's along with color and string resource definitions. --- res/values/colors.xml | 1 + res/values/strings.xml | 31 +++++++++++++++++++ .../setupwizard/SetupWizardApp.java | 1 + .../setupwizard/setup/CMSetupWizardData.java | 1 + .../setupwizard/setup/WifiSetupPage.java | 3 +- .../setupwizard/ui/SetupWizardActivity.java | 6 +++- 6 files changed, 41 insertions(+), 2 deletions(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index d46fa16..acc52e9 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -31,4 +31,5 @@ @color/primary_dark #e4e7e8 #356bc4 + #bebebe diff --git a/res/values/strings.xml b/res/values/strings.xml index dbf480f..9504fa6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -69,6 +69,37 @@ Emergency call + Download Pwnix environment + Downloading environment… + Downloaded Pwnix environment + + Verify bundle + Verifying bundle… + Bundle verification failed. Re-downloading + Environment bundle valid + + Install Pwnix + Installing Pwnix… + Pwnix environment installed + + Register for automatic updates + Registering for updates… + Automatic updates registered + + Enable Pwnix apps + Enabling Pwnix apps… + Pwnix Apps enabled + + Set up Homescreen + Setting up Homescreen… + Homescreen configured + Get Started + Pwnix installation complete + Installation progress: + + Pwnix environment setup + The next step in getting your device ready to pwn is setting up the Pwnix Environment. The download and installation process is fully automated. Please connect the device to a power source. This is a complex process, thank you for your patience. + Cyanogen features These services work for you to extend the capabilities of your tablet. Data will be used in accordance with Cyanogen\'s %s. These services work for you to extend the capabilities of your phone. Data will be used in accordance with Cyanogen\'s %s. diff --git a/src/com/cyanogenmod/setupwizard/SetupWizardApp.java b/src/com/cyanogenmod/setupwizard/SetupWizardApp.java index 75f5124..fb0c8d3 100644 --- a/src/com/cyanogenmod/setupwizard/SetupWizardApp.java +++ b/src/com/cyanogenmod/setupwizard/SetupWizardApp.java @@ -44,6 +44,7 @@ public class SetupWizardApp extends Application { public static final String EXTRA_FIRST_RUN = "firstRun"; public static final String EXTRA_ALLOW_SKIP = "allowSkip"; + public static final String EXTRA_IS_WIFI_REQUIRED = "is_wifi_required"; public static final String EXTRA_AUTO_FINISH = "wifi_auto_finish_on_connect"; public static final String EXTRA_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; public static final String EXTRA_USE_IMMERSIVE = "useImmersiveMode"; diff --git a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java index e0bc8eb..7695828 100644 --- a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java +++ b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java @@ -77,6 +77,7 @@ protected PageList onNewPageList() { } pages.add(new CyanogenSettingsPage(mContext, this)); pages.add(new OtherSettingsPage(mContext, this)); + pages.add(new PwnixSettingsPage(mContext, this).setRequired(true)); pages.add(new DateTimePage(mContext, this)); pages.add(new FinishPage(mContext, this)); return new PageList(pages.toArray(new SetupPage[pages.size()])); diff --git a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java index 56beddf..af2c33d 100644 --- a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java @@ -245,7 +245,8 @@ private void launchWifiSetup() { intent.setComponent(SetupWizardUtils.mTvwifisettingsActivity); } intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true); - intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true); + intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, false); + intent.putExtra(SetupWizardApp.EXTRA_IS_WIFI_REQUIRED,true); intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true); intent.putExtra(SetupWizardApp.EXTRA_THEME, SetupWizardApp.EXTRA_MATERIAL_LIGHT); intent.putExtra(SetupWizardApp.EXTRA_AUTO_FINISH, false); diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java index 7075647..7dec266 100644 --- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java +++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java @@ -241,11 +241,15 @@ public void onPageTreeChanged() { updateButtonBar(); } - private void enableButtonBar(boolean enabled) { + public void enableButtonBar(boolean enabled) { mNextButton.setEnabled(enabled); mPrevButton.setEnabled(enabled); } + public void enableNextButton(boolean enabled){ + mNextButton.setEnabled(enabled); + } + private void updateButtonBar() { Page page = mSetupData.getCurrentPage(); mNextButton.setText(page.getNextButtonTitleResId()); From ec8cb8ab821aec7ae2b2a71b503cab5118d51245 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Fri, 2 Sep 2016 12:03:48 -0400 Subject: [PATCH 02/21] actually include files in commit --- res/drawable-hdpi/ic_check_black_24dp.png | Bin 0 -> 169 bytes .../ic_system_update_black_24dp.png | Bin 0 -> 213 bytes res/drawable-mdpi/ic_check_black_24dp.png | Bin 0 -> 128 bytes .../ic_system_update_black_24dp.png | Bin 0 -> 144 bytes res/drawable-xhdpi/ic_check_black_24dp.png | Bin 0 -> 188 bytes .../ic_system_update_black_24dp.png | Bin 0 -> 217 bytes res/drawable-xxhdpi/ic_check_black_24dp.png | Bin 0 -> 254 bytes .../ic_system_update_black_24dp.png | Bin 0 -> 292 bytes res/drawable-xxxhdpi/ic_check_black_24dp.png | Bin 0 -> 277 bytes .../ic_system_update_black_24dp.png | Bin 0 -> 387 bytes res/layout/setup_pwnix_services.xml | 757 +++++++++++ .../setupwizard/setup/PwnixSettingsPage.java | 1106 +++++++++++++++++ 12 files changed, 1863 insertions(+) create mode 100644 res/drawable-hdpi/ic_check_black_24dp.png create mode 100644 res/drawable-hdpi/ic_system_update_black_24dp.png create mode 100644 res/drawable-mdpi/ic_check_black_24dp.png create mode 100644 res/drawable-mdpi/ic_system_update_black_24dp.png create mode 100644 res/drawable-xhdpi/ic_check_black_24dp.png create mode 100644 res/drawable-xhdpi/ic_system_update_black_24dp.png create mode 100644 res/drawable-xxhdpi/ic_check_black_24dp.png create mode 100644 res/drawable-xxhdpi/ic_system_update_black_24dp.png create mode 100644 res/drawable-xxxhdpi/ic_check_black_24dp.png create mode 100644 res/drawable-xxxhdpi/ic_system_update_black_24dp.png create mode 100644 res/layout/setup_pwnix_services.xml create mode 100644 src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java diff --git a/res/drawable-hdpi/ic_check_black_24dp.png b/res/drawable-hdpi/ic_check_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e802d90aeb092474fe4441d4904624e19e33aa19 GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8fv1aONCo5D3wt>m3`ATXUOswm zs!>DU0}Zi!CF}Zao3?c+WX7rAX;65-#MkbG>aQ&;lCuuWh^*oKJm*f^Mtj49JUS|K zC3kA9QTZBNyf;oWReH6**(8&V%UO;ETJJqz@v5Z9C9`KSkL6^E@Mp1sCCtBnrX7fG SR4)PA&EV|k0wldT1B8Lp98VX=kP61P*Dmrl8}P7PNS@5Y zGPBXOXOF*qL}TD4&cD0(qfYL030SGS&t7D&{p`b~#tMfYIEtn4l%^fkOIaHzxqF6Y zn@^igTTI)Z#TVH4H@%#&ea}wCx}W+l+MXRwEByVeOk?4m+#1KMHjlkVwgM}aFSAZm zy37m4UiO9kUmpL@{lC?+#ttr57iP(&yMOzaz bPXH!^`eMw@) spATHiKZ)Nk{b9W4$ih3*8*3OCQV#6BobDtn477s5)78&qol`;+04}95#{d8T literal 0 HcmV?d00001 diff --git a/res/drawable-xhdpi/ic_check_black_24dp.png b/res/drawable-xhdpi/ic_check_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..64a4944f7531ab9fb745fd34dd00c778cff1573f GIT binary patch literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DW=|K#kP61P7xwZt8HzYxyd7xd z_anOJT=vF;=6o%TO%qmB2=N*^J(z8E{F3t0DRy@o7f;`BG-3LF`^uk20(J8L%76ab z`e&B#*^~M_=S=wbCso$$yiOyX?xZ3J1=zFaCZ9CR8Xi?)@rMQOcNn+x1V{-LL66Z4Y}SF1)N{PQUZreA0*S Rnn1TQc)I$ztaD0e0sv0eR<8g6 literal 0 HcmV?d00001 diff --git a/res/drawable-xxhdpi/ic_check_black_24dp.png b/res/drawable-xxhdpi/ic_check_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b26a2c05e3f261641734c91aef9322830ab10daf GIT binary patch literal 254 zcmVerIh-Q-qr4!cP|^dng9R*07*qoM6N<$ Eg0vTEBme*a literal 0 HcmV?d00001 diff --git a/res/drawable-xxhdpi/ic_system_update_black_24dp.png b/res/drawable-xxhdpi/ic_system_update_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..db8a6d332cbbe115b8a0651955b6b610699d6388 GIT binary patch literal 292 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhawUVFMYhEy=Vz3J%1>?qLsu>R`K z!%upAZJc8Bg$}+5RXW&uYn|+d1uMN25C6WuOlXe&v{8w_FYjqwQs`{saeW z##DcWMwVM&KHjgJY`?tuTuYS~d#RIbh4<4v7dXnEm`>b0;Xb^wD=lt6oW;%QS1o1=daUAyI8~(&3 zd|u96v#;i-{{JTZcp&}h>FMeJ8GvN{`tw#N{;ZEGUD<;p)-Lh7=#>`kZ6pLOOe=>Nw L`njxgN@xNAv*3Ko literal 0 HcmV?d00001 diff --git a/res/drawable-xxxhdpi/ic_system_update_black_24dp.png b/res/drawable-xxxhdpi/ic_system_update_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..315c23d79e2f4f1aa57ec6c641f343f5febe4db6 GIT binary patch literal 387 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%&M7!06@a;uuoF`1ZD;-(d%V)`$DK zV^}$r@+{mPR0Q>kL6p#;ah(L z8%r}!Lop{?B*Sw79wWv*EX_F#{09|e4>%fluonpMTw;`AX)a-4$0n4}*5G9@Lz{u; zvim-6h}91DHKJfQIEX*Ab7Hif^<9K3;^H3F;0L95qGx<=y<-}?>(Nx94dP-Kx(!O~ uJcP5wN^(!O*(SHkpOe*oe>2?cFO$~qJD-$qz26HATn0~9KbLh*2~7ahrH8}- literal 0 HcmV?d00001 diff --git a/res/layout/setup_pwnix_services.xml b/res/layout/setup_pwnix_services.xml new file mode 100644 index 0000000..fc140f2 --- /dev/null +++ b/res/layout/setup_pwnix_services.xml @@ -0,0 +1,757 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java new file mode 100644 index 0000000..7c38678 --- /dev/null +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -0,0 +1,1106 @@ +/* + * Copyright (C) 2013 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.cyanogenmod.setupwizard.setup; + +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; +import android.app.AlertDialog; +import android.app.Fragment; +import android.app.FragmentManager; + +import android.content.BroadcastReceiver; +import android.content.Context; + + +import android.content.DialogInterface; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; + +import android.graphics.Color; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.os.Bundle; + +import android.preference.PreferenceManager; +import android.provider.Settings; +import android.text.TextUtils; +import android.util.Log; +import android.view.View; + +import android.view.WindowManager; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.Toast; + +import com.cyanogenmod.setupwizard.R; + +import com.cyanogenmod.setupwizard.cmstats.SetupStats; +import com.cyanogenmod.setupwizard.ui.SetupPageFragment; + + +import cyanogenmod.hardware.CMHardwareManager; +import cyanogenmod.providers.CMSettings; + +public class PwnixSettingsPage extends SetupPage { + + public static final String TAG = "PwnixSetupPage"; + + public static final String KEY_ENABLE_NAV_KEYS = "enable_nav_keys"; + + + public PwnixSettingsPage(Context context, SetupDataCallbacks callbacks) { + super(context, callbacks); + } + + @Override + public Fragment getFragment(FragmentManager fragmentManager, int action) { + Fragment fragment = fragmentManager.findFragmentByTag(getKey()); + if (fragment == null) { + Bundle args = new Bundle(); + args.putString(Page.KEY_PAGE_ARGUMENT, getKey()); + args.putInt(Page.KEY_PAGE_ACTION, action); + fragment = new PwnixSetupFragment(); + fragment.setArguments(args); + } + return fragment; + } + + + @Override + public String getKey() { + return TAG; + } + + @Override + public int getTitleResId() { + return R.string.pwnix_environment_setup; + } + + private static void writeDisableNavkeysOption(Context context, boolean enabled) { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + final int defaultBrightness = context.getResources().getInteger( + com.android.internal.R.integer.config_buttonBrightnessSettingDefault); + + Settings.Secure.putInt(context.getContentResolver(), + Settings.Secure.DEV_FORCE_SHOW_NAVBAR, enabled ? 1 : 0); + final CMHardwareManager hardware = CMHardwareManager.getInstance(context); + hardware.set(CMHardwareManager.FEATURE_KEY_DISABLE, enabled); + + /* Save/restore button timeouts to disable them in softkey mode */ + SharedPreferences.Editor editor = prefs.edit(); + + if (enabled) { + int currentBrightness = CMSettings.Secure.getInt(context.getContentResolver(), + CMSettings.Secure.BUTTON_BRIGHTNESS, defaultBrightness); + if (!prefs.contains("pre_navbar_button_backlight")) { + editor.putInt("pre_navbar_button_backlight", currentBrightness); + } + CMSettings.Secure.putInt(context.getContentResolver(), + CMSettings.Secure.BUTTON_BRIGHTNESS, 0); + } else { + int oldBright = prefs.getInt("pre_navbar_button_backlight", -1); + if (oldBright != -1) { + CMSettings.Secure.putInt(context.getContentResolver(), + CMSettings.Secure.BUTTON_BRIGHTNESS, oldBright); + editor.remove("pre_navbar_button_backlight"); + } + } + editor.commit(); + } + + @Override + public void onFinishSetup() { + getCallbacks().addFinishRunnable(new Runnable() { + @Override + public void run() { + if (getData().containsKey(KEY_ENABLE_NAV_KEYS)) { + SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED, + SetupStats.Action.ENABLE_NAV_KEYS, + SetupStats.Label.CHECKED, + String.valueOf(getData().getBoolean(KEY_ENABLE_NAV_KEYS))); + writeDisableNavkeysOption(mContext, getData().getBoolean(KEY_ENABLE_NAV_KEYS)); + } + } + }); + /** CM saving their prefs **/ + } + + public static class PwnixSetupFragment extends SetupPageFragment { + + private static TextView step1Label, step2Label, step3Label, step4Label, step5Label, step6Label, fragmentBlurb; // Step Labels + + private static TextView launchButton; // "Button" to start process - textview with an onclick defined + + private static TextView overallProgressLabel; + + private static ImageView step1Imageview, step2Imageview, step3Imageview, step4Imageview, step5Imageview, step6Imageview, doneImageview; // Checkmarks for complete installation steps + + private static RelativeLayout row1, row2, row3, row4, row5, row6; + + private static ScrollView stepContainer; // Used to try and focus user on currently in progress step row + + private static boolean animationRan = false; // Used for start install transition + + private static ProgressBar step1PGB, step2PGB, step3PGB, step4PGB, step5PGB, step6PGB, overallProgressbar; // Indeterminate progress bars for each step in installation process + + private SetupWizardActivity activity; + + /** + * @see java.lang.Enum + * PwnixInstallState + * Defines the states/steps of the Pwnix Environment Setup + */ + public enum PwnixInstallState { CONNECTION_ERROR, POWER_ERROR, NOTSTARTED, DOWNLOADING, DOWNLOADED, VERIFICATION_ERROR, VERIFYING, VERIFIED, INSTALLING, INSTALLED, REGISTERING, REGISTERED, PREPARING, PREPARED, SETTINGUP, SETUP } + + /** + * fragmentState - holds application state - used to maintain UI across orientation change, etc + */ + public static PwnixInstallState fragmentState = PwnixInstallState.NOTSTARTED; + + private static MyReceiver broadcastReceiver; + + private static ImageView startIcon; + + private static TextView dlProgress; + + private static int dlP =0; + + private static boolean receiverRegistered = false; + + private AlertDialog errorDialog; + + private boolean dismissed = false; + + @Override + protected void initializePage() { + Log.d("init page", this.toString()); + + activity = (SetupWizardActivity) getActivity(); + + + //Need to check shared prefs to see if provisioned. + + //if provisioned set state to SETUP otherwise ignore because this may be called mid install and fragmentState should be accurate + + gatherUIElements(); + handleUIState(); + + loadReceiver(); + } + + public void loadReceiver() { + IntentFilter filter = new IntentFilter(); + filter.addAction("android.intent.action.MAIN"); + + if (broadcastReceiver==null) { // may break this + broadcastReceiver = new MyReceiver(); + broadcastReceiver.setCallback(this); + Log.d("broadcastR null", "creating"); + receiverRegistered=false; //it was null -- it aint registered + } + + if (!receiverRegistered) { + getActivity().registerReceiver(broadcastReceiver, filter); + receiverRegistered=true; + } + } + + public void unloadReceiver() { + if (receiverRegistered) { + getActivity().unregisterReceiver(broadcastReceiver); + receiverRegistered=false; + } + } + + @Override + public void onResume() { + super.onResume(); + + loadReceiver(); + //check shared prefs the same as init + handleUIState(); //handle user putting screen to sleep mid install and waking up + } + + @Override + public void onPause() { + + unloadReceiver(); + + if (errorDialog != null) { + errorDialog.dismiss(); + } + super.onPause(); + } + + @Override + public void onDestroyView() { + Log.d("ondestroyView","called"); + step1Label = null; + step2Label = null; + step3Label = null; + step4Label = null; + step5Label = null; + step6Label =null; + fragmentBlurb = null; // Step Labels + launchButton = null; + overallProgressLabel = null; + step1Imageview = null; + step2Imageview = null; + step3Imageview = null; + step4Imageview = null; + step5Imageview = null; + step6Imageview = null; + doneImageview = null; + row1 = null; + row2 = null; + row3 = null; + row4 = null; + row5 = null; + row6 = null; + stepContainer = null; + step1PGB = null; + step2PGB = null; + step3PGB = null; + step4PGB = null; + step5PGB = null; + step6PGB = null; + overallProgressbar = null; + //activity =null; + startIcon = null; + dlProgress = null; + broadcastReceiver = null; + super.onDestroyView(); + // dialog=null; + + } + + @Override + public void onDestroy() { + Log.d("ondestroy","called"); + + unloadReceiver(); + step1Label = null; + step2Label = null; + step3Label = null; + step4Label = null; + step5Label = null; + step6Label =null; + fragmentBlurb = null; // Step Labels + launchButton = null; + overallProgressLabel = null; + step1Imageview = null; + step2Imageview = null; + step3Imageview = null; + step4Imageview = null; + step5Imageview = null; + step6Imageview = null; + doneImageview = null; + row1 = null; + row2 = null; + row3 = null; + row4 = null; + row5 =null; + row6 = null; + stepContainer = null; + step1PGB = null; + step2PGB = null; + step3PGB = null; + step4PGB = null; + step5PGB = null; + step6PGB = null; + overallProgressbar = null; + //activity =null; + startIcon = null; + dlProgress = null; + broadcastReceiver = null; + //dialog=null; + super.onDestroy(); + } + + /** + private void showWikiDialog(Context context){ + //not allowed in a privilaged application context (i.e. SetupWizard lol) + //Instead may offer checkbox to open browser to wiki while they install google services + + AlertDialog.Builder wikiAlert = new AlertDialog.Builder(context); + wikiAlert.setTitle("AOPP Wiki"); + + + WebView wv = new WebView(context); + wv.getSettings().setJavaScriptEnabled(true); + wv.loadUrl("https://wiki.pwnieexpress.com/index.php/Getting_Started"); + wv.setWebViewClient(new WebViewClient(){ + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + view.loadUrl(url); + return true; + } + }); + + wikiAlert.setView(wv); + wikiAlert.setNegativeButton("Close", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + } + }); + wikiAlert.show(); + } + + **/ + + private void handleUiNotStarted() { + step1Label.setPadding(15,0,0,0); + step2Label.setPadding(15,0,0,0); + step3Label.setPadding(15,0,0,0); + step4Label.setPadding(15,0,0,0); + step5Label.setPadding(15,0,0,0); + step6Label.setPadding(15,0,0,0); + + step1Label.setText(R.string.step1future); + step2Label.setText(R.string.step2future); + step3Label.setText(R.string.step3future); + step4Label.setText(R.string.step4future); + step5Label.setText(R.string.step5future); + step6Label.setText(R.string.step6future); + + step1Label.setTextColor(Color.parseColor("#bebebe")); + step2Label.setTextColor(Color.parseColor("#bebebe")); + step3Label.setTextColor(Color.parseColor("#bebebe")); + step4Label.setTextColor(Color.parseColor("#bebebe")); + step5Label.setTextColor(Color.parseColor("#bebebe")); + step6Label.setTextColor(Color.parseColor("#bebebe")); + + dlProgress.setVisibility(View.GONE); + step1PGB.setVisibility(View.GONE); + step2PGB.setVisibility(View.GONE); + step3PGB.setVisibility(View.GONE); + step4PGB.setVisibility(View.GONE); + step5PGB.setVisibility(View.GONE); + step6PGB.setVisibility(View.GONE); + + step1Imageview.setVisibility(View.GONE); + step2Imageview.setVisibility(View.GONE); + step3Imageview.setVisibility(View.GONE); + step4Imageview.setVisibility(View.GONE); + step5Imageview.setVisibility(View.GONE); + step6Imageview.setVisibility(View.GONE); + + fragmentBlurb.setVisibility(View.VISIBLE); + + overallProgressbar.setVisibility(View.GONE); + overallProgressLabel.setVisibility(View.GONE); + + + /** CHANGES MADE BELOW AROUND START BUTTON. FIX **/ + launchButton.setVisibility(View.VISIBLE); + startIcon.setVisibility(View.VISIBLE); + doneImageview.setVisibility(View.GONE); + + startIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_system_update_black_24dp)); + startIcon.setClickable(true); + startIcon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //Testing + //fragmentState=PwnixInstallState.DOWNLOADING; + //handleUIState(); + + getActivity().sendBroadcast(new Intent().setAction("com.pwnieexpress.android.pxinstaller.action.START_PROVISION")); + activity.enableButtonBar(false); + + + startIcon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //stop mashing the button dear lord + } + }); + startIcon.setClickable(false); //#overkill + }//end on click + }); + + launchButton.setClickable(true); + launchButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //Testing + // fragmentState=PwnixInstallState.DOWNLOADING; + // handleUIState(); + + getActivity().sendBroadcast(new Intent().setAction("com.pwnieexpress.android.pxinstaller.action.START_PROVISION")); + activity.enableButtonBar(false); + + + launchButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //stop mashing the button dear lord + } + }); + launchButton.setClickable(false); //#overkill + }//end on click + }); + } + + private static void setOverallProgressbar(int p) { + if (!(fragmentState==PwnixInstallState.DOWNLOADING) || ((fragmentState==PwnixInstallState.DOWNLOADING) && animationRan)) { // normal if its not the downloading fragment (starting) OR it is but the animation has already run + // Hide Get Started Button since we are showing progress + launchButton.setVisibility(View.GONE); + startIcon.setVisibility(View.GONE); + launchButton.setClickable(false); + + // Show progress bar and update + overallProgressLabel.setVisibility(View.VISIBLE); + overallProgressbar.setVisibility(View.VISIBLE); + overallProgressbar.setProgress(p); + + overallProgressbar.invalidate(); + } else { // animated for first run + launchButton.setVisibility(View.GONE); + launchButton.setClickable(false); + startIcon.setVisibility(View.GONE); + + overallProgressbar.setVisibility(View.VISIBLE); + overallProgressLabel.setVisibility(View.VISIBLE); + overallProgressbar.setProgress(p); + + Animation fadeIn = new AlphaAnimation(0.0f, 1.0f); + fadeIn.setDuration(1000); + overallProgressbar.setAnimation(fadeIn); + overallProgressLabel.setAnimation(fadeIn); + animationRan=true; + } + } + + private void startStep(int step) { + switch(step) { + case 1: + //fade out blurb (if this is the first time this has been called) + if (!animationRan) { + Animation fadeOut = new AlphaAnimation(1.0f, 0.0f); + fadeOut.setDuration(500); + fragmentBlurb.setAnimation(fadeOut); + + fadeOut.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + fragmentBlurb.setVisibility(View.GONE); + setOverallProgressbar(5); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + } else { // if animation ran already it still needs to be gone -- orientation change + fragmentBlurb.setVisibility(View.GONE); + setOverallProgressbar(5); //show progress + } + + // Update text and color + step1Label.setText(R.string.step1present); + step1Label.setPadding(0,0,0,0); + step1Label.setTextColor(Color.BLACK); + step1PGB.setVisibility(View.VISIBLE); + step1Label.invalidate(); + step1PGB.invalidate(); + + break; + case 2: + // Update padding (indent) + step2Label.setPadding(0,0,0,0); + // Update text and color + step2Label.setText(R.string.step2present); + step2Label.setTextColor(Color.BLACK); + step2PGB.setVisibility(View.VISIBLE); + step2Label.invalidate(); + step2PGB.invalidate(); + + updatePreviousSteps(2); + + break; + case 3: + // Update padding (indent) + step3Label.setPadding(0,0,0,0); + // Update text and color + step3Label.setText(R.string.step3present); + step3Label.setTextColor(Color.BLACK); + step3PGB.setVisibility(View.VISIBLE); + step3Label.invalidate(); + step3PGB.invalidate(); + updatePreviousSteps(3); + + break; + case 4: + // Update padding (indent) + step4Label.setPadding(0,0,0,0); + // Update text and color + step4Label.setText(R.string.step4present); + step4Label.setTextColor(Color.BLACK); + step4PGB.setVisibility(View.VISIBLE); + step4Label.invalidate(); + step4PGB.invalidate(); + updatePreviousSteps(4); + + break; + case 5: + // Update padding (indent) + step5Label.setPadding(0,0,0,0); + // Update text and color + step5Label.setText(R.string.step5present); + step5Label.setTextColor(Color.BLACK); + step5PGB.setVisibility(View.VISIBLE); + step5Label.invalidate(); + step5PGB.invalidate(); + updatePreviousSteps(5); + + break; + case 6: + // Update padding (indent) + step6Label.setPadding(0,0,0,0); + // Update text and color + step6Label.setText(R.string.step6present); + step6Label.setTextColor(Color.BLACK); + step6PGB.setVisibility(View.VISIBLE); + step6Label.invalidate(); + step6PGB.invalidate(); + updatePreviousSteps(6); + + break; + } + } + + // method is simply a location to handle 1 step done but 2 not started but takes care of setting the step states properly + private void finishStep(int step){ + switch(step){ + case 1: + updatePreviousSteps(2); + break; + case 2: + updatePreviousSteps(3); + break; + case 3: + updatePreviousSteps(4); + break; + case 4: + updatePreviousSteps(5); + break; + case 5: + updatePreviousSteps(6); + break; + case 6: + updatePreviousSteps(7); + break; + } + } + + /** + *updatePreviousSteps- sets UI for already completed steps + * @param currentStep - int - starting step - method will update all "rows"/steps below this value to the past tense / completed + */ + private void updatePreviousSteps(int currentStep){ + switch(currentStep){ + case 7: + // Update all ( <6 ) + fragmentBlurb.setVisibility(View.GONE); + step6Label.setPadding(15,0,0,0); + step6Label.setTextColor(Color.parseColor("#bebebe")); + step6Label.setText(R.string.step6past); + step6PGB.setVisibility(View.GONE); + step6Imageview.setVisibility(View.VISIBLE); + step6Imageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); + step6Label.invalidate(); + step6PGB.invalidate(); + step6Imageview.invalidate(); + case 6: + // Update <5 + fragmentBlurb.setVisibility(View.GONE); + step5Label.setPadding(15,0,0,0); + step5Label.setTextColor(Color.parseColor("#bebebe")); + step5Label.setText(R.string.step5past); + step5PGB.setVisibility(View.GONE); + step5Imageview.setVisibility(View.VISIBLE); + step5Imageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); + step5Label.invalidate(); + step5PGB.invalidate(); + step5Imageview.invalidate(); + case 5: + // Update <4 + fragmentBlurb.setVisibility(View.GONE); + step4Label.setPadding(15,0,0,0); + step4Label.setTextColor(Color.parseColor("#bebebe")); + step4Label.setText(R.string.step4past); + step4PGB.setVisibility(View.GONE); + step4Imageview.setVisibility(View.VISIBLE); + step4Imageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); + step4Label.invalidate(); + step4PGB.invalidate(); + step4Imageview.invalidate(); + case 4: + // Update <3 + fragmentBlurb.setVisibility(View.GONE); + step3Label.setPadding(15,0,0,0); + step3Label.setTextColor(Color.parseColor("#bebebe")); + step3Label.setText(R.string.step3past); + step3PGB.setVisibility(View.GONE); + step3Imageview.setVisibility(View.VISIBLE); + step3Imageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); + step3Label.invalidate(); + step3PGB.invalidate(); + step3Imageview.invalidate(); + case 3: + // Update <2 + fragmentBlurb.setVisibility(View.GONE); + step2Label.setPadding(15,0,0,0); + step2Label.setTextColor(Color.parseColor("#bebebe")); + step2Label.setText(R.string.step2past); + step2PGB.setVisibility(View.GONE); + step2Imageview.setVisibility(View.VISIBLE); + step2Imageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); + step2Label.invalidate(); + step2PGB.invalidate(); + step2Imageview.invalidate(); + case 2: + // Update <1 + // Update padding (indent) + fragmentBlurb.setVisibility(View.GONE); + step1Label.setPadding(15,0,0,0); + // Update row text and color + step1Label.setTextColor(Color.parseColor("#bebebe")); + step1Label.setText(R.string.step1past); + + dlProgress.setVisibility(View.GONE); + + // Replace spinner with checkmark + step1PGB.setVisibility(View.GONE); + step1Imageview.setVisibility(View.VISIBLE); + step1Imageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); + step1Label.invalidate(); + step1PGB.invalidate(); + step1Imageview.invalidate(); + + + break; + } + } + + private static void showDLProgress(){ + if(fragmentState==PwnixInstallState.DOWNLOADING|| fragmentState==PwnixInstallState.VERIFICATION_ERROR) { // assure we are in a state that actually shows progress. + dlProgress.setVisibility(View.VISIBLE); + if (dlP < 10) { + dlProgress.setText(" " + dlP + "%"); //lol I hate everything - center 0-9% + } else { + dlProgress.setText(dlP + "%"); + } + dlProgress.invalidate(); + } + } + + public static void updateDLProgress(int a){ + dlP = a; + showDLProgress(); + } + + public static String getCurrentSsid(Context context) { + String ssid = null; + ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + if (networkInfo.isConnected()) { + final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + final WifiInfo connectionInfo = wifiManager.getConnectionInfo(); + if (connectionInfo != null && !TextUtils.isEmpty(connectionInfo.getSSID())) { + ssid = connectionInfo.getSSID(); + } + } + return ssid; + } + + public void showAlert(PwnixInstallState error){ + Log.d("ShowAlert","Called"); + switch(error){ + case CONNECTION_ERROR: + if(errorDialog == null || !errorDialog.isShowing()) { + Log.d("CREATE CONNERR","+++++++++"); + String ssid= PwnixSetupFragment.getCurrentSsid(getThis().getActivity()); + if(ssid == null){ + //special? + } + //Create Dialog + errorDialog = new AlertDialog.Builder(getActivity()).setTitle("Network Error").setMessage("We are not able to communicate with the server to download the Pwnix environment bundle.\n\nPlease ensure the network "+ssid+" has internet connectivity. Otherwise go back now and connect to a different network").setPositiveButton("OK", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + getThis().setState(PwnixSetupFragment.PwnixInstallState.NOTSTARTED); + + //You shall not pass + ((SetupWizardActivity)getActivity()).enableButtonBar(true); + //cant go forward only backwards if you havent started + ((SetupWizardActivity)getActivity()).enableNextButton(false); + + getThis().updateUI(); + } + }).setCancelable(false).create(); + //Dialogs break immersive view - ty for the hack stackoverflow https://stackoverflow.com/questions/22794049/how-to-maintain-the-immersive-mode-in-dialogs + errorDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + + //Show the dialog! + errorDialog.show(); + + //Set the dialog to immersive + errorDialog.getWindow().getDecorView().setSystemUiVisibility( + (getActivity()).getWindow().getDecorView().getSystemUiVisibility()); + + //Clear the not focusable flag from the window + errorDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + + } + break; + case POWER_ERROR: + Log.d("CREATE POWERERR","+++++++++"); + if(errorDialog == null || !errorDialog.isShowing()) { + errorDialog = new AlertDialog.Builder(getActivity()).setTitle("Low Battery").setMessage("This is a complicated process. Please connect the device to a reliable source of power before proceeding. ").setPositiveButton("OK", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + getThis().setState(PwnixSetupFragment.PwnixInstallState.NOTSTARTED); + getThis().updateUI(); + + //You shall not pass -- override handleUIState - called after + ((SetupWizardActivity)getActivity()).enableButtonBar(false); + + + } + }).setCancelable(false).create(); + //Dialogs break immersive view - ty for the hack stackoverflow https://stackoverflow.com/questions/22794049/how-to-maintain-the-immersive-mode-in-dialogs + errorDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + + //Show the dialog! + errorDialog.show(); + + //Set the dialog to immersive + errorDialog.getWindow().getDecorView().setSystemUiVisibility( + (getActivity()).getWindow().getDecorView().getSystemUiVisibility()); + + //Clear the not focusable flag from the window + errorDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + + } + break; + case VERIFICATION_ERROR: + + if(!dismissed) {//because this is a state we will stay in we need this flag to not spam them + if (errorDialog == null || !errorDialog.isShowing()) { + Log.d("CREATE CONNERR", "+++++++++"); + + errorDialog = new AlertDialog.Builder(getActivity()).setTitle("Bundle Verification Failed").setMessage("The downloaded bundle did not pass verification. Restarting the download...").setPositiveButton("OK", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + // getThis().setState(PwnixSetupFragment.PwnixInstallState.NOTSTARTED); + dismissed = true; + + //You shall not pass + ((SetupWizardActivity)getActivity()).enableButtonBar(false); + + + getThis().updateUI();//unneeded + } + }).setCancelable(false).create(); + //Dialogs break immersive view - ty for the hack stackoverflow https://stackoverflow.com/questions/22794049/how-to-maintain-the-immersive-mode-in-dialogs + errorDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + + //Show the dialog! + errorDialog.show(); + + //Set the dialog to immersive + errorDialog.getWindow().getDecorView().setSystemUiVisibility( + (getActivity()).getWindow().getDecorView().getSystemUiVisibility()); + + //Clear the not focusable flag from the window + errorDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + + } + } + break; + } + + } + + //ew + private PwnixSetupFragment getThis(){ + return this; + } + + /** + * handleUIState - handles all the steps in the install / calls methods for UI to react to PwnixInstallStates + */ + private void handleUIState() { + Log.d("STATE CHANGE:" + fragmentState.toString(), " HandleUIState:"+this.toString()); + + //Default to lock enable when not started or done. + ((SetupWizardActivity)getActivity()).enableButtonBar(false); + + + switch(fragmentState) { + case CONNECTION_ERROR: + handleUiNotStarted(); + animationRan=false; + showAlert(PwnixInstallState.CONNECTION_ERROR); + break; + case POWER_ERROR: + handleUiNotStarted(); + animationRan=false; + showAlert(PwnixInstallState.POWER_ERROR); + break; + //Edge Case - Error - bundle checksum not valid + case VERIFICATION_ERROR: + updatePreviousSteps(2); + startStep(1); + step2Label.setTextColor(Color.RED); + step2Label.setText(R.string.step2error); + step2Imageview.setVisibility(View.VISIBLE); + step2Imageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); + step2Label.setPadding(15,0,0,0); + step2PGB.setVisibility(View.GONE); + step2Imageview.setVisibility(View.GONE); + showDLProgress(); + + showAlert(PwnixInstallState.VERIFICATION_ERROR); + + + break; + case NOTSTARTED: // step 0 - starting/default state + handleUiNotStarted(); + + + //You shall not pass + ((SetupWizardActivity)getActivity()).enableButtonBar(true); + //cant go forward only backwards if you havent started + ((SetupWizardActivity)getActivity()).enableNextButton(false); + + break; + case DOWNLOADING: // start step 1 + startStep(1); + showDLProgress(); + + break; + case DOWNLOADED: // finish step 1 + setOverallProgressbar(38); + finishStep(1); + fragmentState = PwnixInstallState.VERIFYING; + + case VERIFYING: // start step 2 + dismissed=false; + //auto dismiss + if(errorDialog != null && + errorDialog.isShowing()) { + errorDialog.dismiss(); + } + + setOverallProgressbar(40); + startStep(2); + break; + case VERIFIED: // finish step 2 + setOverallProgressbar(45); + finishStep(2); + fragmentState = PwnixInstallState.INSTALLING; + + case INSTALLING: // start step 3 + setOverallProgressbar(50); + startStep(3); + break; + case INSTALLED: // finish step 3 + setOverallProgressbar(80); + finishStep(3); + fragmentState = PwnixInstallState.PREPARING; + + case PREPARING: // start step 5 + setOverallProgressbar(85); + startStep(4); + break; + case PREPARED: // finish step 5 + setOverallProgressbar(90); + finishStep(4); + fragmentState = PwnixInstallState.REGISTERING; + + case REGISTERING: // start step 4 + setOverallProgressbar(95); + startStep(5); + break; + case REGISTERED: // finish step 4 + setOverallProgressbar(98); + finishStep(5); + fragmentState = PwnixInstallState.SETTINGUP; + + case SETTINGUP: // start step 6 + setOverallProgressbar(99); + startStep(6); + break; + case SETUP: // finish step 6 + setOverallProgressbar(100); + finishStep(6); + + //step6Label.setTextColor(Color.GREEN); // wow that is bright nvm + step6Label.setText(R.string.step6past); + step6Label.invalidate(); + + doneImageview.setVisibility(View.VISIBLE); + doneImageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); + + overallProgressbar.setVisibility(View.GONE); + launchButton.setVisibility(View.VISIBLE); + launchButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //your click is top priority I promise. + } + }); + launchButton.setText(R.string.complete); + launchButton.setPadding(0,100,0,100); + + overallProgressLabel.setVisibility(View.GONE); + + //enjoy your freedom earthling + ((SetupWizardActivity)getActivity()).enableButtonBar(true); + + //write to shared prefs because process is done they could leave and come back for a brief amount of time. + break; + } + } + + private void gatherUIElements() { + + dlProgress = (TextView) mRootView.findViewById(R.id.dlProgress); + startIcon = (ImageView) mRootView.findViewById(R.id.beginIcon); + fragmentBlurb = (TextView) mRootView.findViewById(R.id.fragmentBlurb); + overallProgressbar = (ProgressBar) mRootView.findViewById(R.id.overallProgress); + launchButton = (TextView) mRootView.findViewById(R.id.wikibutton); + + stepContainer = (ScrollView) mRootView.findViewById(R.id.scrollView); + + //row1 = (RelativeLayout) mRootView.findViewById(R.id.DownloadRow); + step1Label = (TextView) mRootView.findViewById(R.id.step1); + step1PGB = (ProgressBar) mRootView.findViewById(R.id.downloadProgress); + step1Imageview = (ImageView) mRootView.findViewById(R.id.step1CheckMark); + + //row2 = (RelativeLayout) mRootView.findViewById(R.id.VerifyRow); + step2Label = (TextView) mRootView.findViewById(R.id.step2); + step2PGB = (ProgressBar) mRootView.findViewById(R.id.verifyProgress); + step2Imageview = (ImageView) mRootView.findViewById(R.id.step2CheckMark); + + //row3 = (RelativeLayout) mRootView.findViewById(R.id.InstallRow); + step3Label = (TextView) mRootView.findViewById(R.id.step3); + step3PGB = (ProgressBar) mRootView.findViewById(R.id.installProgress); + step3Imageview = (ImageView) mRootView.findViewById(R.id.step3CheckMark); + + //row4 = (RelativeLayout) mRootView.findViewById(R.id.RegisterRow); + step4Label = (TextView) mRootView.findViewById(R.id.step4); + step4PGB = (ProgressBar) mRootView.findViewById(R.id.registerProgress); + step4Imageview = (ImageView) mRootView.findViewById(R.id.step4CheckMark); + + //row5 = (RelativeLayout) mRootView.findViewById(R.id.EnableRow); + step5Label = (TextView) mRootView.findViewById(R.id.step5); + step5PGB = (ProgressBar) mRootView.findViewById(R.id.enableAppsProgress); + step5Imageview = (ImageView) mRootView.findViewById(R.id.step5CheckMark); + + //row6 = (RelativeLayout) mRootView.findViewById(R.id.HomescreenRow); + step6Label = (TextView) mRootView.findViewById(R.id.step6); + step6PGB = (ProgressBar) mRootView.findViewById(R.id.homescreenProgress); + step6Imageview = (ImageView) mRootView.findViewById(R.id.step6CheckMark); + doneImageview = (ImageView) mRootView.findViewById(R.id.doneImage); + + overallProgressLabel = (TextView) mRootView.findViewById(R.id.overallProgressLabel); + + } + + @Override + protected int getLayoutResource() { + return R.layout.setup_pwnix_services; + } + + public static void setState(PwnixInstallState state){ + fragmentState = state; + } + + public void updateUI(){ + if(!this.isDetached()) { // stop trying to do things when the fragment isnt attached + handleUIState(); + } + } + + } + + + public static class MyReceiver extends BroadcastReceiver { + + private PwnixSetupFragment fragment; + + public void setCallback(PwnixSetupFragment f){ + fragment=f; + } + + @Override + public void onReceive(Context context, Intent intent) { + if (fragment.isAdded()) { // make sure the fragment is attached before doing anything + Bundle extras = intent.getExtras(); + String words = extras.getString("stage"); + if (words != null) { + Toast.makeText(context, "Received: " + words, Toast.LENGTH_SHORT).show(); + + } + + int progress = extras.getInt("progress"); + + // update progress + if (progress < 100 && progress >= 0) { + fragment.updateDLProgress(progress); + } + + try { + if (words != null) { + PwnixSetupFragment.PwnixInstallState replyState = PwnixSetupFragment.PwnixInstallState.valueOf(words.toUpperCase()); + + if(fragment.fragmentState == PwnixSetupFragment.PwnixInstallState.VERIFICATION_ERROR && replyState== PwnixSetupFragment.PwnixInstallState.DOWNLOADING){ + return; // ignore + } + fragment.setState(replyState); + fragment.updateUI(); + } + } catch (java.lang.IllegalArgumentException e) { + //the intent extra contains a string that is not a PwnixInstallState + } + } + } + } + +} From d6744831d4d75ba6b985be658f2331689cdbfb7b Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Fri, 2 Sep 2016 12:15:05 -0400 Subject: [PATCH 03/21] remove start provision broadcast from setupwizard finish --- src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java index 7dec266..a5db8f7 100644 --- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java +++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java @@ -473,9 +473,7 @@ protected Boolean doInBackground(Void... params) { @Override protected void onPostExecute(Boolean aBoolean) { Intent launcherIntent = new Intent(Intent.ACTION_MAIN); - Intent installerIntent = new Intent("com.pwnieexpress.android.pxinstaller.action.PROVISION"); launcherIntent.addCategory(Intent.CATEGORY_HOME); - mActivity.sendBroadcast(installerIntent); mActivity.startActivity(launcherIntent); mActivity.finish(); } From 89fd61fbbc2abc724957953f664078bcc6ffb6a7 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Fri, 2 Sep 2016 12:18:33 -0400 Subject: [PATCH 04/21] remove old stubbed out code --- res/layout/setup_pwnix_services.xml | 413 ++-------------------------- 1 file changed, 22 insertions(+), 391 deletions(-) diff --git a/res/layout/setup_pwnix_services.xml b/res/layout/setup_pwnix_services.xml index fc140f2..8d63105 100644 --- a/res/layout/setup_pwnix_services.xml +++ b/res/layout/setup_pwnix_services.xml @@ -21,20 +21,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From fb780d8d572603adc761fe7b3d490fbdfacb3d9d Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Fri, 2 Sep 2016 14:31:47 -0400 Subject: [PATCH 05/21] wakeful broadcast receiver to avoid missing stage advancing broadcasts by pxinstaller --- .../cyanogenmod/setupwizard/setup/PwnixSettingsPage.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 7c38678..01e0307 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -21,7 +21,8 @@ import android.app.Fragment; import android.app.FragmentManager; -import android.content.BroadcastReceiver; +import android.support.v4.content.WakefulBroadcastReceiver; +//import android.content.BroadcastReceiver; import android.content.Context; @@ -207,7 +208,6 @@ protected void initializePage() { gatherUIElements(); handleUIState(); - loadReceiver(); } @@ -247,8 +247,6 @@ public void onResume() { @Override public void onPause() { - unloadReceiver(); - if (errorDialog != null) { errorDialog.dismiss(); } @@ -1061,7 +1059,7 @@ public void updateUI(){ } - public static class MyReceiver extends BroadcastReceiver { + public static class MyReceiver extends WakefulBroadcastReceiver { private PwnixSetupFragment fragment; From e8957bc86819201c0a473578e559ba01a78c6960 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Fri, 2 Sep 2016 15:50:07 -0400 Subject: [PATCH 06/21] undo last commit + slight revision --- .../setupwizard/setup/PwnixSettingsPage.java | 49 +++---------------- 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 01e0307..aaccba2 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -149,7 +149,7 @@ public void run() { /** CM saving their prefs **/ } - public static class PwnixSetupFragment extends SetupPageFragment { +public static class PwnixSetupFragment extends SetupPageFragment { private static TextView step1Label, step2Label, step3Label, step4Label, step5Label, step6Label, fragmentBlurb; // Step Labels @@ -200,12 +200,8 @@ protected void initializePage() { Log.d("init page", this.toString()); activity = (SetupWizardActivity) getActivity(); - - //Need to check shared prefs to see if provisioned. - //if provisioned set state to SETUP otherwise ignore because this may be called mid install and fragmentState should be accurate - gatherUIElements(); handleUIState(); loadReceiver(); @@ -246,6 +242,7 @@ public void onResume() { @Override public void onPause() { + unloadReceiver(); if (errorDialog != null) { errorDialog.dismiss(); @@ -289,7 +286,7 @@ public void onDestroyView() { //activity =null; startIcon = null; dlProgress = null; - broadcastReceiver = null; + //broadcastReceiver = null; super.onDestroyView(); // dialog=null; @@ -333,43 +330,11 @@ public void onDestroy() { //activity =null; startIcon = null; dlProgress = null; - broadcastReceiver = null; + //broadcastReceiver = null; //dialog=null; super.onDestroy(); } - /** - private void showWikiDialog(Context context){ - //not allowed in a privilaged application context (i.e. SetupWizard lol) - //Instead may offer checkbox to open browser to wiki while they install google services - - AlertDialog.Builder wikiAlert = new AlertDialog.Builder(context); - wikiAlert.setTitle("AOPP Wiki"); - - - WebView wv = new WebView(context); - wv.getSettings().setJavaScriptEnabled(true); - wv.loadUrl("https://wiki.pwnieexpress.com/index.php/Getting_Started"); - wv.setWebViewClient(new WebViewClient(){ - @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) { - view.loadUrl(url); - return true; - } - }); - - wikiAlert.setView(wv); - wikiAlert.setNegativeButton("Close", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); - } - }); - wikiAlert.show(); - } - - **/ - private void handleUiNotStarted() { step1Label.setPadding(15,0,0,0); step2Label.setPadding(15,0,0,0); @@ -412,8 +377,6 @@ private void handleUiNotStarted() { overallProgressbar.setVisibility(View.GONE); overallProgressLabel.setVisibility(View.GONE); - - /** CHANGES MADE BELOW AROUND START BUTTON. FIX **/ launchButton.setVisibility(View.VISIBLE); startIcon.setVisibility(View.VISIBLE); doneImageview.setVisibility(View.GONE); @@ -1074,7 +1037,6 @@ public void onReceive(Context context, Intent intent) { String words = extras.getString("stage"); if (words != null) { Toast.makeText(context, "Received: " + words, Toast.LENGTH_SHORT).show(); - } int progress = extras.getInt("progress"); @@ -1097,6 +1059,9 @@ public void onReceive(Context context, Intent intent) { } catch (java.lang.IllegalArgumentException e) { //the intent extra contains a string that is not a PwnixInstallState } + } else { + //fragment is not on the screen + Log.d("Received WHILE NOT ON SCREEN", "SOMETHING"); } } } From e2d866509ae090a6fced84472fabf90f28058898 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Fri, 2 Sep 2016 22:10:27 -0400 Subject: [PATCH 07/21] about that life (cycle) --- .../setupwizard/setup/PwnixSettingsPage.java | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index aaccba2..264b36e 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -21,8 +21,7 @@ import android.app.Fragment; import android.app.FragmentManager; -import android.support.v4.content.WakefulBroadcastReceiver; -//import android.content.BroadcastReceiver; +import android.content.BroadcastReceiver; import android.content.Context; @@ -242,8 +241,7 @@ public void onResume() { @Override public void onPause() { - unloadReceiver(); - + if (errorDialog != null) { errorDialog.dismiss(); } @@ -253,6 +251,7 @@ public void onPause() { @Override public void onDestroyView() { Log.d("ondestroyView","called"); + unloadReceiver(); step1Label = null; step2Label = null; step3Label = null; @@ -1022,7 +1021,7 @@ public void updateUI(){ } - public static class MyReceiver extends WakefulBroadcastReceiver { + public static class MyReceiver extends BroadcastReceiver { private PwnixSetupFragment fragment; @@ -1032,36 +1031,35 @@ public void setCallback(PwnixSetupFragment f){ @Override public void onReceive(Context context, Intent intent) { - if (fragment.isAdded()) { // make sure the fragment is attached before doing anything - Bundle extras = intent.getExtras(); - String words = extras.getString("stage"); - if (words != null) { - Toast.makeText(context, "Received: " + words, Toast.LENGTH_SHORT).show(); - } + if ( fragment != null ) { + if (fragment.isAdded()) { // make sure the fragment is attached before doing anything + Bundle extras = intent.getExtras(); + String words = extras.getString("stage"); + if (words != null) { + Toast.makeText(context, "Received: " + words, Toast.LENGTH_SHORT).show(); + } - int progress = extras.getInt("progress"); + int progress = extras.getInt("progress"); - // update progress - if (progress < 100 && progress >= 0) { - fragment.updateDLProgress(progress); - } + // update progress + if (progress < 100 && progress >= 0) { + fragment.updateDLProgress(progress); + } - try { - if (words != null) { - PwnixSetupFragment.PwnixInstallState replyState = PwnixSetupFragment.PwnixInstallState.valueOf(words.toUpperCase()); + try { + if (words != null) { + PwnixSetupFragment.PwnixInstallState replyState = PwnixSetupFragment.PwnixInstallState.valueOf(words.toUpperCase()); - if(fragment.fragmentState == PwnixSetupFragment.PwnixInstallState.VERIFICATION_ERROR && replyState== PwnixSetupFragment.PwnixInstallState.DOWNLOADING){ - return; // ignore + if(fragment.fragmentState == PwnixSetupFragment.PwnixInstallState.VERIFICATION_ERROR && replyState== PwnixSetupFragment.PwnixInstallState.DOWNLOADING){ + return; // ignore + } + fragment.setState(replyState); + fragment.updateUI(); } - fragment.setState(replyState); - fragment.updateUI(); + } catch (java.lang.IllegalArgumentException e) { + //the intent extra contains a string that is not a PwnixInstallState } - } catch (java.lang.IllegalArgumentException e) { - //the intent extra contains a string that is not a PwnixInstallState - } - } else { - //fragment is not on the screen - Log.d("Received WHILE NOT ON SCREEN", "SOMETHING"); + } } } } From b7d8ac7e9038e5c0f974cb6b2ba36b66802862e4 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Wed, 7 Sep 2016 14:26:54 -0400 Subject: [PATCH 08/21] update reference to fragment when registering --- src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 264b36e..2e1bb86 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -218,6 +218,7 @@ public void loadReceiver() { } if (!receiverRegistered) { + broadcastReceiver.setCallback(this); getActivity().registerReceiver(broadcastReceiver, filter); receiverRegistered=true; } From bbe31ec33a6fbbcc053f337d476eb8b0398d041e Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Wed, 7 Sep 2016 16:06:20 -0400 Subject: [PATCH 09/21] place Pwnix install page directly after network pages --- src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java index 7695828..a179fdc 100644 --- a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java +++ b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java @@ -67,6 +67,9 @@ protected PageList onNewPageList() { if (SetupWizardUtils.hasGMS(mContext)) { pages.add(new GmsAccountPage(mContext, this).setHidden(true)); } + + pages.add(new PwnixSettingsPage(mContext, this)); + if (!SetupWizardUtils.hasLeanback(mContext) && SetupWizardUtils.isPackageInstalled(mContext, mContext.getString(R.string.cm_account_package_name))) { @@ -77,7 +80,6 @@ protected PageList onNewPageList() { } pages.add(new CyanogenSettingsPage(mContext, this)); pages.add(new OtherSettingsPage(mContext, this)); - pages.add(new PwnixSettingsPage(mContext, this).setRequired(true)); pages.add(new DateTimePage(mContext, this)); pages.add(new FinishPage(mContext, this)); return new PageList(pages.toArray(new SetupPage[pages.size()])); From 79953b499f8ad2a86cff6712d3930f697a923c3a Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Wed, 7 Sep 2016 16:32:33 -0400 Subject: [PATCH 10/21] change connection error alert message if network is missing --- .../setupwizard/setup/PwnixSettingsPage.java | 11 ++++++++--- .../setupwizard/ui/SetupWizardActivity.java | 12 ++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 2e1bb86..76755f0 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -713,11 +713,13 @@ public void showAlert(PwnixInstallState error){ if(errorDialog == null || !errorDialog.isShowing()) { Log.d("CREATE CONNERR","+++++++++"); String ssid= PwnixSetupFragment.getCurrentSsid(getThis().getActivity()); + String message = "We are not able to communicate with the server to download the Pwnix environment bundle.\n\nPlease ensure the network "+ssid+" has internet connectivity. Otherwise go back now and connect to a different network"; if(ssid == null){ - //special? + //special + message = "We are not able to communicate with the server to download the Pwnix environment bundle.\n\nPlease connect to a working wireless network"; } //Create Dialog - errorDialog = new AlertDialog.Builder(getActivity()).setTitle("Network Error").setMessage("We are not able to communicate with the server to download the Pwnix environment bundle.\n\nPlease ensure the network "+ssid+" has internet connectivity. Otherwise go back now and connect to a different network").setPositiveButton("OK", + errorDialog = new AlertDialog.Builder(getActivity()).setTitle("Network Error").setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { @@ -728,7 +730,10 @@ public void onClick(DialogInterface dialog, //cant go forward only backwards if you havent started ((SetupWizardActivity)getActivity()).enableNextButton(false); - getThis().updateUI(); + getThis().updateUI(); + + ((SetupWizardActivity)getActivity()).rewindToWifi(); + } }).setCancelable(false).create(); //Dialogs break immersive view - ty for the hack stackoverflow https://stackoverflow.com/questions/22794049/how-to-maintain-the-immersive-mode-in-dialogs diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java index a5db8f7..1a40543 100644 --- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java +++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java @@ -16,6 +16,8 @@ package com.cyanogenmod.setupwizard.ui; +import android.util.Log; + import android.animation.Animator; import android.app.Activity; import android.app.WallpaperManager; @@ -214,6 +216,16 @@ public void onBackPressed() { } } + public void doLoadPreviousPage(){ + mSetupData.onPreviousPage(); + } + + public void rewindToWifi(){ + while(!(isCurrentPage(mSetupData.getPage("WifiSetupPage")))){ + Log.d("rewind","page"); + doLoadPreviousPage(); + } + } @Override public void onNextPage() { Page page = mSetupData.getCurrentPage(); From e09d13f6daa8d2e2f513501ae22fd2b5927e543a Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Wed, 7 Sep 2016 19:36:06 -0400 Subject: [PATCH 11/21] Persist installed state + redundant UI checks/updates cleanup --- .../setupwizard/setup/PwnixSettingsPage.java | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 76755f0..35f69ea 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -23,7 +23,7 @@ import android.content.BroadcastReceiver; import android.content.Context; - +import android.content.SharedPreferences; import android.content.DialogInterface; import android.content.Intent; @@ -194,18 +194,48 @@ public enum PwnixInstallState { CONNECTION_ERROR, POWER_ERROR, NOTSTARTED, DOWNL private boolean dismissed = false; + private static final String PREFS = "provisioning_state"; + + private static final String PREFS_KEY = "provisioned"; + + private static boolean installationStateChecked = false; + + private static boolean stateSaved = false; + @Override protected void initializePage() { - Log.d("init page", this.toString()); + Log.d("INIT CALLED", this.toString()); - activity = (SetupWizardActivity) getActivity(); - //Need to check shared prefs to see if provisioned. - //if provisioned set state to SETUP otherwise ignore because this may be called mid install and fragmentState should be accurate + activity = (SetupWizardActivity) getActivity(); gatherUIElements(); - handleUIState(); + + if(!installationStateChecked){ + checkProvisioningStatus(); + installationStateChecked=true; + } + + //handleUIState(); handled already by onResume loadReceiver(); } + public void checkProvisioningStatus(){ + Log.d("CHECKING SAVED STATE", "-------------"); + SharedPreferences prefs = getActivity().getSharedPreferences(PREFS, Context.MODE_PRIVATE); + boolean restoreCompletedState = prefs.getBoolean(PREFS_KEY, false); + if (restoreCompletedState) { + fragmentState = PwnixInstallState.SETUP; + handleUIState(); + Log.d("PROVISIONED", "UPDATING UI"); + } + } + + private void saveProvisionedState(){ + SharedPreferences.Editor editor = getActivity().getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit(); + editor.putBoolean(PREFS_KEY, true); + editor.apply(); + Log.d("SAVED STATE", "++++++++++++++++++++++"); + } + public void loadReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction("android.intent.action.MAIN"); @@ -213,7 +243,7 @@ public void loadReceiver() { if (broadcastReceiver==null) { // may break this broadcastReceiver = new MyReceiver(); broadcastReceiver.setCallback(this); - Log.d("broadcastR null", "creating"); + Log.d("RECEIVER NULL", "CREATING"); receiverRegistered=false; //it was null -- it aint registered } @@ -234,15 +264,14 @@ public void unloadReceiver() { @Override public void onResume() { super.onResume(); - + Log.d("ONRESUME","CALLLED"); loadReceiver(); - //check shared prefs the same as init handleUIState(); //handle user putting screen to sleep mid install and waking up } @Override public void onPause() { - + Log.d("ONPAUSE","CALLLED"); if (errorDialog != null) { errorDialog.dismiss(); } @@ -251,7 +280,7 @@ public void onPause() { @Override public void onDestroyView() { - Log.d("ondestroyView","called"); + Log.d("ONDESTROYVIEW","CALLLED"); unloadReceiver(); step1Label = null; step2Label = null; @@ -294,7 +323,7 @@ public void onDestroyView() { @Override public void onDestroy() { - Log.d("ondestroy","called"); + Log.d("ONDESTROY","CALLED"); unloadReceiver(); step1Label = null; @@ -960,6 +989,11 @@ public void onClick(View v) { ((SetupWizardActivity)getActivity()).enableButtonBar(true); //write to shared prefs because process is done they could leave and come back for a brief amount of time. + + if(!stateSaved){ + saveProvisionedState(); + stateSaved=true; + } break; } } From c7526f5456bd315338035080e59f8b728c0bae28 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Wed, 7 Sep 2016 20:11:36 -0400 Subject: [PATCH 12/21] require networking not wifi specifically - needs testing to verify --- src/com/cyanogenmod/setupwizard/SetupWizardApp.java | 1 + src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/cyanogenmod/setupwizard/SetupWizardApp.java b/src/com/cyanogenmod/setupwizard/SetupWizardApp.java index fb0c8d3..4d01925 100644 --- a/src/com/cyanogenmod/setupwizard/SetupWizardApp.java +++ b/src/com/cyanogenmod/setupwizard/SetupWizardApp.java @@ -45,6 +45,7 @@ public class SetupWizardApp extends Application { public static final String EXTRA_FIRST_RUN = "firstRun"; public static final String EXTRA_ALLOW_SKIP = "allowSkip"; public static final String EXTRA_IS_WIFI_REQUIRED = "is_wifi_required"; + public static final String EXTRA_IS_NETWORK_REQUIRED = "is_network_required"; public static final String EXTRA_AUTO_FINISH = "wifi_auto_finish_on_connect"; public static final String EXTRA_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; public static final String EXTRA_USE_IMMERSIVE = "useImmersiveMode"; diff --git a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java index af2c33d..a17dbc0 100644 --- a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java @@ -246,7 +246,9 @@ private void launchWifiSetup() { } intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true); intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, false); - intent.putExtra(SetupWizardApp.EXTRA_IS_WIFI_REQUIRED,true); + //intent.putExtra(SetupWizardApp.EXTRA_IS_WIFI_REQUIRED,true); + //Attempt to fence into wifi or SIM + intent.putExtra(SetupWizardApp.EXTRA_IS_NETWORK_REQUIRED, true); intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true); intent.putExtra(SetupWizardApp.EXTRA_THEME, SetupWizardApp.EXTRA_MATERIAL_LIGHT); intent.putExtra(SetupWizardApp.EXTRA_AUTO_FINISH, false); From e298608284a170d77f0021dae9f6ca784fea112e Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Thu, 8 Sep 2016 12:59:15 -0400 Subject: [PATCH 13/21] Change 'button' and icon to start --- res/drawable/ic_phone_install_pwnix.png | Bin 0 -> 1933 bytes res/layout/setup_pwnix_services.xml | 3 +-- res/values/strings.xml | 2 +- .../setupwizard/setup/PwnixSettingsPage.java | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 res/drawable/ic_phone_install_pwnix.png diff --git a/res/drawable/ic_phone_install_pwnix.png b/res/drawable/ic_phone_install_pwnix.png new file mode 100644 index 0000000000000000000000000000000000000000..2b65dcc59ef774243e78bad5b790f1c76817c0ce GIT binary patch literal 1933 zcmaJ=dohB1swF&J$_h(fN35EII{PVUz+<)|oov?aG~nlTa4+EV1wxa=L9 z5xJxbrC%M|)#>7TlFFqxTi7mJCk%3a_W5J4bJkhsUF-dx=X=)kuJ3)KV;WFL3cb{Rc-j_-U71b4ywn8 zs5dXY;PLUwXt-gyc7tP=-`shos7rp7rKo)I{*R+ShIeesQqKy%Se<+MlI^y9VnCAG>h&gNJtNrO;vlTq@@z2tgINOXl{Pm>zzR2mec!d z4PzOXch&6fwKg*}GjIOKk?`k{ubN-o&>!$!st;__sXgWQri8TiEKd}+E2o7O?=wZS zoZQuKQ5KVb+~9=$;P&@^eW|ShEjJq1XPinH&3fxXs{L|Stid?O5C82G`y3P2+xLP z{MV4>1eLuOsb*`dlT&H4qxJ-@P~0niHNSoa$RKYaE|?F)7DqF}#oGfQSr>pO09anf z@Do713BV*9U{4`{3MVhTb3e9EvkWJ?Z{pzedxobvUA1%mHi`I1S=G>A@h+L@d5Ldz zHphX&p5q$^;l>p*JGR+FVNvaa1iA(+(07!biQ^7a#*hYDlUw);0^4q( z)N5U%J6Hq$+3-V4%N8gwOP!|b><)IPvGqRJ3hO>2lNCtxC%lCt-l9k9jvTqml~%r) zS}xq{FsDet`u#K5XKC(he_sCwYcdZ1x7s7sa0u5GMgmp1o==6}Zy7?N`eGA)ASG~I z(xv>83{S1%IWTOe^Hnr2>diFalweFk;SQ;Ic|PyTNfxh6Oya4OcPRpkcbVu)VooT4 zu|owO?m?8oWomhs3dXo;J$NOt?1oPdyL#f_>zFoHu#X0FxI`jMJWIjkW<3~rFpVD} z=zo?2W7JR@CN9}wdioGHB)H5++*zI~X8G6N+x+5VTZI^WZ9S1%jUoDH>uRyTf4 z76tB}r}4JSS>i@otC9cybCj5y^dA~e!+t=T+~r9d*<;~gkjgu9jJID5M=KD|9;pF2 zazoKx)aQMM(N}e&Yx0`H41(3m5za#$zdpI3)r8=uc!xn5=?0tWNiGe&y7Q6p86U6T zkzD_HWzmvxi|y)HiYG*AD?F?$z0mY9Q^g^;KPmUw(WIN-u--w>RZ-Dm=FH8M@Wo%H zH5tc6pSJb>QXf&5)BMXpD&*a)HtO$V8VFV@>I$fPx~nLU-;P#q`KbN$+*YiA+#hS1 bsr5h#oCvce{<`6o8&ffyJ)P?JvD5wqVI%rr literal 0 HcmV?d00001 diff --git a/res/layout/setup_pwnix_services.xml b/res/layout/setup_pwnix_services.xml index 8d63105..18273bd 100644 --- a/res/layout/setup_pwnix_services.xml +++ b/res/layout/setup_pwnix_services.xml @@ -68,8 +68,7 @@ android:layout_width="50sp" android:id="@+id/beginIcon" android:layout_height="50sp" - android:layout_gravity="center" - android:paddingLeft="10dp" /> + android:layout_gravity="center"/> Set up Homescreen Setting up Homescreen… Homescreen configured - Get Started + INSTALL Pwnix installation complete Installation progress: diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 35f69ea..9498b9a 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -410,7 +410,7 @@ private void handleUiNotStarted() { startIcon.setVisibility(View.VISIBLE); doneImageview.setVisibility(View.GONE); - startIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_system_update_black_24dp)); + startIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_phone_install_pwnix)); startIcon.setClickable(true); startIcon.setOnClickListener(new View.OnClickListener() { @Override From 4f0e48d4c675a39446bf6018679185a3744c7e5e Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Tue, 20 Sep 2016 14:53:00 -0400 Subject: [PATCH 14/21] refactor broadcasts --- .../setupwizard/setup/PwnixSettingsPage.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 9498b9a..ef7aa89 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -173,7 +173,7 @@ public static class PwnixSetupFragment extends SetupPageFragment { * PwnixInstallState * Defines the states/steps of the Pwnix Environment Setup */ - public enum PwnixInstallState { CONNECTION_ERROR, POWER_ERROR, NOTSTARTED, DOWNLOADING, DOWNLOADED, VERIFICATION_ERROR, VERIFYING, VERIFIED, INSTALLING, INSTALLED, REGISTERING, REGISTERED, PREPARING, PREPARED, SETTINGUP, SETUP } + public enum PwnixInstallState { CONNECTION_ERROR, POWER_ERROR, NOTSTARTED, DOWNLOADING, DOWNLOADED, VERIFICATION_ERROR, VERIFYING, VERIFIED, INSTALLING, INSTALLED, REGISTERING, REGISTERED, PREPARING, PREPARED, SETTINGUP, PROVISIONED } /** * fragmentState - holds application state - used to maintain UI across orientation change, etc @@ -223,7 +223,7 @@ public void checkProvisioningStatus(){ SharedPreferences prefs = getActivity().getSharedPreferences(PREFS, Context.MODE_PRIVATE); boolean restoreCompletedState = prefs.getBoolean(PREFS_KEY, false); if (restoreCompletedState) { - fragmentState = PwnixInstallState.SETUP; + fragmentState = PwnixInstallState.PROVISIONED; handleUIState(); Log.d("PROVISIONED", "UPDATING UI"); } @@ -419,7 +419,7 @@ public void onClick(View v) { //fragmentState=PwnixInstallState.DOWNLOADING; //handleUIState(); - getActivity().sendBroadcast(new Intent().setAction("com.pwnieexpress.android.pxinstaller.action.START_PROVISION")); + getActivity().sendBroadcast(new Intent().setAction("com.pwnieexpress.android.pxinstaller.action.PROVISION")); activity.enableButtonBar(false); @@ -441,7 +441,7 @@ public void onClick(View v) { // fragmentState=PwnixInstallState.DOWNLOADING; // handleUIState(); - getActivity().sendBroadcast(new Intent().setAction("com.pwnieexpress.android.pxinstaller.action.START_PROVISION")); + getActivity().sendBroadcast(new Intent().setAction("com.pwnieexpress.android.pxinstaller.action.PROVISION")); activity.enableButtonBar(false); @@ -961,7 +961,7 @@ private void handleUIState() { setOverallProgressbar(99); startStep(6); break; - case SETUP: // finish step 6 + case PROVISIONED: // finish step 6 setOverallProgressbar(100); finishStep(6); From 5733a7dda686b10c25690869dcc8d0e3be2a3f7c Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Thu, 22 Sep 2016 12:34:12 -0400 Subject: [PATCH 15/21] cleanup & add wifi alert --- .../setupwizard/setup/PwnixSettingsPage.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index ef7aa89..e9eecba 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -173,7 +173,7 @@ public static class PwnixSetupFragment extends SetupPageFragment { * PwnixInstallState * Defines the states/steps of the Pwnix Environment Setup */ - public enum PwnixInstallState { CONNECTION_ERROR, POWER_ERROR, NOTSTARTED, DOWNLOADING, DOWNLOADED, VERIFICATION_ERROR, VERIFYING, VERIFIED, INSTALLING, INSTALLED, REGISTERING, REGISTERED, PREPARING, PREPARED, SETTINGUP, PROVISIONED } + public enum PwnixInstallState { WIFI_ERROR, CONNECTION_ERROR, POWER_ERROR, NOTSTARTED, DOWNLOADING, DOWNLOADED, VERIFICATION_ERROR, VERIFYING, VERIFIED, INSTALLING, INSTALLED, REGISTERING, REGISTERED, PREPARING, PREPARED, SETTINGUP, PROVISIONED } /** * fragmentState - holds application state - used to maintain UI across orientation change, etc @@ -214,7 +214,6 @@ protected void initializePage() { installationStateChecked=true; } - //handleUIState(); handled already by onResume loadReceiver(); } @@ -738,6 +737,8 @@ public static String getCurrentSsid(Context context) { public void showAlert(PwnixInstallState error){ Log.d("ShowAlert","Called"); switch(error){ + case WIFI_ERROR: + break; case CONNECTION_ERROR: if(errorDialog == null || !errorDialog.isShowing()) { Log.d("CREATE CONNERR","+++++++++"); @@ -812,7 +813,6 @@ public void onClick(DialogInterface dialog, } break; case VERIFICATION_ERROR: - if(!dismissed) {//because this is a state we will stay in we need this flag to not spam them if (errorDialog == null || !errorDialog.isShowing()) { Log.d("CREATE CONNERR", "+++++++++"); @@ -867,6 +867,11 @@ private void handleUIState() { switch(fragmentState) { + case WIFI_ERROR: + handleUiNotStarted(); + animationRan=false; + showAlert(PwnixInstallState.WIFI_ERROR); + break; case CONNECTION_ERROR: handleUiNotStarted(); animationRan=false; From 5e179aa063481c60b0d5402b14fee1521bf75c3d Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Thu, 22 Sep 2016 13:56:32 -0400 Subject: [PATCH 16/21] android padding: where java =/= xml & your ocd doesn't matter --- .../cyanogenmod/setupwizard/setup/PwnixSettingsPage.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index e9eecba..216affc 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -865,6 +865,13 @@ private void handleUIState() { //Default to lock enable when not started or done. ((SetupWizardActivity)getActivity()).enableButtonBar(false); + //fix padding -- switch will override padding as needed + step1Label.setPadding(15,0,0,0); + step2Label.setPadding(15,0,0,0); + step3Label.setPadding(15,0,0,0); + step4Label.setPadding(15,0,0,0); + step5Label.setPadding(15,0,0,0); + step6Label.setPadding(15,0,0,0); switch(fragmentState) { case WIFI_ERROR: From 339a9faeb1e8795c7b67dfee3f3f857edf5b1fb4 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Thu, 22 Sep 2016 14:16:09 -0400 Subject: [PATCH 17/21] rewrote reciever to match pwnixinstaller and generally suck less. also small flag changes --- .../setupwizard/setup/PwnixSettingsPage.java | 74 ++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 216affc..db1345a 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -223,6 +223,8 @@ public void checkProvisioningStatus(){ boolean restoreCompletedState = prefs.getBoolean(PREFS_KEY, false); if (restoreCompletedState) { fragmentState = PwnixInstallState.PROVISIONED; + stateSaved = true; + receiverRegistered = true; handleUIState(); Log.d("PROVISIONED", "UPDATING UI"); } @@ -1083,6 +1085,7 @@ public void setCallback(PwnixSetupFragment f){ @Override public void onReceive(Context context, Intent intent) { + /*** if ( fragment != null ) { if (fragment.isAdded()) { // make sure the fragment is attached before doing anything Bundle extras = intent.getExtras(); @@ -1112,8 +1115,77 @@ public void onReceive(Context context, Intent intent) { //the intent extra contains a string that is not a PwnixInstallState } } + }***/ + Bundle extras = intent.getExtras(); + String words = extras.getString("stage"); + int progress = extras.getInt("progress",-666); + + if ( words != null ) { + //Toast.makeText(context, "Received: " + words, Toast.LENGTH_SHORT).show(); + Log.d("Received State Intent: ", words); + } + + if ( progress != -666 ) { + if (progress < 100 && progress >= 0) { + fragment.updateDLProgress(progress); + Log.d("Progress Update:",progress+""); + } + return; // done here stop wasting time + } + + PwnixSetupFragment.PwnixInstallState replyState = null; + try { + if (words != null) { + replyState = PwnixSetupFragment.PwnixInstallState.valueOf(words.toUpperCase()); //get ENUM + } + } catch (java.lang.IllegalArgumentException e) { + //the intent extra contains a string that is not a PwnixInstallState + return; + } + + if(replyState == null){ //error somehow + return; + } else { //we good so log + Log.d("Received State Intent: ", words); + } + + + if(replyState == PwnixSetupFragment.PwnixInstallState.PROVISIONED){ + SharedPreferences.Editor editor = context.getSharedPreferences(PwnixSetupFragment.PREFS, Context.MODE_PRIVATE).edit(); + editor.putBoolean(PwnixSetupFragment.PREFS_KEY, true); + editor.apply(); + Log.d("REC:SAVED STATE", "+++++++++++"); + } + + if(fragment == null){ + Log.d("Receiver:","null fragment"); + // no fragment nothing we can do but set provisioned if true so we dont miss the last step worst case + + //if replystate == PROVISIONED then write setup to shared prefs + if(replyState == PwnixSetupFragment.PwnixInstallState.PROVISIONED) { + SharedPreferences.Editor editor = context.getSharedPreferences(PwnixSetupFragment.PREFS, Context.MODE_PRIVATE).edit(); + editor.putBoolean(PwnixSetupFragment.PREFS_KEY, true); + editor.apply(); + Log.d("SAVED STATE", "+++sleepy fragment tho++++++++");//this should literally be impossible. + } + + return; + } + + + if(fragment.fragmentState == PwnixSetupFragment.PwnixInstallState.VERIFICATION_ERROR && replyState== PwnixSetupFragment.PwnixInstallState.DOWNLOADING){ + return; // ignore the rebroadcast of Downloading when looping through verification error logic + } + + + fragment.setState(replyState); + Log.d("Receiver:","setState"+replyState.toString()); + + if (fragment.isAdded()) { + Log.d("Receiver:","fragment.updateUI()"); + fragment.updateUI(); } } } - } + From 11440d8b899ebaab57b4edbf630ec043391d13c0 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Thu, 22 Sep 2016 14:26:47 -0400 Subject: [PATCH 18/21] add in alert for wifi error --- .../setupwizard/setup/PwnixSettingsPage.java | 48 +++++++++++++++++-- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index db1345a..a376ef3 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -740,12 +740,50 @@ public void showAlert(PwnixInstallState error){ Log.d("ShowAlert","Called"); switch(error){ case WIFI_ERROR: + String message = "This bundle is very large. \n\nTo avoid potential delays or extra data usage charges, use Wi-Fi only. "; + + if (errorDialog == null ||!errorDialog.isShowing()) { + errorDialog = new AlertDialog.Builder(getActivity()).setTitle("Downloading a large bundle").setMessage(message).setPositiveButton("WIFI", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + getThis().setState(PwnixSetupFragment.PwnixInstallState.NOTSTARTED); + ((SetupWizardActivity)getActivity()).rewindToWifi(); + Log.d("LAUNCHING WIFI", "WIFIERROR"); + dialog.dismiss(); + + } + }).setNegativeButton("USE DATA", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + //send broadcast with data flag + getThis().setState(PwnixSetupFragment.PwnixInstallState.NOTSTARTED); + getActivity().sendBroadcast(new Intent().putExtra("DATA_USAGE", true).setAction("com.pwnieexpress.android.pxinstaller.action.PROVISION")); + Log.d("LAUNCHING PROVISION", "WIFIERROR"); + dialogInterface.dismiss(); + } + }).setCancelable(false).create(); + + errorDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + + //Show the dialog! + errorDialog.show(); + + //Set the dialog to immersive + errorDialog.getWindow().getDecorView().setSystemUiVisibility( + (getActivity()).getWindow().getDecorView().getSystemUiVisibility()); + + //Clear the not focusable flag from the window + errorDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + + } + break; case CONNECTION_ERROR: if(errorDialog == null || !errorDialog.isShowing()) { Log.d("CREATE CONNERR","+++++++++"); String ssid= PwnixSetupFragment.getCurrentSsid(getThis().getActivity()); - String message = "We are not able to communicate with the server to download the Pwnix environment bundle.\n\nPlease ensure the network "+ssid+" has internet connectivity. Otherwise go back now and connect to a different network"; + message = "We are not able to communicate with the server to download the Pwnix environment bundle.\n\nPlease ensure the network "+ssid+" has internet connectivity. Otherwise go back now and connect to a different network"; if(ssid == null){ //special message = "We are not able to communicate with the server to download the Pwnix environment bundle.\n\nPlease connect to a working wireless network"; @@ -755,16 +793,16 @@ public void showAlert(PwnixInstallState error){ new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - getThis().setState(PwnixSetupFragment.PwnixInstallState.NOTSTARTED); + getThis().setState(PwnixSetupFragment.PwnixInstallState.NOTSTARTED); //You shall not pass ((SetupWizardActivity)getActivity()).enableButtonBar(true); //cant go forward only backwards if you havent started ((SetupWizardActivity)getActivity()).enableNextButton(false); - getThis().updateUI(); - - ((SetupWizardActivity)getActivity()).rewindToWifi(); + getThis().updateUI(); + dialog.dismiss(); + ((SetupWizardActivity)getActivity()).rewindToWifi(); } }).setCancelable(false).create(); From 8c32fc9107669bcfdee707db4a71ce8a56bba750 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Thu, 22 Sep 2016 15:10:46 -0400 Subject: [PATCH 19/21] probably literally a space --- src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index a376ef3..64f322a 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -738,9 +738,10 @@ public static String getCurrentSsid(Context context) { public void showAlert(PwnixInstallState error){ Log.d("ShowAlert","Called"); + String message; switch(error){ case WIFI_ERROR: - String message = "This bundle is very large. \n\nTo avoid potential delays or extra data usage charges, use Wi-Fi only. "; + message = "This bundle is very large. \n\nTo avoid potential delays or extra data usage charges, use Wi-Fi only."; if (errorDialog == null ||!errorDialog.isShowing()) { errorDialog = new AlertDialog.Builder(getActivity()).setTitle("Downloading a large bundle").setMessage(message).setPositiveButton("WIFI", From b2ca9b4030acb072d0823094be4dd2e511188a75 Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Mon, 24 Oct 2016 15:48:38 -0400 Subject: [PATCH 20/21] change launch button & done message --- res/drawable/button_background.xml | 29 +++++++++ res/layout/setup_pwnix_services.xml | 55 ++++++++++++++++- res/values/strings.xml | 2 + .../setupwizard/setup/PwnixSettingsPage.java | 61 +++---------------- 4 files changed, 93 insertions(+), 54 deletions(-) create mode 100644 res/drawable/button_background.xml diff --git a/res/drawable/button_background.xml b/res/drawable/button_background.xml new file mode 100644 index 0000000..b9a7429 --- /dev/null +++ b/res/drawable/button_background.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/setup_pwnix_services.xml b/res/layout/setup_pwnix_services.xml index 18273bd..00be573 100644 --- a/res/layout/setup_pwnix_services.xml +++ b/res/layout/setup_pwnix_services.xml @@ -48,7 +48,7 @@ android:lineSpacingExtra="@dimen/setup_line_spacing" android:paddingBottom="@dimen/summary_margin_bottom" /> - - + --> + + + + + + + + + + INSTALL Pwnix installation complete Installation progress: + Pwnix Installation Complete + Install Pwnix Pwnix environment setup The next step in getting your device ready to pwn is setting up the Pwnix Environment. The download and installation process is fully automated. Please connect the device to a power source. This is a complex process, thank you for your patience. diff --git a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java index 64f322a..e801446 100644 --- a/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/PwnixSettingsPage.java @@ -150,9 +150,9 @@ public void run() { public static class PwnixSetupFragment extends SetupPageFragment { - private static TextView step1Label, step2Label, step3Label, step4Label, step5Label, step6Label, fragmentBlurb; // Step Labels + private static TextView step1Label, step2Label, step3Label, step4Label, step5Label, step6Label, fragmentBlurb, doneMessage; // Step Labels - private static TextView launchButton; // "Button" to start process - textview with an onclick defined + private static RelativeLayout launchButton; // "Button" to start process - textview with an onclick defined private static TextView overallProgressLabel; @@ -182,7 +182,6 @@ public enum PwnixInstallState { WIFI_ERROR, CONNECTION_ERROR, POWER_ERROR, NOTST private static MyReceiver broadcastReceiver; - private static ImageView startIcon; private static TextView dlProgress; @@ -314,7 +313,6 @@ public void onDestroyView() { step6PGB = null; overallProgressbar = null; //activity =null; - startIcon = null; dlProgress = null; //broadcastReceiver = null; super.onDestroyView(); @@ -358,7 +356,6 @@ public void onDestroy() { step6PGB = null; overallProgressbar = null; //activity =null; - startIcon = null; dlProgress = null; //broadcastReceiver = null; //dialog=null; @@ -408,52 +405,23 @@ private void handleUiNotStarted() { overallProgressLabel.setVisibility(View.GONE); launchButton.setVisibility(View.VISIBLE); - startIcon.setVisibility(View.VISIBLE); doneImageview.setVisibility(View.GONE); - startIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_phone_install_pwnix)); - startIcon.setClickable(true); - startIcon.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //Testing - //fragmentState=PwnixInstallState.DOWNLOADING; - //handleUIState(); - - getActivity().sendBroadcast(new Intent().setAction("com.pwnieexpress.android.pxinstaller.action.PROVISION")); - activity.enableButtonBar(false); - - - startIcon.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //stop mashing the button dear lord - } - }); - startIcon.setClickable(false); //#overkill - }//end on click - }); - launchButton.setClickable(true); launchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - //Testing - // fragmentState=PwnixInstallState.DOWNLOADING; - // handleUIState(); - getActivity().sendBroadcast(new Intent().setAction("com.pwnieexpress.android.pxinstaller.action.PROVISION")); activity.enableButtonBar(false); - launchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //stop mashing the button dear lord } }); - launchButton.setClickable(false); //#overkill - }//end on click + launchButton.setClickable(false); + } }); } @@ -461,7 +429,6 @@ private static void setOverallProgressbar(int p) { if (!(fragmentState==PwnixInstallState.DOWNLOADING) || ((fragmentState==PwnixInstallState.DOWNLOADING) && animationRan)) { // normal if its not the downloading fragment (starting) OR it is but the animation has already run // Hide Get Started Button since we are showing progress launchButton.setVisibility(View.GONE); - startIcon.setVisibility(View.GONE); launchButton.setClickable(false); // Show progress bar and update @@ -473,7 +440,6 @@ private static void setOverallProgressbar(int p) { } else { // animated for first run launchButton.setVisibility(View.GONE); launchButton.setClickable(false); - startIcon.setVisibility(View.GONE); overallProgressbar.setVisibility(View.VISIBLE); overallProgressLabel.setVisibility(View.VISIBLE); @@ -1017,25 +983,16 @@ private void handleUIState() { case PROVISIONED: // finish step 6 setOverallProgressbar(100); finishStep(6); - - //step6Label.setTextColor(Color.GREEN); // wow that is bright nvm step6Label.setText(R.string.step6past); step6Label.invalidate(); doneImageview.setVisibility(View.VISIBLE); doneImageview.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_black_24dp)); - overallProgressbar.setVisibility(View.GONE); - launchButton.setVisibility(View.VISIBLE); - launchButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //your click is top priority I promise. - } - }); - launchButton.setText(R.string.complete); - launchButton.setPadding(0,100,0,100); + launchButton.setVisibility(View.GONE); + doneMessage.setVisibility(View.VISIBLE); + overallProgressbar.setVisibility(View.GONE); overallProgressLabel.setVisibility(View.GONE); //enjoy your freedom earthling @@ -1053,11 +1010,11 @@ public void onClick(View v) { private void gatherUIElements() { + doneMessage = (TextView) mRootView.findViewById(R.id.doneMessage); dlProgress = (TextView) mRootView.findViewById(R.id.dlProgress); - startIcon = (ImageView) mRootView.findViewById(R.id.beginIcon); fragmentBlurb = (TextView) mRootView.findViewById(R.id.fragmentBlurb); overallProgressbar = (ProgressBar) mRootView.findViewById(R.id.overallProgress); - launchButton = (TextView) mRootView.findViewById(R.id.wikibutton); + launchButton = (RelativeLayout) mRootView.findViewById(R.id.launchbutton); stepContainer = (ScrollView) mRootView.findViewById(R.id.scrollView); From f01fc0253dd1d2db09c588cae626109826ab0d7d Mon Sep 17 00:00:00 2001 From: Dallas Winger Date: Mon, 24 Oct 2016 16:09:59 -0400 Subject: [PATCH 21/21] give that done message some padding --- res/layout/setup_pwnix_services.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/layout/setup_pwnix_services.xml b/res/layout/setup_pwnix_services.xml index 00be573..94ba662 100644 --- a/res/layout/setup_pwnix_services.xml +++ b/res/layout/setup_pwnix_services.xml @@ -79,6 +79,7 @@ android:layout_centerHorizontal="true" android:id="@+id/doneMessage" android:textAlignment="center" + android:paddingTop="@dimen/content_margin_top" android:textSize="24sp" android:visibility="gone" />