Added WebView activity for all notifications

git-svn-id: https://forja.rediris.es/svn/cusl6-swadroid/trunk@242 5bc14d19-1e4b-4ba2-aa50-860af135f48c
This commit is contained in:
Juan Miguel Boyero Corral 2012-02-25 21:43:29 +00:00
parent 8509e5a7f8
commit 983b6a3a9b
8 changed files with 186 additions and 110 deletions

View File

@ -25,7 +25,7 @@
<activity android:label="@string/testsModuleLabel" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:name=".modules.tests.TestsQuestionsDownload"><activity android:label="@string/testsModuleLabel" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:name=".modules.tests.TestsQuestionsDownload"></activity></activity>
<activity android:name=".modules.tests.TestsConfigDownload" android:label="@string/testsModuleLabel" android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity><activity android:theme="@android:style/Theme.NoTitleBar" android:label="@string/testsModuleLabel" android:configChanges="orientation" android:name=".modules.tests.TestsMake"></activity>
<activity android:theme="@android:style/Theme.Translucent.NoTitleBar" android:name=".modules.Messages" android:label="@string/messagesModuleLabel" android:configChanges="keyboard|keyboardHidden|orientation"></activity>
<activity android:name=".modules.notifications.Marks" android:theme="@android:style/Theme.NoTitleBar" android:label="@string/notificationsModuleLabel"></activity>
<activity android:name=".modules.notifications.NotificationItem" android:theme="@android:style/Theme.NoTitleBar" android:label="@string/notificationsModuleLabel"></activity>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

View File

@ -68,7 +68,9 @@ public final class R {
}
public static final class id {
public static final int actionBarLayout=0x7f090000;
public static final int clean_database_menu=0x7f090039;
public static final int clean_database_menu=0x7f09003d;
public static final int contentWebView=0x7f090022;
public static final int courseNameText=0x7f090020;
public static final int decrement=0x7f09001e;
public static final int eventContent=0x7f090017;
public static final int eventDate=0x7f090013;
@ -92,36 +94,38 @@ public final class R {
public static final int moduleIcon=0x7f090001;
public static final int moduleName=0x7f090002;
public static final int notificationIcon=0x7f090012;
public static final int preferences_menu=0x7f09003a;
public static final int rate_menu=0x7f090038;
public static final int preferences_menu=0x7f09003e;
public static final int rate_menu=0x7f09003c;
public static final int refresh=0x7f090008;
public static final int share_menu=0x7f090037;
public static final int testAnswerTypesAcceptButton=0x7f090021;
public static final int testAnswerTypesList=0x7f090020;
public static final int testAnswerTypesText=0x7f09001f;
public static final int senderNameText=0x7f09001f;
public static final int share_menu=0x7f09003b;
public static final int summaryText=0x7f090021;
public static final int testAnswerTypesAcceptButton=0x7f090025;
public static final int testAnswerTypesList=0x7f090024;
public static final int testAnswerTypesText=0x7f090023;
public static final int testEvaluateButton=0x7f090006;
public static final int testMakeAnswer=0x7f090025;
public static final int testMakeBottomBar=0x7f09002a;
public static final int testMakeCorrectAnswer=0x7f090028;
public static final int testMakeCorrectAnswerImage=0x7f090026;
public static final int testMakeEditText=0x7f090027;
public static final int testMakeList=0x7f090029;
public static final int testMakeNextButton=0x7f09002d;
public static final int testMakePrevButton=0x7f09002b;
public static final int testMakeQuestionScore=0x7f090023;
public static final int testMakeStem=0x7f090022;
public static final int testMakeText=0x7f090024;
public static final int testNumQuestionsAcceptButton=0x7f090033;
public static final int testNumQuestionsNumberPicker=0x7f090030;
public static final int testNumQuestionsText=0x7f090032;
public static final int testResultsButton=0x7f090031;
public static final int testResultsScore=0x7f09002f;
public static final int testResultsText=0x7f09002e;
public static final int testMakeAnswer=0x7f090029;
public static final int testMakeBottomBar=0x7f09002e;
public static final int testMakeCorrectAnswer=0x7f09002c;
public static final int testMakeCorrectAnswerImage=0x7f09002a;
public static final int testMakeEditText=0x7f09002b;
public static final int testMakeList=0x7f09002d;
public static final int testMakeNextButton=0x7f090031;
public static final int testMakePrevButton=0x7f09002f;
public static final int testMakeQuestionScore=0x7f090027;
public static final int testMakeStem=0x7f090026;
public static final int testMakeText=0x7f090028;
public static final int testNumQuestionsAcceptButton=0x7f090037;
public static final int testNumQuestionsNumberPicker=0x7f090034;
public static final int testNumQuestionsText=0x7f090036;
public static final int testResultsButton=0x7f090035;
public static final int testResultsScore=0x7f090033;
public static final int testResultsText=0x7f090032;
public static final int testShowResultsButton=0x7f090004;
public static final int testTagsAcceptButton=0x7f090036;
public static final int testTagsList=0x7f090035;
public static final int testTagsText=0x7f090034;
public static final int test_questions_bar=0x7f09002c;
public static final int testTagsAcceptButton=0x7f09003a;
public static final int testTagsList=0x7f090039;
public static final int testTagsText=0x7f090038;
public static final int test_questions_bar=0x7f090030;
public static final int timepicker_input=0x7f09001d;
public static final int title_sep_1=0x7f090007;
public static final int title_sep_2=0x7f090005;
@ -139,11 +143,12 @@ public final class R {
public static final int notifications_list_item=0x7f030008;
public static final int number_picker=0x7f030009;
public static final int simple_list_item=0x7f03000a;
public static final int tests_answer_types=0x7f03000b;
public static final int tests_make_questions=0x7f03000c;
public static final int tests_make_results=0x7f03000d;
public static final int tests_num_questions=0x7f03000e;
public static final int tests_tags=0x7f03000f;
public static final int single_notification_view=0x7f03000b;
public static final int tests_answer_types=0x7f03000c;
public static final int tests_make_questions=0x7f03000d;
public static final int tests_make_results=0x7f03000e;
public static final int tests_num_questions=0x7f03000f;
public static final int tests_tags=0x7f030010;
}
public static final class menu {
public static final int menu_main=0x7f080000;

View File

@ -33,7 +33,7 @@
<ImageView
android:id="@+id/title_sep_3"
android:layout_toLeftOf="@+id/testShowResultsButton"
android:layout_width="1px"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_alignParentTop="true"
@ -62,7 +62,7 @@
<ImageView
android:id="@+id/title_sep_2"
android:layout_toLeftOf="@+id/testEvaluateButton"
android:layout_width="1px"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_alignParentTop="true"
@ -91,7 +91,7 @@
<ImageView
android:id="@+id/title_sep_1"
android:layout_toLeftOf="@+id/refresh"
android:layout_width="1px"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_alignParentTop="true"

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical" >
<include layout="@layout/action_bar"/>
<TextView
android:id="@+id/senderNameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/foreground1"
android:textStyle="italic"
android:textSize="16sp"
android:layout_marginLeft="9dip" >
</TextView>
<TextView
android:id="@+id/courseNameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/foreground1"
android:textStyle="italic"
android:textSize="16sp"
android:layout_marginLeft="9dip" />
<TextView
android:id="@+id/summaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/foreground1"
android:textStyle="bold"
android:textSize="16sp"
android:layout_marginLeft="9dip" />
<WebView
android:id="@+id/contentWebView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -1,44 +0,0 @@
/*
* This file is part of SWADroid.
*
* Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
*
* SWADroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SWADroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SWADroid. If not, see <http://www.gnu.org/licenses/>.
*/
package es.ugr.swad.swadroid.modules.notifications;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView;
/**
* Webview activity for showing marks
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
*/
public class Marks extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webview = new WebView(this);
setContentView(webview);
String content = this.getIntent().getStringExtra("content");
webview.getSettings().setRenderPriority(RenderPriority.HIGH);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webview.loadDataWithBaseURL("", content, "text/html", "utf-8", "");
}
}

View File

@ -0,0 +1,74 @@
/*
* This file is part of SWADroid.
*
* Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
*
* SWADroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SWADroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SWADroid. If not, see <http://www.gnu.org/licenses/>.
*/
package es.ugr.swad.swadroid.modules.notifications;
import es.ugr.swad.swadroid.MenuActivity;
import es.ugr.swad.swadroid.R;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Webview activity for showing marks
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
*/
public class NotificationItem extends MenuActivity {
private String fixLinks(String body) {
String regex = "(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
body = body.replaceAll(regex, "<a href=\"$0\">$0</a>");
return body;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
TextView text, senderTextView, courseTextView, summaryTextView;
ImageView image;
WebView webview;
String sender = this.getIntent().getStringExtra("sender");
String course = this.getIntent().getStringExtra("course");
String summary = this.getIntent().getStringExtra("summary");
String content = this.getIntent().getStringExtra("content");
super.onCreate(savedInstanceState);
setContentView(R.layout.single_notification_view);
senderTextView = (TextView)this.findViewById(R.id.senderNameText);
courseTextView = (TextView)this.findViewById(R.id.courseNameText);
summaryTextView = (TextView)this.findViewById(R.id.summaryText);
webview = (WebView)this.findViewById(R.id.contentWebView);
image = (ImageView)this.findViewById(R.id.moduleIcon);
image.setBackgroundResource(R.drawable.notif);
text = (TextView)this.findViewById(R.id.moduleName);
text.setText(R.string.notificationsModuleLabel);
senderTextView.setText(sender);
courseTextView.setText(course);
summaryTextView.setText(summary);
content = fixLinks(content);
webview.getSettings().setRenderPriority(RenderPriority.HIGH);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webview.loadDataWithBaseURL("", content, "text/html", "utf-8", "");
}
}

View File

@ -49,7 +49,6 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
/**
* Notifications module for get user's notifications
@ -118,8 +117,21 @@ public class Notifications extends Module {
TextView text;
ListView list;
OnItemClickListener clickListener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> av, View v, int position, long rowId) {
adapter.toggleContentVisibility(position);
public void onItemClick(AdapterView<?> av, View v, int position, long rowId)
{
//adapter.toggleContentVisibility(position);
TextView sender = (TextView) v.findViewById(R.id.eventSender);
TextView course = (TextView) v.findViewById(R.id.eventLocation);
TextView summary = (TextView) v.findViewById(R.id.eventSummary);
TextView content = (TextView) v.findViewById(R.id.eventText);
Intent activity = new Intent(getApplicationContext(), NotificationItem.class);
activity.putExtra("sender", sender.getText().toString());
activity.putExtra("course", course.getText().toString());
activity.putExtra("summary", summary.getText().toString());
activity.putExtra("content", content.getText().toString());
startActivity(activity);
}
};
@ -165,7 +177,7 @@ public class Notifications extends Module {
* @param v Actual view
*/
public void onRefreshClick(View v)
{
{
runConnection();
}
@ -218,8 +230,8 @@ public class Notifications extends Module {
SWADNotification n = new SWADNotification(notificationCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, location, summary, status, content);
dbHelper.insertNotification(n);
if(isDebuggable)
Log.d(TAG, n.toString());
/*if(isDebuggable)
Log.d(TAG, n.toString());*/
}
//Request finalized without errors
@ -278,7 +290,7 @@ public class Notifications extends Module {
@Override
protected void connect() {
String progressDescription = getString(R.string.notificationsProgressDescription);
int progressTitle = R.string.notificationsProgressTitle;
int progressTitle = R.string.notificationsProgressTitle;
new Connect(true, progressDescription, progressTitle).execute();
}
@ -287,9 +299,9 @@ public class Notifications extends Module {
* @see es.ugr.swad.swadroid.modules.Module#postConnect()
*/
@Override
protected void postConnect() {
protected void postConnect() {
refreshScreen();
Toast.makeText(this, R.string.notificationsDownloadedMsg, Toast.LENGTH_SHORT).show();
//Toast.makeText(this, R.string.notificationsDownloadedMsg, Toast.LENGTH_SHORT).show();
alertNotif();
}

View File

@ -76,9 +76,9 @@ public class NotificationsCursorAdapter extends CursorAdapter {
public void bindView(View view, Context context, Cursor cursor) {
final Context ctx = context;
final Long notificationCode = cursor.getLong(cursor.getColumnIndex("id"));
final Cursor curs = cursor;
long unixTime;
String type, sender, senderFirstname, senderSurname1, senderSurname2, summaryText, contentText;
String type, sender, senderFirstname, senderSurname1, senderSurname2, summaryText;
String contentText;
String[] dateContent;
Date d;
int numRows = cursor.getCount();
@ -107,18 +107,6 @@ public class NotificationsCursorAdapter extends CursorAdapter {
}
};
OnClickListener contentListener = new OnClickListener() {
public void onClick(View v) {
TextView content = (TextView) v.findViewById(R.id.eventText);
if(content.getSelectionStart() == -1 && content.getSelectionEnd() == -1) {
toggleContentVisibility(curs.getPosition());
}
}
};
content.setOnClickListener(contentListener);
if(eventType != null) {
type = cursor.getString(cursor.getColumnIndex("eventType"));
messageReplyButton.setVisibility(View.GONE);
@ -225,23 +213,22 @@ public class NotificationsCursorAdapter extends CursorAdapter {
* If the notification is a mark, launches a WebView activity to show it
* @param position Notification position in the ListView
*/
public void toggleContentVisibility(int position) {
/*public void toggleContentVisibility(int position) {
String viewType, marksType;
View view = this.getView(position, null, null);
TextView eventType = (TextView) view.findViewById(R.id.eventType);
TextView content = (TextView) view.findViewById(R.id.eventText);
viewType = String.valueOf(eventType.getText());
marksType = ctx.getString(R.string.marksFile);
if(viewType.equals(marksType)) {
TextView content = (TextView) view.findViewById(R.id.eventText);
Intent activity = new Intent(ctx.getApplicationContext(), Marks.class);
if(viewType.equals(marksType)) {
Intent activity = new Intent(ctx.getApplicationContext(), NotificationItem.class);
activity.putExtra("content", content.getText().toString());
ctx.startActivity(activity);
} else {
contentVisible[position] = !contentVisible[position];
this.notifyDataSetChanged();
}
}
}*/
}