/* * Copyright 2012 Tallinn University Centre for Educational Technology * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package ee.htk.dippler.app; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.text.Html; import android.text.method.LinkMovementMethod; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import ee.htk.dippler.app.entities.Comment; public class CommentDetailsActivity extends Activity implements OnClickListener { private Comment comment; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); comment = extras.getParcelable("dippler-task"); setContentView(R.layout.comment_detail_view); TextView task_title = (TextView) findViewById(R.id.post_title); task_title.setText(comment.getPostTitle()); TextView task_deadline = (TextView) findViewById(R.id.post_meta); task_deadline.setText(getString(R.string.by_author)+" "+comment.getCreator()+" "+getString(R.string.comment_on)+" "+comment.getCreatedDate()); TextView task_content = (TextView) findViewById(R.id.post_content); task_content.setText(Html.fromHtml(comment.getBody())); task_content.setMovementMethod(LinkMovementMethod.getInstance()); Button web_button = (Button) findViewById(R.id.comment_view_on_web); web_button.setOnClickListener(this); } @Override public void onClick(View v) { switch(v.getId()) { case R.id.comment_view_on_web: if ( comment != null ) { Intent open_url = new Intent(Intent.ACTION_VIEW, Uri.parse(comment.getUrl())); startActivity(open_url); } break; } } }