Commit 99575cea authored by Thomas Krex's avatar Thomas Krex
Browse files

-datePicker im dialog für das hinzufügen der Feeds

-url wird durch eingestelltes datum erweitert mit "begindate="
-datepicker stellt sich am Anfang auf den Anfang des aktuellen Semesters ein
-Intent-Filter aktiviert, aber bisher auch bei podcast links aktiv
parent 07492c3a
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<intent-filter> <intent-filter>
<data android:scheme="http" /> <data android:scheme="http" />
<data android:host="ttt.in.tum.de" /> <data android:host="ttt.in.tum.de" />
<data android:pathPattern=".*"/> <data android:pathPattern="\\/lectures\\/.*"/>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
......
...@@ -26,26 +26,42 @@ ...@@ -26,26 +26,42 @@
android:hint="Name" android:hint="Name"
android:singleLine="true" /> android:singleLine="true" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tx_url"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp"
android:gravity="center_horizontal"
android:text="Suscribe to all Lectures since the following date"
android:textAppearance="?android:attr/textAppearanceMedium" />
<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:calendarViewShown="false" />
<Button <Button
android:id="@+id/button_save" android:id="@+id/button_paste"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignLeft="@+id/datePicker"
android:layout_below="@+id/tx_url" android:layout_alignParentBottom="true"
android:layout_marginRight="52dp" android:layout_marginBottom="18dp"
android:layout_marginTop="32dp" android:text="@string/paste_url" />
android:text="@string/save" >
</Button>
<Button <Button
android:id="@+id/button_paste" android:id="@+id/button_save"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button_save" android:layout_alignBaseline="@+id/button_paste"
android:layout_alignBottom="@+id/button_save" android:layout_alignBottom="@+id/button_paste"
android:layout_alignParentLeft="true" android:layout_alignRight="@+id/datePicker"
android:layout_marginLeft="58dp" android:text="@string/save" />
android:text="@string/paste_url" >
</Button>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
package tttclient.activities; package tttclient.activities;
import java.util.Calendar;
import tttclient.models.Feed; import tttclient.models.Feed;
import tttclient.models.FeedDbManager; import tttclient.models.FeedDbManager;
import tttclient.models.FeedItemDbManager; import tttclient.models.FeedItemDbManager;
...@@ -23,6 +25,7 @@ import android.widget.AdapterView; ...@@ -23,6 +25,7 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener; import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SimpleCursorAdapter; import android.widget.SimpleCursorAdapter;
...@@ -52,13 +55,18 @@ public class FeedActivity extends SherlockActivity implements ...@@ -52,13 +55,18 @@ public class FeedActivity extends SherlockActivity implements
private String feedUrl; private String feedUrl;
private String feedName; private String feedName;
private int feedId; private int feedId;
private Dialog addDialog; private Dialog addDialog;
EditText urlTxt; private EditText urlTxt;
EditText nameTxt; private EditText nameTxt;
private DatePicker datePicker;
private Button pasteButton;
private Button saveButton;
private Vibrator myVib; private Vibrator myVib;
private ListView feedLv; private ListView feedLv;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -99,9 +107,31 @@ public class FeedActivity extends SherlockActivity implements ...@@ -99,9 +107,31 @@ public class FeedActivity extends SherlockActivity implements
} }
}); });
datePicker= (DatePicker) addDialog.findViewById(R.id.datePicker);
//determine the current semester and set the spinner to its beginning
Calendar c = Calendar.getInstance();
int currMonth= c.get(Calendar.MONTH);
int year;
int month;
//winter semester
if(currMonth>=Calendar.OCTOBER || currMonth<Calendar.APRIL){
month =Calendar.OCTOBER;
if(currMonth>=Calendar.OCTOBER)
year=c.get(Calendar.YEAR);
else
year=c.get(Calendar.YEAR)-1;
}
//summer semester
else{
year=c.get(Calendar.YEAR);
month= Calendar.APRIL;
}
datePicker.init(year, month, 1, null);
// Button for pasting Url from the clipboard into the textfield // Button for pasting Url from the clipboard into the textfield
Button pasteButton = (Button) addDialog.findViewById(R.id.button_paste); pasteButton = (Button) addDialog.findViewById(R.id.button_paste);
pasteButton.setOnClickListener(new OnClickListener() { pasteButton.setOnClickListener(new OnClickListener() {
/** /**
...@@ -141,7 +171,7 @@ public class FeedActivity extends SherlockActivity implements ...@@ -141,7 +171,7 @@ public class FeedActivity extends SherlockActivity implements
} }
}); });
Button saveButton = (Button) addDialog.findViewById(R.id.button_save); saveButton = (Button) addDialog.findViewById(R.id.button_save);
saveButton.setOnClickListener(new OnClickListener() { saveButton.setOnClickListener(new OnClickListener() {
@Override @Override
...@@ -165,10 +195,15 @@ public class FeedActivity extends SherlockActivity implements ...@@ -165,10 +195,15 @@ public class FeedActivity extends SherlockActivity implements
return; return;
} }
// delete all whitespaces from ulr before inserting into the // delete all whitespaces from url before inserting into the
// database // database
url.replaceAll("\\s+", ""); url.replaceAll("\\s+", "");
String beginDate = "&begindate="+datePicker.getYear()+"_"+"0"+(datePicker.getMonth()+1)+"_"+"0"+datePicker.getDayOfMonth();
url=url +beginDate;
Log.d("FEED URL", url);
Feed feed = new Feed(name, url); Feed feed = new Feed(name, url);
FeedDbManager fm = new FeedDbManager(getParent()); FeedDbManager fm = new FeedDbManager(getParent());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment