/** Sets the visibility of the extra keys appropriately. */
  private void setExtraKeysVisibility(int visibility, boolean forceVisible) {
    Configuration config = getResources().getConfiguration();
    // Log.e(TAG, "Hardware kbd hidden: " + Integer.toString(config.hardKeyboardHidden));
    // Log.e(TAG, "Any keyboard hidden: " + Integer.toString(config.keyboardHidden));
    // Log.e(TAG, "Keyboard type: " + Integer.toString(config.keyboard));

    boolean makeVisible = forceVisible;
    if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) makeVisible = true;

    if (!extraKeysHidden
        && makeVisible
        && connection.getExtraKeysToggleType() == Constants.EXTRA_KEYS_ON) {
      layoutKeys.setVisibility(View.VISIBLE);
      layoutKeys.invalidate();
      return;
    }

    if (visibility == View.GONE) {
      layoutKeys.setVisibility(View.GONE);
      layoutKeys.invalidate();
    }
  }
Exemplo n.º 2
0
  public void initAdWhirl() {

    setContentView(R.layout.main);
    AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);

    AdWhirlLayout adWhirlLayout = (AdWhirlLayout) findViewById(R.id.adwhirl_layout);

    TextView textView = new TextView(this);
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    int diWidth = 320;
    int diHeight = 52;
    int density = (int) getResources().getDisplayMetrics().density;
    try {

      adWhirlLayout.setAdWhirlInterface(this);
      adWhirlLayout.setMaxWidth((int) (diWidth * density));
      adWhirlLayout.setMaxHeight((int) (diHeight * density));

      layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      textView.setText("Below AdWhirlLayout");

      // LinearLayout layout = (LinearLayout)findViewById(R.id.layout_main);
      RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout_main);

      if (layout == null) {
        Log.e("AdWhirl", "Layout is null!");
        return;
      }

      // layout.setGravity(Gravity.CENTER_HORIZONTAL);
      // layout.addView(adWhirlLayout, layoutParams);
      // layout.addView(textView, layoutParams);
      layout.invalidate();
    } catch (Exception e) {
      Log.e("ADWHIRL", "Error in code:" + e.toString());
      e.printStackTrace();
    }

    AdWhirlAdapter.setGoogleAdSenseAppName("OpenMBTA");
    AdWhirlAdapter.setGoogleAdSenseCompanyName("Kaja Software");
    // AdWhirlAdapter.setGoogleAdSenseChannel("xxxxxxx");
    // AdWhirlTargeting.setKeywords("My keywords");

  }
  public AdViewHelper(Cocos2dxActivity activity) {
    com.adsmogo.util.L.debug = true;
    mActivity = activity;

    mLayout = new RelativeLayout(mActivity);

    activity.addContentView(
        mLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    AdsMogoLayout adViewLayout =
        new AdsMogoLayout(mActivity, "20d18f3561a34075bcc2514294239317", true);

    // ¶¥²¿¾ÓÖÐ
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    adViewLayout.setLayoutParams(layoutParams);

    mLayout.addView(adViewLayout);
    mLayout.invalidate();

    mHandler =
        new Handler() {
          @Override
          public void handleMessage(Message msg) {
            switch (msg.what) {
              case 1:
                {
                  if (mLayout != null) mLayout.setVisibility(View.VISIBLE);
                  break;
                }
              case 2:
                {
                  if (mLayout != null) mLayout.setVisibility(View.GONE);
                  break;
                }
              default:
                break;
            }
          }
        };
  }
  @Override
  public void invalidate() {
    super.invalidate();

    if (rootNode == null) {
      return;
    }

    int springOffsetLevel1 = 0;
    int springOffsetLevel2 = 0;

    springLevel1[0].setCurrentValue(CLOSED);
    springLevel1[0].removeAllListeners();

    for (int i = 0; i < springLevel2_disabled.length; i++) {
      springLevel2_disabled[i].setCurrentValue(CLOSED);
      springLevel2_disabled[i].removeAllListeners();
      springLevel2_enabled[i].setCurrentValue(CLOSED);
      springLevel2_enabled[i].removeAllListeners();
    }

    global_latest_springLevel2_enabled = null;
    global_latest_springLevel2_disabled = null;

    for (final Node<StarOptions> node_level_0 : rootNode.getChildren()) {
      final ImageButton view = itemsRow1[springOffsetLevel1];
      view.setVisibility(GONE);
      view.setImageResource(node_level_0.getValue().resourceId);

      if (!node_level_0.hasChildren()) {
        view.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                node_level_0.getValue().onActionPerformer.onClick();
              }
            });

        springLevel1[0].addListener(
            new FlowerCosPerformer(
                view,
                View.TRANSLATION_X,
                springOffsetLevel1 - OFFSET_ROW_1,
                RING_DIAMETER1,
                innerArc) {
              @Override
              public void onSpringUpdate(Spring spring) {
                super.onSpringUpdate(spring);
                if (spring.getCurrentValue() == CLOSED) {
                  view.setVisibility(GONE);
                } else {
                  view.setVisibility(VISIBLE);
                }
              }
            });
        springLevel1[0].addListener(
            new FlowerSinPerformer(
                view,
                View.TRANSLATION_Y,
                springOffsetLevel1 - OFFSET_ROW_1,
                RING_DIAMETER1,
                innerArc));
        springLevel1[0].setEndValue(CLOSED);

      } else {
        final int offsetLevel1 = springOffsetLevel1;
        view.setOnClickListener(
            new OnClickListener() {
              int toggle = 0;

              @Override
              public void onClick(View v) {
                if (selectedView != v) {
                  selectedView = v;
                  toggle = 0;
                }

                if (resetToggles_2) {
                  resetToggles_2 = false;
                  toggle = 0;
                }

                if (toggle == 0) {
                  if (global_latest_springLevel2_enabled != null) {
                    global_latest_springLevel2_enabled.setCurrentValue(CLOSED);
                  }

                  if (global_latest_springLevel2_disabled != null) {
                    global_latest_springLevel2_disabled.setCurrentValue(CLOSED);
                  }

                  global_latest_springLevel2_enabled = springLevel2_enabled[offsetLevel1];
                  global_latest_springLevel2_disabled = springLevel2_disabled[offsetLevel1];

                  springLevel2_enabled[offsetLevel1].setEndValue(OPEN);
                  springLevel2_disabled[offsetLevel1].setEndValue(CLOSED);

                  toggle = 1;
                } else {
                  springLevel2_enabled[offsetLevel1].setEndValue(CLOSED);
                  springLevel2_disabled[offsetLevel1].setEndValue(CLOSED);

                  toggle = 0;
                }
              }
            });

        springLevel1[0].addListener(
            new FlowerCosPerformer(
                view, View.TRANSLATION_X, offsetLevel1 - OFFSET_ROW_1, RING_DIAMETER1, innerArc) {
              @Override
              public void onSpringUpdate(Spring spring) {
                super.onSpringUpdate(spring);
                if (spring.getCurrentValue() == CLOSED) {
                  view.setVisibility(GONE);
                } else {
                  view.setVisibility(VISIBLE);
                }
              }
            });
        springLevel1[0].addListener(
            new FlowerSinPerformer(
                view, View.TRANSLATION_Y, offsetLevel1 - OFFSET_ROW_1, RING_DIAMETER1, innerArc));
        springLevel1[0].setEndValue(CLOSED);

        for (final Node<StarOptions> node_level_1 : node_level_0.getChildren()) {
          if (node_level_1.hasChildren()) {
            continue;
          }

          final ImageButton view1 = itemsRow2[springOffsetLevel2];
          view1.setImageResource(node_level_1.getValue().resourceId);

          view1.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  node_level_1.getValue().onActionPerformer.onClick();
                }
              });

          springLevel2_enabled[springOffsetLevel1].addListener(
              new FlowerCosPerformer(
                  view1,
                  View.TRANSLATION_X,
                  springOffsetLevel2 - OFFSET_ROW_2,
                  RING_DIAMETER2,
                  outerArc) {
                @Override
                public void onSpringUpdate(Spring spring) {
                  super.onSpringUpdate(spring);
                  if (spring.getCurrentValue() == CLOSED) {
                    view1.setVisibility(GONE);
                  } else {
                    view1.setVisibility(VISIBLE);
                  }
                }
              });

          springLevel2_enabled[springOffsetLevel1].addListener(
              new FlowerSinPerformer(
                  view1,
                  View.TRANSLATION_Y,
                  springOffsetLevel2 - OFFSET_ROW_2,
                  RING_DIAMETER2,
                  outerArc));
          springLevel2_enabled[springOffsetLevel1].setEndValue(CLOSED);

          springOffsetLevel2++;
        }

        for (int i = springOffsetLevel2; i < itemsRow2.length; i++) {
          final View view1 = itemsRow2[i];
          view1.setVisibility(GONE);

          springLevel2_disabled[springOffsetLevel1].addListener(
              new FlowerCosPerformer(
                  view1,
                  View.TRANSLATION_X,
                  springOffsetLevel2 - OFFSET_ROW_2,
                  RING_DIAMETER2,
                  outerArc) {
                @Override
                public void onSpringUpdate(Spring spring) {
                  super.onSpringUpdate(spring);
                  if (spring.getCurrentValue() == CLOSED) {
                    view1.setVisibility(GONE);
                  } else {
                    view1.setVisibility(VISIBLE);
                  }
                }
              });
          springLevel2_disabled[springOffsetLevel1].addListener(
              new FlowerSinPerformer(
                  view1,
                  View.TRANSLATION_Y,
                  springOffsetLevel2 - OFFSET_ROW_2,
                  RING_DIAMETER2,
                  outerArc));
          springLevel2_disabled[springOffsetLevel1].setEndValue(CLOSED);
        }

        springOffsetLevel2 = 0;
      }

      springOffsetLevel1++;
    }

    for (int i = springOffsetLevel1; i < itemsRow1.length; i++) {
      View view = itemsRow1[i];
      view.setVisibility(GONE);
    }
  }
Exemplo n.º 5
0
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    String pManufacturer = android.os.Build.MANUFACTURER;
    String pModel = android.os.Build.MODEL;

    if ("GT-I9300".equals(pModel) && "samsung".equals(pManufacturer)) {

      RelativeLayout main = (RelativeLayout) findViewById(R.id.relativeLayout_main);
      main.invalidate();

      setContentView(R.layout.activity_camera_crop);

      mImageView = (CroppedImageView) findViewById(R.id.ivCameraCropPhoto);
      mImageView.setDrawingCacheEnabled(true);

      scaleView();

      // Cancel button
      findViewById(R.id.btnCameraCancel)
          .setOnClickListener(
              new OnClickListener() {

                @Override
                public void onClick(View v) {

                  finish();
                  if (getIntent().getStringExtra("type").equals("gallery")) {
                    Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class);
                    intent.putExtra("type", "gallery");
                    startActivity(intent);
                  } else {
                    Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class);
                    intent.putExtra("type", "camera");
                    startActivity(intent);
                  }
                }
              });

      // Next button
      findViewById(R.id.btnCameraOk)
          .setOnClickListener(
              new OnClickListener() {

                @Override
                public void onClick(View v) {
                  Bitmap resizedBitmap = getBitmapFromView(mImageView);

                  ByteArrayOutputStream bs = new ByteArrayOutputStream();
                  resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bs);

                  if (saveBitmapToFile(resizedBitmap, mFilePath) == true) {

                    if (mForProfile == true) {
                      MyProfileActivity.gProfileImage = getBitmapFromView(mImageView);
                      MyProfileActivity.gProfileImagePath = mFilePath;
                    } else if (mForGroup == true) {
                      CreateGroupActivity.gGroupImage = getBitmapFromView(mImageView);
                      CreateGroupActivity.gGroupImagePath = mFilePath;
                    } else if (mForGroupUpdate == true) {
                      GroupProfileActivity.gGroupImage = getBitmapFromView(mImageView);
                      GroupProfileActivity.gGroupImagePath = mFilePath;
                    } else {
                      fileUploadAsync(mFilePath);

                      //									new FileUploadAsync(CameraCropActivity.this)
                      //											.execute(mFilePath);
                      // new
                      // SendMessageAsync(getApplicationContext(),
                      // SendMessageAsync.TYPE_PHOTO)
                      // .execute(resizedBitmap);
                    }
                  } else {
                    Toast.makeText(
                            CameraCropActivity.this, "Failed to send photo", Toast.LENGTH_LONG)
                        .show();
                  }
                }
              });

      File file = new File(_path);
      boolean exists = file.exists();
      if (exists) onPhotoTaken(_path);
      else
        Toast.makeText(
                getBaseContext(),
                "Something went wrong while taking picture, please try again.",
                Toast.LENGTH_SHORT)
            .show();
    }
  }
 @Override
 public void onPageScrolled(int arg0, float arg1, int arg2) {
   // to refresh frameLayout
   if (mContainer != null) mContainer.invalidate();
 }