Skip to content

Commit

Permalink
Add FOSS notice
Browse files Browse the repository at this point in the history
  • Loading branch information
litetex committed Apr 15, 2022
1 parent 97bf24a commit 281562c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
Expand All @@ -22,19 +23,28 @@ public class UrlMultiInstanceTypeCreator<I extends Instance>
extends AbstractInstanceTypeCreator<I> {

protected final Function<String, I> createNewInstanceFromUrl;
/**
* The (official) list of available instances
*/
@StringRes
protected final int instanceListUrl;
/**
* <code>true</code> if the service is free and open source software
*/
protected final boolean isFoss;

public UrlMultiInstanceTypeCreator(
final String instanceServiceName,
final int icon,
final Class<I> createdClass,
final Function<String, I> createNewInstanceFromUrl,
final int instanceListUrl
final int instanceListUrl,
final boolean isFoss
) {
super(instanceServiceName, icon, createdClass);
this.createNewInstanceFromUrl = createNewInstanceFromUrl;
this.instanceListUrl = instanceListUrl;
this.isFoss = isFoss;
}

@Override
Expand All @@ -59,6 +69,7 @@ void showAddInstanceUrlDialog(
c.getString(
R.string.publicly_available_instances_help,
c.getString(instanceListUrl)));
dialogBinding.fossNoticeContainer.setVisibility(isFoss ? View.VISIBLE : View.GONE);

new AlertDialog.Builder(c)
.setTitle(c.getString(R.string.add_instance, instanceServiceName()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public PeerTubeInstanceTypeCreator() {
R.drawable.ic_placeholder_peertube,
PeertubeInstance.class,
PeertubeInstance::new,
R.string.peertube_instance_list_url);
R.string.peertube_instance_list_url,
true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public InvidiousInstanceTypeCreator() {
R.drawable.ic_placeholder_invidious,
InvidiousInstance.class,
InvidiousInstance::new,
R.string.invidious_instance_list_url);
R.string.invidious_instance_list_url,
true);
}
}
}
38 changes: 34 additions & 4 deletions app/src/main/res/layout/dialog_add_instance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/instanceHelp"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
Expand All @@ -18,12 +18,11 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="You can find a list of available instances here: https://instances.localhost"
tools:visibility="visible" />
tools:text="@string/publicly_available_instances_help" />

<org.schabi.newpipe.views.NewPipeEditText
android:id="@+id/dialogEditText"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
Expand All @@ -35,4 +34,35 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/instanceHelp" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/fossNoticeContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dialogEditText">

<ImageView
android:id="@+id/fossNoticeIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_info_outline" />

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/fossNoticeText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/instance_is_foss"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/fossNoticeIcon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<string name="publicly_available_instances_help">A list of publicly available instances can be found on %s</string>
<string name="add_instance">Add %s instance</string>
<string name="enter_instance_url">Enter instance URL</string>
<string name="instance_is_foss">This service is provided by free and open-source software. Consider donating to the maintainers and developers or feel free to host your own instance.</string>
<string name="could_not_validate_instance">Could not validate instance</string>
<string name="instance_already_exists">Instance already exists</string>
<string name="http_is_insecure_consider_using_https">Communication via HTTP is insecure. Consider using HTTPS instead</string>
Expand Down

0 comments on commit 281562c

Please sign in to comment.