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

+51 -33
View File
@@ -6,6 +6,7 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
@@ -20,33 +21,33 @@ import org.gingercal.Model.Cal;
/** Account, TLS pin, sync interval and reminder settings. */
public class SettingsActivity extends Activity {
EditText url, user, pass, pin, ahead;
Button intervalBtn, remindBtn;
Button intervalBtn, remindBtn, langBtn;
int interval, remind;
@Override
protected void onCreate(Bundle b) {
super.onCreate(b);
setTitle("GingerCal settings");
setTitle(L.t("GingerCal settings"));
LinearLayout f = App.vbox(this);
int p = App.dp(this, 8);
f.setPadding(p, p, p, p);
f.addView(App.text(this, "Nextcloud server. Android 2.3 can't speak TLS 1.2, so use either your "
+ "legacy-TLS bridge (https://cloud.example.com:8443) or http:// to the server on your home "
+ "Wi-Fi. Use an app password, not your real one.", 12, 0xFFB0BEC5));
url = field(f, "Server address", "https://cloud.example.com:8443", 1 | 0x10 /* URI */);
user = field(f, "User name", "", 1 | 0x80000 /* no suggestions */);
pass = field(f, "App password", "", 1 | 0x80 /* password */);
pin = field(f, "Pinned certificate SHA-256 (filled in for you)", "optional", 1 | 0x80000);
ahead = field(f, "Days ahead to sync", "60", 2 /* number */);
f.addView(App.text(this, L.t("Nextcloud server. Android 2.3 can't speak TLS 1.2, so use either your legacy-TLS bridge (https://cloud.example.com:8443) or http:// to the server on your home Wi-Fi. Use an app password, not your real one."), 12, 0xFFB0BEC5));
url = field(f, L.t("Server address"), "https://cloud.example.com:8443", 1 | 0x10 /* URI */);
user = field(f, L.t("User name"), "", 1 | 0x80000 /* no suggestions */);
pass = field(f, L.t("App password"), "", 1 | 0x80 /* password */);
pin = field(f, L.t("Pinned certificate SHA-256 (filled in for you)"), L.t("optional"), 1 | 0x80000);
ahead = field(f, L.t("Days ahead to sync"), "60", 2 /* number */);
intervalBtn = new Button(this);
f.addView(intervalBtn, new LinearLayout.LayoutParams(-1, -2));
remindBtn = new Button(this);
f.addView(remindBtn, new LinearLayout.LayoutParams(-1, -2));
langBtn = new Button(this);
f.addView(langBtn, new LinearLayout.LayoutParams(-1, -2));
Button test = new Button(this);
test.setText("Save and test connection");
test.setText(L.t("Save and test connection"));
f.addView(test, new LinearLayout.LayoutParams(-1, -2));
Button resync = new Button(this);
resync.setText("Re-download everything");
resync.setText(L.t("Re-download everything"));
f.addView(resync, new LinearLayout.LayoutParams(-1, -2));
ScrollView sv = new ScrollView(this);
sv.addView(f);
@@ -65,7 +66,7 @@ public class SettingsActivity extends Activity {
public void onClick(View v) {
final String[] l = new String[App.INTERVALS.length];
for (int i = 0; i < l.length; i++) l[i] = intervalLabel(App.INTERVALS[i]);
new AlertDialog.Builder(SettingsActivity.this).setTitle("Background sync")
new AlertDialog.Builder(SettingsActivity.this).setTitle(L.t("Background sync"))
.setItems(l, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int w) {
interval = App.INTERVALS[w];
@@ -78,8 +79,8 @@ public class SettingsActivity extends Activity {
public void onClick(View v) {
final int[] opts = {-1, 0, 5, 10, 15, 30, 60};
String[] l = new String[opts.length];
for (int i = 0; i < l.length; i++) l[i] = opts[i] < 0 ? "Off" : App.alarmLabel(opts[i]);
new AlertDialog.Builder(SettingsActivity.this).setTitle("Phone notification")
for (int i = 0; i < l.length; i++) l[i] = opts[i] < 0 ? L.t("Off") : App.alarmLabel(opts[i]);
new AlertDialog.Builder(SettingsActivity.this).setTitle(L.t("Phone notification"))
.setItems(l, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int w) {
remind = opts[w];
@@ -88,6 +89,22 @@ public class SettingsActivity extends Activity {
}).show();
}
});
langBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new AlertDialog.Builder(SettingsActivity.this).setTitle("Lingua / Language")
.setItems(new String[] {"Galego", "English"}, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int w) {
boolean toGl = w == 0;
if (toGl == L.gl) return;
save();
App.prefs(SettingsActivity.this).edit().putString("lang", toGl ? "gl" : "en").commit();
L.gl = toGl;
finish(); // reopen so every label is redrawn in the new language
startActivity(new Intent(SettingsActivity.this, SettingsActivity.class));
}
}).show();
}
});
test.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
confirmAndTest();
@@ -98,7 +115,7 @@ public class SettingsActivity extends Activity {
save();
Db.get(SettingsActivity.this).forgetSyncState();
App.requestSync(SettingsActivity.this, true, true);
App.toast(SettingsActivity.this, "Re-downloading in the background");
App.toast(SettingsActivity.this, L.t("Re-downloading in the background"));
finish();
}
});
@@ -117,12 +134,13 @@ public class SettingsActivity extends Activity {
}
static String intervalLabel(int h) {
return h == 0 ? "Manual only" : h == 1 ? "Every hour" : "Every " + h + " hours";
return h == 0 ? L.t("Manual only") : h == 1 ? L.t("Every hour") : L.f("Every %d hours", h);
}
void labels() {
intervalBtn.setText("Background sync: " + intervalLabel(interval));
remindBtn.setText("Notify: " + (remind < 0 ? "off" : App.alarmLabel(remind)));
intervalBtn.setText(L.f("Background sync: %s", intervalLabel(interval)));
remindBtn.setText(L.f("Notification: %s", remind < 0 ? L.t("off") : App.alarmLabel(remind)));
langBtn.setText(L.f("Language: %s", L.gl ? "Galego" : "English"));
}
static String txt(TextView t) {
@@ -155,7 +173,8 @@ public class SettingsActivity extends Activity {
.commit();
if (!oldAccount.equals(u + "|" + txt(user))) {
Db.get(this).clearAll();
App.prefs(this).edit().putLong("lastsync", 0).putString("status", "").commit();
App.prefs(this).edit().putLong("lastsync", 0).putLong("win_from", 0).putLong("win_to", 0)
.putString("status", "").commit();
}
App.scheduleSync(this);
Reminders.schedule(this);
@@ -164,20 +183,19 @@ public class SettingsActivity extends Activity {
void confirmAndTest() {
String u = txt(url);
if (u.length() == 0 || txt(user).length() == 0) {
App.toast(this, "Server address and user name are required.");
App.toast(this, L.t("Server address and user name are required."));
return;
}
if (Dav.normalize(u).startsWith("http://") && !App.isLan(u)) {
new AlertDialog.Builder(this).setTitle("Unencrypted connection")
.setMessage("http:// sends your password in clear text over the internet. Use the legacy-TLS "
+ "bridge instead, or only use http:// to a LAN address.")
.setPositiveButton("Use anyway", new DialogInterface.OnClickListener() {
new AlertDialog.Builder(this).setTitle(L.t("Unencrypted connection"))
.setMessage(L.t("http:// sends your password in clear text over the internet. Use the legacy-TLS bridge instead, or only use http:// to a LAN address."))
.setPositiveButton(L.t("Use anyway"), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int w) {
save();
new TestTask().execute();
}
})
.setNegativeButton("Cancel", null).show();
.setNegativeButton(L.t("Cancel"), null).show();
return;
}
save();
@@ -189,7 +207,7 @@ public class SettingsActivity extends Activity {
@Override
protected void onPreExecute() {
pd = ProgressDialog.show(SettingsActivity.this, null, "Connecting…");
pd = ProgressDialog.show(SettingsActivity.this, null, L.t("Connecting\u2026"));
}
@Override
@@ -223,16 +241,16 @@ public class SettingsActivity extends Activity {
return;
}
if (r instanceof Throwable) {
new AlertDialog.Builder(SettingsActivity.this).setTitle("Connection failed")
.setMessage(App.describe((Throwable) r)).setPositiveButton("OK", null).show();
new AlertDialog.Builder(SettingsActivity.this).setTitle(L.t("Connection failed"))
.setMessage(App.describe((Throwable) r)).setPositiveButton(L.t("OK"), null).show();
return;
}
List<Cal> cals = (List<Cal>) r;
StringBuilder s = new StringBuilder("Connected. Found " + cals.size() + " calendar(s):\n");
for (Cal c : cals) s.append("\n• ").append(c.name).append(c.writable ? "" : " (read-only)");
new AlertDialog.Builder(SettingsActivity.this).setTitle("It works")
StringBuilder s = new StringBuilder(L.f("Connected. Calendars found: %d\n", cals.size()));
for (Cal c : cals) s.append("\n\u2022 ").append(c.name).append(c.writable ? "" : " " + L.t("(read-only)"));
new AlertDialog.Builder(SettingsActivity.this).setTitle(L.t("It works"))
.setMessage(s.toString())
.setPositiveButton("Sync now", new DialogInterface.OnClickListener() {
.setPositiveButton(L.t("Sync now"), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int w) {
App.requestSync(SettingsActivity.this, true, false);
finish();