Compare commits

...

42 Commits

Author SHA1 Message Date
B. Petersen edd4176890 Update messenger-backend submodule. 2017-03-28 16:00:23 +02:00
B. Petersen f4f27ac0ae Changelog. 2017-03-28 16:00:04 +02:00
B. Petersen aeb297548c Remove unused variable. 2017-03-28 11:04:52 +02:00
B. Petersen eb3aa46ff7 After the app is paused, show messages the next 10 minutes immediately. Affter that, we sleep most time (11/12th=55 seconds) of a minute. 2017-03-28 10:59:50 +02:00
B. Petersen 05fbf5bdce Add missing file. 2017-03-27 22:17:03 +02:00
B. Petersen 8a5f05fe2e Create an alert that wakes up the app from time to time; if there's stuff to do, the backend acquires a wake loke then. Additionally, if the app is just dismissed, we keep another wakelock for some minutes to catch messages the user just expects in that moment. 2017-03-27 22:16:26 +02:00
B. Petersen 590841d139 Clearer bootup-code naming. 2017-03-24 19:36:16 +01:00
B. Petersen 44caf01cae Cleanup code to load the native library. 2017-03-24 17:11:31 +01:00
B. Petersen db36341251 Cleanup. 2017-03-24 15:43:28 +01:00
B. Petersen 0a63816ece Acquire wakeLock to receive notifications if 'keep-alive' is on. 2017-03-23 22:18:17 +01:00
B. Petersen ceb0155f5f Cleanup keep-alive code. 2017-03-23 21:01:36 +01:00
B. Petersen 723e677b2b Use more general text 'Audio' instead of 'Music' for audio-files with unknown content. 2017-03-23 16:00:11 +01:00
B. Petersen fab24ee956 Update messenger-backend submodule. 2017-03-22 23:26:07 +01:00
B. Petersen 94f4c8b302 Update changelog. 2017-03-22 23:25:50 +01:00
B. Petersen 008a2410a7 Update changelog. 2017-03-22 15:55:46 +01:00
B. Petersen b43f337af9 Show language name in english in language select activity. 2017-03-22 15:49:56 +01:00
Björn Petersen 21895cf00f Merge pull request #59 from aligitor/master
Add Hungarian translation.
2017-03-22 15:31:53 +01:00
aligitor 721d016d86 Create strings.xml
Hungarian translation file.
2017-03-22 12:42:38 +01:00
B. Petersen 89aaa9c072 Show percentage in the configuration progress dialog. 2017-03-22 00:04:27 +01:00
B. Petersen bcb00a9d23 Add IMAP/SMTP security options. 2017-03-20 21:11:59 +01:00
B. Petersen 34cd40fdd9 Support HTML-only messages. 2017-03-18 11:18:35 +01:00
B. Petersen c8001cedce Provide an http/https-get function for the backend. 2017-03-15 22:23:28 +01:00
B. Petersen 880353888b Add input types for the account configuration dialog. 2017-03-15 21:04:10 +01:00
B. Petersen 2c67d20233 Add options for SSL/TLS and STARTTLS. 2017-03-15 16:32:15 +01:00
B. Petersen 42c08a4d5b Test IMAP and SMTP server when calling the configure-function. 2017-03-14 18:25:20 +01:00
B. Petersen 01bf0f3af5 Remove unused notifications. 2017-03-14 11:41:29 +01:00
B. Petersen e765968c2c Language (do not show 'configuring account' message as the may be interpreted as we do something with the server settings). 2017-03-14 11:09:49 +01:00
B. Petersen 3837463e41 Use larger labels for the basic account settings. 2017-03-13 23:37:13 +01:00
B. Petersen 545a2ddc24 Hide advanced account settings by default (in general, we'll try to find them out automatically). 2017-03-13 23:12:56 +01:00
B. Petersen 4f6f0b4685 Cleanup cache settings code. 2017-03-13 19:36:41 +01:00
B. Petersen 1d1bad8b3b Fine-tuning error handling. 2017-03-13 14:00:30 +01:00
B. Petersen af5769f231 Improve error handling. 2017-03-12 21:03:28 +01:00
B. Petersen 42c6337c4d Show popup errors. 2017-03-12 00:33:08 +01:00
B. Petersen 37a49c9d39 Add Korean. 2017-03-11 22:41:45 +01:00
B. Petersen 3b2f778114 Repair 'Default language' option and cleanup some language stuff. 2017-03-11 21:10:31 +01:00
B. Petersen b55cc03f6d Correct string. 2017-03-11 18:31:02 +01:00
B. Petersen 2e6eead045 Change the order of the account input fields. 2017-03-11 18:17:44 +01:00
B. Petersen e77c3303a1 Show versionCode in about dialog. 2017-03-11 11:55:32 +01:00
B. Petersen e83c4f315c Force unique video names in the blob directory. 2017-03-11 11:35:34 +01:00
B. Petersen 833c75d874 Change order of 'new group icons'. 2017-03-11 10:45:47 +01:00
B. Petersen 9688003648 Force video-recoding for videos which size is okay but the bitrate is too high. Correct maximum bitrate handing (was checked too son before and scaled down afterwards, on typical devices, this resulted in a bitrate of about 500 kbit which we use as a maximum now; everyone is welcome to improve all this stuff). 2017-03-10 19:15:54 +01:00
B. Petersen a2609d5bbe Catch video thumbnail creation errors. 2017-03-10 19:11:49 +01:00
77 changed files with 1798 additions and 2899 deletions
+17
View File
@@ -1,5 +1,22 @@
# Delta Chat Changelog
## v0.1.23
2017-03-28
* Retry connecting to IMAP if there is not network available on the first try
* Notify about new messages if the app is not active for hours, optimize battery consumption
## v0.1.22
2017-03-22
* Show HTML-only messages
* Show connection errors
* Add options for SSL/TLS and STARTTLS
* Automatic account configuration, if possible
* Recode large videos
* Add Hungarian translation
* Add Korean translation
## v0.1.21
2017-03-10
+4 -4
View File
@@ -76,7 +76,7 @@ android {
}
}
defaultConfig.versionCode = 20
defaultConfig.versionCode = 22
sourceSets.main {
jniLibs.srcDir 'libs'
@@ -115,8 +115,8 @@ android {
}
defaultConfig {
minSdkVersion 14 // 14: Android 4.0 Ice Cream Sandwich 2011 (Telegram default), 21: Android 5.0 Lollipop 2014 (recommended for InstantRun)
targetSdkVersion 25
versionName "0.1.21" // do NOT forget to increase defaultConfig.versionCode!
minSdkVersion 14 // 14: Android 4.0 Ice Cream Sandwich 2011 (Telegram default), 21: Android 5.0 Lollipop 2014 (recommended for InstantRun)
targetSdkVersion 25 // 25: Nougat. CAVE: Do NOT target "Andoid O" without checking the background tasks carefully, see https://developer.android.com/preview/behavior-changes.html#back-all . As long as we target "Nougat", everything works as expected even for "Andoid O" or later
versionName "0.1.23" // do NOT forget to increase defaultConfig.versionCode!
}
}
+3 -1
View File
@@ -1611,14 +1611,16 @@ LOCAL_SRC_FILES += \
./messenger-backend/src/mre2ee.c \
./messenger-backend/src/mrimap.c \
./messenger-backend/src/mrjob.c \
./messenger-backend/src/mrlog.c \
./messenger-backend/src/mrloginparam.c \
./messenger-backend/src/mrmailbox.c \
./messenger-backend/src/mrmailbox_configure.c \
./messenger-backend/src/mrmailbox_log.c \
./messenger-backend/src/mrmimeparser.c \
./messenger-backend/src/mrmsg.c \
./messenger-backend/src/mrosnative.c \
./messenger-backend/src/mrparam.c \
./messenger-backend/src/mrpoortext.c \
./messenger-backend/src/mrsaxparser.c \
./messenger-backend/src/mrsimplify.c \
./messenger-backend/src/mrsmtp.c \
./messenger-backend/src/mrsqlite3.c \
+61 -52
View File
@@ -66,45 +66,49 @@ static jstring jstring_new__(JNIEnv* env, const char* a)
}
/* our log handler */
static void s_log_callback_(int type, const char* msg)
{
int prio;
switch( type ) {
case 'd': prio = ANDROID_LOG_DEBUG; break;
case 'i': prio = ANDROID_LOG_INFO; break;
case 'w': prio = ANDROID_LOG_WARN; break;
default: prio = ANDROID_LOG_ERROR; break;
}
__android_log_print(prio, "DeltaChat", "%s\n", msg); /* on problems, add `-llog` to `Android.mk` */
}
/* global stuff */
static JavaVM* s_jvm = NULL;
static jclass s_MrMailbox_class = NULL;
static jmethodID s_MrCallback_methodID = NULL;
static int s_global_init_done = 0;
static void s_init_globals(JNIEnv *env, jclass MrMailbox_class)
{
/* make sure, the intialisation is done only once */
static bool s_global_init_done = 0;
if( s_global_init_done ) { return; }
s_global_init_done = 1;
/* init global callback */
mrlog_set_handler(s_log_callback_);
/* prepare calling back a Java function */
(*env)->GetJavaVM(env, &s_jvm); /* JNIEnv cannot be shared between threads, so we share the JavaVM object */
s_MrMailbox_class = (*env)->NewGlobalRef(env, MrMailbox_class);
s_MrCallback_methodID = (*env)->GetStaticMethodID(env, MrMailbox_class, "MrCallback","(IJJ)J" /*signature as "(param)ret" with I=int, J=long*/ );
}
/* system-specific backend initialisations */
mrosnative_init_android(env); /*this should be called before any other "important" routine is called*/
/* setup threads, only called directly by the backed */
int mrosnative_setup_thread(mrmailbox_t* mailbox)
{
if( s_jvm == NULL ) {
mrmailbox_log_error(mailbox, 0, "Not ready, cannot setup thread.");
return 0;
}
mrmailbox_log_info(mailbox, 0, "Attaching C-thread to Java VM...");
JNIEnv* env = NULL;
(*s_jvm)->AttachCurrentThread(s_jvm, &env, NULL);
mrmailbox_log_info(mailbox, 0, "Attaching ok.");
return 1;
}
void mrosnative_unsetup_thread(mrmailbox_t* mailbox)
{
mrmailbox_log_info(mailbox, 0, "Detaching C-thread from Java VM...");
(*s_jvm)->DetachCurrentThread(s_jvm);
mrmailbox_log_info(mailbox, 0, "Detaching done.");
}
@@ -189,15 +193,22 @@ static uintptr_t s_mailbox_callback_(mrmailbox_t* mailbox, int event, uintptr_t
jlong l;
JNIEnv* env;
if( event==MR_EVENT_INFO || event==MR_EVENT_WARNING ) {
__android_log_print(event==MR_EVENT_INFO? ANDROID_LOG_INFO : ANDROID_LOG_WARN, "DeltaChat", "%s", (char*)data2); /* on problems, add `-llog` to `Android.mk` */
return 0; /* speed up things for info/warning */
}
else if( event == MR_EVENT_ERROR ) {
__android_log_print(ANDROID_LOG_ERROR, "DeltaChat", "%s", (char*)data2);
/* errors are also forwarded to Java to show them in a bubble or so */
}
if( s_jvm==NULL || s_MrMailbox_class==NULL || s_MrCallback_methodID==NULL ) {
s_log_callback_('e', "Callback called but JavaVM not ready.");
return 0;
return 0; /* may happen on startup */
}
(*s_jvm)->GetEnv(s_jvm, &env, JNI_VERSION_1_6); /* as this function may be called from _any_ thread, we cannot use a static pointer to JNIEnv */
if( env==NULL ) {
s_log_callback_('e', "Callback called but cannot get JNIEnv.");
return 0;
return 0; /* may happen on startup */
}
l = (*env)->CallStaticLongMethod(env, s_MrMailbox_class, s_MrCallback_methodID, (jint)event, (jlong)data1, (jlong)data2);
@@ -236,42 +247,33 @@ JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getBlobdir(JNIEnv *env, jcla
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxConfigure(JNIEnv *env, jclass c, jlong hMailbox)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_configureAndConnect(JNIEnv *env, jclass cls)
{
return mrmailbox_configure((mrmailbox_t*)hMailbox);
mrmailbox_configure_and_connect(get_mrmailbox_t(env, cls));
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxIsConfigured(JNIEnv *env, jclass c, jlong hMailbox)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_configureCancel(JNIEnv *env, jclass cls)
{
return (jint)mrmailbox_is_configured((mrmailbox_t*)hMailbox);
mrmailbox_configure_cancel(get_mrmailbox_t(env, cls));
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxConnect(JNIEnv *env, jclass c, jlong hMailbox)
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_isConfigured(JNIEnv *env, jclass cls)
{
return mrmailbox_connect((mrmailbox_t*)hMailbox);
return (jint)mrmailbox_is_configured(get_mrmailbox_t(env, cls));
}
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_MrMailboxDisconnect(JNIEnv *env, jclass c, jlong hMailbox)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_connect(JNIEnv *env, jclass cls)
{
mrmailbox_disconnect((mrmailbox_t*)hMailbox);
mrmailbox_connect(get_mrmailbox_t(env, cls));
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxFetch(JNIEnv *env, jclass c, jlong hMailbox)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_disconnect(JNIEnv *env, jclass cls)
{
return mrmailbox_fetch((mrmailbox_t*)hMailbox);
}
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getErrorDescr(JNIEnv *env, jclass cls)
{
char* c = mrmailbox_get_error_descr(get_mrmailbox_t(env, cls));
jstring ret = JSTRING_NEW(c);
free(c);
return ret;
mrmailbox_disconnect(get_mrmailbox_t(env, cls));
}
@@ -454,22 +456,29 @@ JNIEXPORT void Java_com_b44t_messenger_MrMailbox_forwardMsgs(JNIEnv *env, jclass
/* MrMailbox - handle config */
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxSetConfig(JNIEnv *env, jclass c, jlong hMailbox, jstring key, jstring value)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_setConfig(JNIEnv *env, jclass cls, jstring key, jstring value)
{
CHAR_REF(key);
CHAR_REF(value);
jint ret = (jint)mrmailbox_set_config((mrmailbox_t*)hMailbox, keyPtr, valuePtr);
mrmailbox_set_config(get_mrmailbox_t(env, cls), keyPtr, valuePtr);
CHAR_UNREF(key);
CHAR_UNREF(value);
return ret;
}
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_MrMailboxGetConfig(JNIEnv *env, jclass c, jlong hMailbox, jstring key, jstring def)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_setConfigInt(JNIEnv *env, jclass cls, jstring key, jint value)
{
CHAR_REF(key);
mrmailbox_set_config_int(get_mrmailbox_t(env, cls), keyPtr, value);
CHAR_UNREF(key);
}
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getConfig(JNIEnv *env, jclass cls, jstring key, jstring def)
{
CHAR_REF(key);
CHAR_REF(def);
char* temp = mrmailbox_get_config((mrmailbox_t*)hMailbox, keyPtr, defPtr);
char* temp = mrmailbox_get_config(get_mrmailbox_t(env, cls), keyPtr, defPtr);
jstring ret = JSTRING_NEW(temp);
free(temp);
CHAR_UNREF(key);
@@ -478,10 +487,10 @@ JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_MrMailboxGetConfig(JNIEnv *e
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxGetConfigInt(JNIEnv *env, jclass c, jlong hMailbox, jstring key, jint def)
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_getConfigInt(JNIEnv *env, jclass cls, jstring key, jint def)
{
CHAR_REF(key);
jint ret = mrmailbox_get_config_int((mrmailbox_t*)hMailbox, keyPtr, def);
jint ret = mrmailbox_get_config_int(get_mrmailbox_t(env, cls), keyPtr, def);
CHAR_UNREF(key);
return ret;
}
+4 -4
View File
@@ -191,9 +191,8 @@
</intent-filter>
</service> -->
<service android:name=".NotificationsService" android:enabled="true"/>
<service android:name=".KeepAliveService" android:enabled="true"/>
<service android:name=".NotificationRepeat" android:exported="false"/>
<service android:name=".ClearCacheService" android:exported="false"/>
<service android:name=".MusicPlayerService" android:exported="true" android:enabled="true"/>
<!-- Do not expose data through MediaBrowserService, this seems unexpected for an messenger.
Instead, the user can use 'save to music' or 'share' explicitly for items not privacy related.
@@ -215,9 +214,8 @@
</intent-filter>
</receiver>
<receiver android:name=".AppStartReceiver" android:enabled="true">
<receiver android:name=".BootCompletedReceiver" android:enabled="true">
<intent-filter>
<action android:name="com.b44t.start" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
@@ -229,6 +227,8 @@
<receiver android:name=".ShareBroadcastReceiver" android:enabled="true"/>
-->
<receiver android:name=".TimerReceiver" android:enabled="true"/>
<receiver android:name=".NotificationDismissReceiver" android:exported="false"/>
<provider android:name=".AttachmentsContentProvider" android:authorities="${applicationId}.attachments" android:exported="true" />
@@ -593,7 +593,7 @@ public class AndroidUtilities {
ForegroundDetector.getInstance().resetBackgroundVar();
}
return UserConfig.passcodeHash.length() > 0 && wasInBackground &&
(UserConfig.appLocked || UserConfig.autoLockIn != 0 && UserConfig.lastPauseTime != 0 && !UserConfig.appLocked && (UserConfig.lastPauseTime + UserConfig.autoLockIn) <= ConnectionsManager.getInstance().getCurrentTime());
(UserConfig.appLocked || UserConfig.autoLockIn != 0 && UserConfig.lastPauseTime != 0 && !UserConfig.appLocked && (UserConfig.lastPauseTime + UserConfig.autoLockIn) <= MrMailbox.getCurrentTime());
}
public static void shakeView(final View view, final float x, final int num) {
@@ -937,7 +937,7 @@ public class AndroidUtilities {
}
}
private static File getFineFilename(File path, String desiredName)
public static File getFineFilename(File path, String desiredName)
{
// get a fine file name by adding a number to the basename and avoid overwrites
for( int i = 0; i < 1000; i++ ) {
@@ -33,40 +33,38 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Handler;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.Log;
import com.b44t.ui.Components.ForegroundDetector;
import com.b44t.ui.SettingsAdvActivity;
import java.io.File;
public class ApplicationLoader extends Application {
private static PendingIntent pendingIntent;
private static Drawable cachedWallpaper;
private static int selectedColor;
private static boolean isCustomTheme;
private static final Object sync = new Object();
public static volatile Context applicationContext;
public static volatile Handler applicationHandler;
private static volatile boolean applicationInited = false;
public static volatile boolean isScreenOn = false;
public static volatile boolean mainInterfacePaused = true;
public static boolean isCustomTheme() {
return isCustomTheme;
}
public static PowerManager.WakeLock backendWakeLock = null;
public static PowerManager.WakeLock wakeupWakeLock = null;
private static PowerManager.WakeLock stayAwakeWakeLock = null;
public static int getSelectedColor() {
return selectedColor;
}
public static int fontSize;
public static void reloadWallpaper() {
cachedWallpaper = null;
@@ -93,15 +91,12 @@ public class ApplicationLoader extends Application {
if (selectedColor == 0) {
if (selectedBackground == 1000001) {
cachedWallpaper = applicationContext.getResources().getDrawable(R.drawable.background_hd);
isCustomTheme = false;
} else {
File toFile = new File(getFilesDirFixed(), "wallpaper.jpg");
if (toFile.exists()) {
cachedWallpaper = Drawable.createFromPath(toFile.getAbsolutePath());
isCustomTheme = true;
} else {
cachedWallpaper = applicationContext.getResources().getDrawable(R.drawable.background_hd);
isCustomTheme = false;
}
}
}
@@ -140,23 +135,54 @@ public class ApplicationLoader extends Application {
} catch (Exception e) {
FileLog.e("messenger", e);
}
return new File("/data/data/com.b44t.messenger/files"); // EDIT BY MR
return new File("/data/data/com.b44t.messenger/files");
}
public static void postInitApplication() {
if (applicationInited) {
return;
@Override
public void onCreate() {
Log.i("DeltaChat", "*************** ApplicationLoader.onCreate() ***************");
super.onCreate();
applicationContext = getApplicationContext();
System.loadLibrary("messenger.1");
new ForegroundDetector(this);
applicationHandler = new Handler(applicationContext.getMainLooper());
// create wake locks
try {
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
backendWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "backendWakeLock" /*any name*/);
// bakendWakeLock _is_ reference counted by the backend (every acquire() has a release())
wakeupWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "wakeupWakeLock" /*any name*/);
wakeupWakeLock.setReferenceCounted(false);
stayAwakeWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "stayAwakeWakeLock" /*any name*/);
stayAwakeWakeLock.setReferenceCounted(false);
} catch (Exception e) {
Log.e("DeltaChat", "Cannot acquire wakeLock");
}
applicationInited = true;
//convertConfig();
// create a MrMailbox object; as android stops the App by just killing it, we do never call MrMailboxUnref()
// however, we may want to to have a look at onPause() eg. of activities (eg. for flushing data, if needed)
MrMailbox.MrCallback(0, 0, 0); // do not remove this call; this makes sure, the function is not removed from build or warnings are printed!
MrMailbox.init();
// start keep-alive service that restarts the app as soon it is terminated
// (this is done by just marking the service as START_STICKY which recreates the service as
// it goes away which also inititialized the app indirectly by calling this function)
applicationContext.startService(new Intent(applicationContext, KeepAliveService.class));
// init locale
try {
LocaleController.getInstance();
} catch (Exception e) {
e.printStackTrace();
}
// track screen on/ff
try {
final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
@@ -175,43 +201,27 @@ public class ApplicationLoader extends Application {
}
UserConfig.loadConfig();
String deviceModel;
String langCode;
String appVersion;
String systemVersion;
String configPath = getFilesDirFixed().toString();
try {
langCode = LocaleController.getLocaleStringIso639();
deviceModel = Build.MANUFACTURER + Build.MODEL;
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
appVersion = pInfo.versionName + " (" + pInfo.versionCode + ")";
systemVersion = "SDK " + Build.VERSION.SDK_INT;
} catch (Exception e) {
langCode = "en";
deviceModel = "Android unknown";
appVersion = "App version unknown";
systemVersion = "SDK " + Build.VERSION.SDK_INT;
// create a timer that wakes up the CPU from time to time
try
{
Intent intent = new Intent(applicationContext, TimerReceiver.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(applicationContext, 0, intent, 0);
AlarmManager alarmManager = (AlarmManager)applicationContext.getSystemService(Activity.ALARM_SERVICE);
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime()+60*1000,
60*1000,
alarmIntent);
}
if (langCode.trim().length() == 0) {
langCode = "en";
}
if (deviceModel.trim().length() == 0) {
deviceModel = "Android unknown";
}
if (appVersion.trim().length() == 0) {
appVersion = "App version unknown";
}
if (systemVersion.trim().length() == 0) {
systemVersion = "SDK Unknown";
catch( Exception e) {
Log.e("DeltaChat", "Cannot create alarm.");
}
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean enablePushConnection = preferences.getBoolean("pushConnection", true);
if( preferences.getInt("notify2_"+MrChat.MR_CHAT_ID_DEADDROP, 666)==666 ) {
// make sure, the notifications for the "deaddrop" dialog are muted by default
SharedPreferences.Editor editor = preferences.edit();
// make sure, the notifications for the "deaddrop" dialog are muted by default
SharedPreferences notificationPreferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if( notificationPreferences.getInt("notify2_"+MrChat.MR_CHAT_ID_DEADDROP, 666)==666 ) {
SharedPreferences.Editor editor = notificationPreferences.edit();
editor.putInt("notify2_"+MrChat.MR_CHAT_ID_DEADDROP, 2);
editor.apply();
}
@@ -223,59 +233,13 @@ public class ApplicationLoader extends Application {
MrMailbox.connect();
// create other default objects
MessagesController.getInstance();
ConnectionsManager.getInstance().init(deviceModel, systemVersion, appVersion, langCode, configPath, FileLog.getNetworkLogPath(), UserConfig.getClientUserId(), enablePushConnection);
if (UserConfig.getCurrentUser() != null) {
SendMessagesHelper.getInstance().checkUnsentMessages();
}
SharedPreferences mainPreferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
fontSize = mainPreferences.getInt("msg_font_size", SettingsAdvActivity.defMsgFontSize());
ImageLoader.getInstance();
MediaController.getInstance();
}
@Override
public void onCreate() {
super.onCreate();
applicationContext = getApplicationContext();
NativeLoader.initNativeLibs(ApplicationLoader.applicationContext);
//ConnectionsManager.native_setJava(Build.VERSION.SDK_INT == 14 || Build.VERSION.SDK_INT == 15);
new ForegroundDetector(this);
// EDIT BY MR - create a MrMailbox object; as android stops the App by just killing it, we do never call MrMailboxUnref()
// however, we may want to to have a look at onPause() eg. of activities (eg. for flushing data, if needed)
MrMailbox.MrCallback(0, 0, 0); // do not remove this call; this makes sure, the function is not removed from build or warnings are printed!
MrMailbox.init();
applicationHandler = new Handler(applicationContext.getMainLooper());
startPushService();
}
public static void startPushService() {
SharedPreferences preferences = applicationContext.getSharedPreferences("Notifications", MODE_PRIVATE);
if (preferences.getBoolean("pushService", true)) {
AlarmManager am = (AlarmManager) applicationContext.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(applicationContext, ApplicationLoader.class);
pendingIntent = PendingIntent.getBroadcast(applicationContext, 0, i, 0);
am.cancel(pendingIntent);
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 60000, pendingIntent);
applicationContext.startService(new Intent(applicationContext, NotificationsService.class));
} else {
stopPushService();
}
}
public static void stopPushService() {
applicationContext.stopService(new Intent(applicationContext, NotificationsService.class));
PendingIntent pintent = PendingIntent.getService(applicationContext, 0, new Intent(applicationContext, NotificationsService.class), 0);
AlarmManager alarm = (AlarmManager)applicationContext.getSystemService(Context.ALARM_SERVICE);
alarm.cancel(pintent);
alarm.cancel(pendingIntent);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
@@ -286,4 +250,27 @@ public class ApplicationLoader extends Application {
e.printStackTrace();
}
}
private static int lastClassGuid = 1;
public static int generateClassGuid() {
return lastClassGuid++;
}
public static boolean isNetworkOnline() {
try {
ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnected()) {
return true;
}
} catch (Exception e) {
}
return false;
}
public static void stayAwakeForAMoment()
{
stayAwakeWakeLock.acquire(10*60*1000); // 10 Minutes to wait for "after chat" messages, after that, we sleep most time, see wakeupWakeLock
}
}
@@ -26,12 +26,13 @@ package com.b44t.messenger;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class AutoMessageHeardReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ApplicationLoader.postInitApplication();
long dialog_id = intent.getLongExtra("dialog_id", 0);
int max_id = intent.getIntExtra("max_id", 0);
if (dialog_id == 0 || max_id == 0) {
@@ -28,12 +28,13 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.RemoteInput;
import android.util.Log;
public class AutoMessageReplyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ApplicationLoader.postInitApplication();
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
if (remoteInput == null) {
return;
@@ -1,7 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -26,14 +25,13 @@ package com.b44t.messenger;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class AppStartReceiver extends BroadcastReceiver {
public class BootCompletedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
ApplicationLoader.startPushService();
}
});
Log.i("DeltaChat", "*** BootCompletedReceiver.onReceive()");
// there's nothing more to do here as all initialisation stuff is already done in
// ApplicationLoader.onCreate() which is called before this broadcast is sended.
}
}
@@ -1,99 +0,0 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
package com.b44t.messenger;
import android.app.Activity;
import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.system.Os;
import android.system.StructStat;
import java.io.File;
import java.util.HashMap;
public class ClearCacheService extends IntentService {
public ClearCacheService() {
super("ClearCacheService");
}
@Override
protected void onHandleIntent(Intent intent) {
ApplicationLoader.postInitApplication();
/*
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
final int keepMedia = preferences.getInt("keep_media", 2);
if (keepMedia == 2) {
return;
}
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
long currentTime = System.currentTimeMillis();
long diff = 60 * 60 * 1000 * 24 * (keepMedia == 0 ? 7 : 30);
final HashMap<Integer, File> paths = ImageLoader.getInstance().createMediaPaths();
for (HashMap.Entry<Integer, File> entry : paths.entrySet()) {
if (entry.getKey() == FileLoader.MEDIA_DIR_CACHE) {
continue;
}
try {
File[] array = entry.getValue().listFiles();
if (array != null) {
for (int b = 0; b < array.length; b++) {
File f = array[b];
if (f.isFile()) {
if (f.getName().equals(".nomedia")) {
continue;
}
if (Build.VERSION.SDK_INT >= 21) {
try {
StructStat stat = Os.stat(f.getPath());
if (stat.st_atime != 0) {
if (stat.st_atime + diff < currentTime) {
f.delete();
}
} else if (stat.st_mtime + diff < currentTime) {
f.delete();
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
} else if (f.lastModified() + diff < currentTime) {
f.delete();
}
}
}
}
} catch (Throwable e) {
FileLog.e("messenger", e);
}
}
}
});
*/
}
}
@@ -1,172 +0,0 @@
package com.b44t.messenger;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.PowerManager;
public class ConnectionsManager {
public final static int RequestFlagFailOnServerErrors = 2;
public final static int ConnectionStateConnecting = 1;
public final static int ConnectionStateWaitingForNetwork = 2;
public final static int ConnectionStateConnected = 3;
public final static int ConnectionStateUpdating = 4;
private long lastPauseTime = System.currentTimeMillis();
private boolean appPaused = true;
private int lastClassGuid = 1;
private PowerManager.WakeLock wakeLock = null;
private static volatile ConnectionsManager Instance = null;
public static ConnectionsManager getInstance() {
ConnectionsManager localInstance = Instance;
if (localInstance == null) {
synchronized (ConnectionsManager.class) {
localInstance = Instance;
if (localInstance == null) {
Instance = localInstance = new ConnectionsManager();
}
}
}
return localInstance;
}
public ConnectionsManager() {
try {
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
wakeLock.setReferenceCounted(false);
} catch (Exception e) {
FileLog.e("messenger", e);
}
}
public int getCurrentTime() {
return MrMailbox.getCurrentTime();
}
public void cancelRequest(int token, boolean notifyServer) {
//native_cancelRequest(token, notifyServer);
}
public void cleanup() {
//native_cleanUp();
}
public int getConnectionState() {
return ConnectionStateWaitingForNetwork; // EDIT BY MR - we're always disconnected from the view of the caller
/* EDIT BY MR
if (connectionState == ConnectionStateConnected && isUpdating) {
return ConnectionStateUpdating;
}
return connectionState;
*/
}
public void setPushConnectionEnabled(boolean value) {
//native_setPushConnectionEnabled(value);
}
public void init(String deviceModel, String systemVersion, String appVersion, String langCode, String configPath, String logPath, int userId, boolean enablePushConnection) {
//native_init(version, layer, apiId, deviceModel, systemVersion, appVersion, langCode, configPath, logPath, userId, enablePushConnection);
//checkConnection();
BroadcastReceiver networkStateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//checkConnection();
}
};
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
}
public void resumeNetworkMaybe() {
//native_resumeNetwork(true);
}
public void setAppPaused(final boolean value, final boolean byScreenState) {
if (!byScreenState) {
appPaused = value;
FileLog.d("messenger", "app paused = " + value);
}
if (value) {
if (lastPauseTime == 0) {
lastPauseTime = System.currentTimeMillis();
}
//native_pauseNetwork();
} else {
if (appPaused) {
return;
}
FileLog.e("messenger", "reset app pause time");
/*if (lastPauseTime != 0 && System.currentTimeMillis() - lastPauseTime > 5000) {
ContactsController.getInstance().checkContacts();
}*/
lastPauseTime = 0;
//native_resumeNetwork(false);
}
}
public int generateClassGuid() {
return lastClassGuid++;
}
/* -- leave this for future use
public static boolean isRoaming() {
try {
ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null) {
return netInfo.isRoaming();
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
return false;
} */
/* -- leave this for future use
public static boolean isConnectedToWiFi() {
try {
ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
return false;
} */
public static boolean isNetworkOnline() {
try {
ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && (netInfo.isConnectedOrConnecting() || netInfo.isAvailable())) {
return true;
}
netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
return true;
} else {
netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
return true;
}
}
} catch (Exception e) {
FileLog.e("messenger", e);
return true;
}
return false;
}
}
@@ -30,8 +30,7 @@ import java.util.ArrayList;
public class FileLoadOperation {
private static class RequestInfo {
private int requestToken;
private int offset;
private int dummy;
}
private final static int stateIdle = 0;
@@ -52,11 +51,8 @@ public class FileLoadOperation {
private int totalBytesCount;
private int bytesCountPadding;
private FileLoadOperationDelegate delegate;
private byte[] key;
private byte[] iv;
private int currentDownloadChunkSize;
private int currentMaxDownloadRequests;
private int requestsCount;
private int renameRetryCount;
private int nextDownloadOffset;
@@ -65,7 +61,6 @@ public class FileLoadOperation {
private File cacheFileTemp;
private File cacheFileFinal;
private File cacheIvTemp;
private String ext;
private RandomAccessFile fileOutputStream;
@@ -81,17 +76,7 @@ public class FileLoadOperation {
}
public FileLoadOperation(TLRPC.FileLocation photoLocation, String extension, int size) {
/*if (photoLocation instanceof TLRPC.TL_fileEncryptedLocation) {
location = new TLRPC.TL_inputEncryptedFileLocation();
location.id = photoLocation.volume_id;
location.volume_id = photoLocation.volume_id;
location.access_hash = photoLocation.secret;
location.local_id = photoLocation.local_id;
iv = new byte[32];
System.arraycopy(photoLocation.iv, 0, iv, 0, iv.length);
key = photoLocation.key;
datacenter_id = photoLocation.dc_id;
} else*/ if (photoLocation instanceof TLRPC.TL_fileLocation) {
if (photoLocation instanceof TLRPC.TL_fileLocation) {
location = new TLRPC.TL_inputFileLocation();
location.volume_id = photoLocation.volume_id;
location.local_id = photoLocation.local_id;
@@ -103,28 +88,13 @@ public class FileLoadOperation {
public FileLoadOperation(TLRPC.Document documentLocation) {
try {
/*if (documentLocation instanceof TLRPC.TL_documentEncrypted) {
location = new TLRPC.TL_inputEncryptedFileLocation();
location.id = documentLocation.id;
location.access_hash = documentLocation.access_hash;
datacenter_id = documentLocation.dc_id;
iv = new byte[32];
System.arraycopy(documentLocation.iv, 0, iv, 0, iv.length);
key = documentLocation.key;
} else*/ if (documentLocation instanceof TLRPC.TL_document) {
if (documentLocation instanceof TLRPC.TL_document) {
location = new TLRPC.TL_inputDocumentFileLocation();
location.id = documentLocation.id;
location.access_hash = documentLocation.access_hash;
datacenter_id = documentLocation.dc_id;
}
totalBytesCount = documentLocation.size;
if (key != null) {
int toAdd = 0;
if (totalBytesCount % 16 != 0) {
bytesCountPadding = 16 - totalBytesCount % 16;
totalBytesCount += bytesCountPadding;
}
}
ext = FileLoader.getDocumentFileName(documentLocation);
int idx;
if (ext == null || (idx = ext.lastIndexOf('.')) == -1) {
@@ -196,13 +166,9 @@ public class FileLoadOperation {
}
String fileNameFinal;
String fileNameTemp;
String fileNameIv = null;
if (location.volume_id != 0 && location.local_id != 0) {
fileNameTemp = location.volume_id + "_" + location.local_id + ".temp";
fileNameFinal = location.volume_id + "_" + location.local_id + "." + ext;
if (key != null) {
fileNameIv = location.volume_id + "_" + location.local_id + ".iv";
}
if (datacenter_id == Integer.MIN_VALUE || location.volume_id == Integer.MIN_VALUE || datacenter_id == 0) {
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@@ -216,9 +182,6 @@ public class FileLoadOperation {
} else {
fileNameTemp = datacenter_id + "_" + location.id + ".temp";
fileNameFinal = datacenter_id + "_" + location.id + ext;
if (key != null) {
fileNameIv = datacenter_id + "_" + location.id + ".iv";
}
if (datacenter_id == 0 || location.id == 0) {
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@@ -248,21 +211,6 @@ public class FileLoadOperation {
FileLog.d("messenger", "start loading file to temp = " + cacheFileTemp + " final = " + cacheFileFinal);
}
if (fileNameIv != null) {
cacheIvTemp = new File(tempPath, fileNameIv);
try {
fiv = new RandomAccessFile(cacheIvTemp, "rws");
long len = cacheIvTemp.length();
if (len > 0 && len % 32 == 0) {
fiv.read(iv, 0, 32);
} else {
downloadedBytes = 0;
}
} catch (Exception e) {
FileLog.e("messenger", e);
downloadedBytes = 0;
}
}
try {
fileOutputStream = new RandomAccessFile(cacheFileTemp, "rws");
if (downloadedBytes != 0) {
@@ -313,14 +261,6 @@ public class FileLoadOperation {
}
state = stateFailed;
cleanup();
if (requestInfos != null) {
for (int a = 0; a < requestInfos.size(); a++) {
RequestInfo requestInfo = requestInfos.get(a);
if (requestInfo.requestToken != 0) {
ConnectionsManager.getInstance().cancelRequest(requestInfo.requestToken, true);
}
}
}
delegate.didFailedLoadingFile(FileLoadOperation.this, 1);
}
});
@@ -350,13 +290,6 @@ public class FileLoadOperation {
FileLog.e("messenger", e);
}
if (delayedRequestInfos != null) {
for (int a = 0; a < delayedRequestInfos.size(); a++) {
RequestInfo requestInfo = delayedRequestInfos.get(a);
/*if (requestInfo.response != null) {
requestInfo.response.disableFree = false;
requestInfo.response.freeResources();
}*/
}
delayedRequestInfos.clear();
}
}
@@ -367,10 +300,6 @@ public class FileLoadOperation {
}
state = stateFinished;
cleanup();
if (cacheIvTemp != null) {
cacheIvTemp.delete();
cacheIvTemp = null;
}
if (cacheFileTemp != null) {
boolean renameResult = cacheFileTemp.renameTo(cacheFileFinal);
if (!renameResult) {
@@ -416,24 +345,10 @@ public class FileLoadOperation {
if (totalBytesCount > 0 && nextDownloadOffset >= totalBytesCount) {
break;
}
boolean isLast = totalBytesCount <= 0 || a == count - 1 || totalBytesCount > 0 && nextDownloadOffset + currentDownloadChunkSize >= totalBytesCount;
//TLRPC.TL_upload_getFile req = new TLRPC.TL_upload_getFile();
//req.location = location;
//req.offset = nextDownloadOffset;
//req.limit = currentDownloadChunkSize;
nextDownloadOffset += currentDownloadChunkSize;
final RequestInfo requestInfo = new RequestInfo();
requestInfos.add(requestInfo);
requestInfo.offset = nextDownloadOffset;
requestInfo.requestToken = 0;/*ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
requestInfo.response = (TLRPC.TL_upload_file) response;
processRequestResult(requestInfo, error);
}
}, null, (isForceRequest ? ConnectionsManager.RequestFlagForceDownload : 0) | ConnectionsManager.RequestFlagFailOnServerErrors, datacenter_id, requestsCount % 2 == 0 ? ConnectionsManager.ConnectionTypeDownload : ConnectionsManager.ConnectionTypeDownload2, isLast);*/
requestsCount++;
}
}
@@ -84,11 +84,6 @@ public class ImageLoader {
private static byte[] headerThumb = new byte[12];
private int currentHttpTasksCount = 0;
private LinkedList<HttpFileTask> httpFileLoadTasks = new LinkedList<>();
private HashMap<String, HttpFileTask> httpFileLoadTasksByKeys = new HashMap<>();
private HashMap<String, Runnable> retryHttpsTasks = new HashMap<>();
private int currentHttpFileLoadTasksCount = 0;
private String ignoreRemoval = null;
private volatile long lastCacheOutTime = 0;
@@ -101,128 +96,6 @@ public class ImageLoader {
private String filter;
}
private class HttpFileTask extends AsyncTask<Void, Void, Boolean> {
private String url;
private File tempFile;
private String ext;
private RandomAccessFile fileOutputStream = null;
private boolean canRetry = true;
public HttpFileTask(String url, File tempFile, String ext) {
this.url = url;
this.tempFile = tempFile;
this.ext = ext;
}
protected Boolean doInBackground(Void... voids) {
InputStream httpConnectionStream = null;
boolean done = false;
URLConnection httpConnection = null;
try {
URL downloadUrl = new URL(url);
httpConnection = downloadUrl.openConnection();
httpConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
httpConnection.addRequestProperty("Referer", "google.com");
httpConnection.setConnectTimeout(5000);
httpConnection.setReadTimeout(5000);
if (httpConnection instanceof HttpURLConnection) {
HttpURLConnection httpURLConnection = (HttpURLConnection) httpConnection;
httpURLConnection.setInstanceFollowRedirects(true);
int status = httpURLConnection.getResponseCode();
if (status == HttpURLConnection.HTTP_MOVED_TEMP || status == HttpURLConnection.HTTP_MOVED_PERM || status == HttpURLConnection.HTTP_SEE_OTHER) {
String newUrl = httpURLConnection.getHeaderField("Location");
String cookies = httpURLConnection.getHeaderField("Set-Cookie");
downloadUrl = new URL(newUrl);
httpConnection = downloadUrl.openConnection();
httpConnection.setRequestProperty("Cookie", cookies);
httpConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
httpConnection.addRequestProperty("Referer", "google.com");
}
}
httpConnection.connect();
httpConnectionStream = httpConnection.getInputStream();
fileOutputStream = new RandomAccessFile(tempFile, "rws");
} catch (Throwable e) {
if (e instanceof UnknownHostException) {
canRetry = false;
}
FileLog.e("messenger", e);
}
if (canRetry) {
try {
if (httpConnection != null && httpConnection instanceof HttpURLConnection) {
int code = ((HttpURLConnection) httpConnection).getResponseCode();
if (code != HttpURLConnection.HTTP_OK && code != HttpURLConnection.HTTP_ACCEPTED && code != HttpURLConnection.HTTP_NOT_MODIFIED) {
canRetry = false;
}
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
if (httpConnectionStream != null) {
try {
byte[] data = new byte[1024 * 4];
while (true) {
if (isCancelled()) {
break;
}
try {
int read = httpConnectionStream.read(data);
if (read > 0) {
fileOutputStream.write(data, 0, read);
} else if (read == -1) {
done = true;
break;
} else {
break;
}
} catch (Exception e) {
FileLog.e("messenger", e);
break;
}
}
} catch (Throwable e) {
FileLog.e("messenger", e);
}
}
try {
if (fileOutputStream != null) {
fileOutputStream.close();
fileOutputStream = null;
}
} catch (Throwable e) {
FileLog.e("messenger", e);
}
try {
if (httpConnectionStream != null) {
httpConnectionStream.close();
}
} catch (Throwable e) {
FileLog.e("messenger", e);
}
}
return done;
}
@Override
protected void onPostExecute(Boolean result) {
runHttpFileLoadTasks(this, result ? 2 : 1);
}
@Override
protected void onCancelled() {
runHttpFileLoadTasks(this, 2);
}
}
private class HttpImageTask extends AsyncTask<Void, Void, Boolean> {
private CacheImage cacheImage = null;
@@ -278,7 +151,7 @@ public class ImageLoader {
}
} catch (Throwable e) {
if (e instanceof SocketTimeoutException) {
if (ConnectionsManager.isNetworkOnline()) {
if (ApplicationLoader.isNetworkOnline()) {
canRetry = false;
}
} else if (e instanceof UnknownHostException) {
@@ -1703,45 +1576,6 @@ public class ImageLoader {
}
}
private void runHttpFileLoadTasks(final HttpFileTask oldTask, final int reason) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (oldTask != null) {
currentHttpFileLoadTasksCount--;
}
if (oldTask != null) {
if (reason == 1) {
if (oldTask.canRetry) {
final HttpFileTask newTask = new HttpFileTask(oldTask.url, oldTask.tempFile, oldTask.ext);
Runnable runnable = new Runnable() {
@Override
public void run() {
httpFileLoadTasks.add(newTask);
runHttpFileLoadTasks(null, 0);
}
};
retryHttpsTasks.put(oldTask.url, runnable);
AndroidUtilities.runOnUIThread(runnable, 1000);
} else {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.httpFileDidFailedLoad, oldTask.url);
}
} else if (reason == 2) {
httpFileLoadTasksByKeys.remove(oldTask.url);
File file = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(oldTask.url) + "." + oldTask.ext);
String result = oldTask.tempFile.renameTo(file) ? file.toString() : oldTask.tempFile.toString();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.httpFileDidLoaded, oldTask.url, result);
}
}
while (currentHttpFileLoadTasksCount < 2 && !httpFileLoadTasks.isEmpty()) {
HttpFileTask task = httpFileLoadTasks.poll();
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
currentHttpFileLoadTasksCount++;
}
}
});
}
public static Bitmap loadBitmap(String path, Uri uri, float maxWidth, float maxHeight, boolean useMaxScale) {
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
@@ -371,12 +371,10 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
setImageBackup.ext = currentExt;
setImageBackup.cacheOnly = currentCacheOnly;
}
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReplacedPhotoInMemCache);
clearImage();
}
public boolean onAttachedToWindow() {
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReplacedPhotoInMemCache);
if (setImageBackup != null && (setImageBackup.fileLocation != null || setImageBackup.httpUrl != null || setImageBackup.thumbLocation != null || setImageBackup.thumb != null)) {
setImage(setImageBackup.fileLocation, setImageBackup.httpUrl, setImageBackup.filter, setImageBackup.thumb, setImageBackup.thumbLocation, setImageBackup.thumbFilter, setImageBackup.size, setImageBackup.ext, setImageBackup.cacheOnly);
return true;
@@ -1058,26 +1056,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
}
}
} else if (id == NotificationCenter.didReplacedPhotoInMemCache) {
String oldKey = (String) args[0];
if (currentKey != null && currentKey.equals(oldKey)) {
currentKey = (String) args[1];
currentImageLocation = (TLRPC.FileLocation) args[2];
}
if (currentThumbKey != null && currentThumbKey.equals(oldKey)) {
currentThumbKey = (String) args[1];
currentThumbLocation = (TLRPC.FileLocation) args[2];
}
if (setImageBackup != null) {
if (currentKey != null && currentKey.equals(oldKey)) {
currentKey = (String) args[1];
currentImageLocation = (TLRPC.FileLocation) args[2];
}
if (currentThumbKey != null && currentThumbKey.equals(oldKey)) {
currentThumbKey = (String) args[1];
currentThumbLocation = (TLRPC.FileLocation) args[2];
}
}
}
}
}
@@ -1,7 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -25,19 +24,25 @@ package com.b44t.messenger;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.util.Log;
public class NotificationsService extends Service {
public class KeepAliveService extends Service {
@Override
public void onCreate() {
FileLog.e("messenger", "service started");
ApplicationLoader.postInitApplication();
Log.i("DeltaChat", "*** KeepAliveService.onCreate()");
// there's nothing more to do here as all initialisation stuff is already done in
// ApplicationLoader.onCreate() which is called before this broadcast is sended.
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// START_STICKY ensured, the service is recreated as soon it is terminted for any reasons.
// as ApplicationLoader.onCreate() is called before a service starts, there is no more to do here,
// the app is just running fine.
Log.i("DeltaChat", "*** KeepAliveService.onStartCommand()");
return START_STICKY;
}
@@ -47,12 +52,7 @@ public class NotificationsService extends Service {
}
public void onDestroy() {
FileLog.e("messenger", "service destroyed");
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", MODE_PRIVATE);
if (preferences.getBoolean("pushService", true)) {
Intent intent = new Intent("com.b44t.start");
sendBroadcast(intent);
}
Log.i("DeltaChat", "*** KeepAliveService.onDestroy()");
// the service will be restarted due to START_STICKY automatically, there's nothing more to do.
}
}
@@ -31,18 +31,10 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.text.format.DateFormat;
import android.util.Xml;
import com.b44t.messenger.time.FastDateFormat;
import org.xmlpull.v1.XmlPullParser;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
@@ -62,9 +54,8 @@ public class LocaleController {
public FastDateFormat chatFullDate;
private Locale currentLocale;
private Locale systemDefaultLocale; // this is not Locale.getDefault(); Locale.getDefault() may be changed using Locale.setDefault()
private LocaleInfo currentLocaleInfo;
private LocaleInfo defaultLocalInfo;
private HashMap<String, String> localeValues = new HashMap<>();
private String languageOverride;
private boolean changingConfiguration = false;
@@ -86,34 +77,10 @@ public class LocaleController {
public String name;
public String nameEnglish;
public String shortName;
public String pathToFile;
public String getSaveString() {
return name + "|" + nameEnglish + "|" + shortName + "|" + pathToFile;
}
public static LocaleInfo createWithString(String string) {
if (string == null || string.length() == 0) {
return null;
}
String[] args = string.split("\\|");
if (args.length != 4) {
return null;
}
LocaleInfo localeInfo = new LocaleInfo();
localeInfo.name = args[0];
localeInfo.nameEnglish = args[1];
localeInfo.shortName = args[2];
localeInfo.pathToFile = args[3];
return localeInfo;
}
}
public ArrayList<LocaleInfo> sortedLanguages = new ArrayList<>();
public HashMap<String, LocaleInfo> languagesDict = new HashMap<>();
private ArrayList<LocaleInfo> otherLanguages = new ArrayList<>();
private static volatile LocaleController Instance = null;
public static LocaleController getInstance() {
LocaleController localInstance = Instance;
@@ -133,86 +100,63 @@ public class LocaleController {
localeInfo.name = "English";
localeInfo.nameEnglish = "English";
localeInfo.shortName = "en";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Italiano";
localeInfo.nameEnglish = "Italian";
localeInfo.shortName = "it";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Español";
localeInfo.nameEnglish = "Spanish";
localeInfo.shortName = "es";
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Deutsch";
localeInfo.nameEnglish = "German";
localeInfo.shortName = "de";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Français";
localeInfo.nameEnglish = "French";
localeInfo.shortName = "fr";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Nederlands";
localeInfo.nameEnglish = "Dutch";
localeInfo.shortName = "nl";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Polski";
localeInfo.nameEnglish = "Polish";
localeInfo.shortName = "pl";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Português";
localeInfo.nameEnglish = "Portuguese";
localeInfo.shortName = "pt";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
loadOtherLanguages();
localeInfo = new LocaleInfo();
localeInfo.name = "한국어";
localeInfo.nameEnglish = "Korean";
localeInfo.shortName = "ko";
languagesDict.put(localeInfo.shortName, localeInfo);
for (LocaleInfo locale : otherLanguages) {
sortedLanguages.add(locale);
languagesDict.put(locale.shortName, locale);
}
Collections.sort(sortedLanguages, new Comparator<LocaleInfo>() {
@Override
public int compare(LocaleController.LocaleInfo o, LocaleController.LocaleInfo o2) {
return o.name.compareTo(o2.name);
}
});
defaultLocalInfo = localeInfo = new LocaleController.LocaleInfo();
localeInfo.name = "System default";
localeInfo.nameEnglish = "System default";
localeInfo.shortName = null;
localeInfo.pathToFile = null;
sortedLanguages.add(0, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Magyar";
localeInfo.nameEnglish = "Hungarian";
localeInfo.shortName = "hu";
languagesDict.put(localeInfo.shortName, localeInfo);
systemDefaultLocale = Locale.getDefault(); // we have to remember this as we may switch back to default later
is24HourFormat = DateFormat.is24HourFormat(ApplicationLoader.applicationContext);
LocaleInfo currentInfo = null;
boolean override = false;
@@ -227,11 +171,11 @@ public class LocaleController {
}
}
if (currentInfo == null && Locale.getDefault().getLanguage() != null) {
currentInfo = languagesDict.get(Locale.getDefault().getLanguage());
if (currentInfo == null && systemDefaultLocale.getLanguage() != null) {
currentInfo = languagesDict.get(systemDefaultLocale.getLanguage());
}
if (currentInfo == null) {
currentInfo = languagesDict.get(getLocaleString(Locale.getDefault()));
currentInfo = languagesDict.get(getLocaleString(systemDefaultLocale));
}
if (currentInfo == null) {
currentInfo = languagesDict.get("en");
@@ -272,139 +216,7 @@ public class LocaleController {
return result.toString();
}
public static String getLocaleStringIso639() {
Locale locale = Locale.getDefault();
if (locale == null) {
return "en";
}
String languageCode = locale.getLanguage();
String countryCode = locale.getCountry();
String variantCode = locale.getVariant();
if (languageCode.length() == 0 && countryCode.length() == 0) {
return "en";
}
StringBuilder result = new StringBuilder(11);
result.append(languageCode);
if (countryCode.length() > 0 || variantCode.length() > 0) {
result.append('-');
}
result.append(countryCode);
if (variantCode.length() > 0) {
result.append('_');
}
result.append(variantCode);
return result.toString();
}
private void saveOtherLanguages() {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("langconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
String locales = "";
for (LocaleInfo localeInfo : otherLanguages) {
String loc = localeInfo.getSaveString();
if (loc != null) {
if (locales.length() != 0) {
locales += "&";
}
locales += loc;
}
}
editor.putString("locales", locales);
editor.apply();
}
public boolean deleteLanguage(LocaleInfo localeInfo) {
if (localeInfo.pathToFile == null) {
return false;
}
if (currentLocaleInfo == localeInfo) {
applyLanguage(defaultLocalInfo, true);
}
otherLanguages.remove(localeInfo);
sortedLanguages.remove(localeInfo);
languagesDict.remove(localeInfo.shortName);
File file = new File(localeInfo.pathToFile);
file.delete();
saveOtherLanguages();
return true;
}
private void loadOtherLanguages() {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("langconfig", Activity.MODE_PRIVATE);
String locales = preferences.getString("locales", null);
if (locales == null || locales.length() == 0) {
return;
}
String[] localesArr = locales.split("&");
for (String locale : localesArr) {
LocaleInfo localeInfo = LocaleInfo.createWithString(locale);
if (localeInfo != null) {
otherLanguages.add(localeInfo);
}
}
}
private HashMap<String, String> getLocaleFileStrings(File file) {
FileInputStream stream = null;
try {
HashMap<String, String> stringMap = new HashMap<>();
XmlPullParser parser = Xml.newPullParser();
stream = new FileInputStream(file);
parser.setInput(stream, "UTF-8");
int eventType = parser.getEventType();
String name = null;
String value = null;
String attrName = null;
while (eventType != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_TAG) {
name = parser.getName();
int c = parser.getAttributeCount();
if (c > 0) {
attrName = parser.getAttributeValue(0);
}
} else if(eventType == XmlPullParser.TEXT) {
if (attrName != null) {
value = parser.getText();
if (value != null) {
value = value.trim();
value = value.replace("\\n", "\n");
value = value.replace("\\", "");
}
}
} else if (eventType == XmlPullParser.END_TAG) {
value = null;
attrName = null;
name = null;
}
if (name != null && name.equals("string") && value != null && attrName != null && value.length() != 0 && attrName.length() != 0) {
stringMap.put(attrName, value);
name = null;
value = null;
attrName = null;
}
eventType = parser.next();
}
return stringMap;
} catch (Exception e) {
FileLog.e("messenger", e);
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
}
return new HashMap<>();
}
public void applyLanguage(LocaleInfo localeInfo, boolean override) {
applyLanguage(localeInfo, override, false);
}
public void applyLanguage(LocaleInfo localeInfo, boolean override, boolean fromFile) {
if (localeInfo == null) {
return;
}
@@ -428,7 +240,7 @@ public class LocaleController {
}
}
} else {
newLocale = Locale.getDefault();
newLocale = systemDefaultLocale; // this is not Locale.getDefault(); Locale.getDefault() may be changed using Locale.setDefault()
languageOverride = null;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
@@ -449,11 +261,6 @@ public class LocaleController {
}
}
if (newLocale != null) {
if (localeInfo.pathToFile == null) {
localeValues.clear();
} else if (!fromFile) {
localeValues = getLocaleFileStrings(new File(localeInfo.pathToFile));
}
currentLocale = newLocale;
currentLocaleInfo = localeInfo;
changingConfiguration = true;
@@ -475,14 +282,10 @@ public class LocaleController {
}
private String getStringInternal(String key, int res) {
String value = localeValues.get(key);
if (value == null) {
try {
value = ApplicationLoader.applicationContext.getString(res);
} catch (Exception e) {
FileLog.e("messenger", e);
}
}
String value = null;
try {
value = ApplicationLoader.applicationContext.getString(res);
} catch (Exception e) { }
if (value == null) {
value = "LOC_ERR:" + key;
}
@@ -495,11 +298,7 @@ public class LocaleController {
public static String formatString(String key, int res, Object... args) {
try {
String value = getInstance().localeValues.get(key);
if (value == null) {
value = ApplicationLoader.applicationContext.getString(res);
}
String value = ApplicationLoader.applicationContext.getString(res);
if (getInstance().currentLocale != null) {
return String.format(getInstance().currentLocale, value, args);
} else {
@@ -529,6 +328,7 @@ public class LocaleController {
return;
}
is24HourFormat = DateFormat.is24HourFormat(ApplicationLoader.applicationContext);
systemDefaultLocale = newConfig.locale;
if (languageOverride != null) {
LocaleInfo toSet = currentLocaleInfo;
currentLocaleInfo = null;
@@ -27,10 +27,8 @@ import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.database.ContentObserver;
@@ -50,7 +48,6 @@ import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
@@ -84,6 +81,7 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Semaphore;
public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.NotificationCenterDelegate, SensorEventListener {
private native int startRecord(String path);
@@ -546,17 +544,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
});
BroadcastReceiver networkStateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
checkAutodownloadSettings();
}
};
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
checkAutodownloadSettings();
if (Build.VERSION.SDK_INT >= 16) {
mediaProjections = new String[]{
MediaStore.Images.ImageColumns.DATA,
@@ -739,31 +726,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
cancelVideoConvert(null);
}
public void checkAutodownloadSettings() {
/* -- leave this for future use
int currentMask = getCurrentDownloadMask();
if (currentMask == lastCheckMask) {
return;
}
lastCheckMask = currentMask;
... maybe tell the backend what can be downloaded ...
*/
}
/* -- leave this for future use
private int getCurrentDownloadMask() {
if (ConnectionsManager.isConnectedToWiFi()) {
return wifiDownloadMask;
} else if (ConnectionsManager.isRoaming()) {
return roamingDownloadMask;
} else {
return mobileDataDownloadMask;
}
} */
public int generateObserverTag() {
return lastTag++;
}
@@ -1552,7 +1514,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
return true;
}
if (!messageObject.isOut() && messageObject.isContentUnread()) {
MessagesController.getInstance().markMessageContentAsRead(messageObject);
MrMailbox.markMessageContentAsRead(messageObject);
}
boolean notify = !playMusicAgain;
if (playingMessageObject != null) {
@@ -1843,12 +1805,12 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
recordingAudio = new TLRPC.TL_document();
recordingAudio.dc_id = Integer.MIN_VALUE;
recordingAudio.id = UserConfig.lastLocalId;
recordingAudio.user_id = UserConfig.getClientUserId();
recordingAudio.user_id = MrContact.MR_CONTACT_ID_SELF;
recordingAudio.mime_type = "audio/ogg";
recordingAudio.thumb = new TLRPC.TL_photoSizeEmpty();
recordingAudio.thumb.type = "s";
UserConfig.lastLocalId--;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
recordingAudioFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), FileLoader.getAttachFileName(recordingAudio));
@@ -1976,7 +1938,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
audioToSend.date = ConnectionsManager.getInstance().getCurrentTime();
audioToSend.date = MrMailbox.getCurrentTime();
audioToSend.size = (int) recordingAudioFileToSend.length();
TLRPC.TL_documentAttributeAudio attributeAudio = new TLRPC.TL_documentAttributeAudio();
attributeAudio.voice = true;
@@ -2139,7 +2101,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
if (name == null) {
int id = UserConfig.lastLocalId;
UserConfig.lastLocalId--;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
name = String.format(Locale.US, "%d.%s", id, ext);
}
inputStream = ApplicationLoader.applicationContext.getContentResolver().openInputStream(uri);
@@ -2614,7 +2576,8 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
int rotationValue = messageObject.videoEditedInfo.rotationValue;
int originalWidth = messageObject.videoEditedInfo.originalWidth;
int originalHeight = messageObject.videoEditedInfo.originalHeight;
int bitrate = messageObject.videoEditedInfo.bitrate;
int originalBitrate = messageObject.videoEditedInfo.originalBitrate;
int resultBitrate = messageObject.videoEditedInfo.resultBitrate;
int rotateRender = 0;
File cacheFile = new File(messageObject.messageOwner.attachPath);
@@ -2676,7 +2639,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
checkConversionCanceled();
if (resultWidth != originalWidth || resultHeight != originalHeight || rotateRender != 0) {
if (resultBitrate<originalBitrate || resultWidth != originalWidth || resultHeight != originalHeight || rotateRender != 0) {
int videoIndex;
videoIndex = selectTrack(extractor, false);
if (videoIndex >= 0) {
@@ -2765,7 +2728,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
MediaFormat outputFormat = MediaFormat.createVideoFormat(MIME_TYPE, resultWidth, resultHeight);
outputFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, colorFormat);
outputFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate != 0 ? bitrate : 921600);
outputFormat.setInteger(MediaFormat.KEY_BIT_RATE, resultBitrate != 0 ? resultBitrate : 921600);
outputFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 25);
outputFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 10);
if (Build.VERSION.SDK_INT < 18) {
@@ -95,7 +95,7 @@ public class MessageObject {
textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR;
}
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
textPaint.setTextSize(AndroidUtilities.dp(ApplicationLoader.fontSize));
messageOwner = message;
@@ -106,13 +106,6 @@ public class MessageObject {
setType();
if (messageOwner.message != null && messageOwner.id < 0 && messageOwner.message.length() > 6 && isVideo()) {
videoEditedInfo = new VideoEditedInfo();
if (!videoEditedInfo.parseString(messageOwner.message)) {
videoEditedInfo = null;
}
}
generateCaption();
if (generateLayout) {
messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
@@ -127,7 +120,7 @@ public class MessageObject {
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(Theme.MSG_TEXT_COLOR);
textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR;
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
textPaint.setTextSize(AndroidUtilities.dp(ApplicationLoader.fontSize));
}
return textPaint;
}
@@ -1,147 +0,0 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
package com.b44t.messenger;
import android.app.Activity;
import android.content.SharedPreferences;
import com.b44t.ui.SettingsAdvActivity;
import java.util.ArrayList;
public class MessagesController {
public int fontSize;
public static final int UPDATE_MASK_NAME = 1;
public static final int UPDATE_MASK_AVATAR = 2;
public static final int UPDATE_MASK_STATUS = 4;
public static final int UPDATE_MASK_CHAT_AVATAR = 8;
public static final int UPDATE_MASK_CHAT_NAME = 16;
public static final int UPDATE_MASK_CHAT_MEMBERS = 32;
public static final int UPDATE_MASK_SELECT_DIALOG = 512;
public static final int UPDATE_MASK_NEW_MESSAGE = 2048;
public static final int UPDATE_MASK_SEND_STATE = 4096;
private static volatile MessagesController Instance = null;
public static MessagesController getInstance() {
MessagesController localInstance = Instance;
if (localInstance == null) {
synchronized (MessagesController.class) {
localInstance = Instance;
if (localInstance == null) {
Instance = localInstance = new MessagesController();
}
}
}
return localInstance;
}
public MessagesController() {
ImageLoader.getInstance();
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
fontSize = preferences.getInt("msg_font_size", SettingsAdvActivity.defMsgFontSize());
}
public TLRPC.User getUser(Integer id) {
// EDIT BY MR - additional information should be loaded as needed by the caller
TLRPC.User u = new TLRPC.User();
u.id = id;
return u;
}
public MediaController.SearchImage saveGif(TLRPC.Document document) {
MediaController.SearchImage searchImage = new MediaController.SearchImage();
searchImage.type = 2;
searchImage.document = document;
searchImage.date = (int) (System.currentTimeMillis() / 1000);
searchImage.id = "" + searchImage.document.id;
ArrayList<MediaController.SearchImage> arrayList = new ArrayList<>();
arrayList.add(searchImage);
//MessagesStorage.getInstance().putWebRecent(arrayList);
/*TLRPC.TL_messages_saveGif req = new TLRPC.TL_messages_saveGif();
req.id = new TLRPC.TL_inputDocument();
req.id.id = searchImage.document.id;
req.id.access_hash = searchImage.document.access_hash;
req.unsave = false;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
}
});*/
return searchImage;
}
public void cancelTyping(int action, long dialog_id) {
}
public void sendTyping(final long dialog_id, final int action, int classGuid) {
}
public void markMessageContentAsRead(final MessageObject messageObject) {
}
public void changeChatAvatar(int chat_id, TLRPC.InputFile uploadedAvatar) {
/*TLObject request;
{
TLRPC.TL_messages_editChatPhoto req = new TLRPC.TL_messages_editChatPhoto();
req.chat_id = chat_id;
if (uploadedAvatar != null) {
req.photo = new TLRPC.TL_inputChatUploadedPhoto();
req.photo.file = uploadedAvatar;
req.photo.crop = new TLRPC.TL_inputPhotoCropAuto();
} else {
req.photo = new TLRPC.TL_inputChatPhotoEmpty();
}
request = req;
}*/
/*ConnectionsManager.getInstance().sendRequest(request, new RequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error != null) {
return;
}
processUpdates((TLRPC.Updates) response, false);
}
}, ConnectionsManager.RequestFlagInvokeAfter);*/
}
public boolean isDialogMuted(long dialog_id) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
int mute_type = preferences.getInt("notify2_" + dialog_id, 0);
if (mute_type == 2) {
return true;
} else if (mute_type == 3) {
int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0);
if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) {
return true;
}
}
return false;
}
}
@@ -28,6 +28,20 @@
package com.b44t.messenger;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class MrMailbox {
public static void init () {
@@ -38,53 +52,24 @@ public class MrMailbox {
public native static void close();
public native static String getBlobdir();
public static int configure() {
return MrMailboxConfigure(m_hMailbox);
}
public native static void configureAndConnect();
public native static void configureCancel();
public static int isConfigured() {
return MrMailboxIsConfigured(m_hMailbox);
}
public native static int isConfigured();
public static int connect() {
return MrMailboxConnect(m_hMailbox);
}
public native static void connect();
public native static void disconnect();
public static void disconnect() {
MrMailboxDisconnect(m_hMailbox);
}
public static int fetch() {
return MrMailboxFetch(m_hMailbox);
}
public native static String getErrorDescr();
public static int setConfig(String key, String value) {
return MrMailboxSetConfig(m_hMailbox, key, value);
}
public static String getConfig(String key, String def) {
return MrMailboxGetConfig(m_hMailbox, key, def);
}
public static int getConfigInt(String key, int def) {
return MrMailboxGetConfigInt(m_hMailbox, key, def);
}
public native static void setConfig(String key, String value);
public native static void setConfigInt(String key, int value);
public native static String getConfig(String key, String def);
public native static int getConfigInt(String key, int def);
public native static String getInfo();
public native static String cmdline(String cmd);
private static long m_hMailbox = 0; // do not rename this, is used in C-part
private native static long MrMailboxNew (); // returns hMailbox which must be unref'd after usage (Names as mrmailbox_new don't work due to the additional underscore)
private native static int MrMailboxConfigure (long hMailbox);
private native static int MrMailboxIsConfigured (long hMailbox);
private native static int MrMailboxConnect (long hMailbox);
private native static void MrMailboxDisconnect (long hMailbox);
private native static int MrMailboxFetch (long hMailbox);
private native static int MrMailboxSetConfig (long hMailbox, String key, String value); // value may be NULL
private native static String MrMailboxGetConfig (long hMailbox, String key, String def); // def may be NULL, returns empty string as NULL
private native static int MrMailboxGetConfigInt (long hMailbox, String key, int def); // def may be NULL, returns empty string as NULL
private native static long MrMailboxNew(); // returns hMailbox which must be unref'd after usage (Names as mrmailbox_new don't work due to the additional underscore)
// contacts
public native static int[] getKnownContacts(String query);
@@ -185,27 +170,49 @@ public class MrMailbox {
/* receive events
**********************************************************************************************/
public final static int MR_EVENT_ERROR = 400; // INFO and WARNING are blocked in the mrwrapper.c
public final static int MR_EVENT_MSGS_CHANGED = 2000;
public final static int MR_EVENT_INCOMING_MSG = 2005;
public final static int MR_EVENT_MSG_DELIVERED = 2010;
public final static int MR_EVENT_MSG_READ = 2015;
public final static int MR_EVENT_CHAT_MODIFIED = 2020;
public final static int MR_EVENT_CONTACTS_CHANGED = 2030;
public final static int MR_EVENT_CONNECTION_STATE_CHANGED = 2040;
public final static int MR_EVENT_REPORT = 2050;
public final static int MR_EVENT_CONFIGURE_ENDED = 2040;
public final static int MR_EVENT_CONFIGURE_PROGRESS = 2041;
public final static int MR_EVENT_IS_ONLINE = 2080;
public final static int MR_EVENT_GET_STRING = 2091;
public final static int MR_EVENT_GET_QUANTITIY_STRING = 2092;
public final static int MR_EVENT_HTTP_GET = 2100;
public final static int MR_EVENT_WAKE_LOCK = 2110;
public final static int MR_REPORT_ERR_SELF_NOT_IN_GROUP = 1;
public static final Object m_lastErrorLock = new Object();
public static int m_lastErrorCode = 0;
public static String m_lastErrorString = "";
public static boolean m_showNextErrorAsToast = true;
public static long MrCallback(final int event, final long data1, final long data2) // this function is called from within the C-wrapper
{
switch(event) {
case MR_EVENT_CONNECTION_STATE_CHANGED:
case MR_EVENT_CONFIGURE_ENDED:
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.connectionStateChanged, (int)data1);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.configureEnded, (int)data1);
}
});
return 0;
case MR_EVENT_CONFIGURE_PROGRESS:
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.configureProgress, (int)data1);
}
});
return 0;
@@ -254,18 +261,25 @@ public class MrMailbox {
public void run() {
reloadMainChatlist();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces,
MessagesController.UPDATE_MASK_NAME|MessagesController.UPDATE_MASK_CHAT_NAME|
MessagesController.UPDATE_MASK_CHAT_MEMBERS|MessagesController.UPDATE_MASK_AVATAR);
UPDATE_MASK_NAME|UPDATE_MASK_CHAT_NAME|
UPDATE_MASK_CHAT_MEMBERS|UPDATE_MASK_AVATAR);
}
});
return 0;
case MR_EVENT_REPORT:
case MR_EVENT_ERROR:
synchronized (m_lastErrorLock) {
m_lastErrorCode = (int)data1;
m_lastErrorString = CPtr2String(data2);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if(data1==MR_REPORT_ERR_SELF_NOT_IN_GROUP) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.errSelfNotInGroup);
synchronized (m_lastErrorLock) {
if( m_showNextErrorAsToast ) {
AndroidUtilities.showHint(ApplicationLoader.applicationContext, m_lastErrorString);
}
m_showNextErrorAsToast = true;
}
}
});
@@ -274,6 +288,7 @@ public class MrMailbox {
case MR_EVENT_GET_STRING:
String s = "ErrStrBadId";
switch( (int)data1 ) {
// the string-IDs are defined in the backend; as this is the only place where they're used, there is no benefit in creating an enum or sth. like that.
case 1: s = ApplicationLoader.applicationContext.getString(R.string.NoMessages); break;
case 2: s = ApplicationLoader.applicationContext.getString(R.string.FromSelf); break;
case 3: s = ApplicationLoader.applicationContext.getString(R.string.Draft); break;
@@ -281,7 +296,7 @@ public class MrMailbox {
case 8: s = ApplicationLoader.applicationContext.getString(R.string.Deaddrop); break;
case 9: s = ApplicationLoader.applicationContext.getString(R.string.AttachPhoto); break;
case 10: s = ApplicationLoader.applicationContext.getString(R.string.AttachVideo); break;
case 11: s = ApplicationLoader.applicationContext.getString(R.string.AttachMusic); break;
case 11: s = ApplicationLoader.applicationContext.getString(R.string.Audio); break;
case 12: s = ApplicationLoader.applicationContext.getString(R.string.AttachDocument); break;
case 13: s = ApplicationLoader.applicationContext.getString(R.string.DefaultStatusText); break;
case 14: s = ApplicationLoader.applicationContext.getString(R.string.MsgNewGroupDraft); break;
@@ -290,16 +305,57 @@ public class MrMailbox {
case 17: s = ApplicationLoader.applicationContext.getString(R.string.MsgMemberAddedToGroup); break;
case 18: s = ApplicationLoader.applicationContext.getString(R.string.MsgMemberRemovedFromToGroup); break;
case 19: s = ApplicationLoader.applicationContext.getString(R.string.MsgGroupLeft); break;
case 20: s = ApplicationLoader.applicationContext.getString(R.string.Error); break;
case 21: s = ApplicationLoader.applicationContext.getString(R.string.ErrSelfNotInGroup); break;
case 22: s = ApplicationLoader.applicationContext.getString(R.string.NoNetwork); break;
}
return String2CPtr(s);
case MR_EVENT_GET_QUANTITIY_STRING:
String sp = "ErrQtyStrBadId";
switch( (int)data1 ) {
// the string-IDs are defined in the backend; as this is the only place where they're used, there is no benefit in creating an enum or sth. like that.
case 4: sp = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Members, (int)data2, (int)data2); break;
case 6: sp = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Contacts, (int)data2, (int)data2); break;
}
return String2CPtr(sp);
case MR_EVENT_IS_ONLINE:
return ApplicationLoader.isNetworkOnline()? 1 : 0;
case MR_EVENT_HTTP_GET:
String httpContent = null;
try {
URL url = new URL(CPtr2String(data1));
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder total = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
total.append(line).append('\n');
}
httpContent = total.toString();
} finally {
urlConnection.disconnect();
}
}
catch(Exception e) {}
return String2CPtr(httpContent);
case MR_EVENT_WAKE_LOCK:
if( data1 != 0 ) {
ApplicationLoader.backendWakeLock.acquire();
}
else {
if( !ApplicationLoader.wakeupWakeLock.isHeld()) {
ApplicationLoader.wakeupWakeLock.acquire(1 * 1000); /* make sure, subsequent release/acquires do not make the CPU sleep */
}
ApplicationLoader.backendWakeLock.release();
}
return 0;
}
return 0;
}
@@ -339,4 +395,44 @@ public class MrMailbox {
String text = LocaleController.formatString("InviteText", R.string.InviteText, url, email);
return text;
}
public static TLRPC.User getUser(Integer id) {
TLRPC.User u = new TLRPC.User(); // legacy function, information should be loaded as needed by the caller
u.id = id;
return u;
}
public static void cancelTyping(int action, long dialog_id) {
}
public static void sendTyping(final long dialog_id, final int action, int classGuid) {
}
public static void markMessageContentAsRead(final MessageObject messageObject) {
}
public static boolean isDialogMuted(long dialog_id) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
int mute_type = preferences.getInt("notify2_" + dialog_id, 0);
if (mute_type == 2) {
return true;
} else if (mute_type == 3) {
int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0);
if (mute_until >= MrMailbox.getCurrentTime()) {
return true;
}
}
return false;
}
// legacy update masks
public static final int UPDATE_MASK_NAME = 1;
public static final int UPDATE_MASK_AVATAR = 2;
public static final int UPDATE_MASK_STATUS = 4;
public static final int UPDATE_MASK_CHAT_AVATAR = 8;
public static final int UPDATE_MASK_CHAT_NAME = 16;
public static final int UPDATE_MASK_CHAT_MEMBERS = 32;
public static final int UPDATE_MASK_SELECT_DIALOG = 512;
public static final int UPDATE_MASK_NEW_MESSAGE = 2048;
public static final int UPDATE_MASK_SEND_STATE = 4096;
}
@@ -215,15 +215,18 @@ public class MrMsg {
File vfile = new File(path);
File tfile = new File(MrMailbox.getBlobdir(), vfile.getName()+"-preview.jpg");
if( !tfile.exists() ) {
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Video.Thumbnails.MINI_KIND);
TLRPC.PhotoSize size = ImageLoader.scaleAndSaveImage(tfile, thumb, 90, 90, 55, false);
size.location.mr_path = tfile.getAbsolutePath();
size.type = "s";
ret.media.document.thumb = size;
try {
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Video.Thumbnails.MINI_KIND);
TLRPC.PhotoSize size = ImageLoader.scaleAndSaveImage(tfile, thumb, 90, 90, 55, false);
size.location.mr_path = tfile.getAbsolutePath();
size.type = "s";
ret.media.document.thumb = size;
setParamInt('w', size.w);
setParamInt('h', size.h);
saveParamToDisk();
setParamInt('w', size.w);
setParamInt('h', size.h);
saveParamToDisk();
}
catch (Exception e) {}
}
else {
TLRPC.PhotoSize size = new TLRPC.PhotoSize();
@@ -238,8 +241,8 @@ public class MrMsg {
TLRPC.TL_documentAttributeVideo attr = new TLRPC.TL_documentAttributeVideo();
attr.duration = getParamInt('d', 0) / 1000;
attr.w = ret.media.document.thumb.w;
attr.h = ret.media.document.thumb.h;
attr.w = getParamInt('w', 320);
attr.h = getParamInt('h', 240);
ret.media.document.attributes.add(attr);
}
else {
@@ -1,212 +0,0 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
package com.b44t.messenger;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class NativeLoader {
private final static int LIB_VERSION = 1;
private final static String LIB_NAME = "messenger." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
//private String crashPath = "";
private static volatile boolean nativeLoaded = false;
private static File getNativeLibraryDir(Context context) {
File f = null;
if (context != null) {
try {
f = new File((String)ApplicationInfo.class.getField("nativeLibraryDir").get(context.getApplicationInfo()));
} catch (Throwable th) {
th.printStackTrace();
}
}
if (f == null) {
f = new File(context.getApplicationInfo().dataDir, "lib");
}
if (f.isDirectory()) {
return f;
}
return null;
}
private static boolean loadFromZip(Context context, File destDir, File destLocalFile, String folder) {
try {
for (File file : destDir.listFiles()) {
file.delete();
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
ZipFile zipFile = null;
InputStream stream = null;
try {
zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
ZipEntry entry = zipFile.getEntry("lib/" + folder + "/" + LIB_SO_NAME);
if (entry == null) {
throw new Exception("Unable to find file in apk:" + "lib/" + folder + "/" + LIB_NAME);
}
stream = zipFile.getInputStream(entry);
OutputStream out = new FileOutputStream(destLocalFile);
byte[] buf = new byte[4096];
int len;
while ((len = stream.read(buf)) > 0) {
Thread.yield();
out.write(buf, 0, len);
}
out.close();
destLocalFile.setReadable(true, false);
destLocalFile.setExecutable(true, false);
destLocalFile.setWritable(true);
try {
System.load(destLocalFile.getAbsolutePath());
//init(context.getCacheDir().getAbsolutePath(), BuildVars.DEBUG_VERSION);
nativeLoaded = true;
} catch (Error e) {
FileLog.e("messenger", e);
}
return true;
} catch (Exception e) {
FileLog.e("messenger", e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (Exception e) {
FileLog.e("messenger", e);
}
}
if (zipFile != null) {
try {
zipFile.close();
} catch (Exception e) {
FileLog.e("messenger", e);
}
}
}
return false;
}
public static synchronized void initNativeLibs(Context context) {
if (nativeLoaded) {
return;
}
//String crashDir = context.getCacheDir().getAbsolutePath();
try {
String folder;
try {
if (Build.CPU_ABI.equalsIgnoreCase("armeabi-v7a")) {
folder = "armeabi-v7a";
} else if (Build.CPU_ABI.equalsIgnoreCase("armeabi")) {
folder = "armeabi";
} else if (Build.CPU_ABI.equalsIgnoreCase("x86")) {
folder = "x86";
} else if (Build.CPU_ABI.equalsIgnoreCase("mips")) {
folder = "mips";
} else {
folder = "armeabi";
FileLog.e("messenger", "Unsupported arch: " + Build.CPU_ABI);
}
} catch (Exception e) {
FileLog.e("messenger", e);
folder = "armeabi";
}
String javaArch = System.getProperty("os.arch");
if (javaArch != null && javaArch.contains("686")) {
folder = "x86";
}
File destFile = getNativeLibraryDir(context);
if (destFile != null) {
destFile = new File(destFile, LIB_SO_NAME);
if (destFile.exists()) {
FileLog.d("messenger", "load normal lib");
try {
System.loadLibrary(LIB_NAME);
//init(crashDir, BuildVars.DEBUG_VERSION);
nativeLoaded = true;
return;
} catch (Error e) {
FileLog.e("messenger", e);
}
}
}
File destDir = new File(context.getFilesDir(), "lib");
destDir.mkdirs();
File destLocalFile = new File(destDir, LOCALE_LIB_SO_NAME);
if (destLocalFile.exists()) {
try {
FileLog.d("messenger", "Load local lib");
System.load(destLocalFile.getAbsolutePath());
//init(crashDir, BuildVars.DEBUG_VERSION);
nativeLoaded = true;
return;
} catch (Error e) {
FileLog.e("messenger", e);
}
destLocalFile.delete();
}
FileLog.e("messenger", "Library not found, arch = " + folder);
if (loadFromZip(context, destDir, destLocalFile, folder)) {
return;
}
} catch (Throwable e) {
e.printStackTrace();
}
try {
System.loadLibrary(LIB_NAME);
//init(crashDir, BuildVars.DEBUG_VERSION);
nativeLoaded = true;
} catch (Error e) {
FileLog.e("messenger", e);
}
}
//private static native void init(String path, boolean enableGoglBreakpad); // not needed
//public static native void crash();
}
@@ -31,7 +31,8 @@ public class NotificationCenter {
private static int totalEvents = 1;
public static final int connectionStateChanged = totalEvents++;
public static final int configureEnded = totalEvents++;
public static final int configureProgress = totalEvents++;
public static final int didReceivedNewMessages = totalEvents++;
public static final int updateInterfaces = totalEvents++;
public static final int dialogsNeedReload = totalEvents++;
@@ -43,9 +44,7 @@ public class NotificationCenter {
public static final int chatDidCreated = totalEvents++;
public static final int mediaDidLoaded = totalEvents++;
public static final int mediaCountDidLoaded = totalEvents++;
public static final int dialogPhotosLoaded = totalEvents++;
public static final int notificationsSettingsUpdated = totalEvents++;
//public static final int pushMessagesUpdated = totalEvents++;
public static final int blockedUsersDidLoaded = totalEvents++;
public static final int openedChatChanged = totalEvents++;
public static final int mainUserInfoChanged = totalEvents++;
@@ -54,18 +53,11 @@ public class NotificationCenter {
public static final int didSetPasscode = totalEvents++;
//public static final int screenStateChanged = totalEvents++; -- currently not used, but this may get handy
public static final int stickersDidLoaded = totalEvents++;
public static final int didReplacedPhotoInMemCache = totalEvents++;
//public static final int musicDidLoaded = totalEvents++;
public static final int reloadHints = totalEvents++;
public static final int httpFileDidLoaded = totalEvents++;
public static final int httpFileDidFailedLoad = totalEvents++;
public static final int messageThumbGenerated = totalEvents++;
public static final int wallpapersDidLoaded = totalEvents++;
public static final int closeOtherAppActivities = totalEvents++;
public static final int didUpdatedConnectionState = totalEvents++;
public static final int emojiDidLoaded = totalEvents++;
public static final int FileLoadProgressChanged = totalEvents++;
@@ -87,8 +79,6 @@ public class NotificationCenter {
public static final int audioDidStarted = totalEvents++;
public static final int audioRouteChanged = totalEvents++;
public static final int errSelfNotInGroup = totalEvents++;
private SparseArray<ArrayList<Object>> observers = new SparseArray<>();
private SparseArray<ArrayList<Object>> removeAfterBroadcast = new SparseArray<>();
private SparseArray<ArrayList<Object>> addAfterBroadcast = new SparseArray<>();
@@ -94,7 +94,7 @@ public class NotificationsController {
public static NotificationsController getInstance() {
NotificationsController localInstance = Instance;
if (localInstance == null) {
synchronized (MessagesController.class) {
synchronized (NotificationsController.class) {
localInstance = Instance;
if (localInstance == null) {
Instance = localInstance = new NotificationsController();
@@ -123,7 +123,7 @@ public class NotificationsController {
try {
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
notificationDelayWakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
notificationDelayWakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "notificationDelayWakelock" /*any name*/);
notificationDelayWakelock.setReferenceCounted(false);
} catch (Exception e) {
FileLog.e("messenger", e);
@@ -847,7 +847,7 @@ public class NotificationsController {
int notifyOverride = preferences.getInt("notify2_" + dialog_id, 0);
if (notifyOverride == 3) {
int muteUntil = preferences.getInt("notifyuntil_" + dialog_id, 0);
if (muteUntil >= ConnectionsManager.getInstance().getCurrentTime()) {
if (muteUntil >= MrMailbox.getCurrentTime()) {
notifyOverride = 2;
}
}
@@ -968,8 +968,6 @@ public class NotificationsController {
}
try {
ConnectionsManager.getInstance().resumeNetworkMaybe();
MessageObject lastMessageObject = pushMessages.get(0);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
int dismissDate = preferences.getInt("dismissDate", 0);
@@ -1321,7 +1319,7 @@ public class NotificationsController {
TLRPC.User user = null;
String name;
if (dialog_id > 0) {
user = MessagesController.getInstance().getUser((int)dialog_id);
user = MrMailbox.getUser((int)dialog_id);
if (user == null) {
continue;
}
@@ -1507,35 +1505,4 @@ public class NotificationsController {
}
});
}
public static void updateServerNotificationsSettings(long dialog_id) {
// the following command is needed to reflect the changes in the GUI
NotificationCenter.getInstance().postNotificationName(NotificationCenter.notificationsSettingsUpdated);
/*
if ((int) dialog_id == 0) {
return;
}
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
req.settings = new TLRPC.TL_inputPeerNotifySettings();
req.settings.sound = "default";
int mute_type = preferences.getInt("notify2_" + dialog_id, 0);
if (mute_type == 3) {
req.settings.mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0);
} else {
req.settings.mute_until = mute_type != 2 ? 0 : Integer.MAX_VALUE;
}
req.settings.show_previews = preferences.getBoolean("preview_" + dialog_id, true);
req.settings.silent = preferences.getBoolean("silent_" + dialog_id, false);
req.peer = new TLRPC.TL_inputNotifyPeer();
((TLRPC.TL_inputNotifyPeer) req.peer).peer = MessagesController.getInputPeer((int) dialog_id);
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
}
});
*/
}
}
@@ -26,18 +26,17 @@ package com.b44t.messenger;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class ScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
FileLog.e("messenger", "screen off");
ConnectionsManager.getInstance().setAppPaused(true, true);
Log.i("DeltaChat", "*** Screen off");
ApplicationLoader.isScreenOn = false;
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
FileLog.e("messenger", "screen on");
ConnectionsManager.getInstance().setAppPaused(false, true);
Log.i("DeltaChat", "*** Screen on");
ApplicationLoader.isScreenOn = true;
}
//NotificationCenter.getInstance().postNotificationName(NotificationCenter.screenStateChanged);
@@ -31,7 +31,6 @@ import android.media.ThumbnailUtils;
import android.net.Uri;
import android.provider.MediaStore;
import android.webkit.MimeTypeMap;
import android.widget.Toast;
import com.b44t.messenger.audioinfo.AudioInfo;
@@ -63,8 +62,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FilePreparingStarted);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileNewChunkAvailable);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FilePreparingFailed);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.httpFileDidFailedLoad);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.httpFileDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad);
}
@@ -94,112 +91,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
new File(messageObject.messageOwner.attachPath+".increation").delete();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesSentOrRead);
}
else if (id == NotificationCenter.httpFileDidLoaded) {
/*
String path = (String) args[0];
ArrayList<DelayedMessage> arr = delayedMessages.get(path);
if (arr != null) {
for (int a = 0; a < arr.size(); a++) {
final DelayedMessage message = arr.get(a);
if (message.type == 0) {
String md5 = Utilities.MD5(message.httpLocation) + "." + ImageLoader.getHttpUrlExtension(message.httpLocation, "file");
final File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), md5);
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
final TLRPC.TL_photo photo = SendMessagesHelper.getInstance().generatePhotoSizes(cacheFile.toString(), null);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (photo != null) {
message.httpLocation = null;
message.obj.messageOwner.media.photo = photo;
message.obj.messageOwner.attachPath = cacheFile.toString();
message.location = photo.sizes.get(photo.sizes.size() - 1).location;
ArrayList<TLRPC.Message> messages = new ArrayList<>();
messages.add(message.obj.messageOwner);
//MessagesStorage.getInstance().putMessages(messages, false, true, false, 0);
performSendDelayedMessage(message);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateMessageMedia, message.obj);
} else {
FileLog.e("messenger", "can't load image " + message.httpLocation + " to file " + cacheFile.toString());
//MessagesStorage.getInstance().markMessageAsSendError(message.obj.messageOwner);
message.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.getId());
processSentMessage(message.obj.getId());
}
}
});
}
});
} else if (message.type == 2) {
String md5 = Utilities.MD5(message.httpLocation) + ".gif";
final File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), md5);
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
if (message.documentLocation.thumb.location instanceof TLRPC.TL_fileLocationUnavailable) {
try {
Bitmap bitmap = ImageLoader.loadBitmap(cacheFile.getAbsolutePath(), null, 90, 90, true);
if (bitmap != null) {
message.documentLocation.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, message.sendEncryptedRequest != null);
bitmap.recycle();
}
} catch (Exception e) {
message.documentLocation.thumb = null;
FileLog.e("messenger", e);
}
if (message.documentLocation.thumb == null) {
message.documentLocation.thumb = new TLRPC.TL_photoSizeEmpty();
message.documentLocation.thumb.type = "s";
}
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
message.httpLocation = null;
message.obj.messageOwner.attachPath = cacheFile.toString();
message.location = message.documentLocation.thumb.location;
ArrayList<TLRPC.Message> messages = new ArrayList<>();
messages.add(message.obj.messageOwner);
//MessagesStorage.getInstance().putMessages(messages, false, true, false, 0);
performSendDelayedMessage(message);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateMessageMedia, message.obj);
}
});
}
});
}
}
delayedMessages.remove(path);
}
*/
} else if (id == NotificationCenter.FileDidLoaded) {
/*
String path = (String) args[0];
ArrayList<DelayedMessage> arr = delayedMessages.get(path);
if (arr != null) {
for (int a = 0; a < arr.size(); a++) {
performSendDelayedMessage(arr.get(a));
}
delayedMessages.remove(path);
}
*/
} else if (id == NotificationCenter.httpFileDidFailedLoad || id == NotificationCenter.FileDidFailedLoad) {
/*
String path = (String) args[0];
ArrayList<DelayedMessage> arr = delayedMessages.get(path);
if (arr != null) {
for (DelayedMessage message : arr) {
//MessagesStorage.getInstance().markMessageAsSendError(message.obj.messageOwner);
message.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.getId());
processSentMessage(message.obj.getId());
}
delayedMessages.remove(path);
}
*/
}
}
public void sendSticker(TLRPC.Document document, long peer) {
@@ -343,10 +234,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
}
public void checkUnsentMessages() {
//MessagesStorage.getInstance().getUnsentMessages(1000);
}
public TLRPC.TL_photo generatePhotoSizes(String path, Uri imageUri) {
Bitmap bitmap = ImageLoader.loadBitmap(path, imageUri, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), true);
if (bitmap == null && AndroidUtilities.getPhotoSize() != 800) {
@@ -367,9 +254,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (sizes.isEmpty()) {
return null;
} else {
UserConfig.saveConfig(false);
UserConfig.saveConfig();
TLRPC.TL_photo photo = new TLRPC.TL_photo();
photo.date = ConnectionsManager.getInstance().getCurrentTime();
photo.date = MrMailbox.getCurrentTime();
photo.sizes = sizes;
return photo;
}
@@ -438,16 +325,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
TLRPC.TL_document document = null;
/*if (!isEncrypted)*/ {
document = null;//(TLRPC.TL_document) MessagesStorage.getInstance().getSentFile(originalPath, !isEncrypted ? 1 : 4);
if (document == null && !path.equals(originalPath) /*&& !isEncrypted*/) {
document = null;//(TLRPC.TL_document) MessagesStorage.getInstance().getSentFile(path + f.length(), !isEncrypted ? 1 : 4);
}
}
if (document == null) {
{
document = new TLRPC.TL_document();
document.id = 0;
document.date = ConnectionsManager.getInstance().getCurrentTime();
document.date = MrMailbox.getCurrentTime();
TLRPC.TL_documentAttributeFilename fileName = new TLRPC.TL_documentAttributeFilename();
fileName.file_name = name;
document.attributes.add(fileName);
@@ -511,16 +392,16 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
document.caption = caption;
final HashMap<String, String> params = new HashMap<>();
/*final HashMap<String, String> params = new HashMap<>();
if (originalPath != null) {
params.put("originalPath", originalPath);
}
}*/
final TLRPC.TL_document documentFinal = document;
final String pathFinal = path;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessageDocument(documentFinal, null, pathFinal, dialog_id, params);
SendMessagesHelper.getInstance().sendMessageDocument(documentFinal, null, pathFinal, dialog_id, null);
}
});
return true;
@@ -541,44 +422,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
prepareSendingDocuments(paths, originalPaths, uris, mine, dialog_id);
}
/*public static void prepareSendingAudioDocuments(final ArrayList<MessageObject> messageObjects, final long dialog_id) {
new Thread(new Runnable() {
@Override
public void run() {
int size = messageObjects.size();
for (int a = 0; a < size; a++) {
final MessageObject messageObject = messageObjects.get(a);
String originalPath = messageObject.messageOwner.attachPath;
final File f = new File(originalPath);
if (originalPath != null) {
originalPath += "audio" + f.length();
}
TLRPC.TL_document document = null;
if (!isEncrypted) {
document = null;//(TLRPC.TL_document) MessagesStorage.getInstance().getSentFile(originalPath, !isEncrypted ? 1 : 4);
}
if (document == null) {
document = null;//(TLRPC.TL_document) messageObject.messageOwner.media.document;
}
final HashMap<String, String> params = new HashMap<>();
if (originalPath != null) {
params.put("originalPath", originalPath);
}
final TLRPC.TL_document documentFinal = document;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessageDocument(documentFinal, null, messageObject.messageOwner.attachPath, dialog_id, params);
}
});
}
}
}).start();
}*/
public static void prepareSendingDocuments(final ArrayList<String> paths, final ArrayList<String> originalPaths, final ArrayList<Uri> uris, final String mime, final long dialog_id) {
if (paths == null && originalPaths == null && uris == null || paths != null && originalPaths != null && paths.size() != originalPaths.size()) {
return;
@@ -681,7 +524,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
new Thread(new Runnable() {
@Override
public void run() {
final boolean isEncrypted = false;//(int) dialog_id == 0;
ArrayList<String> sendAsDocuments = null;
ArrayList<String> sendAsDocumentsOriginal = null;
@@ -757,14 +599,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
photo.caption = captions.get(a);
}
final TLRPC.TL_photo photoFinal = photo;
final HashMap<String, String> params = new HashMap<>();
/*final HashMap<String, String> params = new HashMap<>();
if (originalPath != null) {
params.put("originalPath", originalPath);
}
}*/
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessagePhoto(photoFinal, null, dialog_id, params);
SendMessagesHelper.getInstance().sendMessagePhoto(photoFinal, null, dialog_id, null);
}
});
}
@@ -789,20 +631,20 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (videoEditedInfo != null || videoPath.endsWith("mp4")) {
String path = videoPath;
String originalPath = videoPath;
File temp = new File(originalPath);
originalPath += temp.length() + "_" + temp.lastModified();
//String originalPath = videoPath;
File temp = new File(videoPath);
/*originalPath += temp.length() + "_" + temp.lastModified();
if (videoEditedInfo != null) {
originalPath += duration + "_" + videoEditedInfo.startTime + "_" + videoEditedInfo.endTime;
if (videoEditedInfo.resultWidth == videoEditedInfo.originalWidth) {
originalPath += "_" + videoEditedInfo.resultWidth;
}
}
}*/
TLRPC.TL_document document = null;
{
document = new TLRPC.TL_document();
document.mime_type = "video/mp4";
UserConfig.saveConfig(false);
UserConfig.saveConfig();
TLRPC.TL_documentAttributeVideo attributeVideo = new TLRPC.TL_documentAttributeVideo();
document.attributes.add(attributeVideo);
if (videoEditedInfo != null) {
@@ -815,10 +657,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
attributeVideo.h = height;
}
document.size = (int) estimatedSize;
String fileName = Integer.MIN_VALUE + "_" + UserConfig.lastLocalId + ".mp4";
UserConfig.lastLocalId--;
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName);
UserConfig.saveConfig(false);
String fileName = temp.getName(); // we could also all videoEditInformation to the filename and re-use already encoded videos this way. however, for the moment, I have no time to check this out (bp)
File cacheFile = AndroidUtilities.getFineFilename(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName);
path = cacheFile.getAbsolutePath();
} else {
if (temp.exists()) {
@@ -878,14 +718,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
File tfile = new File(MrMailbox.getBlobdir(), vfile.getName()+"-preview.jpg");
ImageLoader.scaleAndSaveImage(tfile, thumb, 90, 90, 55, false);
final HashMap<String, String> params = new HashMap<>();
/*final HashMap<String, String> params = new HashMap<>();
if (originalPath != null) {
params.put("originalPath", originalPath);
}
}*/
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessageDocument(videoFinal, videoEditedInfo, finalPath, dialog_id, params);
SendMessagesHelper.getInstance().sendMessageDocument(videoFinal, videoEditedInfo, finalPath, dialog_id, null);
}
});
} else {
@@ -0,0 +1,39 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
package com.b44t.messenger;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class TimerReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Log.i("DeltaChat", "*** TimerReceiver.onReceive()");
// acquire for 5 seconds, this should wake un the threads,
// _if_ there is more to do, the backend acquires an additional wakelock using MR_EVENT_WAKE_LOCK
ApplicationLoader.wakeupWakeLock.acquire(5*1000);
}
}
@@ -31,7 +31,6 @@ import java.io.File;
public class UserConfig {
private static TLRPC.User currentUser;
public static int lastLocalId = -210000;
private final static Object sync = new Object();
public static String passcodeHash = "";
@@ -43,11 +42,7 @@ public class UserConfig {
public static boolean isWaitingForPasscodeEnter;
public static boolean useFingerprint = true;
public static void saveConfig(boolean withFile) {
saveConfig(withFile, null);
}
public static void saveConfig(boolean withFile, File oldFile) {
public static void saveConfig() {
synchronized (sync) {
try {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
@@ -61,128 +56,15 @@ public class UserConfig {
editor.putInt("lastPauseTime", lastPauseTime);
editor.putBoolean("useFingerprint", useFingerprint);
/*
if (currentUser != null) {
if (withFile) {
SerializedData data = new SerializedData();
currentUser.serializeToStream(data);
String userString = Base64.encodeToString(data.toByteArray(), Base64.DEFAULT);
editor.putString("user", userString);
data.cleanup();
}
} else {
editor.remove("user");
}
*/
editor.apply();
if (oldFile != null) {
oldFile.delete();
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
}
}
public static boolean isClientActivated() {
return true; // EDIT BY MR -- for "real" checking, call MrMailbox.MrMailboxIsConfigured()
/* EDIT BY MR
synchronized (sync) {
return currentUser != null;
}
*/
}
public static int getClientUserId() {
return 1; // we are user #1 by definition
/* EDIT BY MR
synchronized (sync) {
return currentUser != null ? currentUser.id : 0;
}
*/
}
public static TLRPC.User getCurrentUser() {
synchronized (sync) {
if( currentUser==null ) {
currentUser = MrContact.contactId2user(1);
}
return currentUser;
}
}
public static void setCurrentUser(TLRPC.User user) {
synchronized (sync) {
currentUser = MrContact.contactId2user(1); // EDIT BY MR - force the current user to be user #1, normally this function should not be called at all
}
}
public static void loadConfig() {
synchronized (sync) {
/*
final File configFile = new File(ApplicationLoader.getFilesDirFixed(), "user.dat");
if (configFile.exists()) {
try {
SerializedData data = new SerializedData(configFile);
int ver = data.readInt32(false);
if (ver == 1) {
int constructor = data.readInt32(false);
currentUser = TLRPC.User.TLdeserialize(data, constructor, false);
MessagesStorage.lastDateValue = data.readInt32(false);
MessagesStorage.lastPtsValue = data.readInt32(false);
MessagesStorage.lastSeqValue = data.readInt32(false);
registeredForPush = data.readBool(false);
pushString = data.readString(false);
lastSendMessageId = data.readInt32(false);
lastLocalId = data.readInt32(false);
contactsHash = data.readString(false);
data.readString(false);
saveIncomingPhotos = data.readBool(false);
//MessagesStorage.lastQtsValue = data.readInt32(false);
//MessagesStorage.lastSecretVersion = data.readInt32(false);
int val = data.readInt32(false);
//if (val == 1) {
// MessagesStorage.secretPBytes = data.readByteArray(false);
//}
//MessagesStorage.secretG = data.readInt32(false);
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
saveConfig(true, configFile);
}
});
} else if (ver == 2) {
int constructor = data.readInt32(false);
currentUser = TLRPC.User.TLdeserialize(data, constructor, false);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
registeredForPush = preferences.getBoolean("registeredForPush", false);
pushString = preferences.getString("pushString2", "");
lastSendMessageId = preferences.getInt("lastSendMessageId", -210000);
lastLocalId = preferences.getInt("lastLocalId", -210000);
contactsHash = preferences.getString("contactsHash", "");
saveIncomingPhotos = preferences.getBoolean("saveIncomingPhotos", false);
}
if (lastLocalId > -210000) {
lastLocalId = -210000;
}
if (lastSendMessageId > -210000) {
lastSendMessageId = -210000;
}
data.cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
saveConfig(true, configFile);
}
});
} catch (Exception e) {
FileLog.e("messenger", e);
}
} else
*/
{
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
lastLocalId = preferences.getInt("lastLocalId", -210000);
passcodeHash = preferences.getString("passcodeHash1", "");
@@ -192,26 +74,12 @@ public class UserConfig {
lastPauseTime = preferences.getInt("lastPauseTime", 0);
useFingerprint = preferences.getBoolean("useFingerprint", true);
/*
String user = preferences.getString("user", null);
if (user != null) {
byte[] userBytes = Base64.decode(user, Base64.DEFAULT);
if (userBytes != null) {
SerializedData data = new SerializedData(userBytes);
currentUser = TLRPC.User.TLdeserialize(data, data.readInt32(false), false);
data.cleanup();
}
}
*/
setCurrentUser(null);
String passcodeSaltString = preferences.getString("passcodeSalt", "");
if (passcodeSaltString.length() > 0) {
passcodeSalt = Base64.decode(passcodeSaltString, Base64.DEFAULT);
} else {
passcodeSalt = new byte[0];
}
}
}
}
@@ -228,7 +96,7 @@ public class UserConfig {
System.arraycopy(passcodeBytes, 0, bytes, 16, passcodeBytes.length);
System.arraycopy(passcodeSalt, 0, bytes, passcodeBytes.length + 16, 16);
passcodeHash = Utilities.bytesToHex(Utilities.computeSHA256(bytes, 0, bytes.length));
saveConfig(false);
saveConfig();
} catch (Exception e) {
FileLog.e("messenger", e);
}
@@ -23,50 +23,15 @@
package com.b44t.messenger;
import java.util.Locale;
public class VideoEditedInfo {
public long startTime;
public long endTime;
public int rotationValue;
public int originalWidth;
public int originalHeight;
public int originalBitrate;
public int resultWidth;
public int resultHeight;
public int bitrate;
public int resultBitrate;
public String originalPath;
public String getString() {
return String.format(Locale.US, "-1_%d_%d_%d_%d_%d_%d_%d_%d_%s", startTime, endTime, rotationValue, originalWidth, originalHeight, bitrate, resultWidth, resultHeight, originalPath);
}
public boolean parseString(String string) {
if (string.length() < 6) {
return false;
}
try {
String args[] = string.split("_");
if (args.length >= 10) {
startTime = Long.parseLong(args[1]);
endTime = Long.parseLong(args[2]);
rotationValue = Integer.parseInt(args[3]);
originalWidth = Integer.parseInt(args[4]);
originalHeight = Integer.parseInt(args[5]);
bitrate = Integer.parseInt(args[6]);
resultWidth = Integer.parseInt(args[7]);
resultHeight = Integer.parseInt(args[8]);
for (int a = 9; a < args.length; a++) {
if (originalPath == null) {
originalPath = args[a];
} else {
originalPath += "_" + args[a];
}
}
}
return true;
} catch (Exception e) {
FileLog.e("messenger", e);
}
return false;
}
}
@@ -28,12 +28,13 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.RemoteInput;
import android.util.Log;
public class WearReplyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ApplicationLoader.postInitApplication();
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
if (remoteInput == null) {
return;
@@ -37,14 +37,13 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.Toast;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.Utilities;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.BaseFragment;
@@ -52,54 +51,71 @@ import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.HeaderCell;
import com.b44t.ui.Cells.EditTextCell;
import com.b44t.ui.Cells.ShadowSectionCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Cells.TextSettingsCell;
import com.b44t.ui.Components.LayoutHelper;
import static android.app.ProgressDialog.STYLE_HORIZONTAL;
public class AccountSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
// the list
private ListView listView;
private ListAdapter listAdapter;
private int rowSectionBasic;
private int rowAddrHeadline;
private int rowAddr;
private int rowMailPwHeadline;
private int rowMailPw;
private int rowInfoBelowMailPw2;
private int rowOpenAdvOpions;
private int rowSectionMail;
private int rowMailHeadline;
private int rowMailServer;
private int rowMailPort;
private int rowMailUser;
private int rowBreak2;
private int rowMailSecurity;
private int rowBreak1;
private int rowSectionSend;
private int rowSendHeadline;
private int rowSendServer;
private int rowSendPort;
private int rowSendUser;
private int rowSendPw;
private int rowSendSecurity;
private int rowInfoBelowSendPw;
private int rowCount;
private final int typeInfo = 0; // no gaps here!
private final int typeTextEntry = 1;
private final int typeShadowSection = 2;
private final int typeSection = 3;
private final int ROWTYPE_INFO = 0; // no gaps here!
private final int ROWTYPE_TEXT_ENTRY = 1;
private final int ROWTYPE_SHADOW_BREAK = 2;
private final int ROWTYPE_HEADLINE = 3;
private final int ROWTYPE_TEXT_FLAGS = 4;
EditTextCell addrCell; // warning all these objects may be null!
EditTextCell mailPwCell;
EditTextCell mailServerCell;
EditTextCell mailPortCell;
EditTextCell mailUserCell;
EditTextCell sendPwCell;
EditTextCell sendServerCell;
EditTextCell sendPortCell;
EditTextCell sendUserCell;
private EditTextCell addrCell; // warning all these objects may be null!
private EditTextCell mailPwCell;
private EditTextCell mailServerCell;
private EditTextCell mailPortCell;
private EditTextCell mailUserCell;
private EditTextCell sendPwCell;
private EditTextCell sendServerCell;
private EditTextCell sendPortCell;
private EditTextCell sendUserCell;
private final int MR_IMAP_SOCKET_STARTTLS = 0x100;
private final int MR_IMAP_SOCKET_SSL = 0x200;
private final int MR_IMAP_SOCKET_PLAIN = 0x400;
private final int MR_SMTP_SOCKET_STARTTLS = 0x10000;
private final int MR_SMTP_SOCKET_SSL = 0x20000;
private final int MR_SMTP_SOCKET_PLAIN = 0x40000;
private int m_serverFlags;
// misc.
private View doneButton;
private final static int done_button = 1;
private final int ID_DONE_BUTTON = 1;
private ProgressDialog progressDialog = null;
boolean fromIntro;
private boolean fromIntro;
private boolean m_expanded = false;
public AccountSettingsActivity(Bundle args) {
super();
@@ -112,34 +128,77 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
public boolean onFragmentCreate() {
super.onFragmentCreate();
NotificationCenter.getInstance().addObserver(this, NotificationCenter.connectionStateChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.configureEnded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.configureProgress);
rowCount = 0;
rowSectionBasic = rowCount++;
rowAddr = rowCount++;
rowMailPw = rowCount++;
rowInfoBelowMailPw2 = rowCount++;
m_serverFlags = MrMailbox.getConfigInt("server_flags", 0);
rowSectionMail = rowCount++;
rowMailServer = rowCount++;
rowMailUser = rowCount++;
rowMailPort = rowCount++;
rowBreak2 = rowCount++;
m_expanded = false;
if( !MrMailbox.getConfig("mail_user", "").isEmpty()
|| !MrMailbox.getConfig("mail_server", "").isEmpty()
|| !MrMailbox.getConfig("mail_port", "").isEmpty()
|| !MrMailbox.getConfig("send_user", "").isEmpty()
|| !MrMailbox.getConfig("send_pw", "").isEmpty()
|| !MrMailbox.getConfig("send_server", "").isEmpty()
|| !MrMailbox.getConfig("send_port", "").isEmpty()
|| (m_serverFlags!=0) ) {
m_expanded = true;
}
rowSectionSend = rowCount++;
rowSendServer = rowCount++;
rowSendUser = rowCount++;
rowSendPw = rowCount++;
rowSendPort = rowCount++;
rowInfoBelowSendPw = rowCount++;
calculateRows();
return true;
}
private void calculateRows()
{
rowCount = 0;
rowAddrHeadline = rowCount++;
rowAddr = rowCount++;
rowMailPwHeadline= rowCount++;
rowMailPw = rowCount++;
rowOpenAdvOpions = rowCount++;
if( m_expanded ) {
rowMailHeadline = rowCount++;
rowMailUser = rowCount++; // should be the first additional option, the loginname is the component, that cannot be configured automatically (if not derivable from the address)
rowMailServer = rowCount++;
rowMailPort = rowCount++;
rowMailSecurity = rowCount++;
rowBreak1 = rowCount++;
rowSendHeadline = rowCount++;
rowSendUser = rowCount++;
rowSendPw = rowCount++;
rowSendServer = rowCount++;
rowSendPort = rowCount++;
rowSendSecurity = rowCount++;
}
else {
rowMailHeadline = -1;
rowMailUser = -1;
rowMailServer = -1;
rowMailPort = -1;
rowMailSecurity = -1;
rowBreak1 = -1;
rowSendHeadline = -1;
rowSendUser = -1;
rowSendPw = -1;
rowSendServer = -1;
rowSendPort = -1;
rowSendSecurity = -1;
}
rowInfoBelowSendPw = rowCount++;
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.connectionStateChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.configureEnded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.configureProgress);
}
@Override
@@ -155,30 +214,16 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1 && !fromIntro ) {
if( isModified() ) { // as we use "close/ok" buttons instead of a "back" button it is more clear what happens, however, an additional question does not disturb here
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("DiscardChanges", R.string.DiscardChanges));
builder.setPositiveButton(LocaleController.getString("Yes", R.string.Yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finishFragment();
}
});
builder.setNegativeButton(LocaleController.getString("No", R.string.No), null);
showDialog(builder.create());
}
else {
finishFragment();
}
} else if (id == done_button) {
if (id == -1 && !fromIntro ) { // no "is modified" check: as we use "close/ok" buttons instead of a "back" button it is more clear what happens. moreover, the user may have done a failed "OK" in between, so a question "discard changes?" would be ambiguously
finishFragment();
} else if (id == ID_DONE_BUTTON) {
saveData();
}
}
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
menu.addItemWithWidth(ID_DONE_BUTTON, R.drawable.ic_done, AndroidUtilities.dp(56));
// create object to hold the whole view
fragmentView = new FrameLayout(context);
@@ -188,7 +233,7 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
// create the main layout list
listAdapter = new ListAdapter(context);
ListView listView = new ListView(context);
listView = new ListView(context);
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
@@ -198,6 +243,47 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> adapterView, View view, final int i, long l) {
if( i==rowOpenAdvOpions )
{
m_expanded = !m_expanded;
calculateRows();
listAdapter.notifyDataSetChanged();
}
else if( i==rowMailSecurity || i==rowSendSecurity )
{
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(ApplicationLoader.applicationContext.getString(R.string.SecurityTitle));
builder.setItems(new CharSequence[]{
ApplicationLoader.applicationContext.getString(R.string.Automatic),
"SSL/TLS", /*1*/
"STARTTLS", /*2*/
ApplicationLoader.applicationContext.getString(R.string.Disabled) /*3*/
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if( i==rowMailSecurity ) {
m_serverFlags &= ~(MR_IMAP_SOCKET_SSL | MR_IMAP_SOCKET_STARTTLS | MR_IMAP_SOCKET_PLAIN);
switch( which ) {
case 1: m_serverFlags |= MR_IMAP_SOCKET_SSL; break;
case 2: m_serverFlags |= MR_IMAP_SOCKET_STARTTLS; break;
case 3: m_serverFlags |= MR_IMAP_SOCKET_PLAIN; break;
}
}
else if( i==rowSendSecurity ) {
m_serverFlags &= ~(MR_SMTP_SOCKET_SSL | MR_SMTP_SOCKET_STARTTLS | MR_SMTP_SOCKET_PLAIN);
switch( which ) {
case 1: m_serverFlags |= MR_SMTP_SOCKET_SSL; break;
case 2: m_serverFlags |= MR_SMTP_SOCKET_STARTTLS; break;
case 3: m_serverFlags |= MR_SMTP_SOCKET_PLAIN; break;
}
}
listView.invalidateViews();
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
}
}
});
@@ -208,13 +294,6 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
// Warning: the widgets are created as needed and may not be present!
String v;
/*
if( !isModified() && MrMailbox.MrMailboxIsConfigured(MrMailbox.hMailbox)!=0 ) {
finishFragment();
return; // nothing to do
}
*/
if( addrCell!=null) {
v = addrCell.getValue().trim();
MrMailbox.setConfig("addr", v.isEmpty() ? null : v);
@@ -260,6 +339,8 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
MrMailbox.setConfig("send_pw", v.isEmpty() ? null : v);
}
MrMailbox.setConfigInt("server_flags", m_serverFlags);
// show dialog
if( progressDialog!=null ) {
progressDialog.dismiss();
@@ -267,77 +348,77 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
}
progressDialog = new ProgressDialog(getParentActivity());
progressDialog.setMessage(LocaleController.getString("ConfiguringAccount", R.string.ConfiguringAccount));
progressDialog.setMessage(ApplicationLoader.applicationContext.getString(R.string.OneMoment));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
progressDialog = null;
}
});
@Override
public void onClick(DialogInterface dialog, int which) {
MrMailbox.configureCancel();
}
});
progressDialog.show();
// try to connect
// (for the future, we may put all this togehter in a single command, that is executed
// asynchronously by the backend; then we can skip creating a runnable here)
Utilities.searchQueue.postRunnable(new Runnable() {
@Override
public void run() {
MrMailbox.disconnect();
MrMailbox.configure();
MrMailbox.connect();
}
});
synchronized (MrMailbox.m_lastErrorLock) {
MrMailbox.m_showNextErrorAsToast = false;
MrMailbox.m_lastErrorString = "";
}
// try to connect, this results in an MR_EVENT_CONFIGURE_ENDED resp. NotificationCenter.configureEnded event
MrMailbox.configureAndConnect();
}
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.connectionStateChanged ) {
if( id == NotificationCenter.configureProgress )
{
if( progressDialog!=null ) {
// we want the spinner together with a progress info
int percent = (Integer)args[0];
progressDialog.setMessage(ApplicationLoader.applicationContext.getString(R.string.OneMoment)+String.format(" %d%%", percent));
}
}
else if (id == NotificationCenter.configureEnded )
{
final String errorString;
synchronized (MrMailbox.m_lastErrorLock) {
MrMailbox.m_showNextErrorAsToast = true;
errorString = MrMailbox.m_lastErrorString;
}
if( progressDialog!=null ) {
progressDialog.dismiss();
progressDialog = null;
}
if( (int)args[0]==1 ) {
if( fromIntro ) {
if (fromIntro) {
presentFragment(new DialogsActivity(null), true);
LaunchActivity la = ((LaunchActivity)getParentActivity());
if( la != null ) {
LaunchActivity la = ((LaunchActivity) getParentActivity());
if (la != null) {
la.drawerLayoutContainer.setAllowOpenDrawer(true, false);
}
}
else {
} else {
finishFragment();
}
AndroidUtilities.showDoneHint(ApplicationLoader.applicationContext);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
}
else {
String err = MrMailbox.getErrorDescr();
if( err.isEmpty() ) {
err = LocaleController.getString("CannotConnect", R.string.CannotConnect);
}
Toast.makeText(getParentActivity(), err, Toast.LENGTH_LONG).show();
else if( ! MrMailbox.m_lastErrorString.isEmpty() ){
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(errorString);
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
;
}
});
showDialog(builder.create());
}
}
}
private boolean isModified(){
// Warning: the widgets are created as needed and may not be present!
if( addrCell!=null && addrCell.isModified()) { return true; }
if( mailPwCell!=null && mailPwCell.isModified()) { return true; }
if( mailServerCell!=null && mailServerCell.isModified()) { return true; }
if( mailPortCell!=null && mailPortCell.isModified()) { return true; }
if( mailUserCell!=null && mailUserCell.isModified()) { return true; }
if( sendServerCell!=null && sendServerCell.isModified()) { return true; }
if( sendPortCell!=null && sendPortCell.isModified()) { return true; }
if( sendUserCell!=null && sendUserCell.isModified()) { return true; }
if( sendPwCell!=null && sendPwCell.isModified()) { return true; }
return false;
}
@Override
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
if (isOpen && addrCell!=null) {
@@ -362,8 +443,7 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
@Override
public boolean isEnabled(int i) {
return (i == rowAddr || i==rowMailPw || i==rowMailServer || i==rowMailPort|| i==rowMailUser
|| i==rowSendServer || i==rowSendPort || i==rowSendUser || i== rowSendPw);
return !(i==rowAddrHeadline || i==rowMailPwHeadline || i== rowMailHeadline || i== rowBreak1 || i== rowSendHeadline || i==rowInfoBelowSendPw);
}
@Override
@@ -389,21 +469,21 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType__(i);
if (type == typeTextEntry) {
if (type == ROWTYPE_TEXT_ENTRY) {
if (i == rowAddr) {
if( addrCell==null) {
addrCell = new EditTextCell(mContext);
addrCell = new EditTextCell(mContext, false);
addrCell.setValueHintAndLabel(MrMailbox.getConfig("addr", ""),
"", LocaleController.getString("MyEmailAddress", R.string.MyEmailAddress), false);
"", "", false);
addrCell.getEditTextView().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
}
view = addrCell;
}
else if (i == rowMailPw) {
if( mailPwCell==null) {
mailPwCell = new EditTextCell(mContext);
mailPwCell = new EditTextCell(mContext, false);
mailPwCell.setValueHintAndLabel(MrMailbox.getConfig("mail_pw", ""),
"", LocaleController.getString("Password", R.string.Password), false);
"", "", false);
mailPwCell.getEditTextView().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}
view = mailPwCell;
@@ -412,7 +492,8 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
if( mailServerCell==null) {
mailServerCell = new EditTextCell(mContext);
mailServerCell.setValueHintAndLabel(MrMailbox.getConfig("mail_server", ""),
LocaleController.getString("Automatic", R.string.Automatic), LocaleController.getString("ImapServer", R.string.ImapServer), false);
ApplicationLoader.applicationContext.getString(R.string.Automatic), LocaleController.getString("ImapServer", R.string.ImapServer), false);
mailServerCell.getEditTextView().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
}
view = mailServerCell;
}
@@ -420,7 +501,8 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
if( mailPortCell==null) {
mailPortCell = new EditTextCell(mContext);
mailPortCell.setValueHintAndLabel(MrMailbox.getConfig("mail_port", ""),
LocaleController.getString("Default", R.string.Default), LocaleController.getString("ImapPort", R.string.ImapPort), false);
ApplicationLoader.applicationContext.getString(R.string.Automatic), LocaleController.getString("ImapPort", R.string.ImapPort), false);
mailPortCell.getEditTextView().setInputType(InputType.TYPE_CLASS_NUMBER);
}
view = mailPortCell;
}
@@ -428,7 +510,7 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
if( mailUserCell==null) {
mailUserCell = new EditTextCell(mContext);
mailUserCell.setValueHintAndLabel(MrMailbox.getConfig("mail_user", ""),
LocaleController.getString("FromAbove", R.string.FromAbove), LocaleController.getString("ImapLoginname", R.string.ImapLoginname), false);
ApplicationLoader.applicationContext.getString(R.string.Automatic), LocaleController.getString("ImapLoginname", R.string.ImapLoginname), false);
}
view = mailUserCell;
}
@@ -436,7 +518,8 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
if( sendServerCell==null) {
sendServerCell = new EditTextCell(mContext);
sendServerCell.setValueHintAndLabel(MrMailbox.getConfig("send_server", ""),
LocaleController.getString("Automatic", R.string.Automatic), LocaleController.getString("SmtpServer", R.string.SmtpServer), false);
ApplicationLoader.applicationContext.getString(R.string.Automatic), LocaleController.getString("SmtpServer", R.string.SmtpServer), false);
sendServerCell.getEditTextView().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
}
view = sendServerCell;
}
@@ -444,7 +527,8 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
if( sendPortCell==null) {
sendPortCell = new EditTextCell(mContext);
sendPortCell.setValueHintAndLabel(MrMailbox.getConfig("send_port", ""),
LocaleController.getString("Default", R.string.Default), LocaleController.getString("SmtpPort", R.string.SmtpPort), false);
ApplicationLoader.applicationContext.getString(R.string.Automatic), LocaleController.getString("SmtpPort", R.string.SmtpPort), false);
sendPortCell.getEditTextView().setInputType(InputType.TYPE_CLASS_NUMBER);
}
view = sendPortCell;
}
@@ -452,7 +536,7 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
if( sendUserCell==null) {
sendUserCell = new EditTextCell(mContext);
sendUserCell.setValueHintAndLabel(MrMailbox.getConfig("send_user", ""),
LocaleController.getString("FromAbove", R.string.FromAbove), LocaleController.getString("SmtpLoginname", R.string.SmtpLoginname), false);
ApplicationLoader.applicationContext.getString(R.string.Automatic), LocaleController.getString("SmtpLoginname", R.string.SmtpLoginname), false);
}
view = sendUserCell;
}
@@ -466,35 +550,59 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
view = sendPwCell;
}
}
else if (type == typeSection) {
else if (type ==ROWTYPE_TEXT_FLAGS) {
if (view == null) {
view = new TextSettingsCell(mContext);
view.setBackgroundColor(0xffffffff);
}
TextSettingsCell textCell = (TextSettingsCell) view;
String value = ApplicationLoader.applicationContext.getString(R.string.Automatic);
if( i == rowMailSecurity ) {
if( (m_serverFlags&MR_IMAP_SOCKET_SSL)!=0 ) { value = "SSL/TLS"; }
if( (m_serverFlags&MR_IMAP_SOCKET_STARTTLS)!=0 ) { value = "STARTTLS"; }
if( (m_serverFlags&MR_IMAP_SOCKET_PLAIN)!=0 ) { value = ApplicationLoader.applicationContext.getString(R.string.Disabled); }
}
else if( i == rowSendSecurity ) {
if( (m_serverFlags&MR_SMTP_SOCKET_SSL)!=0 ) { value = "SSL/TLS"; }
if( (m_serverFlags&MR_SMTP_SOCKET_STARTTLS)!=0 ) { value = "STARTTLS"; }
if( (m_serverFlags&MR_SMTP_SOCKET_PLAIN)!=0 ) { value = ApplicationLoader.applicationContext.getString(R.string.Disabled); }
}
textCell.setTextAndValue(ApplicationLoader.applicationContext.getString(R.string.SecurityTitle), value, false);
}
else if (type == ROWTYPE_HEADLINE) {
if (view == null) {
view = new HeaderCell(mContext);
view.setBackgroundColor(0xffffffff);
}
if (i == rowSectionBasic) {
((HeaderCell) view).setText(LocaleController.getString("BasicSettings", R.string.BasicSettings));
} else if (i == rowSectionMail) {
if (i == rowAddrHeadline) {
((HeaderCell) view).setText(ApplicationLoader.applicationContext.getString(R.string.EmailAddress));
} else if (i == rowMailPwHeadline) {
((HeaderCell) view).setText(ApplicationLoader.applicationContext.getString(R.string.Password));
} else if (i == rowMailHeadline) {
((HeaderCell) view).setText(LocaleController.getString("InboxHeadline", R.string.InboxHeadline));
} else if (i == rowSectionSend) {
} else if (i == rowSendHeadline) {
((HeaderCell) view).setText(LocaleController.getString("OutboxHeadline", R.string.OutboxHeadline));
}
}
else if (type == typeShadowSection) {
else if (type == ROWTYPE_SHADOW_BREAK) {
if (view == null) {
view = new ShadowSectionCell(mContext);
}
}
else if (type == typeInfo) {
else if (type == ROWTYPE_INFO) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if( i==rowInfoBelowMailPw2) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("MyAccoutExplain", R.string.MyAccountExplain)+"\n");
view.setBackgroundResource(R.drawable.greydivider); // has shadow top+bottom
if( i== rowOpenAdvOpions) {
((TextInfoCell) view).setText(LocaleController.getString("MyAccoutExplain", R.string.MyAccountExplain),
m_expanded? " \u2212" /*minus-sign*/ : "+", m_expanded /*draw bottom border?*/);
view.setBackgroundResource(m_expanded? R.drawable.greydivider : R.drawable.greydivider_bottom); // has shadow top+bottom
}
else if( i==rowInfoBelowSendPw) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("MyAccountExplain2", R.string.MyAccountExplain2));
view.setBackgroundResource(R.drawable.greydivider_bottom);
((TextInfoCell) view).setText(AndroidUtilities.replaceTags(LocaleController.getString("MyAccountExplain2", R.string.MyAccountExplain2)));
if( m_expanded ) {
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
}
}
return view;
@@ -508,15 +616,18 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
private int getItemViewType__(int i) {
if (i == rowAddr || i==rowMailPw || i==rowMailServer || i==rowMailPort|| i==rowMailUser
|| i==rowSendServer || i==rowSendPort || i==rowSendUser || i== rowSendPw ) {
return typeTextEntry;
return ROWTYPE_TEXT_ENTRY;
}
else if( i==rowSectionBasic || i==rowSectionMail || i==rowSectionSend ) {
return typeSection;
else if( i==rowAddrHeadline || i==rowMailPwHeadline || i== rowMailHeadline || i== rowSendHeadline ) {
return ROWTYPE_HEADLINE;
}
else if( i== rowBreak2) {
return typeShadowSection;
else if( i== rowBreak1 ) {
return ROWTYPE_SHADOW_BREAK;
}
return typeInfo;
else if( i==rowMailSecurity || i==rowSendSecurity) {
return ROWTYPE_TEXT_FLAGS;
}
return ROWTYPE_INFO;
}
@Override
@@ -33,8 +33,8 @@ import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.ConnectionsManager;
public class BaseFragment {
@@ -63,12 +63,12 @@ public class BaseFragment {
RC500_PHOTO_VIEW = 500;
public BaseFragment() {
classGuid = ConnectionsManager.getInstance().generateClassGuid();
classGuid = ApplicationLoader.generateClassGuid();
}
public BaseFragment(Bundle args) {
arguments = args;
classGuid = ConnectionsManager.getInstance().generateClassGuid();
classGuid = ApplicationLoader.generateClassGuid();
}
public ActionBar getActionBar() {
@@ -179,7 +179,6 @@ public class BaseFragment {
}
public void onFragmentDestroy() {
//ConnectionsManager.getInstance().cancelRequestsForGuid(classGuid);
isFinished = true;
if (actionBar != null) {
actionBar.setEnabled(false);
@@ -31,7 +31,6 @@ import android.widget.BaseAdapter;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.R;
import com.b44t.messenger.UserConfig;
import com.b44t.ui.Cells.DrawerActionCell;
import com.b44t.ui.Cells.DividerCell;
import com.b44t.ui.Cells.EmptyCell;
@@ -153,6 +152,6 @@ public class DrawerLayoutAdapter extends BaseAdapter {
@Override
public boolean isEmpty() {
return !UserConfig.isClientActivated();
return false;
}
}
@@ -36,6 +36,7 @@ import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.FileLoader;
@@ -229,7 +230,7 @@ public class AudioSelectActivity extends BaseFragment implements NotificationCen
message.out = true;
message.id = id;
message.to_id = new TLRPC.TL_peerUser();
message.to_id.user_id = message.from_id = UserConfig.getClientUserId();
message.to_id.user_id = message.from_id = MrContact.MR_CONTACT_ID_SELF;
message.date = (int) (System.currentTimeMillis() / 1000);
message.message = "-1";
message.attachPath = audioEntry.path;
@@ -40,8 +40,6 @@ import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
@@ -167,8 +165,8 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
updateVisibleRows(mask);
if ((mask & MrMailbox.UPDATE_MASK_AVATAR) != 0 || (mask & MrMailbox.UPDATE_MASK_NAME) != 0) {
updateVisibleRows();
}
} else if (id == NotificationCenter.blockedUsersDidLoaded) {
blockedUserIds = MrMailbox.getBlockedContacts();
@@ -181,7 +179,7 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
}
}
private void updateVisibleRows(int mask) {
private void updateVisibleRows() {
if (listView == null) {
return;
}
@@ -189,7 +187,7 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
((UserCell) child).update();
}
}
}
@@ -23,13 +23,9 @@
package com.b44t.ui;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.view.ViewGroup;
@@ -40,109 +36,34 @@ import android.widget.Toast;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.ClearCacheService;
import com.b44t.messenger.FileLoader;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.ImageLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.R;
import com.b44t.messenger.Utilities;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.HeaderCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Cells.TextSettingsCell;
import com.b44t.ui.Components.LayoutHelper;
import java.io.File;
public class CacheControlActivity extends BaseFragment {
private ListAdapter listAdapter;
private int headlineRow; // EDIT BY MR -- added
private int databaseRow;
private int databaseInfoRow;
private int keepMediaRow;
private int keepMediaInfoRow;
private int cacheRow;
private int cacheInfoRow;
private int rowKeepMediaSetting;
private int rowKeepMediaInfo;
private int rowCount;
private int typeTextSetting = 0; // EDIT BY MR -- no gaps, please
private int typeTextInfo = 1;
private int typeSectionTitle = 2;
private int typeCount = 3; // /EDIT BY MR -- no gaps, please
//private long databaseSize = -1;
//private long cacheSize = -1;
//private long documentsSize = -1;
//private long audioSize = -1;
//private long musicSize = -1;
//private long photoSize = -1;
//private long videoSize = -1;
//private long totalSize = -1;
//private boolean clear[] = new boolean[6];
//private boolean calculating = true;
private volatile boolean canceled = false;
private final int ROWTYPE_TEXT_SETTING = 0; // no gaps here
private final int ROWTYPE_TEXT_INFO = 1;
private final int ROWTYPE_COUNT = 2;
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
rowCount = 0;
headlineRow = -1;// rowCount++; // EDIT BY MR -- added
keepMediaRow = rowCount++;
keepMediaInfoRow = rowCount++;
cacheRow = -1; // EDIT BY MR -- rowCount++;
cacheInfoRow = -1; // EDIT BY MR -- rowCount++;
databaseRow = -1; // EDIT BY MR -- was: rowCount++;
databaseInfoRow = -1; // EDIT BY MR -- was: rowCount++;
File file = new File(ApplicationLoader.getFilesDirFixed(), "cache4.db");
//databaseSize = file.length();
/*
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
cacheSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_CACHE), 0);
if (canceled) {
return;
}
photoSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_IMAGE), 0);
if (canceled) {
return;
}
videoSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_VIDEO), 0);
if (canceled) {
return;
}
documentsSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), 1);
if (canceled) {
return;
}
musicSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), 2);
if (canceled) {
return;
}
audioSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_AUDIO), 0);
totalSize = cacheSize + videoSize + audioSize + photoSize + documentsSize + musicSize;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
calculating = false;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
});
}
});
*/
rowKeepMediaSetting = rowCount++;
rowKeepMediaInfo = rowCount++;
return true;
}
@@ -150,69 +71,6 @@ public class CacheControlActivity extends BaseFragment {
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
canceled = true;
}
/*private long getDirectorySize2(File dir) {
long size = 0;
if (dir.isDirectory()) {
File[] array = dir.listFiles();
if (array != null) {
for (int a = 0; a < array.length; a++) {
File file = array[a];
if (file.isDirectory()) {
size += getDirectorySize2(file);
} else {
size += file.length();
FileLog.e("messenger", "" + file + " size = " + file.length());
}
}
}
} else if (dir.isFile()) {
FileLog.e("messenger", "" + dir + " size = " + dir.length());
size += dir.length();
}
return size;
}*/
private long getDirectorySize(File dir, int documentsMusicType) {
if (dir == null || canceled) {
return 0;
}
long size = 0;
if (dir.isDirectory()) {
try {
File[] array = dir.listFiles();
if (array != null) {
for (int a = 0; a < array.length; a++) {
if (canceled) {
return 0;
}
File file = array[a];
if (documentsMusicType == 1 || documentsMusicType == 2) {
String name = file.getName().toLowerCase();
if (name.endsWith(".mp3") || name.endsWith(".m4a")) {
if (documentsMusicType == 1) {
continue;
}
} else if (documentsMusicType == 2) {
continue;
}
}
if (file.isDirectory()) {
size += getDirectorySize(file, documentsMusicType);
} else {
size += file.length();
}
}
}
} catch (Throwable e) {
FileLog.e("messenger", e);
}
} else if (dir.isFile()) {
size += dir.length();
}
return size;
}
@Override
@@ -245,7 +103,7 @@ public class CacheControlActivity extends BaseFragment {
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> adapterView, View view, final int i, long l) {
if (i == keepMediaRow) {
if (i == rowKeepMediaSetting) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setItems(new CharSequence[]{context.getResources().getQuantityString(R.plurals.Weeks, 1, 1), context.getResources().getQuantityString(R.plurals.Months, 1, 1), LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever)}, new DialogInterface.OnClickListener() {
@Override
@@ -255,206 +113,15 @@ public class CacheControlActivity extends BaseFragment {
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, ClearCacheService.class), 0);
AlarmManager alarmManager = (AlarmManager) ApplicationLoader.applicationContext.getSystemService(Context.ALARM_SERVICE);
if (which == 2) {
alarmManager.cancel(pintent);
} else {
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, AlarmManager.INTERVAL_DAY, AlarmManager.INTERVAL_DAY, pintent);
}
Toast.makeText(context, LocaleController.getString("NotYetImplemented", R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
}
});
showDialog(builder.create());
} else if (i == databaseRow) {
/* EDIT BY MR
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.setMessage(LocaleController.getString("LocalDatabaseClear", R.string.LocalDatabaseClear));
builder.setPositiveButton(LocaleController.getString("CacheClear", R.string.CacheClear), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
try {
SQLiteDatabase database = MessagesStorage.getInstance().getDatabase();
ArrayList<Long> dialogsToCleanup = new ArrayList<>();
SQLiteCursor cursor = database.queryFinalized("SELECT did FROM dialogs WHERE 1");
StringBuilder ids = new StringBuilder();
while (cursor.next()) {
long did = cursor.longValue(0);
int lower_id = (int) did;
int high_id = (int) (did >> 32);
if (lower_id != 0 && high_id != 1) {
dialogsToCleanup.add(did);
}
}
cursor.dispose();
SQLitePreparedStatement state5 = database.executeFast("REPLACE INTO messages_holes VALUES(?, ?, ?)");
SQLitePreparedStatement state6 = database.executeFast("REPLACE INTO media_holes_v2 VALUES(?, ?, ?, ?)");
database.beginTransaction();
for (int a = 0; a < dialogsToCleanup.size(); a++) {
Long did = dialogsToCleanup.get(a);
int messagesCount = 0;
cursor = database.queryFinalized("SELECT COUNT(mid) FROM messages WHERE uid = " + did);
if (cursor.next()) {
messagesCount = cursor.intValue(0);
}
cursor.dispose();
if (messagesCount <= 2) {
continue;
}
cursor = database.queryFinalized("SELECT last_mid_i, last_mid FROM dialogs WHERE did = " + did);
int messageId = -1;
if (cursor.next()) {
long last_mid_i = cursor.longValue(0);
long last_mid = cursor.longValue(1);
SQLiteCursor cursor2 = database.queryFinalized("SELECT data FROM messages WHERE uid = " + did + " AND mid IN (" + last_mid_i + "," + last_mid + ")");
try {
while (cursor2.next()) {
NativeByteBuffer data = cursor2.byteBufferValue(0);
if (data != null) {
TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false);
data.reuse();
if (message != null) {
messageId = message.id;
}
}
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
cursor2.dispose();
database.executeFast("DELETE FROM messages WHERE uid = " + did + " AND mid != " + last_mid_i + " AND mid != " + last_mid).stepThis().dispose();
database.executeFast("DELETE FROM messages_holes WHERE uid = " + did).stepThis().dispose();
database.executeFast("DELETE FROM bot_keyboard WHERE uid = " + did).stepThis().dispose();
database.executeFast("DELETE FROM media_counts_v2 WHERE uid = " + did).stepThis().dispose();
database.executeFast("DELETE FROM media_v2 WHERE uid = " + did).stepThis().dispose();
database.executeFast("DELETE FROM media_holes_v2 WHERE uid = " + did).stepThis().dispose();
BotQuery.clearBotKeyboard(did, null);
if (messageId != -1) {
MessagesStorage.createFirstHoles(did, state5, state6, messageId);
}
}
cursor.dispose();
}
state5.dispose();
state6.dispose();
database.commitTransaction();
database.executeFast("VACUUM").stepThis().dispose();
} catch (Exception e) {
FileLog.e("messenger", e);
} finally {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e("messenger", e);
}
if (listAdapter != null) {
File file = new File(ApplicationLoader.getFilesDirFixed(), "cache4.db");
databaseSize = file.length();
listAdapter.notifyDataSetChanged();
}
}
});
}
}
});
}
});
showDialog(builder.create());
*/
} else if (i == cacheRow) {
/* EDIT BY MR
if (totalSize <= 0 || getParentActivity() == null) {
return;
}
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
builder.setApplyTopPadding(false);
builder.setApplyBottomPadding(false);
LinearLayout linearLayout = new LinearLayout(getParentActivity());
linearLayout.setOrientation(LinearLayout.VERTICAL);
for (int a = 0; a < 6; a++) {
long size = 0;
String name = null;
if (a == 0) {
size = photoSize;
name = LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache);
} else if (a == 1) {
size = videoSize;
name = LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache);
} else if (a == 2) {
size = documentsSize;
name = LocaleController.getString("LocalDocumentCache", R.string.LocalDocumentCache);
} else if (a == 3) {
size = musicSize;
name = LocaleController.getString("LocalMusicCache", R.string.LocalMusicCache);
} else if (a == 4) {
size = audioSize;
name = LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache);
} else if (a == 5) {
size = cacheSize;
name = LocaleController.getString("LocalCache", R.string.LocalCache);
}
if (size > 0) {
clear[a] = true;
CheckBoxCell checkBoxCell = new CheckBoxCell(getParentActivity());
checkBoxCell.setTag(a);
checkBoxCell.setBackgroundResource(R.drawable.list_selector);
linearLayout.addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
checkBoxCell.setText(name, AndroidUtilities.formatFileSize(size), true, true);
checkBoxCell.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CheckBoxCell cell = (CheckBoxCell) v;
int num = (Integer) cell.getTag();
clear[num] = !clear[num];
cell.setChecked(clear[num], true);
}
});
} else {
clear[a] = false;
}
}
BottomSheet.BottomSheetCell cell = new BottomSheet.BottomSheetCell(getParentActivity(), 1);
cell.setBackgroundResource(R.drawable.list_selector);
cell.setTextAndIcon(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache).toUpperCase(), 0);
cell.setTextColor(0xffcd5a5a);
cell.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
if (visibleDialog != null) {
visibleDialog.dismiss();
}
} catch (Exception e) {
FileLog.e("messenger", e);
}
cleanupFolders();
}
});
linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
builder.setCustomView(linearLayout);
showDialog(builder.create());
*/
}
}
});
Toast.makeText(context, LocaleController.getString("NotYetImplemented", R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
return fragmentView;
}
@@ -480,7 +147,7 @@ public class CacheControlActivity extends BaseFragment {
@Override
public boolean isEnabled(int i) {
return i == databaseRow || /*i == cacheRow && totalSize > 0 ||*/ i == keepMediaRow;
return i == rowKeepMediaSetting;
}
@Override
@@ -505,32 +172,14 @@ public class CacheControlActivity extends BaseFragment {
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type_ = getItemViewType(i);
if (type_ == typeSectionTitle) {
if (view == null) {
view = new HeaderCell(mContext);
view.setBackgroundColor(0xffffffff);
}
if (i == headlineRow) {
((HeaderCell) view).setText(LocaleController.getString("Settings", R.string.Settings));
}
}
else if (type_ == typeTextSetting) {
int type = getItemViewType(i);
if (type == ROWTYPE_TEXT_SETTING) {
if (view == null) {
view = new TextSettingsCell(mContext);
view.setBackgroundColor(0xffffffff);
}
TextSettingsCell textCell = (TextSettingsCell) view;
if (i == databaseRow) {
//textCell.setTextAndValue(LocaleController.getString("LocalDatabase", R.string.LocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false);
} else if (i == cacheRow) {
/*if (calculating) {
textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), LocaleController.getString("CalculatingSize", R.string.CalculatingSize), false);
} else {
textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), totalSize == 0 ? LocaleController.getString("CacheEmpty", R.string.CacheEmpty) : AndroidUtilities.formatFileSize(totalSize), false);
}
*/
} else if (i == keepMediaRow) {
if (i == rowKeepMediaSetting) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
int keepMedia = preferences.getInt("keep_media", 2);
String value;
@@ -543,18 +192,12 @@ public class CacheControlActivity extends BaseFragment {
}
textCell.setTextAndValue(mContext.getString(R.string.KeepMedia), value, false);
}
} else if (type_ == typeTextInfo) {
} else if (type == ROWTYPE_TEXT_INFO) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if (i == databaseInfoRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("LocalDatabaseInfo", R.string.LocalDatabaseInfo));
view.setBackgroundResource(R.drawable.greydivider_bottom);
} else if (i == cacheInfoRow) {
((TextInfoPrivacyCell) view).setText("");
view.setBackgroundResource(R.drawable.greydivider);
} else if (i == keepMediaInfoRow) {
((TextInfoPrivacyCell) view).setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
if (i == rowKeepMediaInfo) {
((TextInfoCell) view).setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
}
@@ -563,20 +206,15 @@ public class CacheControlActivity extends BaseFragment {
@Override
public int getItemViewType(int i) {
if (i == databaseRow || i == cacheRow || i == keepMediaRow) {
return typeTextSetting;
} else if (i == databaseInfoRow || i == cacheInfoRow || i == keepMediaInfoRow) {
return typeTextInfo;
if (i == rowKeepMediaInfo) {
return ROWTYPE_TEXT_INFO;
}
else if(i==headlineRow) {
return typeSectionTitle;
}
return typeTextSetting;
return ROWTYPE_TEXT_SETTING;
}
@Override
public int getViewTypeCount() {
return typeCount;
return ROWTYPE_COUNT;
}
@Override
@@ -35,7 +35,6 @@ import android.view.MotionEvent;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.FileLog;
import com.b44t.ui.ActionBar.Theme;
@@ -68,7 +67,7 @@ public class ChatActionCell extends BaseCell {
}
backPaint.setColor(ApplicationLoader.getServiceMessageColor());
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize - 2));
textPaint.setTextSize(AndroidUtilities.dp(ApplicationLoader.fontSize - 2));
}
public void setMessageObject(MessageObject messageObject) {
@@ -53,7 +53,6 @@ import com.b44t.messenger.MediaController;
import com.b44t.messenger.FileLoader;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.MrChat;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
@@ -894,7 +893,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
TLRPC.User newUser = null;
final TLRPC.Chat newChat = null;
if (currentMessageObject.isFromUser()) {
newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id);
newUser = MrMailbox.getUser(currentMessageObject.messageOwner.from_id);
} /*else if (currentMessageObject.messageOwner.post) {
newChat = MessagesController.getInstance().getChat(currentMessageObject.messageOwner.to_id.channel_id);
}*/
@@ -2120,7 +2119,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private void measureTime(MessageObject messageObject) {
boolean hasSign = !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0 && messageObject.messageOwner.post;
TLRPC.User signUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
TLRPC.User signUser = MrMailbox.getUser(messageObject.messageOwner.from_id);
if (hasSign && signUser == null) {
hasSign = false;
}
@@ -2163,7 +2162,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private void setMessageObjectInternal(MessageObject messageObject) {
if (currentMessageObject.isFromUser()) {
currentUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id);
currentUser = MrMailbox.getUser(currentMessageObject.messageOwner.from_id);
} /*else if (currentMessageObject.messageOwner.from_id < 0) {
currentChat = MessagesController.getInstance().getChat(-currentMessageObject.messageOwner.from_id);
} else if (currentMessageObject.messageOwner.post) {
@@ -32,7 +32,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.R;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.ActionBar.Theme;
@@ -50,7 +50,7 @@ public class ChatUnreadCell extends FrameLayout {
textView = new TextView(context);
textView.setPadding(0, 0, 0, AndroidUtilities.dp(1));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, MessagesController.getInstance().fontSize-2);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, ApplicationLoader.fontSize-2);
textView.setTextColor(Theme.MSG_IN_TIME_N_FWD_TEXT_COLOR);
textView.setTypeface(Typeface.DEFAULT_BOLD);
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
@@ -49,7 +49,6 @@ import com.b44t.messenger.MrMsg;
import com.b44t.messenger.MrPoortext;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.Emoji;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.R;
import com.b44t.messenger.ImageReceiver;
import com.b44t.ui.ActionBar.Theme;
@@ -551,27 +550,27 @@ public class DialogCell extends BaseCell {
if (mask != 0) {
boolean continueUpdate = false;
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_AVATAR) != 0) {
if (chat == null) {
continueUpdate = true;
}
}
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_NAME) != 0) {
if (chat == null) {
continueUpdate = true;
}
}
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0) {
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_CHAT_AVATAR) != 0) {
if (user == null) {
continueUpdate = true;
}
}
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_CHAT_NAME) != 0) {
if (user == null) {
continueUpdate = true;
}
}
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_SEND_STATE) != 0) {
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_SEND_STATE) != 0) {
if (message != null && lastSendState != message.messageOwner.send_state) {
lastSendState = message.messageOwner.send_state;
continueUpdate = true;
@@ -583,7 +582,7 @@ public class DialogCell extends BaseCell {
}
}
dialogMuted = isDialogCell && MessagesController.getInstance().isDialogMuted(currentDialogId);
dialogMuted = isDialogCell && MrMailbox.isDialogMuted(currentDialogId);
//user = null;
//chat = null;
@@ -48,10 +48,15 @@ public class EditTextCell extends FrameLayout {
private TextView labelTextView;
private static Paint paint;
private boolean needDivider;
private String originalValue;
private boolean useLabel;
public EditTextCell(Context context) {
this(context, true);
}
public EditTextCell(Context context, boolean useLabel__) {
super(context);
useLabel = useLabel__;
if (paint == null) {
paint = new Paint();
@@ -60,7 +65,7 @@ public class EditTextCell extends FrameLayout {
}
labelTextView = new TextView(context);
labelTextView.setTextColor(0xff8a8a8a);
labelTextView.setTextColor(0xff212121);
labelTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
labelTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
labelTextView.setLines(1);
@@ -68,7 +73,7 @@ public class EditTextCell extends FrameLayout {
labelTextView.setSingleLine(true);
labelTextView.setPadding(0, 0, 0, 0);
addView(labelTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
17, 10, 17, 0));
17, 8, 17, 0));
editView = new EditText(context);
@@ -97,23 +102,21 @@ public class EditTextCell extends FrameLayout {
*/
addView(editView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
17, 25, 17, 0));
17, useLabel? 25 : 25-17, 17, 0));
setBackgroundColor(0xffffffff);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(useLabel? 64 : 64-15) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
}
public void setValueHintAndLabel(String value, String hint, String label, boolean divider) {
originalValue = value;
editView.setText(value);
editView.setSelection(value.length());
editView.setHint(hint.isEmpty()? "" : ("<"+hint+">"));
editView.setHint(hint);
if( label.isEmpty()) {
labelTextView.setVisibility(INVISIBLE);
@@ -132,11 +135,6 @@ public class EditTextCell extends FrameLayout {
return editView.getText().toString();
}
public boolean isModified()
{
return !originalValue.equals(getValue());
}
public EditText getEditTextView()
{
return editView;
@@ -1,7 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -24,7 +23,6 @@
package com.b44t.ui.Cells;
import android.content.Context;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
@@ -33,23 +31,29 @@ import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.ActionBar.Theme;
public class TextInfoPrivacyCell extends FrameLayout {
public class TextInfoCell extends FrameLayout {
private TextView textView;
private TextView iconView;
public TextInfoPrivacyCell(Context context) {
private final int iconDp = 34;
public TextInfoCell(Context context) {
super(context);
textView = new TextView(context);
textView.setTextColor(0xff808080);
textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(17));
textView.setMovementMethod(LinkMovementMethod.getInstance());
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
addView(textView);
iconView = new TextView(context);
iconView.setTextColor(0xff212121);
iconView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, iconDp);
iconView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
addView(iconView);
}
@Override
@@ -57,8 +61,43 @@ public class TextInfoPrivacyCell extends FrameLayout {
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
}
public void setText(CharSequence text) {
public void setText(CharSequence text)
{
setText(text, null, true);
}
public void setText(CharSequence text, CharSequence icon, boolean borderBotton)
{
textView.setText(text);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) textView.getLayoutParams();
lp.width = LayoutHelper.WRAP_CONTENT;
lp.height = LayoutHelper.WRAP_CONTENT;
lp.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
lp.leftMargin = AndroidUtilities.dp(17);
lp.topMargin = AndroidUtilities.dp(13);
lp.rightMargin = AndroidUtilities.dp(17 + (icon!=null?iconDp:0));
lp.bottomMargin = borderBotton? AndroidUtilities.dp(13) : 0;
textView.setLayoutParams(lp);
if( icon != null )
{
iconView.setText(icon);
iconView.setVisibility(VISIBLE);
lp = (FrameLayout.LayoutParams) iconView.getLayoutParams();
lp.width = LayoutHelper.WRAP_CONTENT;
lp.height = LayoutHelper.WRAP_CONTENT;
lp.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP;
lp.leftMargin = AndroidUtilities.dp(17);
lp.topMargin = AndroidUtilities.dp(3);
lp.rightMargin = AndroidUtilities.dp(20);
iconView.setLayoutParams(lp);
}
else
{
iconView.setVisibility(GONE);
}
}
public void setTextColor(int color) {
@@ -96,7 +96,7 @@ public class UserCell extends FrameLayout {
currentStatus = m_mrContact.getAddr();
}
currentResId = resId;
update(0);
update();
}
public void setChecked(boolean checked, boolean animated) {
@@ -117,60 +117,10 @@ public class UserCell extends FrameLayout {
statusColor = color;
}
public void update(int mask) {
public void update() {
if (m_mrContact==null) {
return;
}
TLRPC.FileLocation photo = null;
//String newName = null;
/*
if (mask != 0) {
boolean continueUpdate = false;
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
continueUpdate = true;
}
}
if (user_id != 0 && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
int newStatus = 0;
if (currentUser.status != null) {
newStatus = currentUser.status.expires;
}
if (newStatus != lastStatus) {
continueUpdate = true;
}
}
if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
if (currentUser != null) {
newName = UserObject.getUserName(currentUser);
} else {
newName = currentChat.title;
}
if (!newName.equals(lastName)) {
continueUpdate = true;
}
}
if (!continueUpdate) {
return;
}
}
*/
/*
if (currentUser != null) {
avatarDrawable.setInfoByUser(currentUser);
if (currentUser.status != null) {
lastStatus = currentUser.status.expires;
} else {
lastStatus = 0;
}
} else {
avatarDrawable.setInfoByChat(currentChat);
}
*/
if (currentName != null) {
nameTextView.setText(currentName);
@@ -73,11 +73,9 @@ import com.b44t.messenger.browser.Browser;
import com.b44t.messenger.support.widget.LinearLayoutManager;
import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.ConnectionsManager;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.UserConfig;
@@ -225,7 +223,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidStarted);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.waveformCalculated);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.errSelfNotInGroup);
if (AndroidUtilities.isTablet()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, false);
@@ -355,7 +352,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioDidStarted);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.waveformCalculated);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.errSelfNotInGroup);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioPlayStateChanged);
if (AndroidUtilities.isTablet()) {
@@ -1058,7 +1054,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void needSendTyping() {
MessagesController.getInstance().sendTyping(dialog_id, 0, classGuid);
MrMailbox.sendTyping(dialog_id, 0, classGuid);
}
@Override
@@ -1365,7 +1361,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void toggleMute() {
boolean muted = MessagesController.getInstance().isDialogMuted(dialog_id);
boolean muted = MrMailbox.isDialogMuted(dialog_id);
if (!muted) {
// EDIT BY MR
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); // was: BottomSheet.Builder
@@ -1379,7 +1375,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int untilTime = ConnectionsManager.getInstance().getCurrentTime();
int untilTime = MrMailbox.getCurrentTime();
if (i == 0) { untilTime += 60 * 60; }
else if (i == 1) { untilTime += 60 * 60 * 8; }
else if (i == 2) { untilTime += 60 * 60 * 48; }
@@ -1401,7 +1397,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
dialog.notify_settings.mute_until = untilTime;
}
*/
NotificationsController.updateServerNotificationsSettings(dialog_id);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.notificationsSettingsUpdated);
}
}
);
@@ -1417,7 +1413,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
}
*/
NotificationsController.updateServerNotificationsSettings(dialog_id);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.notificationsSettingsUpdated);
}
}
@@ -1622,7 +1618,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
int rightIcon = 0;
if( m_canMute && MessagesController.getInstance().isDialogMuted(dialog_id) ) {
if( m_canMute && MrMailbox.isDialogMuted(dialog_id) ) {
rightIcon = R.drawable.mute_fixed;
}
@@ -1648,18 +1644,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
VideoEditorActivity fragment = new VideoEditorActivity(args);
fragment.setDelegate(new VideoEditorActivity.VideoEditorActivityDelegate() {
@Override
public void didFinishEditVideo(String videoPath, long startTime, long endTime, int resultWidth, int resultHeight, int rotationValue, int originalWidth, int originalHeight, int bitrate, long estimatedSize, long estimatedDuration) {
VideoEditedInfo videoEditedInfo = new VideoEditedInfo();
videoEditedInfo.startTime = startTime;
videoEditedInfo.endTime = endTime;
videoEditedInfo.rotationValue = rotationValue;
videoEditedInfo.originalWidth = originalWidth;
videoEditedInfo.originalHeight = originalHeight;
videoEditedInfo.bitrate = bitrate;
videoEditedInfo.resultWidth = resultWidth;
videoEditedInfo.resultHeight = resultHeight;
videoEditedInfo.originalPath = videoPath;
SendMessagesHelper.prepareSendingVideo(videoPath, estimatedSize, estimatedDuration, resultWidth, resultHeight, videoEditedInfo, dialog_id);
public void didFinishEditVideo(VideoEditedInfo vei, long estimatedSize, long estimatedDuration) {
SendMessagesHelper.prepareSendingVideo(vei.originalPath, estimatedSize, estimatedDuration, vei.resultWidth, vei.resultHeight, vei, dialog_id);
m_mrChat.cleanDraft();
}
});
@@ -1891,16 +1877,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
else if (id == NotificationCenter.updateInterfaces)
{
int updateMask = (Integer) args[0];
if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
if ((updateMask & MrMailbox.UPDATE_MASK_NAME) != 0 || (updateMask & MrMailbox.UPDATE_MASK_CHAT_NAME) != 0) {
int back_id = m_mrChat.getId();
m_mrChat = MrMailbox.getChat(back_id);
updateTitle();
}
boolean updateSubtitle = false;
if ((updateMask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0 || (updateMask & MessagesController.UPDATE_MASK_STATUS) != 0) {
if ((updateMask & MrMailbox.UPDATE_MASK_CHAT_MEMBERS) != 0 || (updateMask & MrMailbox.UPDATE_MASK_STATUS) != 0) {
updateSubtitle = true;
}
if ((updateMask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_NAME) != 0) {
if ((updateMask & MrMailbox.UPDATE_MASK_AVATAR) != 0 || (updateMask & MrMailbox.UPDATE_MASK_CHAT_AVATAR) != 0 || (updateMask & MrMailbox.UPDATE_MASK_NAME) != 0) {
checkAndUpdateAvatar();
updateVisibleRows();
}
@@ -2029,10 +2015,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
{
updateTitleIcons();
}
else if( id == NotificationCenter.errSelfNotInGroup )
{
Toast.makeText(getParentActivity(), LocaleController.getString("ErrSelfNotInGroup", R.string.ErrSelfNotInGroup), Toast.LENGTH_LONG).show();
}
}
private boolean m_searching = false;
@@ -2268,7 +2250,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
m_mrChat.saveDraft(draftMessage, null);
MessagesController.getInstance().cancelTyping(0, dialog_id);
MrMailbox.cancelTyping(0, dialog_id);
}
private void applyDraftMaybe() {
@@ -2619,7 +2601,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
processRowSelect(cell);
return;
}
if (user != null && user.id != UserConfig.getClientUserId()) {
if (user != null && user.id != MrContact.MR_CONTACT_ID_SELF) {
Bundle args = new Bundle();
args.putInt("user_id", user.id);
ProfileActivity fragment = new ProfileActivity(args);
@@ -211,7 +211,7 @@ public class AvatarUpdater implements PhotoCropActivity.PhotoEditActivityDelegat
delegate.didUploadedPhoto(null, smallPhoto, bigPhoto);
}
} else {
UserConfig.saveConfig(false);
UserConfig.saveConfig();
uploadingAvatar = FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE) + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg";
//FileLoader.getInstance().uploadFile(uploadingAvatar, false, true);
}
@@ -65,7 +65,8 @@ import com.b44t.messenger.Emoji;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.SendMessagesHelper;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.NotificationCenter;
@@ -1384,7 +1385,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
public void onGifSelected(TLRPC.Document gif) {
SendMessagesHelper.getInstance().sendSticker(gif, dialog_id);
if ((int) dialog_id == 0) {
MessagesController.getInstance().saveGif(gif);
//MessagesController.getInstance().saveGif(gif);
}
if (delegate != null) {
delegate.onMessageSend(null);
@@ -1632,7 +1633,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
String str = String.format("%02d:%02d.%02d", time / 60, time % 60, ms);
if (lastTimeString == null || !lastTimeString.equals(str)) {
if (time % 5 == 0) {
MessagesController.getInstance().sendTyping(dialog_id, 1, 0);
MrMailbox.sendTyping(dialog_id, 1, 0);
}
if (recordTimeText != null) {
recordTimeText.setText(str);
@@ -1647,7 +1648,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
} else if (id == NotificationCenter.recordStartError || id == NotificationCenter.recordStopped) {
if (recordingAudio) {
MessagesController.getInstance().sendTyping(dialog_id, 2, 0);
MrMailbox.sendTyping(dialog_id, 2, 0);
recordingAudio = false;
updateAudioRecordInterface();
}
@@ -1668,7 +1669,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
message.out = true;
message.id = 0;
message.to_id = new TLRPC.TL_peerUser();
message.to_id.user_id = message.from_id = UserConfig.getClientUserId();
message.to_id.user_id = message.from_id = MrContact.MR_CONTACT_ID_SELF;
message.date = (int) (System.currentTimeMillis() / 1000);
message.message = "-1";
message.attachPath = audioToSendPath;
@@ -434,7 +434,7 @@ public class PasscodeView extends FrameLayout {
AnimatorSet.start();
UserConfig.appLocked = false;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didSetPasscode);
setOnTouchListener(null);
if (delegate != null) {
@@ -46,13 +46,11 @@ import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.Emoji;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.support.widget.GridLayoutManager;
import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.ConnectionsManager;
import com.b44t.messenger.TLRPC;
import com.b44t.ui.ActionBar.BottomSheet;
import com.b44t.ui.ActionBar.Theme;
@@ -523,7 +521,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
public void dismiss() {
super.dismiss();
if (reqId != 0) {
ConnectionsManager.getInstance().cancelRequest(reqId, true);
//ConnectionsManager.getInstance().cancelRequest(reqId, true);
reqId = 0;
}
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
@@ -42,11 +42,9 @@ import android.widget.Toast;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ContactsController;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrChat;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.ActionBar.ActionBar;
@@ -160,7 +158,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
args.putInt("chat_id", belonging_chat_id);
presentFragment(new ChatActivity(args), true);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidCreated, belonging_chat_id); /*this will remove the contact list from stack */
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MrMailbox.UPDATE_MASK_NAME);
return;
}
}
@@ -171,7 +169,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
}
finishFragment();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MrMailbox.UPDATE_MASK_NAME);
}
}
});
@@ -392,14 +390,5 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
@Override
public void didReceivedNotification(int id, final Object... args) {
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateVisibleRows(mask);
}
}
}
private void updateVisibleRows(int mask) {
}
}
@@ -63,7 +63,6 @@ import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.Utilities;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.Adapters.ContactsAdapter;
@@ -255,6 +254,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
ActionBarMenu menu = actionBar.createMenu();
if( do_what == SELECT_CONTACTS_FOR_NEW_GROUP ) {
menu.addItem(id_done_button, R.drawable.ic_done); // should the "done" button be right or left of other buttons? Esp. for the "more" button, it looks better if it is right left of it - beside the title describing the action and nearer to "cancel"; the other buttons has not so much to do with the group but switches to other types. In other situations, the icon-oder-decision may be different.
}
ActionBarMenuItem item = menu.addItem(10, R.drawable.ic_ab_other);
if (do_what == SELECT_CONTACT_FOR_NEW_CHAT || do_what == SELECT_CONTACTS_FOR_NEW_GROUP) {
@@ -263,11 +265,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
item.addSubItem(id_add_contact, LocaleController.getString("NewContactTitle", R.string.NewContactTitle), 0);
if( do_what == SELECT_CONTACTS_FOR_NEW_GROUP ) {
menu.addItem(id_done_button, R.drawable.ic_done); // this should be the very most right icon
}
listViewAdapter = new ContactsAdapter(context);
listViewAdapter.setCheckedMap(selectedContacts);
@@ -578,8 +575,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
} else if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateVisibleRows(mask);
if ((mask & MrMailbox.UPDATE_MASK_AVATAR) != 0 || (mask & MrMailbox.UPDATE_MASK_NAME) != 0 || (mask & MrMailbox.UPDATE_MASK_STATUS) != 0) {
updateVisibleRows();
}
} else if (id == NotificationCenter.closeChats) {
removeSelfFromStack();
@@ -588,13 +585,13 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
}
private void updateVisibleRows(int mask) {
private void updateVisibleRows() {
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
((UserCell) child).update();
}
}
}
@@ -62,7 +62,6 @@ import com.b44t.messenger.Utilities;
import com.b44t.messenger.support.widget.LinearLayoutManager;
import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.UserConfig;
@@ -150,7 +149,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageSendError);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didSetPasscode);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.reloadHints);
if (!dialogsLoaded) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); // this is the rest of the first call to the removed MessagesController.loadDialogs(); not sure, if this is really needed
@@ -171,7 +169,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageSendError);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didSetPasscode);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.reloadHints);
delegate = null;
}
@@ -280,7 +277,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
listView.setVisibility(View.INVISIBLE);
UserConfig.appLocked = !UserConfig.appLocked;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
if( UserConfig.appLocked )
{
// hide list as it is visible in the "last app switcher" otherwise, save state
@@ -374,7 +371,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
if (dialogsAdapter != null) {
dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
updateVisibleRows(MrMailbox.UPDATE_MASK_SELECT_DIALOG);
}
}
@@ -598,7 +595,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (dialogsAdapter.isDataSetChanged()) {
dialogsAdapter.notifyDataSetChanged();
} else {
updateVisibleRows(MessagesController.UPDATE_MASK_NEW_MESSAGE);
updateVisibleRows(MrMailbox.UPDATE_MASK_NEW_MESSAGE);
}
*/
}
@@ -648,18 +645,14 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (dialogsAdapter != null) {
dialogsAdapter.setOpenedDialogId(openedDialogId);
}
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
updateVisibleRows(MrMailbox.UPDATE_MASK_SELECT_DIALOG);
}
} else if (id == NotificationCenter.notificationsSettingsUpdated) {
updateVisibleRows(0);
} else if ( id == NotificationCenter.messageSendError) {
updateVisibleRows(MessagesController.UPDATE_MASK_SEND_STATE);
updateVisibleRows(MrMailbox.UPDATE_MASK_SEND_STATE);
} else if (id == NotificationCenter.didSetPasscode) {
updatePasscodeButton();
} else if (id == NotificationCenter.reloadHints) {
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
}
}
}
@@ -700,12 +693,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (child instanceof DialogCell) {
if (listView.getAdapter() != dialogsSearchAdapter) {
DialogCell cell = (DialogCell) child;
if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0) {
if ((mask & MrMailbox.UPDATE_MASK_NEW_MESSAGE) != 0) {
cell.checkCurrentDialogIndex();
if ( AndroidUtilities.isTablet()) {
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
}
} else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) {
} else if ((mask & MrMailbox.UPDATE_MASK_SELECT_DIALOG) != 0) {
if ( AndroidUtilities.isTablet()) {
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
}
@@ -714,7 +707,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
}
} else if (child instanceof UserCell) {
((UserCell) child).update(mask);
((UserCell) child).update();
}
}
}
@@ -23,9 +23,7 @@
package com.b44t.ui;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
@@ -49,7 +47,6 @@ import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
@@ -151,7 +148,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
args2.putInt("chat_id", chat_id);
presentFragment(new ChatActivity(args2), true);
if (uploadedAvatar != null) {
MessagesController.getInstance().changeChatAvatar(chat_id, uploadedAvatar);
//MessagesController.getInstance().changeChatAvatar(chat_id, uploadedAvatar);
}
}
}
@@ -360,13 +357,13 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
public void didReceivedNotification(int id, final Object... args) {
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateVisibleRows(mask);
if ((mask & MrMailbox.UPDATE_MASK_AVATAR) != 0 || (mask & MrMailbox.UPDATE_MASK_NAME) != 0 || (mask & MrMailbox.UPDATE_MASK_STATUS) != 0) {
updateVisibleRows();
}
}
}
private void updateVisibleRows(int mask) {
private void updateVisibleRows() {
if (listView == null) {
return;
}
@@ -374,7 +371,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
((UserCell) child).update();
}
}
}
@@ -23,9 +23,7 @@
package com.b44t.ui;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
@@ -39,13 +37,13 @@ import android.widget.ListView;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.R;
import com.b44t.messenger.Utilities;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.TextSettingsCell;
import com.b44t.ui.Cells.TextDetailSettingsCell;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.ActionBarMenuItem;
@@ -53,6 +51,8 @@ import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Components.LayoutHelper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Timer;
import java.util.TimerTask;
@@ -63,12 +63,28 @@ public class LanguageSelectActivity extends BaseFragment {
private boolean searching;
private BaseFragmentAdapter searchListViewAdapter;
private TextView emptyTextView;
private Timer searchTimer;
public ArrayList<LocaleController.LocaleInfo> searchResult;
private ArrayList<LocaleController.LocaleInfo> sortedLanguages = new ArrayList<>();
@Override
public View createView(Context context) {
for (LocaleController.LocaleInfo localInfo : LocaleController.getInstance().languagesDict.values()) {
sortedLanguages.add(localInfo);
}
Collections.sort(sortedLanguages, new Comparator<LocaleController.LocaleInfo>() {
@Override
public int compare(LocaleController.LocaleInfo o, LocaleController.LocaleInfo o2) {
return o.name.compareTo(o2.name);
}
});
LocaleController.LocaleInfo localeInfo = new LocaleController.LocaleInfo();
localeInfo.name = ApplicationLoader.applicationContext.getString(R.string.Default); // the "Default" option is interesting, because it not only sets the language to default but also clears the "override" flag - further system changes are then followed by Delta Chat again.
localeInfo.nameEnglish = "Default";
localeInfo.shortName = null;
sortedLanguages.add(0, localeInfo);
searching = false;
searchWas = false;
@@ -179,8 +195,8 @@ public class LanguageSelectActivity extends BaseFragment {
localeInfo = searchResult.get(i);
}
} else {
if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) {
localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
if (i >= 0 && i < sortedLanguages.size()) {
localeInfo = sortedLanguages.get(i);
}
}
if (localeInfo != null) {
@@ -191,47 +207,6 @@ public class LanguageSelectActivity extends BaseFragment {
}
});
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
LocaleController.LocaleInfo localeInfo = null;
if (searching && searchWas) {
if (i >= 0 && i < searchResult.size()) {
localeInfo = searchResult.get(i);
}
} else {
if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) {
localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
}
}
if (localeInfo == null || localeInfo.pathToFile == null || getParentActivity() == null) {
return false;
}
final LocaleController.LocaleInfo finalLocaleInfo = localeInfo;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("DeleteLocalization", R.string.DeleteLocalization));
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (LocaleController.getInstance().deleteLanguage(finalLocaleInfo)) {
if (searchResult != null) {
searchResult.remove(finalLocaleInfo);
}
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
if (searchListViewAdapter != null) {
searchListViewAdapter.notifyDataSetChanged();
}
}
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
return true;
}
});
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int i) {
@@ -293,10 +268,9 @@ public class LanguageSelectActivity extends BaseFragment {
updateSearchResults(new ArrayList<LocaleController.LocaleInfo>());
return;
}
long time = System.currentTimeMillis();
ArrayList<LocaleController.LocaleInfo> resultArray = new ArrayList<>();
for (LocaleController.LocaleInfo c : LocaleController.getInstance().sortedLanguages) {
for (LocaleController.LocaleInfo c : sortedLanguages) {
if (c.name.toLowerCase().startsWith(query) || c.nameEnglish.toLowerCase().startsWith(query)) {
resultArray.add(c);
}
@@ -360,11 +334,11 @@ public class LanguageSelectActivity extends BaseFragment {
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = new TextSettingsCell(mContext);
view = new TextDetailSettingsCell(mContext);
}
LocaleController.LocaleInfo c = searchResult.get(i);
((TextSettingsCell) view).setText(c.name, i != searchResult.size() - 1);
((TextDetailSettingsCell) view).setTextAndValue(c.name, c.nameEnglish, i != searchResult.size() - 1);
return view;
}
@@ -404,10 +378,10 @@ public class LanguageSelectActivity extends BaseFragment {
@Override
public int getCount() {
if (LocaleController.getInstance().sortedLanguages == null) {
if (sortedLanguages == null) {
return 0;
}
return LocaleController.getInstance().sortedLanguages.size();
return sortedLanguages.size();
}
@Override
@@ -428,11 +402,11 @@ public class LanguageSelectActivity extends BaseFragment {
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = new TextSettingsCell(mContext);
view = new TextDetailSettingsCell(mContext);
}
LocaleController.LocaleInfo localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
((TextSettingsCell) view).setText(localeInfo.name, i != LocaleController.getInstance().sortedLanguages.size() - 1);
LocaleController.LocaleInfo localeInfo = sortedLanguages.get(i);
((TextDetailSettingsCell) view).setTextAndValue(localeInfo.name, localeInfo.nameEnglish, i != sortedLanguages.size() - 1);
return view;
}
@@ -449,7 +423,7 @@ public class LanguageSelectActivity extends BaseFragment {
@Override
public boolean isEmpty() {
return LocaleController.getInstance().sortedLanguages == null || LocaleController.getInstance().sortedLanguages.size() == 0;
return sortedLanguages == null || sortedLanguages.size() == 0;
}
}
}
@@ -27,7 +27,6 @@ import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.Intent;
@@ -41,6 +40,7 @@ import android.os.Parcelable;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -69,8 +69,6 @@ import com.b44t.messenger.LocaleController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.browser.Browser;
import com.b44t.messenger.ConnectionsManager;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.UserConfig;
import com.b44t.ui.Adapters.DrawerLayoutAdapter;
import com.b44t.ui.ActionBar.ActionBarLayout;
@@ -97,7 +95,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
private String documentsMimeType;
private ArrayList<String> documentsOriginalPathsArray;
private ArrayList<Integer> contactsToSend;
private int currentConnectionState;
private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<>();
private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<>();
private static ArrayList<BaseFragment> rightFragmentsStack = new ArrayList<>();
@@ -124,7 +121,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override
protected void onCreate(Bundle savedInstanceState) {
ApplicationLoader.postInitApplication();
if( MrMailbox.isConfigured()==0 ) {
Intent intent = getIntent();
@@ -165,7 +161,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
Theme.loadRecources(this);
if (UserConfig.passcodeHash.length() != 0 && UserConfig.appLocked) {
UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime();
UserConfig.lastPauseTime = MrMailbox.getCurrentTime();
}
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
@@ -363,11 +359,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
passcodeView.setLayoutParams(layoutParams1);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
currentConnectionState = ConnectionsManager.getInstance().getConnectionState();
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState);
if (actionBarLayout.fragmentsStack.isEmpty()) {
if ( MrMailbox.isConfigured()==0 ) {
@@ -408,26 +402,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
}
break;
case "channel":
/* EDIT BY MR
if (args != null) {
ChannelCreateActivity channel = new ChannelCreateActivity(args);
if (actionBarLayout.addFragmentToStack(channel)) {
channel.restoreSelfArgs(savedInstanceState);
}
}
*/
break;
case "edit":
/* EDIT BY MR
if (args != null) {
ChannelEditActivity channel = new ChannelEditActivity(args);
if (actionBarLayout.addFragmentToStack(channel)) {
channel.restoreSelfArgs(savedInstanceState);
}
}
*/
break;
case "chat_profile":
if (args != null) {
ProfileActivity profile = new ProfileActivity(args);
@@ -519,7 +493,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
passcodeSaveIntent = intent;
passcodeSaveIntentIsNew = isNew;
passcodeSaveIntentIsRestore = restore;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
} else {
boolean pushOpened = false;
@@ -1118,7 +1092,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState);
}
public void presentFragment(BaseFragment fragment) {
@@ -1236,7 +1209,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (UserConfig.passcodeHash.length() != 0 && UserConfig.lastPauseTime != 0) {
UserConfig.lastPauseTime = 0;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
}
super.onActivityResult(requestCode, resultCode, data);
if (actionBarLayout.fragmentsStack.size() != 0) {
@@ -1329,6 +1302,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override
protected void onPause() {
Log.i("DeltaChat", "*** LaunchActivity.onPause()");
super.onPause();
ApplicationLoader.mainInterfacePaused = true;
onPasscodePause();
@@ -1340,28 +1314,28 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (passcodeView != null) {
passcodeView.onPause();
}
ConnectionsManager.getInstance().setAppPaused(true, false);
if (PhotoViewer.getInstance().isVisible()) {
PhotoViewer.getInstance().onPause();
}
ApplicationLoader.stayAwakeForAMoment();
}
@Override
/*@Override
protected void onStart() {
Log.i("DeltaChat", "*** LaunchActivity.onStart()");
super.onStart();
//Browser.bindCustomTabsService(this);
}
@Override
protected void onStop() {
Log.i("DeltaChat", "*** LaunchActivity.onStop()");
super.onStop();
//Browser.unbindCustomTabsService(this);
}
}*/
@Override
protected void onDestroy() {
Log.i("DeltaChat", "*** LaunchActivity.onDestroy()");
PhotoViewer.getInstance().destroyPhotoViewer();
//SecretPhotoViewer.getInstance().destroyPhotoViewer();
StickerPreviewViewer.getInstance().destroy();
try {
if (visibleDialog != null) {
@@ -1389,6 +1363,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override
protected void onResume() {
Log.i("DeltaChat", "*** LaunchActivity.onResume()");
super.onResume();
ApplicationLoader.mainInterfacePaused = false;
onPasscodeResume();
@@ -1401,9 +1376,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else {
passcodeView.onResume();
}
ConnectionsManager.getInstance().setAppPaused(false, false);
ContactsController.cleanupAvatarCache();
updateCurrentConnectionState();
if (PhotoViewer.getInstance().isVisible()) {
PhotoViewer.getInstance().onResume();
}
@@ -1424,13 +1397,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
onFinish();
finish();
}
} else if (id == NotificationCenter.didUpdatedConnectionState) {
int state = ConnectionsManager.getInstance().getConnectionState();
if (currentConnectionState != state) {
FileLog.d("messenger", "switch to state " + state);
currentConnectionState = state;
updateCurrentConnectionState();
}
} else if (id == NotificationCenter.mainUserInfoChanged) {
drawerLayoutAdapter.notifyDataSetChanged();
}
@@ -1442,7 +1408,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
lockRunnable = null;
}
if (UserConfig.passcodeHash.length() != 0) {
UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime();
UserConfig.lastPauseTime = MrMailbox.getCurrentTime();
lockRunnable = new Runnable() {
@Override
public void run() {
@@ -1465,7 +1431,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else {
UserConfig.lastPauseTime = 0;
}
UserConfig.saveConfig(false);
UserConfig.saveConfig();
}
private void onPasscodeResume() {
@@ -1478,22 +1444,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
if (UserConfig.lastPauseTime != 0) {
UserConfig.lastPauseTime = 0;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
}
}
private void updateCurrentConnectionState() {
String text = null;
if (currentConnectionState == ConnectionsManager.ConnectionStateWaitingForNetwork) {
text = LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork);
} else if (currentConnectionState == ConnectionsManager.ConnectionStateConnecting) {
text = LocaleController.getString("Connecting", R.string.Connecting);
} else if (currentConnectionState == ConnectionsManager.ConnectionStateUpdating) {
text = LocaleController.getString("Updating", R.string.Updating);
}
actionBarLayout.setTitleOverlayText(text);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
try {
@@ -1528,14 +1482,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else if (lastFragment instanceof ProfileActivity && ((ProfileActivity) lastFragment).isChat() && args != null) {
outState.putBundle("args", args);
outState.putString("fragment", "chat_profile");
/* EDIT BY MR
} else if (lastFragment instanceof ChannelCreateActivity && args != null && args.getInt("step") == 0) {
outState.putBundle("args", args);
outState.putString("fragment", "channel");
} else if (lastFragment instanceof ChannelEditActivity && args != null) {
outState.putBundle("args", args);
outState.putString("fragment", "edit");
*/
}
lastFragment.saveSelfArgs(outState);
}
@@ -28,6 +28,7 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -40,10 +41,8 @@ import android.widget.RelativeLayout;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.ConnectionsManager;
import com.b44t.ui.ActionBar.ActionBarLayout;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.ActionBar.DrawerLayoutContainer;
@@ -55,7 +54,6 @@ import java.util.ArrayList;
public class ManageSpaceActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate {
private boolean finished;
private int currentConnectionState;
private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<>();
private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<>();
@@ -65,7 +63,6 @@ public class ManageSpaceActivity extends Activity implements ActionBarLayout.Act
@Override
protected void onCreate(Bundle savedInstanceState) {
ApplicationLoader.postInitApplication();
requestWindowFeature(Window.FEATURE_NO_TITLE);
setTheme(R.style.Theme_MessengerProj);
@@ -177,7 +174,6 @@ public class ManageSpaceActivity extends Activity implements ActionBarLayout.Act
actionBarLayout.setDelegate(this);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
currentConnectionState = ConnectionsManager.getInstance().getConnectionState();
handleIntent(getIntent(), false, savedInstanceState != null, false);
needLayout();
@@ -315,18 +311,6 @@ public class ManageSpaceActivity extends Activity implements ActionBarLayout.Act
fixLayout();
}
private void updateCurrentConnectionState() {
String text = null;
if (currentConnectionState == ConnectionsManager.ConnectionStateWaitingForNetwork) {
text = LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork);
} else if (currentConnectionState == ConnectionsManager.ConnectionStateConnecting) {
text = LocaleController.getString("Connecting", R.string.Connecting);
} else if (currentConnectionState == ConnectionsManager.ConnectionStateUpdating) {
text = LocaleController.getString("Updating", R.string.Updating);
}
actionBarLayout.setTitleOverlayText(text);
}
@Override
public void onBackPressed() {
if (PhotoViewer.getInstance().isVisible()) {
@@ -47,7 +47,7 @@ import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.HeaderCell;
import com.b44t.ui.Cells.EditTextCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Components.LayoutHelper;
@@ -161,12 +161,6 @@ public class NameSettingsActivity extends BaseFragment {
finishFragment();
}
private boolean isModified()
{
if( displaynameCell!=null && displaynameCell.isModified()) { return true; }
return false;
}
@Override
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
if (isOpen && displaynameCell!=null) {
@@ -238,10 +232,10 @@ public class NameSettingsActivity extends BaseFragment {
}
} else if (type == typeInfo) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if( i==rowDisplaynameInfo) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("MyNameExplain", R.string.MyNameExplain));
((TextInfoCell) view).setText(LocaleController.getString("MyNameExplain", R.string.MyNameExplain));
}
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
@@ -46,7 +46,6 @@ import com.b44t.messenger.LocaleController;
import com.b44t.messenger.NotificationsController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.ConnectionsManager;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.R;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
@@ -65,8 +64,6 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
private ListView listView;
private int notificationsServiceRow;
private int notificationsServiceConnectionRow;
private int messageSectionRow;
private int messageAlertRow;
private int messagePreviewRow;
@@ -135,8 +132,6 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
messagePreviewRow = rowCount++;
badgeNumberRow = rowCount++;
repeatRow = rowCount++;
notificationsServiceRow = rowCount++;
notificationsServiceConnectionRow = rowCount++;
resetNotificationsRow = rowCount++;
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
@@ -294,25 +289,6 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
editor.putBoolean("badgeNumber", !enabled);
editor.apply();
NotificationsController.getInstance().setBadgeEnabled(!enabled);
} else if (i == notificationsServiceConnectionRow) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
enabled = preferences.getBoolean("pushConnection", true);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("pushConnection", !enabled);
editor.apply();
if (!enabled) {
ConnectionsManager.getInstance().setPushConnectionEnabled(true);
} else {
ConnectionsManager.getInstance().setPushConnectionEnabled(false);
}
} else if (i == notificationsServiceRow) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
final SharedPreferences.Editor editor = preferences.edit();
enabled = preferences.getBoolean("pushService", true);
editor.putBoolean("pushService", !enabled);
editor.apply();
ApplicationLoader.stopPushService();
ApplicationLoader.startPushService();
} else if (i == messageLedRow || i == groupLedRow) {
if (getParentActivity() == null) {
return;
@@ -602,10 +578,6 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
checkCell.setTextAndCheck(LocaleController.getString("Vibrate", R.string.Vibrate), preferences.getBoolean("EnableInAppVibrate", true), true);
/*} else if (i == inappPreviewRow) {
checkCell.setTextAndCheck(LocaleController.getString("MessagePreview", R.string.MessagePreview), preferences.getBoolean("EnableInAppPreview", true), true);*/
} else if (i == notificationsServiceRow) {
checkCell.setTextAndValueAndCheck(LocaleController.getString("NotificationsService", R.string.NotificationsService), LocaleController.getString("NotificationsServiceInfo", R.string.NotificationsServiceInfo), preferences.getBoolean("pushService", true), true, true);
} else if (i == notificationsServiceConnectionRow) {
checkCell.setTextAndValueAndCheck(LocaleController.getString("NotificationsServiceConnection", R.string.NotificationsServiceConnection), LocaleController.getString("NotificationsServiceConnectionInfo", R.string.NotificationsServiceConnectionInfo), preferences.getBoolean("pushConnection", true), true, true);
} else if (i == badgeNumberRow) {
checkCell.setTextAndCheck(LocaleController.getString("BadgeNumber", R.string.BadgeNumber), preferences.getBoolean("badgeNumber", true), true);
} else if (i == inchatSoundRow) {
@@ -714,8 +686,8 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} else if (i == messageAlertRow || i == messagePreviewRow || i == groupAlertRow ||
/*i == groupPreviewRow ||*/ i == inappSoundRow || i == inappVibrateRow ||
/*i == inappPreviewRow ||*/
i == notificationsServiceRow || i == badgeNumberRow ||
i == inchatSoundRow || i == notificationsServiceConnectionRow) {
i == badgeNumberRow ||
i == inchatSoundRow ) {
return TYPE_CHECK_CELL;
} else if (i == messageLedRow || i == groupLedRow) {
return TYPE_COLOR_CELL;
@@ -69,7 +69,7 @@ import com.b44t.ui.ActionBar.ActionBarMenuItem;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.TextCheckCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Cells.TextSettingsCell;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.Components.NumberPicker;
@@ -331,7 +331,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
if (UserConfig.passcodeHash.length() != 0) {
UserConfig.passcodeHash = "";
UserConfig.appLocked = false;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
@@ -401,13 +401,13 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
UserConfig.autoLockIn = 60 * 60 * 5;
}
listView.invalidateViews();
UserConfig.saveConfig(false);
UserConfig.saveConfig();
}
});
showDialog(builder.create());
} else if (i == fingerprintRow) {
UserConfig.useFingerprint = !UserConfig.useFingerprint;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
((TextCheckCell) view).setChecked(UserConfig.useFingerprint);
}
}
@@ -567,7 +567,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
}
UserConfig.passcodeType = currentPasswordType;
UserConfig.saveConfig(false);
UserConfig.saveConfig();
finishFragment();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didSetPasscode);
passwordEditText.clearFocus();
@@ -687,17 +687,17 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
}
} else if (viewType == 2) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if (i == passcodeDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("ChangePasscodeInfo", R.string.ChangePasscodeInfo));
((TextInfoCell) view).setText(LocaleController.getString("ChangePasscodeInfo", R.string.ChangePasscodeInfo));
if (autoLockDetailRow != -1) {
view.setBackgroundResource(R.drawable.greydivider);
} else {
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
} else if (i == autoLockDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("AutoLockInfo", R.string.AutoLockInfo));
((TextInfoCell) view).setText(LocaleController.getString("AutoLockInfo", R.string.AutoLockInfo));
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
}
@@ -78,7 +78,6 @@ import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.ConnectionsManager;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.Utilities;
@@ -736,62 +735,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
radialProgressViews[a].setProgress(progress, true);
}
}
} else if (id == NotificationCenter.dialogPhotosLoaded) {
int guid = (Integer) args[4];
int did = (Integer) args[0];
if (avatarsDialogId == did && classGuid == guid) {
//boolean fromCache = (Boolean) args[3];
int setToImage = -1;
ArrayList<TLRPC.Photo> photos = (ArrayList<TLRPC.Photo>) args[5];
if (photos.isEmpty()) {
return;
}
imagesArrLocations.clear();
imagesArrLocationsSizes.clear();
avatarsArr.clear();
for (int a = 0; a < photos.size(); a++) {
TLRPC.Photo photo = photos.get(a);
if (photo == null || photo instanceof TLRPC.TL_photoEmpty || photo.sizes == null) {
continue;
}
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 640);
if (sizeFull != null) {
if (setToImage == -1 && currentFileLocation != null) {
for (int b = 0; b < photo.sizes.size(); b++) {
TLRPC.PhotoSize size = photo.sizes.get(b);
if (size.location.local_id == currentFileLocation.local_id && size.location.volume_id == currentFileLocation.volume_id) {
setToImage = imagesArrLocations.size();
break;
}
}
}
imagesArrLocations.add(sizeFull.location);
imagesArrLocationsSizes.add(sizeFull.size);
avatarsArr.add(photo);
}
}
/*
if (!avatarsArr.isEmpty()) {
menuItem.showSubItem(gallery_menu_delete);
} else {
menuItem.hideSubItem(gallery_menu_delete);
}
*/
needSearchImageInArr = false;
currentIndex = -1;
if (setToImage != -1) {
setImageIndex(setToImage, true);
} else {
avatarsArr.add(0, new TLRPC.TL_photoEmpty());
imagesArrLocations.add(0, currentFileLocation);
imagesArrLocationsSizes.add(0, 0);
setImageIndex(0, true);
}
//if (fromCache) {
// MessagesController.getInstance().loadDialogPhotos(avatarsDialogId, 0, 80, 0, false, classGuid);
//}
}
} else if (id == NotificationCenter.mediaCountDidLoaded) {
long uid = (Long) args[0];
if (uid == currentDialogId || uid == mergeDialogId) {
@@ -2383,7 +2326,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
private void onPhotoShow(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList<MessageObject> messages, final ArrayList<Object> photos, int index, final PlaceProviderObject object) {
classGuid = ConnectionsManager.getInstance().generateClassGuid();
classGuid = ApplicationLoader.generateClassGuid();
currentMessageObject = null;
currentFileLocation = null;
currentPathObject = null;
@@ -2633,13 +2576,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else if (!imagesArrLocations.isEmpty()) {
nameTextView.setText("");
dateTextView.setText("");
/*
if (avatarsDialogId == UserConfig.getClientUserId() && !avatarsArr.isEmpty()) {
menuItem.showSubItem(gallery_menu_delete);
} else {
menuItem.hideSubItem(gallery_menu_delete);
}
*/
TLRPC.FileLocation old = currentFileLocation;
if (index < 0 || index >= imagesArrLocations.size()) {
closePhoto(false, false);
@@ -2659,11 +2595,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return;
}
boolean fromCamera = false;
CharSequence caption = null;
if (object instanceof MediaController.PhotoEntry) {
currentPathObject = ((MediaController.PhotoEntry) object).path;
fromCamera = ((MediaController.PhotoEntry) object).bucketId == 0 && ((MediaController.PhotoEntry) object).dateTaken == 0 && imagesArrLocals.size() == 1;
caption = ((MediaController.PhotoEntry) object).caption;
} else if (object instanceof MediaController.SearchImage) {
MediaController.SearchImage searchImage = (MediaController.SearchImage) object;
if (searchImage.document != null) {
@@ -2671,7 +2605,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else {
currentPathObject = searchImage.imageUrl;
}
caption = searchImage.caption;
}
if (fromCamera) {
actionBar.setTitle(LocaleController.getString("AttachPhoto", R.string.AttachPhoto));
@@ -3050,7 +2983,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileLoadProgressChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogPhotosLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
placeProvider = provider;
@@ -3196,7 +3128,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.mediaCountDidLoaded, NotificationCenter.mediaDidLoaded, NotificationCenter.dialogPhotosLoaded});
NotificationCenter.getInstance().setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.mediaCountDidLoaded, NotificationCenter.mediaDidLoaded});
NotificationCenter.getInstance().setAnimationInProgress(true);
animatorSet.start();
}
@@ -3272,7 +3204,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileLoadProgressChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.dialogPhotosLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
//ConnectionsManager.getInstance().cancelRequestsForGuid(classGuid);
@@ -44,7 +44,7 @@ import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.HeaderCell;
import com.b44t.ui.Cells.TextCheckCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Cells.TextSettingsCell;
import com.b44t.ui.Components.LayoutHelper;
@@ -301,10 +301,10 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
}
} else if (type == TYPE_TEXT_INFO) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if (i == secretDetailRow) {
((TextInfoPrivacyCell) view).setText("");
((TextInfoCell) view).setText("");
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
} else if (type == TYPE_HEADER) {
@@ -65,7 +65,6 @@ import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.MessageObject;
@@ -190,7 +189,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (user_id != 0) {
dialog_id = arguments.getLong("dialog_id", 0);
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
TLRPC.User user = MrMailbox.getUser(user_id);
if (user == null) {
return false;
}
@@ -205,7 +204,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big) {
if (chat_id != 0) {
MessagesController.getInstance().changeChatAvatar(chat_id, file);
//MessagesController.getInstance().changeChatAvatar(chat_id, file);
}
}
};
@@ -454,7 +453,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MrMailbox.addContactToChat(chat_id, added_user_id);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_CHAT_MEMBERS);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MrMailbox.UPDATE_MASK_CHAT_MEMBERS);
}
});
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
@@ -501,7 +500,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MrMailbox.removeContactFromChat(chat_id, curr_user_id);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_CHAT_MEMBERS);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MrMailbox.UPDATE_MASK_CHAT_MEMBERS);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
@@ -537,7 +536,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void onClick(View v) {
if (user_id != 0) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
TLRPC.User user = MrMailbox.getUser(user_id);
if (user.photo != null && user.photo.photo_big != null) {
PhotoViewer.getInstance().setParentActivity(getParentActivity());
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, ProfileActivity.this);
@@ -821,7 +820,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer) args[0];
if (user_id != 0) {
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
if ((mask & MrMailbox.UPDATE_MASK_AVATAR) != 0 || (mask & MrMailbox.UPDATE_MASK_NAME) != 0 || (mask & MrMailbox.UPDATE_MASK_STATUS) != 0) {
updateProfileData();
}
} else if (chat_id != 0) {
@@ -830,13 +829,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
updateProfileData();
listAdapter.notifyDataSetChanged();
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
if ((mask & MrMailbox.UPDATE_MASK_AVATAR) != 0 || (mask & MrMailbox.UPDATE_MASK_NAME) != 0 || (mask & MrMailbox.UPDATE_MASK_STATUS) != 0) {
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
((UserCell) child).update();
}
}
}
@@ -1039,7 +1038,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
TLRPC.FileLocation photoBig = null;
if (user_id != 0) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
TLRPC.User user = MrMailbox.getUser(user_id);
if (user != null && user.photo != null && user.photo.photo_big != null) {
photoBig = user.photo.photo_big;
}
@@ -1184,7 +1183,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
int leftIcon = 0;//currentEncryptedChat != null ? R.drawable.ic_lock_header : 0;
int rightIcon = 0;
if (a == 0) {
rightIcon = MessagesController.getInstance().isDialogMuted(dialog_id != 0 ? dialog_id : (long) user_id) ? R.drawable.mute_fixed : 0;
rightIcon = MrMailbox.isDialogMuted(dialog_id != 0 ? dialog_id : (long) user_id) ? R.drawable.mute_fixed : 0;
}
nameTextView[a].setLeftDrawable(leftIcon);
nameTextView[a].setRightDrawable(rightIcon);
@@ -48,13 +48,11 @@ import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.MrChat;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.NotificationsController;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.FileLog;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.ConnectionsManager;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.HeaderCell;
@@ -219,7 +217,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
if (listView != null) {
listView.invalidateViews();
}
NotificationsController.updateServerNotificationsSettings(dialog_id);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.notificationsSettingsUpdated);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
@@ -576,7 +574,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
} else if (value == 2) {
textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), LocaleController.getString("Disabled", R.string.Disabled), true);
} else if (value == 3) {
int delta = preferences.getInt("notifyuntil_" + dialog_id, 0) - ConnectionsManager.getInstance().getCurrentTime();
int delta = preferences.getInt("notifyuntil_" + dialog_id, 0) - MrMailbox.getCurrentTime();
String val;
if (delta <= 0) {
val = LocaleController.getString("Enabled", R.string.Enabled);
@@ -39,6 +39,7 @@ import android.widget.ListView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.BuildVars;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.R;
@@ -176,12 +177,14 @@ public class SettingsActivity extends BaseFragment {
}
}
private String getAbi() // ABI = Application Binary Interface
private String getAndroidInfo()
{
String abi = "ErrAbi";
int versionCode = 0;
try {
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
String abi = "ErrAbi";
switch (pInfo.versionCode % 10) {
versionCode = pInfo.versionCode;
switch (versionCode % 10) {
case 0:
abi = "arm";
break;
@@ -195,16 +198,14 @@ public class SettingsActivity extends BaseFragment {
abi = "universal";
break;
}
return abi;
} catch (Exception e) {
return "ErrAbi";
}
}
} catch (Exception e) {}
private String getAndroidInfo()
{
return "Build.VERSION.SDK_INT=" + Build.VERSION.SDK_INT + "\n"
+ "ABI=" + getAbi();
return "SDK_INT=" + Build.VERSION.SDK_INT
+ "\nMANUFACTURER=" + Build.MANUFACTURER
+ "\nMODEL=" + Build.MODEL
+ "\nDEBUG_VERSION=" + BuildVars.DEBUG_VERSION
+ "\nABI=" + abi // ABI = Application Binary Interface
+ "\nversionCode=" + versionCode;
}
private class ListAdapter extends BaseFragmentAdapter {
@@ -273,9 +274,6 @@ public class SettingsActivity extends BaseFragment {
else if (i == advRow) {
textCell.setText(ApplicationLoader.applicationContext.getString(R.string.AdvancedSettings), false);
}
else if (i == aboutRow) {
textCell.setText(ApplicationLoader.applicationContext.getString(R.string.AboutThisProgram), false);
}
}
else if (type == ROWTYPE_HEADER) {
if (view == null) {
@@ -316,6 +314,9 @@ public class SettingsActivity extends BaseFragment {
}
textCell.setTextAndValue(LocaleController.getString("MyName", R.string.MyName), subtitle, true);
}
else if (i == aboutRow) {
textCell.setTextAndValue(ApplicationLoader.applicationContext.getString(R.string.AboutThisProgram), "v" + getVersion(), false);
}
}
return view;
}
@@ -325,7 +326,7 @@ public class SettingsActivity extends BaseFragment {
if (i == accountShadowRow || i == settingsShadowRow || i == aboutShadowRow ) {
return ROWTYPE_SHADOW;
}
else if ( i == accountSettingsRow || i == usernameRow) {
else if ( i == accountSettingsRow || i == usernameRow || i==aboutRow ) {
return ROWTYPE_DETAIL_SETTINGS;
}
else if (i == settingsHeaderRow || i == aboutHeaderRow || i == accountHeaderRow) {
@@ -39,7 +39,6 @@ import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MessagesController;
import com.b44t.messenger.R;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.ShadowSectionCell;
@@ -85,7 +84,7 @@ public class SettingsAdvActivity extends BaseFragment {
sendByEnterRow = rowCount++;
raiseToSpeakRow = rowCount++; // outgoing message
enableAnimationsRow = -1;//rowCount++; -- for now, we disable this option, maybe we can add it later to a "view" settings, however, in general, this should be more a system-option
cacheRow = -1; // for now, the page is still reachable by the "storage settings" in the "android App Settings"
cacheRow = -1;// for now, the - non-functional - page is reachable by the "storage settings" in the "android App Settings" only
languageRow = rowCount++;
finalShadowRow = rowCount++;
@@ -148,7 +147,7 @@ public class SettingsAdvActivity extends BaseFragment {
numberPicker.setMaxValue(MAX_VAL);
numberPicker.setDisplayedValues(displayValues);
numberPicker.setWrapSelectorWheel(false);
numberPicker.setValue(MessagesController.getInstance().fontSize);
numberPicker.setValue(ApplicationLoader.fontSize);
builder.setView(numberPicker);
builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() {
@Override
@@ -156,7 +155,7 @@ public class SettingsAdvActivity extends BaseFragment {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("msg_font_size", numberPicker.getValue());
MessagesController.getInstance().fontSize = numberPicker.getValue();
ApplicationLoader.fontSize = numberPicker.getValue();
editor.apply();
if (listView != null) {
listView.invalidateViews();
@@ -264,7 +263,7 @@ public class SettingsAdvActivity extends BaseFragment {
} else if (i == languageRow) {
textCell.setTextAndValue(LocaleController.getString("Language", R.string.Language), LocaleController.getCurrentLanguageName(), false);
} else if (i == cacheRow) {
textCell.setText(LocaleController.getString("CacheSettings", R.string.CacheSettings), false);
textCell.setText(LocaleController.getString("CacheSettings", R.string.CacheSettings), true);
}
} else if (type == ROWTYPE_CHECK) {
if (view == null) {
@@ -40,6 +40,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.b44t.messenger.VideoEditedInfo;
import com.coremedia.iso.IsoFile;
import com.coremedia.iso.boxes.Box;
import com.coremedia.iso.boxes.MediaBox;
@@ -97,7 +98,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
private int originalHeight = 0;
private int resultWidth = 0;
private int resultHeight = 0;
private int bitrate = 0;
private int resultBitrate = 0;
private int originalBitrate = 0;
private float videoDuration = 0;
private long startTime = 0;
@@ -109,7 +110,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
private long originalSize = 0;
public interface VideoEditorActivityDelegate {
void didFinishEditVideo(String videoPath, long startTime, long endTime, int resultWidth, int resultHeight, int rotationValue, int originalWidth, int originalHeight, int bitrate, long estimatedSize, long estimatedDuration);
void didFinishEditVideo(VideoEditedInfo vei, long estimatedSize, long estimatedDuration);
}
private Runnable progressRunnable = new Runnable() {
@@ -259,7 +260,18 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
/*if (compressVideo.getVisibility() == View.GONE || compressVideo.getVisibility() == View.VISIBLE && !compressVideo.isChecked()) {
delegate.didFinishEditVideo(videoPath, startTime, endTime, originalWidth, originalHeight, rotationValue, originalWidth, originalHeight, originalBitrate, estimatedSize, esimatedDuration);
} else*/ {
delegate.didFinishEditVideo(videoPath, startTime, endTime, resultWidth, resultHeight, rotationValue, originalWidth, originalHeight, bitrate, estimatedSize, esimatedDuration);
VideoEditedInfo vei = new VideoEditedInfo();
vei.originalPath = videoPath;
vei.startTime = startTime;
vei.endTime = endTime;
vei.rotationValue = rotationValue;
vei.originalWidth = originalWidth;
vei.originalHeight = originalHeight;
vei.originalBitrate = originalBitrate;
vei.resultWidth = resultWidth;
vei.resultHeight = resultHeight;
vei.resultBitrate = resultBitrate;
delegate.didFinishEditVideo(vei, estimatedSize, esimatedDuration);
}
}
finishFragment();
@@ -738,10 +750,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
TrackHeaderBox headerBox = trackBox.getTrackHeaderBox();
if (headerBox.getWidth() != 0 && headerBox.getHeight() != 0) {
trackHeaderBox = headerBox;
originalBitrate = bitrate = (int) (trackBitrate / 100000 * 100000);
if (bitrate > 900000) {
bitrate = 900000;
}
originalBitrate = resultBitrate = (int) (trackBitrate / 100000 * 100000);
videoFramesSize += sampleSizes;
} else {
audioFramesSize += sampleSizes;
@@ -766,12 +775,17 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
float scale = resultWidth > resultHeight ? 640.0f / resultWidth : 640.0f / resultHeight;
resultWidth *= scale;
resultHeight *= scale;
if (bitrate != 0) {
bitrate *= Math.max(0.5f, scale);
videoFramesSize = (long) (bitrate / 8 * videoDuration);
if (resultBitrate != 0) {
resultBitrate *= Math.max(0.5f, scale);
}
}
if (resultBitrate > 500000) {
resultBitrate = 500000; // ~ 3.7 MB/minute, plus Audio
}
videoFramesSize = (long) (resultBitrate / 8 * videoDuration);
if (!isAvc && (resultWidth == originalWidth || resultHeight == originalHeight)) {
return false;
}
@@ -108,7 +108,6 @@
<string name="SendByEnter">Mit Taste „Enter“ senden</string>
<string name="Language">Sprache</string>
<string name="Help">Hilfe</string>
<string name="DeleteLocalization">Lokalisierung löschen?</string>
<string name="Enabled">An</string>
<string name="Disabled">Aus</string>
<string name="NotificationsService">Keep-Alive-Dienst</string>
@@ -368,11 +367,11 @@
<string name="MyEmailAddress">Meine E-Mail-Adresse</string>
<string name="Password">Passwort</string>
<string name="SmtpPassword">SMTP-Passwort</string>
<string name="FromAbove">wie oben</string>
<string name="FromAbove">Wie oben</string>
<string name="SmtpLoginname">SMTP-Loginname</string>
<string name="SmtpPort">SMTP-Port</string>
<string name="SmtpServer">SMTP-Server</string>
<string name="Automatic">automatisch</string>
<string name="Automatic">Automatisch</string>
<string name="ImapLoginname">IMAP-Loginname</string>
<string name="ImapPort">IMAP-Port</string>
<string name="ImapServer">IMAP-Server</string>
@@ -380,7 +379,7 @@
<string name="OutboxHeadline">Postausgang</string>
<string name="InboxHeadline">Posteingang</string>
<string name="MyAccountExplain">Für bekannte E-Mail-Anbieter werden die weiteren Einstellungen automatisch ermittelt.</string>
<string name="MyAccountExplain2">Manchmal muss die IMAP-/SMTP-Funktion noch in der E-Mail-Weboberfläche eingeschaltet werden.\n\nBei Problemen kann der E-Mail-Anbieter oder ein Bekannter weiterhelfen.</string>
<string name="MyAccountExplain2">Manchmal muss die <![CDATA[<b>]]>IMAP-Funktion<![CDATA[</b>]]> noch in der E-Mail-Weboberfläche <![CDATA[<b>]]>eingeschaltet<![CDATA[</b>]]> werden.\n\nBei Problemen kann der E-Mail-Anbieter oder ein Bekannter weiterhelfen.</string>
<string name="AccountNotConfigured">Konto nicht konfiguriert</string>
<string name="AboutThisProgram">Über Delta Chat</string>
<string name="NotSet">Nicht gesetzt</string>
@@ -429,4 +428,7 @@
<string name="SelectContact">Kontakt auswählen</string>
<string name="DoneHint">Fertig.</string>
<string name="FileNotFound">Datei %1$s nicht gefunden.</string>
<string name="Error">Fehler: %1$s</string>
<string name="NoNetwork">Kein Netz.</string>
<string name="Audio">Audio</string>
</resources>
@@ -105,7 +105,6 @@
<string name="SendByEnter">Enviar con “Intro”</string>
<string name="Language">Idioma</string>
<string name="Help">Preguntas frecuentes</string>
<string name="DeleteLocalization">¿Eliminar traducción?</string>
<string name="Enabled">Activadas</string>
<string name="Disabled">Desactivadas</string>
<string name="NotificationsService">Servicio keep-alive</string>
@@ -213,7 +212,7 @@
<string name="PrivacyTitle">Privacidad</string>
<string name="SecurityTitle">Seguridad</string>
<!--edit video view-->
<string name="SendVideo">Editar vídeo</string>
<string name="SendVideo">Enviar vídeo</string>
<string name="OriginalVideo">Vídeo original</string>
<string name="EditedVideo">Vídeo editado</string>
<string name="CompressVideo">Comprimir Vídeo</string>
@@ -103,7 +103,6 @@
<string name="SendByEnter">Envoyer avec "Entrée"</string>
<string name="Language">Langue</string>
<string name="Help">Aide</string>
<string name="DeleteLocalization">Supprimer la localisation ?</string>
<string name="Enabled">Activé</string>
<string name="Disabled">Désactivé</string>
<string name="NotificationsService">Service de continuité</string>
@@ -211,7 +210,7 @@
<string name="PrivacyTitle">Vie privée</string>
<string name="SecurityTitle">Securité</string>
<!--edit video view-->
<string name="SendVideo">Modifier la vidéo</string>
<string name="SendVideo">Envoyer la vidéo</string>
<string name="OriginalVideo">Vidéo originale</string>
<string name="EditedVideo">Vidéos modifiées</string>
<string name="CompressVideo">Compresser la vidéo</string>
@@ -345,10 +344,10 @@
<string name="MyEmailAddress">Mon adresse e-mail</string>
<string name="Password">Mot de passe</string>
<string name="SmtpPassword">Mot de passe SMTP</string>
<string name="FromAbove">de ci-dessus</string>
<string name="FromAbove">De ci-dessus</string>
<string name="SmtpLoginname">Identifiant SMTP</string>
<string name="SmtpPort">Port SMTP</string>
<string name="Automatic">automatique</string>
<string name="Automatic">Automatique</string>
<string name="ImapServer">Serveur IMAP</string>
<string name="ImapLoginname">Identifiant IMAP</string>
<string name="SmtpServer">Serveur SMTP</string>
@@ -0,0 +1,434 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="AppName">Delta Chat</string>
<string name="LanguageName">Magyar</string>
<string name="LanguageNameInEnglish" tools:keep="@string/LanguageNameInEnglish">Hungarian</string>
<string name="LanguageCode" tools:keep="@string/LanguageCode">hu</string>
<!--chats view-->
<string name="Settings">Beállítások</string>
<string name="NewGroup">Új csoport</string>
<string name="Yesterday">tegnap</string>
<string name="NoResult">Nincs találat.</string>
<string name="NoChats">Még nincs beszélgetés.</string>
<string name="WaitingForNetwork">Várakozás a hálózatra…</string>
<string name="Connecting">Kapcsolódás…</string>
<string name="Updating">Frissítés…</string>
<string name="DeleteChat">Beszélgetés törlése</string>
<string name="SelectChat">Beszélgetés választása…</string>
<string name="Search">Keresés</string>
<string name="MuteNotifications">Értesítések némítása</string>
<string name="MuteFor1Hour">Némítás 1 órára</string>
<string name="MuteFor8Hours">Némítás 8 órára</string>
<string name="MuteFor2Days">Némítás 2 napra</string>
<string name="UnmuteNotifications">Némítás kikapcsolása</string>
<string name="Draft">Piszkozat</string>
<!--audio view-->
<string name="NoAudio">Adj fájlokat a zenei könyvtáradhoz, hogy azokat itt láthasd.</string>
<string name="AttachMusic">Zene</string>
<!--documents view-->
<string name="SelectFile">Fájl választása</string>
<string name="FreeOfTotal">%1$s / %2$s szabad</string>
<string name="ErrorHint">Ismeretlen hiba</string>
<string name="AccessError">Hozzáférési hiba</string>
<string name="NoFiles">Még nincs fájl…</string>
<string name="NotMounted">Nincs csatolt tárhely</string>
<string name="UsbActive">USB átvitel aktív</string>
<string name="InternalStorage">Belső tárhely</string>
<string name="ExternalStorage">Külső tárhely</string>
<string name="SystemRoot">Rendszer gyökér</string>
<string name="SdCard">SD kártya</string>
<string name="Folder">Mappa</string>
<string name="GalleryInfo">Fájl küldése tömörítés nélkül</string>
<!--chat view-->
<string name="ChatGallery">Galéria</string>
<string name="ChatCamera">Kamera</string>
<string name="NoMessages">Nincs üzenet.</string>
<string name="ForwardedMessage">Továbbított üzenet</string>
<string name="From">Feladó</string>
<string name="NoRecent">Nincs legutóbbi</string>
<string name="TypeMessage">Üzenet</string>
<string name="SlideToCancel">VISSZAVONÁS CSÚSZTATÁSSAL</string>
<string name="SaveToDownloads">Mentés a letöltésekhez</string>
<string name="DeleteGif">GIF törlése?</string>
<string name="SaveToMusic">Mentés a zenékhez</string>
<string name="Share">Megosztás</string>
<string name="SendItems">%1$s küldése</string>
<string name="ClearRecentEmoji">Legutóbbi emoji törlése?</string>
<string name="AddShortcut">Widget hozzáadása a kezdőképernyőhöz</string>
<string name="ShortcutAdded">Widget hozzáadva a kezdőképernyőhöz</string>
<!--notification-->
<string name="Reply">Válasz</string>
<string name="ReplyToGroup">Válasz %1$s csoportnak</string>
<string name="ReplyToContact">Válasz %1$s partnernek</string>
<!--contacts view-->
<string name="NoContacts">Még nincs partner.</string>
<string name="TodayAt">ekkor:</string>
<string name="YesterdayAt">tegnap ekkor:</string>
<!--group create view-->
<string name="SendMessageTo">Üzenet küldése…</string>
<string name="EnterGroupNamePlaceholder">Csoport neve</string>
<!--group info view-->
<string name="SharedMedia">Megosztott média</string>
<string name="AddMember">Tag hozzáadása</string>
<string name="Notifications">Értesítések</string>
<string name="RemoveMember">Tag eltávolítása</string>
<!--contact info view-->
<string name="NewContactTitle">Új partner</string>
<string name="BlockContact">Partner letiltása</string>
<string name="DeleteContact">Partner törlése</string>
<string name="Info">Infó</string>
<!--stickers view-->
<string name="Stickers">Matricák</string>
<string name="AddStickers">Matrica hozzáadása</string>
<string name="AddToStickers">Hozzáadás a matricákhoz</string>
<string name="StickersRemove">Törlés</string>
<string name="NoStickers">Még nincs matrica</string>
<!--settings view-->
<string name="TextSize">Üzenetek betűmérete</string>
<string name="EnableAnimations">Áttűnés animációja</string>
<string name="UnblockContact">Tiltás feloldása</string>
<string name="NoBlocked">Nincs letiltott partner</string>
<string name="NormalMessages">Normál üzenetek</string>
<string name="Alert">Figyelmeztetés</string>
<string name="MessagePreview">Üzenet előnézet</string>
<string name="GroupMessages">Csoportüzenetek</string>
<string name="Sound">Hang</string>
<string name="InAppNotifications">Alkalmazáson belüli értesítések</string>
<string name="Vibrate">Rezgés</string>
<string name="Reset">Visszaállítás</string>
<string name="ResetAllNotifications">Minden értesítés visszaállítása</string>
<string name="NotificationsAndSounds">Értesítések és hangok</string>
<string name="BlockedContacts">Letiltott partnerek</string>
<string name="Default">Alapértelmezett</string>
<string name="OnlyIfSilent">Csak ha csendes</string>
<string name="ChatBackground">Beszélgetés háttere</string>
<string name="SendByEnter">Küldés "enterrel"</string>
<string name="Language">Nyelv</string>
<string name="Help">Súgó</string>
<string name="DeleteLocalization">Fordítás törlése?</string>
<string name="Enabled">Be</string>
<string name="Disabled">Ki</string>
<string name="NotificationsService">Ébrentartási szolgáltatás</string>
<string name="NotificationsServiceInfo">Az alkalmazás újraindítása ha a rendszer vagy a felhasználó leállította. Így az alkalmazás mindig meg tudja jeleníteni az értesítéseket.</string>
<string name="NotificationsServiceConnection">Háttérkapcsolat</string>
<string name="NotificationsServiceConnectionInfo">Tartson fenn nem jelentős háttérkapcsolatot az értesítések fogadásához. Az értesítések megbízható működéséhez érdemes bekapcsolni.</string>
<string name="LedColor">LED színe</string>
<string name="BadgeNumber">Ha lehetséges, számok megjelenítése az ikonon</string>
<string name="Short">Rövid</string>
<string name="Long">Hosszú</string>
<string name="SystemDefault">Rendszer alapértelmezett</string>
<string name="RaiseToSpeak">Felemelés a beszédhez</string>
<string name="EditName">Név módosítása</string>
<string name="NotificationsPriority">Nézet</string>
<string name="NotificationsPriorityDefault">Normál prioritás</string>
<string name="NotificationsPriorityHigh">Magas prioritás</string>
<string name="NotificationsPriorityMax">Legmagasabb prioritás</string>
<string name="RepeatNotifications">Értesítések ismétlése</string>
<string name="NotificationsOther">Egyéb</string>
<string name="InChatSound">Hangok beszélgetésen belül</string>
<string name="SoundDefault">Alapértelmezett</string>
<string name="VibrationDefault">Alapértelmezett</string>
<string name="SmartNotifications">Értesítések korlátja</string>
<string name="SmartNotificationsInfo">%2$s idő alatt legfeljebb %1$s hangjelzés</string>
<string name="SmartNotificationsSoundAtMost">Hangjelzés legfeljebb</string>
<string name="SmartNotificationsTimes">alkalommal</string>
<string name="SmartNotificationsWithin"> </string>
<string name="SmartNotificationsMinutes">percen belül</string>
<string name="DirectShare">Közvetlen megosztás</string>
<string name="DirectShareInfo">A megosztás menüben a legutóbbi beszélgetések mutatása</string>
<!--cache view-->
<string name="CacheSettings">Tárhely</string>
<string name="LocalDatabase">Helyi adatbázis</string>
<string name="LocalDatabaseClear">Törlöd a gyorsítótárazott szövegüzeneteket?</string>
<string name="LocalDatabaseInfo">A helyi adatbázis tisztítása törli a gyorsítótárazott üzenetek szövegét és tömöríti az adatbázist, hogy belső tárhelyet takarítson meg. Az alkalmazás működéséhez szükség van némi adatra, ezért nem lesz teljesen üres az adatbázis.\n\nEz a művelet pár percig is eltarthat.</string>
<string name="ClearMediaCache">Gyorsítótár törlése</string>
<string name="CacheClear">Törlés</string>
<string name="LocalCache">Egyéb fájlok</string>
<string name="CacheEmpty">Üres</string>
<string name="KeepMedia">Média megtartása</string>
<string name="KeepMediaInfo">Azok a fényképek, videók és a felhős beszélgetések, amelyeket <![CDATA[<b>nem nyitottál meg</b>]]> ez idő alatt, helymegtakarítás végett törlődnek a készülékről.</string>
<string name="KeepMediaForever">Örökké</string>
<!--passcode view-->
<string name="Passcode">Jelszavas védelem</string>
<string name="ChangePasscode">Jelszóváltoztatás</string>
<string name="ChangePasscodeInfo">Ha jelszót állítasz be, egy lakatikon jelenik meg a beszélgetések oldalán. Rákkatintva lehet lezárni és megnyitni az alkalmazást.\n\nFigyelem: ha elfelejted a jelszavadat, törölnöd és újra telepítened kell az alkalmazást.</string>
<string name="PasscodePIN">PIN</string>
<string name="PasscodePassword">Jelszó</string>
<string name="EnterCurrentPasscode">Add meg a jelenlegi jelszavad</string>
<string name="EnterNewFirstPasscode">Adj meg egy jelszót</string>
<string name="EnterNewPasscode">Adj meg egy új jelszót</string>
<string name="EnterYourPasscode">Add meg a jelszavad</string>
<string name="ReEnterYourPasscode">Add meg ismét az új jelszavad</string>
<string name="PasscodeDoNotMatch">A jelszavak nem egyeznek</string>
<string name="AutoLock">Automatikus lezárás</string>
<string name="AutoLockInfo">Megadott időnyi távollét után jelszót kér.</string>
<string name="AutoLockInTime">%1$s után</string>
<string name="UnlockFingerprint">Feloldás ujjlenyomattal</string>
<string name="FingerprintInfo">A feloldáshoz add meg az ujjlenyomatod!</string>
<string name="FingerprintNotRecognized">Nem sikerült olvasni az ujjlenyomatot. Próbáld újra!</string>
<!--photo gallery view-->
<string name="SaveToGallery">Mentés a galériába</string>
<string name="Of">%1$d / %2$d</string>
<string name="Gallery">Galéria</string>
<string name="AllPhotos">Minden fénykép</string>
<string name="AllVideo">Minden videó</string>
<string name="NoPhotos">Még nincs fénykép</string>
<string name="NoVideo">Még nincs videó</string>
<string name="CropImage">Kép levágása</string>
<string name="EditImage">Kép szerkesztése</string>
<string name="Enhance">Javítás</string>
<string name="Highlights">Csúcsfény</string>
<string name="Contrast">Kontraszt</string>
<string name="Exposure">Fényerő</string>
<string name="Warmth">Melegség</string>
<string name="Saturation">Telítettség</string>
<string name="Vignette">Vignette</string>
<string name="Shadows">Árnyék</string>
<string name="Grain">Zaj</string>
<string name="Sharpen">Élesítés</string>
<string name="Fade">Fakítás</string>
<string name="Tint">Színezés</string>
<string name="TintShadows">ÁRNYÉK</string>
<string name="TintHighlights">CSÚCSFÉNY</string>
<string name="Curves">Görbék</string>
<string name="CurvesAll">MIND</string>
<string name="CurvesRed">PIROS</string>
<string name="CurvesGreen">ZÖLD</string>
<string name="CurvesBlue">KÉK</string>
<string name="Blur">Elmosás</string>
<string name="BlurOff">Ki</string>
<string name="BlurLinear">Lineáris</string>
<string name="BlurRadial">Sugaras</string>
<string name="DiscardChanges">Elveted a módosításokat?</string>
<string name="ClearSearch">Törlöd a keresési előzményeket?</string>
<string name="ClearButton">Törlés</string>
<string name="PickerPhotos">Fényképek</string>
<string name="PickerVideo">Videó</string>
<string name="AddCaption">Felirat hozzáadása …</string>
<string name="PhotoCaption">Felirat fényképhez</string>
<string name="VideoCaption">Felirat videóhoz</string>
<string name="Caption">Felirat</string>
<!--privacy settings-->
<string name="PrivacySettings">Adatvédelem és biztonság</string>
<string name="PrivacyTitle" tools:keep="@string/PrivacyTitle">Adatvédelem</string>
<string name="SecurityTitle">Biztonság</string>
<!--edit video view-->
<string name="SendVideo">Videó küldése</string>
<string name="OriginalVideo">Eredeti videó</string>
<string name="EditedVideo">Szerkesztett videó</string>
<string name="CompressVideo">Videó tömörítése</string>
<!--button titles-->
<string name="Next">Következő</string>
<string name="Back">Előző</string>
<string name="Done">Kész</string>
<string name="Open">Megnyitás</string>
<string name="Save">Mentés</string>
<string name="Cancel">Mégse</string>
<string name="Close">Bezárás</string>
<string name="Add">Hozzáadás</string>
<string name="Edit">Szerkesztés</string>
<string name="Send">Küldés</string>
<string name="CopyToClipboard">Vágólapra másolás</string>
<string name="Delete">Törlés</string>
<string name="Forward">Továbbítás</string>
<string name="Retry">Újra próbál</string>
<string name="FromCamera">Kamerával</string>
<string name="FromGalley">Galériából</string>
<string name="Set">Beállítás</string>
<string name="OK">OK</string>
<string name="Crop">VÁGÁS</string>
<!--messages-->
<string name="AttachPhoto">Fénykép</string>
<string name="AttachVideo">Videó</string>
<string name="AttachGif">GIF</string>
<string name="AttachContact">Névjegy</string>
<string name="AttachDocument">Fájl</string>
<string name="AttachSticker">Matrica</string>
<string name="AttachVoiceMessage">Hangüzenet</string>
<string name="FromSelf">Én</string>
<!--Alert messages-->
<string name="NoHandleAppInstalled">\'%1$s\' fájltípus kezeléséhez nincs alkalmazásod, telepíts egyet!</string>
<string name="ContactAlreadyInGroup">Ez a partner már a csoportban van.</string>
<string name="ForwardMessagesTo">Továbbítod a kijelölt üzeneteket <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> címére?</string>
<string name="SendMessagesTo">Üzenetet küldesz <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> címére?</string>
<string name="AreYouSureDeleteThisChat">Törlöd a beszélgetést? Ezután nem fog megjelenni a beszélgetések listáján, de az üzenetek megmaradnak a szerveren.</string>
<string name="AreYouSureBlockContact">Biztos le szeretnéd tiltani ezt a partnert?</string>
<string name="AreYouSureDeleteContact">Biztos törölni szeretnéd ezt a partnert?</string>
<!--permissions-->
<string name="PermissionContacts">A Delta Chatnek hozzáférésre van szüksége a névjegyeidhez, hogy összekössön a barátaiddal a készülékeiden.</string>
<string name="PermissionStorage">A Delta Chatnek hozzáférésre van szüksége a tárhelyedhez, hogy küldhess és fogadhass fényképeket, videókat, zenét és más médiafájlokat.</string>
<string name="PermissionNoAudio">A Delta Chatnek hozzáférésre van szüksége a mikrofonodhoz, hogy küldhess hangüzeneteket.</string>
<string name="PermissionOpenSettings">Beállítások</string>
<!--Intro view-->
<string name="Intro1Headline">Delta Chat</string>
<string name="Intro1Message">A világ <![CDATA[<b>legkiterjedtebb</b>]]> üzenetküldője.<![CDATA[<br/><b>Szabad</b>]]> és <![CDATA[<b>ingyenes</b>]]>.</string>
<string name="Intro2Headline">Független</string>
<string name="Intro2Message"><![CDATA[<b>Nem függ</b>]]> más számítógépektől vagy szolgáltatásoktól. Az alkalmazás csak az e-mail szerveredet használja.</string>
<string name="Intro3Headline">Gyors</string>
<string name="Intro3Message"><![CDATA[<b>Azonnali üzenetek</b>]]> másodpercek alatt.<![CDATA[<br/>]]>Villámgyors kezelőfelület.</string>
<string name="Intro4Headline">Erőteljes</string>
<string name="Intro4Message"><![CDATA[<b>Korlátlan</b>]]> beszélgetés, kép, videó, hangüzenet és még sok más. Együttműködik más kliensekkel is.</string>
<string name="Intro5Headline">Szabad</string>
<string name="Intro5Message"><![CDATA[<b>Delta Chat</b>]]> ist free forever.<![CDATA[<br/>]]>OpenSource. No ads. No subscription. No vendor lock-in.</string>
<string name="Intro6Headline">Biztonságos</string>
<string name="Intro6Message"><![CDATA[<b>Titkosítás</b>]]> a legelterjedtebb algoritmusokkal. Az üzenetek a szervereden maradnak.</string>
<string name="Intro7Headline">Megbízható</string>
<string name="IntroStartMessaging">Kezdj csevegni!</string>
<!--plural-->
<plurals name="Members">
<item quantity="one">%d tag</item>
<item quantity="other">%d tag</item>
</plurals>
<plurals name="Contacts">
<item quantity="one">%d névjegy</item>
<item quantity="other">%d névjegy</item>
</plurals>
<plurals name="MeAndMembers">
<item quantity="one">Én és %d tag</item>
<item quantity="other">Én és %d tag</item>
</plurals>
<plurals name="NewMessages">
<item quantity="one">%d új üzenet</item>
<item quantity="other">%d új üzenet</item>
</plurals>
<plurals name="messages">
<item quantity="one">%d üzenet</item>
<item quantity="other">%d üzenet</item>
</plurals>
<plurals name="AreYouSureDeleteMessages">
<item quantity="one">%d üzenet törlése? Az üzenet a szerverről is törlődik.</item>
<item quantity="other">%d üzenet törlése? Az üzenetek a szerverről is törlődnek.</item>
</plurals>
<plurals name="NewMessagesInChats">
<!-- Translators: the first string placeholder "%s" gets replaced with the
text "%d new messages", so the complete sentence would be e.g.
"4 new messages in 2 chats". -->
<item quantity="one">%1$s %2$d beszélgetésben</item>
<item quantity="other">%1$s %2$d beszélgetésben</item>
</plurals>
<plurals name="Chats">
<item quantity="one">%d beszélgetés</item>
<item quantity="other">%d beszélgetés</item>
</plurals>
<plurals name="Minutes">
<item quantity="one">%d perc</item>
<item quantity="other">%d perc</item>
</plurals>
<plurals name="Hours">
<item quantity="one">%d óra</item>
<item quantity="other">%d óra</item>
</plurals>
<plurals name="Days">
<item quantity="one">%d nap</item>
<item quantity="other">%d nap</item>
</plurals>
<plurals name="Weeks">
<item quantity="one">%d hét</item>
<item quantity="other">%d hét</item>
</plurals>
<plurals name="Months">
<item quantity="one">%d hónap</item>
<item quantity="other">%d hónap</item>
</plurals>
<plurals name="MaxNotifications">
<!-- Translators: the second string placeholder "%s" gets replaced with the
text "%d minutes", so the complete sentence would be e.g.
"At most 8 notifications within 3 minutes". -->
<item quantity="one">Legfeljebb %1$d értesítés %2$s alatt</item>
<item quantity="other">Legfeljebb %1$d értesítés %2$s alatt</item>
</plurals>
<!--date formatters-->
<string name="formatterMonthYear">yyyy. MMMM</string>
<string name="formatterMonth">MMM. d.</string>
<string name="formatterYear">yyyy. M. d.</string>
<string name="chatDate">MMMM. d. EEEE</string>
<string name="chatFullDate">yyyy. MMMM. d. EEEE</string>
<string name="formatterWeek">EEEE</string>
<string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">a h:mm</string>
<string name="formatDateAtTime">%1$s %2$s</string>
<string name="AccountSettings">Fiókbeállítások</string>
<string name="MyAccount">Fiókom</string>
<string name="Yes">Igen</string>
<string name="No">Nem</string>
<string name="MyName">Nevem</string>
<string name="MyNameExplain">A címzetteknek megjelenő neved.\n\nHa nem adsz meg nevet, a címzett csak a fiókbeállításoknál megadott e-mail címedet látja.</string>
<string name="MyEmailAddress">E-mail címem</string>
<string name="Password">Jelszó</string>
<string name="SmtpPassword">SMTP jelszó</string>
<string name="FromAbove">fentről másolva</string>
<string name="SmtpLoginname">SMTP bejelentkezési név</string>
<string name="SmtpPort">SMTP port</string>
<string name="Automatic">automatikus</string>
<string name="ImapServer">IMAP szerver</string>
<string name="ImapLoginname">IMAP bejelentkezési név</string>
<string name="SmtpServer">SMTP szerver</string>
<string name="ImapPort">IMAP port</string>
<string name="InboxHeadline">Bejövő</string>
<string name="OutboxHeadline">Kimenő</string>
<string name="BasicSettings">Alap beállítások</string>
<string name="MyAccountExplain">Ismert e-mail szolgáltató esetén az alábbi beállításokat automatikusan meghatározzuk.</string>
<string name="MyAccountExplain2" >Előfordulhat, hogy az IMAP/SMTP szolgáltatást az email fiókod webes felületén engedélyezni kell.\n\nHa nem megy, kérj segítséget a szolgáltatótól vagy a barátaidtól.</string>
<string name="AccountNotConfigured">A fiók nincs beállítva</string>
<string name="AboutThisProgram">Delta Chat névjegye</string>
<string name="NotSet">Nincs beállítva</string>
<string name="NewChat">Új beszélgetés</string>
<string name="Deaddrop">Levelesláda</string>
<string name="Media">Média</string>
<string name="DeaddropInChatlist">Levelesláda megjelenítése a beszélgetéslistában</string>
<string name="MuteAlways">Mindig lenémítva</string>
<string name="AskStartChatWith">Beszélgetést indítasz <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> partnerrel?</string>
<string name="DeaddropHint">Beszélgetés indításához koppints a válasz-nyílra.</string>
<string name="NotYetImplemented">Ez a funkció nem érhető el vagy még nem készült el.</string>
<string name="DefaultStatusText">Delta Chat Messengerből küldve</string>
<string name="Name" >Név</string>
<string name="EmailAddress">E-mail cím</string>
<string name="CannotDeleteContact">A használatban lévő névjegyet nem lehet törölni, ehelyett letilthatod a partnert.</string>
<string name="BadEmailAddress">Rossz e-mail cím.</string>
<string name="ContactCreated">Névjegy létrehozva.</string>
<string name="ViewProfile">Profil megtekintése</string>
<!-- Translators: please use a very short string here, it should not much longer than
the string needed for video time+size (0:00, 12,3 Mib) -->
<string name="OneMoment">Egy pillanat…</string>
<string name="NoChatsHelp">Kezdj beszélgetni a jobb alsó \"új beszélgetés\" gombbal vagy több lehetőségért nyomd meg a menü gombot.</string>
<string name="ConfiguringAccount">Fiók beállítása…</string>
<string name="CannotConnect">Nem sikerül csatlakozni, ellenőrizd a beállításokat.</string>
<string name="Intro7Message">A <![CDATA[<b>Delta Chat</b>]]> üzleti használatra is biztonságos, kompatibilis és szabványokra épül.</string>
<string name="InviteMenuEntry">Meghívó küldése</string>
<string name="InviteText">A Delta Chat nevű programmal chatelek - %1$s - írhatsz nekem ezen a címen: %2$s</string>
<string name="AdvancedSettings">További beállítások</string>
<string name="AskResetNotifications" >Az oldal, a partnereid és csoportjaid minden értesítési és hangbeállítását visszaállítod?</string>
<string name="AttachFiles">Fájlok csatolása</string>
<string name="ErrGroupNameEmpty">Nevezd el a csoportot.</string>
<string name="MsgNewGroupDraftHint">Írj egy kezdőüzenetet, hogy a többiek válaszolhassanak a csoportban.\n\n• Nincs gond, ha nem használja minden tag a Delta Chatet.\n\n• Az első üzenet kézbesítése kicsit lassabb lehet.</string>
<string name="MsgNewGroupDraft">Üdv! Indítottam egy \"%1$s\" nevű csoportot magunknak.</string>
<string name="MsgGroupNameChanged">\"%1$s\" csoport új neve: \"%2$s\".</string>
<string name="MsgGroupImageChanged">A csoport képe megváltozott.</string>
<string name="MsgMemberAddedToGroup">%1$s hozzáadva a csoporthoz.</string>
<string name="MsgMemberRemovedFromToGroup">%1$s eltávolítva a csoportból.</string>
<string name="AskAddMemberToGroup">Hozzáadod a csoporthoz <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> partnert?</string>
<string name="AskRemoveMemberFromGroup">Kiveszed a csoportból <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> partnert?</string>
<string name="ErrSelfNotInGroup">Csoporttagnak kell lenned, hogy ezt megtehesd.</string>
<string name="MsgGroupLeft">Kiléptél a csoportból.</string>
<string name="NoMessagesHint">Üzenetküldés <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> partnernek:\n\n• Nincs gond, ha <![CDATA[<b>]]>%2$s<![CDATA[</b>]]> nem használja a Delta Chatet.\n\n• Az első üzenet kézbesítése kicsit lassabb lehet.</string>
<string name="SendNRcvReadReceipts">Tértivevények küldése és fogadása</string>
<string name="E2EEncryption">Végpontok közötti titkosítás</string>
<string name="E2EManagePrivateKeys">Privát kulcsok kezelése</string>
<string name="E2ECompareKeys">Kulcsok összehasonlítása</string>
<string name="ResetContactsKey">Partner kulcsának visszaállítása</string>
<string name="ForwardToTitle">Továbbítás…</string>
<string name="SelectContact">Válassz partnert</string>
<string name="DoneHint">Kész.</string>
<string name="FileNotFound">%1$s fájl nem található.</string>
</resources>
@@ -105,7 +105,6 @@
<string name="SendByEnter">Invia con tasto "invio"</string>
<string name="Language">Lingua</string>
<string name="Help">Domande frequenti</string>
<string name="DeleteLocalization">Eliminare la traduzione?</string>
<string name="Enabled">Abilitate</string>
<string name="Disabled">Disabilitata</string>
<string name="NotificationsService">Servizio keep-alive</string>
@@ -213,7 +212,7 @@
<string name="PrivacyTitle">Privacy</string>
<string name="SecurityTitle">Sicurezza</string>
<!--edit video view-->
<string name="SendVideo">Modifica video</string>
<string name="SendVideo">Invia video</string>
<string name="OriginalVideo">Video originale</string>
<string name="EditedVideo">Video modificato</string>
<string name="CompressVideo">Comprimi video</string>
@@ -0,0 +1,332 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="AppName">Delta Chat</string>
<string name="LanguageName">한국어</string>
<string name="LanguageNameInEnglish">Korean</string>
<string name="LanguageCode">ko</string>
<!--chats view-->
<string name="Settings">설정</string>
<string name="NewGroup">새 그룹</string>
<string name="Yesterday">어제</string>
<string name="NoResult">결과 없음</string>
<string name="NoChats">채팅방이 없습니다...</string>
<string name="WaitingForNetwork">연결 대기 중...</string>
<string name="Connecting">연결 중...</string>
<string name="Updating">업데이트 중...</string>
<string name="Search">검색</string>
<string name="MuteNotifications">알림 음소거</string>
<string name="UnmuteNotifications">음소거 해제</string>
<string name="Draft">임시저장</string>
<!--audio view-->
<string name="NoAudio">음악 라이브러리에 파일을 추가하셔야지만 볼 수 있습니다.</string>
<string name="AttachMusic">음악</string>
<!--documents view-->
<string name="SelectFile">파일 선택</string>
<string name="FreeOfTotal">%2$s 중 %1$s 남음</string>
<string name="ErrorHint">알 수 없는 오류</string>
<string name="AccessError">접근 오류</string>
<string name="NoFiles">파일이 없습니다</string>
<string name="NotMounted">스토리지가 마운트되지 않음</string>
<string name="UsbActive">USB 전송 활성</string>
<string name="InternalStorage">내부 저장소</string>
<string name="ExternalStorage">외부 저장소</string>
<string name="SystemRoot">시스템 루트</string>
<string name="SdCard">SD 카드</string>
<string name="Folder">폴더</string>
<string name="GalleryInfo">압축 없이 사진 보내기</string>
<!--chat view-->
<string name="ChatGallery">앨범</string>
<string name="ChatCamera">카메라</string>
<string name="NoMessages">메시지가 없습니다...</string>
<string name="ForwardedMessage">전달된 메시지</string>
<string name="From">보낸 사람</string>
<string name="NoRecent">최근에 사용한 이모티콘</string>
<string name="TypeMessage">메시지</string>
<string name="SlideToCancel">밀어서 취소</string>
<string name="SaveToDownloads">다운로드 폴더에 저장</string>
<string name="DeleteGif">GIF파일을 삭제하겠습니까?</string>
<string name="SaveToMusic">음악으로 저장</string>
<string name="Share">공유</string>
<string name="SendItems">%1$s 전송</string>
<string name="ClearRecentEmoji">최근 사용한 이모티콘 삭제?</string>
<string name="AddShortcut">바로 가기 추가</string>
<string name="ShortcutAdded">홈에 바로가기 추가</string>
<!--notification-->
<string name="Reply">답장</string>
<string name="ReplyToGroup">%1$s 그룹에 답장하기</string>
<string name="ReplyToUser">%1$s님에게 답장하기</string>
<!--contacts view-->
<string name="NoContacts">대화상대가 없습니다</string>
<string name="TodayAt">오늘</string>
<string name="YesterdayAt">어제</string>
<!--group create view-->
<string name="SendMessageTo">메시지 보내기...</string>
<string name="EnterGroupNamePlaceholder">그룹 이름 입력</string>
<!--group info view-->
<string name="SharedMedia">공유한 미디어</string>
<string name="AddMember">대화상대 추가</string>
<string name="Notifications">알림</string>
<string name="RemoveMember">채널에서 내보내기</string>
<!--contact info view-->
<string name="BlockContact">차단</string>
<string name="DeleteContact">삭제</string>
<string name="Info">정보</string>
<!--stickers view-->
<string name="Stickers">스티커</string>
<string name="AddStickers">스티커 추가</string>
<string name="AddToStickers">스티커 추가</string>
<string name="StickersRemove">삭제</string>
<string name="NoStickers">스티커가 아직 없음</string>
<!--settings view-->
<string name="TextSize">채팅 글자 크기</string>
<string name="EnableAnimations">화면 전환 효과 사용</string>
<string name="UnblockContact">차단 해제</string>
<string name="NoBlocked">차단한 친구가 없습니다</string>
<string name="NormalMessages">메시지 알림</string>
<string name="Alert">알림 사용</string>
<string name="MessagePreview">메시지 미리보기</string>
<string name="GroupMessages">그룹 알림</string>
<string name="Sound">>알림음</string>
<string name="InAppNotifications">앱 내 알림</string>
<string name="Vibrate">진동</string>
<string name="Reset">초기화</string>
<string name="ResetAllNotifications">모든 알림 설정 초기화</string>
<string name="NotificationsAndSounds">알림 및 소리</string>
<string name="BlockedContacts">차단 목록</string>
<string name="Default">기본값</string>
<string name="OnlyIfSilent">음소거일 중에만</string>
<string name="ChatBackground">채팅방 배경화면</string>
<string name="SendByEnter">엔터키로 메시지 전송</string>
<string name="Language">언어</string>
<string name="Help">자주 묻는 질문</string>
<string name="Enabled">켜기</string>
<string name="Disabled">끄기</string>
<string name="NotificationsService">항상 활성화 서비스</string>
<string name="NotificationsServiceInfo">시스템이나 사용자에 의하여 닫힌 앱을 재시작합니다. 해당 작업은 알림을 보여지게 합니다.</string>
<string name="NotificationsServiceConnection">백그라운드 연결</string>
<string name="NotificationsServiceConnectionInfo">알림을 받기 위하여 텔레그램 백그라운드 연결을 최소화로 유지합니다. 안정적인 알림을 유지합니다.</string>
<string name="LedColor">LED 색상</string>
<string name="BadgeNumber">앱 아이콘에 알림 개수 표시</string>
<string name="Short">짧게</string>
<string name="Long">길게</string>
<string name="SystemDefault">시스템 기본값</string>
<string name="RaiseToSpeak">기기를 들어 말하기</string>
<string name="EditName">이름 편집</string>
<string name="NotificationsPriority">우선순위</string>
<string name="NotificationsPriorityDefault">기본</string>
<string name="NotificationsPriorityLow">낮음</string>
<string name="NotificationsPriorityHigh">높음</string>
<string name="NotificationsPriorityMax">최우선</string>
<string name="RepeatNotifications">알림 반복</string>
<string name="NotificationsOther">기타</string>
<string name="InChatSound">채팅중 소리 설정</string>
<string name="SoundDefault">기본값</string>
<string name="VibrationDefault">기본값</string>
<string name="SmartNotifications">스마트 알림</string>
<string name="SmartNotificationsInfo">최대 %1$s번, %2$s번 이내 알림</string>
<string name="SmartNotificationsSoundAtMost">알림 최대치</string>
<string name="SmartNotificationsTimes"></string>
<string name="SmartNotificationsWithin">이내</string>
<string name="SmartNotificationsMinutes"></string>
<string name="DirectShare">직접 공유</string>
<string name="DirectShareInfo">공유 메뉴에서 최근 대화 보기</string>
<!--cache view-->
<string name="CacheSettings">캐시 설정</string>
<string name="LocalDatabase">로컬 데이터베이스</string>
<string name="LocalDatabaseClear">캐시된 텍스트 메시지를 삭제하시겠습니까?</string>
<string name="LocalDatabaseInfo">압축된 데이터베이스 및 캐시에 저장된 메시지를 로컬 데이터베이스에서 삭제하면 내부 저장공간이 증가합니다. 데이터베이스는 Telegram이 작동하는데 어느정도 필요함으로 완전히 삭제가 되지는 않습니다.\n\n이 작업은 완료되기까지 몇분정도 소요가 될 수 있습니다.</string>
<string name="ClearMediaCache">캐시 삭제</string>
<string name="CacheClear">삭제</string>
<string name="LocalCache">다른 파일</string>
<string name="CacheEmpty">없음</string>
<string name="KeepMedia">미디어 저장</string>
<string name="KeepMediaInfo">이 기간 동안 클라우드 채팅방에서 <![CDATA[<b>접근하지 않은</b>]]> 사진이나 동영상, 기타 파일 등은 공간 절약을 위해 이 기기에서 삭제됩니다.\n\n모든 파일은 Telegram 클라우드에 여전히 남으며 필요하시면 언제든 다시 다운로드하실 수 있습니다.</string>
<string name="KeepMediaForever">영원히</string>
<!--passcode view-->
<string name="Passcode">잠금코드 잠금</string>
<string name="ChangePasscode">잠금번호 변경</string>
<string name="ChangePasscodeInfo">잠금코드를 설정하셨을 경우, 대화방에 잠금 아이콘이 표시됩니다. 해당 아이콘을 클릭하여 텔레그램 잠금 설정을 할 수 있습니다.\n\n주의: 잠금코드를 잊어버렸을 경우 앱 삭제후 재설치를 해주셔야합니다. 이 경우 비밀대화 내용은 삭제가 됩니다.</string>
<string name="PasscodePIN">핀코드</string>
<string name="PasscodePassword">잠금번호</string>
<string name="EnterCurrentPasscode">현재 잠금코드 입력</string>
<string name="EnterNewFirstPasscode">잠금코드 입력</string>
<string name="EnterNewPasscode">새로운 잠금코드 입력</string>
<string name="EnterYourPasscode">잠금코드를 입력해주세요</string>
<string name="ReEnterYourPasscode">잠금코드 재입력</string>
<string name="PasscodeDoNotMatch">잠금코드가 정확하지 않습니다</string>
<string name="AutoLock">자동 잠금</string>
<string name="AutoLockInfo">일정 시간 후에 잠금코드 활성화</string>
<string name="AutoLockInTime">%1$s 후에</string>
<string name="UnlockFingerprint">지문으로 언락하기</string>
<string name="FingerprintInfo">지문인식 후 진행해주세요</string>
<string name="FingerprintNotRecognized">지문인식이 실패하였습니다. 다시 시도해주세요.</string>
<!--photo gallery view-->
<string name="SaveToGallery">앨범에 저장</string>
<string name="Of">%1$d / %2$d</string>
<string name="Gallery">앨범</string>
<string name="AllPhotos">모든 사진</string>
<string name="AllVideo">모든 동영상</string>
<string name="NoPhotos">사진이 없습니다.</string>
<string name="NoVideo">동영상이 아직 없음</string>
<string name="CropImage">사진 자르기</string>
<string name="EditImage">이미지 편집</string>
<string name="Enhance">향상</string>
<string name="Highlights">하이라이트</string>
<string name="Contrast">대비</string>
<string name="Exposure">노출</string>
<string name="Warmth">온기</string>
<string name="Saturation">채도</string>
<string name="Vignette">비네팅</string>
<string name="Shadows">그림자</string>
<string name="Grain">그레인</string>
<string name="Sharpen">선명</string>
<string name="Fade">흐리기</string>
<string name="Tint">색조</string>
<string name="TintShadows">새도우</string>
<string name="TintHighlights">하이라이트</string>
<string name="Curves">커브</string>
<string name="CurvesAll">모두</string>
<string name="CurvesRed">빨강</string>
<string name="CurvesGreen">초록</string>
<string name="CurvesBlue">파랑</string>
<string name="Blur">흐림</string>
<string name="BlurOff"></string>
<string name="BlurLinear">선형</string>
<string name="BlurRadial">방사형</string>
<string name="DiscardChanges">변경을 취소하시겠습니까?</string>
<string name="ClearSearch">검색기록을 지우시겠습니까?</string>
<string name="ClearButton">지우기</string>
<string name="PickerPhotos">사진</string>
<string name="PickerVideo">동영상</string>
<string name="AddCaption">설명 추가...</string>
<string name="PhotoCaption">사진 설명</string>
<string name="VideoCaption">동영상 설명</string>
<string name="Caption">설명</string>
<!--privacy settings-->
<string name="PrivacySettings">개인정보 및 보안</string>
<string name="PrivacyTitle">개인정보</string>
<string name="SecurityTitle">보안</string>
<!--edit video view-->
<string name="OriginalVideo">동영상 원본</string>
<string name="EditedVideo">편집한 동영상</string>
<string name="CompressVideo">동영상 크기 줄이기</string>
<!--button titles-->
<string name="Next">다음</string>
<string name="Back">뒤로</string>
<string name="Done">완료</string>
<string name="Open">열기</string>
<string name="Save">저장</string>
<string name="Cancel">취소</string>
<string name="Close">닫기</string>
<string name="Add">추가</string>
<string name="Edit">편집</string>
<string name="Send">보내기</string>
<string name="CopyToClipboard">복사</string>
<string name="Delete">삭제</string>
<string name="Forward">전달</string>
<string name="Retry">재전송</string>
<string name="FromCamera">사진 촬영</string>
<string name="FromGalley">앨범</string>
<string name="Set">설정</string>
<string name="OK">확인</string>
<string name="Crop">자르기</string>
<!--messages-->
<string name="AttachPhoto">사진</string>
<string name="AttachVideo">동영상</string>
<string name="AttachGif">GIF파일</string>
<string name="AttachContact">연락처</string>
<string name="AttachDocument">파일</string>
<string name="AttachSticker">스티커</string>
<string name="AttachVoiceMessage">음성 메시지</string>
<string name="FromSelf"></string>
<!--Alert messages-->
<string name="NoHandleAppInstalled">\'%1$s\' 파일 형식을 처리할 앱이 없습니다. 계속하려면 앱을 설치해 주세요.</string>
<string name="ContactAlreadyInGroup">이 사용자는 이미 그룹에 추가되었습니다.</string>
<string name="ForwardMessagesTo">%1$s님에게 메시지를 전달할까요?</string>
<string name="SendMessagesTo">%1$s님에게 메시지를 보낼까요?</string>
<string name="AreYouSureDeleteThisChat">채팅방을 삭제할까요?</string>
<string name="AreYouSureBlockContact">대화상대를 차단할까요?</string>
<string name="AreYouSureDeleteContact">대화상대를 삭제할까요?</string>
<!--permissions-->
<string name="PermissionContacts">Delta Chat은 여러 기기에서 친구와 메시지를 주고받을 수 있도록 회원님의 연락처 접근이 필요합니다.</string>
<string name="PermissionStorage">Delta Chat은 사진, 비디오, 음악 및 다양한 미디어를 공유 및 저장하기 위하여 스토리지 접근이 필요합니다.</string>
<string name="PermissionNoAudio">Delta Chat이 음성 메시지를 보내기 위하여 마이크에 대한 접근이 필요합니다.</string>
<string name="PermissionOpenSettings">설정</string>
<!--Intro view-->
<string name="IntroStartMessaging">시작하기</string>
<!--plural-->
<plurals name="Members">
<item quantity="one">대화상대 %1$d명</item>
<item quantity="other">대화상대 %1$d명</item>
</plurals>
<plurals name="Contacts">
<item quantity="one">%1$d명의 대화상대</item>
<item quantity="other">%1$d명의 대화상대</item>
</plurals>
<plurals name="MeAndMembers">
<item quantity="one">%1$d명의 대화상대</item>
<item quantity="other">%1$d명의 대화상대</item>
</plurals>
<plurals name="NewMessages">
<item quantity="zero">새 메시지 없음</item>
<item quantity="one">새 메시지 %1$d건</item>
<item quantity="other">새 메시지 %1$d건</item>
</plurals>
<plurals name="messages">
<item quantity="zero">새 메시지 없음</item>
<item quantity="one">새 메시지 %1$d건</item>
<item quantity="other">새 메시지 %1$d건</item>
</plurals>
<plurals name="Minutes">
<item quantity="one">%1$d분</item>
<item quantity="other">%1$d분</item>
</plurals>
<plurals name="Hours">
<item quantity="one">%1$d시간</item>
<item quantity="other">%1$d시간</item>
</plurals>
<plurals name="Days">
<item quantity="one">%1$d일</item>
<item quantity="other">%1$d일</item>
</plurals>
<plurals name="Weeks">
<item quantity="one">%1$d주</item>
<item quantity="other">%1$d주</item>
</plurals>
<plurals name="Months">
<item quantity="one">%1$d개월</item>
<item quantity="other">%1$d개월</item>
</plurals>
<!--date formatters-->
<string name="formatterMonthYear">MMMM yyyy</string>
<string name="formatterMonth">M\'월\' d\'일\'</string>
<string name="formatterYear">yyyy.MM.dd.</string>
<string name="chatDate">M\'월\' d\'일\' EEEE</string>
<string name="chatFullDate">yyyy\'년\' M\'월\' d\'일\' EEEE</string>
<string name="formatterWeek">EEEE</string>
<string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">a h:mm</string>
<string name="formatDateAtTime">%1$s %2$s</string>
<string name="Yes"></string>
<string name="No">아니</string>
<string name="InviteMenuEntry">친구 초대</string>
<string name="DeleteChat">채팅방 나가기</string>
<string name="DoneHint">성공!</string>
<string name="ForwardToTitle">채팅방 선택</string>
<string name="AskAddMemberToGroup">%1$s 님을 그룹에 추가할까요?</string>
<string name="NewContactTitle">대화상대 추가</string>
<string name="ReplyToContact">%1$s님에게 답장하기</string>
<string name="AdvancedSettings">고급 설정</string>
<string name="MyAccount">계정</string>
<string name="MyName">내 이름</string>
<string name="AccountSettings">계정 설정</string>
<string name="Password">암호</string>
<string name="MyEmailAddress">이메일 주소</string>
<string name="BasicSettings">기본 설정</string>
<string name="Deaddrop">사서함</string>
<string name="NewChat">채팅 시작</string>
<string name="Audio">음악</string>
</resources>
@@ -105,7 +105,6 @@
<string name="SendByEnter">Versturen met "Enter"</string>
<string name="Language">Taal</string>
<string name="Help">Veelgestelde vragen</string>
<string name="DeleteLocalization">Vertaling verwijderen?</string>
<string name="Enabled">Inschakelen</string>
<string name="Disabled">Uitgeschakeld</string>
<string name="NotificationsService">Meldingenservice</string>
@@ -213,7 +212,7 @@
<string name="PrivacyTitle">Privacy</string>
<string name="SecurityTitle">Veiligheid</string>
<!--edit video view-->
<string name="SendVideo">Video bewerken</string>
<string name="SendVideo">Video versturen</string>
<string name="OriginalVideo">Originele video</string>
<string name="EditedVideo">Bewerkte video</string>
<string name="CompressVideo">Video comprimeren</string>
@@ -108,7 +108,6 @@
<string name="SendByEnter">Wyślij wiadomość naciskając Enter</string>
<string name="Language">Język</string>
<string name="Help">Pomoc</string>
<string name="DeleteLocalization">Usunąć lokalizację?</string>
<string name="Enabled">Włączone</string>
<string name="Disabled">Wyłączony</string>
<string name="NotificationsService">Podtrzymywanie usługi</string>
@@ -216,7 +215,7 @@
<string name="PrivacyTitle">Prywatność</string>
<string name="SecurityTitle">Bezpieczeństwo</string>
<!--edit video view-->
<string name="SendVideo">Edycja wideo</string>
<string name="SendVideo">Wyślij wideo</string>
<string name="OriginalVideo">Oryginalne wideo</string>
<string name="EditedVideo">Edytowane wideo</string>
<string name="CompressVideo">Kompresuj wideo</string>
@@ -388,10 +387,10 @@
<string name="MyEmailAddress">Mój adres e-mail</string>
<string name="Password">Hasło</string>
<string name="SmtpPassword">SMTP hasło</string>
<string name="FromAbove">jak wyżej</string>
<string name="FromAbove">Jak wyżej</string>
<string name="SmtpLoginname">SMTP nazwa użytkownika</string>
<string name="SmtpPort">SMTP port</string>
<string name="Automatic">atomatycznie</string>
<string name="Automatic">Atomatycznie</string>
<string name="ImapServer">IMAP serwer</string>
<string name="ImapLoginname">IMAP nazwa użytkownika</string>
<string name="SmtpServer">SMTP serwer</string>
@@ -104,7 +104,6 @@
<string name="SendByEnter">Enviar usando \'Enter\'</string>
<string name="Language">Idioma</string>
<string name="Help">Perguntas frequentes</string>
<string name="DeleteLocalization">Apagar localização?</string>
<string name="Enabled">Ativado</string>
<string name="Disabled">Desativado</string>
<string name="NotificationsService">Serviço Manter-Ativo</string>
@@ -212,7 +211,7 @@
<string name="PrivacyTitle">Privacidade</string>
<string name="SecurityTitle">Segurança</string>
<!--edit video view-->
<string name="SendVideo">Editar Vídeo</string>
<string name="SendVideo">Enviar Vídeo</string>
<string name="OriginalVideo">Vídeo Original</string>
<string name="EditedVideo">Vídeo Editado</string>
<string name="CompressVideo">Compactar Vídeo</string>
@@ -341,10 +340,10 @@
<string name="MyEmailAddress">Meu endereço de e-mail</string>
<string name="Password">Senha</string>
<string name="SmtpPassword">Senha SMPT</string>
<string name="FromAbove">de acima</string>
<string name="FromAbove">De acima</string>
<string name="SmtpLoginname">Usuário SMTP</string>
<string name="SmtpPort">Porta SMTP</string>
<string name="Automatic">automático</string>
<string name="Automatic">Automático</string>
<string name="ImapServer">Servidor IMAP</string>
<string name="ImapLoginname">Usuário IMAP</string>
<string name="SmtpServer">Servidor SMTP</string>
@@ -108,7 +108,6 @@
<string name="SendByEnter">Send by "enter"</string>
<string name="Language">Language</string>
<string name="Help">Help</string>
<string name="DeleteLocalization">Delete localization?</string>
<string name="Enabled">On</string>
<string name="Disabled">Off</string>
<string name="NotificationsService">Keep-alive service</string>
@@ -366,10 +365,10 @@
<string name="MyEmailAddress">My e-mail address</string>
<string name="Password">Password</string>
<string name="SmtpPassword">SMTP password</string>
<string name="FromAbove">from above</string>
<string name="FromAbove">From above</string>
<string name="SmtpLoginname">SMTP loginname</string>
<string name="SmtpPort">SMTP port</string>
<string name="Automatic">automatic</string>
<string name="Automatic">Automatic</string>
<string name="ImapServer">IMAP server</string>
<string name="ImapLoginname">IMAP loginname</string>
<string name="SmtpServer">SMTP server</string>
@@ -377,8 +376,8 @@
<string name="InboxHeadline">Inbox</string>
<string name="OutboxHeadline">Outbox</string>
<string name="BasicSettings">Basic settings</string>
<string name="MyAccountExplain">For known e-mail providers, the following settings are determinated automatically.</string>
<string name="MyAccountExplain2" >Sometimes, IMAP/SMTP needs to be enabled in the e-mail web frontend.\n\nOn problems, ask your e-mail provider or your friends.</string>
<string name="MyAccountExplain">For known e-mail providers, additional settings are determinated automatically.</string>
<string name="MyAccountExplain2" >Sometimes, <![CDATA[<b>]]>IMAP needs to be enabled<![CDATA[</b>]]> in the e-mail web frontend.\n\nOn problems, ask your e-mail provider or your friends.</string>
<string name="AccountNotConfigured">Account not configured</string>
<string name="AboutThisProgram">About Delta Chat</string>
<string name="NotSet">Not set</string>
@@ -430,5 +429,8 @@
<string name="SelectContact">Choose a contact</string>
<string name="DoneHint">Done.</string>
<string name="FileNotFound">File %1$s not found.</string>
<string name="Error">Error: %1$s</string>
<string name="NoNetwork">Network not available.</string>
<string name="Audio">Audio</string>
</resources>