Example #1
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
    super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
    // android.util.Log.d("PREF", ""+requestCode+"ff "+resultCode);
    switch (requestCode) {
      case REQ_CODE_PICK_IMAGE:
        if (resultCode == RESULT_OK) {
          Uri selectedImage = imageReturnedIntent.getData();
          String[] filePathColumn = {MediaColumns.DATA};

          Cursor cursor =
              getContentResolver().query(selectedImage, filePathColumn, null, null, null);
          cursor.moveToFirst();

          int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
          String filePath = cursor.getString(columnIndex);
          cursor.close();
          mNewPostView.setImage(filePath);
        } else {
          mNewPostView.setImage("");
        }
        if (!getSlidingMenu().isShown()) {
          getSlidingMenu().showContent();
        }
        break;
      case REQ_CODE_PREFS:
        setTheme(
            PrefsActivity.getTheme(
                this,
                (getHomeFragment().getCurrentChanPage() == null)
                    ? false
                    : getHomeFragment().getCurrentChanPage().isWorksafe()));
        if (((BoardsFragment) getHomeFragment().mBoardsPagerAdapter.getChanFragmentByPosition(0))
            != null)
          ((BaseAdapter)
                  ((BoardsFragment)
                          getHomeFragment().mBoardsPagerAdapter.getChanFragmentByPosition(0))
                      .getListAdapter())
              .notifyDataSetChanged();
        if (resultCode == RESULT_GOLD) {
          showDialog("Error", "Couldn't connect to android market.");
        }
        try {
          // android.util.Log.d("CHAN", "Starting...");
          int time =
              Integer.parseInt(PrefsActivity.getSetting(this, PrefsActivity.KEY_INTERVAL, "0"));
          // android.util.Log.d("CHAN", "time..."+time);
          if (time != 0) {
            Intent i = new Intent(this, AutoUpdater.class);
            startService(i);
            bindService(i, mConnection, Context.BIND_AUTO_CREATE);
            mIsBound = true;
          }
        } catch (NumberFormatException e) {

        }

        break;
    }
  }
  public void setBackground() {
    LinearLayout lb = (LinearLayout) findViewById(R.id.login_body);
    LinearLayout lh = (LinearLayout) findViewById(R.id.login_header);

    //

    if (PrefsActivity.getCor(this).equals("Azul")) {
      lb.setBackgroundResource(R.color.background_softblue);
      lh.setBackgroundResource(R.drawable.background_azul1);

    } else if (PrefsActivity.getCor(this).equals("Vermelho")) {
      lb.setBackgroundResource(R.color.background_softred);
      lh.setBackgroundResource(R.drawable.background_vermelho1);

    } else if (PrefsActivity.getCor(this).equals("Verde")) {
      lb.setBackgroundResource(R.color.background_softgreen);
      lh.setBackgroundResource(R.drawable.background_verde1);
    }
  }
Example #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // android.util.Log.d("CHANEXPLORE", String.format("Mem class: %d",
    // ((android.app.ActivityManager)getSystemService( ACTIVITY_SERVICE )).getMemoryClass()));
    setContentView(R.layout.chanexplorer);
    ImageCache.initialize(this);

    isTablet = getResources().getBoolean(R.bool.isTablet);

    mNewPostView = (NewPostView) getLayoutInflater().inflate(R.layout.new_post, null);
    setBehindContentView(mNewPostView);
    mNewPostView.mSubmit.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (getHomeFragment().getCurrentPage() != 0) {
              getHomeFragment().getCurrentChanPage().uploadPost(mNewPostView);
            }
          }
        });
    mNewPostView.mBrowse.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent i =
                new Intent(
                    Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(i, REQ_CODE_PICK_IMAGE);
          }
        });
    getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
    getSlidingMenu().setShadowDrawable(R.drawable.shadow);
    getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
    getSlidingMenu().setSlidingEnabled(false);
    getSlidingMenu()
        .setOnCloseListener(
            new SlidingMenu.OnCloseListener() {

              @Override
              public void onClose() {
                mNewPostView.requestFocus();
                InputMethodManager imm =
                    (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromInputMethod(mNewPostView.getWindowToken(), 0);
                if (getHomeFragment().getCurrentPage() != 0)
                  mNewPostView.saveNewPost(getHomeFragment().getCurrentNewPost());
              }
            });
    getSlidingMenu()
        .setOnOpenListener(
            new SlidingMenu.OnOpenListener() {

              @Override
              public void onOpen() {
                if (getHomeFragment().getCurrentPage() != 0)
                  mNewPostView.setNewPost(
                      getHomeFragment().getCurrentChanPage().getBoard(),
                      getHomeFragment().getCurrentChanPage().getThreadId(),
                      getHomeFragment().getCurrentNewPost());
              }
            });

    mTheme = PrefsActivity.getTheme(this, false);
    getSupportActionBar().setLogo(mTheme.action_icon);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(mTheme.action_bar_bg));
    if (isTablet) {
      getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }
    invalidateOptionsMenu();

    mNewPostView.requestFocus();
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar()
        .setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);

    // ((PagerTitleStrip)findViewById(R.id.pager_title_strip)).setTextSize(TypedValue.COMPLEX_UNIT_SP,
    // 13);
    // ActionBar bar = getSupportActionBar();

    // bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // mTabsAdapter = new TabsAdapter(this, mViewPager);

    // mPurchaseDatabase = new PurchaseDatabase(this);
    // setupWidgets();

    // Check if billing is supported.

  }