public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   textView = new TextView(this);
   textView.setText("Toca y arrastra (solo un dedo)");
   textView.setOnTouchListener(this);
   setContentView(textView);
 }
  private void inflateView(int index) {
    // 动态创建新闻视图,并赋值
    View newsBodyLayout = mNewsBodyInflater.inflate(R.layout.news_body, null);
    // 获取点击新闻基本信息
    HashMap<String, Object> hashMap = mNewsData.get(mPosition);
    // 新闻标题
    TextView newsTitle = (TextView) newsBodyLayout.findViewById(R.id.news_body_title);
    newsTitle.setText(hashMap.get("newslist_item_title").toString());
    // 发布时间和出处
    TextView newsPtimeAndSource =
        (TextView) newsBodyLayout.findViewById(R.id.news_body_ptime_source);
    newsPtimeAndSource.setText(
        hashMap.get("newslist_item_ptime").toString()
            + "    "
            + hashMap.get("newslist_item_source").toString());
    // 新闻编号
    mNid = (Integer) hashMap.get("nid");
    // 新闻回复数
    mNewsdetailsTitlebarComm.setText(hashMap.get("newslist_item_comments") + "跟帖");

    // 把新闻视图添加到Flipper中
    mNewsBodyFlipper = (ViewFlipper) findViewById(R.id.news_body_flipper);
    mNewsBodyFlipper.addView(newsBodyLayout, index);

    // 给新闻Body添加触摸事件
    mNewsDetails = (TextView) newsBodyLayout.findViewById(R.id.news_body_details);
    mNewsDetails.setOnTouchListener(newsBodyOnTouchListener);

    // 启动线程
    new UpdateNewsThread().start();
  }
示例#3
0
  private void removeListeners() {
    closeButton.setOnClickListener(null);

    changeZoomFactorButton.setOnTouchListener(null);

    setOnTouchListener(null);
  }
示例#4
0
 private void addText(TableRow r, String s, boolean isChecked, boolean isRight, Long sessionId) {
   TextView c = new TextView(this);
   c.setText(s);
   if (isChecked) {
     c.setTypeface(null, Typeface.BOLD);
     c.setTextColor(Color.WHITE);
   }
   if (isRight) {
     c.setGravity(Gravity.RIGHT);
   }
   controls.put(c, sessionId);
   c.setOnTouchListener(
       new OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           if (event.getAction() == MotionEvent.ACTION_DOWN) {
             Long sessionId = controls.get(v);
             if (sessionId != null) {
               Uri uri = ContentUris.withAppendedId(PuzzleDb.Sessions.CONTENT_URI, sessionId);
               setResult(RESULT_OK, new Intent().setData(uri));
               finish();
               return true;
             }
           }
           return false;
         }
       });
   r.addView(c);
 }
示例#5
0
  private void setListeners() {
    closeButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            stopZoomDisplay(true);
          }
        });

    changeZoomFactorButton.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {

            if (event.getAction() == MotionEvent.ACTION_UP) {
              if (event.getX()
                  >= (changeZoomFactorButton.getLeft() + changeZoomFactorButton.getWidth() / 2)) {
                changeZoomFactor(true);
              } else {
                changeZoomFactor(false);
              }
            }
            return true;
          }
        });

    setOnTouchListener(touchListener);
  }
示例#6
0
    void show(int offx, int offy) {
      int textHeight = chooseSize(window, inputView, text, textView);
      offy -= textView.getPaddingTop() + textHeight;
      if (inputView.getVisibility() == View.VISIBLE
          && inputView.getWindowVisibility() == View.VISIBLE) {
        try {
          if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) offy -= window.getHeight();
          if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) offx -= window.getWidth();
          textView.setOnTouchListener(
              new View.OnTouchListener() {
                public boolean onTouch(View view, MotionEvent me) {

                  boolean ret = !mEnableKeyTouch;
                  switch (me.getAction()) {
                    case MotionEvent.ACTION_UP:
                      if (mBubbleIndex >= mBubbles.size()) {
                        mInputView.setOnTouchListener(null);
                      } else {
                        TutorialJAJP.this.next();
                      }
                      break;
                    default:
                      break;
                  }
                  return ret;
                }
              });
          window.showAtLocation(inputView, Gravity.NO_GRAVITY, x + offx, y + offy);
        } catch (Exception e) {
        }
      }
    }
  public void showTags() {
    clearTags();

    if (!mShowTags) return;
    if (videoTags == null) return;

    for (int i = 0; i < videoTags.size(); i++) {
      VideoTag videoTag = videoTags.get(i);

      TextView textView;
      if (i < tagViews.size()) {
        textView = (TextView) tagViews.get(i);
      } else {
        textView = new TextView(getContext());
        textView.setOnTouchListener(listener);
        textView.setTag(VIDEO_TAG_VIEW_TAG);
        tagViews.add(textView);
      }
      textView.setText(videoTag.getText());
      // position
      int left = (int) (videoTag.getX() * getSize());
      int top = (int) (videoTag.getY() * getSize());

      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.setMargins(left, top, 0, 0);
      textView.setLayoutParams(params);
      addView(textView);
    }
  }
示例#8
0
  @Override
  protected void setListener() {
    super.setListener();
    deleteusername_btn.setOnClickListener(this);
    login_btn.setOnClickListener(this);
    qqlogin_btn.setOnClickListener(this);
    sinalogin_btn.setOnClickListener(this);
    left_tv.setOnClickListener(this);
    forgetpwd_tv.setOnClickListener(this);
    regist_tv.setOnClickListener(this);
    right_tv.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                right_tv.setTextColor(Color.BLACK);
                break;
              case MotionEvent.ACTION_UP:
                right_tv.setTextColor(Color.WHITE);
                goByIntent(MoreActivity.class, false);
                break;
            }
            return true;
          }
        });
  }
示例#9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    // Configuration ActionBar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle("Set up");
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(false);

    // Bound control
    final TextView textViewUpdateMusicFile = (TextView) findViewById(R.id.textViewUpdateMusicFile);
    Switch switchSaveMusicStatus = (Switch) findViewById(R.id.switchSaveMusicStatus);
    switchSaveMusicStatus.setChecked(
        getSharedPreferences("settings", 0).getBoolean(CodeUtil.EXIT_MUSIC_STATUS, false));
    // Setting Listener
    textViewUpdateMusicFile.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN
                || event.getAction() == MotionEvent.ACTION_MOVE) {
              textViewUpdateMusicFile.setBackgroundColor(0x25FFFFFF);
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
              textViewUpdateMusicFile.setBackgroundColor(0x00FFFFFF);
            }
            return false;
          }
        });
    textViewUpdateMusicFile.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            new ThreadUtil.DatabaseAsyncTask(Settings.this, true).execute(FileUtil.getRootPath());
          }
        });
    switchSaveMusicStatus.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked) {
            new Runnable() {
              @Override
              public void run() {
                getSharedPreferences("settings", 0)
                    .edit()
                    .putBoolean(CodeUtil.EXIT_MUSIC_STATUS, isChecked)
                    .commit();
                if (isChecked) {
                  SharedPreferences.Editor editor = getSharedPreferences("data", 0).edit();
                  editor.putString("sql", MusicService.sql);
                  editor.putInt("position", MusicService.position);
                  editor.commit();
                }
              }
            }.run();
          }
        });
  }
 public DebateViewHolder(View itemView) {
   super(itemView);
   ButterKnife.inject(this, itemView);
   itemView.setOnClickListener(
       v -> {
         if (onItemClickListener != null) {
           onItemClickListener.onItemClick(debateViewModel);
         }
       });
   content.setOnTouchListener(new ClickableSpanTouchListener());
 }
  public void showSnoozeDialog() {
    final Dialog bteldialog = new Dialog(this);
    bteldialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    bteldialog.setCanceledOnTouchOutside(true);
    bteldialog.setContentView(R.layout.snooze_settings);
    TextView btn = ((TextView) bteldialog.findViewById(R.id.id_set_btn));
    final Spinner spinner = (Spinner) bteldialog.findViewById(R.id.spinner);
    sharedPrefManager.isSnoozeExpired(sharedPrefManager.getUserDomain());
    spinner.setSelection(sharedPrefManager.getSnoozeIndex(sharedPrefManager.getUserDomain()));
    btn.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            bteldialog.cancel();
            sharedPrefManager.setSnoozeIndex(
                sharedPrefManager.getUserDomain(), spinner.getSelectedItemPosition());
            sharedPrefManager.setSnoozeStartTime(
                sharedPrefManager.getUserDomain(), System.currentTimeMillis());
            muteSettingText.setVisibility(View.VISIBLE);
            muteSettingText.setText(String.valueOf(spinner.getSelectedItem()));
            //                Toast.makeText(MoreScreen.this,
            // String.valueOf(spinner.getSelectedItem()), Toast.LENGTH_SHORT).show();
            return false;
          }
        });
    TextView cancelBtn = ((TextView) bteldialog.findViewById(R.id.id_cancel));
    cancelBtn.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            bteldialog.cancel();
            return false;
          }
        });
    if (!bteldialog.isShowing()) bteldialog.show();
  }
示例#12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings);

    _imgSourceLang = (ImageView) findViewById(R.id.ImageSourceLang);
    _imgDestLang = (ImageView) findViewById(R.id.ImageDestLang);
    _txtSourceLang = (TextView) findViewById(R.id.TextSourceLang);
    _txtDestLang = (TextView) findViewById(R.id.TextDestLang);
    _txtEmail = (TextView) findViewById(R.id.txtEmail);
    _txtSms = (TextView) findViewById(R.id.txtSms);
    _edSendTo = (EditText) findViewById(R.id.EditEmail);
    _edNumbMob = (EditText) findViewById(R.id.EditNumMob);
    _togAskSend = (ToggleButton) findViewById(R.id.ToggleAskSend);
    _imgAccept = (ImageView) findViewById(R.id.ImageAccept);

    _imgDestLang.setOnTouchListener(this);
    _imgSourceLang.setOnTouchListener(this);
    _imgAccept.setOnClickListener(this);
    _imgAccept.setOnTouchListener(this);
    _imgAccept.setOnFocusChangeListener(this);
    _togAskSend.setOnClickListener(this);
    _txtSms.setOnClickListener(this);
    _txtSms.setOnTouchListener(this);

    Resources res = getResources();
    SharedPreferences settings = getSharedPreferences(res.getString(R.string.setting_file), 0);
    _txtSourceLang.setText(settings.getString(res.getString(R.string.setting_lang_source), "IT"));
    _txtDestLang.setText(settings.getString(res.getString(R.string.setting_lang_dest), "EN"));
    _edSendTo.setText(settings.getString(res.getString(R.string.setting_lang_sendto), ""));
    _txtEmail.setOnClickListener(this);
    _txtEmail.setOnTouchListener(this);
    _edNumbMob.setText(settings.getString(res.getString(R.string.setting_lang_nummob), ""));
    _bAskSend = settings.getBoolean(res.getString(R.string.setting_lang_asksend), false);
    _togAskSend.setChecked(_bAskSend);
    _imgSourceLang.setImageResource(GetDrawableLangFromText(_txtSourceLang.getText().toString()));
    _imgDestLang.setImageResource(GetDrawableLangFromText(_txtDestLang.getText().toString()));
  }
  @SuppressWarnings("deprecation")
  public MessageOperatePopup(Context ctx, View parent) {
    View view = LayoutInflater.from(ctx).inflate(R.layout.tt_popup_list, null);
    this.context = ctx;

    // popView = (LinearLayout) view.findViewById(R.id.popup_list);

    copyBtn = (TextView) view.findViewById(R.id.copy_btn);
    copyBtn.setOnClickListener(this);
    copyBtn.setOnTouchListener(this);
    copyBtn.setPadding(0, 13, 0, 8);

    resendBtn = (TextView) view.findViewById(R.id.resend_btn);
    resendBtn.setOnClickListener(this);
    resendBtn.setOnTouchListener(this);
    resendBtn.setPadding(0, 13, 0, 8);

    speakerBtn = (TextView) view.findViewById(R.id.speaker_btn);
    speakerBtn.setOnClickListener(this);
    speakerBtn.setOnTouchListener(this);
    speakerBtn.setPadding(0, 13, 0, 8);

    mWidth =
        (int) context.getResources().getDimension(R.dimen.message_item_popup_width_single_short);
    mHeight = (int) context.getResources().getDimension(R.dimen.message_item_popup_height);

    int[] location = new int[2];
    parent.getLocationOnScreen(location);
    mParentTop = location[1];
    mPopup = new PopupWindow(view, mWidth, mHeight);
    // mPopup.setFocusable(true);
    // 设置允许在外点击消失
    mPopup.setOutsideTouchable(true);
    // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
    mPopup.setBackgroundDrawable(new BitmapDrawable());
  }
  /**
   * Setteo las acciones para un equipo, ya sea nosotros o ellos, dependiendo de los ID de los
   * resources.
   *
   * @param teamScoreId El ID del {@link TextView} donde se anotar� el score.
   * @param labelForWinnerTeamId ID del recurso string que se utilizar� cuando gane el equipo.
   * @param teamLabelId El ID del {@link TextView} con el label del equipo en el cu�l se debe hacer
   *     tap para sumar un punto.
   * @param viewsIdToDisable List of Integer containing one element for each View to disable when
   *     one team wins.
   * @since 1
   */
  private void setActions(
      int teamScoreId, int labelForWinnerTeamId, int teamLabelId, List<Integer> viewsIdToDisable) {

    List<View> viewsToDisable = new ArrayList<View>();
    for (int eachViewId : viewsIdToDisable) {
      viewsToDisable.add(findViewById(eachViewId));
    }

    TextSwitcher teamScore = (TextSwitcher) findViewById(teamScoreId);
    TrucoScoreListener listener =
        new TrucoScoreListener(teamScore, getText(labelForWinnerTeamId), viewsToDisable);
    initializeTextSwitcher(teamScore, listener);

    TextView teamLabel = (TextView) findViewById(teamLabelId);
    teamLabel.setOnTouchListener(listener);
  }
示例#15
0
  public void addTextViewResources(String src) {
    TextView textView = new TextView(EditProduct.this);

    // RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(OriImgSize,
    // OriImgSize);

    mRrootLayout.addView(textView);

    // textView.setLayoutParams(layoutParams);
    textView.setVisibility(View.VISIBLE);
    textView.setOnTouchListener(this);
    if (position_status == FRONT) ViewList.add(textView);
    else ViewListBack.add(textView);
    textView.setText(src);
    textView.setTextSize(25);
    // layoutParamsList.add(layoutParams);
  }
示例#16
0
  @Override
  protected void onResume() {
    super.onResume();
    Log.d(TAG, "ArticleActivity OnResume");
    tvFullText = (TextView) fragment.getView().findViewById(R.id.tvFragmentFullText);
    startSize = tvFullText.getTextSize();

    tvFullText.setOnTouchListener(
        new OnScaleTouchListener(ArticleActivity.this) {
          @Override
          void resize(ScaleGestureDetector detector) {
            scale *= detector.getScaleFactor();
            scale = Math.max(0.5f, Math.min(scale, 1.2f));

            tvFullText.setTextSize(startSize * scale);
          }
        });
  }
  public void showDialog(String s, String btnTxt) {
    final Dialog bteldialog = new Dialog(this);
    bteldialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    bteldialog.setCanceledOnTouchOutside(false);
    bteldialog.setContentView(R.layout.custom_dialog);
    ((TextView) bteldialog.findViewById(R.id.id_dialog_message)).setText(s);
    TextView btn = ((TextView) bteldialog.findViewById(R.id.id_ok));
    btn.setText(btnTxt);
    btn.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            bteldialog.cancel();
            return false;
          }
        });
    bteldialog.show();
  }
示例#18
0
  private void initData(View view) {
    failTips = (TextView) view.findViewById(R.id.failed_tips);
    tabiIndicator = (TabPageIndicator) view.findViewById(R.id.tab_indicator);
    viewPager = (ViewPager) view.findViewById(R.id.mv_pager);
    progressBar = (ProgressBar) view.findViewById(R.id.mv_root_progress);
    mvPagerAdapter = new MVPagerAdapter(getChildFragmentManager(), areaBeans, fragments);
    viewPager.setAdapter(mvPagerAdapter);
    tabiIndicator.setViewPager(viewPager);
    failTips.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            startLoadArea();
            failTips.setVisibility(View.GONE);
            progressBar.setVisibility(View.VISIBLE);
            return true;
          }
        });
    startLoadArea();
  }
示例#19
0
  /** Format menu items Contains some hard-coded values (laziness) */
  private void formatMenuItem(
      int id_TextView, int id_String, OnClickListener action_OnClickListener) {
    try {
      // Find the text view, may possibly fail?
      final TextView tv = (TextView) findViewById(id_TextView);
      final int AZURE = 0xFFE0EEEE;
      final int ROYAL_BLUE = 0xDD4876FF;

      // Set the font format
      tv.setTypeface(Typeface.MONOSPACE);
      tv.setTextColor(AZURE);
      tv.setShadowLayer(4f, 3, 3, ROYAL_BLUE);

      // Set highlight listener
      tv.setOnTouchListener(
          new OnTouchListener() {
            public boolean onTouch(View v, MotionEvent e) {
              if (e.getAction() == MotionEvent.ACTION_DOWN) {
                tv.setTextColor(Color.BLACK);
                tv.setShadowLayer(5f, 0, 0, AZURE);
              } else if (e.getAction() == MotionEvent.ACTION_UP) {
                tv.setTextColor(AZURE);
                tv.setShadowLayer(4f, 3, 3, ROYAL_BLUE);
              }
              return false;
            }
          });

      // Set click listener
      if (action_OnClickListener != null) {
        tv.setOnClickListener(action_OnClickListener);
      }

      // Set text string
      tv.setText(id_String);

    } catch (Exception e) {
      // TODO
    }
  }
示例#20
0
  public void populateShowTextView(String text) {

    textView = (TextView) activity.findViewById(R.id.infoRow);
    textView.setText(res.getString(R.string.infoRow) + ": " + text);
    textView.setVisibility(View.VISIBLE);

    textView.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              // do stuff here
              showModalYesNoDialogB();
            }

            Log.i("click text", "xyz");
            return false;
          }
        });
  }
示例#21
0
  void resetLayout() {
    mContent.removeAllViewsInLayout();

    if (!AppsCustomizePagedView.DISABLE_ALL_APPS) {
      // Add the Apps button
      Context context = getContext();

      LayoutInflater inflater = LayoutInflater.from(context);
      TextView allAppsButton =
          (TextView) inflater.inflate(R.layout.all_apps_button, mContent, false);
      Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
      Utilities.resizeIconDrawable(d);
      allAppsButton.setCompoundDrawables(null, d, null, null);

      allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
      if (mLauncher != null) {
        allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
      }
      allAppsButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(android.view.View v) {
              if (mLauncher != null) {
                mLauncher.onClickAllAppsButton(v);
              }
            }
          });

      // Note: We do this to ensure that the hotseat is always laid out in the orientation of
      // the hotseat in order regardless of which orientation they were added
      int x = getCellXFromOrder(mAllAppsButtonRank);
      int y = getCellYFromOrder(mAllAppsButtonRank);
      CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x, y, 1, 1);
      lp.canReorder = false;
      mContent.addViewToCellLayout(allAppsButton, -1, 0, lp, true);
    }
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder mHolder;
    if (convertView != null) {
      mHolder = (ViewHolder) convertView.getTag();
    } else {
      convertView = (SwipeLayout) mInflater.inflate(R.layout.list_item_swipe, null);
      mHolder = ViewHolder.fromValues(convertView);
      convertView.setTag(mHolder);
    }
    SwipeLayout view = (SwipeLayout) convertView;

    view.close(false, false);

    view.getFrontView()
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                Utils.showToast(mContext, "item click: " + position);
              }
            });

    view.setSwipeListener(mSwipeListener);

    mHolder.mImage.setImageResource(HEAD_IDS[position % HEAD_IDS.length]);
    mHolder.mName.setText(NAMES[position % NAMES.length]);

    mHolder.mButtonCall.setTag(position);
    mHolder.mButtonCall.setOnClickListener(onActionClick);

    mHolder.mButtonDel.setTag(position);
    mHolder.mButtonDel.setOnClickListener(onActionClick);

    TextView mUnreadView = mHolder.mReminder;
    boolean visiable = !mRemoved.contains(position);
    mUnreadView.setVisibility(visiable ? View.VISIBLE : View.GONE);

    if (visiable) {
      mUnreadView.setText(String.valueOf(position));
      mUnreadView.setTag(position);
      GooViewListener mGooListener =
          new GooViewListener(mContext, mUnreadView) {
            @Override
            public void onDisappear(PointF mDragCenter) {
              super.onDisappear(mDragCenter);

              mRemoved.add(position);
              notifyDataSetChanged();
              Utils.showToast(mContext, "Cheers! We have get rid of it!");
            }

            @Override
            public void onReset(boolean isOutOfRange) {
              super.onReset(isOutOfRange);

              notifyDataSetChanged();
              Utils.showToast(mContext, isOutOfRange ? "Are you regret?" : "Try again!");
            }
          };
      mUnreadView.setOnTouchListener(mGooListener);
    }
    ViewHelper.setRotationX(view, 60);
    ViewPropertyAnimator.animate(view)
        .rotationX(0)
        .setDuration(600)
        .setInterpolator(new OvershootInterpolator(8))
        .start();
    ViewHelper.setScaleX(view, 0.4f);
    ViewPropertyAnimator.animate(view)
        .scaleX(1f)
        .setDuration(600)
        .setInterpolator(new OvershootInterpolator(8))
        .start();
    return view;
  }
  @Override
  public View createView(Context context) {
    if (!receiverRegistered) {
      receiverRegistered = true;
      IntentFilter filter = new IntentFilter();
      filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
      filter.addAction(Intent.ACTION_MEDIA_CHECKING);
      filter.addAction(Intent.ACTION_MEDIA_EJECT);
      filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
      filter.addAction(Intent.ACTION_MEDIA_NOFS);
      filter.addAction(Intent.ACTION_MEDIA_REMOVED);
      filter.addAction(Intent.ACTION_MEDIA_SHARED);
      filter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE);
      filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
      filter.addDataScheme("file");
      ApplicationLoader.applicationContext.registerReceiver(receiver, filter);
    }

    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            } else if (id == -2) {
              selectedFiles.clear();
              actionBar.hideActionMode();
              listView.invalidateViews();
            } else if (id == done) {
              if (delegate != null) {
                ArrayList<String> files = new ArrayList<>();
                files.addAll(selectedFiles.keySet());
                delegate.didSelectFiles(DocumentSelectActivity.this, files);
              }
            }
          }
        });
    selectedFiles.clear();
    actionModeViews.clear();

    final ActionBarMenu actionMode = actionBar.createActionMode();
    actionModeViews.add(
        actionMode.addItem(
            -2,
            R.drawable.ic_ab_back_grey,
            R.drawable.bar_selector_mode,
            null,
            AndroidUtilities.dp(54)));

    selectedMessagesCountTextView = new TextView(actionMode.getContext());
    selectedMessagesCountTextView.setTextSize(18);
    selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    selectedMessagesCountTextView.setTextColor(0xff737373);
    selectedMessagesCountTextView.setSingleLine(true);
    selectedMessagesCountTextView.setLines(1);
    selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END);
    selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2));
    selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL);
    selectedMessagesCountTextView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });
    actionMode.addView(selectedMessagesCountTextView);
    LinearLayout.LayoutParams layoutParams =
        (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams();
    layoutParams.weight = 1;
    layoutParams.width = 0;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    selectedMessagesCountTextView.setLayoutParams(layoutParams);

    actionModeViews.add(
        actionMode.addItem(
            done,
            R.drawable.ic_ab_done_gray,
            R.drawable.bar_selector_mode,
            null,
            AndroidUtilities.dp(54)));

    fragmentView =
        getParentActivity()
            .getLayoutInflater()
            .inflate(R.layout.document_select_layout, null, false);
    listAdapter = new ListAdapter(context);
    emptyView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
    emptyView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });
    listView = (ListView) fragmentView.findViewById(R.id.listView);
    listView.setEmptyView(emptyView);
    listView.setAdapter(listAdapter);

    listView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            scrolling = scrollState != SCROLL_STATE_IDLE;
          }

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}
        });

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int i, long id) {
            if (actionBar.isActionModeShowed() || i < 0 || i >= items.size()) {
              return false;
            }
            ListItem item = items.get(i);
            File file = item.file;
            if (file != null && !file.isDirectory()) {
              if (!file.canRead()) {
                showErrorBox(LocaleController.getString("AccessError", R.string.AccessError));
                return false;
              }
              if (sizeLimit != 0) {
                if (file.length() > sizeLimit) {
                  showErrorBox(
                      LocaleController.formatString(
                          "FileUploadLimit",
                          R.string.FileUploadLimit,
                          AndroidUtilities.formatFileSize(sizeLimit)));
                  return false;
                }
              }
              if (file.length() == 0) {
                return false;
              }
              selectedFiles.put(file.toString(), item);
              selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size()));
              if (Build.VERSION.SDK_INT >= 11) {
                AnimatorSetProxy animatorSet = new AnimatorSetProxy();
                ArrayList<Object> animators = new ArrayList<>();
                for (int a = 0; a < actionModeViews.size(); a++) {
                  View view2 = actionModeViews.get(a);
                  AndroidUtilities.clearDrawableAnimation(view2);
                  if (a < 1) {
                    animators.add(
                        ObjectAnimatorProxy.ofFloat(
                            view2, "translationX", -AndroidUtilities.dp(56), 0));
                  } else {
                    animators.add(ObjectAnimatorProxy.ofFloat(view2, "scaleY", 0.1f, 1.0f));
                  }
                }
                animatorSet.playTogether(animators);
                animatorSet.setDuration(250);
                animatorSet.start();
              }
              scrolling = false;
              if (view instanceof SharedDocumentCell) {
                ((SharedDocumentCell) view).setChecked(true, true);
              }
              actionBar.showActionMode();
            }
            return true;
          }
        });

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (i < 0 || i >= items.size()) {
              return;
            }
            ListItem item = items.get(i);
            File file = item.file;
            if (file == null) {
              if (item.icon == R.drawable.ic_storage_gallery) {
                if (delegate != null) {
                  delegate.startDocumentSelectActivity();
                }
                finishFragment(false);
              } else {
                HistoryEntry he = history.remove(history.size() - 1);
                actionBar.setTitle(he.title);
                if (he.dir != null) {
                  listFiles(he.dir);
                } else {
                  listRoots();
                }
                listView.setSelectionFromTop(he.scrollItem, he.scrollOffset);
              }
            } else if (file.isDirectory()) {
              HistoryEntry he = new HistoryEntry();
              he.scrollItem = listView.getFirstVisiblePosition();
              he.scrollOffset = listView.getChildAt(0).getTop();
              he.dir = currentDir;
              he.title = actionBar.getTitle();
              history.add(he);
              if (!listFiles(file)) {
                history.remove(he);
                return;
              }
              actionBar.setTitle(item.title);
              listView.setSelection(0);
            } else {
              if (!file.canRead()) {
                showErrorBox(LocaleController.getString("AccessError", R.string.AccessError));
                file = new File("/mnt/sdcard");
              }
              if (sizeLimit != 0) {
                if (file.length() > sizeLimit) {
                  showErrorBox(
                      LocaleController.formatString(
                          "FileUploadLimit",
                          R.string.FileUploadLimit,
                          AndroidUtilities.formatFileSize(sizeLimit)));
                  return;
                }
              }
              if (file.length() == 0) {
                return;
              }
              if (actionBar.isActionModeShowed()) {
                if (selectedFiles.containsKey(file.toString())) {
                  selectedFiles.remove(file.toString());
                } else {
                  selectedFiles.put(file.toString(), item);
                }
                if (selectedFiles.isEmpty()) {
                  actionBar.hideActionMode();
                } else {
                  selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size()));
                }
                scrolling = false;
                if (view instanceof SharedDocumentCell) {
                  ((SharedDocumentCell) view)
                      .setChecked(selectedFiles.containsKey(item.file.toString()), true);
                }
              } else {
                if (delegate != null) {
                  ArrayList<String> files = new ArrayList<>();
                  files.add(file.getAbsolutePath());
                  delegate.didSelectFiles(DocumentSelectActivity.this, files);
                }
              }
            }
          }
        });

    listRoots();

    return fragmentView;
  }
示例#24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    t = (TextView) findViewById(R.id.textBox);
    l = (FrameLayout) findViewById(R.id.layout);

    t.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent e) {
            int Rawx = (int) e.getRawX() - 1;
            int Rawy = (int) e.getRawY() - 1;
            int x = (int) e.getX() - 1;
            int y = (int) e.getY() - 1;
            System.out.println("x: " + (e.getX() - 1) + "; y: " + (e.getY() - 1));
            System.out.println("Rawx: " + Rawx + "; Rawy: " + Rawy);
            switch (e.getAction()) {
              case MotionEvent.ACTION_DOWN:
                origX = Rawx;
                origY = Rawy;
                System.out.println("DOWN");
                iV = new ImageView(getApplicationContext());
                //                        iV.setScaleType(ImageView.);
                iV.setImageResource(R.drawable.arrow);
                iV.setScaleType(ImageView.ScaleType.FIT_XY);
                // set position based on rawX/Y coordinates
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(1, 1);
                layoutParams.setMargins(Rawx - 50, Rawy - 50, 0, 0);
                iV.setLayoutParams(layoutParams);
                l.addView(iV);
                //                        iV.setMaxWidth(1);
                //                        iV.setMinimumWidth(1);
                //                        iV.setMaxHeight(1);
                //                        iV.setMinimumHeight(1);
                //                        iV.setTop(y);
                //                        iV.setLeft(x);;
                return true;
                //                        i = new ImageView(getApplicationContext());
                //                        i.setImageResource(R.drawable.arrow_nine);
                ////
                //                        i = new DragView(getApplicationContext(),x,y);
                //                        i.setMinimumWidth(1);
                //                        i.setMinimumHeight(1);
                //                        i.setTop(x);
                //                        i.setLeft(y);
                //                        l.addView(i);
                //                        return true;
              case MotionEvent.ACTION_MOVE:
                System.out.println("MOVE");
                //                        int width = Math.abs(x-i.x0);
                //                        int height = Math.abs(y-i.y0);
                // set width and height based on normal x and y coordinates (not on raw)
                FrameLayout.LayoutParams layoutParam = new FrameLayout.LayoutParams(x, y);
                layoutParam.setMargins(origX, origY, 0, 0);
                iV.setLayoutParams(layoutParam);
                //                        iV.setMinimumWidth(x);
                //                        iV.setMinimumHeight(y);
                //                        iV.setMaxWidth(x);
                //                        iV.setMaxHeight(y);
                //                        iV.setTop(x);
                //                        iV.setLeft(y);
                //                        i.invalidate();
                //                        i.setImageBitmap(arrow);
                return true;
                //                        a.setTop(x);
                //                        a.setLeft(y);
                //                        a.update(x,y);
                //                        return true;
            }
            return false;
          }
        });
  }
示例#25
0
  @Override
  public View createView(LayoutInflater inflater, ViewGroup container) {
    if (fragmentView == null) {
      actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
      actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
      if (isBroadcast) {
        actionBarLayer.setTitle(
            LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
      } else {
        actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
      }
      actionBarLayer.setSubtitle(
          LocaleController.formatString(
              "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));

      actionBarLayer.setActionBarMenuOnItemClick(
          new ActionBarLayer.ActionBarMenuOnItemClick() {
            @Override
            public void onItemClick(int id) {
              if (id == -1) {
                finishFragment();
              } else if (id == done_button) {
                if (!selectedContacts.isEmpty()) {
                  ArrayList<Integer> result = new ArrayList<Integer>();
                  result.addAll(selectedContacts.keySet());
                  Bundle args = new Bundle();
                  args.putIntegerArrayList("result", result);
                  args.putBoolean("broadcast", isBroadcast);
                  presentFragment(new GroupCreateFinalActivity(args));
                }
              }
            }
          });

      ActionBarMenu menu = actionBarLayer.createMenu();
      View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout);
      TextView doneTextView = (TextView) doneItem.findViewById(R.id.done_button);
      doneTextView.setText(LocaleController.getString("Next", R.string.Next));

      searching = false;
      searchWas = false;

      fragmentView = inflater.inflate(R.layout.group_create_layout, container, false);

      emptyTextView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
      emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
      emptyTextView.setOnTouchListener(
          new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              return true;
            }
          });
      userSelectEditText = (EditText) fragmentView.findViewById(R.id.bubble_input_text);
      userSelectEditText.setHint(
          LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
      if (Build.VERSION.SDK_INT >= 11) {
        userSelectEditText.setTextIsSelectable(false);
      }
      userSelectEditText.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(
                CharSequence charSequence, int start, int count, int after) {
              if (!ignoreChange) {
                beforeChangeIndex = userSelectEditText.getSelectionStart();
                changeString = new SpannableString(charSequence);
              }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

            @Override
            public void afterTextChanged(Editable editable) {
              if (!ignoreChange) {
                boolean search = false;
                int afterChangeIndex = userSelectEditText.getSelectionEnd();
                if (editable.toString().length() < changeString.toString().length()) {
                  String deletedString = "";
                  try {
                    deletedString =
                        changeString.toString().substring(afterChangeIndex, beforeChangeIndex);
                  } catch (Exception e) {
                    FileLog.e("tmessages", e);
                  }
                  if (deletedString.length() > 0) {
                    if (searching && searchWas) {
                      search = true;
                    }
                    Spannable span = userSelectEditText.getText();
                    for (int a = 0; a < allSpans.size(); a++) {
                      XImageSpan sp = allSpans.get(a);
                      if (span.getSpanStart(sp) == -1) {
                        allSpans.remove(sp);
                        selectedContacts.remove(sp.uid);
                      }
                    }
                    actionBarLayer.setSubtitle(
                        LocaleController.formatString(
                            "MembersCount",
                            R.string.MembersCount,
                            selectedContacts.size(),
                            maxCount));
                    listView.invalidateViews();
                  } else {
                    search = true;
                  }
                } else {
                  search = true;
                }
                if (search) {
                  String text = userSelectEditText.getText().toString().replace("<", "");
                  if (text.length() != 0) {
                    searchDialogs(text);
                    searching = true;
                    searchWas = true;
                    emptyTextView.setText(
                        LocaleController.getString("NoResult", R.string.NoResult));
                    listViewAdapter.notifyDataSetChanged();
                  } else {
                    searchResult = null;
                    searchResultNames = null;
                    searching = false;
                    searchWas = false;
                    emptyTextView.setText(
                        LocaleController.getString("NoContacts", R.string.NoContacts));
                    listViewAdapter.notifyDataSetChanged();
                  }
                }
              }
            }
          });

      listView = (PinnedHeaderListView) fragmentView.findViewById(R.id.listView);
      listView.setEmptyView(emptyTextView);
      listView.setVerticalScrollBarEnabled(false);

      listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
      listView.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
              TLRPC.User user;
              int section = listViewAdapter.getSectionForPosition(i);
              int row = listViewAdapter.getPositionInSectionForPosition(i);
              if (searching && searchWas) {
                user = searchResult.get(row);
              } else {
                ArrayList<TLRPC.TL_contact> arr =
                    ContactsController.getInstance()
                        .usersSectionsDict
                        .get(
                            ContactsController.getInstance().sortedUsersSectionsArray.get(section));
                user = MessagesController.getInstance().getUser(arr.get(row).user_id);
                listView.invalidateViews();
              }
              if (selectedContacts.containsKey(user.id)) {
                XImageSpan span = selectedContacts.get(user.id);
                selectedContacts.remove(user.id);
                SpannableStringBuilder text =
                    new SpannableStringBuilder(userSelectEditText.getText());
                text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                allSpans.remove(span);
                ignoreChange = true;
                userSelectEditText.setText(text);
                userSelectEditText.setSelection(text.length());
                ignoreChange = false;
              } else {
                if (selectedContacts.size() == maxCount) {
                  return;
                }
                ignoreChange = true;
                XImageSpan span = createAndPutChipForUser(user);
                span.uid = user.id;
                ignoreChange = false;
              }
              actionBarLayer.setSubtitle(
                  LocaleController.formatString(
                      "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
              if (searching || searchWas) {
                searching = false;
                searchWas = false;
                emptyTextView.setText(
                    LocaleController.getString("NoContacts", R.string.NoContacts));

                ignoreChange = true;
                SpannableStringBuilder ssb = new SpannableStringBuilder("");
                for (ImageSpan sp : allSpans) {
                  ssb.append("<<");
                  ssb.setSpan(
                      sp,
                      ssb.length() - 2,
                      ssb.length(),
                      SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                userSelectEditText.setText(ssb);
                userSelectEditText.setSelection(ssb.length());
                ignoreChange = false;

                listViewAdapter.notifyDataSetChanged();
              } else {
                listView.invalidateViews();
              }
            }
          });

      listView.setOnScrollListener(
          new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
              if (i == SCROLL_STATE_TOUCH_SCROLL) {
                AndroidUtilities.hideKeyboard(userSelectEditText);
              }
            }

            @Override
            public void onScroll(
                AbsListView absListView,
                int firstVisibleItem,
                int visibleItemCount,
                int totalItemCount) {}
          });
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }
    return fragmentView;
  }
示例#26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_site_access);
    Bundle extras = getIntent().getExtras();
    String title = extras.getString("title");
    setTitle(title);
    new Thread(getSite).start();
    textView = (TextView) findViewById(R.id.textView3);
    // Display display = ((WindowManager) getSystemService(WINDOW_SERVICE))
    //  .getDefaultDisplay();
    scrWidth = textView.getWidth();
    scrHeight = textView.getHeight();

    // ---------
    RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.site_info_lo);
    textView.setOnTouchListener(
        new OnSwipeTouchListener(this) {
          @Override
          public void onSwipeLeft() {
            if (CurrentPage < 3) {
              CurrentPage++;
              printPage();
            }
          }

          @Override
          public void onSwipeRight() {
            if (CurrentPage > 0) {
              CurrentPage--;
              printPage();
            }
          }

          @Override
          public boolean onTouch(View v, MotionEvent event) {

            switch (event.getAction() & MotionEvent.ACTION_MASK) {
              case MotionEvent.ACTION_DOWN:
                start.set(event.getX(), event.getY());
                tvPos0.set((int) event.getX(), (int) event.getY());
                mode = Mode.DRAG;
                break;
              case MotionEvent.ACTION_POINTER_DOWN:
                oldDist = spacing(event);
                if (oldDist > 10f) {
                  mode = Mode.ZOOM;
                }
                break;
              case MotionEvent.ACTION_UP:
              case MotionEvent.ACTION_POINTER_UP:
                mode = Mode.NONE;
                tvPos1.set(tvPosSave.x, tvPosSave.y);
                break;
              case MotionEvent.ACTION_MOVE:
                if (mode == Mode.DRAG) {
                  doScroll(event);
                } else if (mode == Mode.ZOOM) {
                  doZoom(event);
                }
                break;
            }
            return super.onTouch(v, event);
          }
        });
    // text3.setMovementMethod(new ScrollingMovementMethod());
  }
示例#27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.choose_stats);

    Intent preIntent = getIntent();
    Bundle bundle = preIntent.getExtras();

    myCharacter = (String[]) bundle.get("myCharacter");

    chooseStatsText = (TextView) findViewById(R.id.chooseStatsText);

    reset = (Button) findViewById(R.id.resetButton);
    reset.setOnClickListener(new resetButtonListener());

    proceed = (Button) findViewById(R.id.statsProceedButton);
    proceed.setEnabled(false);
    proceed.setOnClickListener(new proceedButtonListener());

    raceButton = (ImageButton) findViewById(R.id.raceButton);
    raceButton.setImageResource(R.drawable.green_circle);
    raceButton.setOnClickListener(new raceButtonListener());

    classButton = (ImageButton) findViewById(R.id.classButton);
    classButton.setImageResource(R.drawable.green_circle);
    classButton.setOnClickListener(new classButtonListener());

    bgButton = (ImageButton) findViewById(R.id.backgroundButton);
    bgButton.setImageResource(R.drawable.green_circle);
    bgButton.setOnClickListener(new bgButtonListener());

    statsButton = (ImageButton) findViewById(R.id.statsButton);
    statsButton.setImageResource(R.drawable.blue_circle);

    fCharButton = (ImageButton) findViewById(R.id.finalCharacterButton);
    fCharButton.setImageResource(R.drawable.grey_circle);

    // Points: 15, 14, 13, 12, 10, 8
    point1 = (TextView) findViewById(R.id.point1);
    point1.setText("15");
    point1.setOnTouchListener(new My15TouchListener());

    point2 = (TextView) findViewById(R.id.point2);
    point2.setText("14");
    point2.setOnTouchListener(new My14TouchListener());

    point3 = (TextView) findViewById(R.id.point3);
    point3.setText("13");
    point3.setOnTouchListener(new My13TouchListener());

    point4 = (TextView) findViewById(R.id.point4);
    point4.setText("12");
    point4.setOnTouchListener(new My12TouchListener());

    point5 = (TextView) findViewById(R.id.point5);
    point5.setText("10");
    point5.setOnTouchListener(new My10TouchListener());

    point6 = (TextView) findViewById(R.id.point6);
    point6.setText("8");
    point6.setOnTouchListener(new My8TouchListener());

    strengthVal = (TextView) findViewById(R.id.strengthValue);
    strengthVal.setOnDragListener(new MyDragStrengthListener());

    conVal = (TextView) findViewById(R.id.conValue);
    conVal.setOnDragListener(new MyDragConListener());

    dexVal = (TextView) findViewById(R.id.dexValue);
    dexVal.setOnDragListener(new MyDragDexListener());

    intVal = (TextView) findViewById(R.id.intValue);
    intVal.setOnDragListener(new MyDragIntListener());

    charismaVal = (TextView) findViewById(R.id.charValue);
    charismaVal.setOnDragListener(new MyDragCharismaListener());

    wisdomVal = (TextView) findViewById(R.id.wisValue);
    wisdomVal.setOnDragListener(new MyDragWisdomListener());
  }
示例#28
0
  /**
   * text类型的: 1. 设定内容Emoparser 2. 点击事件 单击跳转、 双击方法、长按pop menu 点击头像的事件 跳转
   *
   * @param position
   * @param convertView
   * @param viewGroup
   * @param isMine
   * @return
   */
  private View textMsgRender(
      final int position, View convertView, final ViewGroup viewGroup, final boolean isMine) {
    TextRenderView textRenderView;
    final TextMessage textMessage = (TextMessage) msgObjectList.get(position);
    UserEntity userEntity = imService.getContactManager().findContact(textMessage.getFromId());

    if (null == convertView) {
      textRenderView =
          TextRenderView.inflater(
              ctx, viewGroup, isMine); // new TextRenderView(ctx,viewGroup,isMine);
    } else {
      textRenderView = (TextRenderView) convertView;
    }

    final TextView textView = textRenderView.getMessageContent();

    // 失败事件添加
    textRenderView
        .getMessageFailed()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View arg0) {
                MessageOperatePopup popup =
                    getPopMenu(viewGroup, new OperateItemClickListener(textMessage, position));
                popup.show(textView, DBConstant.SHOW_ORIGIN_TEXT_TYPE, true, isMine);
              }
            });

    textView.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            // 弹窗类型
            MessageOperatePopup popup =
                getPopMenu(viewGroup, new OperateItemClickListener(textMessage, position));
            boolean bResend = textMessage.getStatus() == MessageConstant.MSG_FAILURE;
            popup.show(textView, DBConstant.SHOW_ORIGIN_TEXT_TYPE, bResend, isMine);
            return true;
          }
        });

    // url 路径可以设定 跳转哦哦
    final String content = textMessage.getContent();
    textView.setOnTouchListener(
        new OnDoubleClickListener() {
          @Override
          public void onClick(View view) {
            // todo
          }

          @Override
          public void onDoubleClick(View view) {
            Intent intent = new Intent(ctx, PreviewTextActivity.class);
            intent.putExtra(IntentConstant.PREVIEW_TEXT_CONTENT, content);
            ctx.startActivity(intent);
          }
        });
    textRenderView.render(textMessage, userEntity, ctx);
    return textRenderView;
  }
示例#29
0
  @SuppressWarnings("unchecked")
  @Override
  public View createView(Context context) {
    actionBar.setBackgroundColor(0xff333333);
    actionBar.setItemsBackground(R.drawable.bar_selector_picker);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    if (selectedAlbum != null) {
      actionBar.setTitle(selectedAlbum.bucketName);
    } else if (type == 0) {
      actionBar.setTitle(
          LocaleController.getString("SearchImagesTitle", R.string.SearchImagesTitle));
    } else if (type == 1) {
      actionBar.setTitle(LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle));
    }
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              if (Build.VERSION.SDK_INT < 11) {
                listView.setAdapter(null);
                listView = null;
                listAdapter = null;
              }
              finishFragment();
            }
          }
        });

    if (selectedAlbum == null) {
      ActionBarMenu menu = actionBar.createMenu();
      searchItem =
          menu.addItem(0, R.drawable.ic_ab_search)
              .setIsSearchField(true)
              .setActionBarMenuItemSearchListener(
                  new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
                    @Override
                    public void onSearchExpand() {}

                    @Override
                    public boolean canCollapseSearch() {
                      finishFragment();
                      return false;
                    }

                    @Override
                    public void onTextChanged(EditText editText) {
                      if (editText.getText().length() == 0) {
                        searchResult.clear();
                        searchResultKeys.clear();
                        lastSearchString = null;
                        nextSearchBingString = null;
                        giphySearchEndReached = true;
                        searching = false;
                        requestQueue.cancelAll("search");
                        if (type == 0) {
                          emptyView.setText(
                              LocaleController.getString(
                                  "NoRecentPhotos", R.string.NoRecentPhotos));
                        } else if (type == 1) {
                          emptyView.setText(
                              LocaleController.getString("NoRecentGIFs", R.string.NoRecentGIFs));
                        }
                        updateSearchInterface();
                      }
                    }

                    @Override
                    public void onSearchPressed(EditText editText) {
                      if (editText.getText().toString().length() == 0) {
                        return;
                      }
                      searchResult.clear();
                      searchResultKeys.clear();
                      nextSearchBingString = null;
                      giphySearchEndReached = true;
                      if (type == 0) {
                        searchBingImages(editText.getText().toString(), 0, 53);
                      } else if (type == 1) {
                        searchGiphyImages(editText.getText().toString(), 0, 53);
                      }
                      lastSearchString = editText.getText().toString();
                      if (lastSearchString.length() == 0) {
                        lastSearchString = null;
                        if (type == 0) {
                          emptyView.setText(
                              LocaleController.getString(
                                  "NoRecentPhotos", R.string.NoRecentPhotos));
                        } else if (type == 1) {
                          emptyView.setText(
                              LocaleController.getString("NoRecentGIFs", R.string.NoRecentGIFs));
                        }
                      } else {
                        emptyView.setText(
                            LocaleController.getString("NoResult", R.string.NoResult));
                      }
                      updateSearchInterface();
                    }
                  });
    }

    if (selectedAlbum == null) {
      if (type == 0) {
        searchItem
            .getSearchField()
            .setHint(LocaleController.getString("SearchImagesTitle", R.string.SearchImagesTitle));
      } else if (type == 1) {
        searchItem
            .getSearchField()
            .setHint(LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle));
      }
    }

    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(0xff000000);

    listView = new GridView(context);
    listView.setPadding(
        AndroidUtilities.dp(4),
        AndroidUtilities.dp(4),
        AndroidUtilities.dp(4),
        AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setDrawSelectorOnTop(true);
    listView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setNumColumns(GridView.AUTO_FIT);
    listView.setVerticalSpacing(AndroidUtilities.dp(4));
    listView.setHorizontalSpacing(AndroidUtilities.dp(4));
    listView.setSelector(R.drawable.list_selector);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (selectedAlbum != null && selectedAlbum.isVideo) {
              if (i < 0 || i >= selectedAlbum.photos.size()) {
                return;
              }
              if (delegate.didSelectVideo(selectedAlbum.photos.get(i).path)) {
                finishFragment();
              }
            } else {
              ArrayList<Object> arrayList;
              if (selectedAlbum != null) {
                arrayList = (ArrayList) selectedAlbum.photos;
              } else {
                if (searchResult.isEmpty() && lastSearchString == null) {
                  arrayList = (ArrayList) recentImages;
                } else {
                  arrayList = (ArrayList) searchResult;
                }
              }
              if (i < 0 || i >= arrayList.size()) {
                return;
              }
              PhotoViewer.getInstance().setParentActivity(getParentActivity());
              PhotoViewer.getInstance()
                  .openPhotoForSelect(
                      arrayList, i, singlePhoto ? 1 : 0, PhotoPickerActivity.this, chatActivity);
            }
          }
        });

    if (selectedAlbum == null) {
      listView.setOnItemLongClickListener(
          new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(
                AdapterView<?> parent, View view, int position, long id) {
              if (searchResult.isEmpty() && lastSearchString == null) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setMessage(LocaleController.getString("ClearSearch", R.string.ClearSearch));
                builder.setPositiveButton(
                    LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(),
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialogInterface, int i) {
                        recentImages.clear();
                        if (listAdapter != null) {
                          listAdapter.notifyDataSetChanged();
                        }
                        MessagesStorage.getInstance().clearWebRecent(type);
                      }
                    });
                builder.setNegativeButton(
                    LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
                return true;
              }
              return false;
            }
          });
    }

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    if (selectedAlbum != null) {
      emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
    } else {
      if (type == 0) {
        emptyView.setText(LocaleController.getString("NoRecentPhotos", R.string.NoRecentPhotos));
      } else if (type == 1) {
        emptyView.setText(LocaleController.getString("NoRecentGIFs", R.string.NoRecentGIFs));
      }
    }
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    if (selectedAlbum == null) {
      listView.setOnScrollListener(
          new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
              if (i == SCROLL_STATE_TOUCH_SCROLL) {
                AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
              }
            }

            @Override
            public void onScroll(
                AbsListView absListView,
                int firstVisibleItem,
                int visibleItemCount,
                int totalItemCount) {
              if (visibleItemCount != 0
                  && firstVisibleItem + visibleItemCount > totalItemCount - 2
                  && !searching) {
                if (type == 0 && nextSearchBingString != null) {
                  searchBingImages(lastSearchString, searchResult.size(), 54);
                } else if (type == 1 && !giphySearchEndReached) {
                  searchGiphyImages(
                      searchItem.getSearchField().getText().toString(), searchResult.size(), 54);
                }
              }
            }
          });

      progressView = new FrameLayout(context);
      progressView.setVisibility(View.GONE);
      frameLayout.addView(progressView);
      layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
      layoutParams.width = LayoutHelper.MATCH_PARENT;
      layoutParams.height = LayoutHelper.MATCH_PARENT;
      layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48);
      progressView.setLayoutParams(layoutParams);

      ProgressBar progressBar = new ProgressBar(context);
      progressView.addView(progressBar);
      layoutParams = (FrameLayout.LayoutParams) progressBar.getLayoutParams();
      layoutParams.width = LayoutHelper.WRAP_CONTENT;
      layoutParams.height = LayoutHelper.WRAP_CONTENT;
      layoutParams.gravity = Gravity.CENTER;
      progressBar.setLayoutParams(layoutParams);

      updateSearchInterface();
    }

    pickerBottomLayout = new PickerBottomLayout(context);
    frameLayout.addView(pickerBottomLayout);
    layoutParams = (FrameLayout.LayoutParams) pickerBottomLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    layoutParams.gravity = Gravity.BOTTOM;
    pickerBottomLayout.setLayoutParams(layoutParams);
    pickerBottomLayout.cancelButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            delegate.actionButtonPressed(true);
            finishFragment();
          }
        });
    pickerBottomLayout.doneButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            sendSelectedPhotos();
          }
        });
    if (singlePhoto) {
      pickerBottomLayout.setVisibility(View.GONE);
    }

    listView.setEmptyView(emptyView);
    pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true);

    return fragmentView;
  }
示例#30
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.clavier_main);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    numeros = (TextView) findViewById(com.project.talk_to_your_phone.R.id.textView1);
    numeros.setText("");

    it = getIntent();

    // INITIALIZE RECEIVER
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    BroadcastReceiver mReceiver = new ScreenReceiver();
    registerReceiver(mReceiver, filter);

    btn_1 = (Button) findViewById(R.id.button1);
    btn_2 = (Button) findViewById(R.id.button2);
    btn_3 = (Button) findViewById(R.id.button3);
    btn_4 = (Button) findViewById(R.id.button4);
    btn_5 = (Button) findViewById(R.id.button5);
    btn_6 = (Button) findViewById(R.id.button6);
    btn_7 = (Button) findViewById(R.id.button7);
    btn_8 = (Button) findViewById(R.id.button8);
    btn_9 = (Button) findViewById(R.id.button9);
    btn_0 = (Button) findViewById(R.id.button11);
    btn_etoile = (Button) findViewById(R.id.button_etoile);
    btn_dieze = (Button) findViewById(R.id.button_dieze);
    btn_plus = (Button) findViewById(R.id.button_plus);
    btn_appeler = (Button) findViewById(R.id.button_appeler);
    btn_effacer = (Button) findViewById(R.id.button_effacer);

    tts = new TextToSpeech(this, this);

    btn_1.setOnLongClickListener(this);
    btn_1.setOnClickListener(this);
    btn_2.setOnLongClickListener(this);
    btn_2.setOnClickListener(this);
    btn_3.setOnLongClickListener(this);
    btn_3.setOnClickListener(this);
    btn_4.setOnLongClickListener(this);
    btn_4.setOnClickListener(this);
    btn_5.setOnLongClickListener(this);
    btn_5.setOnClickListener(this);
    btn_6.setOnLongClickListener(this);
    btn_6.setOnClickListener(this);
    btn_7.setOnLongClickListener(this);
    btn_7.setOnClickListener(this);
    btn_8.setOnLongClickListener(this);
    btn_8.setOnClickListener(this);
    btn_9.setOnLongClickListener(this);
    btn_9.setOnClickListener(this);
    btn_0.setOnLongClickListener(this);
    btn_0.setOnClickListener(this);
    btn_etoile.setOnLongClickListener(this);
    btn_etoile.setOnClickListener(this);
    btn_dieze.setOnLongClickListener(this);
    btn_dieze.setOnClickListener(this);
    btn_plus.setOnLongClickListener(this);
    btn_plus.setOnClickListener(this);
    btn_appeler.setOnLongClickListener(this);
    btn_appeler.setOnClickListener(this);
    btn_effacer.setOnLongClickListener(this);
    btn_effacer.setOnClickListener(this);
    numeros.setOnTouchListener(this);

    vibration = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    tremblementDetection =
        new TremblementDetection(
            getApplicationContext(),
            new TremblementListener() {
              public void onTremblementDetected() {
                if (!numeros.getText().toString().equals("")) {
                  final Intent it = new Intent(Clavier.this, Menu_choix.class);
                  it.putExtra("num", numeros.getText().toString());
                  startActivityForResult(it, CODE_RETOUR);
                }
                finish();
              }
            });
  }