コード例 #1
0
ファイル: Submit.java プロジェクト: Econitex/Slide
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    getTheme().applyStyle(new ColorPreferences(this).getThemeSubreddit(""), true);

    getTheme().applyStyle(new FontPreferences(this).getFontStyle().getResId(), true);
    setContentView(R.layout.activity_submit);

    final Toolbar b = (Toolbar) findViewById(R.id.toolbar);
    b.setTitle(R.string.title_submit_post);
    b.setBackgroundColor(Pallete.getColor("alksfjalskjf"));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Window window = this.getWindow();
      window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.setStatusBarColor(Pallete.getDarkerColor(Pallete.getColor("asldkfj")));
    }
    setSupportActionBar(b);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();

    final String subreddit = intent.getStringExtra("subreddit");

    self = findViewById(R.id.selftext);
    subredditText = ((EditText) findViewById(R.id.subreddittext));
    image = findViewById(R.id.image);
    link = findViewById(R.id.url);

    image.setVisibility(View.GONE);
    link.setVisibility(View.GONE);

    subredditText.setText(subreddit);

    findViewById(R.id.selftextradio)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                self.setVisibility(View.VISIBLE);

                image.setVisibility(View.GONE);
                link.setVisibility(View.GONE);
              }
            });
    findViewById(R.id.imageradio)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                self.setVisibility(View.GONE);
                image.setVisibility(View.VISIBLE);
                link.setVisibility(View.GONE);
              }
            });
    findViewById(R.id.linkradio)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                self.setVisibility(View.GONE);
                image.setVisibility(View.GONE);
                link.setVisibility(View.VISIBLE);
              }
            });

    findViewById(R.id.selImage)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(
                    Intent.createChooser(intent, getString(R.string.editor_select_img)), 1);
              }
            });

    DoEditorActions.doActions(
        ((EditText) findViewById(R.id.bodytext)),
        findViewById(R.id.innersend2),
        getSupportFragmentManager());

    findViewById(R.id.send)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                ((FloatingActionButton) findViewById(R.id.send)).hide();
                new AsyncDo().execute();
              }
            });
  }
コード例 #2
0
ファイル: Sendmessage.java プロジェクト: Gilleland/Slide
  public void onCreate(Bundle savedInstanceState) {
    disableSwipeBackLayout();
    super.onCreate(savedInstanceState);
    applyColorTheme();
    setContentView(R.layout.activity_sendmessage);

    final Toolbar b = (Toolbar) findViewById(R.id.toolbar);
    final String name;
    reply = getIntent() != null && getIntent().hasExtra(EXTRA_REPLY);
    subject = (EditText) findViewById(R.id.subject);
    to = (EditText) findViewById(R.id.to);
    body = (EditText) findViewById(R.id.body);
    View oldMSG = findViewById(R.id.oldMSG);

    if (getIntent() != null && getIntent().hasExtra(EXTRA_NAME)) {
      name = getIntent().getExtras().getString(EXTRA_NAME, "");
      to.setText(name);
      to.setInputType(InputType.TYPE_NULL);

      if (reply) {
        b.setTitle(getString(R.string.mail_reply_to, name));
        previousMessage = DataShare.sharedMessage;
        subject.setText(getString(R.string.mail_re, previousMessage.getSubject()));
        subject.setInputType(InputType.TYPE_NULL);

        // Disable if replying to another user, as they are already set
        to.setEnabled(false);
        subject.setEnabled(false);

        body.requestFocus();

        oldMSG.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                AlertDialogWrapper.Builder b = new AlertDialogWrapper.Builder(Sendmessage.this);
                b.setTitle(getString(R.string.mail_author_wrote, name));
                b.setMessage(previousMessage.getBody());
                b.create().show();
              }
            });
      } else {
        b.setTitle(getString(R.string.mail_send_to, name));
        oldMSG.setVisibility(View.GONE);
      }
    } else {
      name = "";
      oldMSG.setVisibility(View.GONE);
      b.setTitle(R.string.mail_send);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Window window = this.getWindow();
      window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    }
    setupUserAppBar(R.id.toolbar, null, true, name);
    setRecentBar(b.getTitle().toString(), Palette.getDefaultColor());

    findViewById(R.id.send)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                bodytext = body.getText().toString();
                totext = to.getText().toString();
                subjecttext = subject.getText().toString();

                new AsyncDo().execute();
              }
            });
    DoEditorActions.doActions(
        ((EditText) findViewById(R.id.body)),
        findViewById(R.id.area),
        getSupportFragmentManager(),
        Sendmessage.this,
        previousMessage == null ? null : previousMessage.getBody());
  }