From dacfbb34556732610e3f86e4f01ace22aada7a83 Mon Sep 17 00:00:00 2001 From: Vavassor Date: Thu, 22 Jun 2017 14:01:25 -0400 Subject: [PATCH] Minor writing style changes. --- .../com/keylesspalace/tusky/AboutActivity.java | 2 +- .../com/keylesspalace/tusky/AccountActivity.java | 16 ++++++++-------- .../com/keylesspalace/tusky/BaseActivity.java | 14 ++++++++------ .../com/keylesspalace/tusky/ComposeActivity.java | 6 +++--- .../keylesspalace/tusky/EditProfileActivity.java | 4 ++-- .../com/keylesspalace/tusky/LoginActivity.java | 8 ++++---- .../com/keylesspalace/tusky/MainActivity.java | 2 +- .../com/keylesspalace/tusky/ReportActivity.java | 4 ++-- .../com/keylesspalace/tusky/SearchActivity.java | 2 +- .../tusky/fragment/AccountListFragment.java | 14 +++++++------- .../keylesspalace/tusky/fragment/SFragment.java | 6 +++--- .../tusky/fragment/ViewThreadFragment.java | 8 ++++---- .../{MastodonAPI.java => MastodonApi.java} | 2 +- 13 files changed, 45 insertions(+), 43 deletions(-) rename app/src/main/java/com/keylesspalace/tusky/network/{MastodonAPI.java => MastodonApi.java} (99%) diff --git a/app/src/main/java/com/keylesspalace/tusky/AboutActivity.java b/app/src/main/java/com/keylesspalace/tusky/AboutActivity.java index 01e59066..00a9ef0b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AboutActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AboutActivity.java @@ -88,7 +88,7 @@ public class AboutActivity extends BaseActivity { onSearchFailed(); } }; - mastodonAPI.searchAccounts("Tusky@mastodon.social", true, null).enqueue(callback); + mastodonApi.searchAccounts("Tusky@mastodon.social", true, null).enqueue(callback); } private void onSearchFailed() { diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index 616d9e00..9126acae 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -205,7 +205,7 @@ public class AccountActivity extends BaseActivity { } private void obtainAccount() { - mastodonAPI.account(accountId).enqueue(new Callback() { + mastodonApi.account(accountId).enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { @@ -313,7 +313,7 @@ public class AccountActivity extends BaseActivity { private void obtainRelationships() { List ids = new ArrayList<>(1); ids.add(accountId); - mastodonAPI.relationships(ids).enqueue(new Callback>() { + mastodonApi.relationships(ids).enqueue(new Callback>() { @Override public void onResponse(Call> call, Response> response) { @@ -474,8 +474,8 @@ public class AccountActivity extends BaseActivity { Assert.expect(followState != FollowState.REQUESTED); switch (followState) { - case NOT_FOLLOWING: { mastodonAPI.followAccount(id).enqueue(cb); break; } - case FOLLOWING: { mastodonAPI.unfollowAccount(id).enqueue(cb); break; } + case NOT_FOLLOWING: { mastodonApi.followAccount(id).enqueue(cb); break; } + case FOLLOWING: { mastodonApi.unfollowAccount(id).enqueue(cb); break; } } } @@ -523,9 +523,9 @@ public class AccountActivity extends BaseActivity { } }; if (blocking) { - mastodonAPI.unblockAccount(id).enqueue(cb); + mastodonApi.unblockAccount(id).enqueue(cb); } else { - mastodonAPI.blockAccount(id).enqueue(cb); + mastodonApi.blockAccount(id).enqueue(cb); } } @@ -562,9 +562,9 @@ public class AccountActivity extends BaseActivity { }; if (muting) { - mastodonAPI.unmuteAccount(id).enqueue(cb); + mastodonApi.unmuteAccount(id).enqueue(cb); } else { - mastodonAPI.muteAccount(id).enqueue(cb); + mastodonApi.muteAccount(id).enqueue(cb); } } diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index 45c69b33..b5de0a69 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -36,7 +36,7 @@ import com.keylesspalace.tusky.entity.Session; import com.keylesspalace.tusky.json.SpannedTypeAdapter; import com.keylesspalace.tusky.json.StringWithEmoji; import com.keylesspalace.tusky.json.StringWithEmojiTypeAdapter; -import com.keylesspalace.tusky.network.MastodonAPI; +import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.network.TuskyApi; import com.keylesspalace.tusky.util.OkHttpUtils; import com.keylesspalace.tusky.util.PushNotificationClient; @@ -57,7 +57,7 @@ import retrofit2.converter.gson.GsonConverterFactory; public class BaseActivity extends AppCompatActivity { private static final String TAG = "BaseActivity"; // logging tag - public MastodonAPI mastodonAPI; + public MastodonApi mastodonApi; public TuskyApi tuskyApi; protected PushNotificationClient pushNotificationClient; protected Dispatcher mastodonApiDispatcher; @@ -67,7 +67,7 @@ public class BaseActivity extends AppCompatActivity { super.onCreate(savedInstanceState); redirectIfNotLoggedIn(); - createMastodonAPI(); + createMastodonApi(); createTuskyApi(); createPushNotificationClient(); @@ -81,7 +81,9 @@ public class BaseActivity extends AppCompatActivity { @Override protected void onDestroy() { - if(mastodonApiDispatcher != null) mastodonApiDispatcher.cancelAll(); + if (mastodonApiDispatcher != null) { + mastodonApiDispatcher.cancelAll(); + } super.onDestroy(); } @@ -124,7 +126,7 @@ public class BaseActivity extends AppCompatActivity { return "https://" + preferences.getString("domain", null); } - protected void createMastodonAPI() { + protected void createMastodonApi() { mastodonApiDispatcher = new Dispatcher(); Gson gson = new GsonBuilder() @@ -158,7 +160,7 @@ public class BaseActivity extends AppCompatActivity { .addConverterFactory(GsonConverterFactory.create(gson)) .build(); - mastodonAPI = retrofit.create(MastodonAPI.class); + mastodonApi = retrofit.create(MastodonApi.class); } protected void createTuskyApi() { diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 88f56f4c..2e3d0086 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -697,7 +697,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm onSendFailure(); } }; - mastodonAPI.createStatus(content, inReplyToId, spoilerText, visibility, sensitive, mediaIds) + mastodonApi.createStatus(content, inReplyToId, spoilerText, visibility, sensitive, mediaIds) .enqueue(callback); } @@ -1031,7 +1031,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm RequestBody requestFile = RequestBody.create(MediaType.parse(mimeType), content); MultipartBody.Part body = MultipartBody.Part.createFormData("file", filename, requestFile); - item.uploadRequest = mastodonAPI.uploadMedia(body); + item.uploadRequest = mastodonApi.uploadMedia(body); item.uploadRequest.enqueue(new Callback() { @Override @@ -1263,7 +1263,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm private ArrayList autocompleteMention(String mention) { ArrayList resultList = new ArrayList<>(); try { - List accountList = mastodonAPI.searchAccounts(mention, false, 40) + List accountList = mastodonApi.searchAccounts(mention, false, 40) .execute() .body(); if (accountList != null) { diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java index 88e59072..5f7f6f9b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java @@ -157,7 +157,7 @@ public class EditProfileActivity extends BaseActivity { } }); - mastodonAPI.accountVerifyCredentials().enqueue(new Callback() { + mastodonApi.accountVerifyCredentials().enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { if (!response.isSuccessful()) { @@ -309,7 +309,7 @@ public class EditProfileActivity extends BaseActivity { profile.note = newNote; profile.avatar = avatarBase64; profile.header = headerBase64; - mastodonAPI.accountUpdateCredentials(profile).enqueue(new Callback() { + mastodonApi.accountUpdateCredentials(profile).enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { if (!response.isSuccessful()) { diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index 810c318b..ca85d43e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -38,7 +38,7 @@ import android.widget.TextView; import com.keylesspalace.tusky.entity.AccessToken; import com.keylesspalace.tusky.entity.AppCredentials; -import com.keylesspalace.tusky.network.MastodonAPI; +import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.util.CustomTabsHelper; import com.keylesspalace.tusky.util.OkHttpUtils; @@ -150,14 +150,14 @@ public class LoginActivity extends AppCompatActivity { return scheme + "://" + host + "/"; } - private MastodonAPI getApiFor(String domain) { + private MastodonApi getApiFor(String domain) { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://" + domain) .client(OkHttpUtils.getCompatibleClient()) .addConverterFactory(GsonConverterFactory.create()) .build(); - return retrofit.create(MastodonAPI.class); + return retrofit.create(MastodonApi.class); } /** @@ -267,7 +267,7 @@ public class LoginActivity extends AppCompatActivity { private void redirectUserToAuthorizeAndLogin(EditText editText) { /* To authorize this app and log in it's necessary to redirect to the domain given, * activity_login there, and the server will redirect back to the app with its response. */ - String endpoint = MastodonAPI.ENDPOINT_AUTHORIZE; + String endpoint = MastodonApi.ENDPOINT_AUTHORIZE; String redirectUri = getOauthRedirectUri(); Map parameters = new HashMap<>(); parameters.put("client_id", clientId); diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 2c3936dd..a9f910f1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -387,7 +387,7 @@ public class MainActivity extends BaseActivity { loggedInAccountUsername = username; } - mastodonAPI.accountVerifyCredentials().enqueue(new Callback() { + mastodonApi.accountVerifyCredentials().enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { if (!response.isSuccessful()) { diff --git a/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java b/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java index 8b8198fc..b62ff260 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java @@ -118,7 +118,7 @@ public class ReportActivity extends BaseActivity { private void sendReport(final String accountId, final String[] statusIds, final String comment) { - mastodonAPI.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback() { + mastodonApi.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback() { @Override public void onResponse(Call call, retrofit2.Response response) { if (response.isSuccessful()) { @@ -155,7 +155,7 @@ public class ReportActivity extends BaseActivity { } private void fetchRecentStatuses(String accountId) { - mastodonAPI.accountStatuses(accountId, null, null, null).enqueue(new Callback>() { + mastodonApi.accountStatuses(accountId, null, null, null).enqueue(new Callback>() { @Override public void onResponse(Call> call, retrofit2.Response> response) { if (!response.isSuccessful()) { diff --git a/app/src/main/java/com/keylesspalace/tusky/SearchActivity.java b/app/src/main/java/com/keylesspalace/tusky/SearchActivity.java index f75b33ac..df7d8d44 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SearchActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/SearchActivity.java @@ -188,7 +188,7 @@ public class SearchActivity extends BaseActivity implements SearchView.OnQueryTe onSearchFailure(); } }; - mastodonAPI.search(query, false) + mastodonApi.search(query, false) .enqueue(callback); } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java index b3259ab6..7c371067 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java @@ -41,7 +41,7 @@ import com.keylesspalace.tusky.BaseActivity; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.Relationship; import com.keylesspalace.tusky.interfaces.AccountActionListener; -import com.keylesspalace.tusky.network.MastodonAPI; +import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.util.ThemeUtils; import com.keylesspalace.tusky.view.EndlessOnScrollListener; @@ -70,7 +70,7 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi private EndlessOnScrollListener scrollListener; private AccountAdapter adapter; private TabLayout.OnTabSelectedListener onTabSelectedListener; - private MastodonAPI api; + private MastodonApi api; public static AccountListFragment newInstance(Type type) { Bundle arguments = new Bundle(); @@ -153,10 +153,10 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi layout.addOnTabSelectedListener(onTabSelectedListener); } - /* MastodonAPI on the base activity is only guaranteed to be initialised after the parent + /* MastodonApi on the base activity is only guaranteed to be initialised after the parent * activity is created, so everything needing to access the api object has to be delayed * until here. */ - api = activity.mastodonAPI; + api = activity.mastodonApi; scrollListener = new EndlessOnScrollListener(layoutManager) { @Override public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { @@ -266,7 +266,7 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi /* If somehow an unmute button is clicked after onCreateView but before * onActivityCreated, then this would get called with a null api object, so this eats * that input. */ - Log.d(TAG, "MastodonAPI isn't initialised so this mute can't occur."); + Log.d(TAG, "MastodonApi isn't initialised so this mute can't occur."); return; } @@ -330,7 +330,7 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi /* If somehow an unblock button is clicked after onCreateView but before * onActivityCreated, then this would get called with a null api object, so this eats * that input. */ - Log.d(TAG, "MastodonAPI isn't initialised so this block can't occur."); + Log.d(TAG, "MastodonApi isn't initialised so this block can't occur."); return; } @@ -395,7 +395,7 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi /* If somehow an response button is clicked after onCreateView but before * onActivityCreated, then this would get called with a null api object, so this eats * that input. */ - Log.d(TAG, "MastodonAPI isn't initialised, so follow requests can't be responded to."); + Log.d(TAG, "MastodonApi isn't initialised, so follow requests can't be responded to."); return; } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java index b5d82bb9..6eea7c62 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java @@ -39,7 +39,7 @@ import com.keylesspalace.tusky.ViewVideoActivity; import com.keylesspalace.tusky.entity.Relationship; import com.keylesspalace.tusky.entity.Status; import com.keylesspalace.tusky.interfaces.AdapterItemRemover; -import com.keylesspalace.tusky.network.MastodonAPI; +import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.receiver.TimelineReceiver; import com.keylesspalace.tusky.util.HtmlUtils; @@ -60,7 +60,7 @@ import retrofit2.Response; public abstract class SFragment extends BaseFragment { protected String loggedInAccountId; protected String loggedInUsername; - protected MastodonAPI mastodonAPI; + protected MastodonApi mastodonAPI; protected static int COMPOSE_RESULT = 1; @Override @@ -76,7 +76,7 @@ public abstract class SFragment extends BaseFragment { public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); BaseActivity activity = (BaseActivity) getActivity(); - mastodonAPI = activity.mastodonAPI; + mastodonAPI = activity.mastodonApi; } protected void reply(Status status) { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java index 0b25998c..f38cba3d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java @@ -36,7 +36,7 @@ import com.keylesspalace.tusky.adapter.ThreadAdapter; import com.keylesspalace.tusky.BaseActivity; import com.keylesspalace.tusky.entity.Status; import com.keylesspalace.tusky.entity.StatusContext; -import com.keylesspalace.tusky.network.MastodonAPI; +import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.interfaces.StatusActionListener; import com.keylesspalace.tusky.receiver.TimelineReceiver; @@ -54,7 +54,7 @@ public class ViewThreadFragment extends SFragment implements private SwipeRefreshLayout swipeRefreshLayout; private RecyclerView recyclerView; private ThreadAdapter adapter; - private MastodonAPI mastodonApi; + private MastodonApi mastodonApi; private String thisThreadsStatusId; private TimelineReceiver timelineReceiver; @@ -112,9 +112,9 @@ public class ViewThreadFragment extends SFragment implements public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - /* BaseActivity's MastodonAPI object isn't guaranteed to be valid until after its onCreate + /* BaseActivity's MastodonApi object isn't guaranteed to be valid until after its onCreate * is run, so all calls that need it can't be done until here. */ - mastodonApi = ((BaseActivity) getActivity()).mastodonAPI; + mastodonApi = ((BaseActivity) getActivity()).mastodonApi; thisThreadsStatusId = getArguments().getString("id"); onRefresh(); diff --git a/app/src/main/java/com/keylesspalace/tusky/network/MastodonAPI.java b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.java similarity index 99% rename from app/src/main/java/com/keylesspalace/tusky/network/MastodonAPI.java rename to app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.java index 72c71608..2fd66184 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/MastodonAPI.java +++ b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.java @@ -43,7 +43,7 @@ import retrofit2.http.Part; import retrofit2.http.Path; import retrofit2.http.Query; -public interface MastodonAPI { +public interface MastodonApi { String ENDPOINT_AUTHORIZE = "/oauth/authorize"; @GET("api/v1/timelines/home")