mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-05 19:41:57 +02:00
Merge pull request #1339 from deltachat/media-quality
use media-quality-option from core
This commit is contained in:
commit
4b200fab63
5 changed files with 38 additions and 15 deletions
|
@ -66,6 +66,9 @@ public class DcContext {
|
|||
public final static int DC_SHOW_EMAILS_ACCEPTED_CONTACTS = 1;
|
||||
public final static int DC_SHOW_EMAILS_ALL = 2;
|
||||
|
||||
public final static int DC_MEDIA_QUALITY_BALANCED = 0;
|
||||
public final static int DC_MEDIA_QUALITY_WORSE = 1;
|
||||
|
||||
public final static int DC_EMPTY_MVBOX = 0x01;
|
||||
public final static int DC_EMPTY_INBOX = 0x02;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.thoughtcrime.securesms.connect;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
|
@ -13,6 +13,8 @@ import android.os.PowerManager;
|
|||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.Toast;
|
||||
|
@ -55,6 +57,22 @@ public class ApplicationDcContext extends DcContext {
|
|||
File dbfile = AccountManager.getInstance().getSelectedAccount(context);
|
||||
open(dbfile.getAbsolutePath());
|
||||
|
||||
// migration, can be removed after some versions (added 5/2020)
|
||||
// (this will convert only for one account, but that is fine, multi-account is experimental anyway)
|
||||
try {
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if(sharedPreferences.contains("pref_compression")) {
|
||||
if (sharedPreferences.getString("pref_compression", "0").equals("1")) {
|
||||
setConfigInt(DcHelper.CONFIG_MEDIA_QUALITY, DC_MEDIA_QUALITY_WORSE);
|
||||
}
|
||||
sharedPreferences.edit().remove("pref_compression").apply();
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.e(TAG, "cannot migrate pref_compression");
|
||||
}
|
||||
// /migration
|
||||
|
||||
try {
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ public class DcHelper {
|
|||
public static final String CONFIG_MVBOX_MOVE = "mvbox_move";
|
||||
public static final String CONFIG_BCC_SELF = "bcc_self";
|
||||
public static final String CONFIG_SHOW_EMAILS = "show_emails";
|
||||
public static final String CONFIG_MEDIA_QUALITY = "media_quality";
|
||||
|
||||
public static ApplicationDcContext getContext(Context context) {
|
||||
return ApplicationContext.getInstance(context).dcContext;
|
||||
|
|
|
@ -8,12 +8,9 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.CheckBoxPreference;
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Toast;
|
||||
|
@ -25,7 +22,6 @@ import org.thoughtcrime.securesms.BlockedAndShareContactsActivity;
|
|||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.ScreenLockUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
|
@ -37,6 +33,7 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
|||
|
||||
|
||||
private ListPreference showEmails;
|
||||
private ListPreference mediaQuality;
|
||||
private CheckBoxPreference readReceiptsCheckbox;
|
||||
|
||||
private ListPreference autoDelDevice;
|
||||
|
@ -46,8 +43,12 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
|||
public void onCreate(Bundle paramBundle) {
|
||||
super.onCreate(paramBundle);
|
||||
|
||||
findPreference("pref_compression")
|
||||
.setOnPreferenceChangeListener(new ListSummaryListener());
|
||||
mediaQuality = (ListPreference) this.findPreference("pref_compression");
|
||||
mediaQuality.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
updateListSummary(preference, newValue);
|
||||
dcContext.setConfigInt(DcHelper.CONFIG_MEDIA_QUALITY, Util.objectToInt(newValue));
|
||||
return true;
|
||||
});
|
||||
|
||||
showEmails = (ListPreference) this.findPreference("pref_show_emails");
|
||||
showEmails.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
|
@ -81,11 +82,14 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
|||
super.onResume();
|
||||
((ApplicationPreferencesActivity)getActivity()).getSupportActionBar().setTitle(R.string.pref_chats_and_media);
|
||||
|
||||
initializeListSummary((ListPreference) findPreference("pref_compression"));
|
||||
|
||||
String value = Integer.toString(dcContext.getConfigInt("show_emails"));
|
||||
showEmails.setValue(value);
|
||||
updateListSummary(showEmails, value);
|
||||
|
||||
value = Integer.toString(dcContext.getConfigInt(DcHelper.CONFIG_MEDIA_QUALITY));
|
||||
mediaQuality.setValue(value);
|
||||
updateListSummary(mediaQuality, value);
|
||||
|
||||
readReceiptsCheckbox.setChecked(0 != dcContext.getConfigInt("mdns_enabled"));
|
||||
|
||||
initAutodelFromCore();
|
||||
|
|
|
@ -12,8 +12,10 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -173,12 +175,7 @@ public class Prefs {
|
|||
}
|
||||
|
||||
public static boolean isHardCompressionEnabled(Context context) {
|
||||
try {
|
||||
return getStringPreference(context, "pref_compression", "0").equals("1");
|
||||
}
|
||||
catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
return DcHelper.getContext(context).getConfigInt(DcHelper.CONFIG_MEDIA_QUALITY) == DcContext.DC_MEDIA_QUALITY_WORSE;
|
||||
}
|
||||
|
||||
public static boolean isLocationStreamingEnabled(Context context) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue