Search in sources :

Example 1 with IconCard

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

the class FlashFragment method addKernelCards.

/**
     * addKernelCards checks wich kernels are supported by your device
     *
     * @param cardUI Where should be the cards added
     */
public void addKernelCards(CardUI cardUI) {
    if (RashrApp.DEVICE.isStockKernelSupported() || BuildConfig.DEBUG) {
        final IconCard StockCard = new IconCard(getString(R.string.stock_kernel), R.drawable.ic_stock_kernel, getString(R.string.stock_kernel_description));
        StockCard.setData("stock");
        StockCard.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                FlashSupportedKernel(StockCard);
            }
        });
        cardUI.addCard(StockCard, true);
    }
    final IconCard OtherCard = new IconCard(getString(R.string.other_kernel), R.drawable.ic_folder, getString(R.string.other_storage_description));
    OtherCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            bFlashOtherKernel(v);
        }
    });
    cardUI.addCard(OtherCard, true);
}
Also used : 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 IconCard

use of com.fima.cardsui.views.IconCard 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 3 with IconCard

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

the class FlashFragment method optimizeLayout.

/**
     * optimizeLayout checks which cards need to be added to UI. So if you device doesn't support
     * kernel flashing optimizeLayout will not add it to UI.
     *
     * @param root RootView from Fragment
     * @throws NullPointerException layout can't be inflated
     */
@SuppressLint("PrivateResource")
public void optimizeLayout(View root) throws NullPointerException {
    CardUI RashrCards = (CardUI) root.findViewById(R.id.RashrCards);
    if (RashrApp.DEVICE.isRecoverySupported() || RashrApp.DEVICE.isKernelSupported() || BuildConfig.DEBUG) {
        /** If device is supported start setting up layout */
        setupSwipeUpdater(root);
        /** Avoid overlapping scroll on CardUI and SwipeRefreshLayout */
        RashrCards.getListView().setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                int topRowVerticalPosition = (view == null || view.getChildCount() == 0) ? 0 : view.getChildAt(0).getTop();
                if (mSwipeUpdater != null)
                    mSwipeUpdater.setEnabled((topRowVerticalPosition >= 0));
            }
        });
        if (RashrApp.DEVICE.isRecoverySupported() || BuildConfig.DEBUG) {
            addRecoveryCards(RashrCards);
        }
        if (RashrApp.DEVICE.isKernelSupported() || BuildConfig.DEBUG) {
            addKernelCards(RashrCards);
        }
        //Device has been flashed over Rashr so you can choose previously used images
        if (getHistoryFiles().size() > 0) {
            final IconCard HistoryCard = new IconCard(getString(R.string.history), R.drawable.ic_history, getString(R.string.history_description));
            HistoryCard.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    showFlashHistory();
                }
            });
            RashrCards.addCard(HistoryCard, true);
        }
    }
    addRebooterCards(RashrCards);
}
Also used : CardUI(com.fima.cardsui.views.CardUI) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) IconCard(com.fima.cardsui.views.IconCard) SuppressLint(android.annotation.SuppressLint)

Aggregations

View (android.view.View)3 AbsListView (android.widget.AbsListView)3 AdapterView (android.widget.AdapterView)3 ListView (android.widget.ListView)3 IconCard (com.fima.cardsui.views.IconCard)3 SuppressLint (android.annotation.SuppressLint)1 Bundle (android.os.Bundle)1 CardUI (com.fima.cardsui.views.CardUI)1 SimpleCard (com.fima.cardsui.views.SimpleCard)1