Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[Michal Tajchert] Wearables Views

[Michal Tajchert] Wearables Views

Presentation from GDG DevFest - the biggest Google related event in Ukraine. October 24-25, Lviv. Learn more at http://devfest.gdg.org.ua/

Google Developers Group Lviv

October 25, 2014
Tweet

More Decks by Google Developers Group Lviv

Other Decks in Programming

Transcript

  1. #dfua WearViewStub <?xml version="1.0" encoding="utf-8"?> <android.support.wearable.view.WatchViewStub xmlns:android="http://schemas.android. com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/watch_view_stub" android:layout_width="match_parent" android:layout_height="match_parent" app:rectLayout="@layout/rect_activity_stub" app:roundLayout="@layout/round_activity_stub" tools:context=".StubActivity" tools:deviceIds="wear"> </android.support.wearable.view.WatchViewStub>
  2. #dfua BoxInsetLayout <?xml version="1.0" encoding="utf-8"?> <android.support.wearable.view.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_height="match_parent" android:layout_width="match_parent">

    <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:orientation="horizontal" app:layout_box="all" > <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:text="@string/text_long"/> </LinearLayout> </android.support.wearable.view.BoxInsetLayout>
  3. #dfua CircledImageView <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white"> <android.support.wearable.view.CircledImageView android:layout_width="100dp"

    android:layout_height="100dp" android:layout_gravity="center" android:src="@drawable/ic_launcher" app:circle_border_color="#999999" app:circle_border_width="1dp" app:circle_color="#000" app:circle_radius="50dp"/> </FrameLayout>
  4. #dfua DismissOverlayView dismissOverlayView = (DismissOverlayView) findViewById(R.id.dismiss_plain); gestureDetector = new GestureDetector(this,

    new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent e) { dismissOverlayView.show(); } }); <android.support.wearable.view.DismissOverlayView android:id="@+id/dismiss_plain" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
  5. #dfua DelayedConfirmationView delayedConfirmationView = (DelayedConfirmationView) findViewById(R.id.delayed_confirmation); delayedConfirmationView.setTotalTimeMs(2000); delayedConfirmationView.setListener(ConfirmationOverlayActivity.this); ... implements

    DelayedConfirmationView.DelayedConfirmationListener{...} @Override public void onTimerFinished(View view) { view.setPressed(false); } @Override public void onTimerSelected(View view) { view.setPressed(true); delayedConfirmationView.start(); }
  6. #dfua GridViewPager final Resources res = getResources(); final GridViewPager pager

    = (GridViewPager) findViewById(R.id.pager); pager.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { final boolean round = insets.isRound(); int rowMargin = res.getDimensionPixelOffset(R.dimen.card_margin); int colMargin = res.getDimensionPixelOffset(round ? R.dimen.padding_round : R.dimen. padding_rect); pager.setPageMargins(rowMargin, colMargin); return insets; } }); pager.setAdapter(new GridViewPagerCustomAdapter(this, getFragmentManager()));
  7. #dfua CardFragment protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wear_activity2); FragmentManager

    fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); CardFragment cardFragment = CardFragment.create(getString(R.string.cftitle), getString(R.string.cfdesc),R.drawable.p); fragmentTransaction.add(R.id.frame_layout, cardFragment); fragmentTransaction.commit(); }