Example usage for android.text.format DateUtils getMonthString

List of usage examples for android.text.format DateUtils getMonthString

Introduction

In this page you can find the example usage for android.text.format DateUtils getMonthString.

Prototype

@Deprecated
public static String getMonthString(int month, int abbrev) 

Source Link

Document

Return a localized string for the month of the year.

Usage

From source file:com.plusot.senselib.SenseMain.java

@SuppressWarnings("deprecation")
public void showPopupDialog(int dialogId, int viewId, String[] items) {// ,
    if (!alive) {
        if (dialogId == STEP_POPUP)
            popupToShow = STEP_POPUP;/*from w w w.  j  a va2 s . c  om*/
        return;
    }
    int iEnd = 3;
    int timeOut = 0;
    int defaultChoice = 0;
    boolean cancelable = true;
    popupToShow = -1;
    String title = null;
    Map<String, String> lookup = null;
    if (items == null)
        items = getResources().getStringArray(R.array.value_popup_dialog_items);
    switch (dialogId) {
    case VALUE_POPUP:
        title = getString(R.string.valuepopup);
        items = getResources().getStringArray(R.array.value_popup_dialog_items);

        if (viewHasValue(viewId)) {
            popupValue = viewGetCurrentValue(viewId);
            title = popupValue.getValueType(this);
            if (popupValue.getValueType().equals(ValueType.POWER)) {
                items = Arrays.copyOf(items, items.length + 1);
                items[items.length - 1] = getString(R.string.calibrate);
            } else if (popupValue.getValueType().equals(ValueType.SLOPE)) {
                items = Arrays.copyOf(items, items.length + 1);
                items[items.length - 1] = getString(R.string.set_level);
            }
        }

        break;
    case VALUESELECT_POPUP:
        title = getString(R.string.valuepopup);
        items = Value.getValuePopupList(this, PreferenceKey.XTRAVALUES.isTrue());
        break;
    case UNIT_POPUP:
        title = getString(R.string.unitpopup);
        if (items == null || items.length == 0)
            ToastHelper.showToastLong(R.string.no_unit_choice);
        break;
    case YEAR_POPUP:
        title = getString(R.string.yearpopup);
        if (fileExplorer == null) {
            items = null;
        } else {
            items = fileExplorer.getYears();
        }
        if (items == null || items.length == 0) {
            ToastHelper.showToastLong(R.string.no_year_choice);
            return;
        } else if (items.length > 1) {
            break;
        }
        logYear = items[0];
        dialogId = MONTH_POPUP;
    case MONTH_POPUP:
        title = getString(R.string.monthpopup);
        if (fileExplorer == null) {
            items = null;
        } else {
            logMonths = fileExplorer.getMonths(logYear);
            items = FileExplorer.getMonths(logYear, logMonths);
        }
        if (items == null || items.length == 0) {
            ToastHelper.showToastLong(getString(R.string.no_month_choice, logYear));
            return;
        } else if (items.length > 1) {
            break;
        }
        logMonth = logMonths[0];
        LLog.d(Globals.TAG, CLASSTAG + ".showPopupDialog: logMonth = " + logMonth);
        dialogId = DAY_POPUP;
    case DAY_POPUP:
        title = getString(R.string.daypopup);
        if (fileExplorer == null) {
            items = null;
        } else {
            logDays = fileExplorer.getDays(logYear, logMonth);
            items = FileExplorer.getDays(logYear, DateUtils.getMonthString(logMonth - 1, DateUtils.LENGTH_LONG),
                    logDays);
        }
        break;
    case TIMES_POPUP:
        title = getString(R.string.timespopup);
        if (fileExplorer == null) {
            items = null;
        } else {
            items = fileExplorer.getTimes(logYear, logMonth, logDay);
        }
        break;
    case MOVESTART_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();
        if (moveStartBusy) {
            title = null;
        } else {
            moveStartBusy = true;
            title = getString(R.string.movestartpopup);
            items = getResources().getStringArray(R.array.start_popup_dialog_items);
            if (SenseGlobals.stopState.equals(SenseGlobals.StopState.STOP))
                items = Arrays.copyOfRange(items, 1, iEnd);
            else
                items = Arrays.copyOfRange(items, 0, iEnd);
            cancelable = false;
        }
        break;
    case STEP_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();
        timeOut = 10000;
        switch (step) {
        case 0:
            title = getString(R.string.recoverypopup);
            items = getResources().getStringArray(R.array.fitnessorrecovery_popup_dialog_items);
            cancelable = false;
            break;
        case 1:
            title = getString(R.string.step1settingspopup);
            List<String> list = new ArrayList<String>();
            String profile = PreferenceKey.getProfileName();
            list.add(getString(R.string.step1_bikeprofile, profile));
            //list.add(getString(R.string.popitem_wheelcirumference, prefs.getWheelCirc()));
            if (PreferenceKey.USEPAIRING.isTrue())
                list.add(getString(R.string.popitem_pairing_on, profile));
            else
                list.add(getString(R.string.popitem_pairing_off, profile));
            BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
            if (adapter != null && adapter.isEnabled())
                list.add(getString(R.string.popitem_bluetooth_on));
            else
                list.add(getString(R.string.popitem_bluetooth_off));
            list.add(getString(R.string.step_continue));
            items = list.toArray(new String[0]);
            cancelable = false;
            break;
        case 2:
            if (PreferenceKey.XTRAVALUES.isTrue()) {
                title = getString(R.string.startpopup);
                iEnd = 3;
            } else {
                title = getString(R.string.step2startpopup);
                iEnd = 4;
            }
            cancelable = false;
            if (title == null)
                title = getString(R.string.startpopup);
            items = getResources().getStringArray(R.array.start_popup_dialog_items);
            if (SenseGlobals.stopState.equals(SenseGlobals.StopState.STOP)) {
                items = Arrays.copyOfRange(items, 1, iEnd);
                startOptions = 3;
            } else {
                items = Arrays.copyOfRange(items, 0, iEnd);
                startOptions = 4;
            }
            break;
        }
        break;
    case START_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();
        if (title == null)
            title = getString(R.string.startpopup);
        timeOut = 10000;
        items = getResources().getStringArray(R.array.start_popup_dialog_items);
        if (SenseGlobals.stopState.equals(SenseGlobals.StopState.STOP))
            items = Arrays.copyOfRange(items, 1, iEnd);
        else
            items = Arrays.copyOfRange(items, 0, iEnd);
        break;
    case ARGOSSTOP_POPUP:
        cancelable = false;
        switch (argosStopStep) {
        case 0:
            title = getString(R.string.intensitypopup);
            items = getResources().getStringArray(R.array.intensity_popup_dialog_items);
            break;
        case 1:
            title = getString(R.string.fitnesspopup);
            items = getResources().getStringArray(R.array.fitnessorrecovery_popup_dialog_items);
            break;
        }
        break;
    case FULLSTOP_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();
        title = getString(R.string.stoppopup);
        items = getResources().getStringArray(R.array.stop_popup_dialog_items);
        break;
    case STOP_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();
        title = getString(R.string.stoppopup);
        items = getResources().getStringArray(R.array.stop_popup_dialog_items);
        break;
    case SHARE_POPUP:
        title = getString(R.string.sharepopup);
        items = getResources().getStringArray(R.array.share_popup_dialog_items);
        if (Globals.testing.isNoTest())
            items = Arrays.copyOf(items, items.length - 1);
        break;
    case INTERVAL_POPUP:
        title = getString(R.string.menu_interval);
        items = getResources().getStringArray(R.array.interval_popup_dialog_items);
        break;
    case GPX_POPUP:
        title = getString(R.string.menu_gpx);
        FileExplorer.FileList list = FileExplorer.getFileList(
                new String[] { Globals.getDataPath(), Globals.getDownloadPath(), SenseGlobals.getGpxPath() },
                new String[] { ".gpx" }, false);
        items = list.items;
        lookup = list.lookup;
        break;
    }
    if (title != null && items != null && items.length > 0) {
        if (!PopupDialog.showPopupDialog(getFragmentManager(), title, dialogId, viewId, items, lookup,
                cancelable, timeOut, defaultChoice) && dialogId == STEP_POPUP)
            popupToShow = STEP_POPUP;
    }
}

From source file:com.plusot.senselib.SenseMain.java

@SuppressWarnings("deprecation")
public void onPopupResult(int dialogId, int viewId, int iWhich, int itemsSize, String sWhich, String sTag) { // , int tag) {
    switch (dialogId) {
    case VALUE_POPUP:
        switch (iWhich) {
        /*case 0://from w w  w .  j av a 2s  .  co m
           showPopupDialog(VALUESELECT_POPUP, viewId, null); // , 0);
           break;*/
        case 0:
            showMultiChoiceDialog(VALUESELECT_POPUP, viewId);
            break;
        case 1:
            //            if (SenseGlobals.isLite) 
            //               showLiteWarning();
            //            else 
            if (PreferenceKey.VOICEON.isTrue())
                showMultiChoiceDialog(SPEECHSELECT_POPUP, viewId);
            else
                warnNoSpeech();
            break;
        case 2:
            if (popupValue == null) {
                popupValue = viewGetCurrentValue(viewId);
            }
            if (popupValue != null) {
                final String[] units = Unit.getValidUnits(popupValue.getValueType().getUnitType(), this);
                showPopupDialog(UNIT_POPUP, viewId, units);
            }
            break;
        case 3:
            if (sWhich.equals(getString(R.string.calibrate))) {
                calibrate();
            } else if (sWhich.equals(getString(R.string.set_level))) {
                if (Manager.managers.get(ManagerType.SENSOR_MANAGER) == null)
                    return;
                ((AndroidSensorManager) Manager.managers.get(ManagerType.SENSOR_MANAGER)).setLevel();
                ToastHelper.showToastLong(R.string.level_message);
            }
            break;
        }
        break;
    case UNIT_POPUP:
        final Unit unit = Unit.getUnitByChoiceString(sWhich, this);
        if (popupValue != null) {
            popupValue.setUnit(unit);
        }
        break;
    case VALUESELECT_POPUP:
        viewSetValue(viewId, Value.getValueByString(this, sWhich));
        ToastHelper.showToastShort(getString(R.string.hint_long_click));
        saveConfiguration();
        break;
    case YEAR_POPUP:
        logYear = sWhich;
        showPopupDialog(MONTH_POPUP, viewId, null); // , 0);
        break;
    case MONTH_POPUP:
        logMonth = logMonths[iWhich];
        LLog.d(Globals.TAG, CLASSTAG + ".showPopupDialog: logMonth = " + logMonth);
        showPopupDialog(DAY_POPUP, viewId, null); // , 0);
        break;
    case DAY_POPUP:
        logDay = logDays[iWhich];

        if (fileExplorer != null) {
            switch (fileExplorer.getTag()) {
            case FileExplorer.ACTIVITY_TAG:
                showPopupDialog(TIMES_POPUP, viewId, null);
                break;
            }
        }
        break;
    case TIMES_POPUP:
        if (fileExplorer != null) {
            switch (fileExplorer.getTag()) {
            case FileExplorer.ACTIVITY_TAG:
                stopActivity("onPopupResult", false);
                ToastHelper.showToastLong(getString(R.string.chosen_file) + " = " + logDay + " "
                        + DateUtils.getMonthString(logMonth - 1, DateUtils.LENGTH_LONG) + " " + logYear + " "
                        + sWhich);

                DataLog dataLog = DataLog.getInstance();
                if (dataLog != null) {
                    String file = fileExplorer.getFileList(logYear, logMonth, logDay, sWhich);
                    if (file != null) {
                        SenseGlobals.replaySession = logYear + String.format("%02d%02d", logMonth, logDay) + "-"
                                + sWhich.substring(0, 2) + sWhich.substring(3, 5) + sWhich.substring(6, 8);
                        LLog.d(Globals.TAG,
                                CLASSTAG + ".onPopupResult: ReplaySession = " + SenseGlobals.replaySession);
                        dataLog.readCsv(new String[] { file }, this);
                    }
                }
                //               if (showMap) showLocation();
                break;
            }
        }
        break;
    case STEP_POPUP:
        switch (step) {
        case 0:
            argosRecovery = 6 + iWhich;
            step = 1;
            showPopupDialog(STEP_POPUP, VIEW_ID_BASE + viewsAdded - 1, null);
            break;
        case 1:
            LLog.d(Globals.TAG, CLASSTAG + ".onPopuResult: STEP1SETTINGS_POPUP = " + iWhich);
            //ActivityUtil.lockScreenOrientation(this);
            switch (iWhich) {
            case 0:
                startActivityForResult(new Intent(this, BikeSettingsActivity.class), RESULT_STEP1);
                break;
            case 1:
                startActivityForResult(new Intent(SenseMain.this, AntSettingsActivity.class), RESULT_STEP1);
                break;
            case 2:
                startActivityForResult(new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS),
                        RESULT_STEP1);
                break;
            default:
                //enableAnt();
                step = 2;
                showPopupDialog(STEP_POPUP, VIEW_ID_BASE + viewsAdded - 1, null);
                break;
            }
            break;
        case 2:
            if (iWhich == startOptions - 1)
                startUpDialogs("STEP2START_POPUP");
            else {
                View view = this.findViewById(R.id.main_layout);
                if (view != null)
                    view.setVisibility(View.VISIBLE);

                if (iWhich >= 0 && iWhich <= startOptions - 3)
                    startActivity(iWhich == startOptions - 3);
                stepsDone = true;
            }
            lastAskForActivityStart = System.currentTimeMillis();
            break;
        }
        break;
    case MOVESTART_POPUP:
        moveStartBusy = false;
        lastAskForActivityStart = System.currentTimeMillis();
    case START_POPUP:
        if (iWhich >= 0 && iWhich <= itemsSize - 2)
            startActivity(iWhich == itemsSize - 2);

        break;
    case ARGOSSTOP_POPUP:
        switch (argosStopStep) {
        case 0:
            SimpleLog.getInstance(SimpleLogType.TEXT, ARGOS_MENTALSTATEFILE).log("recovery=" + argosRecovery);
            SimpleLog.getInstance(SimpleLogType.TEXT, ARGOS_MENTALSTATEFILE).log("intensity=" + (6 + iWhich));
            argosStopStep = 1;
            showPopupDialog(ARGOSSTOP_POPUP, VIEW_ID_BASE + viewsAdded - 1, null);

            break;
        case 1:
            SimpleLog.getInstance(SimpleLogType.TEXT, ARGOS_MENTALSTATEFILE).log("fitness=" + (6 + iWhich));
            new InputDialog(this, 666, R.string.remarkspopup_title, R.string.remarkspopup_description, "",
                    R.string.remarkspopup_hint, new InputDialog.Listener() {

                        @Override
                        public void onClose(int id, String temp) {
                            SimpleLog.getInstance(SimpleLogType.TEXT, ARGOS_MENTALSTATEFILE)
                                    .log("remark=" + temp);
                            argosStopStep = 2;
                            new SleepAndWake(new SleepAndWake.Listener() {
                                @Override
                                public void onWake() {
                                    shouldFinish = (shouldFinish == 1) ? 2 : 0;
                                    sendMail(true);
                                }
                            }, 100);
                        }
                    }).show();
            break;
        }
        break;

    case FULLSTOP_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();

        if (iWhich == 0) {
            ToastHelper.showToastLong(R.string.toast_pause);
            pauseActivity("onPopupResult");
            finishIt();
        } else {
            stopActivity("onPopupResult", true);
        }
        //         if (dialogId == FULLSTOP_POPUP) finishIt();

        break;
    case STOP_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();
        if (iWhich == 0) {
            ToastHelper.showToastLong(R.string.toast_pause);
            pauseActivity("onPopupResult");
        } else {
            stopActivity("onPopupResult", false);
        }
        break;
    case SHARE_POPUP:
        switch (iWhich) {
        case 0:
            this.sendMail(false);
            break;
        case 1:
            //            if (SenseGlobals.isLite) {
            //               this.showLiteWarning();
            //            } else 
            if (!PreferenceKey.HTTPPOST.isTrue())
                showTweetWarning();
            else {
                String link = getString(R.string.tweet_msg, Globals.TAG,
                        PreferenceKey.SHARE_URL.getString() + "?device=" + SenseUserInfo.getDeviceId(),
                        TimeUtil.formatTime(System.currentTimeMillis(), "EEE dd MMM HH:mm:ss"));
                int session = HttpSender.getSession();
                if (session >= 0)
                    link += "&session=" + session;
                new Tweet(this, null).send(link);
            }
            break;
        case 2:
            //            if (SenseGlobals.isLite)
            //               this.showLiteWarning();
            //            else
            this.sendTP();
            break;
        case 3:
            if (!Value.fileTypes.contains(FileType.FIT)) {
                this.warnNoFit();
                break;
            }
            switch (new SendStravaMail(this).send()) {
            case SUCCES:
                break;
            case NOACCOUNT:
                this.warnAccount();
                break;
            case NOFILES:
                this.warnNoFilesToday();
                break;
            }
            break;
        case 4:
            StringBuffer buf = new StringBuffer();
            buf.append("\nApp version: " + UserInfo.appNameVersion() + "\n");
            buf.append("Android version: " + Build.VERSION.RELEASE + "\n");
            buf.append("Android incremental: " + Build.VERSION.INCREMENTAL + "\n");
            buf.append("Android SDK: " + Build.VERSION.SDK_INT + "\n");
            //buf.append("FINGERPRINT: "+Build.FINGERPRINT+ "\n");
            buf.append("Device manufacturer: " + Build.MANUFACTURER + "\n");
            buf.append("Device brand: " + Build.BRAND + "\n");
            buf.append("Device model: " + Build.MODEL + "\n");
            buf.append("Device board: " + Build.BOARD + "\n");
            buf.append("Device id: " + Build.DEVICE);

            new LogMail(this,
                    getString(R.string.reportmail, TimeUtil.formatTime(System.currentTimeMillis()), buf),
                    getString(R.string.mail_sending), getString(R.string.no_mail_to_send), null);
        }
        break;
    case INTERVAL_POPUP:
        switch (iWhich) {
        case 0:
            newInterval();
            break;
        case 1:
            new LapsDialog(this, Laps.getLaps() - 1, false).show();
        }
        break;
    case GPX_POPUP:
        ToastHelper.showToastLong(getString(R.string.get_gpx_file, sWhich + " " + sTag));
        getGPX(sTag);
        break;
    }

}