summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-07-22 11:49:49 -0700
committerYorke Lee <yorkelee@google.com>2014-07-22 17:31:24 -0700
commit69c247f619fd2f2474070bdbcec32b78f6444149 (patch)
tree168f658fdfa9b86b0020c4abaccffeeb9f9c02ff /src/com/android
parent769540c1ed68cb52b455630d3547a54aff71497a (diff)
downloadandroid_packages_apps_Dialer-69c247f619fd2f2474070bdbcec32b78f6444149.tar.gz
android_packages_apps_Dialer-69c247f619fd2f2474070bdbcec32b78f6444149.tar.bz2
android_packages_apps_Dialer-69c247f619fd2f2474070bdbcec32b78f6444149.zip
Make ViewPagerTabs and FABController RTL aware
* Underline in ViewPagerTabStrips is correctly drawn in RTL mode * Clicking on ViewPagerTabs propogates correct onPageSelected position to ViewPager * FAB is now end aligned instead of right aligned * ViewPager in Dialer is correctly reversed and behaves correctly * Call Log groups headers in call log are now correctly aligned in RTL Bug: 16162264 Bug: 16464471 Change-Id: I2db6b9147a628a68fba5bbbdb7276855d483bad5
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java21
-rw-r--r--src/com/android/dialer/calllog/CallLogActivity.java2
-rw-r--r--src/com/android/dialer/list/ListsFragment.java17
-rw-r--r--src/com/android/dialer/util/DialerUtils.java9
4 files changed, 37 insertions, 12 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index bf2af138a..249e0c1aa 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -93,6 +93,7 @@ import com.android.phone.common.animation.AnimationListenerAdapter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
/**
* The dialer tab's title is 'phone', a more common name (see strings.xml).
@@ -1104,11 +1105,20 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ position = mListsFragment.getRtlPosition(position);
// Only scroll the button when the first tab is selected. The button should scroll from
// the middle to right position only on the transition from the first tab to the second
// tab.
- if (position == ListsFragment.TAB_INDEX_SPEED_DIAL && !mIsLandscape) {
- mFloatingActionButtonController.onPageScrolled(positionOffset);
+ // If the app is in RTL mode, we need to check against the second tab, rather than the
+ // first. This is because if we are scrolling between the first and second tabs, the
+ // viewpager will report that the starting tab position is 1 rather than 0, due to the
+ // reversal of the order of the tabs.
+ final boolean isLayoutRtl = DialerUtils.isRtl();
+ final boolean shouldScrollButton = position == (isLayoutRtl
+ ? ListsFragment.TAB_INDEX_RECENTS : ListsFragment.TAB_INDEX_SPEED_DIAL);
+ if (shouldScrollButton && !mIsLandscape) {
+ mFloatingActionButtonController.onPageScrolled(
+ isLayoutRtl ? 1 - positionOffset : positionOffset);
} else if (position != ListsFragment.TAB_INDEX_SPEED_DIAL) {
mFloatingActionButtonController.onPageScrolled(1);
}
@@ -1116,6 +1126,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
@Override
public void onPageSelected(int position) {
+ position = mListsFragment.getRtlPosition(position);
mCurrentTabPosition = position;
}
@@ -1163,15 +1174,15 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
private void updateFloatingActionButtonControllerAlignment(boolean animate) {
int align;
if (mIsDialpadShown) {
- align = mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_RIGHT
+ align = mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END
: FloatingActionButtonController.ALIGN_MIDDLE;
} else {
if (!mIsLandscape) {
align = mCurrentTabPosition == ListsFragment.TAB_INDEX_SPEED_DIAL
? FloatingActionButtonController.ALIGN_MIDDLE
- : FloatingActionButtonController.ALIGN_RIGHT;
+ : FloatingActionButtonController.ALIGN_END;
} else {
- align = FloatingActionButtonController.ALIGN_RIGHT;
+ align = FloatingActionButtonController.ALIGN_END;
}
}
mFloatingActionButtonController.align(align,
diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java
index 4e969e189..1129f2795 100644
--- a/src/com/android/dialer/calllog/CallLogActivity.java
+++ b/src/com/android/dialer/calllog/CallLogActivity.java
@@ -29,9 +29,9 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import com.android.contacts.common.list.ViewPagerTabs;
import com.android.dialer.DialtactsActivity;
import com.android.dialer.R;
-import com.android.contacts.common.list.ViewPagerTabs;
import com.android.dialer.voicemail.VoicemailStatusHelper;
import com.android.dialer.voicemail.VoicemailStatusHelperImpl;
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java
index 847edd9a0..4f96d63f4 100644
--- a/src/com/android/dialer/list/ListsFragment.java
+++ b/src/com/android/dialer/list/ListsFragment.java
@@ -10,7 +10,6 @@ import android.content.CursorLoader;
import android.content.Loader;
import android.content.SharedPreferences;
import android.database.Cursor;
-import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.provider.CallLog;
@@ -26,9 +25,6 @@ import android.widget.ListView;
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.list.ViewPagerTabs;
import com.android.dialer.DialtactsActivity;
-
-import android.view.View.OnClickListener;
-
import com.android.dialer.R;
import com.android.dialer.calllog.CallLogAdapter;
import com.android.dialer.calllog.CallLogFragment;
@@ -36,6 +32,7 @@ import com.android.dialer.calllog.CallLogQuery;
import com.android.dialer.calllog.CallLogQueryHandler;
import com.android.dialer.calllog.ContactInfoHelper;
import com.android.dialer.list.ShortcutCardsAdapter.SwipeableShortcutCard;
+import com.android.dialer.util.DialerUtils;
import com.android.dialer.widget.OverlappingPaneLayout;
import com.android.dialer.widget.OverlappingPaneLayout.PanelSlideListener;
import com.android.dialerbind.ObjectFactory;
@@ -60,7 +57,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
public static final int TAB_INDEX_RECENTS = 1;
public static final int TAB_INDEX_ALL_CONTACTS = 2;
- private static final int TAB_INDEX_COUNT = 3;
+ public static final int TAB_INDEX_COUNT = 3;
private static final int MAX_RECENTS_ENTRIES = 20;
// Oldest recents entry to display is 2 weeks old.
@@ -186,7 +183,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
@Override
public Fragment getItem(int position) {
- switch (position) {
+ switch (getRtlPosition(position)) {
case TAB_INDEX_SPEED_DIAL:
mSpeedDialFragment = new SpeedDialFragment();
return mSpeedDialFragment;
@@ -260,6 +257,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
mViewPager.setAdapter(mViewPagerAdapter);
mViewPager.setOffscreenPageLimit(2);
mViewPager.setOnPageChangeListener(this);
+ mViewPager.setCurrentItem(getRtlPosition(TAB_INDEX_SPEED_DIAL));
mTabTitles = new String[TAB_INDEX_COUNT];
mTabTitles[TAB_INDEX_SPEED_DIAL] = getResources().getString(R.string.tab_speed_dial);
@@ -387,4 +385,11 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
public RemoveView getRemoveView() {
return mRemoveView;
}
+
+ public int getRtlPosition(int position) {
+ if (DialerUtils.isRtl()) {
+ return TAB_INDEX_COUNT - 1 - position;
+ }
+ return position;
+ }
}
diff --git a/src/com/android/dialer/util/DialerUtils.java b/src/com/android/dialer/util/DialerUtils.java
index 2b4a74ccc..07a330e6c 100644
--- a/src/com/android/dialer/util/DialerUtils.java
+++ b/src/com/android/dialer/util/DialerUtils.java
@@ -34,6 +34,7 @@ import com.android.contacts.common.CallUtil;
import com.android.dialer.R;
import java.util.List;
+import java.util.Locale;
/**
* General purpose utility methods for the Dialer.
@@ -138,4 +139,12 @@ public class DialerUtils {
final CharSequence separator = resources.getString(R.string.list_delimeter);
return TextUtils.join(separator, list);
}
+
+ /**
+ * @return True if the application is currently in RTL mode.
+ */
+ public static boolean isRtl() {
+ return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) ==
+ View.LAYOUT_DIRECTION_RTL;
+ }
}