Java源码示例:android.support.wearable.activity.ConfirmationActivity

示例1
private void onButtonClicked()
{
    PendingResult<DataApi.DataItemResult> pendingResult = Message.sendActionMessage(mGoogleApiClient);
    pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
        @Override
        public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
            Message.emptyActionMessage(mGoogleApiClient);
        }
    });

    Intent intent = new Intent(this, ConfirmationActivity.class);
    intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,
            ConfirmationActivity.SUCCESS_ANIMATION);
    intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE,
            getString(R.string.action_sent));
    startActivity(intent);
}
 
示例2
@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    if (intent != null && intent.getAction() != null) {
        if ("open_ticket".equals(intent.getAction())) {
            final Ticket t = (Ticket)intent.getExtras().getSerializable("ticket");
            sendMessage("openTicket/" + t.getId(), null);

            Intent confirmationIntent = new Intent(this, ConfirmationActivity.class);
            confirmationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            confirmationIntent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.OPEN_ON_PHONE_ANIMATION);
            startActivity(confirmationIntent);
        }
    }

    return super.onStartCommand(intent, flags, startId);
}
 
示例3
@Override
public void onTimerFinished(View view) {
    Intent intent = new Intent(this, ConfirmationActivity.class);
    intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.SUCCESS_ANIMATION);
    switch (mActionMode) {
        case ACTION_MODE_CLOSE_SUNROOF:
            EventBus.getDefault().post(new ToHandHoldRequestEvent(WEAR_CLOSE_SUNROOF));
            intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE, getString(R.string.notification_bad_weather_confirmation_done));
            break;
        case ACTION_MODE_LOCK_DOOR:
            EventBus.getDefault().post(new ToHandHoldRequestEvent(WEAR_ACTION_DOOR_LOCK));
            intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE, getString(R.string.notification_car_unlocked_confirmation_done));
            break;
        case ACTION_MODE_START_CHARGING:
            EventBus.getDefault().post(new ToHandHoldRequestEvent(WEAR_ACTION_CHARGING_START));
            intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE, getString(R.string.notification_unexpected_charge_stop_confirmation_done));
            break;
    }
    startActivity(intent);
    finish();
}
 
示例4
private PendingIntent getOpenOnPhonePendingIntent(String permalink,
                                                  boolean openOnPhoneDismisses,
                                                  int notificationId) {
    Intent openOnPhone = new Intent(this, ActionReceiver.class);
    openOnPhone.putExtra(Constants.KEY_PATH, Constants.PATH_OPEN_ON_PHONE);
    openOnPhone.putExtra(Constants.KEY_CONFIRMATION_MESSAGE, getString(R.string.open_on_phone));
    openOnPhone.putExtra(Constants.KEY_CONFIRMATION_ANIMATION,
            ConfirmationActivity.SUCCESS_ANIMATION);
    openOnPhone.putExtra(Constants.KEY_POST_PERMALINK, permalink);
    openOnPhone.putExtra(Constants.KEY_DISMISS_AFTER_ACTION, openOnPhoneDismisses);
    openOnPhone.putExtra(Constants.KEY_NOTIFICATION_ID, notificationId);
    return PendingIntent.getBroadcast(this,
            REQUEST_CODE_OPEN_ON_PHONE + notificationId,
            openOnPhone,
            PendingIntent.FLAG_UPDATE_CURRENT);
}
 
示例5
/**
 * Use the Wear Message API to execute an action. Clears local and remote notifications and
 * also runs a confirmation animation before finishing the Wear activity.
 *
 * @param attraction The attraction to start the action on
 * @param pathName The Wear Message API pathname
 * @param confirmAnimationType The confirmation animation type from ConfirmationActivity
 */
private void startAction(Attraction attraction, String pathName, int confirmAnimationType) {
    Intent intent = new Intent(mContext, ConfirmationActivity.class);
    intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, confirmAnimationType);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    mContext.startActivity(intent);

    UtilityService.clearNotification(mContext);
    UtilityService.clearRemoteNotifications(mContext);
    UtilityService.startDeviceActivity(mContext, pathName, attraction.name, attraction.city);

    ((Activity)mContext).finish();
}
 
示例6
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
    wearPayBinder = (WatchService.WearPayBinder) iBinder;
    wearPayBinder.addChangeListener(CodeActivity.this);
    wearPayBinder.setOnPaySuccessListener(new WatchService.OnPaySuccessListener() {
        @Override
        public void onPaySuccess() {
            Intent intent = new Intent(CodeActivity.this, ConfirmationActivity.class);
            intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.SUCCESS_ANIMATION);
            intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE, getString(R.string.pay_success));
            startActivity(intent);
            finish();
        }
    });
}
 
示例7
@Override
public void onTimerFinished(View view) {
    // save only if user hasn't canceled
    if(!this.isFinishing()) {
        saveClimb();

        String savedString = getString(R.string.climb_saved, routeGradeLabelToSave);

        Intent intent = new Intent(this, ConfirmationActivity.class);
        intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.SUCCESS_ANIMATION);
        intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE, savedString);
        startActivity(intent);
    }
    finish();
}
 
示例8
/**
 * Use the Wear Message API to execute an action. Clears local and remote notifications and
 * also runs a confirmation animation before finishing the Wear activity.
 *
 * @param attraction The attraction to start the action on
 * @param pathName The Wear Message API pathname
 * @param confirmAnimationType The confirmation animation type from ConfirmationActivity
 */
private void startAction(Attraction attraction, String pathName, int confirmAnimationType) {
    Intent intent = new Intent(mActivity, ConfirmationActivity.class);
    intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, confirmAnimationType);
    mActivity.startActivity(intent);

    UtilityService.clearNotification(mActivity);
    UtilityService.clearRemoteNotifications(mActivity);
    UtilityService.startDeviceActivity(mActivity, pathName, attraction.name, attraction.city);

    ((Activity) mActivity).finish();
}
 
示例9
/**
 * Use the Wear Message API to execute an action. Clears local and remote notifications and
 * also runs a confirmation animation before finishing the Wear activity.
 *
 * @param attraction The attraction to start the action on
 * @param pathName The Wear Message API pathname
 * @param confirmAnimationType The confirmation animation type from ConfirmationActivity
 */
private void startAction(Attraction attraction, String pathName, int confirmAnimationType) {
    Intent intent = new Intent(mContext, ConfirmationActivity.class);
    intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, confirmAnimationType);
    mContext.startActivity(intent);

    UtilityService.clearNotification(mContext);
    UtilityService.clearRemoteNotifications(mContext);
    UtilityService.startDeviceActivity(mContext, pathName, attraction.name, attraction.city);

    ((Activity)mContext).finish();
}
 
示例10
@Override
protected void onHandleIntent(Intent intent) {
    if (ACTION_CHECK_IN.equals(intent.getAction())) {
        // In a real app, code for checking in would go here. For this sample, we will simply
        // display a success animation.
        startConfirmationActivity(ConfirmationActivity.SUCCESS_ANIMATION,
                getString(R.string.check_in_success));
        // Dismiss the check-in notification.
        ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancel(NOTIFICATION_ID);
    } else if (!ACTION_DELETE_DATA_ITEM.equals(intent.getAction())) {
        // The only possible actions should be checking in or dismissing the notification
        // (which causes an intent with ACTION_DELETE_DATA_ITEM).
        Log.e(TAG, "Unrecognized action: " + intent.getAction());
        return;
    }
    // Regardless of the action, delete the DataItem (we are only be handling intents
    // if the notification is dismissed or if the user has chosen to check in, either of which
    // would be completed at this point).
    mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
    Uri dataItemUri = intent.getData();
    if (mGoogleApiClient.isConnected()) {
        DataApi.DeleteDataItemsResult result = Wearable.DataApi
                .deleteDataItems(mGoogleApiClient, dataItemUri).await();
        if (!result.getStatus().isSuccess()) {
            Log.e(TAG, "CheckInAndDeleteDataItemsService.onHandleIntent: "
                     + "Failed to delete dataItem: " + dataItemUri);
        } else if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Successfully deleted data item: " + dataItemUri);
        }
    } else {
        Log.e(TAG, "Failed to delete data item: " + dataItemUri
                 + " - Client disconnected from Google Play Services");
    }
    mGoogleApiClient.disconnect();
}
 
示例11
/**
 * Helper method to create confirmation animations on the wearable.
 * @param animationType Defined by constants in ConfirmationActivity.
 * @param message The message to display with the animation.
 */
private void startConfirmationActivity(int animationType, String message) {
    Intent confirmationActivity = new Intent(this, ConfirmationActivity.class)
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION)
            .putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, animationType)
            .putExtra(ConfirmationActivity.EXTRA_MESSAGE, message);
    startActivity(confirmationActivity);
}
 
示例12
@Override
protected void onHandleIntent(Intent intent) {
    if (ACTION_CHECK_IN.equals(intent.getAction())) {
        // In a real app, code for checking in would go here. For this sample, we will simply
        // display a success animation.
        startConfirmationActivity(ConfirmationActivity.SUCCESS_ANIMATION,
                getString(R.string.check_in_success));
        // Dismiss the check-in notification.
        ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancel(NOTIFICATION_ID);
    } else if (!ACTION_DELETE_DATA_ITEM.equals(intent.getAction())) {
        // The only possible actions should be checking in or dismissing the notification
        // (which causes an intent with ACTION_DELETE_DATA_ITEM).
        Log.e(TAG, "Unrecognized action: " + intent.getAction());
        return;
    }
    // Regardless of the action, delete the DataItem (we are only be handling intents
    // if the notification is dismissed or if the user has chosen to check in, either of which
    // would be completed at this point).
    mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
    Uri dataItemUri = intent.getData();
    if (mGoogleApiClient.isConnected()) {
        DataApi.DeleteDataItemsResult result = Wearable.DataApi
                .deleteDataItems(mGoogleApiClient, dataItemUri).await();
        if (!result.getStatus().isSuccess()) {
            Log.e(TAG, "CheckInAndDeleteDataItemsService.onHandleIntent: "
                     + "Failed to delete dataItem: " + dataItemUri);
        } else if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Successfully deleted data item: " + dataItemUri);
        }
    } else {
        Log.e(TAG, "Failed to delete data item: " + dataItemUri
                 + " - Client disconnected from Google Play Services");
    }
    mGoogleApiClient.disconnect();
}
 
示例13
/**
 * Helper method to create confirmation animations on the wearable.
 * @param animationType Defined by constants in ConfirmationActivity.
 * @param message The message to display with the animation.
 */
private void startConfirmationActivity(int animationType, String message) {
    Intent confirmationActivity = new Intent(this, ConfirmationActivity.class)
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION)
            .putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, animationType)
            .putExtra(ConfirmationActivity.EXTRA_MESSAGE, message);
    startActivity(confirmationActivity);
}
 
示例14
@Override
protected void onHandleIntent(Intent intent) {
    mGoogleApiClient.blockingConnect(TIME_OUT, TimeUnit.MILLISECONDS);
    Uri dataItemUri = intent.getData();
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "DeleteService.onHandleIntent=" + dataItemUri);
    }
    if (mGoogleApiClient.isConnected()) {
        DataApi.DeleteDataItemsResult result = Wearable.DataApi
                .deleteDataItems(mGoogleApiClient, dataItemUri).await();
        if (result.getStatus().isSuccess() && !intent.getBooleanExtra(EXTRA_SILENT, false)) {
            // Show the success animation on the watch unless Silent extra is true.
            startConfirmationActivity(ConfirmationActivity.SUCCESS_ANIMATION,
                                      getString(R.string.delete_successful));
        } else {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "DeleteService.onHandleIntent: Failed to delete dataItem:"
                        + dataItemUri);
            }
            // Show the failure animation on the watch unless Silent extra is true.
            if (!intent.getBooleanExtra(EXTRA_SILENT, false)) {
                startConfirmationActivity(ConfirmationActivity.FAILURE_ANIMATION,
                                          getString(R.string.delete_unsuccessful));
            }
        }
    } else {
        Log.e(TAG, "Failed to delete data item: " + dataItemUri
                + " - Client disconnected from Google Play Services");
        // Show the failure animation on the watch unless Silent extra is true.
        if (!intent.getBooleanExtra(EXTRA_SILENT, false)) {
            startConfirmationActivity(ConfirmationActivity.FAILURE_ANIMATION,
                    getString(R.string.delete_unsuccessful));
        }
    }
    mGoogleApiClient.disconnect();
}
 
示例15
private void startConfirmationActivity(int animationType, String message) {
    Intent confirmationActivity = new Intent(this, ConfirmationActivity.class)
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION)
            .putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, animationType)
            .putExtra(ConfirmationActivity.EXTRA_MESSAGE, message);
    startActivity(confirmationActivity);
}
 
示例16
private void showConfirmation() {
    Intent intent = new Intent(getApplicationContext(), ConfirmationActivity.class);
    intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,
            ConfirmationActivity.SUCCESS_ANIMATION);
    intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE, "OK");
    startActivity(intent);
}
 
示例17
private PendingIntent getVotePendingIntent(Post post, int voteDirection, int requestCode) {
    Intent vote = new Intent(this, ActionReceiver.class);
    vote.putExtra(Constants.KEY_PATH, Constants.PATH_VOTE);
    vote.putExtra(Constants.KEY_CONFIRMATION_MESSAGE, getString(R.string.vote));
    vote.putExtra(Constants.KEY_CONFIRMATION_ANIMATION, ConfirmationActivity.SUCCESS_ANIMATION);
    vote.putExtra(Constants.PATH_KEY_POST_FULLNAME, post.getFullname());
    vote.putExtra(Constants.KEY_POST_VOTE_DIRECTION, voteDirection);
    return PendingIntent.getBroadcast(this,
            requestCode,
            vote,
            PendingIntent.FLAG_UPDATE_CURRENT);
}
 
示例18
private PendingIntent getSaveToPocketPendingIntent(String permalink, int notificationId) {
    Intent saveToPocket = new Intent(this, ActionReceiver.class);
    saveToPocket.putExtra(Constants.KEY_PATH, Constants.PATH_SAVE_TO_POCKET);
    saveToPocket.putExtra(Constants.KEY_CONFIRMATION_MESSAGE,
            getString(R.string.save_to_pocket));
    saveToPocket.putExtra(Constants.KEY_CONFIRMATION_ANIMATION,
            ConfirmationActivity.SUCCESS_ANIMATION);
    saveToPocket.putExtra(Constants.KEY_POST_PERMALINK, permalink);
    return PendingIntent.getBroadcast(this,
            REQUEST_CODE_SAVE_TO_POCKET + notificationId,
            saveToPocket,
            PendingIntent.FLAG_UPDATE_CURRENT);
}
 
示例19
private PendingIntent getViewCommentsPendingIntent(Post post, int notificationId) {
    Intent intent = new Intent(this, ActionReceiver.class);
    intent.putExtra(Constants.KEY_PATH, Constants.PATH_COMMENTS);
    intent.putExtra(Constants.KEY_CONFIRMATION_MESSAGE, getString(R.string.getting_comments));
    intent.putExtra(Constants.KEY_CONFIRMATION_ANIMATION,
            ConfirmationActivity.SUCCESS_ANIMATION);
    intent.putExtra(Constants.KEY_POST_PERMALINK, post.getPermalink());
    return PendingIntent.getBroadcast(this,
            REQUEST_VIEW_COMMENTS + notificationId,
            intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
}
 
示例20
private void showConfirmation(Context context, String message, int animation) {
    Intent confirmationActivity = new Intent(context, ConfirmationActivity.class).setFlags(
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION)
            .putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, animation)
            .putExtra(ConfirmationActivity.EXTRA_MESSAGE, message);
    context.startActivity(confirmationActivity);
}
 
示例21
@Override
public Object instantiateItem(ViewGroup container, int row, final int column) {
    if (mAttractions != null && mAttractions.size() > 0) {
        final Attraction attraction = mAttractions.get(row);
        switch (column) {
            case PAGER_PRIMARY_IMAGE_COLUMN:
            case PAGER_SECONDARY_IMAGE_COLUMN:
                // Two pages of full screen images, one with the attraction name
                // and one with the distance to the attraction
                final View view = mLayoutInflater.inflate(
                        R.layout.gridpager_fullscreen_image, container, false);
                ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
                TextView textView = (TextView) view.findViewById(R.id.textView);
                FrameLayout overlayTextLayout =
                        (FrameLayout) view.findViewById(R.id.overlaytext);

                mDelayedHide.add(overlayTextLayout);
                view.setOnClickListener(mDelayedHide);

                FrameLayout.LayoutParams params =
                        (FrameLayout.LayoutParams) textView.getLayoutParams();
                params.bottomMargin = params.bottomMargin + mInsets.bottom;
                params.leftMargin = mInsets.left;
                params.rightMargin = mInsets.right;
                textView.setLayoutParams(params);

                if (column == PAGER_PRIMARY_IMAGE_COLUMN) {
                    imageView.setImageBitmap(attraction.image);
                    textView.setText(attraction.name);
                } else {
                    imageView.setImageBitmap(attraction.secondaryImage);
                    if (TextUtils.isEmpty(attraction.distance)) {
                        overlayTextLayout.setVisibility(View.GONE);
                    } else {
                        textView.setText(mContext.getString(
                                R.string.map_caption, attraction.distance));
                    }
                }
                container.addView(view);
                return view;
            case PAGER_DESCRIPTION_COLUMN:
                // The description card page
                CardScrollView cardScrollView = (CardScrollView) mLayoutInflater.inflate(
                        R.layout.gridpager_card, container, false);
                TextView descTextView = (TextView) cardScrollView.findViewById(R.id.textView);
                descTextView.setText(attraction.description);
                cardScrollView.setCardGravity(Gravity.BOTTOM);
                cardScrollView.setExpansionEnabled(true);
                cardScrollView.setExpansionDirection(CardFrame.EXPAND_DOWN);
                cardScrollView.setExpansionFactor(10);
                container.addView(cardScrollView);
                return cardScrollView;
            case PAGER_NAVIGATE_ACTION_COLUMN:
                // The navigate action
                final ActionPage navActionPage = (ActionPage) mLayoutInflater.inflate(
                        R.layout.gridpager_action, container, false);

                navActionPage.setOnClickListener(getStartActionClickListener(
                        attraction, Constants.START_NAVIGATION_PATH,
                        ConfirmationActivity.SUCCESS_ANIMATION));
                navActionPage.setImageResource(R.drawable.ic_full_directions_walking);
                navActionPage.setText(mContext.getString(R.string.action_navigate));

                container.addView(navActionPage);
                return navActionPage;
            case PAGER_OPEN_ACTION_COLUMN:
                // The "open on device" action
                final ActionPage openActionPage = (ActionPage) mLayoutInflater.inflate(
                        R.layout.gridpager_action, container, false);

                openActionPage.setOnClickListener(getStartActionClickListener(
                        attraction, Constants.START_ATTRACTION_PATH,
                        ConfirmationActivity.OPEN_ON_PHONE_ANIMATION));
                openActionPage.setImageResource(R.drawable.ic_full_openonphone);
                openActionPage.setText(mContext.getString(R.string.action_open));

                container.addView(openActionPage);
                return openActionPage;
        }
    }
    return new View(mContext);
}