@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.facebook_login_ui);

    // start login sub activity
    loghelper = FacebookLoginHelper.instance(this);
    handler = new LoginHandler();

    facebook_info_span = (View) this.findViewById(R.id.facebook_info_span);
    facebook_info = (TextView) this.findViewById(R.id.facebook_info);
    facebook_info_span.setVisibility(View.VISIBLE);
    orm = SocialORM.instance(this);
    boolean forinvalidsession = getIntent().getBooleanExtra("forinvalidsession", false);
    if (forinvalidsession) {
      Log.d(TAG, "for invalid session issue=" + this);
      loghelper.clearSesion();
      AccountListener.AccountManager.logout();
    }

    // for UI
    email = (EditText) this.findViewById(R.id.facebook_login_email);
    email.setHint(R.string.facebook_email_address);
    pwd = (EditText) this.findViewById(R.id.facebook_login_pwd);
    pwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
    pwd.setHint(R.string.facebook_password);

    login = (Button) this.findViewById(R.id.facebook_login_ok_button);
    sign_up = (Button) this.findViewById(R.id.facebook_login_sign_up_button);

    Paint p = login.getPaint();
    float width1 = p.measureText(login.getText().toString());
    p = null;

    p = sign_up.getPaint();
    float width2 = p.measureText(sign_up.getText().toString());
    int width = Math.round(Math.max(width1, width1));

    width = width + 40;
    login.getLayoutParams().width = width;
    sign_up.getLayoutParams().width = width;
    p = null;

    login.setText(R.string.facebook_login_ok);
    sign_up.setText(R.string.facebook_login_sign_up);
    checkbox_sync_phonebook = (CheckBox) this.findViewById(R.id.checkbox_sync_phonebook);
    checkbox_sync_phonebook.setChecked(orm.isEnableSyncPhonebook());
    checkbox_sync_phonebook.setOnCheckedChangeListener(checkedListener);

    login.setOnClickListener(loginClick);
    sign_up.setOnClickListener(signupClick);

    SocialORM.Account ac = orm.getFacebookAccount();
    email.setText(ac.email);
    pwd.setText(ac.password);

    setTitle(R.string.menu_title_login);
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    sbWeight = (SeekBar) findViewById(R.id.sbWeight);
    sbWeight.setOnSeekBarChangeListener(this);

    btn1 = (Button) findViewById(R.id.btn1);
    btn2 = (Button) findViewById(R.id.btn2);

    lParams1 = (LinearLayout.LayoutParams) btn1.getLayoutParams();
    lParams2 = (LinearLayout.LayoutParams) btn2.getLayoutParams();
  }
  /**
   * Zooms in or out of the board by scalling the size of each Box
   *
   * @param big increase or decrease the size
   */
  public void resizeMe(int big) {
    double resizeButton = 0.0;
    double resizeText = 0.0;
    boolean myCondition = false;
    if (big == 0) {
      resizeButton = 1.25;
      resizeText = 0.3125;
      myCondition = true;
    } else {
      resizeButton = 0.8;
      resizeText = 0.3125;
      myCondition = false;
    }

    for (int x = 0; x < this.getX(); ++x) {
      for (int y = 0; y < this.getY(); ++y) {
        Button change = this.board[x][y];
        LayoutParams params = change.getLayoutParams();

        if (((change.getHeight() * resizeButton > 70.0) && !myCondition)
            || ((change.getHeight() * resizeButton < 130.0) && myCondition)) {
          params.height = (int) (change.getHeight() * resizeButton);
          params.width = (int) (change.getWidth() * resizeButton);
          change.setLayoutParams(params);
          change.setTextSize((float) (params.height * resizeText));
        }
      }
    }
  }
示例#4
0
 /** Sets <code>OnClickListener</code> for "OK" button */
 private void defineOkButton() {
   Button ok = (Button) findViewById(R.id.vaOK);
   int controlElementSize = calculateControlOkElementsSize();
   ok.getLayoutParams().height = controlElementSize;
   ok.getLayoutParams().width = controlElementSize;
   ok.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           onBackPressed();
         }
       });
 }
 private void centerButton(Button button) {
   LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button.getLayoutParams();
   params.gravity = Gravity.CENTER_HORIZONTAL;
   params.weight = 0.5f;
   button.setLayoutParams(params);
   View leftSpacer = mWindow.findViewById(R.id.leftSpacer);
   if (leftSpacer != null) {
     leftSpacer.setVisibility(View.VISIBLE);
   }
   View rightSpacer = mWindow.findViewById(R.id.rightSpacer);
   if (rightSpacer != null) {
     rightSpacer.setVisibility(View.VISIBLE);
   }
 }
 @Override
 public void onSizeChanged(int width, int height) {
   // this is called whenever size of the BlinkIDView changes
   // we will use this callback in this example to adjust the margins of buttons
   int horizontalMargin = (int) (width * 0.07);
   int verticalMargin = (int) (height * 0.07);
   // set margins for back button
   FrameLayout.LayoutParams backButtonParams =
       (FrameLayout.LayoutParams) mBackButton.getLayoutParams();
   if (backButtonParams.leftMargin != horizontalMargin
       && backButtonParams.topMargin != verticalMargin) {
     backButtonParams.setMargins(
         horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
     mBackButton.setLayoutParams(backButtonParams);
   }
   // set margins for torch button
   FrameLayout.LayoutParams torchButtonParams =
       (FrameLayout.LayoutParams) mTorchButton.getLayoutParams();
   if (torchButtonParams.leftMargin != horizontalMargin
       && torchButtonParams.topMargin != verticalMargin) {
     torchButtonParams.setMargins(
         horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
     mTorchButton.setLayoutParams(torchButtonParams);
   }
   // set margins for text view
   FrameLayout.LayoutParams statusViewParams =
       (FrameLayout.LayoutParams) mStatusTextView.getLayoutParams();
   if (statusViewParams.bottomMargin != verticalMargin) {
     if (android.os.Build.VERSION.SDK_INT <= 7) {
       statusViewParams.setMargins(0, verticalMargin, 0, verticalMargin);
     } else {
       statusViewParams.setMargins(
           horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
     }
     mStatusTextView.setLayoutParams(statusViewParams);
   }
 }
  /**
   * The button group has different layout properties (margins, gravity, etc) when placed on the
   * main row as opposed to on a separate row. This updates the layout properties of the button
   * group to prepare for placing it on either the main row or a separate row.
   *
   * @param row One of ROW_MAIN or ROW_OTHER.
   */
  private void updateButtonGroupForRow(int row) {
    int startEndMargin = row == ROW_MAIN ? mMargin : 0;
    mButtonGroup.setHorizontalMode(mMargin / 2, startEndMargin, startEndMargin);
    mButtonGroup.gravity = Gravity.END;

    if (row == ROW_OTHER && mButtonGroup.views.length >= 2) {
      int extraWidth = availableWidth() - getWidthWithMargins(mButtonGroup);
      if (extraWidth < 0) {
        // Group is too wide to fit on a single row, so stack the group items vertically.
        mButtonGroup.setVerticalMode(mMargin / 2, 0);
        mButtonGroup.gravity = Gravity.FILL_HORIZONTAL;
      } else if (mTertiaryButton != null) {
        // Align tertiary or custom button at the start and the other buttons at the end.
        ((LayoutParams) mTertiaryButton.getLayoutParams()).endMargin += extraWidth;
      }
    }
    if (row == ROW_MAIN && mCustomButton != null) {
      // Increase spacing between custom button and primary button.
      ((LayoutParams) mCustomButton.getLayoutParams()).endMargin = mMargin;
    }
  }
示例#8
0
  public void resizeMe(int big) {
    double resizeButton;
    double resizeText;
    boolean myCondition;
    boolean isSizeChanged = false;
    if (big == 0) {
      resizeButton = 1.25;
      resizeText = 0.175;
      // resizeText = 1;
      myCondition = true;
    } else {
      resizeButton = 0.8;
      resizeText = 0.175;
      myCondition = false;
    }

    for (int x = 0; x < minesweeperGame.getRows(); ++x) {
      for (int y = 0; y < minesweeperGame.getCols(); ++y) {
        Button change = minesweeperGame.board[x][y];
        ViewGroup.LayoutParams params = change.getLayoutParams();
        if (params != null) {
          if (((change.getHeight() * resizeButton > 50.0) && !myCondition)
              || ((change.getHeight() * resizeButton < 100.0) && myCondition)) {
            params.height = (int) (change.getHeight() * resizeButton);
            params.width = (int) (change.getWidth() * resizeButton);
            change.setLayoutParams(params);
            change.setTextSize((float) (params.height * resizeText));
            isSizeChanged = true;
          }
        }
      }
    }

    if (isSizeChanged) {
      minesweeperGame.createNewImages();
    }
  }
    /**
     * Fits as many menu items in the main panel and returns a list of the menu items that were not
     * fit in.
     *
     * @return The menu items that are not included in this main panel.
     */
    public List<MenuItem> layoutMenuItems(List<MenuItem> menuItems, int suggestedWidth) {
      final int toolbarWidth =
          getAdjustedToolbarWidth(mContext, suggestedWidth)
              // Reserve space for the "open overflow" button.
              - getEstimatedOpenOverflowButtonWidth(mContext);

      int availableWidth = toolbarWidth;
      final LinkedList<MenuItem> remainingMenuItems = new LinkedList<MenuItem>(menuItems);

      mContentView.removeAllViews();

      boolean isFirstItem = true;
      while (!remainingMenuItems.isEmpty()) {
        final MenuItem menuItem = remainingMenuItems.peek();
        Button menuItemButton = createMenuItemButton(mContext, menuItem);

        // Adding additional start padding for the first button to even out button spacing.
        if (isFirstItem) {
          menuItemButton.setPaddingRelative(
              (int) (1.5 * menuItemButton.getPaddingStart()),
              menuItemButton.getPaddingTop(),
              menuItemButton.getPaddingEnd(),
              menuItemButton.getPaddingBottom());
          isFirstItem = false;
        }

        // Adding additional end padding for the last button to even out button spacing.
        if (remainingMenuItems.size() == 1) {
          menuItemButton.setPaddingRelative(
              menuItemButton.getPaddingStart(),
              menuItemButton.getPaddingTop(),
              (int) (1.5 * menuItemButton.getPaddingEnd()),
              menuItemButton.getPaddingBottom());
        }

        menuItemButton.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
        int menuItemButtonWidth = Math.min(menuItemButton.getMeasuredWidth(), toolbarWidth);
        if (menuItemButtonWidth <= availableWidth) {
          menuItemButton.setTag(menuItem);
          menuItemButton.setOnClickListener(mMenuItemButtonOnClickListener);
          mContentView.addView(menuItemButton);
          ViewGroup.LayoutParams params = menuItemButton.getLayoutParams();
          params.width = menuItemButtonWidth;
          menuItemButton.setLayoutParams(params);
          availableWidth -= menuItemButtonWidth;
          remainingMenuItems.pop();
        } else {
          if (mOpenOverflowButton == null) {
            mOpenOverflowButton =
                (ImageButton)
                    LayoutInflater.from(mContext)
                        .inflate(R.layout.floating_popup_open_overflow_button, null);
            mOpenOverflowButton.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    if (mOpenOverflowButton != null) {
                      mOpenOverflow.run();
                    }
                  }
                });
          }
          mContentView.addView(mOpenOverflowButton);
          break;
        }
      }
      return remainingMenuItems;
    }
  public static void overrideStyle(Context context, AlertDialog dialog, boolean light) {
    // resources
    int resourceDialogTitleText =
        light ? R.color.dialog_title_text_light : R.color.dialog_title_text_dark;
    int resourceDialogTitleDivider =
        light ? R.color.dialog_title_divider_light : R.color.dialog_title_divider_dark;
    int resourceDialogMessageText =
        light ? R.color.dialog_message_text_light : R.color.dialog_message_text_dark;
    int resourceDialogButtonText =
        light ? R.color.dialog_button_text_light : R.color.dialog_button_text_dark;
    int resourceSelectorDialogButtonBg =
        light
            ? R.drawable.selector_dialog_button_bg_light
            : R.drawable.selector_dialog_button_bg_dark;
    int resourceShapeDialogDividerHorizontal =
        light
            ? R.drawable.shape_dialog_divider_horizontal_light
            : R.drawable.shape_dialog_divider_horizontal_dark;
    int resourceShapeDialogDividerVertical =
        light
            ? R.drawable.shape_dialog_divider_vertical_light
            : R.drawable.shape_dialog_divider_vertical_dark;

    // ids
    // final int parentPanel = context.getResources().getIdentifier("parentPanel", "id", "android");
    final int topPanel = context.getResources().getIdentifier("topPanel", "id", "android");
    final int contentPanel = context.getResources().getIdentifier("contentPanel", "id", "android");
    final int customPanel = context.getResources().getIdentifier("customPanel", "id", "android");
    final int buttonPanel = context.getResources().getIdentifier("buttonPanel", "id", "android");

    final int alertTitle = context.getResources().getIdentifier("alertTitle", "id", "android");
    final int titleDivider = context.getResources().getIdentifier("titleDivider", "id", "android");
    final int message = context.getResources().getIdentifier("message", "id", "android");
    final int selectDialogListview =
        context.getResources().getIdentifier("select_dialog_listview", "id", "android");
    final int button1 = context.getResources().getIdentifier("button1", "id", "android");
    final int button2 = context.getResources().getIdentifier("button2", "id", "android");
    final int button3 = context.getResources().getIdentifier("button3", "id", "android");

    // references
    // LinearLayout parentPanelView = (LinearLayout) dialog.findViewById(parentPanel);
    LinearLayout topPanelView = (LinearLayout) dialog.findViewById(topPanel);
    LinearLayout contentPanelView = (LinearLayout) dialog.findViewById(contentPanel);
    FrameLayout customPanelView = (FrameLayout) dialog.findViewById(customPanel);
    LinearLayout buttonPanelView = (LinearLayout) dialog.findViewById(buttonPanel);
    LinearLayout buttonPanelChildView = (LinearLayout) buttonPanelView.getChildAt(0);

    TextView alertTitleView = (TextView) dialog.findViewById(alertTitle);
    View titleDividerView = (View) dialog.findViewById(titleDivider);
    TextView messageView = (TextView) dialog.findViewById(message);
    ListView selectDialogListviewView = (ListView) dialog.findViewById(selectDialogListview);
    Button button1View = (Button) dialog.findViewById(button1);
    Button button2View = (Button) dialog.findViewById(button2);
    Button button3View = (Button) dialog.findViewById(button3);

    // dialog background
    if (topPanelView != null
        && contentPanelView != null
        && customPanelView != null
        && buttonPanelView != null) {
      setBackground(topPanelView, contentPanelView, customPanelView, buttonPanelView, light);
    }

    // dialog style
    if (alertTitleView != null)
      alertTitleView.setTextColor(context.getResources().getColor(resourceDialogTitleText));
    if (titleDividerView != null) {
      titleDividerView.setBackgroundColor(
          context.getResources().getColor(resourceDialogTitleDivider));
      ViewGroup.LayoutParams params = titleDividerView.getLayoutParams();
      params.height =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 2, context.getResources().getDisplayMetrics());
    }
    if (messageView != null)
      messageView.setTextColor(context.getResources().getColor(resourceDialogMessageText));
    if (selectDialogListviewView != null) {
      selectDialogListviewView.setSelector(resourceSelectorDialogButtonBg);
      selectDialogListviewView.setDivider(
          context.getResources().getDrawable(resourceShapeDialogDividerHorizontal));
    }
    if (button1View != null) {
      button1View.setTextColor(context.getResources().getColor(resourceDialogButtonText));
      button1View.setBackgroundResource(resourceSelectorDialogButtonBg);
      button1View.setTypeface(Typeface.DEFAULT);

      LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button1View.getLayoutParams();
      params.setMargins(0, 0, 0, 0);
      button1View.setLayoutParams(params);
    }
    if (button2View != null) {
      button2View.setTextColor(context.getResources().getColor(resourceDialogButtonText));
      button2View.setBackgroundResource(resourceSelectorDialogButtonBg);
      button2View.setTypeface(Typeface.DEFAULT);

      LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button2View.getLayoutParams();
      params.setMargins(0, 0, 0, 0);
      button2View.setLayoutParams(params);
    }
    if (button3View != null) {
      button3View.setTextColor(context.getResources().getColor(resourceDialogButtonText));
      button3View.setBackgroundResource(resourceSelectorDialogButtonBg);
      button3View.setTypeface(Typeface.DEFAULT);

      LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button3View.getLayoutParams();
      params.setMargins(0, 0, 0, 0);
      button3View.setLayoutParams(params);
    }
    if (buttonPanelView != null) {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        buttonPanelView.setShowDividers(LinearLayout.SHOW_DIVIDER_BEGINNING);
        buttonPanelView.setDividerDrawable(
            context.getResources().getDrawable(resourceShapeDialogDividerHorizontal));
      }
    }
    if (buttonPanelChildView != null) {
      buttonPanelChildView.setPadding(0, 0, 0, 0);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        buttonPanelChildView.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        buttonPanelChildView.setDividerDrawable(
            context.getResources().getDrawable(resourceShapeDialogDividerVertical));
      }
    }
  }
示例#11
0
  /**
   * Novo m�todo para criar o painel din�mico para os bot�es de selec��o da turma
   *
   * @author Thiago
   */
  @SuppressLint("NewApi")
  private void makeTabela() {

    // Cria o objecto da base de dados
    LetrinhasDB db = new LetrinhasDB(this);
    // ************* Mudar este select de all para por ID de turma
    // (ALEXANDRE!!)
    List<Estudante> alunos = db.getAllStudentsByTurmaId(idTurma);
    // *******************************************************************************
    int nAlunos = alunos.size();
    int[] idAluno = new int[nAlunos];
    String nomeAluno[] = new String[nAlunos];
    String fotoAluno[] = new String[nAlunos];

    // preenche os arrays s� com a informa��o necess�ria
    for (int i = 0; i < nAlunos; i++) {
      idAluno[i] = alunos.get(i).getIdEstudante();
      nomeAluno[i] = alunos.get(i).getNome();
      fotoAluno[i] = alunos.get(i).getNomefoto();
    }

    for (Estudante cn : alunos) {
      String storage =
          cn.getNome()
              + ","
              + cn.getIdEstudante()
              + ","
              + cn.getNomefoto()
              + ","
              + cn.getEstado()
              + ","
              + cn.getIdTurma();
      Log.d("letrinhas-Alunos", storage.toString());
    }

    /** Scroll view com uma tabela de 4 colunas(max) */
    // tabela a editar
    TableLayout tabela = (TableLayout) findViewById(R.id.tblEscolheAl);
    // linha da tabela a editar
    TableRow linha = (TableRow) findViewById(R.id.escAllinha01);
    // 1� bot�o
    Button bt = (Button) findViewById(R.id.AlBtOriginal);
    bt.setText("teste alunos");

    // Contador de controlo
    int cont = 0;
    // criar o n� de linhas a dividir por 4 colunas
    for (int i = 0; i < nAlunos / 4; i++) {
      // nova linha da tabela
      TableRow linha1 = new TableRow(getBaseContext());
      // Copiar os parametros da 1� linha
      linha1.setLayoutParams(linha.getLayoutParams());
      // criar os 4 bot�es da linha
      for (int j = 0; j < 4; j++) {

        // **********************************
        // Nome, id e foto do aluno

        final String alumni = nomeAluno[cont];
        final int idAL = idAluno[cont];
        final String alunFot = fotoAluno[cont];
        // ***********************************

        // novo bot�o
        Button bt1 = new Button(bt.getContext());
        // copiar os parametros do bot�o original
        bt1.setLayoutParams(bt.getLayoutParams());

        // se o aluno tiver foto, vou busca-la
        if (fotoAluno[cont] != null) {
          String imageInSD =
              Environment.getExternalStorageDirectory().getAbsolutePath()
                  + "/School-Data/Students/"
                  + fotoAluno[cont];
          Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
          ImageView imageView = new ImageView(this);

          // ajustar o tamanho da imagem
          imageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 210, 200, false));
          // enviar para o bot�o
          bt1.setCompoundDrawablesWithIntrinsicBounds(null, imageView.getDrawable(), null, null);
        } else {
          // sen�o copia a imagem do bot�o original
          bt1.setCompoundDrawables(null, bt.getCompoundDrawablesRelative()[1], null, null);
        }

        // addicionar o nome
        bt1.setText(nomeAluno[cont]);
        // Defenir o que faz o bot�o ao clicar
        bt1.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                // Entrar na activity
                Bundle wrap = new Bundle();
                wrap.putString("Escola", Escola);
                wrap.putInt("Escola_ID", idEscola);
                wrap.putString("Professor", Professor);
                wrap.putInt("Professor_ID", idProfessor);
                wrap.putString("Foto_professor", FotoProf);
                wrap.putString("Turma", Turma);
                wrap.putInt("Turma_ID", idTurma);
                wrap.putString("Aluno", alumni);
                wrap.putInt("Aluno_ID", idAL);
                wrap.putString("Foto_Aluno", alunFot);

                Intent it = new Intent(getApplicationContext(), EscModo.class);
                it.putExtras(wrap);

                startActivity(it);
              }
            });
        // inserir o bot�o na linha
        linha1.addView(bt1);
        // incrementar o contador de controlo
        cont++;
      }
      // inserir a linha criada
      tabela.addView(linha1);
    }

    // resto
    if (nAlunos % 4 != 0) {
      TableRow linha1 = new TableRow(getBaseContext());
      linha1.setLayoutParams(linha.getLayoutParams());
      for (int j = 0; j < nAlunos % 4; j++) {

        // **********************************
        // Nome, id e foto do aluno

        final String alumni = nomeAluno[cont];
        final int idAL = idAluno[cont];
        final String alunFot = fotoAluno[cont];
        // ***********************************

        // novo bot�o
        Button bt1 = new Button(bt.getContext());
        // copiar os parametros do bot�o original
        bt1.setLayoutParams(bt.getLayoutParams());

        // se o aluno tiver foto, vou busca-la
        if (fotoAluno[cont] != null) {
          String imageInSD =
              Environment.getExternalStorageDirectory().getAbsolutePath()
                  + "/School-Data/Students/"
                  + fotoAluno[cont];
          Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
          ImageView imageView = new ImageView(this);

          // ajustar o tamanho da imagem
          imageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 240, 240, false));
          // enviar para o bot�o
          bt1.setCompoundDrawablesWithIntrinsicBounds(null, imageView.getDrawable(), null, null);
        } else {
          // sen�o copia a imagem do bot�o original
          bt1.setCompoundDrawables(null, bt.getCompoundDrawablesRelative()[1], null, null);
        }

        // addicionar o nome
        bt1.setText(nomeAluno[cont]);
        // Defenir o que faz o bot�o ao clicar
        bt1.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                // Entrar na activity
                Bundle wrap = new Bundle();
                wrap.putString("Escola", Escola);
                wrap.putInt("Escola_ID", idEscola);
                wrap.putString("Professor", Professor);
                wrap.putInt("Professor_ID", idProfessor);
                wrap.putString("Foto_professor", FotoProf);
                wrap.putString("Turma", Turma);
                wrap.putInt("Turma_ID", idTurma);
                wrap.putString("Aluno", alumni);
                wrap.putInt("Aluno_ID", idAL);
                wrap.putString("Foto_Aluno", alunFot);

                Intent it = new Intent(getApplicationContext(), EscModo.class);
                it.putExtras(wrap);

                startActivity(it);
              }
            });
        // inserir o bot�o na linha
        linha1.addView(bt1);
        // incrementar o contador de controlo
        cont++;
      }
      // inserir a linha criada
      tabela.addView(linha1);
    }

    // por fim escondo a 1� linha
    tabela.removeView(linha);
  }
示例#12
0
  // test button exists
  public void test020201() {
    /*
     * Test for US02.01.01 Basic Flow 1
     */
    // test button exists
    assertNotNull(activity.findViewById(ca.ualberta.CMPUT301W15T06.R.id.claimantButton));
    assertNotNull(activity.findViewById(ca.ualberta.CMPUT301W15T06.R.id.approverButton));
    assertNotNull(activity.findViewById(ca.ualberta.CMPUT301W15T06.R.id.userButton));

    // test "Approver" button layout
    final View decorView = activity.getWindow().getDecorView();
    ViewAsserts.assertOnScreen(decorView, ApproverButton);
    final ViewGroup.LayoutParams layoutParams = ApproverButton.getLayoutParams();
    assertNotNull(layoutParams);
    assertEquals(layoutParams.width, WindowManager.LayoutParams.WRAP_CONTENT);
    assertEquals(layoutParams.height, WindowManager.LayoutParams.WRAP_CONTENT);
    Button view = (Button) activity.findViewById(ca.ualberta.CMPUT301W15T06.R.id.approverButton);
    assertEquals("Incorrect label of the button", "Approver", view.getText());

    // test "Claimant" button layout
    ViewAsserts.assertOnScreen(decorView, ClaimantButton);
    final ViewGroup.LayoutParams layoutParams1 = ClaimantButton.getLayoutParams();
    assertNotNull(layoutParams1);
    assertEquals(layoutParams1.width, WindowManager.LayoutParams.WRAP_CONTENT);
    assertEquals(layoutParams1.height, WindowManager.LayoutParams.WRAP_CONTENT);
    Button view1 = (Button) activity.findViewById(ca.ualberta.CMPUT301W15T06.R.id.claimantButton);
    assertEquals("Incorrect label of the button", "Claimant", view1.getText());

    // test "Change User" button layout
    ViewAsserts.assertOnScreen(decorView, ClaimantButton);
    final ViewGroup.LayoutParams layoutParams2 = UserButton.getLayoutParams();
    assertNotNull(layoutParams1);
    assertEquals(layoutParams2.width, WindowManager.LayoutParams.WRAP_CONTENT);
    assertEquals(layoutParams2.height, WindowManager.LayoutParams.WRAP_CONTENT);
    Button view2 = (Button) activity.findViewById(ca.ualberta.CMPUT301W15T06.R.id.userButton);
    assertEquals("Incorrect label of the button", "Change User", view2.getText());

    /*
     * Test for US02.02.01 Basic Flow 2
     */
    // User click "Change User"

    activity.runOnUiThread(
        new Runnable() {

          @Override
          public void run() {
            // open the dialog
            UserButton.performClick();
          }
        });

    /*
     * Test for US 02.02.01 Basic Flow 3
     */
    // click "Claimant" button and create next activity
    ActivityMonitor activityMonitor =
        getInstrumentation().addMonitor(ClaimantClaimListActivity.class.getName(), null, false);
    // open current activity
    MainActivity myActivity = getActivity();
    final Button button =
        (Button) myActivity.findViewById(ca.ualberta.CMPUT301W15T06.R.id.claimantButton);

    myActivity.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            // click button and open next activity.
            button.performClick();
          }
        });

    ClaimantClaimListActivity nextActivity =
        (ClaimantClaimListActivity)
            getInstrumentation().waitForMonitorWithTimeout(activityMonitor, 10000);
    // next activity is opened and captured.
    assertNotNull(nextActivity);

    /*
     * Test for US 02.02.01 Basic Flow 4
     */
    // view which is expected to be present on the screen
    final View decorView1 = nextActivity.getWindow().getDecorView();
    listView = (ListView) nextActivity.findViewById(ca.ualberta.CMPUT301W15T06.R.id.claimListView);
    // check if it is on screen
    ViewAsserts.assertOnScreen(decorView1, listView);
    // check whether the Button object's width and height attributes match
    // the expected values
    final ViewGroup.LayoutParams layoutParams11 = listView.getLayoutParams();
    /* assertNotNull(layoutParams); */
    assertEquals(layoutParams11.width, WindowManager.LayoutParams.MATCH_PARENT);
    assertEquals(layoutParams11.height, WindowManager.LayoutParams.WRAP_CONTENT);

    nextActivity.finish();
    activity.finish();
  }
 private void centerButton(Button button) {
   LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button.getLayoutParams();
   params.gravity = Gravity.CENTER_HORIZONTAL;
   params.weight = 0.5f;
   button.setLayoutParams(params);
 }
示例#14
0
  @SuppressWarnings("deprecation")
  private void initUIComponents() {
    // 设置Fragment
    addFragment(ResFinder.getId("umeng_comm_user_info_fragment_container"), mPostedFragment);

    // 选中的某个tab时的文字颜色
    mSelectedColor = ResFinder.getColor("umeng_comm_text_topic_light_color");

    // 初始化feed、好友、粉丝、back、设置的listener
    findViewById(ResFinder.getId("umeng_comm_posted_layout")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_follow_user_layout")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_my_fans_layout")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_setting_back")).setOnClickListener(this);

    // 举报用户的Dialog
    mReportDialog = new UserReportDialog(this);
    mReportDialog.setTargetUid(mUser.id);

    Button settingButton = (Button) findViewById(ResFinder.getId("umeng_comm_save_bt"));
    settingButton.setBackgroundDrawable(ResFinder.getDrawable("umeng_comm_more"));
    RelativeLayout.LayoutParams params =
        (RelativeLayout.LayoutParams) settingButton.getLayoutParams();
    params.width = DeviceUtils.dp2px(this, 20);
    params.height = DeviceUtils.dp2px(this, 20);
    params.rightMargin = DeviceUtils.dp2px(getApplicationContext(), 10);
    settingButton.setLayoutParams(params);
    settingButton.setOnClickListener(
        new LoginOnViewClickListener() {

          @Override
          protected void doAfterLogin(View v) {
            mReportDialog.show();
          }
        });
    // 如果是用户自己,则不显示设置菜单按钮【目前菜单只有举报功能,即自己不能举报自己】
    if (mUser.id.equals(CommConfig.getConfig().loginedUser.id)
        || mUser.permisson == Permisson.SUPPER_ADMIN) {
      settingButton.setVisibility(View.GONE);
    }

    TextView titleTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_setting_title"));
    titleTextView.setText(ResFinder.getString("umeng_comm_user_center"));
    //
    mPostedTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_posted_msg_tv"));
    mPostedTv.setTextColor(mSelectedColor);

    //
    mPostedCountTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_posted_count_tv"));
    mPostedCountTv.setTextColor(mSelectedColor);

    mFollowedUserTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_followed_user_tv"));
    mFollowedUserCountTv =
        mViewFinder.findViewById(ResFinder.getId("umeng_comm_follow_user_count_tv"));

    mFansTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_my_fans_tv"));
    mFansCountTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_fans_count_tv"));
    // 昵称
    mUserNameTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_name_tv"));
    mUserNameTv.setText(mUser.name);

    mHeaderImageView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_header"));

    ImgDisplayOption option = ImgDisplayOption.getOptionByGender(mUser.gender);
    mHeaderImageView.setImageUrl(mUser.iconUrl, option);

    // 用户性别
    mGenderImageView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_gender"));

    // 关注按钮
    mFollowToggleButton = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_follow"));
    mFollowToggleButton.setOnClickListener(
        new Listeners.LoginOnViewClickListener() {

          @Override
          protected void doAfterLogin(View v) {
            mFollowToggleButton.setClickable(false);
            // true为选中状态为已关注,此时显示文本为“取消关注”;false代表未关注,此时显示文本为“关注”
            if (mFollowToggleButton.isChecked()) {
              mPresenter.followUser(mResultListener);
            } else {
              mPresenter.cancelFollowUser(mResultListener);
            }
          }
        });

    mAlbumTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_albums_tv"));
    mAlbumTextView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            jumpToActivityWithUid(AlbumActivity.class);
          }
        });
    mTopicTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_topic_tv"));
    mTopicTextView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            jumpToActivityWithUid(FollowedTopicActivity.class);
          }
        });

    // 用户自己(在未登录的情况下,点击设置跳转到登录,此时传递进来的uid是空的情况),隐藏关注按钮,显示设置按钮
    // // 如果是超级管理员且已经关注,则隐藏取消关注按钮
    if (isHideFollowStatus()) {
      mFollowToggleButton.setVisibility(View.GONE);
    }
    initCommentView();
  }