Changes the icon for the visibility menu in the composer to match the current visibility. Also, fixes build errors with the dutch translation file.

This commit is contained in:
Vavassor 2017-04-21 01:50:59 -04:00
parent db021b948b
commit 681c70d056
2 changed files with 44 additions and 30 deletions

View File

@ -18,7 +18,6 @@ package com.keylesspalace.tusky;
import android.Manifest; import android.Manifest;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -108,7 +107,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
private static final int PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1; private static final int PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
private static final int MEDIA_SIZE_UNKNOWN = -1; private static final int MEDIA_SIZE_UNKNOWN = -1;
private static final int COMPOSE_SUCCESS = -1; private static final int COMPOSE_SUCCESS = -1;
private static final int THUMBNAIL_SIZE = 128; private static final int THUMBNAIL_SIZE = 128; // pixels
private String inReplyToId; private String inReplyToId;
private EditText textEditor; private EditText textEditor;
@ -346,8 +345,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
actionBar.setHomeAsUpIndicator(closeIcon); actionBar.setHomeAsUpIndicator(closeIcon);
} }
SharedPreferences preferences = getSharedPreferences( SharedPreferences preferences = getPrivatePreferences();
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
floatingBtn = (Button) findViewById(R.id.floating_btn); floatingBtn = (Button) findViewById(R.id.floating_btn);
pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick); pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick);
@ -595,26 +593,53 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
floatingBtn.setEnabled(true); floatingBtn.setEnabled(true);
} }
private void addLockToSendButton() {
floatingBtn.setText(R.string.action_send);
Drawable lock = AppCompatResources.getDrawable(this, R.drawable.send_private);
if (lock != null) {
lock.setBounds(0, 0, lock.getIntrinsicWidth(), lock.getIntrinsicHeight());
floatingBtn.setCompoundDrawables(null, null, lock, null);
}
}
private void setStatusVisibility(String visibility) { private void setStatusVisibility(String visibility) {
statusVisibility = visibility; statusVisibility = visibility;
switch (visibility) { switch (visibility) {
case "public": { case "public": {
floatingBtn.setText(R.string.action_send_public); floatingBtn.setText(R.string.action_send_public);
floatingBtn.setCompoundDrawables(null, null, null, null); floatingBtn.setCompoundDrawables(null, null, null, null);
break; Drawable globe = AppCompatResources.getDrawable(this, R.drawable.ic_public_24dp);
} if (globe != null) {
case "private": { visibilityBtn.setImageDrawable(globe);
floatingBtn.setText(R.string.action_send);
Drawable lock = AppCompatResources.getDrawable(this, R.drawable.send_private);
if (lock != null) {
lock.setBounds(0, 0, lock.getIntrinsicWidth(), lock.getIntrinsicHeight());
floatingBtn.setCompoundDrawables(null, null, lock, null);
} }
break; break;
} }
case "private": {
addLockToSendButton();
Drawable lock = AppCompatResources.getDrawable(this,
R.drawable.ic_lock_outline_24dp);
if (lock != null) {
visibilityBtn.setImageDrawable(lock);
}
break;
}
case "direct": {
addLockToSendButton();
Drawable envelope = AppCompatResources.getDrawable(this, R.drawable.ic_email_24dp);
if (envelope != null) {
visibilityBtn.setImageDrawable(envelope);
}
break;
}
case "unlisted":
default: { default: {
floatingBtn.setText(R.string.action_send); floatingBtn.setText(R.string.action_send);
floatingBtn.setCompoundDrawables(null, null, null, null); floatingBtn.setCompoundDrawables(null, null, null, null);
Drawable openLock = AppCompatResources.getDrawable(this,
R.drawable.ic_lock_open_24dp);
if (openLock != null) {
visibilityBtn.setImageDrawable(openLock);
}
break; break;
} }
} }
@ -728,11 +753,9 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
* the status they reply to and that behaviour needs to be kept separate. */ * the status they reply to and that behaviour needs to be kept separate. */
return; return;
} }
SharedPreferences preferences = getSharedPreferences( getPrivatePreferences().edit()
getString(R.string.preferences_file_key), Context.MODE_PRIVATE); .putString("rememberedVisibility", statusVisibility)
SharedPreferences.Editor editor = preferences.edit(); .apply();
editor.putString("rememberedVisibility", statusVisibility);
editor.apply();
} }
private EditText createEditText(String[] contentMimeTypes) { private EditText createEditText(String[] contentMimeTypes) {
@ -967,12 +990,11 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
String imageFileName = "Tusky_" + timeStamp + "_"; String imageFileName = "Tusky_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile( return File.createTempFile(
imageFileName, /* prefix */ imageFileName, /* prefix */
".jpg", /* suffix */ ".jpg", /* suffix */
storageDir /* directory */ storageDir /* directory */
); );
return image;
} }
private void initiateCameraApp() { private void initiateCameraApp() {
@ -1250,19 +1272,11 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
long mediaSize = getMediaSize(getContentResolver(), uri); long mediaSize = getMediaSize(getContentResolver(), uri);
pickMedia(uri, mediaSize); pickMedia(uri, mediaSize);
} else if (requestCode == MEDIA_TAKE_PHOTO_RESULT && resultCode == RESULT_OK) { } else if (requestCode == MEDIA_TAKE_PHOTO_RESULT && resultCode == RESULT_OK) {
queueCameraResult(); long mediaSize = getMediaSize(getContentResolver(), photoUploadUri);
pickMedia(photoUploadUri, mediaSize);
} }
} }
private void queueCameraResult() {
ContentResolver contentResolver = getContentResolver();
Cursor returnCursor = contentResolver.query(photoUploadUri, null, null, null, null);
int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE);
returnCursor.moveToFirst();
pickMedia(photoUploadUri, returnCursor.getLong(sizeIndex));
}
private void pickMedia(Uri uri, long mediaSize) { private void pickMedia(Uri uri, long mediaSize) {
ContentResolver contentResolver = getContentResolver(); ContentResolver contentResolver = getContentResolver();
if (mediaSize == MEDIA_SIZE_UNKNOWN) { if (mediaSize == MEDIA_SIZE_UNKNOWN) {

View File

@ -13,7 +13,7 @@
<string name="error_media_upload_type">Bestandstype kan niet worden geüpload.</string> <string name="error_media_upload_type">Bestandstype kan niet worden geüpload.</string>
<string name="error_media_upload_opening">Bestand kan niet worden geopend.</string> <string name="error_media_upload_opening">Bestand kan niet worden geopend.</string>
<string name="error_media_upload_permission">Toestemming nodig om media te kunnen lezen.</string> <string name="error_media_upload_permission">Toestemming nodig om media te kunnen lezen.</string>
<string name="error_media_upload_image_or_video">Afbeeldingen en video's kunnen niet allebei aan dezelfde toot worden toegevoegd.</string> <string name="error_media_upload_image_or_video">Afbeeldingen en video\'s kunnen niet allebei aan dezelfde toot worden toegevoegd.</string>
<string name="error_media_upload_sending">Uploaden mislukt.</string> <string name="error_media_upload_sending">Uploaden mislukt.</string>
<string name="error_report_too_few_statuses">Tenminste één toot moet worden gerapporteerd.</string> <string name="error_report_too_few_statuses">Tenminste één toot moet worden gerapporteerd.</string>