예제 #1
0
  /**
   * (�� Javadoc,��д�ķ���) @Title: onCreate @Description: ����Activity�����Ҹ��ֳ�ʼ��
   *
   * @param savedInstanceState
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    // �����ޱ���
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // ����ȫ��
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.photo_viewfilpper);

    // ��ȡintent��Ϣ,ͨ��Intent���ݵ����
    Intent intent = getIntent();
    currentNum = intent.getIntExtra("currentpic", 0);
    albumArray = intent.getStringArrayExtra("albumArray");
    photoPath = intent.getStringExtra("photopath");
    AlbumName = intent.getStringExtra("AlbumName");

    detector = new GestureDetector(this);
    flipper = (ViewFlipper) findViewById(R.id.ViewFlipper);

    try {
      // ��ʼ����������ͱ���
      initCompenents();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #2
0
	public void shareClick(View view) {
		Intent shareIntent = new Intent();
		shareIntent.setAction(Intent.ACTION_SEND);
		shareIntent.putExtra(Intent.EXTRA_STREAM, saveImageUri(getApplicationContext(), ScreenShot()));
		shareIntent.setType("image/png");
		startActivity(Intent.createChooser(shareIntent, "Share with..."));
	}
  @Override
  public void onActivityStartup() {
    AndroidOsService androidService =
        getSpaceEnvironment().getServiceRegistry().getService(AndroidOsService.SERVICE_NAME);

    try {
      Intent browserIntent = new Intent(Intent.ACTION_VIEW);
      browserIntent.setData(Uri.parse("https://www.smartspaces.io/"));
      browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      androidService.getAndroidContext().getApplicationContext().startActivity(browserIntent);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #4
0
    @Override
    protected void onActivityResult(int requestCode, int resultCode,
            Intent data) {
        switch (requestCode) {
            case MenuHelper.RESULT_COMMON_MENU_CROP:
                if (resultCode == RESULT_OK) {
                    // The CropImage activity passes back the Uri of the
                    // cropped image as the Action rather than the Data.
                    mSavedUri = Uri.parse(data.getAction());

                    // if onStart() runs before, then set the returned
                    // image as currentImage.
                    if (mAllImages != null) {
                        IImage image = mAllImages.getImageForUri(mSavedUri);
                        // image could be null if SD card is removed.
                        if (image == null) {
                            finish();
                        } else {
                            mCurrentPosition = mAllImages.getImageIndex(image);
                            setImage(mCurrentPosition, false);
                        }
                    }
                }
                break;
        }
    }
예제 #5
0
 private void startShareMediaActivity(IImage image) {
     boolean isVideo = image instanceof VideoObject;
     Intent intent = new Intent();
     intent.setAction(Intent.ACTION_SEND);
     intent.setType(image.getMimeType());
     intent.putExtra(Intent.EXTRA_STREAM, image.fullSizeImageUri());
     try {
         startActivity(Intent.createChooser(intent, getText(
                 isVideo ? R.string.sendVideo : R.string.sendImage)));
     } catch (android.content.ActivityNotFoundException ex) {
         Toast.makeText(this, isVideo
                 ? R.string.no_way_to_share_image
                 : R.string.no_way_to_share_video,
                 Toast.LENGTH_SHORT).show();
     }
 }
예제 #6
0
 /** Checks that objects are created correctly. */
 @Test
 public void testConstruction() {
   final IntentOperations operations =
       IntentOperations.builder(appId)
           .addUpdateOperation(intent.id())
           .addWithdrawOperation(intent.id())
           .build();
   final List<IntentOperation> operationList = operations.operations();
   assertThat(operationList, hasSize(2));
   for (final IntentOperation operation : operationList) {
     assertThat(
         operation.type(), isOneOf(IntentOperation.Type.UPDATE, IntentOperation.Type.WITHDRAW));
     assertThat(operation.intent(), is((Intent) null));
     assertThat(operation.intentId(), is(intent.id()));
   }
 }
예제 #7
0
        public final void onReceive(Context context, Intent intent)
        {
            List list;
label0:
            {
                if (intent.getAction().equals("android.net.wifi.WIFI_STATE_CHANGED"))
                {
                    a = intent.getIntExtra("wifi_state", 4);
                    if (f.b(d) != null)
                    {
                        f.b(d).b(a);
                    }
                }
                if (intent.getAction().equals("android.net.wifi.SCAN_RESULTS") || intent.getAction().equals("android.net.wifi.WIFI_STATE_CHANGED"))
                {
                    WifiManager wifimanager = f.c(d);
                    list = null;
                    if (wifimanager != null)
                    {
                        list = f.c(d).getScanResults();
                    }
                    if (!intent.getAction().equals("android.net.wifi.WIFI_STATE_CHANGED") || list != null && (list == null || list.size() != 0))
                    {
                        break label0;
                    }
                }
                return;
            }
            if (!c && b != null && b.size() >= 4 && list != null && list.size() <= 2)
            {
                a(list);
                c = true;
                d.a(0L);
                return;
            }
            a(list);
            c = false;
            f.a(d, d. new b(b, System.currentTimeMillis(), a));
            if (f.b(d) != null)
            {
                f.b(d).a(f.d(d));
            }
            d.a(20000L * (long)f.e(d));
        }
  /**
   * (�� Javadoc,��д�ķ���) @Title: onCreate @Description:
   *
   * @param savedInstanceState
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    // �����ޱ���
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.grid);

    Intent intent = getIntent(); // ��ȡintent ��Ϣ
    AlbumName = intent.getStringExtra("albumname");
    albumArray = intent.getStringArrayExtra("albumArray");
    setTitle("����" + "/" + AlbumName); // ����

    // ��ʼ���������
    initComponents();

    tLocalAlbum = new Thread(rLocalAlbum); // ����һ�����߳�
    tLocalAlbum.start();
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 public Intent createIntentFromString(EDataType eDataType, String initialValue) {
   Intent result = Intent.get(initialValue);
   if (result == null)
     throw new IllegalArgumentException(
         "The value '"
             + initialValue
             + "' is not a valid enumerator of '"
             + eDataType.getName()
             + "'");
   return result;
 }
예제 #10
0
  /** Tests equals(), hashCode() and toString() methods. */
  @Test
  public void testEquals() {
    final IntentOperations operations1 =
        IntentOperations.builder(appId).addSubmitOperation(intent).build();
    final IntentOperations sameAsOperations1 =
        IntentOperations.builder(appId).addSubmitOperation(intent).build();
    final IntentOperations operations2 =
        IntentOperations.builder(appId).addReplaceOperation(intent.id(), intent).build();

    new EqualsTester()
        .addEqualityGroup(operations1, sameAsOperations1)
        .addEqualityGroup(operations2)
        .testEquals();
  }
예제 #11
0
 // Workaround to bug where sometimes response codes come as Long instead of Integer
 int getResponseCodeFromIntent(Intent i) {
     Object o = i.getExtras().get(RESPONSE_CODE);
     if (o == null) {
         logError("Intent with no response code, assuming OK (known issue)");
         return BILLING_RESPONSE_RESULT_OK;
     }
     else if (o instanceof Integer) return ((Integer)o).intValue();
     else if (o instanceof Long) return (int)((Long)o).longValue();
     else {
         logError("Unexpected type for intent response code.");
         logError(o.getClass().getName());
         throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
     }
 }
예제 #12
0
 /**
  * @Method: shareToWeiBo @Description: ����ͼƬ��΢��
  *
  * @param path ͼƬ��·��
  */
 private void shareToWeiBo(String path) {
   Log.d("���?΢�� -ͼƬ��ַ : ", path);
   Intent intent = new Intent(Intent.ACTION_SEND);
   // imagePath:����·����Ҫ���ļ���չ��
   String url = "file:///" + path;
   intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
   intent.setType("image/jpeg");
   intent.putExtra(Intent.EXTRA_TITLE, "���?΢��");
   intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
   startActivity(Intent.createChooser(intent, "���?ʽ"));
 }
예제 #13
0
 public void onClick(View v) {
     switch (v.getId()) {
         case R.id.btn_delete:
             MenuHelper.deleteImage(this, mDeletePhotoRunnable,
                     mAllImages.getImageAt(mCurrentPosition));
             break;
         case R.id.btn_play:
             startPlayVideoActivity();
             break;
         case R.id.btn_share: {
             IImage image = mAllImages.getImageAt(mCurrentPosition);
             if (!MenuHelper.isWhiteListUri(image.fullSizeImageUri())) {
                 return;
             }
             startShareMediaActivity(image);
             break;
         }
         case R.id.btn_set_as: {
             IImage image = mAllImages.getImageAt(mCurrentPosition);
             Intent intent = Util.createSetAsIntent(image);
             try {
                 startActivity(Intent.createChooser(
                         intent, getText(R.string.setImage)));
             } catch (android.content.ActivityNotFoundException ex) {
                 Toast.makeText(this, R.string.no_way_to_share_video,
                         Toast.LENGTH_SHORT).show();
             }
             break;
         }
         case R.id.btn_done:
             finish();
             break;
         case R.id.next_image:
             moveNextOrPrevious(1);
             break;
         case R.id.prev_image:
             moveNextOrPrevious(-1);
             break;
     }
 }
예제 #14
0
  @Before
  public void setUp() {
    Intent.bindIdGenerator(idGenerator);

    intent = new PointToPointIntent(NetTestTools.APP_ID, selector, treatment, ingress, egress);
  }
예제 #15
0
    @Override
    public void onCreate(Bundle instanceState) {
        super.onCreate(instanceState);

        Intent intent = getIntent();
        mFullScreenInNormalMode = intent.getBooleanExtra(
                MediaStore.EXTRA_FULL_SCREEN, true);

        setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.review_image);

        mRootView = findViewById(R.id.root);
        mControlBar = findViewById(R.id.control_bar);
        mImageView = (ImageViewTouch2) findViewById(R.id.image);
        mImageView.setEnableTrackballScroll(true);
        mCache = new BitmapCache(3);
        mImageView.setRecycler(mCache);

        ((PreviewFrameLayout) findViewById(
                R.id.frame_layout)).setAspectRatio(ASPECT_RATIO);


        makeGetter();

        mSlideShowImageViews[0] =
                (ImageViewTouchBase) findViewById(R.id.image1_slideShow);
        mSlideShowImageViews[1] =
                (ImageViewTouchBase) findViewById(R.id.image2_slideShow);
        for (ImageViewTouchBase v : mSlideShowImageViews) {
            v.setVisibility(View.INVISIBLE);
            v.setRecycler(mCache);
        }

        mParam = getIntent().getParcelableExtra(KEY_IMAGE_LIST);

        if (instanceState != null) {
            mSavedUri = instanceState.getParcelable(STATE_URI);
            mShowControls = instanceState.getBoolean(STATE_SHOW_CONTROLS, true);
        } else {
            mSavedUri = getIntent().getData();
        }

        int[] pickIds = {R.id.attach, R.id.cancel};
        int[] reviewIds = {R.id.btn_delete, R.id.btn_share, R.id.btn_set_as,
                R.id.btn_play, R.id.btn_done};
        int[] connectIds = isPickIntent() ? pickIds : reviewIds;
        for (int id : connectIds) {
            View view = mControlBar.findViewById(id);
            view.setOnClickListener(this);
            // Set the LinearLayout of the given button to visible
            ((View) view.getParent()).setVisibility(View.VISIBLE);
        }

        if (mFullScreenInNormalMode) {
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        setupOnScreenControls(findViewById(R.id.mainPanel), mImageView);
    }
예제 #16
0
 @After
 public void tearDown() {
   Intent.unbindIdGenerator(idGenerator);
 }
예제 #17
0
    /**
     * Starts the setup process. This will start up the setup process asynchronously.
     * You will be notified through the listener when the setup process is complete.
     * This method is safe to call from a UI thread.
     *
     * @param listener The listener to notify when the setup process is complete.
     */
    public void startSetup(final OnIabSetupFinishedListener listener) {
        // If already set up, can't do it again.
        checkNotDisposed();
        if (mSetupDone) throw new IllegalStateException("IAB helper is already set up.");

        // Connection to IAB service
        logDebug("Starting in-app billing setup.");
        mServiceConn = new ServiceConnection() {
            @Override
            public void onServiceDisconnected(ComponentName name) {
                logDebug("Billing service disconnected.");
                mService = null;
            }

            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
                if (mDisposed) return;
                logDebug("Billing service connected.");
                mService = IInAppBillingService.Stub.asInterface(service);
                String packageName = mContext.getPackageName();
                try {
                    logDebug("Checking for in-app billing 3 support.");

                    // check for in-app billing v3 support
                    int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP);
                    if (response != BILLING_RESPONSE_RESULT_OK) {
                        if (listener != null) listener.onIabSetupFinished(new IabResult(response,
                                "Error checking for billing v3 support."));

                        // if in-app purchases aren't supported, neither are subscriptions.
                        mSubscriptionsSupported = false;
                        return;
                    }
                    logDebug("In-app billing version 3 supported for " + packageName);

                    // check for v3 subscriptions support
                    response = mService.isBillingSupported(3, packageName, ITEM_TYPE_SUBS);
                    if (response == BILLING_RESPONSE_RESULT_OK) {
                        logDebug("Subscriptions AVAILABLE.");
                        mSubscriptionsSupported = true;
                    }
                    else {
                        logDebug("Subscriptions NOT AVAILABLE. Response: " + response);
                    }

                    mSetupDone = true;
                }
                catch (RemoteException e) {
                    if (listener != null) {
                        listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION,
                                                    "RemoteException while setting up in-app billing."));
                    }
                    e.printStackTrace();
                    return;
                }

                if (listener != null) {
                    listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful."));
                }
            }
        };

        Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        serviceIntent.setPackage("com.android.vending");
        if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {
            // service available to handle that Intent
            mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
        }
        else {
            // no service available to handle that Intent
            if (listener != null) {
                listener.onIabSetupFinished(
                        new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,
                        "Billing service unavailable on device."));
            }
        }
    }
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.timer_layout://Layout made clickable to increase click area.
		case R.id.menu_header_time_tracker:
			if(AppUtility.getAppUtilityInstance().isConnectionEstablished()) {
				AppUtility.getAppUtilityInstance().printTimerLogs();
				Intent timerDrawerIntent = new Intent(this, TimeDrawerActivity.class);
				timerDrawerIntent.putExtra(IAppConstants.IS_APP_ON_PAUSE_STATE, false);
				timerDrawerIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				
				Object setResult =  v.getTag(R.id.menu_header_time_tracker);
				
				if(setResult != null && (setResult instanceof Integer)) {
					int requestCode = Integer.parseInt(setResult.toString());
					if ((requestCode&0xffff0000) == 0) {
						timerDrawerIntent.putExtra(IAppConstants.StoreVisitSummary.EXTRA_NOTIFY_REFRESH, requestCode );
						startActivityForResult(timerDrawerIntent, requestCode);
					} else {
						startActivity(timerDrawerIntent);
					}
				} else {
					startActivity(timerDrawerIntent);
				}
			}else {
				AppLogs.d("NavigationDrawerSliderActivity", " connection not established!!");
			}
			break;

		case R.id.tv_header_subtitle: //Set click listener to subtitle to increase clickable area.
		case R.id.ll_header_clickable_menubar:
			if (button.getVisibility() == View.VISIBLE) {
				if (isToggle) {
					final ListPopupWindow mPopupMenuWindow = new ListPopupWindow(
							this);
					mPopupMenuWindow.setAnchorView(v);
					mPopupMenuWindow.setHeight(406);
					mPopupMenuWindow.setWidth(325);
					mPopupMenuWindow.getListView();
					mPopupMenuWindow.setBackgroundDrawable(getResources()
							.getDrawable(R.drawable.bg_popover_function_nine));
					if (menuItems != null) {
						menuAdapter = new FunctionMenuAdapter(this, menuItems,
								txtHeaderTypeface);
					}
					mPopupMenuWindow.setAdapter(menuAdapter);
					mPopupMenuWindow.setVerticalOffset(15);
					mPopupMenuWindow.setHorizontalOffset(-19);
					mPopupMenuWindow
							.setOnItemClickListener(new OnItemClickListener() {

								@Override
								public void onItemClick(AdapterView<?> parent,
										View view, int position, long arg3) {
									//TODO: Call through Presenter. Currently, the "this" instance is of HomeScreenActivity, hence making local method call.
									/*mPresenter.*/OnClickSelectedItem(menuItems
											.get(position).toString());
									mPopupMenuWindow.dismiss();
									isToggle = !isToggle;
								}
							});
					mPopupMenuWindow.show();
				}
				isToggle = !isToggle;
			}
			break;
		}
	}
예제 #19
0
    /**
     * Handles an activity result that's part of the purchase flow in in-app billing. If you
     * are calling {@link #launchPurchaseFlow}, then you must call this method from your
     * Activity's {@link android.app.Activity@onActivityResult} method. This method
     * MUST be called from the UI thread of the Activity.
     *
     * @param requestCode The requestCode as you received it.
     * @param resultCode The resultCode as you received it.
     * @param data The data (Intent) as you received it.
     * @return Returns true if the result was related to a purchase flow and was handled;
     *     false if the result was not related to a purchase, in which case you should
     *     handle it normally.
     */
    public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
        IabResult result;
        if (requestCode != mRequestCode) return false;

        checkNotDisposed();
        checkSetupDone("handleActivityResult");

        // end of async purchase operation that started on launchPurchaseFlow
        flagEndAsync();

        if (data == null) {
            logError("Null data in IAB activity result.");
            result = new IabResult(IABHELPER_BAD_RESPONSE, "Null data in IAB result");
            if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);
            return true;
        }

        int responseCode = getResponseCodeFromIntent(data);
        String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA);
        String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE);

        if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) {
            logDebug("Successful resultcode from purchase activity.");
            logDebug("Purchase data: " + purchaseData);
            logDebug("Data signature: " + dataSignature);
            logDebug("Extras: " + data.getExtras());
            logDebug("Expected item type: " + mPurchasingItemType);

            if (purchaseData == null || dataSignature == null) {
                logError("BUG: either purchaseData or dataSignature is null.");
                logDebug("Extras: " + data.getExtras().toString());
                result = new IabResult(IABHELPER_UNKNOWN_ERROR, "IAB returned null purchaseData or dataSignature");
                if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);
                return true;
            }

            Purchase purchase = null;
            try {
                purchase = new Purchase(mPurchasingItemType, purchaseData, dataSignature);
                String sku = purchase.getSku();

                // Verify signature
                if (!Security.verifyPurchase(mSignatureBase64, purchaseData, dataSignature)) {
                    logError("Purchase signature verification FAILED for sku " + sku);
                    result = new IabResult(IABHELPER_VERIFICATION_FAILED, "Signature verification failed for sku " + sku);
                    if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, purchase);
                    return true;
                }
                logDebug("Purchase signature successfully verified.");
            }
            catch (JSONException e) {
                logError("Failed to parse purchase data.");
                e.printStackTrace();
                result = new IabResult(IABHELPER_BAD_RESPONSE, "Failed to parse purchase data.");
                if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);
                return true;
            }

            if (mPurchaseListener != null) {
                mPurchaseListener.onIabPurchaseFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Success"), purchase);
            }
        }
        else if (resultCode == Activity.RESULT_OK) {
            // result code was OK, but in-app billing response was not OK.
            logDebug("Result code was OK but in-app billing response was not OK: " + getResponseDesc(responseCode));
            if (mPurchaseListener != null) {
                result = new IabResult(responseCode, "Problem purchashing item.");
                mPurchaseListener.onIabPurchaseFinished(result, null);
            }
        }
        else if (resultCode == Activity.RESULT_CANCELED) {
            logDebug("Purchase canceled - Response: " + getResponseDesc(responseCode));
            result = new IabResult(IABHELPER_USER_CANCELLED, "User canceled.");
            if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);
        }
        else {
            logError("Purchase failed. Result code: " + Integer.toString(resultCode)
                    + ". Response: " + getResponseDesc(responseCode));
            result = new IabResult(IABHELPER_UNKNOWN_PURCHASE_RESPONSE, "Unknown purchase response.");
            if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);
        }
        return true;
    }