private void updateViews() {
    Step step = getCurrentStep();

    if (stepIndex + 1 >= steps.size()) {
      nextButton.setImageDrawable(buttonFinishIcon);
      nextButton.setContentDescription(getString(R.string.finish));
      step.updateView(true);
    } else {
      nextButton.setImageDrawable(buttonNextIcon);
      nextButton.setContentDescription(getString(R.string.next_step));
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    inputSwitcher.setDisplayedChild(stepIndex);
    errorSwitcher.setText("");
    detailsSwitcher.setText(step.getDetails(this));
    titleSwitcher.setText(step.getTitle(this));
    stepText.setText(getString(R.string.page_number, stepIndex + 1, steps.size()));

    stepText.setTextColor(detailsTextColor);

    updateProgressbar();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_input_form);

    loadTheme();

    findViews();

    steps = onCreateSteps();

    if (savedInstanceState != null) {
      setupData = savedInstanceState.getBundle(KEY_DATA);
      stepIndex = savedInstanceState.getInt(KEY_STEP_INDEX, 0);
    }

    setupTitle();
    setupInput();
    setupError();
    setupDetails();

    nextButton.setOnClickListener(nextButtonClickListener);
    errorSwitcher.setText("");
    updateStep();
  }
 public void run() {
   int num = words.length;
   Random r = new Random();
   int i = (r.nextInt(num));
   _quote.setText(String.valueOf(words[i]).trim());
   _handler.postDelayed(this, 6000);
 }
 private void doUpdate() {
   currentIndex++;
   if (currentIndex == messageCount) {
     currentIndex = 0;
   }
   mSwitcher.setText(textToShow.get(currentIndex));
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_input_form);

    loadTheme();

    sSteps = getSteps(this);
    sStepOptional = getOptionalSteps(this);

    findViews();

    if (savedInstanceState != null) {
      setupData = savedInstanceState.getBundle(KEY_DATA);
      mStepIndex = savedInstanceState.getInt(KEY_STEP_INDEX, 0);
    }

    setupTitle();
    setupInput();
    setupError();
    setupDetails();

    mNextButton.setOnClickListener(mOnNextButtonClickListener);
    mErrorSwitcher.setText("");

    Step step = getCurrentStep();
    if (step != null && step instanceof TextStep) {
      try {
        ((TextStep) step).getView().setOnEditorActionListener(mOnEnterPressListener);
      } catch (Exception e) {
      }
    }
    updateStep();
  }
  public void updateTabCountAndAnimate(int count) {
    if (mCount > count) {
      mTabsCount.setInAnimation(mSlideDownIn);
      mTabsCount.setOutAnimation(mSlideDownOut);
    } else if (mCount < count) {
      mTabsCount.setInAnimation(mSlideUpIn);
      mTabsCount.setOutAnimation(mSlideUpOut);
    } else {
      return;
    }

    mTabsCount.setText(String.valueOf(count));
    mCount = count;
    mTabs.setContentDescription(mContext.getString(R.string.num_tabs, count));

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            ((TextView) mTabsCount.getCurrentView())
                .setTextColor(mContext.getResources().getColor(R.color.url_bar_text_highlight));
          }
        },
        mDuration);

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            ((TextView) mTabsCount.getCurrentView())
                .setTextColor(mContext.getResources().getColor(R.color.tabs_counter_color));
          }
        },
        2 * mDuration);
  }
  /**
   * Substracts one point to the corresponding team score depending on the {@code callerView}.
   *
   * @param callerView The view that has called this method.
   * @since 6
   */
  public void substractScore(View callerView) {
    int teamScoreToSubstractId = -1;

    switch (callerView.getId()) {
      case R.id.trucoAnnotator_substractButtonTeam1:
        teamScoreToSubstractId = R.id.trucoAnnotator_scoreTeam1;
        break;
      case R.id.trucoAnnotator_substractButtonTeam2:
        teamScoreToSubstractId = R.id.trucoAnnotator_scoreTeam2;
        break;
    }

    if (teamScoreToSubstractId != -1) {
      TextSwitcher scoreToUpdate = (TextSwitcher) findViewById(teamScoreToSubstractId);
      String currentValueString = ((TextView) scoreToUpdate.getCurrentView()).getText().toString();

      int currentScore = 0;
      if (!currentValueString.equals("")) {
        currentScore = Integer.valueOf(currentValueString);
      }

      if (currentScore != Integer.parseInt(getText(R.string.defaultInitialGameScore).toString())) {
        int updatedScore = currentScore - GameKeys.TRUCO_INCREMENT;

        Log.i(LOG_TAG, "Updating score to: " + updatedScore);
        scoreToUpdate.setText(String.valueOf(updatedScore));

        if (updatedScore == GameKeys.TRUCO_MAX_SCORE_WITHOUT_WIN) {
          enableAllControls();
        }
      }
    }
  }
  /** 当没有问题时 */
  private void handNoQuestion() {
    mQuestionText.setText(getResources().getText(R.string.no_questions));
    mQuestionImage.setImageResource(R.drawable.noquestion);

    Button yesButton = (Button) findViewById(R.id.Button_Yes);
    yesButton.setEnabled(false);

    Button noButton = (Button) findViewById(R.id.Button_No);
    noButton.setEnabled(false);
  }
  private void updateViews() {
    Step step = getCurrentStep();
    if (step == null) {
      if (mStepIndex >= stepsSize()) {
        hideSoftInput();
        onFormFinished(setupData);

        mStepIndex--; // reset stepIndex to last step
        finish();
        return;
      }
    }
    if (mStepIndex + 1 >= stepsSize()) {
      mNextButton.setImageDrawable(mButtonFinishIcon);
      step.updateView(true);
    } else {
      hideSoftInput();
      mNextButton.setImageDrawable(mButtonNextIcon);
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    mInputSwitcher.setDisplayedChild(mStepIndex);
    mErrorSwitcher.setText("");
    mDetailsSwitcher.setText(step.getDetails());
    mTitleSwitcher.setText(step.getTitle());
    mStepText.setText(getString(R.string.page_number, mStepIndex + 1, stepsSize()));

    mStepText.setTextColor(mDetailsTextColor);
    if (step instanceof TextStep) System.out.println(step.getView().requestFocus());

    updateProgressbar();
  }
Exemple #10
0
  public void setValueText(String valueText) {
    if (null == valueText) {
      return;
    }

    mSwitcher.setText(valueText);
    /*if(!TextUtils.isDigitsOnly(valueText)){
    	mSwitcher.setText(valueText);
    	return;
    }
    final int number = Integer.valueOf(valueText);
    if(null != mSwitcher && !TextUtils.isEmpty(valueText)){
           new AsyncTask<Void, Void, Void>(){

    		private int mCounter;

    		@Override
    		protected Void doInBackground(Void... params) {
               	for (int i = 0; i <= number; i+=100) {
               		try {
               			mCounter+=100;
    					Thread.sleep(0, 300000);
               			publishProgress();
    				} catch (InterruptedException e) {
    					e.printStackTrace();
    				}
    			}
    			return null;
    		}

           	@Override
           	protected void onProgressUpdate(Void... values) {
       			mSwitcher.setText(String.valueOf(mCounter));
           		super.onProgressUpdate(values);
           	}

           	@Override
           	protected void onPostExecute(Void result) {
           		mSwitcher.setText(String.valueOf(mCounter));
           		super.onPostExecute(result);
           	}

           }.execute();
    }*/
  }
  /**
   * Initializes the score TextSwitcher for the specified {@code textSwitcher}. It also sets the
   * {@code listener}.
   *
   * @param listener The listener which will update the text.
   */
  private void initializeTextSwitcher(
      final TextSwitcher textSwitcher, View.OnTouchListener listener) {
    textSwitcher.setFactory(
        new ViewSwitcher.ViewFactory() {
          @Override
          public View makeView() {
            TextView textView = new TextView(textSwitcher.getContext());
            textView.setTextSize(36);
            return textView;
          }
        });

    textSwitcher.setOnTouchListener(listener);
    textSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
    textSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));

    textSwitcher.setText(getText(R.string.defaultInitialGameScore));
  }
  private void setupTitle() {
    titleSwitcher.setInAnimation(getAnimation(R.anim.slide_in_to_bottom, true));
    titleSwitcher.setOutAnimation(getAnimation(R.anim.slide_out_to_top, false));

    titleSwitcher.setFactory(
        new ViewSwitcher.ViewFactory() {

          @Override
          public View makeView() {
            TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_title, null);
            if (view != null) {
              view.setTextColor(titleTextColor);
            }
            return view;
          }
        });

    titleSwitcher.setText("");
  }
  private void setupError() {
    errorSwitcher.setInAnimation(getAnimation(android.R.anim.slide_in_left, true));
    errorSwitcher.setOutAnimation(getAnimation(android.R.anim.slide_out_right, false));

    errorSwitcher.setFactory(
        new ViewSwitcher.ViewFactory() {

          @Override
          public View makeView() {
            TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_error, null);
            if (view != null && errorTextColor != -1) {
              view.setTextColor(errorTextColor);
            }
            return view;
          }
        });

    errorSwitcher.setText("");
  }
  protected void nextStep() {
    Step step = getCurrentStep();
    boolean checkStep = checkStep();
    if (!checkStep) {
      if (!error) {
        error = true;
        errorSwitcher.setText(step.getError(this));
      }
    } else {
      error = false;
    }
    if (error) {
      return;
    }
    setupData = step.save(setupData);

    stepIndex++;
    updateStep();
  }
  private void setupDetails() {
    detailsSwitcher.setInAnimation(getAnimation(R.anim.alpha_in, true));
    detailsSwitcher.setOutAnimation(getAnimation(R.anim.alpha_out, false));

    detailsSwitcher.setFactory(
        new ViewSwitcher.ViewFactory() {

          @Override
          public View makeView() {
            TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_details, null);
            if (view != null && detailsTextColor != -1) {
              view.setTextColor(detailsTextColor);
            }
            return view;
          }
        });

    detailsSwitcher.setText("");
  }
  public void updateTabs(int count) {
    if (mCount > count) {
      mTabsCount.setInAnimation(mSlideDownIn);
      mTabsCount.setOutAnimation(mSlideDownOut);
    } else if (mCount < count) {
      mTabsCount.setInAnimation(mSlideUpIn);
      mTabsCount.setOutAnimation(mSlideUpOut);
    }

    if (count > 1) mTabs.setImageLevel(count);
    else mTabs.setImageLevel(0);

    mTabsCount.setVisibility(View.VISIBLE);
    mTabsCount.setText(String.valueOf(count));
    mCount = count;

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            ((TextView) mTabsCount.getCurrentView()).setTextColor(mColor);
          }
        },
        mDuration);

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            if (Tabs.getInstance().getCount() == 1) {
              mTabs.setImageLevel(1);
              mTabsCount.setVisibility(View.GONE);
              ((TextView) mTabsCount.getCurrentView()).setTextColor(mCounterColor);
            } else {
              ((TextView) mTabsCount.getCurrentView()).setTextColor(mCounterColor);
            }
          }
        },
        2 * mDuration);
  }
  public BrowserToolbar(Context context, AttributeSet attrs) {
    super(context, attrs);

    mContext = context;

    // Get the device's highlight color
    ContextThemeWrapper wrapper = new ContextThemeWrapper(mContext, android.R.style.TextAppearance);
    TypedArray typedArray =
        wrapper.getTheme().obtainStyledAttributes(new int[] {android.R.attr.textColorHighlight});
    mColor = typedArray.getColor(typedArray.getIndex(0), 0);

    // Load layout into the custom view
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    inflater.inflate(R.layout.browser_toolbar, this);

    mAwesomeBar = (Button) findViewById(R.id.awesome_bar);
    mAwesomeBar.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            onAwesomeBarSearch();
          }
        });

    Resources resources = getResources();

    int padding[] = {
      mAwesomeBar.getPaddingLeft(),
      mAwesomeBar.getPaddingTop(),
      mAwesomeBar.getPaddingRight(),
      mAwesomeBar.getPaddingBottom()
    };

    GeckoStateListDrawable states = new GeckoStateListDrawable();
    states.initializeFilter(mColor);
    states.addState(
        new int[] {android.R.attr.state_pressed},
        resources.getDrawable(R.drawable.address_bar_url_pressed));
    states.addState(new int[] {}, resources.getDrawable(R.drawable.address_bar_url_default));
    mAwesomeBar.setBackgroundDrawable(states);

    mAwesomeBar.setPadding(padding[0], padding[1], padding[2], padding[3]);

    mTabs = (ImageButton) findViewById(R.id.tabs);
    mTabs.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            if (Tabs.getInstance().getCount() > 1) showTabs();
            else addTab();
          }
        });
    mTabs.setImageLevel(1);

    mCounterColor = 0x99ffffff;

    mTabsCount = (TextSwitcher) findViewById(R.id.tabs_count);
    mTabsCount.setFactory(
        new ViewFactory() {
          public View makeView() {
            TextView text = new TextView(mContext);
            text.setGravity(Gravity.CENTER);
            text.setTextSize(16);
            text.setTextColor(mCounterColor);
            text.setTypeface(text.getTypeface(), Typeface.BOLD);
            return text;
          }
        });
    mCount = 0;
    mTabsCount.setText("0");

    mFavicon = (ImageButton) findViewById(R.id.favicon);
    mSiteSecurity = (ImageButton) findViewById(R.id.site_security);
    mProgressSpinner = (AnimationDrawable) resources.getDrawable(R.drawable.progress_spinner);

    mStop = (ImageButton) findViewById(R.id.stop);
    mStop.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            doStop();
          }
        });

    mHandler = new Handler();
    mSlideUpIn = new TranslateAnimation(0, 0, 30, 0);
    mSlideUpOut = new TranslateAnimation(0, 0, 0, -30);
    mSlideDownIn = new TranslateAnimation(0, 0, -30, 0);
    mSlideDownOut = new TranslateAnimation(0, 0, 0, 30);

    mDuration = 750;
    mSlideUpIn.setDuration(mDuration);
    mSlideUpOut.setDuration(mDuration);
    mSlideDownIn.setDuration(mDuration);
    mSlideDownOut.setDuration(mDuration);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sharedPrefs =
        getSharedPreferences(
            "com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    context = this;
    settings = AppSettings.getInstance(context);

    // context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH"));

    Utils.setUpTheme(context, settings);
    setContentView(R.layout.login_activity);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setOAuthConsumerKey(settings.TWITTER_CONSUMER_KEY);
    builder.setOAuthConsumerSecret(settings.TWITTER_CONSUMER_SECRET);
    Configuration configuration = builder.build();

    TwitterFactory factory = new TwitterFactory(configuration);
    twitter = factory.getInstance();

    btnLoginTwitter = (Button) findViewById(R.id.btnLoginTwitter);
    noThanks = (Button) findViewById(R.id.dont_follow);
    title = (TextSwitcher) findViewById(R.id.welcome);
    summary = (TextSwitcher) findViewById(R.id.info);
    progDescription = (TextSwitcher) findViewById(R.id.progress_desc);
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    main = (LinearLayout) findViewById(R.id.mainLayout);

    Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
    Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right);

    title.setFactory(
        new ViewSwitcher.ViewFactory() {

          public View makeView() {
            TextView myText = new TextView(LoginActivity.this);
            myText.setTextSize(30);
            return myText;
          }
        });

    // set the animation type of textSwitcher
    title.setInAnimation(in);
    title.setOutAnimation(out);

    summary.setFactory(
        new ViewSwitcher.ViewFactory() {

          public View makeView() {
            TextView myText = new TextView(LoginActivity.this);
            myText.setTextSize(17);
            return myText;
          }
        });

    // set the animation type of textSwitcher
    summary.setInAnimation(in);
    summary.setOutAnimation(out);

    progDescription.setFactory(
        new ViewSwitcher.ViewFactory() {

          public View makeView() {
            TextView myText = new TextView(LoginActivity.this);
            myText.setTextSize(17);
            return myText;
          }
        });

    // set the animation type of textSwitcher
    progDescription.setInAnimation(in);
    progDescription.setOutAnimation(out);

    title.setText(getResources().getString(R.string.first_welcome));
    summary.setText(getResources().getString(R.string.first_info));

    progressBar.setProgress(100);

    CookieSyncManager.createInstance(this);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();

    mWebView = (WebView) findViewById(R.id.loginWebView);
    try {
      mWebView.getSettings().setJavaScriptEnabled(true);
    } catch (Exception e) {

    }
    mWebView.getSettings().setAppCacheEnabled(false);
    mWebView.getSettings().setSavePassword(false);
    mWebView.getSettings().setSaveFormData(false);
    mWebView.setWebViewClient(
        new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView webView, String url) {
            Log.v("talon_login", "url: " + url);
            if (url != null && url.startsWith("oauth:///talonforandroid")) {
              handleTwitterCallback(url);
            } else if (url.equals("https://twitter.com/")) {
              webView.loadUrl(requestUrl);
            } else {
              webView.loadUrl(url);
            }
            return true;
          }
        });

    noThanks.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            new FollowMe().execute();

            btnLoginTwitter.setText(getResources().getString(R.string.back_to_timeline));
            noThanks.setVisibility(View.GONE);

            summary.setText(getResources().getString(R.string.third_info));
          }
        });

    btnLoginTwitter.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // Call login_activity twitter function
            if (btnLoginTwitter
                .getText()
                .toString()
                .contains(getResources().getString(R.string.login_to_twitter))) {
              if (Utils.hasInternetConnection(context)) {
                btnLoginTwitter.setEnabled(false);

                new AlertDialog.Builder(context)
                    .setMessage(
                        "Twitter may display that Talon cannot authenticate any more users. "
                            + "\n\n"
                            + "If so, and you have logged into Talon in the past, simply hit the 'Sign In' button in the top right and it will allow you to log in as normal. "
                            + "\n\n"
                            + "If you have never logged into Talon, then you will have to wait to login. Twitter seems to allow more users access every few hours.")
                    .setPositiveButton(
                        R.string.ok,
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                          }
                        })
                    .setNegativeButton(
                        "More Info",
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                            startActivity(
                                new Intent(
                                    Intent.ACTION_VIEW,
                                    Uri.parse(
                                        "https://plus.google.com/117432358268488452276/posts/KG4AcH3YA2U")));
                          }
                        })
                    .show();

                new RetreiveFeedTask().execute();
              } else {
                Toast.makeText(
                        context,
                        getResources().getString(R.string.no_network) + "!",
                        Toast.LENGTH_SHORT)
                    .show();
              }
            } else if (btnLoginTwitter
                .getText()
                .toString()
                .contains(getResources().getString(R.string.initial_sync))) {
              new getTimeLine().execute();
            } else if (btnLoginTwitter
                .getText()
                .toString()
                .contains(getResources().getString(R.string.no_thanks))) {
              btnLoginTwitter.setText(getResources().getString(R.string.back_to_timeline));
              noThanks.setVisibility(View.GONE);

              summary.setText(getResources().getString(R.string.third_info));
            } else {

              if (settings.timelineRefresh != 0) { // user only wants manual
                AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

                long now = new Date().getTime();
                long alarm = now + settings.timelineRefresh;

                PendingIntent pendingIntent =
                    PendingIntent.getService(
                        context,
                        HomeFragment.HOME_REFRESH_ID,
                        new Intent(context, TimelineRefreshService.class),
                        0);

                am.setRepeating(
                    AlarmManager.RTC_WAKEUP, alarm, settings.timelineRefresh, pendingIntent);

                now = new Date().getTime();
                alarm = now + settings.mentionsRefresh;

                PendingIntent pendingIntent2 =
                    PendingIntent.getService(
                        context,
                        MentionsFragment.MENTIONS_REFRESH_ID,
                        new Intent(context, MentionsRefreshService.class),
                        0);

                am.setRepeating(
                    AlarmManager.RTC_WAKEUP, alarm, settings.mentionsRefresh, pendingIntent2);

                alarm = now + settings.dmRefresh;

                PendingIntent pendingIntent3 =
                    PendingIntent.getService(
                        context,
                        DMFragment.DM_REFRESH_ID,
                        new Intent(context, DirectMessageRefreshService.class),
                        0);
                am.setRepeating(AlarmManager.RTC_WAKEUP, alarm, settings.dmRefresh, pendingIntent3);
              }

              // set up the autotrim
              AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
              long now = new Date().getTime();
              long alarm = now + AlarmManager.INTERVAL_DAY;
              Log.v("alarm_date", "auto trim " + new Date(alarm).toString());
              PendingIntent pendingIntent =
                  PendingIntent.getService(
                      context, 161, new Intent(context, TrimDataService.class), 0);
              am.set(AlarmManager.RTC_WAKEUP, alarm, pendingIntent);

              finish();

              Intent timeline = new Intent(context, MainActivity.class);
              timeline.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
              timeline.putExtra("tutorial", true);
              sharedPrefs.edit().putBoolean("should_refresh", false).commit();
              sharedPrefs.edit().putBoolean("refresh_me", true).commit();
              sharedPrefs.edit().putBoolean("refresh_me_mentions", true).commit();
              sharedPrefs.edit().putBoolean("refresh_me_dm", true).commit();
              sharedPrefs.edit().putBoolean("need_new_dm", false).commit();
              sharedPrefs.edit().putBoolean("need_clean_databases_version_1_3_0", false).commit();
              sharedPrefs.edit().putBoolean("setup_v_two", true).commit();
              sharedPrefs.edit().putBoolean("version_2_2_7_1", false).commit();
              AppSettings.invalidate();
              startActivity(timeline);
            }
          }
        });
  }
Exemple #19
0
 @Override
 public void onQuestionUpdateTime(String newTime) {
   textSwitcherTime.setText(newTime);
 }
Exemple #20
0
 @Override
 public void onQuestionTimeFinished() {
   checkAnswer(-1, null);
   textSwitcherTime.setText("0");
 }
Exemple #21
0
 // 事件处理函数,控制显示下一个字符串
 public void next(View source) {
   textSwitcher.setText(strs[curStr++ % strs.length]); // ①
 }
 @Override
 public void setTitle(CharSequence title) {
   super.setTitle(title);
   mTextSwitcher.setText(title);
 }
  public void from(LinearLayout layout) {
    mLayout = layout;

    mShowSiteSecurity = false;
    mShowReader = false;
    mReaderPopup = null;

    mAwesomeBar = (Button) mLayout.findViewById(R.id.awesome_bar);
    mAwesomeBar.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            GeckoApp.mAppContext.hideTabs();
            onAwesomeBarSearch();
          }
        });
    mAwesomeBar.setOnCreateContextMenuListener(
        new View.OnCreateContextMenuListener() {
          public void onCreateContextMenu(
              ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            MenuInflater inflater = GeckoApp.mAppContext.getMenuInflater();
            inflater.inflate(R.menu.titlebar_contextmenu, menu);

            String clipboard = GeckoAppShell.getClipboardText();
            if (clipboard == null || TextUtils.isEmpty(clipboard)) {
              menu.findItem(R.id.pasteandgo).setVisible(false);
              menu.findItem(R.id.paste).setVisible(false);
            }

            Tab tab = Tabs.getInstance().getSelectedTab();
            if (tab != null) {
              String url = tab.getURL();
              if (url == null) {
                menu.findItem(R.id.copyurl).setVisible(false);
                menu.findItem(R.id.share).setVisible(false);
                menu.findItem(R.id.add_to_launcher).setVisible(false);
              }
            } else {
              // if there is no tab, remove anything tab dependent
              menu.findItem(R.id.copyurl).setVisible(false);
              menu.findItem(R.id.share).setVisible(false);
              menu.findItem(R.id.add_to_launcher).setVisible(false);
            }
          }
        });

    mPadding =
        new int[] {
          mAwesomeBar.getPaddingLeft(),
          mAwesomeBar.getPaddingTop(),
          mAwesomeBar.getPaddingRight(),
          mAwesomeBar.getPaddingBottom()
        };

    mTabs = (ImageButton) mLayout.findViewById(R.id.tabs);
    mTabs.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            toggleTabs();
          }
        });
    mTabs.setImageLevel(0);

    mTabsCount = (TextSwitcher) mLayout.findViewById(R.id.tabs_count);
    mTabsCount.removeAllViews();
    mTabsCount.setFactory(this);
    mTabsCount.setText("");
    mCount = 0;

    mBack = (ImageButton) mLayout.findViewById(R.id.back);
    mBack.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View view) {
            Tabs.getInstance().getSelectedTab().doBack();
          }
        });

    mForward = (ImageButton) mLayout.findViewById(R.id.forward);
    mForward.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View view) {
            Tabs.getInstance().getSelectedTab().doForward();
          }
        });

    mFavicon = (ImageButton) mLayout.findViewById(R.id.favicon);
    mSiteSecurity = (ImageButton) mLayout.findViewById(R.id.site_security);
    mSiteSecurity.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View view) {
            int[] lockLocation = new int[2];
            view.getLocationOnScreen(lockLocation);
            LayoutParams lockLayoutParams = (LayoutParams) view.getLayoutParams();

            // Calculate the left margin for the arrow based on the position of the lock icon.
            int leftMargin = lockLocation[0] - lockLayoutParams.rightMargin;
            SiteIdentityPopup.getInstance().show(mSiteSecurity, leftMargin);
          }
        });

    mProgressSpinner =
        (AnimationDrawable) mContext.getResources().getDrawable(R.drawable.progress_spinner);

    mStop = (ImageButton) mLayout.findViewById(R.id.stop);
    mStop.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            Tab tab = Tabs.getInstance().getSelectedTab();
            if (tab != null) tab.doStop();
          }
        });

    mReader = (ImageButton) mLayout.findViewById(R.id.reader);
    mReader.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View view) {
            if (mReaderPopup == null) mReaderPopup = new ReaderPopup(GeckoApp.mAppContext);

            mReaderPopup.show();
          }
        });

    mShadow = (ImageView) mLayout.findViewById(R.id.shadow);

    mHandler = new Handler();
    mSlideUpIn = new TranslateAnimation(0, 0, 40, 0);
    mSlideUpOut = new TranslateAnimation(0, 0, 0, -40);
    mSlideDownIn = new TranslateAnimation(0, 0, -40, 0);
    mSlideDownOut = new TranslateAnimation(0, 0, 0, 40);

    mDuration = 750;
    mSlideUpIn.setDuration(mDuration);
    mSlideUpOut.setDuration(mDuration);
    mSlideDownIn.setDuration(mDuration);
    mSlideDownOut.setDuration(mDuration);

    mMenu = (ImageButton) mLayout.findViewById(R.id.menu);
    mActionItemBar = (LinearLayout) mLayout.findViewById(R.id.menu_items);
    mHasSoftMenuButton = false;

    if (Build.VERSION.SDK_INT >= 11) mHasSoftMenuButton = true;

    if (Build.VERSION.SDK_INT >= 14) {
      if (!ViewConfiguration.get(GeckoApp.mAppContext).hasPermanentMenuKey())
        mHasSoftMenuButton = true;
      else mHasSoftMenuButton = false;
    }

    if (mHasSoftMenuButton) {
      mMenu.setVisibility(View.VISIBLE);
      mMenu.setOnClickListener(
          new Button.OnClickListener() {
            public void onClick(View view) {
              GeckoApp.mAppContext.openOptionsMenu();
            }
          });
    }

    if (Build.VERSION.SDK_INT >= 11) {
      View panel = GeckoApp.mAppContext.getMenuPanel();

      // If panel is null, the app is starting up for the first time;
      //    add this to the popup only if we have a soft menu button.
      // else, browser-toolbar is initialized on rotation,
      //    and we need to re-attach action-bar items.

      if (panel == null) {
        GeckoApp.mAppContext.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null);
        panel = GeckoApp.mAppContext.getMenuPanel();

        if (mHasSoftMenuButton) {
          mMenuPopup = new MenuPopup(mContext);
          mMenuPopup.setPanelView(panel);
        }
      }
    }
  }