Search in sources :

Example 1 with SimpleCard

use of com.fima.cardsui.views.SimpleCard in project Rashr by DsLNeXuS.

the class FlashFragment method addRecoveryCards.

/**
     * addRecoveryCards checks which recovery systems are supported by your device for example:
     * Galaxy S6 (SM-G920F) supports TWRP but isn't supported by CWM so addRecoveryCards will add
     * TWRP Card and Recovery From Storage card.
     *
     * @param cardUI Where should be the cards added
     */
public void addRecoveryCards(CardUI cardUI) {
    if (RashrApp.DEVICE.isXZDualRecoverySupported() || BuildConfig.DEBUG) {
        final IconCard XZCard = new IconCard(getString(R.string.xzdualrecovery), R.drawable.ic_xzdual, getString(R.string.xzdual_describtion));
        XZCard.setData(Device.REC_SYS_XZDUAL);
        XZCard.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString(RecoverySystemFragment.PARAM_TITLE, XZCard.getData().toString());
                bundle.putString(RecoverySystemFragment.PARAM_DEV, getString(R.string.dev_name_xzdual));
                bundle.putString(RecoverySystemFragment.PARAM_DESC, getString(R.string.xzdual_describtion));
                bundle.putStringArrayList(RecoverySystemFragment.PARAM_VERSIONS, RashrApp.DEVICE.getXZDualRecoveryVersions());
                bundle.putInt(RecoverySystemFragment.PARAM_LOGO, R.drawable.ic_xzdual);
                bundle.putString(RecoverySystemFragment.PARAM_IMG_PATH, Const.PathToXZDual.toString());
                mActivity.switchTo(RecoverySystemFragment.newInstance(bundle), true);
            }
        });
        cardUI.addCard(XZCard, true);
    }
    if (RashrApp.DEVICE.isCwmRecoverySupported() || BuildConfig.DEBUG) {
        final IconCard CWMCard = new IconCard(getString(R.string.sCWM), R.drawable.ic_cwm, getString(R.string.cwm_description));
        CWMCard.setData(Device.REC_SYS_CWM);
        CWMCard.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString(RecoverySystemFragment.PARAM_TITLE, CWMCard.getData().toString());
                bundle.putString(RecoverySystemFragment.PARAM_DEV, getString(R.string.dev_name_cwm));
                bundle.putString(RecoverySystemFragment.PARAM_DESC, getString(R.string.cwm_description));
                bundle.putStringArrayList(RecoverySystemFragment.PARAM_VERSIONS, RashrApp.DEVICE.getCwmRecoveryVersions());
                bundle.putString(RecoverySystemFragment.PARAM_SCREENSHOT_URL, Const.CWM_SCREENSHOT_URL);
                bundle.putInt(RecoverySystemFragment.PARAM_LOGO, R.drawable.ic_cwm);
                bundle.putString(RecoverySystemFragment.PARAM_IMG_PATH, Const.PathToCWM.toString());
                mActivity.switchTo(RecoverySystemFragment.newInstance(bundle), true);
            }
        });
        cardUI.addCard(CWMCard, true);
    }
    if (RashrApp.DEVICE.isTwrpRecoverySupported() || BuildConfig.DEBUG) {
        final IconCard TWRPCard = new IconCard(getString(R.string.sTWRP), R.drawable.ic_twrp, getString(R.string.twrp_description));
        TWRPCard.setData(Device.REC_SYS_TWRP);
        TWRPCard.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString(RecoverySystemFragment.PARAM_TITLE, TWRPCard.getData().toString());
                bundle.putString(RecoverySystemFragment.PARAM_DEV, getString(R.string.dev_name_twrp));
                bundle.putString(RecoverySystemFragment.PARAM_DESC, getString(R.string.twrp_description));
                bundle.putStringArrayList(RecoverySystemFragment.PARAM_VERSIONS, RashrApp.DEVICE.getTwrpRecoveryVersions());
                bundle.putString(RecoverySystemFragment.PARAM_SCREENSHOT_URL, Const.TWRP_SCREENSHOT_URL);
                bundle.putInt(RecoverySystemFragment.PARAM_LOGO, R.drawable.ic_twrp);
                bundle.putString(RecoverySystemFragment.PARAM_IMG_PATH, Const.PathToTWRP.toString());
                mActivity.switchTo(RecoverySystemFragment.newInstance(bundle), true);
            }
        });
        cardUI.addCard(TWRPCard, true);
    }
    if (RashrApp.DEVICE.isPhilzRecoverySupported() || BuildConfig.DEBUG) {
        final SimpleCard PHILZCard = new SimpleCard(getString(R.string.sPhilz), getString(R.string.philz_description));
        PHILZCard.setData(Device.REC_SYS_PHILZ);
        PHILZCard.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString(RecoverySystemFragment.PARAM_TITLE, PHILZCard.getData().toString());
                bundle.putString(RecoverySystemFragment.PARAM_DEV, getString(R.string.dev_name_philz));
                bundle.putString(RecoverySystemFragment.PARAM_DESC, getString(R.string.philz_description));
                bundle.putStringArrayList(RecoverySystemFragment.PARAM_VERSIONS, RashrApp.DEVICE.getPhilzRecoveryVersions());
                bundle.putString(RecoverySystemFragment.PARAM_IMG_PATH, Const.PathToPhilz.toString());
                mActivity.switchTo(RecoverySystemFragment.newInstance(bundle), true);
            }
        });
        cardUI.addCard(PHILZCard, true);
    }
    if (RashrApp.DEVICE.isCmRecoverySupported() || BuildConfig.DEBUG) {
        final IconCard CMCard = new IconCard(getString(R.string.cm_recovery), R.drawable.ic_cm, getString(R.string.cm_recovery_description));
        CMCard.setData(Device.REC_SYS_CM);
        CMCard.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString(RecoverySystemFragment.PARAM_TITLE, CMCard.getData().toString());
                bundle.putString(RecoverySystemFragment.PARAM_DEV, getString(R.string.dev_name_cm));
                bundle.putString(RecoverySystemFragment.PARAM_DESC, getString(R.string.cm_recovery_description));
                bundle.putStringArrayList(RecoverySystemFragment.PARAM_VERSIONS, RashrApp.DEVICE.getCmRecoveriyVersions());
                bundle.putInt(RecoverySystemFragment.PARAM_LOGO, R.drawable.ic_cm);
                bundle.putString(RecoverySystemFragment.PARAM_IMG_PATH, Const.PathToCM.toString());
                mActivity.switchTo(RecoverySystemFragment.newInstance(bundle), true);
            }
        });
        cardUI.addCard(CMCard, true);
    }
    if (RashrApp.DEVICE.isStockRecoverySupported() || BuildConfig.DEBUG) {
        final IconCard StockCard = new IconCard(getString(R.string.stock_recovery), R.drawable.ic_update, getString(R.string.stock_recovery_description));
        StockCard.setData(Device.REC_SYS_STOCK);
        StockCard.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString(RecoverySystemFragment.PARAM_TITLE, StockCard.getData().toString());
                bundle.putString(RecoverySystemFragment.PARAM_DEV, RashrApp.DEVICE.getManufacture());
                bundle.putString(RecoverySystemFragment.PARAM_DESC, getString(R.string.stock_recovery_description));
                bundle.putStringArrayList(RecoverySystemFragment.PARAM_VERSIONS, RashrApp.DEVICE.getStockRecoveryVersions());
                bundle.putInt(RecoverySystemFragment.PARAM_LOGO, R.drawable.ic_update);
                bundle.putString(RecoverySystemFragment.PARAM_IMG_PATH, Const.PathToStockRecovery.toString());
                mActivity.switchTo(RecoverySystemFragment.newInstance(bundle));
            }
        });
        cardUI.addCard(StockCard, true);
    }
    final IconCard OtherCard = new IconCard(getString(R.string.other_recovery), R.drawable.ic_folder, getString(R.string.other_storage_description));
    OtherCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            bFlashOtherRecovery(v);
        }
    });
    cardUI.addCard(OtherCard, true);
}
Also used : Bundle(android.os.Bundle) SimpleCard(com.fima.cardsui.views.SimpleCard) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) IconCard(com.fima.cardsui.views.IconCard)

Example 2 with SimpleCard

use of com.fima.cardsui.views.SimpleCard in project Rashr by DsLNeXuS.

the class FlashFragment method addRebooterCards.

/**
     * Add cards for reboot device: Reboot to Bootloader, Reboot to Recovery, Reboot, Shutdown
     *
     * @param cardUI Where should be the cards added
     */
public void addRebooterCards(CardUI cardUI) {
    SimpleCard Reboot = new SimpleCard(getString(R.string.sReboot), getString(R.string.reboot_description));
    Reboot.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(mContext);
            ConfirmationDialog.setTitle(R.string.warning);
            ConfirmationDialog.setMessage(R.string.reboot_confirmation);
            ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        RashrApp.TOOLBOX.reboot(Toolbox.REBOOT_REBOOT);
                    } catch (Exception e) {
                        Toast.makeText(mContext, R.string.reboot_failed, Toast.LENGTH_SHORT).show();
                        RashrApp.ERRORS.add(e.toString());
                    }
                }
            });
            ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            ConfirmationDialog.show();
        }
    });
    SimpleCard RebootRecovery = new SimpleCard(getString(R.string.sRebootRecovery), getString(R.string.reboot_recovery_description));
    RebootRecovery.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(mContext);
            ConfirmationDialog.setTitle(R.string.warning);
            ConfirmationDialog.setMessage(R.string.reboot_confirmation);
            ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        RashrApp.TOOLBOX.reboot(Toolbox.REBOOT_RECOVERY);
                    } catch (Exception e) {
                        Toast.makeText(mContext, R.string.reboot_failed, Toast.LENGTH_SHORT).show();
                        RashrApp.ERRORS.add(e.toString());
                    }
                }
            });
            ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            ConfirmationDialog.show();
        }
    });
    SimpleCard RebootBootloader = new SimpleCard(getString(R.string.sRebootBootloader), getString(R.string.reboot_bootloader_description));
    RebootBootloader.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(mContext);
            ConfirmationDialog.setTitle(R.string.warning);
            ConfirmationDialog.setMessage(R.string.reboot_confirmation);
            ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        RashrApp.TOOLBOX.reboot(Toolbox.REBOOT_BOOTLOADER);
                    } catch (Exception e) {
                        Toast.makeText(mContext, R.string.reboot_failed, Toast.LENGTH_SHORT).show();
                        RashrApp.ERRORS.add(e.toString());
                    }
                }
            });
            ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            ConfirmationDialog.show();
        }
    });
    SimpleCard Shutdown = new SimpleCard(getString(R.string.sRebootShutdown), getString(R.string.shutdown_description));
    Shutdown.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(mContext);
            ConfirmationDialog.setTitle(R.string.warning);
            ConfirmationDialog.setMessage(R.string.shutdown_confirmation);
            ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        RashrApp.TOOLBOX.reboot(Toolbox.REBOOT_SHUTDOWN);
                    } catch (Exception e) {
                        Toast.makeText(mContext, R.string.reboot_failed, Toast.LENGTH_SHORT).show();
                        RashrApp.ERRORS.add(e.toString());
                    }
                }
            });
            ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            ConfirmationDialog.show();
        }
    });
    cardUI.addCard(Reboot, true);
    cardUI.addCard(RebootRecovery, true);
    cardUI.addCard(RebootBootloader, true);
    cardUI.addCard(Shutdown, true);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) SimpleCard(com.fima.cardsui.views.SimpleCard) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

View (android.view.View)2 AbsListView (android.widget.AbsListView)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 SimpleCard (com.fima.cardsui.views.SimpleCard)2 DialogInterface (android.content.DialogInterface)1 Bundle (android.os.Bundle)1 AlertDialog (android.support.v7.app.AlertDialog)1 IconCard (com.fima.cardsui.views.IconCard)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1