Some fixes
This commit is contained in:
parent
8dc9579462
commit
b21f07dccf
|
@ -20,6 +20,7 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.AnticipateOvershootInterpolator;
|
import android.view.animation.AnticipateOvershootInterpolator;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -88,6 +90,8 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
||||||
private ConstraintLayout mRootView;
|
private ConstraintLayout mRootView;
|
||||||
private ConstraintSet mConstraintSet = new ConstraintSet();
|
private ConstraintSet mConstraintSet = new ConstraintSet();
|
||||||
private boolean mIsFilterVisible;
|
private boolean mIsFilterVisible;
|
||||||
|
private Uri uri;
|
||||||
|
private boolean exit;
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,9 +124,10 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
||||||
if( path == null) {
|
if( path == null) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
Uri uri = Uri.parse(path);
|
uri = Uri.parse(path);
|
||||||
|
|
||||||
|
|
||||||
|
exit = false;
|
||||||
|
|
||||||
setContentView(R.layout.activity_photoeditor);
|
setContentView(R.layout.activity_photoeditor);
|
||||||
|
|
||||||
|
@ -157,6 +162,17 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
||||||
|
|
||||||
//Set Image Dynamically
|
//Set Image Dynamically
|
||||||
mPhotoEditorView.getSource().setImageURI(uri);
|
mPhotoEditorView.getSource().setImageURI(uri);
|
||||||
|
|
||||||
|
|
||||||
|
Button send = findViewById(R.id.send);
|
||||||
|
|
||||||
|
send.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
exit = true;
|
||||||
|
saveImage();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
private void initViews() {
|
||||||
|
@ -264,9 +280,11 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
||||||
private void saveImage() {
|
private void saveImage() {
|
||||||
if (requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
if (requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||||
showLoading(getString(R.string.saving));
|
showLoading(getString(R.string.saving));
|
||||||
File file = new File(Environment.getExternalStorageDirectory()
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
+ File.separator + ""
|
String myDir = sharedpreferences.getString(Helper.SET_FOLDER_RECORD, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
|
||||||
+ System.currentTimeMillis() + ".png");
|
String filename = System.currentTimeMillis()+"_"+Helper.getFileName(PhotoEditorActivity.this, uri);
|
||||||
|
|
||||||
|
File file = new File(myDir+"/"+filename);
|
||||||
try {
|
try {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
|
|
||||||
|
@ -281,6 +299,12 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
||||||
hideLoading();
|
hideLoading();
|
||||||
showSnackbar(getString(R.string.image_saved));
|
showSnackbar(getString(R.string.image_saved));
|
||||||
mPhotoEditorView.getSource().setImageURI(Uri.fromFile(new File(imagePath)));
|
mPhotoEditorView.getSource().setImageURI(Uri.fromFile(new File(imagePath)));
|
||||||
|
if( exit ){
|
||||||
|
Intent intentImage = new Intent(Helper.INTENT_SEND_MODIFIED_IMAGE);
|
||||||
|
intentImage.putExtra("imgpath", imagePath);
|
||||||
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentImage);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,10 +18,13 @@ import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
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.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
@ -40,6 +43,7 @@ import android.support.annotation.RequiresApi;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.content.FileProvider;
|
import android.support.v4.content.FileProvider;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
@ -108,6 +112,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||||
import app.fedilab.android.client.API;
|
import app.fedilab.android.client.API;
|
||||||
import app.fedilab.android.client.APIResponse;
|
import app.fedilab.android.client.APIResponse;
|
||||||
import app.fedilab.android.client.Entities.Account;
|
import app.fedilab.android.client.Entities.Account;
|
||||||
|
@ -813,11 +818,26 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
||||||
});
|
});
|
||||||
|
|
||||||
toot_space_left.setText(String.valueOf(countLength()));
|
toot_space_left.setText(String.valueOf(countLength()));
|
||||||
|
|
||||||
|
LocalBroadcastManager.getInstance(this)
|
||||||
|
.registerReceiver(imageReceiver,
|
||||||
|
new IntentFilter(Helper.INTENT_SEND_MODIFIED_IMAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private BroadcastReceiver imageReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String imgpath = intent.getStringExtra("imgpath");
|
||||||
|
if( imgpath != null)
|
||||||
|
new asyncPicture(TootActivity.this, account, Uri.fromFile(new File(imgpath))).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
|
};
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
LocalBroadcastManager.getInstance(this)
|
||||||
|
.unregisterReceiver(imageReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -408,6 +408,7 @@ public class Helper {
|
||||||
public static final String EP_AUTHORIZE = "/oauth/authorize";
|
public static final String EP_AUTHORIZE = "/oauth/authorize";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Proxy
|
//Proxy
|
||||||
public static final String SET_PROXY_ENABLED = "set_proxy_enabled";
|
public static final String SET_PROXY_ENABLED = "set_proxy_enabled";
|
||||||
public static final String SET_PROXY_TYPE = "set_proxy_type";
|
public static final String SET_PROXY_TYPE = "set_proxy_type";
|
||||||
|
@ -427,6 +428,7 @@ public class Helper {
|
||||||
public static final String INTENT_ACTION = "intent_action";
|
public static final String INTENT_ACTION = "intent_action";
|
||||||
public static final String INTENT_TARGETED_ACCOUNT = "intent_targeted_account";
|
public static final String INTENT_TARGETED_ACCOUNT = "intent_targeted_account";
|
||||||
public static final String INTENT_BACKUP_FINISH = "intent_backup_finish";
|
public static final String INTENT_BACKUP_FINISH = "intent_backup_finish";
|
||||||
|
public static final String INTENT_SEND_MODIFIED_IMAGE = "intent_send_modified_image";
|
||||||
//Receiver
|
//Receiver
|
||||||
public static final String RECEIVE_DATA = "receive_data";
|
public static final String RECEIVE_DATA = "receive_data";
|
||||||
public static final String RECEIVE_ACTION = "receive_action";
|
public static final String RECEIVE_ACTION = "receive_action";
|
||||||
|
|
|
@ -135,6 +135,20 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/guideline" />
|
app:layout_constraintTop_toBottomOf="@+id/guideline" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/send"
|
||||||
|
style="@style/Widget.AppCompat.Button.Colored"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="0dp"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/imgSave"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/guideline"
|
||||||
|
android:text="@string/validate" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imgSave"
|
android:id="@+id/imgSave"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="8dp"
|
android:textSize="8sp"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/imgFilterView"
|
app:layout_constraintBottom_toBottomOf="@+id/imgFilterView"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/imgFilterView"
|
app:layout_constraintEnd_toEndOf="@+id/imgFilterView"
|
||||||
app:layout_constraintStart_toStartOf="@+id/imgFilterView"
|
app:layout_constraintStart_toStartOf="@+id/imgFilterView"
|
||||||
|
|
Loading…
Reference in New Issue