Skip to content

Commit

Permalink
Add RTL support for navigation drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavpandey committed Jan 10, 2019
1 parent 6d16b27 commit f7afa28
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Expand Up @@ -39,6 +39,7 @@

import com.google.android.material.navigation.NavigationView;
import com.pranavpandey.android.dynamic.support.R;
import com.pranavpandey.android.dynamic.support.locale.DynamicLocaleUtils;
import com.pranavpandey.android.dynamic.support.utils.DynamicLayoutUtils;
import com.pranavpandey.android.dynamic.support.utils.DynamicResourceUtils;
import com.pranavpandey.android.dynamic.support.utils.DynamicTintUtils;
Expand Down Expand Up @@ -197,9 +198,16 @@ private void configureDrawer() {
mDrawerToggle.setDrawerIndicatorEnabled(false);

ViewGroup frame = findViewById(R.id.ads_drawer_persistent_frame);
frame.setPadding(getResources().getDimensionPixelSize(
R.dimen.ads_margin_content_start), frame.getPaddingTop(),
frame.getPaddingRight(), frame.getPaddingBottom());

if (DynamicLocaleUtils.isLayoutRtl()) {
frame.setPadding(frame.getPaddingLeft(), frame.getPaddingTop(),
getResources().getDimensionPixelSize(R.dimen.ads_margin_content_start),
frame.getPaddingBottom());
} else {
frame.setPadding(getResources().getDimensionPixelSize(
R.dimen.ads_margin_content_start), frame.getPaddingTop(),
frame.getPaddingRight(), frame.getPaddingBottom());
}
} else {
if (isDrawerLocked()) {
mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
Expand Down
23 changes: 23 additions & 0 deletions dynamic-support/src/main/res/values-ldrtl-sw600dp/dimens.xml
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Pranav Pandey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<resources>

<!-- Toolbar -->
<dimen name="ads_toolbar_inset_start_collapsing">68dp</dimen>

</resources>

0 comments on commit f7afa28

Please sign in to comment.