|
|
@ -23,7 +23,6 @@ import android.graphics.Bitmap; |
|
|
|
import android.graphics.BitmapFactory; |
|
|
|
import android.graphics.BitmapFactory; |
|
|
|
import android.net.Uri; |
|
|
|
import android.net.Uri; |
|
|
|
import android.os.AsyncTask; |
|
|
|
import android.os.AsyncTask; |
|
|
|
import android.os.Build; |
|
|
|
|
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.support.annotation.NonNull; |
|
|
|
import android.support.annotation.NonNull; |
|
|
|
import android.support.annotation.Nullable; |
|
|
|
import android.support.annotation.Nullable; |
|
|
@ -109,7 +108,7 @@ public class EditProfileActivity extends BaseActivity { |
|
|
|
setSupportActionBar(toolbar); |
|
|
|
setSupportActionBar(toolbar); |
|
|
|
ActionBar actionBar = getSupportActionBar(); |
|
|
|
ActionBar actionBar = getSupportActionBar(); |
|
|
|
if (actionBar != null) { |
|
|
|
if (actionBar != null) { |
|
|
|
actionBar.setTitle(getString(R.string.title_edit_profile)); |
|
|
|
actionBar.setTitle(R.string.title_edit_profile); |
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true); |
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true); |
|
|
|
actionBar.setDisplayShowHomeEnabled(true); |
|
|
|
actionBar.setDisplayShowHomeEnabled(true); |
|
|
|
} |
|
|
|
} |
|
|
@ -130,39 +129,23 @@ public class EditProfileActivity extends BaseActivity { |
|
|
|
headerBase64 = null; |
|
|
|
headerBase64 = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
avatarButton.setOnClickListener(new View.OnClickListener() { |
|
|
|
avatarButton.setOnClickListener(v -> onMediaPick(PickType.AVATAR)); |
|
|
|
@Override |
|
|
|
headerButton.setOnClickListener(v -> onMediaPick(PickType.HEADER)); |
|
|
|
public void onClick(View v) { |
|
|
|
|
|
|
|
onMediaPick(PickType.AVATAR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
headerButton.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
|
|
onMediaPick(PickType.HEADER); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
avatarPreview.setOnClickListener(new View.OnClickListener() { |
|
|
|
avatarPreview.setOnClickListener(v -> { |
|
|
|
@Override |
|
|
|
avatarPreview.setImageBitmap(null); |
|
|
|
public void onClick(View v) { |
|
|
|
avatarPreview.setVisibility(View.INVISIBLE); |
|
|
|
avatarPreview.setImageBitmap(null); |
|
|
|
avatarBase64 = null; |
|
|
|
avatarPreview.setVisibility(View.INVISIBLE); |
|
|
|
|
|
|
|
avatarBase64 = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
headerPreview.setOnClickListener(new View.OnClickListener() { |
|
|
|
headerPreview.setOnClickListener(v -> { |
|
|
|
@Override |
|
|
|
headerPreview.setImageBitmap(null); |
|
|
|
public void onClick(View v) { |
|
|
|
headerPreview.setVisibility(View.INVISIBLE); |
|
|
|
headerPreview.setImageBitmap(null); |
|
|
|
headerBase64 = null; |
|
|
|
headerPreview.setVisibility(View.INVISIBLE); |
|
|
|
|
|
|
|
headerBase64 = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
mastodonApi.accountVerifyCredentials().enqueue(new Callback<Account>() { |
|
|
|
mastodonApi.accountVerifyCredentials().enqueue(new Callback<Account>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onResponse(Call<Account> call, Response<Account> response) { |
|
|
|
public void onResponse(@NonNull Call<Account> call, @NonNull Response<Account> response) { |
|
|
|
if (!response.isSuccessful()) { |
|
|
|
if (!response.isSuccessful()) { |
|
|
|
onAccountVerifyCredentialsFailed(); |
|
|
|
onAccountVerifyCredentialsFailed(); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -187,7 +170,7 @@ public class EditProfileActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onFailure(Call<Account> call, Throwable t) { |
|
|
|
public void onFailure(@NonNull Call<Account> call, @NonNull Throwable t) { |
|
|
|
onAccountVerifyCredentialsFailed(); |
|
|
|
onAccountVerifyCredentialsFailed(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -214,8 +197,7 @@ public class EditProfileActivity extends BaseActivity { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
currentlyPicking = pickType; |
|
|
|
currentlyPicking = pickType; |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && |
|
|
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) |
|
|
|
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) |
|
|
|
|
|
|
|
!= PackageManager.PERMISSION_GRANTED) { |
|
|
|
!= PackageManager.PERMISSION_GRANTED) { |
|
|
|
ActivityCompat.requestPermissions(this, |
|
|
|
ActivityCompat.requestPermissions(this, |
|
|
|
new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, |
|
|
|
new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, |
|
|
@ -314,7 +296,7 @@ public class EditProfileActivity extends BaseActivity { |
|
|
|
profile.header = headerBase64; |
|
|
|
profile.header = headerBase64; |
|
|
|
mastodonApi.accountUpdateCredentials(profile).enqueue(new Callback<Account>() { |
|
|
|
mastodonApi.accountUpdateCredentials(profile).enqueue(new Callback<Account>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onResponse(Call<Account> call, Response<Account> response) { |
|
|
|
public void onResponse(@NonNull Call<Account> call, @NonNull Response<Account> response) { |
|
|
|
if (!response.isSuccessful()) { |
|
|
|
if (!response.isSuccessful()) { |
|
|
|
onSaveFailure(); |
|
|
|
onSaveFailure(); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -326,7 +308,7 @@ public class EditProfileActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onFailure(Call<Account> call, Throwable t) { |
|
|
|
public void onFailure(@NonNull Call<Account> call, @NonNull Throwable t) { |
|
|
|
onSaveFailure(); |
|
|
|
onSaveFailure(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|