Merge branch 'daycode-direct-message'

main
Vavassor 8 years ago
commit 98cb5513eb
  1. 64
      app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java
  2. 12
      app/src/main/java/com/keylesspalace/tusky/ComposeOptionsFragment.java
  3. 5
      app/src/main/res/color/drawer_visibility_panel_item.xml
  4. 9
      app/src/main/res/drawable/ic_email_24dp.xml
  5. 9
      app/src/main/res/drawable/ic_lock_open_24dp.xml
  6. 9
      app/src/main/res/drawable/ic_lock_outline_24dp.xml
  7. 25
      app/src/main/res/layout/fragment_compose_options.xml
  8. 7
      app/src/main/res/values-fr/strings.xml
  9. 2
      app/src/main/res/values-nl/strings.xml
  10. 7
      app/src/main/res/values/strings.xml

@ -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);
Drawable globe = AppCompatResources.getDrawable(this, R.drawable.ic_public_24dp);
if (globe != null) {
visibilityBtn.setImageDrawable(globe);
}
break; break;
} }
case "private": { case "private": {
floatingBtn.setText(R.string.action_send); addLockToSendButton();
Drawable lock = AppCompatResources.getDrawable(this, R.drawable.send_private); Drawable lock = AppCompatResources.getDrawable(this,
R.drawable.ic_lock_outline_24dp);
if (lock != null) { if (lock != null) {
lock.setBounds(0, 0, lock.getIntrinsicWidth(), lock.getIntrinsicHeight()); visibilityBtn.setImageDrawable(lock);
floatingBtn.setCompoundDrawables(null, null, lock, null);
} }
break; 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) {

@ -73,10 +73,14 @@ public class ComposeOptionsFragment extends BottomSheetDialogFragment {
radioCheckedId = R.id.radio_unlisted; radioCheckedId = R.id.radio_unlisted;
} }
if (statusVisibility != null) { if (statusVisibility != null) {
if (statusVisibility.equals("unlisted")) { if (statusVisibility.equals("public")) {
radioCheckedId = R.id.radio_unlisted; radioCheckedId = R.id.radio_public;
} else if (statusVisibility.equals("private")) { } else if (statusVisibility.equals("private")) {
radioCheckedId = R.id.radio_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;
} }
} }
radio.check(radioCheckedId); radio.check(radioCheckedId);
@ -113,6 +117,10 @@ public class ComposeOptionsFragment extends BottomSheetDialogFragment {
visibility = "private"; visibility = "private";
break; break;
} }
case R.id.radio_direct: {
visibility = "direct";
break;
}
} }
listener.onVisibilityChanged(visibility); listener.onVisibilityChanged(visibility);
} }

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/button_dark" android:state_checked="true" />
<item android:color="?material_drawer_primary_icon" />
</selector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@color/toolbar_icon_dark"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z" />
</vector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@color/toolbar_icon_dark"
android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6h1.9c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM18,20L6,20L6,10h12v10z" />
</vector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@color/toolbar_icon_dark"
android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1s3.1,1.39 3.1,3.1v2L8.9,8L8.9,6zM18,20L6,20L6,10h12v10z" />
</vector>

@ -15,23 +15,48 @@
<RadioButton <RadioButton
android:text="@string/visibility_public" android:text="@string/visibility_public"
android:button="@drawable/ic_public_24dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/radio_public" android:id="@+id/radio_public"
android:layout_marginBottom="5dp"
android:paddingLeft="10dp"
android:buttonTint="@color/drawer_visibility_panel_item"
android:layout_weight="1" /> android:layout_weight="1" />
<RadioButton <RadioButton
android:text="@string/visibility_unlisted" android:text="@string/visibility_unlisted"
android:button="@drawable/ic_lock_open_24dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/radio_unlisted" android:id="@+id/radio_unlisted"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:paddingLeft="10dp"
android:buttonTint="@color/drawer_visibility_panel_item"
android:layout_weight="1" /> android:layout_weight="1" />
<RadioButton <RadioButton
android:text="@string/visibility_private" android:text="@string/visibility_private"
android:button="@drawable/ic_lock_outline_24dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/radio_private" android:id="@+id/radio_private"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:paddingLeft="10dp"
android:buttonTint="@color/drawer_visibility_panel_item"
android:layout_weight="1" />
<RadioButton
android:text="@string/visibility_direct"
android:button="@drawable/ic_email_24dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/radio_direct"
android:layout_marginTop="5dp"
android:paddingLeft="10dp"
android:buttonTint="@color/drawer_visibility_panel_item"
android:layout_weight="1" /> android:layout_weight="1" />
</RadioGroup> </RadioGroup>

@ -109,9 +109,10 @@
<string name="dialog_title_finishing_media_upload">Média mis en ligne avec succès</string> <string name="dialog_title_finishing_media_upload">Média mis en ligne avec succès</string>
<string name="dialog_message_uploading_media">Mise en ligne…</string> <string name="dialog_message_uploading_media">Mise en ligne…</string>
<string name="visibility_public">Afficher dans les fils publics</string> <string name="visibility_public">Public: Afficher dans les fils publics</string>
<string name="visibility_unlisted">Ne pas afficher dans les fils publics</string> <string name="visibility_unlisted">Non-listé: Ne pas afficher dans les fils publics</string>
<string name="visibility_private">N’afficher que pour vos abonné⋅e⋅s</string> <string name="visibility_private">Privé: N\'afficher que pour vos abonné⋅e⋅s</string>
<string name="visibility_direct">Direct: N\'afficher que pour les personnes mentionnées</string>
<string name="pref_title_notification_settings">Notifications</string> <string name="pref_title_notification_settings">Notifications</string>
<string name="pref_title_edit_notification_settings">Modifier la notification</string> <string name="pref_title_edit_notification_settings">Modifier la notification</string>

@ -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>

@ -125,9 +125,10 @@
<string name="dialog_message_uploading_media">Uploading…</string> <string name="dialog_message_uploading_media">Uploading…</string>
<string name="dialog_download_image">Download</string> <string name="dialog_download_image">Download</string>
<string name="visibility_public">Everyone can view</string> <string name="visibility_public">Public: Post to public timelines</string>
<string name="visibility_unlisted">Everyone can view, but not on public timelines</string> <string name="visibility_unlisted">Unlisted: Do not show in public timelines</string>
<string name="visibility_private">Only followers and mentions can view</string> <string name="visibility_private">Private: Post to followers only</string>
<string name="visibility_direct">Direct: Post to mentioned users only</string>
<string name="pref_title_notification_settings">Notifications</string> <string name="pref_title_notification_settings">Notifications</string>
<string name="pref_title_edit_notification_settings">Edit Notifications</string> <string name="pref_title_edit_notification_settings">Edit Notifications</string>

Loading…
Cancel
Save