Før effektivisering

This commit is contained in:
ErolHaagenrud 2025-12-19 06:58:34 +01:00
parent 845ccf22c2
commit f4cd9603fa
9 changed files with 117 additions and 5771 deletions

View file

@ -1,11 +1,14 @@
package com.kbs.kbsintranett;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -64,18 +67,50 @@ public class CalendarDetailsBottomSheet extends BottomSheetDialogFragment {
calName.setBackgroundTintList(ColorStateList.valueOf(color));
} catch (Exception e) {}
// --- BESKRIVELSE OG LENKER ---
if (!event.getDescription().isEmpty()) {
String cleanDesc = event.getDescription().replaceAll("#varsel:[\\d,]+", "").trim();
// Konverter HTML til Spannable
desc.setText(Html.fromHtml(cleanDesc, Html.FROM_HTML_MODE_COMPACT));
desc.setVisibility(View.VISIBLE);
// Sørg for at rene tekst-lenker (uten <a href>) også blir klikkbare
Linkify.addLinks(desc, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
// Gjør at man kan klikke lenkene
desc.setMovementMethod(LinkMovementMethod.getInstance());
desc.setVisibility(View.VISIBLE);
} else {
desc.setVisibility(View.GONE);
}
// --- ADRESSE OG KART ---
if (!event.getLocation().isEmpty()) {
loc.setText("Sted: " + event.getLocation());
loc.setText(event.getLocation()); // Viser kun teksten, ikonet ligger i XML
loc.setVisibility(View.VISIBLE);
// Gjør adressen klikkbar for å åpne kart
loc.setOnClickListener(v -> {
String location = event.getLocation();
// Opprett en geo-URI. "q=" søker etter stedet.
Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + Uri.encode(location));
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
// Sett pakke til Google Maps for å foretrekke det, men la systemet velge hvis ikke installert
mapIntent.setPackage("com.google.android.apps.maps");
try {
startActivity(mapIntent);
} catch (Exception e) {
// Fallback: Hvis Google Maps ikke finnes, prøv uten pakkenavn (hvilken som helst kart-app)
mapIntent.setPackage(null);
try {
startActivity(mapIntent);
} catch (Exception ex) {
Toast.makeText(getContext(), "Fant ingen kart-app", Toast.LENGTH_SHORT).show();
}
}
});
} else {
loc.setVisibility(View.GONE);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 B

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 395 B

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 895 B

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -7,7 +7,7 @@
android:padding="24dp"
android:background="@android:color/white">
<!-- NYTT: Kalendernavn (Lite merke øverst) -->
<!-- Kalendernavn (Lite merke øverst) -->
<TextView
android:id="@+id/sheet_calendar_name"
android:layout_width="wrap_content"
@ -38,20 +38,34 @@
android:text="Tidspunkt"
android:textSize="16sp"
android:textColor="@color/kbs_muted_blue_gray"
android:layout_marginBottom="16dp"
android:layout_marginBottom="12dp"
android:drawablePadding="8dp"
app:drawableStartCompat="@android:drawable/ic_menu_recent_history"/>
<!--
ENDRET: Lagt til kart-ikon, blå tekstfarge, og gjort den klikkbar visuelt
med background="?attr/selectableItemBackground"
-->
<TextView
android:id="@+id/sheet_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sted"
android:textSize="16sp"
android:textColor="#333"
android:textColor="@color/kbs_logo_blue"
android:textStyle="bold"
android:layout_marginBottom="16dp"
android:visibility="gone"/>
android:visibility="gone"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:background="?attr/selectableItemBackground"
android:paddingVertical="8dp"
app:drawableStartCompat="@android:drawable/ic_dialog_map"/>
<!--
ENDRET: Lagt til autoLink for web, email og phone
Dette hjelper TextView å forstå linker automatisk
-->
<TextView
android:id="@+id/sheet_desc"
android:layout_width="match_parent"
@ -59,7 +73,9 @@
android:text="Beskrivelse..."
android:textSize="14sp"
android:textColor="#555"
android:layout_marginBottom="24dp"/>
android:layout_marginBottom="24dp"
android:autoLink="web|email|phone"
android:linksClickable="true"/>
<!-- ADMIN KNAPPER (Vises kun for admin) -->
<LinearLayout

View file

@ -598,11 +598,14 @@ FILSTI: app\src\main\java\com\kbs\kbsintranett\CalendarDetailsBottomSheet.java
package com.kbs.kbsintranett;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -661,18 +664,50 @@ public class CalendarDetailsBottomSheet extends BottomSheetDialogFragment {
calName.setBackgroundTintList(ColorStateList.valueOf(color));
} catch (Exception e) {}
// --- BESKRIVELSE OG LENKER ---
if (!event.getDescription().isEmpty()) {
String cleanDesc = event.getDescription().replaceAll("#varsel:[\\d,]+", "").trim();
// Konverter HTML til Spannable
desc.setText(Html.fromHtml(cleanDesc, Html.FROM_HTML_MODE_COMPACT));
desc.setVisibility(View.VISIBLE);
// Sørg for at rene tekst-lenker (uten <a href>) også blir klikkbare
Linkify.addLinks(desc, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
// Gjør at man kan klikke på lenkene
desc.setMovementMethod(LinkMovementMethod.getInstance());
desc.setVisibility(View.VISIBLE);
} else {
desc.setVisibility(View.GONE);
}
// --- ADRESSE OG KART ---
if (!event.getLocation().isEmpty()) {
loc.setText("Sted: " + event.getLocation());
loc.setText(event.getLocation()); // Viser kun teksten, ikonet ligger i XML
loc.setVisibility(View.VISIBLE);
// Gjør adressen klikkbar for å åpne kart
loc.setOnClickListener(v -> {
String location = event.getLocation();
// Opprett en geo-URI. "q=" søker etter stedet.
Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + Uri.encode(location));
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
// Sett pakke til Google Maps for å foretrekke det, men la systemet velge hvis ikke installert
mapIntent.setPackage("com.google.android.apps.maps");
try {
startActivity(mapIntent);
} catch (Exception e) {
// Fallback: Hvis Google Maps ikke finnes, prøv uten pakkenavn (hvilken som helst kart-app)
mapIntent.setPackage(null);
try {
startActivity(mapIntent);
} catch (Exception ex) {
Toast.makeText(getContext(), "Fant ingen kart-app", Toast.LENGTH_SHORT).show();
}
}
});
} else {
loc.setVisibility(View.GONE);
}
@ -5552,7 +5587,7 @@ import java.util.concurrent.TimeUnit;
public class MainActivity extends AppCompatActivity {
public static final String GOOGLE_WEB_CLIENT_ID = "738325360287-cidl3plnqv9ei74vm9vm5muustj6eenb.apps.googleusercontent.com"; // Bytt med din egen hvis denne er feil
public static final String GOOGLE_WEB_CLIENT_ID = "SECRET.apps.googleusercontent.com"; // Bytt med din egen hvis denne er feil
private static final String TAG = "MainActivity";
private NavController navController;
@ -7140,7 +7175,7 @@ FILSTI: app\src\main\res\layout\bottom_sheet_calendar_details.xml
android:padding="24dp"
android:background="@android:color/white">
<!-- NYTT: Kalendernavn (Lite merke øverst) -->
<!-- Kalendernavn (Lite merke øverst) -->
<TextView
android:id="@+id/sheet_calendar_name"
android:layout_width="wrap_content"
@ -7171,20 +7206,34 @@ FILSTI: app\src\main\res\layout\bottom_sheet_calendar_details.xml
android:text="Tidspunkt"
android:textSize="16sp"
android:textColor="@color/kbs_muted_blue_gray"
android:layout_marginBottom="16dp"
android:layout_marginBottom="12dp"
android:drawablePadding="8dp"
app:drawableStartCompat="@android:drawable/ic_menu_recent_history"/>
<!--
ENDRET: Lagt til kart-ikon, blå tekstfarge, og gjort den klikkbar visuelt
med background="?attr/selectableItemBackground"
-->
<TextView
android:id="@+id/sheet_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sted"
android:textSize="16sp"
android:textColor="#333"
android:textColor="@color/kbs_logo_blue"
android:textStyle="bold"
android:layout_marginBottom="16dp"
android:visibility="gone"/>
android:visibility="gone"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:background="?attr/selectableItemBackground"
android:paddingVertical="8dp"
app:drawableStartCompat="@android:drawable/ic_dialog_map"/>
<!--
ENDRET: Lagt til autoLink for web, email og phone
Dette hjelper TextView å forstå linker automatisk
-->
<TextView
android:id="@+id/sheet_desc"
android:layout_width="match_parent"
@ -7192,7 +7241,9 @@ FILSTI: app\src\main\res\layout\bottom_sheet_calendar_details.xml
android:text="Beskrivelse..."
android:textSize="14sp"
android:textColor="#555"
android:layout_marginBottom="24dp"/>
android:layout_marginBottom="24dp"
android:autoLink="web|email|phone"
android:linksClickable="true"/>
<!-- ADMIN KNAPPER (Vises kun for admin) -->
<LinearLayout

File diff suppressed because it is too large Load diff