- Server selection stubs

This commit is contained in:
Stefan Schueller 2018-11-11 14:53:32 +01:00
parent cb091c0694
commit 91d4b0c9ad
6 changed files with 216 additions and 13 deletions

View File

@ -10,28 +10,23 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application <application
tools:ignore="GoogleAppIndexingWarning"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<meta-data android:name="android.app.default_searchable" <meta-data
android:name="android.app.default_searchable"
android:value=".activity.SearchActivity" /> android:value=".activity.SearchActivity" />
<activity <activity android:name=".activity.VideoListActivity">
android:name=".activity.VideoListActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".activity.SearchActivity" android:name=".activity.SearchActivity"
android:label="@string/title_activity_search" android:label="@string/title_activity_search"
@ -44,7 +39,6 @@
android:name="android.app.searchable" android:name="android.app.searchable"
android:resource="@xml/searchable" /> android:resource="@xml/searchable" />
</activity> </activity>
<activity <activity
android:name=".activity.LoginActivity" android:name=".activity.LoginActivity"
android:label="@string/title_activity_login" /> android:label="@string/title_activity_login" />
@ -59,10 +53,13 @@
android:label="@string/title_activity_settings" /> android:label="@string/title_activity_settings" />
<!-- Content provider for search suggestions --> <!-- Content provider for search suggestions -->
<provider android:name=".provider.SearchSuggestionsProvider" <provider
android:enabled="true" android:name=".provider.SearchSuggestionsProvider"
android:authorities="net.schueller.peertube.provider.SearchSuggestionsProvider" android:authorities="net.schueller.peertube.provider.SearchSuggestionsProvider"
android:enabled="true"
android:exported="false" /> android:exported="false" />
<activity android:name=".activity.SelectServerActivity"></activity>
</application> </application>
</manifest> </manifest>

View File

@ -0,0 +1,43 @@
package net.schueller.peertube.activity;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import net.schueller.peertube.R;
import net.schueller.peertube.model.ServerList;
import net.schueller.peertube.network.GetServerListDataService;
import net.schueller.peertube.network.RetrofitInstance;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class SelectServerActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_server);
// get list of peertube servers
// TODO: Get here via settings, get data from API, add to adapter and show in recycle view, upon selection fill settings field
GetServerListDataService service = RetrofitInstance.getRetrofitInstance("https://instances.joinpeertube.org/api/v1/").create(GetServerListDataService.class);
Call<ServerList> call = service.getInstancesData(0, 500);
call.enqueue(new Callback<ServerList>() {
@Override
public void onResponse(@NonNull Call<ServerList> call, @NonNull Response<ServerList> response) {
// response.body().getVideoArrayList();
}
@Override
public void onFailure(@NonNull Call<ServerList> call, @NonNull Throwable t) {
}
});
}
}

View File

@ -0,0 +1,122 @@
package net.schueller.peertube.model;
public class Server {
private Integer id;
private String host;
private String name;
private String shortDescription;
private String version;
private Boolean signupAllowed;
private Integer userVideoQuota;
private Integer totalUsers;
private Integer totalVideos;
private Integer totalLocalVideos;
private Integer totalInstanceFollowers;
private Integer totalInstanceFollowing;
private Integer health;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getShortDescription() {
return shortDescription;
}
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Boolean getSignupAllowed() {
return signupAllowed;
}
public void setSignupAllowed(Boolean signupAllowed) {
this.signupAllowed = signupAllowed;
}
public Integer getUserVideoQuota() {
return userVideoQuota;
}
public void setUserVideoQuota(Integer userVideoQuota) {
this.userVideoQuota = userVideoQuota;
}
public Integer getTotalUsers() {
return totalUsers;
}
public void setTotalUsers(Integer totalUsers) {
this.totalUsers = totalUsers;
}
public Integer getTotalVideos() {
return totalVideos;
}
public void setTotalVideos(Integer totalVideos) {
this.totalVideos = totalVideos;
}
public Integer getTotalLocalVideos() {
return totalLocalVideos;
}
public void setTotalLocalVideos(Integer totalLocalVideos) {
this.totalLocalVideos = totalLocalVideos;
}
public Integer getTotalInstanceFollowers() {
return totalInstanceFollowers;
}
public void setTotalInstanceFollowers(Integer totalInstanceFollowers) {
this.totalInstanceFollowers = totalInstanceFollowers;
}
public Integer getTotalInstanceFollowing() {
return totalInstanceFollowing;
}
public void setTotalInstanceFollowing(Integer totalInstanceFollowing) {
this.totalInstanceFollowing = totalInstanceFollowing;
}
public Integer getHealth() {
return health;
}
public void setHealth(Integer health) {
this.health = health;
}
}

View File

@ -0,0 +1,16 @@
package net.schueller.peertube.model;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
public class ServerList {
@SerializedName("data")
private ArrayList<Server> serverList;
public ArrayList<Server> getServerArrayList() {
return serverList;
}
}

View File

@ -0,0 +1,16 @@
package net.schueller.peertube.network;
import net.schueller.peertube.model.ServerList;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
public interface GetServerListDataService {
@GET("instances/")
Call<ServerList> getInstancesData(
@Query("start") int start,
@Query("count") int count
);
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.SelectServerActivity">
</android.support.constraint.ConstraintLayout>