Search in sources :

Example 1 with AppCompatCheckedTextView

use of android.support.v7.widget.AppCompatCheckedTextView in project Osmand by osmandapp.

the class SettingsGeneralActivity method addLocalPrefs.

private void addLocalPrefs(PreferenceGroup screen) {
    drivingRegionPreference.setTitle(R.string.driving_region);
    drivingRegionPreference.setSummary(R.string.driving_region_descr);
    drivingRegionPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            final AlertDialog.Builder b = new AlertDialog.Builder(SettingsGeneralActivity.this);
            b.setTitle(getString(R.string.driving_region));
            final List<DrivingRegion> drs = new ArrayList<>();
            drs.add(null);
            drs.addAll(Arrays.asList(DrivingRegion.values()));
            int sel = -1;
            DrivingRegion selectedDrivingRegion = settings.DRIVING_REGION.get();
            if (settings.DRIVING_REGION_AUTOMATIC.get()) {
                sel = 0;
            }
            for (int i = 1; i < drs.size(); i++) {
                if (sel == -1 && drs.get(i) == selectedDrivingRegion) {
                    sel = i;
                    break;
                }
            }
            final int selected = sel;
            final ArrayAdapter<DrivingRegion> singleChoiceAdapter = new ArrayAdapter<DrivingRegion>(SettingsGeneralActivity.this, R.layout.single_choice_description_item, R.id.text1, drs) {

                @NonNull
                @Override
                public View getView(int position, View convertView, @NonNull ViewGroup parent) {
                    View v = convertView;
                    if (v == null) {
                        LayoutInflater inflater = SettingsGeneralActivity.this.getLayoutInflater();
                        v = inflater.inflate(R.layout.single_choice_description_item, parent, false);
                    }
                    DrivingRegion item = getItem(position);
                    AppCompatCheckedTextView title = (AppCompatCheckedTextView) v.findViewById(R.id.text1);
                    TextView desc = (TextView) v.findViewById(R.id.description);
                    if (item != null) {
                        title.setText(getString(item.name));
                        desc.setVisibility(View.VISIBLE);
                        desc.setText(item.getDescription(v.getContext()));
                    } else {
                        title.setText(getString(R.string.driving_region_automatic));
                        desc.setVisibility(View.GONE);
                    }
                    title.setChecked(position == selected);
                    return v;
                }
            };
            b.setAdapter(singleChoiceAdapter, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (drs.get(which) == null) {
                        settings.DRIVING_REGION_AUTOMATIC.set(true);
                        MapViewTrackingUtilities mapViewTrackingUtilities = MapActivity.getSingleMapViewTrackingUtilities();
                        if (mapViewTrackingUtilities != null) {
                            mapViewTrackingUtilities.resetDrivingRegionUpdate();
                        }
                    } else {
                        settings.DRIVING_REGION_AUTOMATIC.set(false);
                        settings.DRIVING_REGION.set(drs.get(which));
                    }
                    updateAllSettings();
                }
            });
            b.setNegativeButton(R.string.shared_string_cancel, null);
            b.show();
            return true;
        }
    });
    String[] entries;
    String[] entrieValues;
    MetricsConstants[] mvls = MetricsConstants.values();
    entries = new String[mvls.length];
    for (int i = 0; i < entries.length; i++) {
        entries[i] = mvls[i].toHumanString(getMyApplication());
    }
    registerListPreference(settings.METRIC_SYSTEM, screen, entries, mvls);
    Integer[] cvls = new Integer[5];
    cvls[0] = PointDescription.FORMAT_DEGREES;
    cvls[1] = PointDescription.FORMAT_MINUTES;
    cvls[2] = PointDescription.FORMAT_SECONDS;
    cvls[3] = PointDescription.UTM_FORMAT;
    cvls[4] = PointDescription.OLC_FORMAT;
    entries = new String[5];
    entries[0] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_DEGREES);
    entries[1] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_MINUTES);
    entries[2] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_SECONDS);
    entries[3] = PointDescription.formatToHumanString(this, PointDescription.UTM_FORMAT);
    entries[4] = PointDescription.formatToHumanString(this, PointDescription.OLC_FORMAT);
    registerListPreference(settings.COORDINATES_FORMAT, screen, entries, cvls);
    // See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
    // Hardy maintenance 2016-05-29:
    // - Include languages if their translation is >= ~10%    (but any language will be visible if it is the device's system locale)
    // - Mark as "incomplete" if                    < ~80%
    String incompleteSuffix = " (" + getString(R.string.incomplete_locale) + ")";
    // Add " (Device language)" to system default entry in Latin letters, so it can be more easily identified if a foreign language has been selected by mistake
    String latinSystemDefaultSuffix = " (" + getString(R.string.system_locale_no_translate) + ")";
    // getResources().getAssets().getLocales();
    entrieValues = new String[] { "", "en", "af", "ar", "ast", "az", "be", "be_BY", "bg", "ca", "cs", "cy", "da", "de", "el", "en_GB", "eo", "es", "es_AR", "es_US", "eu", "fa", "fi", "fr", "gl", "he", "hr", "hsb", "hu", "hy", "is", "it", "ja", "ka", "kab", "kn", "ko", "lt", "lv", "ml", "mr", "nb", "nl", "nn", "pl", "pt", "pt_BR", "ro", "ru", "sc", "sk", "sl", "sr", "sr+Latn", "sv", "tr", "uk", "vi", "zh_CN", "zh_TW" };
    entries = new String[] { getString(R.string.system_locale) + latinSystemDefaultSuffix, getString(R.string.lang_en), getString(R.string.lang_af) + incompleteSuffix, getString(R.string.lang_ar), getString(R.string.lang_ast) + incompleteSuffix, getString(R.string.lang_az), getString(R.string.lang_be), getString(R.string.lang_be_by), getString(R.string.lang_bg), getString(R.string.lang_ca), getString(R.string.lang_cs), getString(R.string.lang_cy) + incompleteSuffix, getString(R.string.lang_da), getString(R.string.lang_de), getString(R.string.lang_el) + incompleteSuffix, getString(R.string.lang_en_gb), getString(R.string.lang_eo), getString(R.string.lang_es), getString(R.string.lang_es_ar), getString(R.string.lang_es_us), getString(R.string.lang_eu) + incompleteSuffix, getString(R.string.lang_fa), getString(R.string.lang_fi) + incompleteSuffix, getString(R.string.lang_fr), getString(R.string.lang_gl) + incompleteSuffix, getString(R.string.lang_he) + incompleteSuffix, getString(R.string.lang_hr) + incompleteSuffix, getString(R.string.lang_hsb) + incompleteSuffix, getString(R.string.lang_hu), getString(R.string.lang_hy), getString(R.string.lang_is) + incompleteSuffix, getString(R.string.lang_it), getString(R.string.lang_ja), getString(R.string.lang_ka) + incompleteSuffix, getString(R.string.lang_kab) + incompleteSuffix, getString(R.string.lang_kn) + incompleteSuffix, getString(R.string.lang_ko), getString(R.string.lang_lt), getString(R.string.lang_lv), getString(R.string.lang_ml) + incompleteSuffix, getString(R.string.lang_mr) + incompleteSuffix, getString(R.string.lang_nb), getString(R.string.lang_nl), getString(R.string.lang_nn) + incompleteSuffix, getString(R.string.lang_pl), getString(R.string.lang_pt), getString(R.string.lang_pt_br), getString(R.string.lang_ro) + incompleteSuffix, getString(R.string.lang_ru), getString(R.string.lang_sc), getString(R.string.lang_sk), getString(R.string.lang_sl), getString(R.string.lang_sr) + incompleteSuffix, getString(R.string.lang_sr_latn) + incompleteSuffix, getString(R.string.lang_sv), getString(R.string.lang_tr), getString(R.string.lang_uk), getString(R.string.lang_vi) + incompleteSuffix, getString(R.string.lang_zh_cn) + incompleteSuffix, getString(R.string.lang_zh_tw) };
    String[] valuesPl = ConfigureMapMenu.getSortedMapNamesIds(this, entries, entries);
    String[] idsPl = ConfigureMapMenu.getSortedMapNamesIds(this, entrieValues, entries);
    registerListPreference(settings.PREFERRED_LOCALE, screen, valuesPl, idsPl);
    // Add " (Display language)" to menu title in Latin letters for all non-en languages
    if (!getResources().getString(R.string.preferred_locale).equals(getResources().getString(R.string.preferred_locale_no_translate))) {
        ((ListPreference) screen.findPreference(settings.PREFERRED_LOCALE.getId())).setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")");
    }
// This setting now only in "Confgure map" menu
// String[] values = ConfigureMapMenu.getMapNamesValues(this, ConfigureMapMenu.mapNamesIds);
// String[] ids = ConfigureMapMenu.getSortedMapNamesIds(this, ConfigureMapMenu.mapNamesIds, values);
// registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.getMapNamesValues(this, ids), ids);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) MapViewTrackingUtilities(net.osmand.plus.base.MapViewTrackingUtilities) DrivingRegion(net.osmand.plus.OsmandSettings.DrivingRegion) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) NonNull(android.support.annotation.NonNull) List(java.util.List) ArrayList(java.util.ArrayList) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) TextView(android.widget.TextView) ViewGroup(android.view.ViewGroup) ListPreference(android.preference.ListPreference) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) View(android.view.View) TextView(android.widget.TextView) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) LayoutInflater(android.view.LayoutInflater) MetricsConstants(net.osmand.plus.OsmandSettings.MetricsConstants) OnClickListener(android.content.DialogInterface.OnClickListener) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with AppCompatCheckedTextView

use of android.support.v7.widget.AppCompatCheckedTextView in project Osmand by osmandapp.

the class ConfigureMapMenu method createRenderingAttributeItems.

private void createRenderingAttributeItems(List<RenderingRuleProperty> customRules, final ContextMenuAdapter adapter, final MapActivity activity) {
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity).setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_renderer, activity).setDescription(getRenderDescr(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_map).setListener(new ContextMenuAdapter.ItemClickListener() {

        @Override
        public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
            AlertDialog.Builder bld = new AlertDialog.Builder(activity);
            bld.setTitle(R.string.renderers);
            final OsmandApplication app = activity.getMyApplication();
            final ArrayList<String> items = new ArrayList<>(app.getRendererRegistry().getRendererNames());
            boolean nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
            final List<String> visibleNamesList = new ArrayList<>();
            int selected = -1;
            final String selectedName = app.getRendererRegistry().getCurrentSelectedRenderer().getName();
            int i = 0;
            Iterator<String> iterator = items.iterator();
            while (iterator.hasNext()) {
                String item = iterator.next();
                if (nauticalPluginDisabled && item.equals(RendererRegistry.NAUTICAL_RENDER)) {
                    iterator.remove();
                } else {
                    if (item.equals(selectedName)) {
                        selected = i;
                    }
                    String translation = RendererRegistry.getTranslatedRendererName(activity, item);
                    visibleNamesList.add(translation != null ? translation : item.replace('_', ' ').replace('-', ' '));
                    i++;
                }
            }
            bld.setSingleChoiceItems(visibleNamesList.toArray(new String[visibleNamesList.size()]), selected, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String renderer = items.get(which);
                    RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
                    if (loaded != null) {
                        OsmandMapTileView view = activity.getMapView();
                        view.getSettings().RENDERER.set(renderer);
                        app.getRendererRegistry().setCurrentSelectedRender(loaded);
                        refreshMapComplete(activity);
                    } else {
                        Toast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
                    }
                    adapter.getItem(pos).setDescription(getRenderDescr(activity));
                    activity.getDashboard().refreshContent(true);
                    dialog.dismiss();
                }
            });
            bld.setNegativeButton(R.string.shared_string_dismiss, null);
            bld.show();
            return false;
        }
    }).createItem());
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_mode, activity).setDescription(getDayNightDescr(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(getDayNightIcon(activity)).setListener(new ItemClickListener() {

        @Override
        public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
            final OsmandMapTileView view = activity.getMapView();
            AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
            bld.setTitle(R.string.daynight);
            final String[] items = new String[OsmandSettings.DayNightMode.values().length];
            for (int i = 0; i < items.length; i++) {
                items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(activity.getMyApplication());
            }
            int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
            bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
                    refreshMapComplete(activity);
                    dialog.dismiss();
                    activity.getDashboard().refreshContent(true);
                // adapter.getItem(pos).setDescription(s, getDayNightDescr(activity));
                // ad.notifyDataSetInvalidated();
                }
            });
            bld.setNegativeButton(R.string.shared_string_dismiss, null);
            bld.show();
            return false;
        }
    }).createItem());
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_magnifier, activity).setDescription(String.format(Locale.UK, "%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %").setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_action_map_magnifier).setListener(new ContextMenuAdapter.ItemClickListener() {

        @Override
        public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
            final OsmandMapTileView view = activity.getMapView();
            final OsmandSettings.OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY;
            final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
            int p = (int) (mapDensity.get() * 100);
            final TIntArrayList tlist = new TIntArrayList(new int[] { 33, 50, 75, 100, 150, 200, 300, 400 });
            final List<String> values = new ArrayList<>();
            int i = -1;
            for (int k = 0; k <= tlist.size(); k++) {
                final boolean end = k == tlist.size();
                if (i == -1) {
                    if ((end || p < tlist.get(k))) {
                        values.add(p + " %");
                        i = k;
                    } else if (p == tlist.get(k)) {
                        i = k;
                    }
                }
                if (k < tlist.size()) {
                    values.add(tlist.get(k) + " %");
                }
            }
            if (values.size() != tlist.size()) {
                tlist.insert(i, p);
            }
            bld.setTitle(R.string.map_magnifier);
            bld.setSingleChoiceItems(values.toArray(new String[values.size()]), i, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    int p = tlist.get(which);
                    mapDensity.set(p / 100.0f);
                    view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity());
                    MapRendererContext mapContext = NativeCoreContext.getMapRendererContext();
                    if (mapContext != null) {
                        mapContext.updateMapSettings();
                    }
                    adapter.getItem(pos).setDescription(String.format(Locale.UK, "%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %");
                    ad.notifyDataSetInvalidated();
                    dialog.dismiss();
                }
            });
            bld.setNegativeButton(R.string.shared_string_dismiss, null);
            bld.show();
            return false;
        }
    }).createItem());
    ContextMenuItem props;
    props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR);
    if (props != null) {
        adapter.addItem(props);
    }
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.text_size, activity).setDescription(getScale(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_action_map_text_size).setListener(new ContextMenuAdapter.ItemClickListener() {

        @Override
        public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
            final OsmandMapTileView view = activity.getMapView();
            AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
            // test old descr as title
            b.setTitle(R.string.text_size);
            final Float[] txtValues = new Float[] { 0.75f, 1f, 1.25f, 1.5f, 2f, 3f };
            int selected = -1;
            final String[] txtNames = new String[txtValues.length];
            for (int i = 0; i < txtNames.length; i++) {
                txtNames[i] = (int) (txtValues[i] * 100) + " %";
                if (Math.abs(view.getSettings().TEXT_SCALE.get() - txtValues[i]) < 0.1f) {
                    selected = i;
                }
            }
            b.setSingleChoiceItems(txtNames, selected, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    view.getSettings().TEXT_SCALE.set(txtValues[which]);
                    refreshMapComplete(activity);
                    adapter.getItem(pos).setDescription(getScale(activity));
                    ad.notifyDataSetInvalidated();
                    dialog.dismiss();
                }
            });
            b.setNegativeButton(R.string.shared_string_dismiss, null);
            b.show();
            return false;
        }
    }).createItem());
    String localeDescr = activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get();
    localeDescr = localeDescr == null || localeDescr.equals("") ? activity.getString(R.string.local_map_names) : localeDescr;
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_locale, activity).setDescription(localeDescr).setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_action_map_language).setListener(new ContextMenuAdapter.ItemClickListener() {

        @Override
        public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
            final OsmandMapTileView view = activity.getMapView();
            final AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
            b.setTitle(activity.getString(R.string.map_locale));
            final String[] txtIds = getSortedMapNamesIds(activity, mapNamesIds, getMapNamesValues(activity, mapNamesIds));
            final String[] txtValues = getMapNamesValues(activity, txtIds);
            int selected = -1;
            for (int i = 0; i < txtIds.length; i++) {
                if (view.getSettings().MAP_PREFERRED_LOCALE.get().equals(txtIds[i])) {
                    selected = i;
                    break;
                }
            }
            selectedLanguageIndex = selected;
            transliterateNames = view.getSettings().MAP_TRANSLITERATE_NAMES.get();
            final OnCheckedChangeListener translitChangdListener = new OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    transliterateNames = isChecked;
                }
            };
            final ArrayAdapter<CharSequence> singleChoiceAdapter = new ArrayAdapter<CharSequence>(activity, R.layout.single_choice_switch_item, R.id.text1, txtValues) {

                @NonNull
                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    View v = super.getView(position, convertView, parent);
                    AppCompatCheckedTextView checkedTextView = (AppCompatCheckedTextView) v.findViewById(R.id.text1);
                    if (position == selectedLanguageIndex && position > 0) {
                        checkedTextView.setChecked(true);
                        v.findViewById(R.id.topDivider).setVisibility(View.VISIBLE);
                        v.findViewById(R.id.bottomDivider).setVisibility(View.VISIBLE);
                        v.findViewById(R.id.switchLayout).setVisibility(View.VISIBLE);
                        TextView switchText = (TextView) v.findViewById(R.id.switchText);
                        switchText.setText(activity.getString(R.string.translit_name_if_miss, txtValues[position]));
                        SwitchCompat check = (SwitchCompat) v.findViewById(R.id.check);
                        check.setChecked(transliterateNames);
                        check.setOnCheckedChangeListener(translitChangdListener);
                    } else {
                        checkedTextView.setChecked(position == selectedLanguageIndex);
                        v.findViewById(R.id.topDivider).setVisibility(View.GONE);
                        v.findViewById(R.id.bottomDivider).setVisibility(View.GONE);
                        v.findViewById(R.id.switchLayout).setVisibility(View.GONE);
                    }
                    return v;
                }
            };
            b.setAdapter(singleChoiceAdapter, null);
            b.setSingleChoiceItems(txtValues, selected, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    selectedLanguageIndex = which;
                    ((AlertDialog) dialog).getListView().setSelection(which);
                    singleChoiceAdapter.notifyDataSetChanged();
                }
            });
            b.setNegativeButton(R.string.shared_string_cancel, null);
            b.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    view.getSettings().MAP_TRANSLITERATE_NAMES.set(selectedLanguageIndex > 0 && transliterateNames);
                    AlertDialog dlg = (AlertDialog) dialog;
                    int index = dlg.getListView().getCheckedItemPosition();
                    view.getSettings().MAP_PREFERRED_LOCALE.set(txtIds[index]);
                    refreshMapComplete(activity);
                    String localeDescr = txtIds[index];
                    localeDescr = localeDescr == null || localeDescr.equals("") ? activity.getString(R.string.local_map_names) : localeDescr;
                    adapter.getItem(pos).setDescription(localeDescr);
                    ad.notifyDataSetInvalidated();
                }
            });
            b.show();
            return false;
        }
    }).createItem());
    props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_bus_dark, "transport", null, adapter, activity, true);
    if (props != null) {
        adapter.addItem(props);
    }
    props = createProperties(customRules, null, R.string.rendering_category_details, R.drawable.ic_action_layers_dark, "details", null, adapter, activity, true);
    if (props != null) {
        adapter.addItem(props);
    }
    props = createProperties(customRules, null, R.string.rendering_category_hide, R.drawable.ic_action_hide, "hide", null, adapter, activity, true);
    if (props != null) {
        adapter.addItem(props);
    }
    List<RenderingRuleProperty> customRulesIncluded = new ArrayList<>();
    for (RenderingRuleProperty p : customRules) {
        if (p.getAttrName().equals(HIKING_ROUTES_OSMC_ATTR)) {
            customRulesIncluded.add(p);
            break;
        }
    }
    props = createProperties(customRules, customRulesIncluded, R.string.rendering_category_routes, R.drawable.ic_action_map_routes, "routes", null, adapter, activity, true);
    if (props != null) {
        adapter.addItem(props);
    }
    if (getCustomRenderingPropertiesSize(customRules) > 0) {
        adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.rendering_category_others, activity).setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
        createCustomRenderingProperties(adapter, activity, customRules);
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) NonNull(android.support.annotation.NonNull) Iterator(java.util.Iterator) TIntArrayList(gnu.trove.list.array.TIntArrayList) List(java.util.List) ArrayList(java.util.ArrayList) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) TextView(android.widget.TextView) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) ContextMenuItem(net.osmand.plus.ContextMenuItem) ViewGroup(android.view.ViewGroup) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage) TIntArrayList(gnu.trove.list.array.TIntArrayList) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) MapRendererContext(net.osmand.core.android.MapRendererContext) CompoundButton(android.widget.CompoundButton) ArrayAdapter(android.widget.ArrayAdapter) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 3 with AppCompatCheckedTextView

use of android.support.v7.widget.AppCompatCheckedTextView in project EssayJoke by qiyei2015.

the class SkinAppCompatViewInflater method createView.

public final View createView(View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs, boolean inheritContext, boolean readAndroidTheme, boolean readAppTheme) {
    final Context originalContext = context;
    // by using the parent's context
    if (inheritContext && parent != null) {
        context = parent.getContext();
    }
    if (readAndroidTheme || readAppTheme) {
        // We then apply the theme on the context, if specified
        context = themifyContext(context, attrs, readAndroidTheme, readAppTheme);
    }
    View view = null;
    // We need to 'inject' our tint aware Views in place of the standard framework versions
    switch(name) {
        case "TextView":
            view = new AppCompatTextView(context, attrs);
            break;
        case "ImageView":
            view = new AppCompatImageView(context, attrs);
            break;
        case "Button":
            view = new AppCompatButton(context, attrs);
            break;
        case "EditText":
            view = new AppCompatEditText(context, attrs);
            break;
        case "Spinner":
            view = new AppCompatSpinner(context, attrs);
            break;
        case "ImageButton":
            view = new AppCompatImageButton(context, attrs);
            break;
        case "CheckBox":
            view = new AppCompatCheckBox(context, attrs);
            break;
        case "RadioButton":
            view = new AppCompatRadioButton(context, attrs);
            break;
        case "CheckedTextView":
            view = new AppCompatCheckedTextView(context, attrs);
            break;
        case "AutoCompleteTextView":
            view = new AppCompatAutoCompleteTextView(context, attrs);
            break;
        case "MultiAutoCompleteTextView":
            view = new AppCompatMultiAutoCompleteTextView(context, attrs);
            break;
        case "RatingBar":
            view = new AppCompatRatingBar(context, attrs);
            break;
        case "SeekBar":
            view = new AppCompatSeekBar(context, attrs);
            break;
    }
    if (view == null) {
        // If the original context does not equal our themed context, then we need to manually
        // inflate it using the name so that android:theme takes effect.
        view = createViewFromTag(context, name, attrs);
    }
    if (view != null) {
        // If we have created a view, check it's android:onClick
        checkOnClickListener(view, attrs);
    }
    return view;
}
Also used : Context(android.content.Context) AppCompatSeekBar(android.support.v7.widget.AppCompatSeekBar) AppCompatRadioButton(android.support.v7.widget.AppCompatRadioButton) AppCompatRatingBar(android.support.v7.widget.AppCompatRatingBar) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageButton(android.support.v7.widget.AppCompatImageButton) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) AppCompatAutoCompleteTextView(android.support.v7.widget.AppCompatAutoCompleteTextView) View(android.view.View) AppCompatImageView(android.support.v7.widget.AppCompatImageView) AppCompatMultiAutoCompleteTextView(android.support.v7.widget.AppCompatMultiAutoCompleteTextView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageView(android.support.v7.widget.AppCompatImageView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) AppCompatMultiAutoCompleteTextView(android.support.v7.widget.AppCompatMultiAutoCompleteTextView) AppCompatAutoCompleteTextView(android.support.v7.widget.AppCompatAutoCompleteTextView)

Aggregations

AppCompatCheckedTextView (android.support.v7.widget.AppCompatCheckedTextView)3 View (android.view.View)3 DialogInterface (android.content.DialogInterface)2 NonNull (android.support.annotation.NonNull)2 AlertDialog (android.support.v7.app.AlertDialog)2 ViewGroup (android.view.ViewGroup)2 ArrayAdapter (android.widget.ArrayAdapter)2 TextView (android.widget.TextView)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Context (android.content.Context)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 EditTextPreference (android.preference.EditTextPreference)1 ListPreference (android.preference.ListPreference)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 AppCompatAutoCompleteTextView (android.support.v7.widget.AppCompatAutoCompleteTextView)1 AppCompatButton (android.support.v7.widget.AppCompatButton)1 AppCompatCheckBox (android.support.v7.widget.AppCompatCheckBox)1