use of com.android.contacts.common.widget.FloatingActionButtonController in project android_packages_apps_Dialer by LineageOS.
the class DialpadFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
Trace.beginSection(TAG + " onCreateView");
Trace.beginSection(TAG + " inflate view");
final View fragmentView = inflater.inflate(R.layout.dialpad_fragment, container, false);
Trace.endSection();
Trace.beginSection(TAG + " buildLayer");
fragmentView.buildLayer();
Trace.endSection();
Trace.beginSection(TAG + " setup views");
mDialpadView = (DialpadView) fragmentView.findViewById(R.id.dialpad_view);
mDialpadView.setCanDigitsBeEdited(true);
mDigits = mDialpadView.getDigits();
mDigits.setKeyListener(UnicodeDialerKeyListener.INSTANCE);
mDigits.setOnClickListener(this);
mDigits.setOnKeyListener(this);
mDigits.setOnLongClickListener(this);
mDigits.addTextChangedListener(this);
mDigits.setElegantTextHeight(false);
PhoneNumberFormattingTextWatcher watcher = new PhoneNumberFormattingTextWatcher(GeoUtil.getCurrentCountryIso(getActivity()));
mDigits.addTextChangedListener(watcher);
// Check for the presence of the keypad
View oneButton = fragmentView.findViewById(R.id.one);
if (oneButton != null) {
configureKeypadListeners(fragmentView);
}
mDelete = mDialpadView.getDeleteButton();
if (mDelete != null) {
mDelete.setOnClickListener(this);
mDelete.setOnLongClickListener(this);
}
mSpacer = fragmentView.findViewById(R.id.spacer);
mSpacer.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (isDigitsEmpty()) {
if (getActivity() != null) {
return ((HostInterface) getActivity()).onDialpadSpacerTouchWithEmptyQuery();
}
return true;
}
return false;
}
});
mDigits.setCursorVisible(false);
// Set up the "dialpad chooser" UI; see showDialpadChooser().
mDialpadChooser = (ListView) fragmentView.findViewById(R.id.dialpadChooser);
mDialpadChooser.setOnItemClickListener(this);
FloatingActionButton floatingActionButton = (FloatingActionButton) fragmentView.findViewById(R.id.dialpad_floating_action_button);
floatingActionButton.setOnClickListener(this);
mFloatingActionButtonController = new FloatingActionButtonController(getActivity(), floatingActionButton);
Trace.endSection();
Trace.endSection();
return fragmentView;
}
use of com.android.contacts.common.widget.FloatingActionButtonController in project packages_apps_Contacts by AOKP.
the class PeopleActivity method createViewsAndFragments.
private void createViewsAndFragments(Bundle savedState) {
// Disable the ActionBar so that we can use a Toolbar. This needs to be called before
// setContentView().
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.people_activity);
final FragmentManager fragmentManager = getFragmentManager();
// Hide all tabs (the current tab will later be reshown once a tab is selected)
final FragmentTransaction transaction = fragmentManager.beginTransaction();
mTabTitles = new String[TabState.COUNT];
mTabTitles[TabState.FAVORITES] = getString(R.string.favorites_tab_label);
mTabTitles[TabState.ALL] = getString(R.string.all_contacts_tab_label);
mTabTitles[TabState.GROUPS] = getString(R.string.contacts_groups_label);
mTabPager = getView(R.id.tab_pager);
mTabPagerAdapter = new TabPagerAdapter();
mTabPager.setAdapter(mTabPagerAdapter);
mTabPager.setOnPageChangeListener(mTabPagerListener);
// Configure toolbar and toolbar tabs. If in landscape mode, we configure tabs differntly.
final Toolbar toolbar = getView(R.id.toolbar);
setActionBar(toolbar);
final ViewPagerTabs portraitViewPagerTabs = (ViewPagerTabs) findViewById(R.id.lists_pager_header);
ViewPagerTabs landscapeViewPagerTabs = null;
if (portraitViewPagerTabs == null) {
landscapeViewPagerTabs = (ViewPagerTabs) getLayoutInflater().inflate(R.layout.people_activity_tabs_lands, toolbar, /* attachToRoot = */
false);
mViewPagerTabs = landscapeViewPagerTabs;
} else {
mViewPagerTabs = portraitViewPagerTabs;
}
mViewPagerTabs.setViewPager(mTabPager);
final String FAVORITE_TAG = "tab-pager-favorite";
final String ALL_TAG = "tab-pager-all";
final String GROUPS_TAG = "tab-pager-groups";
// Create the fragments and add as children of the view pager.
// The pager adapter will only change the visibility; it'll never create/destroy
// fragments.
// However, if it's after screen rotation, the fragments have been re-created by
// the fragment manager, so first see if there're already the target fragments
// existing.
mFavoritesFragment = (ContactTileListFragment) fragmentManager.findFragmentByTag(FAVORITE_TAG);
mAllFragment = (MultiSelectContactsListFragment) fragmentManager.findFragmentByTag(ALL_TAG);
mGroupsFragment = (GroupBrowseListFragment) fragmentManager.findFragmentByTag(GROUPS_TAG);
if (mFavoritesFragment == null) {
mFavoritesFragment = new ContactTileListFragment();
mAllFragment = new MultiSelectContactsListFragment();
mGroupsFragment = new GroupBrowseListFragment();
transaction.add(R.id.tab_pager, mFavoritesFragment, FAVORITE_TAG);
transaction.add(R.id.tab_pager, mAllFragment, ALL_TAG);
transaction.add(R.id.tab_pager, mGroupsFragment, GROUPS_TAG);
}
mFavoritesFragment.setListener(mFavoritesFragmentListener);
mAllFragment.setOnContactListActionListener(new ContactBrowserActionListener());
mAllFragment.setCheckBoxListListener(new CheckBoxListListener());
mGroupsFragment.setListener(new GroupBrowserActionListener());
// Hide all fragments for now. We adjust visibility when we get onSelectedTabChanged()
// from ActionBarAdapter.
transaction.hide(mFavoritesFragment);
transaction.hide(mAllFragment);
transaction.hide(mGroupsFragment);
transaction.commitAllowingStateLoss();
fragmentManager.executePendingTransactions();
// Setting Properties after fragment is created
mFavoritesFragment.setDisplayType(DisplayType.STREQUENT);
mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar(), portraitViewPagerTabs, landscapeViewPagerTabs, toolbar);
mActionBarAdapter.initialize(savedState, mRequest);
// Add shadow under toolbar
ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources());
// Configure floating action button
mFloatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
final ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
floatingActionButton.setOnClickListener(this);
mFloatingActionButtonController = new FloatingActionButtonController(this, mFloatingActionButtonContainer, floatingActionButton);
initializeFabVisibility();
invalidateOptionsMenuIfNeeded();
}
use of com.android.contacts.common.widget.FloatingActionButtonController in project android_packages_apps_Dialer by LineageOS.
the class DialtactsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Trace.beginSection(TAG + " onCreate");
super.onCreate(savedInstanceState);
mFirstLaunch = true;
isLastTabEnabled = ConfigProviderBindings.get(this).getBoolean("last_tab_enabled", false);
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 = getActionBarSafely();
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_box_collapsed).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 = DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL;
FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.floating_action_button);
floatingActionButton.setOnClickListener(this);
mFloatingActionButtonController = new FloatingActionButtonController(this, floatingActionButton);
ImageButton optionsMenuButton = (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button);
optionsMenuButton.setOnClickListener(this);
mOverflowMenu = buildOptionsMenu(optionsMenuButton);
optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());
// 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);
mWasConfigurationChange = savedInstanceState.getBoolean(KEY_WAS_CONFIGURATION_CHANGE);
mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
mActionBarController.restoreInstanceState(savedInstanceState);
}
final boolean isLayoutRtl = ViewUtil.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());
ViewUtil.doOnGlobalLayout(floatingActionButton, view -> {
int screenWidth = mParentLayout.getWidth();
mFloatingActionButtonController.setScreenWidth(screenWidth);
mFloatingActionButtonController.align(getFabAlignment(), false);
});
Trace.endSection();
Trace.beginSection(TAG + " initialize smart dialing");
mDialerDatabaseHelper = Database.get(this).getDatabaseHelper(this);
SmartDialPrefix.initializeNanpSettings(this);
Trace.endSection();
mP13nLogger = P13nLogging.get(getApplicationContext());
mP13nRanker = P13nRanking.get(getApplicationContext());
Trace.endSection();
}
use of com.android.contacts.common.widget.FloatingActionButtonController in project android_packages_apps_Dialer by MoKee.
the class DialpadFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
Trace.beginSection(TAG + " onCreateView");
Trace.beginSection(TAG + " inflate view");
final View fragmentView = inflater.inflate(R.layout.dialpad_fragment, container, false);
Trace.endSection();
Trace.beginSection(TAG + " buildLayer");
fragmentView.buildLayer();
Trace.endSection();
Trace.beginSection(TAG + " setup views");
mDialpadView = (DialpadView) fragmentView.findViewById(R.id.dialpad_view);
mDialpadView.setCanDigitsBeEdited(true);
mDigits = mDialpadView.getDigits();
mRecipients = (EditText) fragmentView.findViewById(R.id.recipients);
mDigitsContainer = fragmentView.findViewById(R.id.digits_container);
mDialpad = fragmentView.findViewById(R.id.dialpad);
if (mRecipients != null) {
mRecipients.setVisibility(View.GONE);
mRecipients.addTextChangedListener(this);
}
mDigits.setKeyListener(UnicodeDialerKeyListener.INSTANCE);
mDigits.setOnClickListener(this);
mDigits.setOnKeyListener(this);
mDigits.setOnLongClickListener(this);
mDigits.addTextChangedListener(this);
mDigits.setElegantTextHeight(false);
PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(getActivity(), mDigits);
mLocation = mDialpadView.getLocation();
// Check for the presence of the keypad
View oneButton = fragmentView.findViewById(R.id.one);
if (oneButton != null) {
configureKeypadListeners(fragmentView);
}
mDelete = mDialpadView.getDeleteButton();
if (mDelete != null) {
mDelete.setOnClickListener(this);
mDelete.setOnLongClickListener(this);
}
mSpacer = fragmentView.findViewById(R.id.spacer);
mSpacer.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (isDigitsEmpty()) {
if (getActivity() != null) {
return ((HostInterface) getActivity()).onDialpadSpacerTouchWithEmptyQuery();
}
return true;
}
return false;
}
});
mDigits.setCursorVisible(false);
// Set up the "dialpad chooser" UI; see showDialpadChooser().
mDialpadChooser = (ListView) fragmentView.findViewById(R.id.dialpadChooser);
mDialpadChooser.setOnItemClickListener(this);
final View floatingActionButtonContainer = fragmentView.findViewById(R.id.dialpad_floating_action_button_container);
final ImageButton floatingActionButton = (ImageButton) fragmentView.findViewById(R.id.dialpad_floating_action_button);
floatingActionButton.setOnClickListener(this);
mFloatingActionButtonController = new FloatingActionButtonController(getActivity(), floatingActionButtonContainer, floatingActionButton);
mOperator = (TextView) fragmentView.findViewById(R.id.dialpad_floating_operator);
Trace.endSection();
Trace.endSection();
return fragmentView;
}
use of com.android.contacts.common.widget.FloatingActionButtonController in project android_packages_apps_Dialer by MoKee.
the class DialtactsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Trace.beginSection(TAG + " onCreate");
super.onCreate(savedInstanceState);
mFirstLaunch = true;
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);
mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
mDialCallButton = findViewById(R.id.floating_action_button);
mFloatingActionButton.setOnClickListener(this);
if (!getResources().getBoolean(R.bool.config_hide_SIP_dial_icon)) {
mConferenceDialButton = (ImageButton) findViewById(R.id.dialConferenceButton);
mConferenceDialButton.setOnClickListener(this);
}
mFloatingActionButtonController = new FloatingActionButtonController(this, floatingActionButtonContainer, mFloatingActionButton);
ImageButton optionsMenuButton = (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button);
optionsMenuButton.setOnClickListener(this);
mOverflowMenu = buildOptionsMenu(searchEditTextLayout);
optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());
// fragment manager is responsible for recreating it.
if (savedInstanceState == null) {
getFragmentManager().beginTransaction().add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT).add(R.id.dialtacts_container, new DialpadFragment(), TAG_DIALPAD_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);
}
});
Trace.endSection();
Trace.beginSection(TAG + " initialize smart dialing");
mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
boolean isPresenceEnabled = this.getResources().getBoolean(R.bool.config_regional_presence_enable);
if (isPresenceEnabled && !PresenceHelper.isBound()) {
PresenceHelper.bindService((Context) DialtactsActivity.this);
}
mWifiCallUtils = new WifiCallUtils();
if (resources.getBoolean(R.bool.config_regional_pup_no_available_network) && mFirstLaunch) {
mWifiCallUtils.addWifiCallReadyMarqueeMessage((Context) DialtactsActivity.this);
if (ActivityCompat.checkSelfPermission(DialtactsActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, PERMISSION_REQUEST_CODE_LOCATION);
} else {
mWifiCallUtils.showWifiCallNotification((Context) DialtactsActivity.this);
}
}
Trace.endSection();
Trace.endSection();
if (getResources().getBoolean(R.bool.config_regional_video_call_welcome_dialog)) {
if (CallUtil.isVideoEnabled(this)) {
showVideoCallWelcomeDialog();
}
}
}
Aggregations