Clickable status link
This commit is contained in:
parent
ac69434ee2
commit
19a77d0dac
|
@ -191,6 +191,7 @@
|
|||
android:label="@string/app_name"
|
||||
/>
|
||||
<activity android:name=".activities.TootActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:fitsSystemWindows="true"
|
||||
android:configChanges="orientation|screenSize"
|
||||
|
|
|
@ -114,6 +114,7 @@ import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
|||
import fr.gouv.etalab.mastodon.fragments.TabLayoutSettingsFragment;
|
||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.ADD_USER_INTENT;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.BACKUP_INTENT;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
|
||||
|
@ -1216,14 +1217,24 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
} else if (type.startsWith("image/")) {
|
||||
|
||||
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
|
||||
if (imageUri != null) {
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("sharedUri", imageUri);
|
||||
b.putInt("uriNumberMast", 1);
|
||||
CrossActions.doCrossShare(BaseMainActivity.this, b);
|
||||
if( !TootActivity.active){
|
||||
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (imageUri != null) {
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("sharedUri", imageUri);
|
||||
b.putInt("uriNumberMast", 1);
|
||||
CrossActions.doCrossShare(BaseMainActivity.this, b);
|
||||
}
|
||||
}else{
|
||||
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (imageUri != null) {
|
||||
intent = new Intent(getApplicationContext(), TootActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
intent .putExtra("imageUri", imageUri.toString());
|
||||
startActivity(intent );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null ) {
|
||||
if (type.startsWith("image/")) {
|
||||
|
|
|
@ -49,7 +49,6 @@ import android.text.Html;
|
|||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -195,6 +194,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
private int stepSpliToot;
|
||||
private boolean removed;
|
||||
private boolean restoredScheduled;
|
||||
static boolean active = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -739,7 +739,6 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (requestCode == PICK_IMAGE && resultCode == Activity.RESULT_OK) {
|
||||
picture_scrollview.setVisibility(View.VISIBLE);
|
||||
if (data == null || data.getData() == null) {
|
||||
|
@ -818,6 +817,39 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null) {
|
||||
Uri imageUri = Uri.parse(extras.getString("imageUri"));
|
||||
picture_scrollview.setVisibility(View.VISIBLE);
|
||||
if( imageUri == null) {
|
||||
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String filename = Helper.getFileName(TootActivity.this, imageUri);
|
||||
ContentResolver cr = getContentResolver();
|
||||
String mime = cr.getType(imageUri);
|
||||
if(mime != null && (mime.toLowerCase().contains("video") || mime.toLowerCase().contains("gif")) ) {
|
||||
InputStream inputStream = getContentResolver().openInputStream(imageUri);
|
||||
new HttpsConnection(TootActivity.this).upload(inputStream, filename, accountReply!=null?accountReply.getToken():null, TootActivity.this);
|
||||
} else if(mime != null && mime.toLowerCase().contains("image")) {
|
||||
new asyncPicture(TootActivity.this, accountReply, intent.getData()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}else {
|
||||
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
|
||||
toot_picture.setEnabled(true);
|
||||
toot_it.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
@ -2163,7 +2195,17 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
active = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
active = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue