Fix issue #514 - Add about and privacy links into About the instance.

This commit is contained in:
Thomas 2022-11-22 17:14:00 +01:00
parent 9d4a576bc1
commit 900e78f5e8
3 changed files with 61 additions and 13 deletions

View file

@ -22,12 +22,17 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.UnderlineSpan;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
@ -39,6 +44,7 @@ import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.client.entities.api.Instance;
import app.fedilab.android.databinding.ActivityInstanceBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.viewmodel.mastodon.InstancesVM;
@ -61,6 +67,22 @@ public class InstanceActivity extends BaseActivity {
if (getSupportActionBar() != null)
getSupportActionBar().hide();
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(InstanceActivity.this);
final SpannableString contentAbout = new SpannableString(getString(R.string.action_about_instance));
contentAbout.setSpan(new UnderlineSpan(), 0, contentAbout.length(), 0);
contentAbout.setSpan(new ForegroundColorSpan(ContextCompat.getColor(InstanceActivity.this, R.color.cyanea_accent_reference)), 0, contentAbout.length(),
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
binding.tos.setText(contentAbout);
final SpannableString contentPrivacy = new SpannableString(getString(R.string.action_privacy_policy));
contentPrivacy.setSpan(new UnderlineSpan(), 0, contentPrivacy.length(), 0);
contentPrivacy.setSpan(new ForegroundColorSpan(ContextCompat.getColor(InstanceActivity.this, R.color.cyanea_accent_reference)), 0, contentPrivacy.length(),
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
binding.privacy.setText(contentPrivacy);
binding.tos.setOnClickListener(v -> Helper.openBrowser(InstanceActivity.this, "https://" + MainActivity.currentInstance + "/about"));
binding.privacy.setOnClickListener(v -> Helper.openBrowser(InstanceActivity.this, "https://" + MainActivity.currentInstance + "/privacy-policy"));
binding.close.setOnClickListener(
view -> {

View file

@ -23,7 +23,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="420dp"
android:layout_height="wrap_content"
android:padding="@dimen/fab_margin"
android:paddingLeft="@dimen/drawer_padding"
android:paddingRight="@dimen/drawer_padding">
@ -36,7 +36,7 @@
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/instance_container"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
@ -118,7 +118,7 @@
<RelativeLayout
android:id="@+id/loader"
android:layout_width="match_parent"
android:layout_height="420dp"
android:layout_height="wrap_content"
android:gravity="center"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
@ -144,22 +144,47 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/close"
style="@style/Widget.AppCompat.Button.Colored"
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:text="@string/close"
android:textAllCaps="false"
android:textColor="@color/white"
android:layout_marginTop="10dp"
android:text="@string/action_about_instance"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/max_char_container" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/privacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/action_privacy_policy"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tos" />
<com.google.android.material.button.MaterialButton
android:id="@+id/close"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingVertical="12dp"
android:text="@string/close"
android:textAlignment="textStart"
android:textColor="@color/cyanea_accent_dark_reference"
app:layout_constraintTop_toBottomOf="@+id/privacy"
android:textAllCaps="false"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:strokeColor="@color/cyanea_accent_dark_reference" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View file

@ -1910,4 +1910,5 @@
<string name="unblock_domain">Unblock domain</string>
<string name="no_blocked_domains">You have not blocked domains</string>
<string name="unblock_domain_confirm">Are you sure to unblock %1$s?</string>
<string name="action_privacy_policy">Privacy policy</string>
</resources>