From b01807d2a9b31348f6af2ab2cfea7f589aa8b246 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 5 Jul 2020 14:25:28 +0200 Subject: [PATCH] Code cleanup, renamed serverlist to search server --- app/src/main/AndroidManifest.xml | 2 +- ...erActivity.java => SearchServerActivity.java} | 16 ++++++++-------- .../peertube/adapter/ServerListAdapter.java | 8 -------- ...rverAdapter.java => ServerSearchAdapter.java} | 8 ++++---- .../peertube/fragment/AddServerFragment.java | 4 ++-- ..._selection.xml => activity_search_server.xml} | 2 +- app/src/main/res/values/strings.xml | 2 +- 7 files changed, 17 insertions(+), 25 deletions(-) rename app/src/main/java/net/schueller/peertube/activity/{SelectServerActivity.java => SearchServerActivity.java} (92%) rename app/src/main/java/net/schueller/peertube/adapter/{ServerAdapter.java => ServerSearchAdapter.java} (95%) rename app/src/main/res/layout/{activity_server_selection.xml => activity_search_server.xml} (97%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee09a9b..3091705 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -49,7 +49,7 @@ android:label="@string/title_activity_settings" android:theme="@style/AppTheme.NoActionBar" /> (), this); + serverAdapter = new ServerSearchAdapter(new ArrayList<>(), this); recyclerView.setAdapter(serverAdapter); loadServers(currentStart, count); @@ -132,7 +132,7 @@ public class SelectServerActivity extends CommonActivity { isLoading = true; GetServerListDataService service = RetrofitInstance.getRetrofitInstance( - APIUrlHelper.getServerIndexUrl(SelectServerActivity.this) + APIUrlHelper.getServerIndexUrl(SearchServerActivity.this) ).create(GetServerListDataService.class); @@ -171,7 +171,7 @@ public class SelectServerActivity extends CommonActivity { @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { Log.wtf("err", t.fillInStackTrace()); - Toast.makeText(SelectServerActivity.this, getString(R.string.api_error), Toast.LENGTH_SHORT).show(); + Toast.makeText(SearchServerActivity.this, getString(R.string.api_error), Toast.LENGTH_SHORT).show(); isLoading = false; swipeRefreshLayout.setRefreshing(false); } diff --git a/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java index f7225df..b5a575a 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java @@ -18,15 +18,11 @@ package net.schueller.peertube.adapter; import android.app.Activity; -import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import android.provider.SearchRecentSuggestions; import android.text.TextUtils; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -39,12 +35,8 @@ import androidx.recyclerview.widget.RecyclerView; import net.schueller.peertube.R; -import net.schueller.peertube.activity.SelectServerActivity; -import net.schueller.peertube.activity.ServerAddressBookActivity; -import net.schueller.peertube.activity.VideoListActivity; import net.schueller.peertube.database.Server; import net.schueller.peertube.helper.APIUrlHelper; -import net.schueller.peertube.provider.SearchSuggestionsProvider; import net.schueller.peertube.service.LoginService; diff --git a/app/src/main/java/net/schueller/peertube/adapter/ServerAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/ServerSearchAdapter.java similarity index 95% rename from app/src/main/java/net/schueller/peertube/adapter/ServerAdapter.java rename to app/src/main/java/net/schueller/peertube/adapter/ServerSearchAdapter.java index 4798032..f605cf8 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/ServerAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/ServerSearchAdapter.java @@ -27,7 +27,7 @@ import android.widget.Toast; import net.schueller.peertube.R; -import net.schueller.peertube.activity.SelectServerActivity; +import net.schueller.peertube.activity.SearchServerActivity; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.model.Server; @@ -41,14 +41,14 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import static android.app.Activity.RESULT_OK; -public class ServerAdapter extends RecyclerView.Adapter { +public class ServerSearchAdapter extends RecyclerView.Adapter { private ArrayList serverList; - private SelectServerActivity activity; + private SearchServerActivity activity; private String baseUrl; - public ServerAdapter(ArrayList serverList, SelectServerActivity activity) { + public ServerSearchAdapter(ArrayList serverList, SearchServerActivity activity) { this.serverList = serverList; this.activity = activity; } diff --git a/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java index 6e15a2b..4c90721 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java @@ -38,7 +38,7 @@ import android.widget.EditText; import android.widget.Toast; import net.schueller.peertube.R; -import net.schueller.peertube.activity.SelectServerActivity; +import net.schueller.peertube.activity.SearchServerActivity; import net.schueller.peertube.activity.ServerAddressBookActivity; import net.schueller.peertube.helper.APIUrlHelper; @@ -128,7 +128,7 @@ public class AddServerFragment extends Fragment { Button pickServerUrl = mView.findViewById(R.id.pickServerUrl); pickServerUrl.setOnClickListener(view -> { - Intent intentServer = new Intent(getActivity(), SelectServerActivity.class); + Intent intentServer = new Intent(getActivity(), SearchServerActivity.class); this.startActivityForResult(intentServer, PICK_SERVER); }); diff --git a/app/src/main/res/layout/activity_server_selection.xml b/app/src/main/res/layout/activity_search_server.xml similarity index 97% rename from app/src/main/res/layout/activity_server_selection.xml rename to app/src/main/res/layout/activity_search_server.xml index 9a91455..1860129 100644 --- a/app/src/main/res/layout/activity_server_selection.xml +++ b/app/src/main/res/layout/activity_search_server.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".activity.SelectServerActivity"> + tools:context=".activity.SearchServerActivity"> Remove Server Are you sure you want to remove this server from the address book? - Select Server + Search Server Account SettingsActivity2