Commit 99575cea by Thomas Krex

-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 @@
<intent-filter>
<data android:scheme="http" />
<data android:host="ttt.in.tum.de" />
<data android:pathPattern=".*"/>
<data android:pathPattern="\\/lectures\\/.*"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
......
......@@ -26,26 +26,42 @@
android:hint="Name"
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
android:id="@+id/button_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/tx_url"
android:layout_marginRight="52dp"
android:layout_marginTop="32dp"
android:text="@string/save" >
</Button>
android:id="@+id/button_paste"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/datePicker"
android:layout_alignParentBottom="true"
android:layout_marginBottom="18dp"
android:text="@string/paste_url" />
<Button
android:id="@+id/button_paste"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button_save"
android:layout_alignBottom="@+id/button_save"
android:layout_alignParentLeft="true"
android:layout_marginLeft="58dp"
android:text="@string/paste_url" >
</Button>
android:id="@+id/button_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button_paste"
android:layout_alignBottom="@+id/button_paste"
android:layout_alignRight="@+id/datePicker"
android:text="@string/save" />
</RelativeLayout>
\ No newline at end of file
package tttclient.activities;
import java.util.Calendar;
import tttclient.models.Feed;
import tttclient.models.FeedDbManager;
import tttclient.models.FeedItemDbManager;
......@@ -23,6 +25,7 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
......@@ -52,13 +55,18 @@ public class FeedActivity extends SherlockActivity implements
private String feedUrl;
private String feedName;
private int feedId;
private Dialog addDialog;
EditText urlTxt;
EditText nameTxt;
private EditText urlTxt;
private EditText nameTxt;
private DatePicker datePicker;
private Button pasteButton;
private Button saveButton;
private Vibrator myVib;
private ListView feedLv;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -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 pasteButton = (Button) addDialog.findViewById(R.id.button_paste);
pasteButton = (Button) addDialog.findViewById(R.id.button_paste);
pasteButton.setOnClickListener(new OnClickListener() {
/**
......@@ -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() {
@Override
......@@ -165,10 +195,15 @@ public class FeedActivity extends SherlockActivity implements
return;
}
// delete all whitespaces from ulr before inserting into the
// delete all whitespaces from url before inserting into the
// database
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);
FeedDbManager fm = new FeedDbManager(getParent());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment