Example usage for android.content.res Resources getDimensionPixelSize

List of usage examples for android.content.res Resources getDimensionPixelSize

Introduction

In this page you can find the example usage for android.content.res Resources getDimensionPixelSize.

Prototype

public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID for use as a size in raw pixels.

Usage

From source file:com.android.mail.browse.MessageHeaderView.java

public MessageHeaderView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mIsSnappy = false;//from  w  w  w . ja v a 2s. c om
    mEmailCopyMenu = new EmailCopyContextMenu(getContext());
    mInflater = LayoutInflater.from(context);
    mMyName = context.getString(R.string.me_object_pronoun);

    final Resources res = getResources();
    mContactPhotoWidth = res.getDimensionPixelSize(R.dimen.contact_image_width);
    mContactPhotoHeight = res.getDimensionPixelSize(R.dimen.contact_image_height);
    mTitleContainerMarginEnd = res.getDimensionPixelSize(R.dimen.conversation_view_margin_side);
}

From source file:net.toload.main.hd.candidate.CandidateView.java

public void clear() {
    if (DEBUG)//from   w  w  w  .j a  v a  2  s  . c om
        Log.i(TAG, "clear()");
    //mHeight =0; //Jeremy '12,5,6 hide candidate bar when candidateview is fixed.
    if (mSuggestions != null)
        mSuggestions.clear();
    mCount = 0;
    // Jeremy 11,8,14 close all popup on clear
    setComposingText("");
    mTargetScrollX = 0;
    mTotalWidth = 0;
    hideComposing();

    prepareLayout();
    mHandler.updateUI(0);

    Resources r = mContext.getResources();
    configHeight = (int) (r.getDimensionPixelSize(R.dimen.candidate_stripe_height) * mLIMEPref.getFontSize());
    mVerticalPadding = (int) (r.getDimensionPixelSize(R.dimen.candidate_vertical_padding)
            * mLIMEPref.getFontSize());
    configHeight = (int) (r.getDimensionPixelSize(R.dimen.candidate_stripe_height) * mLIMEPref.getFontSize());
    mHeight = configHeight + mVerticalPadding;

}

From source file:androidx.mediarouter.app.MediaRouteControllerDialog.java

/**
 * Sets the width of the dialog. Also called when configuration changes.
 */// w ww.j  ava2s. co m
void updateLayout() {
    int width = MediaRouteDialogHelper.getDialogWidth(mContext);
    getWindow().setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT);

    View decorView = getWindow().getDecorView();
    mDialogContentWidth = width - decorView.getPaddingLeft() - decorView.getPaddingRight();

    Resources res = mContext.getResources();
    mVolumeGroupListItemIconSize = res
            .getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_item_icon_size);
    mVolumeGroupListItemHeight = res.getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_item_height);
    mVolumeGroupListMaxHeight = res.getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_max_height);

    // Fetch art icons again for layout changes to resize it accordingly
    mArtIconBitmap = null;
    mArtIconUri = null;
    updateArtIconIfNeeded();
    update(false);
}

From source file:com.limewoodmedia.nsdroid.fragments.WACouncilFragment.java

private void setUpChartRenderer(XYMultipleSeriesRenderer chartRenderer) {
    Log.d(TAG, "Set up chart renderer");
    Resources r = getResources();
    float labelTextSize = r.getDimension(R.dimen.bar_chart_label_size);

    // For renderer
    forRenderer = new XYSeriesRenderer();
    forRenderer.setColor(r.getColor(R.color.wa_for));
    forRenderer.setChartValuesTextSize(labelTextSize);
    forRenderer.setDisplayChartValues(true);

    againstRenderer = new XYSeriesRenderer();
    againstRenderer.setColor(r.getColor(R.color.wa_against));
    againstRenderer.setChartValuesTextSize(labelTextSize);
    againstRenderer.setDisplayChartValues(true);

    chartRenderer.setZoomButtonsVisible(false);
    chartRenderer.setOrientation(XYMultipleSeriesRenderer.Orientation.HORIZONTAL);
    chartRenderer.setClickEnabled(true);
    chartRenderer.setInScroll(true);/*  w  w w. j  a va 2 s . c  o  m*/
    chartRenderer.setAntialiasing(true);
    chartRenderer.setShowLegend(false);
    chartRenderer.setTextTypeface(Typeface.DEFAULT);
    chartRenderer.setPanEnabled(false);
    chartRenderer.setShowLabels(false);
    chartRenderer.setXAxisMin(-0.5);
    chartRenderer.setXAxisMax(2.5);
    chartRenderer.setYAxisMin(0);
    chartRenderer.setXLabels(0);
    chartRenderer.setYLabels(0);
    chartRenderer.setBarWidth(r.getDimensionPixelSize(R.dimen.wa_bar_width));
    chartRenderer.setGridColor(Color.WHITE);
    chartRenderer.setMarginsColor(Color.WHITE);
    chartRenderer.setMargins(new int[] { 0, 0, 0, 0 });
    chartRenderer.setBackgroundColor(Color.WHITE);
    chartRenderer.setApplyBackgroundColor(true);
    chartRenderer.removeAllRenderers();
    chartRenderer.addSeriesRenderer(forRenderer);
    chartRenderer.addSeriesRenderer(againstRenderer);
}

From source file:com.android.dialer.DialtactsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Trace.beginSection(TAG + " onCreate");
    super.onCreate(savedInstanceState);

    mFirstLaunch = true;/* www  .j  a va 2s .c  om*/

    final Resources resources = getResources();
    mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large);

    Trace.beginSection(TAG + " setContentView");
    setContentView(R.layout.dialtacts_activity);
    Trace.endSection();
    getWindow().setBackgroundDrawable(null);

    Trace.beginSection(TAG + " setup Views");
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setCustomView(R.layout.search_edittext);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setBackgroundDrawable(null);

    SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView()
            .findViewById(R.id.search_view_container);
    searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);

    mActionBarController = new ActionBarController(this, searchEditTextLayout);

    mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
    mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
    mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button);
    searchEditTextLayout.findViewById(R.id.search_magnifying_glass)
            .setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.findViewById(R.id.search_box_start_search)
            .setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() {
        @Override
        public void onBackButtonClicked() {
            onBackPressed();
        }

        @Override
        public void onSearchViewClicked() {
            // Hide FAB, as the keyboard is shown.
            mFloatingActionButtonController.scaleOut();
        }
    });

    mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    mPreviouslySelectedTabIndex = ListsFragment.TAB_INDEX_SPEED_DIAL;
    final View floatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
    ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
    floatingActionButton.setOnClickListener(this);
    mFloatingActionButtonController = new FloatingActionButtonController(this, floatingActionButtonContainer,
            floatingActionButton);

    ImageButton optionsMenuButton = (ImageButton) searchEditTextLayout
            .findViewById(R.id.dialtacts_options_menu_button);
    optionsMenuButton.setOnClickListener(this);
    mOverflowMenu = buildOptionsMenu(searchEditTextLayout);
    optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());

    // Add the favorites fragment but only if savedInstanceState is null. Otherwise the
    // fragment manager is responsible for recreating it.
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT).commit();
    } else {
        mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
        mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
        mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
        mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
        mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
        mActionBarController.restoreInstanceState(savedInstanceState);
    }

    final boolean isLayoutRtl = DialerUtils.isRtl();
    if (mIsLandscape) {
        mSlideIn = AnimationUtils.loadAnimation(this,
                isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right);
        mSlideOut = AnimationUtils.loadAnimation(this,
                isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right);
    } else {
        mSlideIn = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_in_bottom);
        mSlideOut = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_out_bottom);
    }

    mSlideIn.setInterpolator(AnimUtils.EASE_IN);
    mSlideOut.setInterpolator(AnimUtils.EASE_OUT);

    mSlideIn.setAnimationListener(mSlideInListener);
    mSlideOut.setAnimationListener(mSlideOutListener);

    mParentLayout = (CoordinatorLayout) findViewById(R.id.dialtacts_mainlayout);
    mParentLayout.setOnDragListener(new LayoutOnDragListener());
    floatingActionButtonContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    final ViewTreeObserver observer = floatingActionButtonContainer.getViewTreeObserver();
                    if (!observer.isAlive()) {
                        return;
                    }
                    observer.removeOnGlobalLayoutListener(this);
                    int screenWidth = mParentLayout.getWidth();
                    mFloatingActionButtonController.setScreenWidth(screenWidth);
                    mFloatingActionButtonController.align(getFabAlignment(), false /* animate */);
                }
            });

    Trace.endSection();

    Trace.beginSection(TAG + " initialize smart dialing");
    mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
    SmartDialPrefix.initializeNanpSettings(this);
    Trace.endSection();
    Trace.endSection();
}

From source file:com.microsoft.mimickeralarm.appcore.AlarmListItemTouchHelperCallback.java

@Override
public void onChildDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX,
        float dY, int actionState, boolean isCurrentlyActive) {

    if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {

        View itemView = viewHolder.itemView;
        Resources resources = AlarmApplication.getAppContext().getResources();
        Bitmap icon = BitmapFactory.decodeResource(resources, R.drawable.delete_trash_can);
        int iconPadding = resources.getDimensionPixelOffset(R.dimen.alarm_list_delete_icon_padding);
        int maxDrawWidth = (iconPadding * 2) + icon.getWidth();

        Paint paint = new Paint();
        paint.setColor(ContextCompat.getColor(AlarmApplication.getAppContext(), R.color.red));

        int x = Math.round(Math.abs(dX));

        // Reset the dismiss flag if the view resets to its default position
        if (x == 0) {
            mCanDismiss = false;//from w  w w.j a va2  s. co m
        }

        // If we have travelled beyond the icon area via direct user interaction
        // we will dismiss when we get a swipe callback.  We do this to try to avoid
        // unwanted swipe dismissal
        if ((x > maxDrawWidth) && isCurrentlyActive) {
            mCanDismiss = true;
        }

        int drawWidth = Math.min(x, maxDrawWidth);
        // Cap the height of the drawable area to the selectable area - this improves the visual
        // for the first taller item in the alarm list
        int itemTop = itemView.getBottom() - resources.getDimensionPixelSize(R.dimen.alarm_list_item_height);

        if (dX > 0) {
            // Handle swiping to the right
            // Draw red background in area that we vacate up to maxDrawWidth
            canvas.drawRect((float) itemView.getLeft(), (float) itemTop, drawWidth,
                    (float) itemView.getBottom(), paint);

            // Only draw icon when we've past the padding threshold
            if (x > iconPadding) {

                Rect destRect = new Rect();
                destRect.left = itemView.getLeft() + iconPadding;
                destRect.top = itemTop + (itemView.getBottom() - itemTop - icon.getHeight()) / 2;
                int maxRight = destRect.left + icon.getWidth();
                destRect.right = Math.min(x, maxRight);
                destRect.bottom = destRect.top + icon.getHeight();

                // Only draw the appropriate parts of the bitmap as it is revealed
                Rect srcRect = null;
                if (x < maxRight) {
                    srcRect = new Rect();
                    srcRect.top = 0;
                    srcRect.left = 0;
                    srcRect.bottom = icon.getHeight();
                    srcRect.right = x - iconPadding;
                }

                canvas.drawBitmap(icon, srcRect, destRect, paint);
            }

        } else {
            // Handle swiping to the left
            // Draw red background in area that we vacate  up to maxDrawWidth
            canvas.drawRect((float) itemView.getRight() - drawWidth, (float) itemTop,
                    (float) itemView.getRight(), (float) itemView.getBottom(), paint);

            // Only draw icon when we've past the padding threshold
            if (x > iconPadding) {
                int fromLeftX = itemView.getRight() - x;
                Rect destRect = new Rect();
                destRect.right = itemView.getRight() - iconPadding;
                destRect.top = itemTop + (itemView.getBottom() - itemTop - icon.getHeight()) / 2;
                int maxFromLeft = destRect.right - icon.getWidth();
                destRect.left = Math.max(fromLeftX, maxFromLeft);
                destRect.bottom = destRect.top + icon.getHeight();

                // Only draw the appropriate parts of the bitmap as it is revealed
                Rect srcRect = null;
                if (fromLeftX > maxFromLeft) {
                    srcRect = new Rect();
                    srcRect.top = 0;
                    srcRect.right = icon.getWidth();
                    srcRect.bottom = icon.getHeight();
                    srcRect.left = srcRect.right - (x - iconPadding);
                }

                canvas.drawBitmap(icon, srcRect, destRect, paint);
            }
        }

        // Fade out the item as we swipe it
        float alpha = 1.0f - Math.abs(dX) / (float) itemView.getWidth();
        itemView.setAlpha(alpha);
        itemView.setTranslationX(dX);
    } else {
        super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
    }
}

From source file:net.toload.main.hd.candidate.CandidateView.java

protected void updateFontSize() {
    Resources r = mContext.getResources();
    float scaling = mLIMEPref.getFontSize();
    mVerticalPadding = (int) (r.getDimensionPixelSize(R.dimen.candidate_vertical_padding) * scaling);
    mCandidatePaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_size) * scaling);
    mSelKeyPaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_number_font_size) * scaling);
    configHeight = (int) (r.getDimensionPixelSize(R.dimen.candidate_stripe_height) * scaling);
    if (DEBUG)// www  . j  a v a 2 s. c  o  m
        Log.i(TAG, "updateFontSize(), scaling=" + scaling + ", mVerticalPadding=" + mVerticalPadding);
}

From source file:com.codetroopers.betterpickers.calendardatepicker.MonthView.java

public MonthView(Context context) {
    super(context);
    Resources res = context.getResources();

    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();

    mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.sans_serif);

    mDayTextColorEnabled = res.getColor(R.color.date_picker_text_normal);
    mDayTextColorDisabled = res.getColor(R.color.date_picker_text_disabled);
    mTodayNumberColor = res.getColor(R.color.bpBlue);
    mDayBackgroundColorDisabled = res.getColor(R.color.bpDarker_red);
    mMonthTitleColor = res.getColor(R.color.date_picker_text_normal);

    mStringBuilder = new StringBuilder(50);
    mFormatter = new Formatter(mStringBuilder, Locale.getDefault());

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE)
            / MAX_NUM_ROWS;//  ww  w.  j  a va 2s  . co  m

    // Set up accessibility components.
    mTouchHelper = new MonthViewTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);
    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    mLockAccessibilityDelegate = true;

    // Sets up any standard paints that will be used
    initView();
}

From source file:net.toload.main.hd.candidate.CandidateView.java

public synchronized void setSuggestions(List<Mapping> suggestions, boolean showNumber) {
    //clear();//  w w w  .  j  a  v  a2s  .co m
    //Jeremy '11,8,14 moved from clear();
    if (DEBUG)
        Log.i(TAG, "setSuggestions()");

    Resources res = mContext.getResources();

    configHeight = (int) (res.getDimensionPixelSize(R.dimen.candidate_stripe_height) * mLIMEPref.getFontSize());
    mVerticalPadding = (int) (res.getDimensionPixelSize(R.dimen.candidate_vertical_padding)
            * mLIMEPref.getFontSize());
    mHeight = configHeight + mVerticalPadding;

    currentX = 0;
    mTouchX = OUT_OF_BOUNDS;
    mCount = 0;
    mSelectedIndex = -1;

    if (mLIMEPref.getDisablePhysicalSelKeyOption()) {
        showNumber = true;
    }

    mShowNumber = showNumber;

    if (mShowNumber)
        X_GAP = (int) (res.getDimensionPixelSize(R.dimen.candidate_font_size) * 0.35f);//13;
    else
        X_GAP = (int) (res.getDimensionPixelSize(R.dimen.candidate_font_size) * 0.25f);

    if (suggestions != null) {
        mSuggestions = new LinkedList<>(suggestions);

        if (mSuggestions.size() > 0) {
            // Add by Jeremy '10, 3, 29
            mCount = mSuggestions.size();
            if (mCount > MAX_SUGGESTIONS)
                mCount = MAX_SUGGESTIONS;

            if (DEBUG)
                Log.i(TAG, "setSuggestions():mSuggestions.size():" + mSuggestions.size() + " mCount=" + mCount);

            if (mCount > 1 && mSuggestions.get(1).isExactMatchToCodeRecord()) {
                mSelectedIndex = 1;
            } else if (mCount > 0 && (mSuggestions.get(0).isComposingCodeRecord()
                    || mSuggestions.get(0).isRuntimeBuiltPhraseRecord())) {
                /*
                                    int seloption = mLIMEPref.getSelkeyOption();
                                    if(seloption > 0 && suggestions.size() > seloption){
                mSelectedIndex = seloption;
                                    }else{*/
                mSelectedIndex = 0;
                //}

            } else {
                // no default selection for related phrase, chinese punctuation symbols1 and English suggestions  Jeremy '15,6,4
                mSelectedIndex = -1;
            }
        } else {
            if (DEBUG)
                Log.i(TAG, "setSuggestions():mSuggestions=null");
        }
    } else {
        mSuggestions = new LinkedList<>();
        hideCandidatePopup();
    }

    prepareLayout();

    mHandler.updateUI(0);

}

From source file:org.navitproject.navit.Navit.java

/** Called when the activity is first created. */
@Override/*ww w.ja va  2  s  .  c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    else
        this.getActionBar().hide();

    dialogs = new NavitDialogs(this);

    NavitResources = getResources();

    // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
    Navit.startup_intent = this.getIntent();
    // hack! Remember time stamps, and only allow 4 secs. later in onResume to set target!
    Navit.startup_intent_timestamp = System.currentTimeMillis();
    Log.e("Navit", "**1**A " + startup_intent.getAction());
    Log.e("Navit", "**1**D " + startup_intent.getDataString());

    // init translated text
    NavitTextTranslations.init();

    // NOTIFICATION
    // Setup the status bar notification      
    // This notification is removed in the exit() function
    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Grab a handle to the NotificationManager
    Notification NavitNotification = new Notification(R.drawable.ic_notify,
            getString(R.string.notification_ticker), System.currentTimeMillis()); // Create a new notification, with the text string to show when the notification first appears
    PendingIntent appIntent = PendingIntent.getActivity(getApplicationContext(), 0, getIntent(), 0);
    //      FIXME : needs a fix for sdk 23
    //      NavitNotification.setLatestEventInfo(getApplicationContext(), "Navit", getString(R.string.notification_event_default), appIntent);   // Set the text in the notification
    //      NavitNotification.flags|=Notification.FLAG_ONGOING_EVENT;   // Ensure that the notification appears in Ongoing
    //      nm.notify(R.string.app_name, NavitNotification);   // Set the notification

    // Status and navigation bar sizes
    // These are platform defaults and do not change with rotation, but we have to figure out which ones apply
    // (is the navigation bar visible? on the side or at the bottom?)
    Resources resources = getResources();
    int shid = resources.getIdentifier("status_bar_height", "dimen", "android");
    int adhid = resources.getIdentifier("action_bar_default_height", "dimen", "android");
    int nhid = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    int nhlid = resources.getIdentifier("navigation_bar_height_landscape", "dimen", "android");
    int nwid = resources.getIdentifier("navigation_bar_width", "dimen", "android");
    status_bar_height = (shid > 0) ? resources.getDimensionPixelSize(shid) : 0;
    action_bar_default_height = (adhid > 0) ? resources.getDimensionPixelSize(adhid) : 0;
    navigation_bar_height = (nhid > 0) ? resources.getDimensionPixelSize(nhid) : 0;
    navigation_bar_height_landscape = (nhlid > 0) ? resources.getDimensionPixelSize(nhlid) : 0;
    navigation_bar_width = (nwid > 0) ? resources.getDimensionPixelSize(nwid) : 0;
    Log.d(TAG, String.format(
            "status_bar_height=%d, action_bar_default_height=%d, navigation_bar_height=%d, navigation_bar_height_landscape=%d, navigation_bar_width=%d",
            status_bar_height, action_bar_default_height, navigation_bar_height,
            navigation_bar_height_landscape, navigation_bar_width));
    if ((ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
            || (ContextCompat.checkSelfPermission(this,
                    Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
        Log.d(TAG, "ask for permission(s)");
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.ACCESS_FINE_LOCATION }, MY_PERMISSIONS_REQUEST_ALL);
    }
    // get the local language -------------
    Locale locale = java.util.Locale.getDefault();
    String lang = locale.getLanguage();
    String langu = lang;
    String langc = lang;
    Log.e("Navit", "lang=" + lang);
    int pos = langu.indexOf('_');
    if (pos != -1) {
        langc = langu.substring(0, pos);
        NavitLanguage = langc + langu.substring(pos).toUpperCase(locale);
        Log.e("Navit", "substring lang " + NavitLanguage.substring(pos).toUpperCase(locale));
        // set lang. for translation
        NavitTextTranslations.main_language = langc;
        NavitTextTranslations.sub_language = NavitLanguage.substring(pos).toUpperCase(locale);
    } else {
        String country = locale.getCountry();
        Log.e("Navit", "Country1 " + country);
        Log.e("Navit", "Country2 " + country.toUpperCase(locale));
        NavitLanguage = langc + "_" + country.toUpperCase(locale);
        // set lang. for translation
        NavitTextTranslations.main_language = langc;
        NavitTextTranslations.sub_language = country.toUpperCase(locale);
    }
    Log.e("Navit", "Language " + lang);

    SharedPreferences prefs = getSharedPreferences(NAVIT_PREFS, MODE_PRIVATE);
    map_filename_path = prefs.getString("filenamePath",
            Environment.getExternalStorageDirectory().getPath() + "/navit/");

    // make sure the new path for the navitmap.bin file(s) exist!!
    File navit_maps_dir = new File(map_filename_path);
    navit_maps_dir.mkdirs();

    // make sure the share dir exists
    File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR);
    navit_data_share_dir.mkdirs();

    Display display_ = getWindowManager().getDefaultDisplay();
    int width_ = display_.getWidth();
    int height_ = display_.getHeight();
    metrics = new DisplayMetrics();
    display_.getMetrics(Navit.metrics);
    int densityDpi = (int) ((Navit.metrics.density * 160) - .5f);
    Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_);
    Log.e("Navit", "Navit -> dpi=" + densityDpi);
    Log.e("Navit", "Navit -> density=" + Navit.metrics.density);
    Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity);

    ActivityResults = new NavitActivityResult[16];
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");

    if (!extractRes(langc, NAVIT_DATA_DIR + "/locale/" + langc + "/LC_MESSAGES/navit.mo")) {
        Log.e("Navit", "Failed to extract language resource " + langc);
    }

    if (densityDpi <= 120) {
        my_display_density = "ldpi";
    } else if (densityDpi <= 160) {
        my_display_density = "mdpi";
    } else if (densityDpi < 240) {
        my_display_density = "hdpi";
    } else if (densityDpi < 320) {
        my_display_density = "xhdpi";
    } else if (densityDpi < 480) {
        my_display_density = "xxhdpi";
    } else if (densityDpi < 640) {
        my_display_density = "xxxhdpi";
    } else {
        Log.e("Navit", "found device of very high density (" + densityDpi + ")");
        Log.e("Navit", "using xxxhdpi values");
        my_display_density = "xxxhdpi";
    }

    if (!extractRes("navit" + my_display_density, NAVIT_DATA_DIR + "/share/navit.xml")) {
        Log.e("Navit", "Failed to extract navit.xml for " + my_display_density);
    }

    // --> dont use android.os.Build.VERSION.SDK_INT, needs API >= 4
    Log.e("Navit", "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
    NavitMain(this, NavitLanguage, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density,
            NAVIT_DATA_DIR + "/bin/navit", map_filename_path);

    showInfos();

    Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}