android.support.wearable.view.BoxInsetLayout Java Examples

The following examples show how to use android.support.wearable.view.BoxInsetLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WearActivity.java    From Sensor-Data-Logger with Apache License 2.0 6 votes vote down vote up
private void setupUi() {
    setContentView(R.layout.main_activity_wear);
    setAmbientEnabled();

    mContainerView = (BoxInsetLayout) findViewById(R.id.container);
    mainTextView = (TextView) findViewById(R.id.mainText);
    preTextView = (TextView) findViewById(R.id.preText);
    postTextView = (TextView) findViewById(R.id.postText);
    logTextView = (TextView) findViewById(R.id.logText);

    mContainerView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            updateStatusTexts();
        }
    });

    updateDisplay();
}
 
Example #2
Source File: MainActivity.java    From CircularSeekBar with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setAmbientEnabled();

    mContainerView = (BoxInsetLayout) findViewById(R.id.container);
    mTextView = (CircularSeekBar) findViewById(R.id.text);
    mClockView = (TextView) findViewById(R.id.clock);
}
 
Example #3
Source File: MainActivity.java    From ibm-wearables-android-sdk with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setAmbientEnabled();

    mContainerView = (BoxInsetLayout) findViewById(R.id.container);
    mTextView = (TextView) findViewById(R.id.text);
    mClockView = (TextView) findViewById(R.id.clock);

}
 
Example #4
Source File: MainActivity.java    From MycroftCore-Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setAmbientEnabled();

    mContainerView = (BoxInsetLayout) findViewById(R.id.container);
    mTextView = (TextView) findViewById(R.id.text);
    mClockView = (TextView) findViewById(R.id.clock);
}
 
Example #5
Source File: WatchFaceConfigActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_background_selector);

    mImageResourceList = getResources().obtainTypedArray( R.array.background_resource_ids );
    mHeader = (TextView) findViewById( R.id.header );

    WearableListView listView = (WearableListView) findViewById( R.id.background_picker );
    BoxInsetLayout content = (BoxInsetLayout) findViewById( R.id.content );

    content.setOnApplyWindowInsetsListener( new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if( !insets.isRound() ) {
                v.setPaddingRelative( (getResources().getDimensionPixelSize( R.dimen.content_padding_start ) ),
                        v.getPaddingTop(),
                        v.getPaddingEnd(),
                        v.getPaddingBottom() );
            }

            return v.onApplyWindowInsets( insets );
        }
    });

    listView.setHasFixedSize( true );
    listView.setClickListener( this );
    listView.addOnScrollListener( this );

    String[] backgrounds = getResources().getStringArray( R.array.background_array );
    listView.setAdapter( new BackgroundListAdapter( backgrounds ) );


}
 
Example #6
Source File: SunsetsBackgroundWearableConfigActivity.java    From american-sunsets-watch-face with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_background_config);

    mHeader = (TextView) findViewById(R.id.header);
    WearableListView listView = (WearableListView) findViewById(R.id.color_picker);
    BoxInsetLayout content = (BoxInsetLayout) findViewById(R.id.content);
    // BoxInsetLayout adds padding by default on round devices. Add some on square devices.
    content.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if (!insets.isRound()) {
                v.setPaddingRelative(
                        (int) getResources().getDimensionPixelSize(R.dimen.content_padding_start),
                        v.getPaddingTop(),
                        v.getPaddingEnd(),
                        v.getPaddingBottom());
            }
            return v.onApplyWindowInsets(insets);
        }
    });

    listView.setHasFixedSize(true);
    listView.setClickListener(this);
    listView.addOnScrollListener(this);

    String[] colors = getResources().getStringArray(R.array.bitmap_face_array);
    listView.setAdapter(new ColorListAdapter(colors));

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(Bundle connectionHint) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnected: " + connectionHint);
                    }
                }

                @Override
                public void onConnectionSuspended(int cause) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionSuspended: " + cause);
                    }
                }
            })
            .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(ConnectionResult result) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionFailed: " + result);
                    }
                }
            })
            .addApi(Wearable.API)
            .build();
}
 
Example #7
Source File: SunsetsGeneralWearableConfigActivity.java    From american-sunsets-watch-face with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_general_config);
    colors = new String[]{getResources().getString(R.string.image),getResources().getString(R.string.fluid_motion)};
    mHeader = (TextView) findViewById(R.id.header);
    listView = (WearableListView) findViewById(R.id.color_picker);
    BoxInsetLayout content = (BoxInsetLayout) findViewById(R.id.content);
    // BoxInsetLayout adds padding by default on round devices. Add some on square devices.
    content.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if (!insets.isRound()) {
                v.setPaddingRelative(
                        (int) getResources().getDimensionPixelSize(R.dimen.content_padding_start),
                        v.getPaddingTop(),
                        v.getPaddingEnd(),
                        v.getPaddingBottom());
            }
            return v.onApplyWindowInsets(insets);
        }
    });

    listView.setHasFixedSize(true);
    listView.setClickListener(this);
    listView.addOnScrollListener(this);

    listView.setAdapter(new ColorListAdapter(colors));
    mPeerId = getIntent().getStringExtra(WatchFaceCompanion.EXTRA_PEER_ID);
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(Bundle connectionHint) {
                    Log.d(TAG, "onConnected: " + connectionHint);
                    //Uri.Builder builder = new Uri.Builder();
                    //Uri uri = builder.scheme("wear").path(PATH_WITH_FEATURE).build();
                    //Wearable.DataApi.getDataItem(mGoogleApiClient, uri).setResultCallback(SunsetsGeneralWearableConfigActivity.this);
                    new Thread() {
                        @Override
                        public void run() {
                            PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient,getUriForDataItem());
                            results.setResultCallback(new ResultCallback<DataItemBuffer>() {
                                @Override
                                public void onResult(DataItemBuffer dataItems) {
                                    if (dataItems.getCount() != 0) {
                                        for(int i=0; i<dataItems.getCount(); i++) {
                                            DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItems.get(i));
                                            DataMap config = dataMapItem.getDataMap();
                                            Log.d(TAG, "startup setup UI...");
                                            updateUiForConfigDataMap(config);
                                        }
                                    }

                                    dataItems.release();
                                }
                            });
                        }
                    }.start();

                    Wearable.DataApi.addListener(mGoogleApiClient, SunsetsGeneralWearableConfigActivity.this);
                }

                @Override
                public void onConnectionSuspended(int cause) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionSuspended: " + cause);
                    }
                }
            })
            .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(ConnectionResult result) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionFailed: " + result);
                    }
                }
            })
            .addApi(Wearable.API)
            .build();
}