GingerCal 1.3: month view, Galician interface, Nginx Proxy Manager bridge option

This commit is contained in:
xocko committed 2026-10-15 17:42:46 +02:00
1 parent f44ecf4871
commit 42c3d6da91
39 files changed
+1409 -220

No files matched your search

+68 -27
View File
@@ -10,7 +10,9 @@ import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
@@ -41,39 +43,51 @@ public class EditActivity extends Activity {
@Override
protected void onCreate(Bundle b) {
super.onCreate(b);
long id = getIntent().getLongExtra("id", -1);
if (id >= 0) editing = Db.get(this).event(id);
setTitle(editing == null ? "New event" : "Edit event");
// Events come by value: month view can show events fetched live that aren't in the DB.
String href = getIntent().getStringExtra("href");
if (href != null) {
editing = new Ev();
editing.href = href;
editing.cal = str("cal");
editing.etag = str("etag");
editing.title = str("title");
editing.location = str("location");
editing.descr = str("descr");
editing.start = getIntent().getLongExtra("start", 0);
editing.end = getIntent().getLongExtra("end", 0);
editing.allDay = getIntent().getBooleanExtra("allDay", false);
}
setTitle(editing == null ? L.t("New event") : L.t("Edit event"));
for (Cal c : Db.get(this).calendarList()) if (c.enabled && c.writable) cals.add(c);
LinearLayout f = App.vbox(this);
int p = App.dp(this, 8);
f.setPadding(p, p, p, p);
title = field(f, "Title", false);
title = field(f, L.t("Title"), false);
allDay = new CheckBox(this);
allDay.setText("All day");
allDay.setText(L.t("All day"));
allDay.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
refresh();
}
});
f.addView(allDay);
f.addView(label("Starts"));
f.addView(label(L.t("Starts")));
startDate = new Button(this);
startTime = new Button(this);
f.addView(pair(startDate, startTime));
f.addView(label("Ends"));
f.addView(label(L.t("Ends")));
endDate = new Button(this);
endTime = new Button(this);
f.addView(pair(endDate, endTime));
location = field(f, "Location", false);
notes = field(f, "Notes", true);
location = field(f, L.t("Location"), false);
notes = field(f, L.t("Notes"), true);
alarmBtn = new Button(this);
f.addView(alarmBtn, new LinearLayout.LayoutParams(-1, -2));
calBtn = new Button(this);
f.addView(calBtn, new LinearLayout.LayoutParams(-1, -2));
save = new Button(this);
save.setText("Save");
save.setText(L.t("Save"));
f.addView(save, new LinearLayout.LayoutParams(-1, -2));
ScrollView sv = new ScrollView(this);
sv.addView(f);
@@ -117,7 +131,15 @@ public class EditActivity extends Activity {
if (editing == null) {
long now = System.currentTimeMillis();
start.setTimeInMillis(now - now % ICal.HOUR + ICal.HOUR);
long day = getIntent().getLongExtra("day", -1);
if (day >= 0 && day != ICal.startOfDay(now)) {
start.setTimeInMillis(day); // a day picked in the month view: 09:00 there
start.set(Calendar.HOUR_OF_DAY, 9);
} else {
start.setTimeInMillis(now); // next full hour
start.add(Calendar.HOUR_OF_DAY, 1);
}
start.set(Calendar.MINUTE, 0);
start.set(Calendar.SECOND, 0);
start.set(Calendar.MILLISECOND, 0);
end.setTimeInMillis(start.getTimeInMillis() + ICal.HOUR);
@@ -134,6 +156,25 @@ public class EditActivity extends Activity {
}
}
String str(String k) {
String v = getIntent().getStringExtra(k);
return v == null ? "" : v;
}
static Intent editIntent(Context c, Ev e) {
Intent i = new Intent(c, EditActivity.class);
i.putExtra("href", e.href);
i.putExtra("cal", e.cal);
i.putExtra("etag", e.etag);
i.putExtra("title", e.title);
i.putExtra("location", e.location);
i.putExtra("descr", e.descr);
i.putExtra("start", e.start);
i.putExtra("end", e.end);
i.putExtra("allDay", e.allDay);
return i;
}
EditText field(LinearLayout f, String hint, boolean multi) {
EditText e = new EditText(this);
e.setHint(hint);
@@ -181,10 +222,10 @@ public class EditActivity extends Activity {
endTime.setText(App.time(this, end.getTimeInMillis()));
startTime.setVisibility(ad ? View.GONE : View.VISIBLE);
endTime.setVisibility(ad ? View.GONE : View.VISIBLE);
alarmBtn.setText("Alarm: " + App.alarmLabel(alarm));
alarmBtn.setText(L.f("Alarm: %s", App.alarmLabel(alarm)));
String name = "?";
for (Cal c : Db.get(this).calendarList()) if (c.href.equals(calHref)) name = c.name;
calBtn.setText("Calendar: " + name);
calBtn.setText(L.f("Calendar: %s", name));
}
void pickDate(final Calendar c, final boolean isStart) {
@@ -214,7 +255,7 @@ public class EditActivity extends Activity {
void pickAlarm() {
String[] labels = new String[App.ALARMS.length];
for (int i = 0; i < labels.length; i++) labels[i] = App.alarmLabel(App.ALARMS[i]);
new AlertDialog.Builder(this).setTitle("Alarm (saved in the event)")
new AlertDialog.Builder(this).setTitle(L.t("Alarm (saved in the event)"))
.setItems(labels, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int w) {
alarm = App.ALARMS[w];
@@ -226,7 +267,7 @@ public class EditActivity extends Activity {
void pickCalendar() {
String[] names = new String[cals.size()];
for (int i = 0; i < names.length; i++) names[i] = cals.get(i).name;
new AlertDialog.Builder(this).setTitle("Calendar")
new AlertDialog.Builder(this).setTitle(L.t("Calendar"))
.setItems(names, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int w) {
calHref = cals.get(w).href;
@@ -250,15 +291,15 @@ public class EditActivity extends Activity {
e = end.getTimeInMillis() - end.getTimeInMillis() % 60000L;
}
if (e < s || (ad && e <= s)) {
App.toast(this, "The end is before the start.");
App.toast(this, L.t("The end is before the start."));
return;
}
if (calHref == null) {
App.toast(this, "No writable calendar. Sync first.");
App.toast(this, L.t("No writable calendar. Sync first."));
return;
}
String t = txt(title);
new SaveTask(t.length() > 0 ? t : "(no title)", txt(location), notes.getText().toString().trim(), s, e, ad).execute();
new SaveTask(t.length() > 0 ? t : L.t("(no title)"), txt(location), notes.getText().toString().trim(), s, e, ad).execute();
}
// ----------------------------------------------------------- network
@@ -268,7 +309,7 @@ public class EditActivity extends Activity {
@Override
protected void onPreExecute() {
pd = ProgressDialog.show(EditActivity.this, null, "Loading…");
pd = ProgressDialog.show(EditActivity.this, null, L.t("Loading\u2026"));
}
@Override
@@ -291,19 +332,19 @@ public class EditActivity extends Activity {
} catch (RuntimeException ignored) {
}
if (r instanceof Throwable) {
fail("Can't load event", App.describe((Throwable) r));
fail(L.t("Can't load event"), App.describe((Throwable) r));
return;
}
String[] got = (String[]) r;
ics = got[0];
etag = got[1] != null ? got[1] : editing.etag;
if (ICal.isRecurring(ics)) {
fail("Repeating event", "Repeating events can't be edited on the phone yet. Edit the series in Nextcloud.");
fail(L.t("Repeating event"), L.t("Repeating events can't be edited on the phone yet. Edit the series in Nextcloud."));
return;
}
List<ICal.VEvent> vs = ICal.parse(ics);
if (vs.isEmpty()) {
fail("Can't edit", "The server returned no event data.");
fail(L.t("Can't edit"), L.t("The server returned no event data."));
return;
}
ICal.VEvent v = vs.get(0);
@@ -316,7 +357,7 @@ public class EditActivity extends Activity {
void fail(String t, String msg) {
new AlertDialog.Builder(this).setTitle(t).setMessage(msg)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
.setPositiveButton(L.t("OK"), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int w) {
finish();
}
@@ -340,7 +381,7 @@ public class EditActivity extends Activity {
@Override
protected void onPreExecute() {
pd = ProgressDialog.show(EditActivity.this, null, "Saving…");
pd = ProgressDialog.show(EditActivity.this, null, L.t("Saving\u2026"));
}
@Override
@@ -370,13 +411,13 @@ public class EditActivity extends Activity {
} catch (RuntimeException ignored) {
}
if (x != null) {
new AlertDialog.Builder(EditActivity.this).setTitle("Not saved")
.setMessage(App.describe(x)).setPositiveButton("OK", null).show();
new AlertDialog.Builder(EditActivity.this).setTitle(L.t("Not saved"))
.setMessage(App.describe(x)).setPositiveButton(L.t("OK"), null).show();
return;
}
if (editing == null) App.prefs(EditActivity.this).edit().putString("defcal", calHref).commit();
App.requestSync(EditActivity.this, true, false);
App.toast(EditActivity.this, "Saved");
App.toast(EditActivity.this, L.t("Saved"));
finish();
}
}