Minor writing style changes.

This commit is contained in:
Vavassor 2017-06-22 14:01:25 -04:00
parent 100b9f0a47
commit 18ebfa212e
13 changed files with 45 additions and 43 deletions

View file

@ -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() {

View file

@ -205,7 +205,7 @@ public class AccountActivity extends BaseActivity {
}
private void obtainAccount() {
mastodonAPI.account(accountId).enqueue(new Callback<Account>() {
mastodonApi.account(accountId).enqueue(new Callback<Account>() {
@Override
public void onResponse(Call<Account> call, Response<Account> response) {
if (response.isSuccessful()) {
@ -313,7 +313,7 @@ public class AccountActivity extends BaseActivity {
private void obtainRelationships() {
List<String> ids = new ArrayList<>(1);
ids.add(accountId);
mastodonAPI.relationships(ids).enqueue(new Callback<List<Relationship>>() {
mastodonApi.relationships(ids).enqueue(new Callback<List<Relationship>>() {
@Override
public void onResponse(Call<List<Relationship>> call,
Response<List<Relationship>> 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);
}
}

View file

@ -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() {

View file

@ -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<Media>() {
@Override
@ -1263,7 +1263,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
private ArrayList<Account> autocompleteMention(String mention) {
ArrayList<Account> resultList = new ArrayList<>();
try {
List<Account> accountList = mastodonAPI.searchAccounts(mention, false, 40)
List<Account> accountList = mastodonApi.searchAccounts(mention, false, 40)
.execute()
.body();
if (accountList != null) {

View file

@ -157,7 +157,7 @@ public class EditProfileActivity extends BaseActivity {
}
});
mastodonAPI.accountVerifyCredentials().enqueue(new Callback<Account>() {
mastodonApi.accountVerifyCredentials().enqueue(new Callback<Account>() {
@Override
public void onResponse(Call<Account> call, Response<Account> 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<Account>() {
mastodonApi.accountUpdateCredentials(profile).enqueue(new Callback<Account>() {
@Override
public void onResponse(Call<Account> call, Response<Account> response) {
if (!response.isSuccessful()) {

View file

@ -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<String, String> parameters = new HashMap<>();
parameters.put("client_id", clientId);

View file

@ -387,7 +387,7 @@ public class MainActivity extends BaseActivity {
loggedInAccountUsername = username;
}
mastodonAPI.accountVerifyCredentials().enqueue(new Callback<Account>() {
mastodonApi.accountVerifyCredentials().enqueue(new Callback<Account>() {
@Override
public void onResponse(Call<Account> call, Response<Account> response) {
if (!response.isSuccessful()) {

View file

@ -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<ResponseBody>() {
mastodonApi.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> 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<List<Status>>() {
mastodonApi.accountStatuses(accountId, null, null, null).enqueue(new Callback<List<Status>>() {
@Override
public void onResponse(Call<List<Status>> call, retrofit2.Response<List<Status>> response) {
if (!response.isSuccessful()) {

View file

@ -188,7 +188,7 @@ public class SearchActivity extends BaseActivity implements SearchView.OnQueryTe
onSearchFailure();
}
};
mastodonAPI.search(query, false)
mastodonApi.search(query, false)
.enqueue(callback);
}

View file

@ -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;
}

View file

@ -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) {

View file

@ -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();

View file

@ -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")