From b1aa05694e40b88d24e21de6f99e2e9494de3884 Mon Sep 17 00:00:00 2001 From: Vavassor Date: Thu, 22 Jun 2017 14:59:12 -0400 Subject: [PATCH] Removes ButterKnife annotations. --- app/build.gradle | 2 - .../keylesspalace/tusky/AccountActivity.java | 23 ++++---- .../keylesspalace/tusky/ComposeActivity.java | 53 +++++++++---------- .../tusky/EditProfileActivity.java | 33 ++++++------ .../keylesspalace/tusky/LoginActivity.java | 20 ++++--- .../com/keylesspalace/tusky/MainActivity.java | 13 ++--- .../keylesspalace/tusky/ReportActivity.java | 17 +++--- .../keylesspalace/tusky/ViewTagActivity.java | 8 +-- .../tusky/ViewVideoActivity.java | 14 ++--- .../tusky/adapter/BlocksAdapter.java | 17 +++--- .../tusky/adapter/FollowRequestsAdapter.java | 20 +++---- .../tusky/adapter/MutesAdapter.java | 17 +++--- .../fragment/ComposeOptionsFragment.java | 13 ++--- .../tusky/fragment/ViewMediaFragment.java | 43 ++++++--------- 14 files changed, 135 insertions(+), 158 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a6ed973f..6e8ccd8a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,12 +48,10 @@ dependencies { compile 'com.github.chrisbanes:PhotoView:2.0.0' compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.3' - compile 'com.jakewharton:butterknife:8.5.1' compile 'org.jsoup:jsoup:1.10.2' compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0' compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.1') { exclude module: 'support-v4' } testCompile 'junit:junit:4.12' - annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' } diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index 9126acae..70884ae3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -59,8 +59,6 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; -import butterknife.BindView; -import butterknife.ButterKnife; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -80,19 +78,24 @@ public class AccountActivity extends BaseActivity { private boolean muting; private boolean isSelf; private Account loadedAccount; - - @BindView(R.id.account_avatar) CircularImageView avatar; - @BindView(R.id.account_header) ImageView header; - @BindView(R.id.floating_btn) FloatingActionButton floatingBtn; - @BindView(R.id.tab_layout) TabLayout tabLayout; - @BindView(R.id.account_locked) ImageView accountLockedView; - @BindView(R.id.activity_account) View container; + private CircularImageView avatar; + private ImageView header; + private FloatingActionButton floatingBtn; + private TabLayout tabLayout; + private ImageView accountLockedView; + private View container; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_account); - ButterKnife.bind(this); + + avatar = (CircularImageView) findViewById(R.id.account_avatar); + header = (ImageView) findViewById(R.id.account_header); + floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn); + tabLayout = (TabLayout) findViewById(R.id.tab_layout); + accountLockedView = (ImageView) findViewById(R.id.account_locked); + container = findViewById(R.id.activity_account); if (savedInstanceState != null) { accountId = savedInstanceState.getString("accountId"); diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 2e3d0086..8c6ad64c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -105,8 +105,6 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; -import butterknife.BindView; -import butterknife.ButterKnife; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.RequestBody; @@ -129,28 +127,20 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm private static final int PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1; private static final int COMPOSE_SUCCESS = -1; private static final int THUMBNAIL_SIZE = 128; // pixels - @BindView(R.id.compose_edit_field) - EditTextTyped textEditor; - @BindView(R.id.compose_media_preview_bar) - LinearLayout mediaPreviewBar; - @BindView(R.id.compose_content_warning_bar) - View contentWarningBar; - @BindView(R.id.field_content_warning) - EditText contentWarningEditor; - @BindView(R.id.characters_left) - TextView charactersLeft; - @BindView(R.id.floating_btn) - Button floatingBtn; - @BindView(R.id.compose_photo_pick) - ImageButton pickBtn; - @BindView(R.id.compose_photo_take) - ImageButton takeBtn; - @BindView(R.id.action_hide_media) - ImageButton hideMediaToggle; - @BindView(R.id.postProgress) - ProgressBar postProgress; - @BindView(R.id.action_toggle_visibility) - ImageButton visibilityBtn; + + private EditTextTyped textEditor; + private LinearLayout mediaPreviewBar; + private View contentWarningBar; + private EditText contentWarningEditor; + private TextView charactersLeft; + private Button floatingBtn; + private ImageButton pickBtn; + private ImageButton takeBtn; + private ImageButton hideMediaToggle; + private ImageButton visibilityBtn; + private ProgressBar postProgress; + // this only exists when a status is trying to be sent, but uploads are still occurring + private ProgressDialog finishingUploadDialog; private String inReplyToId; private ArrayList mediaQueued; private CountUpDownLatch waitForMediaLatch; @@ -162,8 +152,6 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm private InputContentInfoCompat currentInputContentInfo; private int currentFlags; private Uri photoUploadUri; - // this only exists when a status is trying to be sent, but uploads are still occurring - private ProgressDialog finishingUploadDialog; /** * The Target object must be stored as a member field or method and cannot be an anonymous class otherwise this won't work as expected. The reason is that Picasso accepts this parameter as a weak memory reference. Because anonymous classes are eligible for garbage collection when there are no more references, the network request to fetch the image may finish after this anonymous class has already been reclaimed. See this Stack Overflow discussion for more details. @@ -175,7 +163,18 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); - ButterKnife.bind(this); + + textEditor = (EditTextTyped) findViewById(R.id.compose_edit_field); + mediaPreviewBar = (LinearLayout) findViewById(R.id.compose_media_preview_bar); + contentWarningBar = findViewById(R.id.compose_content_warning_bar); + contentWarningEditor = (EditText) findViewById(R.id.field_content_warning); + charactersLeft = (TextView) findViewById(R.id.characters_left); + floatingBtn = (Button) findViewById(R.id.floating_btn); + pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick); + takeBtn = (ImageButton) findViewById(R.id.compose_photo_take); + hideMediaToggle = (ImageButton) findViewById(R.id.action_hide_media); + visibilityBtn = (ImageButton) findViewById(R.id.action_toggle_visibility); + postProgress = (ProgressBar) findViewById(R.id.postProgress); // Setup the toolbar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java index 5f7f6f9b..1961606c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java @@ -55,8 +55,6 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; -import butterknife.BindView; -import butterknife.ButterKnife; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -77,16 +75,14 @@ public class EditProfileActivity extends BaseActivity { HEADER } - @BindView(R.id.edit_profile_header) ImageButton headerButton; - @BindView(R.id.edit_profile_header_preview) ImageView headerPreview; - @BindView(R.id.edit_profile_header_progress) ProgressBar headerProgress; - @BindView(R.id.edit_profile_avatar) ImageButton avatarButton; - @BindView(R.id.edit_profile_avatar_preview) ImageView avatarPreview; - @BindView(R.id.edit_profile_avatar_progress) ProgressBar avatarProgress; - @BindView(R.id.edit_profile_display_name) EditText displayNameEditText; - @BindView(R.id.edit_profile_note) EditText noteEditText; - @BindView(R.id.edit_profile_save_progress) ProgressBar saveProgress; - + private ImageView headerPreview; + private ProgressBar headerProgress; + private ImageButton avatarButton; + private ImageView avatarPreview; + private ProgressBar avatarProgress; + private EditText displayNameEditText; + private EditText noteEditText; + private ProgressBar saveProgress; private String priorDisplayName; private String priorNote; private boolean isAlreadySaving; @@ -98,7 +94,16 @@ public class EditProfileActivity extends BaseActivity { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_profile); - ButterKnife.bind(this); + + ImageButton headerButton = (ImageButton) findViewById(R.id.edit_profile_header); + headerPreview = (ImageView) findViewById(R.id.edit_profile_header_preview); + headerProgress = (ProgressBar) findViewById(R.id.edit_profile_header_progress); + avatarButton = (ImageButton) findViewById(R.id.edit_profile_avatar); + avatarPreview = (ImageView) findViewById(R.id.edit_profile_avatar_preview); + avatarProgress = (ProgressBar) findViewById(R.id.edit_profile_avatar_progress); + displayNameEditText = (EditText) findViewById(R.id.edit_profile_display_name); + noteEditText = (EditText) findViewById(R.id.edit_profile_note); + saveProgress = (ProgressBar) findViewById(R.id.edit_profile_save_progress); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); @@ -125,8 +130,6 @@ public class EditProfileActivity extends BaseActivity { headerBase64 = null; } - - avatarButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index ca85d43e..e8fb6472 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -45,8 +45,6 @@ import com.keylesspalace.tusky.util.OkHttpUtils; import java.util.HashMap; import java.util.Map; -import butterknife.BindView; -import butterknife.ButterKnife; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -57,19 +55,14 @@ public class LoginActivity extends AppCompatActivity { private static final String TAG = "LoginActivity"; // logging tag private static String OAUTH_SCOPES = "read write follow"; + private LinearLayout input; + private LinearLayout loading; + private EditText editText; private SharedPreferences preferences; - private String domain; private String clientId; private String clientSecret; - @BindView(R.id.login_input) LinearLayout input; - @BindView(R.id.login_loading) LinearLayout loading; - - @BindView(R.id.edit_text_domain) EditText editText; - @BindView(R.id.button_login) Button button; - @BindView(R.id.whats_an_instance) TextView whatsAnInstance; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -79,7 +72,12 @@ public class LoginActivity extends AppCompatActivity { } setContentView(R.layout.activity_login); - ButterKnife.bind(this); + + input = (LinearLayout) findViewById(R.id.login_input); + loading = (LinearLayout) findViewById(R.id.login_loading); + editText = (EditText) findViewById(R.id.edit_text_domain); + Button button = (Button) findViewById(R.id.button_login); + TextView whatsAnInstance = (TextView) findViewById(R.id.whats_an_instance); if (savedInstanceState != null) { domain = savedInstanceState.getString("domain"); diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index a9f910f1..5631ee9d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -58,8 +58,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Stack; -import butterknife.BindView; -import butterknife.ButterKnife; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -82,11 +80,7 @@ public class MainActivity extends BaseActivity { private Stack pageHistory; private AccountHeader headerResult; private Drawer drawer; - - @BindView(R.id.floating_btn) FloatingActionButton floatingBtn; - @BindView(R.id.drawer_toggle) ImageButton drawerToggle; - @BindView(R.id.tab_layout) TabLayout tabLayout; - @BindView(R.id.pager) ViewPager viewPager; + private ViewPager viewPager; public FloatingActionButton composeButton; @@ -103,7 +97,10 @@ public class MainActivity extends BaseActivity { } } - ButterKnife.bind(this); + FloatingActionButton floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn); + ImageButton drawerToggle = (ImageButton) findViewById(R.id.drawer_toggle); + TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); + viewPager = (ViewPager) findViewById(R.id.pager); floatingBtn.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java b/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java index b62ff260..3ef117ca 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ReportActivity.java @@ -43,6 +43,7 @@ import java.util.List; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.Callback; +import retrofit2.Response; public class ReportActivity extends BaseActivity { private static final String TAG = "ReportActivity"; // logging tag @@ -118,9 +119,9 @@ 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() { + Callback callback = new Callback() { @Override - public void onResponse(Call call, retrofit2.Response response) { + public void onResponse(Call call, Response response) { if (response.isSuccessful()) { onSendSuccess(); } else { @@ -132,7 +133,9 @@ public class ReportActivity extends BaseActivity { public void onFailure(Call call, Throwable t) { onSendFailure(accountId, statusIds, comment); } - }); + }; + mastodonApi.report(accountId, Arrays.asList(statusIds), comment) + .enqueue(callback); } private void onSendSuccess() { @@ -155,9 +158,9 @@ public class ReportActivity extends BaseActivity { } private void fetchRecentStatuses(String accountId) { - mastodonApi.accountStatuses(accountId, null, null, null).enqueue(new Callback>() { + Callback> callback = new Callback>() { @Override - public void onResponse(Call> call, retrofit2.Response> response) { + public void onResponse(Call> call, Response> response) { if (!response.isSuccessful()) { onFetchStatusesFailure(new Exception(response.message())); return; @@ -178,7 +181,9 @@ public class ReportActivity extends BaseActivity { public void onFailure(Call> call, Throwable t) { onFetchStatusesFailure((Exception) t); } - }); + }; + mastodonApi.accountStatuses(accountId, null, null, null) + .enqueue(callback); } private void onFetchStatusesFailure(Exception exception) { diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java b/app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java index 3401195c..00904828 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java @@ -25,21 +25,15 @@ import android.view.MenuItem; import com.keylesspalace.tusky.fragment.TimelineFragment; -import butterknife.BindView; -import butterknife.ButterKnife; - public class ViewTagActivity extends BaseActivity { - @BindView(R.id.toolbar) Toolbar toolbar; - @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_tag); - ButterKnife.bind(this); - String hashtag = getIntent().getStringExtra("hashtag"); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar bar = getSupportActionBar(); diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java b/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java index 9f1c4bf0..a6e06a52 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java @@ -25,24 +25,18 @@ import android.widget.MediaController; import android.widget.ProgressBar; import android.widget.VideoView; -import butterknife.BindView; -import butterknife.ButterKnife; - public class ViewVideoActivity extends BaseActivity { - @BindView(R.id.video_progress) ProgressBar progressBar; - @BindView(R.id.video_player) VideoView videoView; - @BindView(R.id.toolbar) Toolbar toolbar; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_video); - ButterKnife.bind(this); + final ProgressBar progressBar = (ProgressBar) findViewById(R.id.video_progress); + VideoView videoView = (VideoView) findViewById(R.id.video_player); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); - ActionBar bar = getSupportActionBar(); - if (bar != null) { bar.setTitle(null); bar.setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/BlocksAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/BlocksAdapter.java index e4e34fa9..91a718ec 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/BlocksAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/BlocksAdapter.java @@ -28,9 +28,6 @@ import com.keylesspalace.tusky.interfaces.AccountActionListener; import com.pkmmte.view.CircularImageView; import com.squareup.picasso.Picasso; -import butterknife.BindView; -import butterknife.ButterKnife; - public class BlocksAdapter extends AccountAdapter { private static final int VIEW_TYPE_BLOCKED_USER = 0; private static final int VIEW_TYPE_FOOTER = 1; @@ -75,16 +72,18 @@ public class BlocksAdapter extends AccountAdapter { } static class BlockedUserViewHolder extends RecyclerView.ViewHolder { - @BindView(R.id.blocked_user_avatar) CircularImageView avatar; - @BindView(R.id.blocked_user_username) TextView username; - @BindView(R.id.blocked_user_display_name) TextView displayName; - @BindView(R.id.blocked_user_unblock) ImageButton unblock; - + private CircularImageView avatar; + private TextView username; + private TextView displayName; + private ImageButton unblock; private String id; BlockedUserViewHolder(View itemView) { super(itemView); - ButterKnife.bind(this, itemView); + avatar = (CircularImageView) itemView.findViewById(R.id.blocked_user_avatar); + username = (TextView) itemView.findViewById(R.id.blocked_user_username); + displayName = (TextView) itemView.findViewById(R.id.blocked_user_display_name); + unblock = (ImageButton) itemView.findViewById(R.id.blocked_user_unblock); } void setupWithAccount(Account account) { diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestsAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestsAdapter.java index 392d33ac..269ac337 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestsAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestsAdapter.java @@ -28,9 +28,6 @@ import com.keylesspalace.tusky.entity.Account; import com.pkmmte.view.CircularImageView; import com.squareup.picasso.Picasso; -import butterknife.BindView; -import butterknife.ButterKnife; - public class FollowRequestsAdapter extends AccountAdapter { private static final int VIEW_TYPE_FOLLOW_REQUEST = 0; private static final int VIEW_TYPE_FOOTER = 1; @@ -75,17 +72,20 @@ public class FollowRequestsAdapter extends AccountAdapter { } static class FollowRequestViewHolder extends RecyclerView.ViewHolder { - @BindView(R.id.follow_request_avatar) CircularImageView avatar; - @BindView(R.id.follow_request_username) TextView username; - @BindView(R.id.follow_request_display_name) TextView displayName; - @BindView(R.id.follow_request_accept) ImageButton accept; - @BindView(R.id.follow_request_reject) ImageButton reject; - + private CircularImageView avatar; + private TextView username; + private TextView displayName; + private ImageButton accept; + private ImageButton reject; private String id; FollowRequestViewHolder(View itemView) { super(itemView); - ButterKnife.bind(this, itemView); + avatar = (CircularImageView) itemView.findViewById(R.id.follow_request_avatar); + username = (TextView) itemView.findViewById(R.id.follow_request_username); + displayName = (TextView) itemView.findViewById(R.id.follow_request_display_name); + accept = (ImageButton) itemView.findViewById(R.id.follow_request_accept); + reject = (ImageButton) itemView.findViewById(R.id.follow_request_reject); } void setupWithAccount(Account account) { diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/MutesAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/MutesAdapter.java index 06258a4b..b1499c9e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/MutesAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/MutesAdapter.java @@ -13,9 +13,6 @@ import com.keylesspalace.tusky.interfaces.AccountActionListener; import com.pkmmte.view.CircularImageView; import com.squareup.picasso.Picasso; -import butterknife.BindView; -import butterknife.ButterKnife; - public class MutesAdapter extends AccountAdapter { private static final int VIEW_TYPE_MUTED_USER = 0; private static final int VIEW_TYPE_FOOTER = 1; @@ -60,16 +57,18 @@ public class MutesAdapter extends AccountAdapter { } static class MutedUserViewHolder extends RecyclerView.ViewHolder { - @BindView(R.id.muted_user_avatar) CircularImageView avatar; - @BindView(R.id.muted_user_username) TextView username; - @BindView(R.id.muted_user_display_name) TextView displayName; - @BindView(R.id.muted_user_unmute) ImageButton unmute; - + private CircularImageView avatar; + private TextView username; + private TextView displayName; + private ImageButton unmute; private String id; MutedUserViewHolder(View itemView) { super(itemView); - ButterKnife.bind(this, itemView); + avatar = (CircularImageView) itemView.findViewById(R.id.muted_user_avatar); + username = (TextView) itemView.findViewById(R.id.muted_user_username); + displayName = (TextView) itemView.findViewById(R.id.muted_user_display_name); + unmute = (ImageButton) itemView.findViewById(R.id.muted_user_unmute); } void setupWithAccount(Account account) { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ComposeOptionsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/ComposeOptionsFragment.java index ab522602..ea930012 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ComposeOptionsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ComposeOptionsFragment.java @@ -82,14 +82,11 @@ public class ComposeOptionsFragment extends BottomSheetDialogFragment { radioCheckedId = R.id.radio_unlisted; } if (statusVisibility != null) { - if (statusVisibility.equals("public")) { - radioCheckedId = R.id.radio_public; - } else if (statusVisibility.equals("private")) { - radioCheckedId = R.id.radio_private; - } else if (statusVisibility.equals("unlisted")) { - radioCheckedId = R.id.radio_unlisted; - } else if (statusVisibility.equals("direct")) { - radioCheckedId = R.id.radio_direct; + switch (statusVisibility) { + case "public": radioCheckedId = R.id.radio_public; break; + case "private": radioCheckedId = R.id.radio_private; break; + case "unlisted": radioCheckedId = R.id.radio_unlisted; break; + case "direct": radioCheckedId = R.id.radio_direct; break; } } radio.check(radioCheckedId); diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.java index f53a4ef6..903e9bc0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.java @@ -15,6 +15,7 @@ package com.keylesspalace.tusky.fragment; +import android.Manifest; import android.app.DownloadManager; import android.content.Context; import android.content.pm.PackageManager; @@ -26,6 +27,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.support.design.widget.Snackbar; +import android.support.v4.app.ActivityCompat; import android.support.v4.app.DialogFragment; import android.support.v4.content.ContextCompat; import android.support.v7.widget.Toolbar; @@ -47,21 +49,11 @@ import com.squareup.picasso.Picasso; import java.io.File; -import butterknife.BindView; -import butterknife.ButterKnife; - public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuItemClickListener { - private PhotoViewAttacher attacher; private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1; - @BindView(R.id.view_media_image) - PhotoView photoView; - - @BindView(R.id.toolbar) - Toolbar toolbar; - public static ViewMediaFragment newInstance(String url) { Bundle arguments = new Bundle(); ViewMediaFragment fragment = new ViewMediaFragment(); @@ -89,7 +81,9 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_view_media, container, false); - ButterKnife.bind(this, rootView); + + final Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); + PhotoView photoView = (PhotoView) rootView.findViewById(R.id.view_media_image); Bundle arguments = getArguments(); String url = arguments.getString("url"); @@ -138,37 +132,34 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI } @Override - public void onError() { - - } + public void onError() {} }); return rootView; } - private void downloadImage(){ - + private void downloadImage() { //Permission stuff - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && - ContextCompat.checkSelfPermission(this.getContext(), android.Manifest.permission.WRITE_EXTERNAL_STORAGE) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN + && ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - android.support.v4.app.ActivityCompat.requestPermissions(getActivity(), - new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, + ActivityCompat.requestPermissions(getActivity(), + new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); } else { - //download stuff String url = getArguments().getString("url"); Uri uri = Uri.parse(url); String filename = new File(url).getName(); - DownloadManager downloadManager = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE); + DownloadManager downloadManager = (DownloadManager) getContext() + .getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(uri); request.allowScanningByMediaScanner(); - request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, getString(R.string.app_name) + "/" + filename); + request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, + getString(R.string.app_name) + "/" + filename); downloadManager.enqueue(request); } @@ -197,8 +188,8 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI } private void doErrorDialog(@StringRes int descriptionId, @StringRes int actionId, - View.OnClickListener listener) { - if(getView() != null) { + View.OnClickListener listener) { + if (getView() != null) { Snackbar bar = Snackbar.make(getView(), getString(descriptionId), Snackbar.LENGTH_SHORT); bar.setAction(actionId, listener);