diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt index 9e4c2249..06e7dc0c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt @@ -57,6 +57,7 @@ private const val AVATAR_FILE_NAME = "avatar.png" private const val KEY_OLD_DISPLAY_NAME = "OLD_DISPLAY_NAME" private const val KEY_OLD_NOTE = "OLD_NOTE" +private const val KEY_OLD_LOCKED = "OLD_LOCKED" private const val KEY_IS_SAVING = "IS_SAVING" private const val KEY_CURRENTLY_PICKING = "CURRENTLY_PICKING" private const val KEY_AVATAR_CHANGED = "AVATAR_CHANGED" @@ -73,6 +74,7 @@ class EditProfileActivity : BaseActivity(), Injectable { private var oldDisplayName: String? = null private var oldNote: String? = null + private var oldLocked: Boolean = false private var isSaving: Boolean = false private var currentlyPicking: PickType = PickType.NOTHING private var avatarChanged: Boolean = false @@ -101,6 +103,7 @@ class EditProfileActivity : BaseActivity(), Injectable { savedInstanceState?.let { oldDisplayName = it.getString(KEY_OLD_DISPLAY_NAME) oldNote = it.getString(KEY_OLD_NOTE) + oldLocked = it.getBoolean(KEY_OLD_LOCKED) isSaving = it.getBoolean(KEY_IS_SAVING) currentlyPicking = it.getSerializable(KEY_CURRENTLY_PICKING) as PickType avatarChanged = it.getBoolean(KEY_AVATAR_CHANGED) @@ -137,10 +140,12 @@ class EditProfileActivity : BaseActivity(), Injectable { val me = response.body() oldDisplayName = me!!.displayName oldNote = me.note.toString() - + oldLocked = me.locked displayNameEditText.setText(oldDisplayName) noteEditText.setText(oldNote) + lockedCheckBox.isChecked = oldLocked + if (!avatarChanged) { Picasso.with(avatarPreview.context) .load(me.avatar) @@ -165,6 +170,7 @@ class EditProfileActivity : BaseActivity(), Injectable { outState.run { putString(KEY_OLD_DISPLAY_NAME, oldDisplayName) putString(KEY_OLD_NOTE, oldNote) + putBoolean(KEY_OLD_LOCKED, oldLocked) putBoolean(KEY_IS_SAVING, isSaving) putSerializable(KEY_CURRENTLY_PICKING, currentlyPicking) putBoolean(KEY_AVATAR_CHANGED, avatarChanged) @@ -259,6 +265,13 @@ class EditProfileActivity : BaseActivity(), Injectable { RequestBody.create(MultipartBody.FORM, newNote) } + val newLocked = lockedCheckBox.isChecked + val locked = if (oldLocked == newLocked) { + null + } else { + RequestBody.create(MultipartBody.FORM, newLocked.toString()) + } + val avatar = if (avatarChanged) { val avatarBody = RequestBody.create(MediaType.parse("image/png"), getCacheFileForName(AVATAR_FILE_NAME)) MultipartBody.Part.createFormData("avatar", getFileName(), avatarBody) @@ -273,13 +286,13 @@ class EditProfileActivity : BaseActivity(), Injectable { null } - if (displayName == null && note == null && avatar == null && header == null) { + if (displayName == null && note == null && locked == null && avatar == null && header == null) { /** if nothing has changed, there is no need to make a network request */ finish() return } - mastodonApi.accountUpdateCredentials(displayName, note, avatar, header).enqueue(object : Callback { + mastodonApi.accountUpdateCredentials(displayName, note, locked, avatar, header).enqueue(object : Callback { override fun onResponse(call: Call, response: Response) { if (!response.isSuccessful) { onSaveFailure() diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 25811532..bf45bd96 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -69,7 +69,6 @@ import javax.inject.Inject; import dagger.android.AndroidInjector; import dagger.android.DispatchingAndroidInjector; -import dagger.android.support.AndroidSupportInjection; import dagger.android.support.HasSupportFragmentInjector; import retrofit2.Call; import retrofit2.Callback; @@ -457,7 +456,6 @@ public class MainActivity extends BaseActivity implements ActionButtonActivity, .setTitle(R.string.action_logout) .setMessage(getString(R.string.action_logout_confirm, activeAccount.getFullName())) .setPositiveButton(android.R.string.yes, (dialog, which) -> { - ; NotificationHelper.deleteNotificationChannelsForAccount(accountManager.getActiveAccount(), MainActivity.this); @@ -521,6 +519,8 @@ public class MainActivity extends BaseActivity implements ActionButtonActivity, .withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_person_add); drawer.addItemAtPosition(followRequestsItem, 3); + } else { + drawer.removeItem(DRAWER_ITEM_FOLLOW_REQUESTS); } updateProfiles(); diff --git a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.java b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.java index 351953b0..06f2aaaa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.java +++ b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.java @@ -142,6 +142,7 @@ public interface MastodonApi { Call accountUpdateCredentials( @Nullable @Part(value="display_name") RequestBody displayName, @Nullable @Part(value="note") RequestBody note, + @Nullable @Part(value="locked") RequestBody locked, @Nullable @Part MultipartBody.Part avatar, @Nullable @Part MultipartBody.Part header); diff --git a/app/src/main/res/layout/activity_edit_profile.xml b/app/src/main/res/layout/activity_edit_profile.xml index ea78b68c..543cf1d1 100644 --- a/app/src/main/res/layout/activity_edit_profile.xml +++ b/app/src/main/res/layout/activity_edit_profile.xml @@ -112,6 +112,27 @@ + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 26fb8d66..c2d28223 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -286,5 +286,7 @@ Describe for visually impaired Set caption Remove + Lock account + Requires you to manually approve followers