Merge branch 'develop' into 'develop'

add option: set maximum retry times of uploading image

See merge request tom79/fedilab!281
This commit is contained in:
Thomas 2019-07-04 09:08:38 +02:00
commit 288e3b158d
5 changed files with 51 additions and 2 deletions

View File

@ -2544,6 +2544,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String scheme = sharedpreferences.getString(Helper.SET_ONION_SCHEME+Helper.getLiveInstance(context), "https");
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
int maxUploadRetryTimes = sharedpreferences.getInt(Helper.MAX_UPLOAD_IMG_RETRY_TIMES, 3);
String url = null;
if(MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
url = scheme + "://" + Helper.getLiveInstance(context) + "/api/v1/media";
@ -2563,7 +2564,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}else {
request.addFileToUpload(uri.toString().replace("file://",""), "media");
};
request.addParameter("filename", fileName).setMaxRetries(1)
request.addParameter("filename", fileName).setMaxRetries(maxUploadRetryTimes)
.startUpload();
} catch (MalformedURLException e) {
e.printStackTrace();

View File

@ -617,6 +617,22 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable
}
});
int upload_img_max_retry_times = sharedpreferences.getInt(Helper.MAX_UPLOAD_IMG_RETRY_TIMES, 3);
final SeekBar max_times_bar = rootView.findViewById(R.id.max_upload_image_retry_times);
final TextView max_times_value = rootView.findViewById(R.id.max_upload_image_retry_times_value);
max_times_bar.setProgress(upload_img_max_retry_times);
max_times_value.setText(String.valueOf(upload_img_max_retry_times));
max_times_bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override public void onStartTrackingTouch(SeekBar seekBar) {}
@Override public void onStopTrackingTouch(SeekBar seekBar) {}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
max_times_value.setText(String.valueOf(progress));
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putInt(Helper.MAX_UPLOAD_IMG_RETRY_TIMES, progress);
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

@ -402,6 +402,7 @@ public class Helper {
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 MAX_UPLOAD_IMG_RETRY_TIMES = "max_upload_img_retry_times";
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

@ -1580,6 +1580,36 @@
android:text="@string/set_photo_editor"
android:layout_height="wrap_content" />
<!-- maximum upload image retry times -->
<TextView
android:textSize="16sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/upload_image_maximum_retry_times"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_marginBottom="10dp"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content">
<TextView
android:id="@+id/max_upload_image_retry_times_value"
android:layout_gravity="center"
android:layout_width="50dp"
android:layout_height="wrap_content" />
<SeekBar
android:layout_gravity="center_vertical"
android:id="@+id/max_upload_image_retry_times"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10">
</SeekBar>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -1091,7 +1091,7 @@
<string name="set_display_video_preview_indication">Allow to play embedded videos directly in timelines</string>
<string name="set_display_content_after_fetch_more_indication">Allow to reverse the way to read statuses that are displayed once clicking the fetch more button</string>
<string name="set_security_provider_indication">This option allows to support recent cipher suites. It is useful for older Android devices or if you cannot connect to your instance.</string>
<string name="set_video_mode_indication">Exclusively for Peertube videos. Switch this mode if you cannot play them.</string>
<string name="set_video_mode_indication">Exclusively for Peertube videos. Switch this mode if you cannot read them.</string>
<string name="featured_hashtags_indication">These tags will allow to filter statuses from profiles. You will have to use the context menu for seeing them.</string>
<string name="set_capitalize_indication">Automatically insert a line break after the mention to capitalize the first letter</string>
<string name="settings_title_custom_sharing_indication">Allow content creators to share statuses to their RSS feeds</string>
@ -1099,6 +1099,7 @@
<string name="u_interface">Interface</string>
<string name="battery">Battery</string>
<string name="compose">Compose</string>
<string name="upload_image_maximum_retry_times">Upload image maximum retry times</string>
<string name="new_folder">Create a new Folder here</string>
<string name="folder_name">Enter the folder name</string>
<string name="valid_folder_name">Please enter a valid folder name</string>