Allow to disable photo editor

This commit is contained in:
tom79 2019-05-31 18:20:54 +02:00
parent 4c848f8ac8
commit 3dd634e3ee
6 changed files with 54 additions and 15 deletions

View File

@ -113,7 +113,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import app.fedilab.android.BuildConfig;
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
import app.fedilab.android.client.API;
import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.Entities.Account;
@ -161,8 +160,6 @@ import app.fedilab.android.interfaces.OnRetrieveAttachmentInterface;
import app.fedilab.android.interfaces.OnRetrieveEmojiInterface;
import app.fedilab.android.interfaces.OnRetrieveSearcAccountshInterface;
import app.fedilab.android.interfaces.OnRetrieveSearchInterface;
import ja.burhanrashid52.photoeditor.PhotoEditor;
import ja.burhanrashid52.photoeditor.PhotoEditorView;
import static app.fedilab.android.helper.Helper.changeDrawableColor;
import static app.fedilab.android.helper.Helper.countWithEmoji;
@ -943,6 +940,8 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true);
if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) {
picture_scrollview.setVisibility(View.VISIBLE);
if (data == null) {
@ -972,12 +971,15 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
InputStream inputStream = getContentResolver().openInputStream(data.getData());
new HttpsConnection(TootActivity.this, instance).upload(inputStream, filename, account, TootActivity.this);
} else if (mime != null && mime.toLowerCase().contains("image")) {
Intent intent = new Intent(TootActivity.this, PhotoEditorActivity.class);
Bundle b = new Bundle();
intent.putExtra("imageUri", data.getData().toString());
intent.putExtras(b);
startActivity(intent);
if( photo_editor) {
Intent intent = new Intent(TootActivity.this, PhotoEditorActivity.class);
Bundle b = new Bundle();
intent.putExtra("imageUri", data.getData().toString());
intent.putExtras(b);
startActivity(intent);
}else{
new asyncPicture(TootActivity.this, account, data.getData()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}else {
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
}
@ -996,12 +998,15 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
toot_content.setSelection(toot_content.getText().length());
}
}else if (requestCode == TAKE_PHOTO && resultCode == RESULT_OK) {
Intent intent = new Intent(TootActivity.this, PhotoEditorActivity.class);
Bundle b = new Bundle();
intent.putExtra("imageUri", photoFileUri.toString());
intent.putExtras(b);
startActivity(intent);
//new asyncPicture(TootActivity.this, account, photoFileUri).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if( photo_editor) {
Intent intent = new Intent(TootActivity.this, PhotoEditorActivity.class);
Bundle b = new Bundle();
intent.putExtra("imageUri", photoFileUri.toString());
intent.putExtras(b);
startActivity(intent);
}else {
new asyncPicture(TootActivity.this, account, photoFileUri).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
}

View File

@ -464,6 +464,20 @@ public class SettingsFragment extends Fragment {
}
});
boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true);
final CheckBox set_photo_editor = rootView.findViewById(R.id.set_photo_editor);
set_photo_editor.setChecked(photo_editor);
set_photo_editor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_PHOTO_EDITOR, set_photo_editor.isChecked());
editor.apply();
}
});
boolean remember_position_home = sharedpreferences.getBoolean(Helper.SET_REMEMBER_POSITION_HOME, true);
final CheckBox set_remember_position = rootView.findViewById(R.id.set_remember_position);
set_remember_position.setChecked(remember_position_home);

View File

@ -384,6 +384,7 @@ public class Helper {
public static final String SET_NOTIF_SILENT = "set_notif_silent";
public static final String SET_EXPAND_CW = "set_expand_cw";
public static final String SET_EXPAND_MEDIA = "set_expand_media";
public static final String SET_PHOTO_EDITOR = "set_photo_editor";
public static final String SET_DISPLAY_FOLLOW_INSTANCE = "set_display_follow_instance";
public static final String SET_DISPLAY_NEW_BADGE = "set_display_new_badge";
public static final String SET_DISPLAY_BOT_ICON = "set_display_bot_icon";

View File

@ -432,12 +432,21 @@
android:text="@string/set_forward_tags"
android:layout_height="wrap_content" />
<EditText
android:hint="@string/settings_custom_sharing_url"
android:id="@+id/custom_sharing_url"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/set_photo_editor"
android:layout_width="wrap_content"
android:layout_marginTop="@dimen/settings_checkbox_margin"
android:layout_marginBottom="@dimen/settings_checkbox_margin"
android:text="@string/set_photo_editor"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -443,6 +443,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/set_photo_editor"
android:layout_width="wrap_content"
android:layout_marginTop="@dimen/settings_checkbox_margin"
android:layout_marginBottom="@dimen/settings_checkbox_margin"
android:text="@string/set_photo_editor"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -977,6 +977,7 @@
<string name="save_image_failed">Failed to save Image</string>
<string name="opacity">Opacity</string>
<string name="label_crop">Crop</string>
<string name="set_photo_editor">Enable photo editor</string>
<plurals name="number_of_vote">
<item quantity="one">%d vote</item>
<item quantity="other">%d votes</item>