mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 19:38:45 +00:00
clean dynamic language
This commit is contained in:
parent
0c191d5177
commit
075e265a46
@ -1,61 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.loki.database.BackupFileRecord;
|
||||
|
||||
import org.session.libsignal.utilities.externalstorage.NoExternalStorageException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
//TODO AC: Delete this class when its functionality is
|
||||
// fully replaced by the BackupUtil.kt and related classes.
|
||||
/** @deprecated in favor of {@link BackupUtil} */
|
||||
public class BackupUtilOld {
|
||||
|
||||
private static final String TAG = BackupUtilOld.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* @deprecated this method exists only for the backward compatibility with the legacy Signal backup code.
|
||||
* Use {@link BackupUtil} if possible.
|
||||
*/
|
||||
public static @Nullable BackupInfo getLatestBackup(Context context) throws NoExternalStorageException {
|
||||
BackupFileRecord backup = BackupUtil.getLastBackup(context);
|
||||
if (backup == null) return null;
|
||||
|
||||
|
||||
return new BackupInfo(
|
||||
backup.getTimestamp().getTime(),
|
||||
backup.getFileSize(),
|
||||
new File(backup.getUri().getPath()));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static class BackupInfo {
|
||||
|
||||
private final long timestamp;
|
||||
private final long size;
|
||||
private final File file;
|
||||
|
||||
BackupInfo(long timestamp, long size, File file) {
|
||||
this.timestamp = timestamp;
|
||||
this.size = size;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package org.session.libsession.utilities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import org.session.libsession.utilities.dynamiclanguage.LanguageString;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @deprecated Use a base activity that uses the {@link org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper}
|
||||
*/
|
||||
@Deprecated
|
||||
public class DynamicLanguage {
|
||||
|
||||
public void onCreate(Activity activity) {
|
||||
}
|
||||
|
||||
public void onResume(Activity activity) {
|
||||
}
|
||||
|
||||
public void updateServiceLocale(Service service) {
|
||||
setContextLocale(service, getSelectedLocale(service));
|
||||
}
|
||||
|
||||
public Locale getCurrentLocale() {
|
||||
return Locale.getDefault();
|
||||
}
|
||||
|
||||
static int getLayoutDirection(Context context) {
|
||||
Configuration configuration = context.getResources().getConfiguration();
|
||||
return configuration.getLayoutDirection();
|
||||
}
|
||||
|
||||
private static void setContextLocale(Context context, Locale selectedLocale) {
|
||||
Configuration configuration = context.getResources().getConfiguration();
|
||||
|
||||
if (!configuration.locale.equals(selectedLocale)) {
|
||||
configuration.setLocale(selectedLocale);
|
||||
context.getResources().updateConfiguration(configuration,
|
||||
context.getResources().getDisplayMetrics());
|
||||
}
|
||||
}
|
||||
|
||||
private static Locale getSelectedLocale(Context context) {
|
||||
Locale locale = LanguageString.parseLocale(TextSecurePreferences.getLanguage(context));
|
||||
if (locale == null) {
|
||||
return Locale.getDefault();
|
||||
} else {
|
||||
return locale;
|
||||
}
|
||||
}
|
||||
}
|
@ -177,24 +177,6 @@ public class ViewUtil {
|
||||
return (T)(inflater.inflate(layoutResId, parent, false));
|
||||
}
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
public static void setTextViewGravityStart(final @NonNull TextView textView, @NonNull Context context) {
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
if (DynamicLanguage.getLayoutDirection(context) == View.LAYOUT_DIRECTION_RTL) {
|
||||
textView.setGravity(Gravity.RIGHT);
|
||||
} else {
|
||||
textView.setGravity(Gravity.LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void mirrorIfRtl(View view, Context context) {
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1 &&
|
||||
DynamicLanguage.getLayoutDirection(context) == View.LAYOUT_DIRECTION_RTL) {
|
||||
view.setScaleX(-1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public static int dpToPx(Context context, int dp) {
|
||||
return (int)((dp * context.getResources().getDisplayMetrics().density) + 0.5);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user