Removes ButterKnife annotations.

This commit is contained in:
Vavassor 2017-06-22 14:59:12 -04:00
parent 18ebfa212e
commit b1aa05694e
14 changed files with 135 additions and 158 deletions

View File

@ -48,12 +48,10 @@ dependencies {
compile 'com.github.chrisbanes:PhotoView:2.0.0' compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar' compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.3' 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.jsoup:jsoup:1.10.2'
compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0' compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0'
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.1') { compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.1') {
exclude module: 'support-v4' exclude module: 'support-v4'
} }
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
} }

View File

@ -59,8 +59,6 @@ import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -80,19 +78,24 @@ public class AccountActivity extends BaseActivity {
private boolean muting; private boolean muting;
private boolean isSelf; private boolean isSelf;
private Account loadedAccount; private Account loadedAccount;
private CircularImageView avatar;
@BindView(R.id.account_avatar) CircularImageView avatar; private ImageView header;
@BindView(R.id.account_header) ImageView header; private FloatingActionButton floatingBtn;
@BindView(R.id.floating_btn) FloatingActionButton floatingBtn; private TabLayout tabLayout;
@BindView(R.id.tab_layout) TabLayout tabLayout; private ImageView accountLockedView;
@BindView(R.id.account_locked) ImageView accountLockedView; private View container;
@BindView(R.id.activity_account) View container;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account); 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) { if (savedInstanceState != null) {
accountId = savedInstanceState.getString("accountId"); accountId = savedInstanceState.getString("accountId");

View File

@ -105,8 +105,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.RequestBody; 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 PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
private static final int COMPOSE_SUCCESS = -1; private static final int COMPOSE_SUCCESS = -1;
private static final int THUMBNAIL_SIZE = 128; // pixels private static final int THUMBNAIL_SIZE = 128; // pixels
@BindView(R.id.compose_edit_field)
EditTextTyped textEditor; private EditTextTyped textEditor;
@BindView(R.id.compose_media_preview_bar) private LinearLayout mediaPreviewBar;
LinearLayout mediaPreviewBar; private View contentWarningBar;
@BindView(R.id.compose_content_warning_bar) private EditText contentWarningEditor;
View contentWarningBar; private TextView charactersLeft;
@BindView(R.id.field_content_warning) private Button floatingBtn;
EditText contentWarningEditor; private ImageButton pickBtn;
@BindView(R.id.characters_left) private ImageButton takeBtn;
TextView charactersLeft; private ImageButton hideMediaToggle;
@BindView(R.id.floating_btn) private ImageButton visibilityBtn;
Button floatingBtn; private ProgressBar postProgress;
@BindView(R.id.compose_photo_pick) // this only exists when a status is trying to be sent, but uploads are still occurring
ImageButton pickBtn; private ProgressDialog finishingUploadDialog;
@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 String inReplyToId; private String inReplyToId;
private ArrayList<QueuedMedia> mediaQueued; private ArrayList<QueuedMedia> mediaQueued;
private CountUpDownLatch waitForMediaLatch; private CountUpDownLatch waitForMediaLatch;
@ -162,8 +152,6 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
private InputContentInfoCompat currentInputContentInfo; private InputContentInfoCompat currentInputContentInfo;
private int currentFlags; private int currentFlags;
private Uri photoUploadUri; 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. * 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) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compose); 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. // Setup the toolbar.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

View File

@ -55,8 +55,6 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -77,16 +75,14 @@ public class EditProfileActivity extends BaseActivity {
HEADER HEADER
} }
@BindView(R.id.edit_profile_header) ImageButton headerButton; private ImageView headerPreview;
@BindView(R.id.edit_profile_header_preview) ImageView headerPreview; private ProgressBar headerProgress;
@BindView(R.id.edit_profile_header_progress) ProgressBar headerProgress; private ImageButton avatarButton;
@BindView(R.id.edit_profile_avatar) ImageButton avatarButton; private ImageView avatarPreview;
@BindView(R.id.edit_profile_avatar_preview) ImageView avatarPreview; private ProgressBar avatarProgress;
@BindView(R.id.edit_profile_avatar_progress) ProgressBar avatarProgress; private EditText displayNameEditText;
@BindView(R.id.edit_profile_display_name) EditText displayNameEditText; private EditText noteEditText;
@BindView(R.id.edit_profile_note) EditText noteEditText; private ProgressBar saveProgress;
@BindView(R.id.edit_profile_save_progress) ProgressBar saveProgress;
private String priorDisplayName; private String priorDisplayName;
private String priorNote; private String priorNote;
private boolean isAlreadySaving; private boolean isAlreadySaving;
@ -98,7 +94,16 @@ public class EditProfileActivity extends BaseActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_profile); 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); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -125,8 +130,6 @@ public class EditProfileActivity extends BaseActivity {
headerBase64 = null; headerBase64 = null;
} }
avatarButton.setOnClickListener(new View.OnClickListener() { avatarButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -45,8 +45,6 @@ import com.keylesspalace.tusky.util.OkHttpUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -57,19 +55,14 @@ public class LoginActivity extends AppCompatActivity {
private static final String TAG = "LoginActivity"; // logging tag private static final String TAG = "LoginActivity"; // logging tag
private static String OAUTH_SCOPES = "read write follow"; private static String OAUTH_SCOPES = "read write follow";
private LinearLayout input;
private LinearLayout loading;
private EditText editText;
private SharedPreferences preferences; private SharedPreferences preferences;
private String domain; private String domain;
private String clientId; private String clientId;
private String clientSecret; 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -79,7 +72,12 @@ public class LoginActivity extends AppCompatActivity {
} }
setContentView(R.layout.activity_login); 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) { if (savedInstanceState != null) {
domain = savedInstanceState.getString("domain"); domain = savedInstanceState.getString("domain");

View File

@ -58,8 +58,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -82,11 +80,7 @@ public class MainActivity extends BaseActivity {
private Stack<Integer> pageHistory; private Stack<Integer> pageHistory;
private AccountHeader headerResult; private AccountHeader headerResult;
private Drawer drawer; private Drawer drawer;
private ViewPager viewPager;
@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;
public FloatingActionButton composeButton; 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() { floatingBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override

View File

@ -43,6 +43,7 @@ import java.util.List;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response;
public class ReportActivity extends BaseActivity { public class ReportActivity extends BaseActivity {
private static final String TAG = "ReportActivity"; // logging tag 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, private void sendReport(final String accountId, final String[] statusIds,
final String comment) { final String comment) {
mastodonApi.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback<ResponseBody>() { Callback<ResponseBody> callback = new Callback<ResponseBody>() {
@Override @Override
public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) { public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
onSendSuccess(); onSendSuccess();
} else { } else {
@ -132,7 +133,9 @@ public class ReportActivity extends BaseActivity {
public void onFailure(Call<ResponseBody> call, Throwable t) { public void onFailure(Call<ResponseBody> call, Throwable t) {
onSendFailure(accountId, statusIds, comment); onSendFailure(accountId, statusIds, comment);
} }
}); };
mastodonApi.report(accountId, Arrays.asList(statusIds), comment)
.enqueue(callback);
} }
private void onSendSuccess() { private void onSendSuccess() {
@ -155,9 +158,9 @@ public class ReportActivity extends BaseActivity {
} }
private void fetchRecentStatuses(String accountId) { private void fetchRecentStatuses(String accountId) {
mastodonApi.accountStatuses(accountId, null, null, null).enqueue(new Callback<List<Status>>() { Callback<List<Status>> callback = new Callback<List<Status>>() {
@Override @Override
public void onResponse(Call<List<Status>> call, retrofit2.Response<List<Status>> response) { public void onResponse(Call<List<Status>> call, Response<List<Status>> response) {
if (!response.isSuccessful()) { if (!response.isSuccessful()) {
onFetchStatusesFailure(new Exception(response.message())); onFetchStatusesFailure(new Exception(response.message()));
return; return;
@ -178,7 +181,9 @@ public class ReportActivity extends BaseActivity {
public void onFailure(Call<List<Status>> call, Throwable t) { public void onFailure(Call<List<Status>> call, Throwable t) {
onFetchStatusesFailure((Exception) t); onFetchStatusesFailure((Exception) t);
} }
}); };
mastodonApi.accountStatuses(accountId, null, null, null)
.enqueue(callback);
} }
private void onFetchStatusesFailure(Exception exception) { private void onFetchStatusesFailure(Exception exception) {

View File

@ -25,21 +25,15 @@ import android.view.MenuItem;
import com.keylesspalace.tusky.fragment.TimelineFragment; import com.keylesspalace.tusky.fragment.TimelineFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ViewTagActivity extends BaseActivity { public class ViewTagActivity extends BaseActivity {
@BindView(R.id.toolbar) Toolbar toolbar;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_tag); setContentView(R.layout.activity_view_tag);
ButterKnife.bind(this);
String hashtag = getIntent().getStringExtra("hashtag"); String hashtag = getIntent().getStringExtra("hashtag");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
ActionBar bar = getSupportActionBar(); ActionBar bar = getSupportActionBar();

View File

@ -25,24 +25,18 @@ import android.widget.MediaController;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.VideoView; import android.widget.VideoView;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ViewVideoActivity extends BaseActivity { 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 @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_video); 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); setSupportActionBar(toolbar);
ActionBar bar = getSupportActionBar(); ActionBar bar = getSupportActionBar();
if (bar != null) { if (bar != null) {
bar.setTitle(null); bar.setTitle(null);
bar.setDisplayHomeAsUpEnabled(true); bar.setDisplayHomeAsUpEnabled(true);

View File

@ -28,9 +28,6 @@ import com.keylesspalace.tusky.interfaces.AccountActionListener;
import com.pkmmte.view.CircularImageView; import com.pkmmte.view.CircularImageView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import butterknife.BindView;
import butterknife.ButterKnife;
public class BlocksAdapter extends AccountAdapter { public class BlocksAdapter extends AccountAdapter {
private static final int VIEW_TYPE_BLOCKED_USER = 0; private static final int VIEW_TYPE_BLOCKED_USER = 0;
private static final int VIEW_TYPE_FOOTER = 1; private static final int VIEW_TYPE_FOOTER = 1;
@ -75,16 +72,18 @@ public class BlocksAdapter extends AccountAdapter {
} }
static class BlockedUserViewHolder extends RecyclerView.ViewHolder { static class BlockedUserViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.blocked_user_avatar) CircularImageView avatar; private CircularImageView avatar;
@BindView(R.id.blocked_user_username) TextView username; private TextView username;
@BindView(R.id.blocked_user_display_name) TextView displayName; private TextView displayName;
@BindView(R.id.blocked_user_unblock) ImageButton unblock; private ImageButton unblock;
private String id; private String id;
BlockedUserViewHolder(View itemView) { BlockedUserViewHolder(View itemView) {
super(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) { void setupWithAccount(Account account) {

View File

@ -28,9 +28,6 @@ import com.keylesspalace.tusky.entity.Account;
import com.pkmmte.view.CircularImageView; import com.pkmmte.view.CircularImageView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import butterknife.BindView;
import butterknife.ButterKnife;
public class FollowRequestsAdapter extends AccountAdapter { public class FollowRequestsAdapter extends AccountAdapter {
private static final int VIEW_TYPE_FOLLOW_REQUEST = 0; private static final int VIEW_TYPE_FOLLOW_REQUEST = 0;
private static final int VIEW_TYPE_FOOTER = 1; private static final int VIEW_TYPE_FOOTER = 1;
@ -75,17 +72,20 @@ public class FollowRequestsAdapter extends AccountAdapter {
} }
static class FollowRequestViewHolder extends RecyclerView.ViewHolder { static class FollowRequestViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.follow_request_avatar) CircularImageView avatar; private CircularImageView avatar;
@BindView(R.id.follow_request_username) TextView username; private TextView username;
@BindView(R.id.follow_request_display_name) TextView displayName; private TextView displayName;
@BindView(R.id.follow_request_accept) ImageButton accept; private ImageButton accept;
@BindView(R.id.follow_request_reject) ImageButton reject; private ImageButton reject;
private String id; private String id;
FollowRequestViewHolder(View itemView) { FollowRequestViewHolder(View itemView) {
super(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) { void setupWithAccount(Account account) {

View File

@ -13,9 +13,6 @@ import com.keylesspalace.tusky.interfaces.AccountActionListener;
import com.pkmmte.view.CircularImageView; import com.pkmmte.view.CircularImageView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MutesAdapter extends AccountAdapter { public class MutesAdapter extends AccountAdapter {
private static final int VIEW_TYPE_MUTED_USER = 0; private static final int VIEW_TYPE_MUTED_USER = 0;
private static final int VIEW_TYPE_FOOTER = 1; private static final int VIEW_TYPE_FOOTER = 1;
@ -60,16 +57,18 @@ public class MutesAdapter extends AccountAdapter {
} }
static class MutedUserViewHolder extends RecyclerView.ViewHolder { static class MutedUserViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.muted_user_avatar) CircularImageView avatar; private CircularImageView avatar;
@BindView(R.id.muted_user_username) TextView username; private TextView username;
@BindView(R.id.muted_user_display_name) TextView displayName; private TextView displayName;
@BindView(R.id.muted_user_unmute) ImageButton unmute; private ImageButton unmute;
private String id; private String id;
MutedUserViewHolder(View itemView) { MutedUserViewHolder(View itemView) {
super(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) { void setupWithAccount(Account account) {

View File

@ -82,14 +82,11 @@ public class ComposeOptionsFragment extends BottomSheetDialogFragment {
radioCheckedId = R.id.radio_unlisted; radioCheckedId = R.id.radio_unlisted;
} }
if (statusVisibility != null) { if (statusVisibility != null) {
if (statusVisibility.equals("public")) { switch (statusVisibility) {
radioCheckedId = R.id.radio_public; case "public": radioCheckedId = R.id.radio_public; break;
} else if (statusVisibility.equals("private")) { case "private": radioCheckedId = R.id.radio_private; break;
radioCheckedId = R.id.radio_private; case "unlisted": radioCheckedId = R.id.radio_unlisted; break;
} else if (statusVisibility.equals("unlisted")) { case "direct": radioCheckedId = R.id.radio_direct; break;
radioCheckedId = R.id.radio_unlisted;
} else if (statusVisibility.equals("direct")) {
radioCheckedId = R.id.radio_direct;
} }
} }
radio.check(radioCheckedId); radio.check(radioCheckedId);

View File

@ -15,6 +15,7 @@
package com.keylesspalace.tusky.fragment; package com.keylesspalace.tusky.fragment;
import android.Manifest;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -26,6 +27,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
@ -47,21 +49,11 @@ import com.squareup.picasso.Picasso;
import java.io.File; import java.io.File;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuItemClickListener { public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuItemClickListener {
private PhotoViewAttacher attacher; private PhotoViewAttacher attacher;
private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1; 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) { public static ViewMediaFragment newInstance(String url) {
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
ViewMediaFragment fragment = new ViewMediaFragment(); ViewMediaFragment fragment = new ViewMediaFragment();
@ -89,7 +81,9 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI
public View onCreateView(LayoutInflater inflater, final ViewGroup container, public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_view_media, container, false); 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(); Bundle arguments = getArguments();
String url = arguments.getString("url"); String url = arguments.getString("url");
@ -138,37 +132,34 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI
} }
@Override @Override
public void onError() { public void onError() {}
}
}); });
return rootView; return rootView;
} }
private void downloadImage(){ private void downloadImage() {
//Permission stuff //Permission stuff
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && && ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
ContextCompat.checkSelfPermission(this.getContext(), android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
android.support.v4.app.ActivityCompat.requestPermissions(getActivity(), ActivityCompat.requestPermissions(getActivity(),
new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
} else { } else {
//download stuff //download stuff
String url = getArguments().getString("url"); String url = getArguments().getString("url");
Uri uri = Uri.parse(url); Uri uri = Uri.parse(url);
String filename = new File(url).getName(); 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); DownloadManager.Request request = new DownloadManager.Request(uri);
request.allowScanningByMediaScanner(); 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); downloadManager.enqueue(request);
} }
@ -197,8 +188,8 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI
} }
private void doErrorDialog(@StringRes int descriptionId, @StringRes int actionId, private void doErrorDialog(@StringRes int descriptionId, @StringRes int actionId,
View.OnClickListener listener) { View.OnClickListener listener) {
if(getView() != null) { if (getView() != null) {
Snackbar bar = Snackbar.make(getView(), getString(descriptionId), Snackbar bar = Snackbar.make(getView(), getString(descriptionId),
Snackbar.LENGTH_SHORT); Snackbar.LENGTH_SHORT);
bar.setAction(actionId, listener); bar.setAction(actionId, listener);